lkml.org 
[lkml]   [1999]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectfcheck()/fcheck_task() question.
Hello,

The <linux/file.h> contains two inlines:

/*
* Check whether the specified task has the fd open. Since the task
* may not have a files_struct, we must test for p->files != NULL.
*/
extern inline struct file * fcheck_task(struct task_struct *p, unsigned
int fd)
{
struct file * file = NULL;

if (p->files && fd < p->files->max_fds)
file = p->files->fd[fd];
return file;
}

/*
* Check whether the specified fd has an open file.
*/
extern inline struct file * fcheck(unsigned int fd)
{
struct file * file = NULL;

if (fd < current->files->max_fds)
file = current->files->fd[fd];
return file;
}

Correspondingly, why does fget(fd) use fcheck(fd) and not fcheck_task(fd,
current)? If there are any circumstances when p->files == NULL then it
should be made clear (e.g. to be used by malicious crackers to panic the
system from a simple userspace program). If, however, there is no such
possibility then it should also be made clear by removing the check in
fcheck_task().

Any thoughts?

Regards,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.aivazian.demon.co.uk


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

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