From owner-dev-commits-src-all@freebsd.org Tue Jun 29 17:20:22 2021 Return-Path: <owner-dev-commits-src-all@freebsd.org> Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1077164F317; Tue, 29 Jun 2021 17:20:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GDrpF6nqJz3Pcl; Tue, 29 Jun 2021 17:20:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CDAAC1CDCA; Tue, 29 Jun 2021 17:20:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15THKL1b062255; Tue, 29 Jun 2021 17:20:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15THKLZM062245; Tue, 29 Jun 2021 17:20:21 GMT (envelope-from git) Date: Tue, 29 Jun 2021 17:20:21 GMT Message-Id: <202106291720.15THKLZM062245@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin <dchagin@FreeBSD.org> Subject: git: 615f22b2fb6d - main - Add a link to the Elf_Brandinfo into the struc proc. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 615f22b2fb6d999005473abcb771c6bf25118dfe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository <dev-commits-src-all.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/dev-commits-src-all>, <mailto:dev-commits-src-all-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/dev-commits-src-all/> List-Post: <mailto:dev-commits-src-all@freebsd.org> List-Help: <mailto:dev-commits-src-all-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all>, <mailto:dev-commits-src-all-request@freebsd.org?subject=subscribe> X-List-Received-Date: Tue, 29 Jun 2021 17:20:22 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=615f22b2fb6d999005473abcb771c6bf25118dfe commit 615f22b2fb6d999005473abcb771c6bf25118dfe Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2021-06-29 17:15:08 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2021-06-29 17:15:08 +0000 Add a link to the Elf_Brandinfo into the struc proc. To allow the ABI to make a dicision based on the Brandinfo add a link to the Elf_Brandinfo into the struct proc. Add a note that the high 8 bits of Elf_Brandinfo flags is private to the ABI. Note to MFC: it breaks KBI. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D30918 MFC after: 2 weeks --- sys/kern/imgact_elf.c | 1 + sys/kern/kern_exec.c | 4 ++++ sys/kern/kern_thread.c | 4 ++-- sys/sys/imgact_elf.h | 1 + sys/sys/proc.h | 2 ++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 8c56660b1fe4..98ce5460e360 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1246,6 +1246,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) map = &vmspace->vm_map; imgp->proc->p_sysent = sv; + imgp->proc->p_elf_brandinfo = brand_info; maxv = vm_map_max(map) - lim_max(td, RLIMIT_STACK); if (et_dyn_addr == ET_DYN_ADDR_RAND) { diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index b091d6061616..aff030cd432e 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -397,6 +397,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, #endif int error, i, orig_osrel; uint32_t orig_fctl0; + Elf_Brandinfo *orig_brandinfo; static const char fexecv_proc_title[] = "(fexecv)"; imgp = &image_params; @@ -427,6 +428,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, oldcred = p->p_ucred; orig_osrel = p->p_osrel; orig_fctl0 = p->p_fctl0; + orig_brandinfo = p->p_elf_brandinfo; #ifdef MAC error = mac_execve_enter(imgp, mac_p); @@ -499,6 +501,7 @@ interpret: imgp->proc->p_osrel = 0; imgp->proc->p_fctl0 = 0; + imgp->proc->p_elf_brandinfo = NULL; /* * Implement image setuid/setgid. @@ -894,6 +897,7 @@ exec_fail_dealloc: if (error != 0) { p->p_osrel = orig_osrel; p->p_fctl0 = orig_fctl0; + p->p_elf_brandinfo = orig_brandinfo; } if (imgp->firstpage != NULL) diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 949095a4d34e..3afcf2d3f0ef 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -100,7 +100,7 @@ _Static_assert(offsetof(struct proc, p_filemon) == 0x3b8, "struct proc KBI p_filemon"); _Static_assert(offsetof(struct proc, p_comm) == 0x3d0, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b0, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, "struct proc KBI p_emuldata"); #endif #ifdef __i386__ @@ -120,7 +120,7 @@ _Static_assert(offsetof(struct proc, p_filemon) == 0x268, "struct proc KBI p_filemon"); _Static_assert(offsetof(struct proc, p_comm) == 0x27c, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x308, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x30c, "struct proc KBI p_emuldata"); #endif diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h index 44a860359a75..97383c6eeeb8 100644 --- a/sys/sys/imgact_elf.h +++ b/sys/sys/imgact_elf.h @@ -91,6 +91,7 @@ typedef struct { Elf_Brandnote *brand_note; boolean_t (*header_supported)(struct image_params *, int32_t *, uint32_t *); + /* High 8 bits of flags is private to the ABI */ #define BI_CAN_EXEC_DYN 0x0001 #define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */ #define BI_BRAND_NOTE_MANDATORY 0x0004 /* Must have note.ABI-tag section. */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index ef27691ae4cd..36c07b3b5e78 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -702,6 +702,8 @@ struct proc { our subtree. */ uint16_t p_elf_machine; /* (x) ELF machine type */ uint64_t p_elf_flags; /* (x) ELF flags */ + void *p_elf_brandinfo; /* (x) Elf_Brandinfo, NULL for + non ELF binaries. */ /* End area that is copied on creation. */ #define p_endcopy p_xexit