svn commit: r306232 - head/sys/kern

Mariusz Zaborski oshogbo at FreeBSD.org
Fri Sep 23 08:13:47 UTC 2016


Author: oshogbo
Date: Fri Sep 23 08:13:46 2016
New Revision: 306232
URL: https://svnweb.freebsd.org/changeset/base/306232

Log:
  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

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Fri Sep 23 07:51:01 2016	(r306231)
+++ head/sys/kern/kern_descrip.c	Fri Sep 23 08:13:46 2016	(r306232)
@@ -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 @@ get_locked:
 	if (error == 0)
 		fhold(*fpp);
 	FILEDESC_SUNLOCK(fdp);
-
+#endif
 	return (error);
 }
 


More information about the svn-src-head mailing list