lkml.org 
[lkml]   [2000]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Broken NR_RESERVED_FILES
On Thu, 7 Dec 2000, Szabolcs Szakacsits wrote:
> Reserved fd's for superuser doesn't work.

It does actually work, but remember that the concept of "reserved file
structures for superuser" is defined as "file structures to be taken from
the freelist" whereas your patch below:

> + total_free = max_files - nr_files + nr_free_files;
> + if (total_free > NR_RESERVED_FILES || (total_free && !current->euid)) {
> + if (nr_free_files) {
> + used_one:
> + f = free_filps;
> + remove_filp(f);
> + nr_free_files--;
> + new_one:
> + memset(f, 0, sizeof(*f));
> + f->f_count = 1;
> + f->f_version = ++global_event;
> + f->f_uid = current->fsuid;
> + f->f_gid = current->fsgid;
> + put_inuse(f);
> + return f;
> + }
> + /*
> + * Allocate a new one if we're below the limit.
> + */
> f = kmem_cache_alloc(filp_cache, SLAB_KERNEL);

allows one to allocate a file structure from the filp_cache slab cache if
one is a superuser. That is not a "fix" -- it is a serious re-definition
of semantics of 'freelist'. There are even books (Understanding the Linux
Kernel by Bovet et all) which describe this freelist in the current
context so your patch will require updates to the books.

Having said that, it is probably a good idea to allow superuser to
allocate new file structures... just remember that you have just
_rewritten_ get_empty_filp()'s rules completely and not "fixed" them.

Regards,
Tigran

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:51    [W:0.035 / U:2.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site