mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 08:44:41 +00:00 
			
		
		
		
	[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>
This commit is contained in:
		
							parent
							
								
									3d0a07e331
								
							
						
					
					
						commit
						30f04a4efa
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		|  | @ -501,11 +501,16 @@ int hostfs_commit_write(struct file *file, struct page *page, unsigned from, | |||
| 	long long start; | ||||
| 	int err = 0; | ||||
| 
 | ||||
| 	start = (long long) (page->index << PAGE_CACHE_SHIFT) + from; | ||||
| 	start = (((long long) page->index) << PAGE_CACHE_SHIFT) + from; | ||||
| 	buffer = kmap(page); | ||||
| 	err = write_file(FILE_HOSTFS_I(file)->fd, &start, buffer + from, | ||||
| 			 to - from); | ||||
| 	if(err > 0) err = 0; | ||||
| 
 | ||||
| 	/* Actually, if !err, write_file has added to-from to start, so, despite
 | ||||
| 	 * the appearance, we are comparing i_size against the _last_ written | ||||
| 	 * location, as we should. */ | ||||
| 
 | ||||
| 	if(!err && (start > inode->i_size)) | ||||
| 		inode->i_size = start; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Paolo 'Blaisorblade' Giarrusso
						Paolo 'Blaisorblade' Giarrusso