Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jul 2019 01:00:28 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r349776 - stable/11/sys/kern
Message-ID:  <201907060100.x6610SjY052230@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Sat Jul  6 01:00:28 2019
New Revision: 349776
URL: https://svnweb.freebsd.org/changeset/base/349776

Log:
  MFC r349547:
  Use a consistent snapshot of the fd's rights in fget_mmap().

Modified:
  stable/11/sys/kern/kern_descrip.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/kern_descrip.c
==============================================================================
--- stable/11/sys/kern/kern_descrip.c	Sat Jul  6 01:00:11 2019	(r349775)
+++ stable/11/sys/kern/kern_descrip.c	Sat Jul  6 01:00:28 2019	(r349776)
@@ -2687,6 +2687,7 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rig
 	if (maxprotp != NULL)
 		*maxprotp = VM_PROT_ALL;
 #else
+	cap_rights_t fdrights;
 	struct filedesc *fdp = td->td_proc->p_fd;
 	seq_t seq;
 
@@ -2695,15 +2696,18 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rig
 		error = _fget(td, fd, fpp, 0, rightsp, &seq);
 		if (error != 0)
 			return (error);
-		/*
-		 * If requested, convert capability rights to access flags.
-		 */
 		if (maxprotp != NULL)
-			*maxprotp = cap_rights_to_vmprot(cap_rights(fdp, fd));
+			fdrights = *cap_rights(fdp, fd);
 		if (!fd_modified(fdp, fd, seq))
 			break;
 		fdrop(*fpp, td);
 	}
+
+	/*
+	 * If requested, convert capability rights to access flags.
+	 */
+	if (maxprotp != NULL)
+		*maxprotp = cap_rights_to_vmprot(&fdrights);
 #endif
 	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907060100.x6610SjY052230>