1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00

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.
This commit is contained in:
Mateusz Guzik 2015-02-18 13:37:28 +00:00
parent 117c6e7cf2
commit 8fbda7f00b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=278956

View File

@ -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);
}