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:
oshogbo 2016-09-23 08:13:46 +00:00
parent 4541cd5240
commit a50a02f734

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