Module Name:    src
Committed By:   riastradh
Date:           Sun Nov 10 16:20:13 UTC 2024

Modified Files:
        src/sys/compat/netbsd32: netbsd32_ioctl.c

Log Message:
netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.

No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/compat/netbsd32/netbsd32_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.121 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.122
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.121	Sat May 11 10:22:17 2024
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c	Sun Nov 10 16:20:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.c,v 1.121 2024/05/11 10:22:17 martin Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.c,v 1.122 2024/11/10 16:20:12 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.121 2024/05/11 10:22:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.122 2024/11/10 16:20:12 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -1301,9 +1301,7 @@ netbsd32_ioctl(struct lwp *l,
 		syscallarg(netbsd32_u_long) com;
 		syscallarg(netbsd32_voidp) data;
 	} */
-	struct proc *p = l->l_proc;
 	struct file *fp;
-	struct filedesc *fdp;
 	u_long com;
 	int error = 0;
 	size_t size;
@@ -1311,7 +1309,6 @@ netbsd32_ioctl(struct lwp *l,
 	void *data, *memp = NULL;
 	void *data32, *memp32 = NULL;
 	unsigned int fd;
-	fdfile_t *ff;
 	int tmp;
 #define STK_PARAMS	128
 	uint64_t stkbuf[STK_PARAMS/sizeof(uint64_t)];
@@ -1343,7 +1340,6 @@ netbsd32_ioctl(struct lwp *l,
 	size32 = 0;
 	size = 0;
 
-	fdp = p->p_fd;
 	fd = SCARG(uap, fd);
 	if ((fp = fd_getfile(fd)) == NULL)
 		return EBADF;
@@ -1352,15 +1348,10 @@ netbsd32_ioctl(struct lwp *l,
 		goto out;
 	}
 
-	ff = atomic_load_consume(&fdp->fd_dt)->dt_ff[SCARG(uap, fd)];
 	switch (com = SCARG(uap, com)) {
-	case FIOCLEX:
-		ff->ff_exclose = true;
-		fdp->fd_exclose = true;
-		goto out;
-
 	case FIONCLEX:
-		ff->ff_exclose = false;
+	case FIOCLEX:
+		fd_set_exclose(l, fd, com == FIOCLEX);
 		goto out;
 	}
 

Reply via email to