Fix rlimit check in precheck_file_write()
Subsystems (2)
PATCH 1/1 Fix rlimit check in precheck_file_write()
Remove a broken assumption that rlimits are 32 bits which can cause nasty things to happen on 64-bit machines if we try to write past the 2^32-1th character of a file and a larger file size limit exists.
mm/filemap.c +2 -2
@@ -3088,9 +3088,9 @@send_sig (SIGXFSZ , current,0 ); goto out; } -if (pos >0xFFFFFFFFULL || *count > limit - (u32 )pos) { +if (*count > limit - pos) {/* send_sig(SIGXFSZ, current, 0); */ - *count = limit - (u32 )pos; + *count = limit - pos; } }
Quoted 9 lines · Jason Uhlenkott
Remove a broken assumption that rlimits are 32 bits which can cause nasty things to happen on 64-bit machines if we try to write past the 2^32-1th character of a file and a larger file size limit exists.
Signed-off-by Jason Uhlenkott <[email protected]>
mm/filemap.c line 3094
Quoted 9 lines
mm/filemap.c +2
-2@@ -3088,9 +3088,9 @@send_sig (SIGXFSZ , current,0 ); goto out; } -if (pos >0xFFFFFFFFULL || *count > limit - (u32 )pos) { +if (*count > limit - pos) {/* send_sig(SIGXFSZ, current, 0); */ - *count = limit - (u32 )pos; + *count = limit - pos; }
Are you sure this is safe for all conceivable 32bit cases as well as your 64bit one ? I don't think it is looking at the overflow cases in the if that you removed checking of.
Alan
Quoted 7 lines · Alan Cox
Quoted 6 lines · Jason Uhlenkott
Remove a broken assumption that rlimits are 32 bits which can cause nasty things to happen on 64-bit machines if we try to write past the 2^32-1th character of a file and a larger file size limit exists.
Signed-off-by Jason Uhlenkott <[email protected]>
Quoted 16 lines
mm/filemap.c line 3094
Quoted 12 lines
mm/filemap.c +2
-2@@ -3088,9 +3088,9 @@send_sig (SIGXFSZ , current,0 ); goto out; } -if (pos >0xFFFFFFFFULL || *count > limit - (u32 )pos) { +if (*count > limit - pos) {/* send_sig(SIGXFSZ, current, 0); */ - *count = limit - (u32 )pos; + *count = limit - pos; }Are you sure this is safe for all conceivable 32bit cases as well as your 64bit one ? I don't think it is looking at the overflow cases in the if that you removed checking of.
We can't overflow -- immediately above this, we bail out if pos >= limit.