Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jul 2019 01:00:11 +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-12@freebsd.org
Subject:   svn commit: r349775 - stable/12/sys/kern
Message-ID:  <201907060100.x6610Bfd052171@repo.freebsd.org>

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

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

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

Modified: stable/12/sys/kern/kern_descrip.c
==============================================================================
--- stable/12/sys/kern/kern_descrip.c	Sat Jul  6 00:59:46 2019	(r349774)
+++ stable/12/sys/kern/kern_descrip.c	Sat Jul  6 01:00:11 2019	(r349775)
@@ -2776,6 +2776,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;
 
@@ -2784,15 +2785,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.x6610Bfd052171>