Re: [PATCH] Broken NR_RESERVED_FILES

From: Tigran Aivazian (tigran@veritas.com)
Date: Thu Dec 07 2000 - 07:53:29 EST


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/



This archive was generated by hypermail 2b29 : Thu Dec 07 2000 - 21:00:17 EST