The patch titled revert "rlimit: permit setting RLIMIT_NOFILE to RLIM_INFINITY" has been added to the -mm tree. Its filename is revert-rlimit-permit-setting-rlimit_nofile-to-rlim_infinity.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: revert "rlimit: permit setting RLIMIT_NOFILE to RLIM_INFINITY" From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Revert commit 0c2d64fb6cae9aae480f6a46cfe79f8d7d48b59f Author: Adam Tkac <vonsch@xxxxxxxxx> AuthorDate: Wed Oct 15 22:01:45 2008 -0700 Commit: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> CommitDate: Thu Oct 16 11:21:31 2008 -0700 rlimit: permit setting RLIMIT_NOFILE to RLIM_INFINITY because it causes (arguably poorly designed) existing userspace to spend interminable periods closing billions of not-open file descriptors. We could bring this back, with some sort of opt-in tunable in /proc, which defaults to "off". Peter's alanysis follows: : I spent several hours trying to get to the bottom of a serious : performance issue that appeared on one of our servers after upgrading to : 2.6.28. In the end it's what could be considered a userspace bug that : was triggered by a change in 2.6.28. Since this might also affect other : people I figured I'd at least document what I found here, and maybe we : can even do something about it: : : : So, I upgraded some of debian.org's machines to 2.6.28.1 and immediately : the team maintaining our ftp archive complained that one of their : scripts that previously ran in a few minutes still hadn't even come : close to being done after an hour or so. Downgrading to 2.6.27 fixed : that. : : Turns out that script is forking a lot and something in it or python or : whereever closes all the file descriptors it doesn't want to pass on. : That is, it starts at zero and goes up to ulimit -n/RLIMIT_NOFILE and : closes them all with a few exceptions. : : Turns out that takes a long time when your limit -n is now 2^20 (1048576). : : With 2.6.27.* the ulimit -n was the standard 1024, but with 2.6.28 it is : now a thousand times that. : : 2.6.28 included a patch titled "rlimit: permit setting RLIMIT_NOFILE to : RLIM_INFINITY" (0c2d64fb6cae9aae480f6a46cfe79f8d7d48b59f)[1] that : allows, as the title implies, to set the limit for number of files to : infinity. : : Closer investigation showed that the broken default ulimit did not apply : to "system" processes (like stuff started from init). In the end I : could establish that all processes that passed through pam_limit at one : point had the bad resource limit. : : Apparently the pam library in Debian etch (4.0) initializes the limits : to some default values when it doesn't have any settings in limit.conf : to override them. Turns out that for nofiles this is RLIM_INFINITY. : Commenting out "case RLIMIT_NOFILE" in pam_limit.c:267 of our pam : package version 0.79-5 fixes that - tho I'm not sure what side effects : that has. : : Debian lenny (the upcoming 5.0 version) doesn't have this issue as it : uses a different pam (version). Reported-by: Peter Palfrader <weasel@xxxxxxxxxx> Cc: Adam Tkac <vonsch@xxxxxxxxx> Cc: Michael Kerrisk <mtk.manpages@xxxxxxxxxxxxxx> Cc: <stable@xxxxxxxxxx> [2.6.28.x] Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/sys.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff -puN kernel/sys.c~revert-rlimit-permit-setting-rlimit_nofile-to-rlim_infinity kernel/sys.c --- a/kernel/sys.c~revert-rlimit-permit-setting-rlimit_nofile-to-rlim_infinity +++ a/kernel/sys.c @@ -1525,22 +1525,14 @@ SYSCALL_DEFINE2(setrlimit, unsigned int, return -EINVAL; if (copy_from_user(&new_rlim, rlim, sizeof(*rlim))) return -EFAULT; + if (new_rlim.rlim_cur > new_rlim.rlim_max) + return -EINVAL; old_rlim = current->signal->rlim + resource; if ((new_rlim.rlim_max > old_rlim->rlim_max) && !capable(CAP_SYS_RESOURCE)) return -EPERM; - - if (resource == RLIMIT_NOFILE) { - if (new_rlim.rlim_max == RLIM_INFINITY) - new_rlim.rlim_max = sysctl_nr_open; - if (new_rlim.rlim_cur == RLIM_INFINITY) - new_rlim.rlim_cur = sysctl_nr_open; - if (new_rlim.rlim_max > sysctl_nr_open) - return -EPERM; - } - - if (new_rlim.rlim_cur > new_rlim.rlim_max) - return -EINVAL; + if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open) + return -EPERM; retval = security_task_setrlimit(resource, &new_rlim); if (retval) _ Patches currently in -mm which might be from akpm@xxxxxxxxxxxxxxxxxxxx are origin.patch kprobes-fix-module-compilation-error-with-config_kprobes=n.patch i-need-old-gcc.patch linux-next.patch next-remove-localversion.patch linux-next-git-rejects.patch acpi-fix-pmtimer-overflow-which-makes-cx-states-time-incorrect-checkpatch-fixes.patch thinkpad-acpi-split-delayed-leds-stuff-clean-up-code-checkpatch-fixes.patch x86-define-arch_want_frame_pointers-fix.patch drivers-consolidate-driver_probe_done-loops-into-one-place-fix.patch drivers-consolidate-driver_probe_done-loops-into-one-place-checkpatch-fixes.patch clocksource-pass-clocksource-to-read-callback.patch mtd-rbtx4939-add-mtd-support-fix.patch pci-quirks-unhide-overflow-device-on-i828675p-pe-chipsets.patch raw-fix-rawctl-compat-ioctls-breakage-on-amd64-and-itanic.patch revert-rlimit-permit-setting-rlimit_nofile-to-rlim_infinity.patch scsi-dpt_i2o-is-bust-on-ia64.patch acpi-dock-dont-eval-_sta-on-every-show_docked-sysfs-read-simplification.patch nommu-fix-a-number-of-issues-with-the-per-mm-vma-patch.patch page_fault-retry-with-nopage_retry.patch page_fault-retry-with-nopage_retry-fix.patch page_fault-retry-with-nopage_retry-fix-fix.patch mm-add-proc-controls-for-pdflush-threads-fix.patch mm-add-proc-controls-for-pdflush-threads-fix-fix.patch proc-pid-maps-dont-show-pgoff-of-pure-anon-vmas-checkpatch-fixes.patch rtc-convert-leap_year-into-an-inline.patch rtc-add-platform-driver-for-efi-fix.patch cpuset-fix-allocating-page-cache-slab-object-on-the-unallowed-node-when-memory-spread-is-set-checkpatch-fixes.patch pids-document-task_pgrp-task_session-is-not-safe-without-tasklist-rcu-fix.patch kexec-add-dmesg-log-symbols-to-proc-vmcoreinfo-lists-fix.patch nilfs2-integrated-block-mapping-remove-nilfs-bmap-wrapper-macros-checkpatch-fixes.patch nilfs2-inode-operations-fix.patch nilfs2-pathname-operations-fix.patch nilfs2-super-block-operations-fix.patch reiser4.patch reiser4-remove-simple_prepare_write-usage-checkpatch-fixes.patch slab-leaks3-default-y.patch put_bh-debug.patch shrink_slab-handle-bad-shrinkers.patch getblk-handle-2tb-devices.patch getblk-handle-2tb-devices-fix.patch undeprecate-pci_find_device.patch notify_change-callers-must-hold-i_mutex.patch drivers-net-bonding-bond_sysfsc-suppress-uninitialized-var-warning.patch w1-build-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html