Revision 59771079c18c44e39106f0f30054025acafadb41 authored by Linus Torvalds on 19 December 2012, 15:18:35 UTC, committed by Linus Torvalds on 19 December 2012, 15:18:35 UTC
Commit 8dd2cb7e880d ("block: discard granularity might not be power of 2") changed a couple of 'binary and' operations into modulus operations. Which turned the harmless case of a zero discard_granularity into a possible divide-by-zero. The code also had a much more subtle bug: it was doing the modulus of a value in bytes using 'sector_t'. That was always conceptually wrong, but didn't actually matter back when the code assumed a power-of-two granularity: we only looked at the low bits anyway. But with potentially arbitrary sector numbers, using a 'sector_t' to express bytes is very very wrong: depending on configuration it limits the starting offset of the device to just 32 bits, and any overflow would result in a wrong value if the modulus wasn't a power-of-two. So re-write the code to not only protect against the divide-by-zero, but to do the starting sector arithmetic in sectors, and using the proper types. [ For any mathematicians out there: it also looks monumentally stupid to do the 'modulo granularity' operation *twice*, never mind having a "+ granularity" in the second modulus op. But that's the easiest way to avoid negative values or overflow, and it is how the original code was done. ] Reported-by: Ingo Molnar <mingo@kernel.org> Reported-by: Doug Anderson <dianders@chromium.org> Cc: Neil Brown <neilb@suse.de> Cc: Shaohua Li <shli@fusionio.com> Acked-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 752451f
File | Mode | Size |
---|---|---|
Makefile | -rw-r--r-- | 559 bytes |
inffast.c | -rw-r--r-- | 12.7 KB |
inffast.h | -rw-r--r-- | 403 bytes |
inffixed.h | -rw-r--r-- | 6.2 KB |
inflate.c | -rw-r--r-- | 30.6 KB |
inflate.h | -rw-r--r-- | 5.5 KB |
inflate_syms.c | -rw-r--r-- | 447 bytes |
inftrees.c | -rw-r--r-- | 13.0 KB |
inftrees.h | -rw-r--r-- | 2.3 KB |
infutil.c | -rw-r--r-- | 1.2 KB |
infutil.h | -rw-r--r-- | 657 bytes |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...