X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Ffile.c;h=d8773b19fe47fd23d6bbec2149679b123a79c139;hb=0ccd58fc03f40529f66190b1a41e92a732d2bda8;hp=7b3887e054d0bcb5e0e187c8e1e42691c4fadcd0;hpb=6715930654e06c4d2e66e718ea159079f71838f4;p=linux-2.6 diff --git a/fs/file.c b/fs/file.c index 7b3887e054..d8773b19fe 100644 --- a/fs/file.c +++ b/fs/file.c @@ -250,9 +250,18 @@ int expand_files(struct files_struct *files, int nr) struct fdtable *fdt; fdt = files_fdtable(files); + + /* + * N.B. For clone tasks sharing a files structure, this test + * will limit the total number of files that can be opened. + */ + if (nr >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) + return -EMFILE; + /* Do we need to expand? */ if (nr < fdt->max_fds) return 0; + /* Can we expand? */ if (nr >= sysctl_nr_open) return -EMFILE;