Blame SOURCES/0003-eCryptfs-fix-a-couple-type-promotion-bugs.patch

Kmods SIG c540c3
From 0bdf8a8245fdea6f075a5fede833a5fcf1b3466c Mon Sep 17 00:00:00 2001
Kmods SIG c540c3
From: Dan Carpenter <dan.carpenter@oracle.com>
Kmods SIG c540c3
Date: Wed, 4 Jul 2018 12:35:56 +0300
Kmods SIG c540c3
Subject: [Backport 0bdf8a8245fd] eCryptfs: fix a couple type promotion bugs
Kmods SIG c540c3
Kmods SIG c540c3
ECRYPTFS_SIZE_AND_MARKER_BYTES is type size_t, so if "rc" is negative
Kmods SIG c540c3
that gets type promoted to a high positive value and treated as success.
Kmods SIG c540c3
Kmods SIG c540c3
Fixes: 778aeb42a708 ("eCryptfs: Cleanup and optimize ecryptfs_lookup_interpose()")
Kmods SIG c540c3
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Kmods SIG c540c3
[tyhicks: Use "if/else if" rather than "if/if"]
Kmods SIG c540c3
Cc: stable@vger.kernel.org
Kmods SIG c540c3
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Kmods SIG c540c3
---
Kmods SIG c540c3
 src/crypto.c | 12 ++++++++----
Kmods SIG c540c3
 1 file changed, 8 insertions(+), 4 deletions(-)
Kmods SIG c540c3
Kmods SIG c540c3
diff --git a/src/crypto.c b/src/crypto.c
Kmods SIG c540c3
index 4dd842f728465591cc7982d635f544c0084b064a..708f931c36f14adace91af82229a6043386c9baf 100644
Kmods SIG c540c3
--- a/src/crypto.c
Kmods SIG c540c3
+++ b/src/crypto.c
Kmods SIG c540c3
@@ -1018,8 +1018,10 @@ int ecryptfs_read_and_validate_header_region(struct inode *inode)
Kmods SIG c540c3
 
Kmods SIG c540c3
 	rc = ecryptfs_read_lower(file_size, 0, ECRYPTFS_SIZE_AND_MARKER_BYTES,
Kmods SIG c540c3
 				 inode);
Kmods SIG c540c3
-	if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
Kmods SIG c540c3
-		return rc >= 0 ? -EINVAL : rc;
Kmods SIG c540c3
+	if (rc < 0)
Kmods SIG c540c3
+		return rc;
Kmods SIG c540c3
+	else if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
Kmods SIG c540c3
+		return -EINVAL;
Kmods SIG c540c3
 	rc = ecryptfs_validate_marker(marker);
Kmods SIG c540c3
 	if (!rc)
Kmods SIG c540c3
 		ecryptfs_i_size_init(file_size, inode);
Kmods SIG c540c3
@@ -1381,8 +1383,10 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry,
Kmods SIG c540c3
 				     ecryptfs_inode_to_lower(inode),
Kmods SIG c540c3
 				     ECRYPTFS_XATTR_NAME, file_size,
Kmods SIG c540c3
 				     ECRYPTFS_SIZE_AND_MARKER_BYTES);
Kmods SIG c540c3
-	if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
Kmods SIG c540c3
-		return rc >= 0 ? -EINVAL : rc;
Kmods SIG c540c3
+	if (rc < 0)
Kmods SIG c540c3
+		return rc;
Kmods SIG c540c3
+	else if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
Kmods SIG c540c3
+		return -EINVAL;
Kmods SIG c540c3
 	rc = ecryptfs_validate_marker(marker);
Kmods SIG c540c3
 	if (!rc)
Kmods SIG c540c3
 		ecryptfs_i_size_init(file_size, inode);
Kmods SIG c540c3
-- 
Kmods SIG c540c3
2.31.1
Kmods SIG c540c3