1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-22 11:17:19 +00:00

fd: fix up fget_cap

If the kernel is not compiled with the CAPABILITIES kernel options
fget_unlocked doesn't return the sequence number so fd_modify will
always report modification, in that case we got infinity loop.

Reported by:	br
Reviewed by:	mjg
Tested by:	br, def
This commit is contained in:
Mariusz Zaborski 2016-09-23 08:13:46 +00:00
parent 3a970562d7
commit ad5e83dd3c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306232

View File

@ -2480,12 +2480,16 @@ int
fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
struct file **fpp, struct filecaps *havecapsp)
{
struct filedesc *fdp;
struct file *fp;
struct filedesc *fdp = td->td_proc->p_fd;
int error;
#ifndef CAPABILITIES
error = fget_unlocked(fdp, fd, needrightsp, fpp, NULL);
if (error == 0 && havecapsp != NULL)
filecaps_fill(havecapsp);
#else
struct file *fp;
seq_t seq;
fdp = td->td_proc->p_fd;
for (;;) {
error = fget_unlocked(fdp, fd, needrightsp, &fp, &seq);
if (error != 0)
@ -2513,7 +2517,7 @@ fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
if (error == 0)
fhold(*fpp);
FILEDESC_SUNLOCK(fdp);
#endif
return (error);
}