提交 7e41104f 编写于 作者: D Dan Carpenter 提交者: Xie XiuQi

eCryptfs: fix a couple type promotion bugs

commit 0bdf8a8245fdea6f075a5fede833a5fcf1b3466c upstream.

ECRYPTFS_SIZE_AND_MARKER_BYTES is type size_t, so if "rc" is negative
that gets type promoted to a high positive value and treated as success.

Fixes: 778aeb42 ("eCryptfs: Cleanup and optimize ecryptfs_lookup_interpose()")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
[tyhicks: Use "if/else if" rather than "if/if"]
Cc: stable@vger.kernel.org
Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 12a444c0
...@@ -1018,8 +1018,10 @@ int ecryptfs_read_and_validate_header_region(struct inode *inode) ...@@ -1018,8 +1018,10 @@ int ecryptfs_read_and_validate_header_region(struct inode *inode)
rc = ecryptfs_read_lower(file_size, 0, ECRYPTFS_SIZE_AND_MARKER_BYTES, rc = ecryptfs_read_lower(file_size, 0, ECRYPTFS_SIZE_AND_MARKER_BYTES,
inode); inode);
if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) if (rc < 0)
return rc >= 0 ? -EINVAL : rc; return rc;
else if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
return -EINVAL;
rc = ecryptfs_validate_marker(marker); rc = ecryptfs_validate_marker(marker);
if (!rc) if (!rc)
ecryptfs_i_size_init(file_size, inode); ecryptfs_i_size_init(file_size, inode);
...@@ -1381,8 +1383,10 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry, ...@@ -1381,8 +1383,10 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry,
ecryptfs_inode_to_lower(inode), ecryptfs_inode_to_lower(inode),
ECRYPTFS_XATTR_NAME, file_size, ECRYPTFS_XATTR_NAME, file_size,
ECRYPTFS_SIZE_AND_MARKER_BYTES); ECRYPTFS_SIZE_AND_MARKER_BYTES);
if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) if (rc < 0)
return rc >= 0 ? -EINVAL : rc; return rc;
else if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
return -EINVAL;
rc = ecryptfs_validate_marker(marker); rc = ecryptfs_validate_marker(marker);
if (!rc) if (!rc)
ecryptfs_i_size_init(file_size, inode); ecryptfs_i_size_init(file_size, inode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册