Skip to contentSkip to conversation

Possible bug in fs/read_write.c::rw_verify_area

AMD64 Bruno Ducrot 1 participant 1 message Nov 9, 2005 VFS

lore
Share & tools
lore
#0 lore raw

Hi all,

fs/read_write.c::rw_verify_area check if the count for a read/write is valid. Unfortunately, this check assume that a size_t is an int, which is wrong at least on AMD64 architecture.

This fix is not correct also in general: it is wrong to assume that size_t is a long int. A correct fix would be to introduce a new constant (say SSIZE_MAX) for each supported architecture and to use that contstant instead. I'm not an expert on this and it is why I don't do it (sorry). But at least the following patch is ok for more achitecture, I believe.

fs/read_write.c +1 -1
@@ -188,7 +188,7 @@ int rw_verify_area(int read_write, struc
 	struct inode *inode;
 	loff_t pos;
 
-	if (unlikely(count > INT_MAX))
+	if (unlikely(count > LONG_MAX))
 		goto Einval;
 	pos = *ppos;
 	if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
Signature · 4 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.