已合并
add file verification to OpenHarmony-6.0-Release #200
zfeixiang创建于 3月12日
add file verification to OpenHarmony-6.0-Release #200
已合并
共 1 个文件变更+7-1
| @@ -224,6 +224,7 @@ int elf_file_enable_fs_verity(struct file *file) | |||
| 224 | code_sign_log_error("alloc mem for path_buf failed"); | 224 | code_sign_log_error("alloc mem for path_buf failed"); |
| 225 | return -ENOMEM; | 225 | return -ENOMEM; |
| 226 | } | 226 | } |
| 227 | + struct inode *original_inode = file_inode(file); | ||
| 227 | int err = 0; | 228 | int err = 0; |
| 228 | char *real_path = file_path(file, path_buf, PATH_MAX - 1); | 229 | char *real_path = file_path(file, path_buf, PATH_MAX - 1); |
| 229 | if (IS_ERR_OR_NULL(real_path)) { | 230 | if (IS_ERR_OR_NULL(real_path)) { |
| @@ -242,7 +243,12 @@ int elf_file_enable_fs_verity(struct file *file) | |||
| 242 | if (!inode) { | 243 | if (!inode) { |
| 243 | code_sign_log_error("file_inode failed"); | 244 | code_sign_log_error("file_inode failed"); |
| 244 | err = -EFAULT; | 245 | err = -EFAULT; |
| 245 | - goto filp_close_out;; | 246 | + goto filp_close_out; |
| 247 | + } | ||
| 248 | + if (!original_inode || inode->i_ino != original_inode->i_ino || inode->i_sb != original_inode->i_sb) { | ||
| 249 | + code_sign_log_error("file_inode is inconsistent"); | ||
| 250 | + err = -EFAULT; | ||
| 251 | + goto filp_close_out; | ||
| 246 | } | 252 | } |
| 247 | 253 | ||
| 248 | long long fsize = inode->i_size; | 254 | long long fsize = inode->i_size; |