Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] uml: hostfs - fix possible PAGE_CACHE_SHIFT overflows

Prevent page->index << PAGE_CACHE_SHIFT from overflowing.

There is a casting there, but was added without care, so it's at the wrong
place. Note the extra parens around the shift - "+" is higher precedence than
"<<", leading to a GCC warning which saved all us.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Paolo 'Blaisorblade' Giarrusso and committed by
Linus Torvalds
30f04a4e 3d0a07e3

+6 -1
+6 -1
fs/hostfs/hostfs_kern.c
··· 501 501 long long start; 502 502 int err = 0; 503 503 504 - start = (long long) (page->index << PAGE_CACHE_SHIFT) + from; 504 + start = (((long long) page->index) << PAGE_CACHE_SHIFT) + from; 505 505 buffer = kmap(page); 506 506 err = write_file(FILE_HOSTFS_I(file)->fd, &start, buffer + from, 507 507 to - from); 508 508 if(err > 0) err = 0; 509 + 510 + /* Actually, if !err, write_file has added to-from to start, so, despite 511 + * the appearance, we are comparing i_size against the _last_ written 512 + * location, as we should. */ 513 + 509 514 if(!err && (start > inode->i_size)) 510 515 inode->i_size = start; 511 516