Skip to contentSkip to conversation

fs: Fix internal type confusion in getdents system calls

PATCH New Florian Weimer 1 participant 1 message Jun 27, 2019 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: Fix internal type confusion in getdents system calls

The callback functions use a signed int type, but the callers have only verified the value as an unsigned type. This should be only a cosmetic change because if the value wraps around, this error check catches it:

	if (reclen > buf->count)
		return -EINVAL;

But it should be clearer to prevent the wrap-around.

---
 fs/readdir.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/readdir.c +3 -3
index 2f6a4534e0df..d344061e387e 100644
@@ -159,7 +159,7 @@ struct getdents_callback {
 	struct dir_context ctx;
 	struct linux_dirent __user * current_dir;
 	struct linux_dirent __user * previous;
-	int count;
+	unsigned int count;
 	int error;
 };
 
@@ -246,7 +246,7 @@ struct getdents_callback64 {
 	struct dir_context ctx;
 	struct linux_dirent64 __user * current_dir;
 	struct linux_dirent64 __user * previous;
-	int count;
+	unsigned int count;
 	int error;
 };
 
@@ -413,7 +413,7 @@ struct compat_getdents_callback {
 	struct dir_context ctx;
 	struct compat_linux_dirent __user *current_dir;
 	struct compat_linux_dirent __user *previous;
-	int count;
+	unsigned int count;
 	int error;
 };
 
Signature · 1 line
2.21.0