Sigh the patch that I sent earlier will make swapon fail when adding more
entries if 32 entries have been defined before even if some of these are
later freed. Plus maybe we better leave the probing intact for arches that
support less than 32 swap devices and also return -EPERM like before. I
guess we need this one instead:
Do proper boundary checking in sys_swapon().
sys_swapon currently does not limit the number of swap devices. It may as
a result overwrite memory following the swap_info array and get into
entanglements with page migration since it may usethe swap types reserved
for page migration.
Fix this by limiting the number of swap devices in swapon to
MAX_SWAPFILES
Signed-off-by: Christoph Lameter <[email protected]>
Index: linux-2.6.17-rc5-mm2/mm/swapfile.c
===================================================================
--- linux-2.6.17-rc5-mm2.orig/mm/swapfile.c 2006-06-01 10:03:07.127259731 -0700
+++ linux-2.6.17-rc5-mm2/mm/swapfile.c 2006-06-05 13:40:45.887291175 -0700
@@ -1408,8 +1408,13 @@ asmlinkage long sys_swapon(const char __
spin_unlock(&swap_lock);
goto out;
}
- if (type >= nr_swapfiles)
+ if (type >= nr_swapfiles) {
+ if (nr_swapfiles >= MAX_SWAPFILES) {
+ spin_unlock(&swap_lock);
+ goto out;
+ }
nr_swapfiles = type+1;
+ }
INIT_LIST_HEAD(&p->extent_list);
p->flags = SWP_USED;
p->swap_file = NULL;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]