Page MenuHomeFreeBSD

D59875.diff
No OneTemporary

D59875.diff

diff --git a/lib/libsys/fcntl.2 b/lib/libsys/fcntl.2
--- a/lib/libsys/fcntl.2
+++ b/lib/libsys/fcntl.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 24, 2025
+.Dd September 22, 2026
.Dt FCNTL 2
.Os
.Sh NAME
@@ -173,6 +173,13 @@
.Xr openat 2
where the directory descriptor has the flag set causes the new directory
descriptor to also have the flag set.
+A file descriptor with the
+.Dv FD_RESOLVE_BENEATH
+set cannot be used as either the source or target descriptor in
+.Xr renameat 2
+or
+.Xr renameat2 2
+system calls.
.El
.It Dv F_SETFD
Set flags associated with
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -3869,6 +3869,15 @@
error = EEXIST;
goto out;
}
+ if (fvp->v_type == VDIR &&
+ ((fromnd.ni_resflags | tond.ni_resflags) & NIRES_BENEATH) != 0) {
+ /*
+ * We must not rename a directory relative to FD_RESOLVE_BENEATH
+ * descriptors.
+ */
+ error = ENOTCAPABLE;
+ goto out;
+ }
if (exchange) {
if (tvp == NULL) {
error = ENOENT;

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 28, 1:21 AM (3 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39724872
Default Alt Text
D59875.diff (1 KB)

Event Timeline