diff options
| author | Eric Sandeen <[email protected]> | 2006-12-07 04:33:06 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2006-12-07 16:39:23 +0000 |
| commit | 5d1854e15ee979f8e27330f0d3ce5e2703afa1dc (patch) | |
| tree | 8aff9641966020284218f2cdd75fd3b7bfc2babc /security/selinux/hooks.c | |
| parent | [PATCH] silence unused pgdat warning from alloc_bootmem_node and friends (diff) | |
| download | kernel-5d1854e15ee979f8e27330f0d3ce5e2703afa1dc.tar.gz kernel-5d1854e15ee979f8e27330f0d3ce5e2703afa1dc.zip | |
[PATCH] reject corrupt swapfiles earlier
The fsfuzzer found this; with a corrupt small swapfile that claims to have
many pages:
[root]# file swap.741.img
swap.741.img: Linux/i386 swap file (new style) 1 (4K pages) size 1040191487 pages
[root]# ls -l swap.741.img
-rw-r--r-- 1 root root 16777216 Nov 22 05:18 swap.741.img
sys_swapon() will try to vmalloc all those pages, and -then- check to see if
the file is actually that large:
if (!(p->swap_map = vmalloc(maxpages * sizeof(short)))) {
<snip>
if (swapfilesize && maxpages > swapfilesize) {
printk(KERN_WARNING
"Swap area shorter than signature indicates\n");
It seems to me that it would make more sense to move this test up before
the vmalloc, with the other checks, to avoid the OOM-killer in this
situation...
Signed-off-by: Eric Sandeen <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'security/selinux/hooks.c')
0 files changed, 0 insertions, 0 deletions
