From 8fbda7f00bd2570deacd3bafd85c6e8d06c44e60 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 18 Feb 2015 13:37:28 +0000 Subject: [PATCH] filedesc: obtain a stable copy of credentials in fget_unlocked This was broken in r278930. While here tidy up fget_mmap to use fdp from local var instead of obtaining the same pointer from td. --- sys/kern/kern_descrip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index a84a478e4e9b..42ca1efda41f 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2337,7 +2337,7 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, u_int count; #ifdef CAPABILITIES seq_t seq; - cap_rights_t *haverights; + cap_rights_t haverights; int error; #endif @@ -2356,7 +2356,7 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, #ifdef CAPABILITIES seq = seq_read(fd_seq(fdt, fd)); fde = &fdt->fdt_ofiles[fd]; - haverights = cap_rights_fde(fde); + haverights = *cap_rights_fde(fde); fp = fde->fde_file; if (!seq_consistent(fd_seq(fdt, fd), seq)) { cpu_spinwait(); @@ -2369,7 +2369,7 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, return (EBADF); #ifdef CAPABILITIES if (needrightsp != NULL) { - error = cap_check(haverights, needrightsp); + error = cap_check(&haverights, needrightsp); if (error != 0) return (error); } @@ -2505,7 +2505,7 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp, */ if (maxprotp != NULL) *maxprotp = cap_rights_to_vmprot(cap_rights(fdp, fd)); - if (!fd_modified(td->td_proc->p_fd, fd, seq)) + if (!fd_modified(fdp, fd, seq)) break; fdrop(*fpp, td); }