Module Name:    src
Committed By:   riastradh
Date:           Mon Mar 17 19:02:49 UTC 2025

Modified Files:
        src/sys/kern: kern_proc.c

Log Message:
kern_proc.c: Fix mistakes in SET_ERROR sprinkling.

To avoid triggering a SET_ERROR probe, I moved an initial

        rval = EPERM;

to a separate label `eperm', and then adjusted all the `goto done'
lines that didn't initialize rval themselves to do `goto eperm'
instead.

However, I was sloppy and missed some cases, so some spuriously
failed when they should have succeeded.

Annoyingly, we don't seem to have any automatic tests for this bug!
So the releng test bed hasn't discovered the problem.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/sys/kern/kern_proc.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/kern/kern_proc.c
diff -u src/sys/kern/kern_proc.c:1.278 src/sys/kern/kern_proc.c:1.279
--- src/sys/kern/kern_proc.c:1.278	Sun Mar 16 15:52:03 2025
+++ src/sys/kern/kern_proc.c	Mon Mar 17 19:02:49 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.278 2025/03/16 15:52:03 riastradh Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.279 2025/03/17 19:02:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008, 2020, 2023
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.278 2025/03/16 15:52:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.279 2025/03/17 19:02:49 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -1338,9 +1338,11 @@ proc_enterpgrp(struct proc *curp, pid_t 
 	/* Changing the process group/session of a session
 	   leader is definitely off limits. */
 	if (SESS_LEADER(p)) {
-		if (sess == NULL && p->p_pgrp == pgrp)
+		if (sess == NULL && p->p_pgrp == pgrp) {
 			/* unless it's a definite noop */
 			rval = 0;
+			goto done;
+		}
 		goto eperm;
 	}
 
@@ -1365,7 +1367,7 @@ proc_enterpgrp(struct proc *curp, pid_t 
 
 	if (pgrp == p->p_pgrp)
 		/* nothing to do */
-		goto eperm;
+		goto done;
 
 	/* Ok all setup, link up required structures */
 

Reply via email to