Messages in this thread Patch in this message | | | Subject | [RFC][PATCH 12/20] fcntl: Update fcntl to work with pspaces. | From | (Eric W. Biederman) | Date | Mon, 06 Feb 2006 12:54:37 -0700 |
| |
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
fs/fcntl.c | 25 ++++++++++++++++--------- include/linux/fs.h | 1 + 2 files changed, 17 insertions(+), 9 deletions(-)
34f261442c7ac3c160830b86aefd5b15df68de9d diff --git a/fs/fcntl.c b/fs/fcntl.c index 5f96786..0a41df8 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -18,6 +18,7 @@ #include <linux/ptrace.h> #include <linux/signal.h> #include <linux/rcupdate.h> +#include <linux/pspace.h> #include <asm/poll.h> #include <asm/siginfo.h> @@ -248,11 +249,14 @@ static int setfl(int fd, struct file * f return error; } -static void f_modown(struct file *filp, unsigned long pid, +static void f_modown(struct file *filp, struct pspace *pspace, unsigned long pid, uid_t uid, uid_t euid, int force) { write_lock_irq(&filp->f_owner.lock); if (force || !filp->f_owner.pid) { + put_pspace(filp->f_owner.pspace); + get_pspace(pspace); + filp->f_owner.pspace = pspace; filp->f_owner.pid = pid; filp->f_owner.uid = uid; filp->f_owner.euid = euid; @@ -268,7 +272,7 @@ int f_setown(struct file *filp, unsigned if (err) return err; - f_modown(filp, arg, current->uid, current->euid, force); + f_modown(filp, current->pspace, arg, current->uid, current->euid, force); return 0; } @@ -276,7 +280,7 @@ EXPORT_SYMBOL(f_setown); void f_delown(struct file *filp) { - f_modown(filp, 0, 0, 0, 1); + f_modown(filp, NULL, 0, 0, 0, 1); } static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, @@ -318,6 +322,9 @@ static long do_fcntl(int fd, unsigned in * to fix this will be in libc. */ err = filp->f_owner.pid; + /* Don't return an owner in a different pspace */ + if (filp->f_owner.pspace != current->pspace) + err = 0; force_successful_syscall_return(); break; case F_SETOWN: @@ -478,14 +485,14 @@ void send_sigio(struct fown_struct *fown read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_pid(fown->pspace, pid); if (p) { send_sigio_to_task(p, fown, fd, band); } } else { - do_each_task_pid(-pid, PIDTYPE_PGID, p) { + do_each_task_pid(fown->pspace, -pid, PIDTYPE_PGID, p) { send_sigio_to_task(p, fown, fd, band); - } while_each_task_pid(-pid, PIDTYPE_PGID, p); + } while_each_task_pid(fown->pspace, -pid, PIDTYPE_PGID, p); } read_unlock(&tasklist_lock); out_unlock_fown: @@ -513,14 +520,14 @@ int send_sigurg(struct fown_struct *fown read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_pid(fown->pspace, pid); if (p) { send_sigurg_to_task(p, fown); } } else { - do_each_task_pid(-pid, PIDTYPE_PGID, p) { + do_each_task_pid(fown->pspace, -pid, PIDTYPE_PGID, p) { send_sigurg_to_task(p, fown); - } while_each_task_pid(-pid, PIDTYPE_PGID, p); + } while_each_task_pid(fown->pspace, -pid, PIDTYPE_PGID, p); } read_unlock(&tasklist_lock); out_unlock_fown: diff --git a/include/linux/fs.h b/include/linux/fs.h index e059da9..cabb1b6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -589,6 +589,7 @@ extern struct block_device *I_BDEV(struc struct fown_struct { rwlock_t lock; /* protects pid, uid, euid fields */ + struct pspace *pspace; /* process space of owner pid */ int pid; /* pid or -pgrp where SIGIO should be sent */ uid_t uid, euid; /* uid/euid of process setting the owner */ void *security; -- 1.1.5.g3480 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |