Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Nov 2019 12:35:17 +0000 (UTC)
From:      Konstantin Belousov <kib@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: r355053 - stable/11/sys/kern
Message-ID:  <201911241235.xAOCZHL7053767@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Nov 24 12:35:16 2019
New Revision: 355053
URL: https://svnweb.freebsd.org/changeset/base/355053

Log:
  MFC r354789:
  kern_exec: p_osrel and p_fctl0 were obliterated by failed execve(2) attempt.

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

Modified: stable/11/sys/kern/kern_exec.c
==============================================================================
--- stable/11/sys/kern/kern_exec.c	Sun Nov 24 12:30:41 2019	(r355052)
+++ stable/11/sys/kern/kern_exec.c	Sun Nov 24 12:35:16 2019	(r355053)
@@ -361,7 +361,6 @@ do_execve(struct thread *td, struct image_args *args, 
 	struct ucred *oldcred;
 	struct uidinfo *euip = NULL;
 	register_t *stack_base;
-	int error, i;
 	struct image_params image_params, *imgp;
 	struct vattr attr;
 	int (*img_first)(struct image_params *);
@@ -382,6 +381,7 @@ do_execve(struct thread *td, struct image_args *args, 
 #ifdef HWPMC_HOOKS
 	struct pmckern_procexec pe;
 #endif
+	int error, i, orig_osrel;
 	static const char fexecv_proc_title[] = "(fexecv)";
 
 	imgp = &image_params;
@@ -407,6 +407,7 @@ do_execve(struct thread *td, struct image_args *args, 
 	imgp->attr = &attr;
 	imgp->args = args;
 	oldcred = p->p_ucred;
+	orig_osrel = p->p_osrel;
 
 #ifdef MAC
 	error = mac_execve_enter(imgp, mac_p);
@@ -892,6 +893,10 @@ interpret:
 	SDT_PROBE1(proc, , , exec__success, args->fname);
 
 exec_fail_dealloc:
+	if (error != 0) {
+		p->p_osrel = orig_osrel;
+	}
+
 	if (imgp->firstpage != NULL)
 		exec_unmap_first_page(imgp);
 



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