From owner-svn-src-all@freebsd.org Tue Jun 4 14:58:10 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC7BA15B3344 for ; Tue, 4 Jun 2019 14:58:10 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2m.ore.mailhop.org (outbound2m.ore.mailhop.org [54.149.155.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E2EE6C748 for ; Tue, 4 Jun 2019 14:58:09 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1559660282; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=b1FJQDQSA6h3ZXiQCHZKHvRzPeyqOoNEN9wCuRl4ANndE+VjkpCfOecUpZAtIMMJGruQYscmWzF4L cIOPNWt2MYtp4W1hY1fLBBxm2izeIkhBeh/MF+S7z49hBjkE9pjBH2XG93PpEEMT3dWaS2Dg3iiIuS siUKKjBvt0eP/v62AzSdh90JK4Ui4acc/dz0yli0YaK0mTWXSlNNi6an2JDpoaBohtmpHZObmHgQrv gNdP0br3YSSdZKtuxikTstkUE/i4A09ncxGbSoIVmckfCYPXaUlpRHZxTuYXqVMF2w4v8uII4mp7H6 30d6P1zfGann+IC4o2Ewpr5gJv4RUMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=Dl0OU0jHCACnoKmjvuEFw7JG2N0zMFmOpZWfb3iqNhE=; b=RMeS9KlzwMR1hSGMHPmM4cGy0QKWKdoMQ9d0G65aKYrYZCGC5bQTzFOkv8T/IE8rZmMDY9jwAqkxX bl+GQbEMKNf+mMjQaD6OERJaXNKwEO/0ij1bYE2VlXqJQ88WbkTr4XG7tjwcIVQ82ZYnyZgsvv7iHA pHgvSoHfhR1wi2M4nllCViPZpUeieQccGtwbupaDCj3dMZa7xnugZiXFHdvmTymDfBJCY7p02icaRX oCOiEEgfs6kc2+RhOoLacI1PjLHMHdS0CDKTGvA+25tuYqak9XwAtnArr8foZuuxb0YZY+0ruglB1i PQPZP4pkjCXFFxnDEv7/3ngjw1EbRqQ== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=Dl0OU0jHCACnoKmjvuEFw7JG2N0zMFmOpZWfb3iqNhE=; b=NdXOtedKllzmWxWPBZcnGJR7dnfxGNvoJbJ2w0oiSnUWq7hxoDl0E9H2cczM8SyQXn8EehWfbJHxH oaNzaeV0L3tpLBnfxl2Z/QdDEZebbIqh6GNmavKFMjsCKIGQHRpzZxBVjSNL1KsBtVuhGnsJfFmMhU i/91rk8uVMDe8WCsCzyyAunj8kaA0gwOgxpJx0xDWq76jnS3EOQaee484ZzkcoY3FzsD2zBBM0StAD 9serp6efO2EXa7OrV1YRsT2s97LkP6ybSfOZ06v+ZiHwQrpZoG3lfNtUirfc0LcMFHyo0Fg5nfyM1T wTwnnRr8t0ery6irDKjvC+Ko/wiuNLw== X-MHO-RoutePath: aGlwcGll X-MHO-User: 2518b291-86d9-11e9-b399-9d2c53d3dedb X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id 2518b291-86d9-11e9-b399-9d2c53d3dedb; Tue, 04 Jun 2019 14:58:00 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x54Evxj8060216; Tue, 4 Jun 2019 08:57:59 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <0708f493570462d065fa0ba3c361832720e60741.camel@freebsd.org> Subject: Re: svn commit: r348611 - in head/sys: conf kern From: Ian Lepore To: Ed Maste , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Tue, 04 Jun 2019 08:57:59 -0600 In-Reply-To: <201906041307.x54D7Acf058688@repo.freebsd.org> References: <201906041307.x54D7Acf058688@repo.freebsd.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 1E2EE6C748 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.993,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 14:58:11 -0000 On Tue, 2019-06-04 at 13:07 +0000, Ed Maste wrote: > Author: emaste > Date: Tue Jun 4 13:07:10 2019 > New Revision: 348611 > URL: https://svnweb.freebsd.org/changeset/base/348611 > > Log: > Expose the kernel's build-ID through sysctl > > After our migration (of certain architectures) to lld the kernel is built > with a unique build-ID. Make it available via a sysctl and uname(1) to > allow the user to identify their running kernel. > Won't this impact WITH_REPRODUCIBLE_BUILD? -- Ian > Submitted by: Ali Mashtizadeh > MFC after: 2 weeks > Relnotes: Yes > Event: Waterloo Hackathon 2019 > Differential Revision: https://reviews.freebsd.org/D20326 > > Modified: > head/sys/conf/ldscript.amd64 > head/sys/conf/ldscript.arm > head/sys/conf/ldscript.arm64 > head/sys/conf/ldscript.i386 > head/sys/conf/ldscript.mips > head/sys/conf/ldscript.mips.cfe > head/sys/conf/ldscript.mips.mips64 > head/sys/conf/ldscript.mips.octeon1 > head/sys/conf/ldscript.powerpc > head/sys/conf/ldscript.powerpc64 > head/sys/conf/ldscript.powerpcspe > head/sys/conf/ldscript.riscv > head/sys/conf/ldscript.sparc64 > head/sys/kern/kern_mib.c > > Modified: head/sys/conf/ldscript.amd64 > ===================================================================== > ========= > --- head/sys/conf/ldscript.amd64 Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.amd64 Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -74,6 +74,11 @@ SECTIONS > PROVIDE (etext = .); > .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } > .rodata1 : { *(.rodata1) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .eh_frame_hdr : { *(.eh_frame_hdr) } > .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table > .gcc_except_table.*) } > > Modified: head/sys/conf/ldscript.arm > ===================================================================== > ========= > --- head/sys/conf/ldscript.arm Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.arm Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -27,6 +27,11 @@ SECTIONS > .gnu.version : { *(.gnu.version) } > .gnu.version_d : { *(.gnu.version_d) } > .gnu.version_r : { *(.gnu.version_r) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .rel.text : > { *(.rel.text) *(.rel.gnu.linkonce.t*) } > .rela.text : > > Modified: head/sys/conf/ldscript.arm64 > ===================================================================== > ========= > --- head/sys/conf/ldscript.arm64 Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.arm64 Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -27,6 +27,11 @@ SECTIONS > .gnu.version : { *(.gnu.version) } > .gnu.version_d : { *(.gnu.version_d) } > .gnu.version_r : { *(.gnu.version_r) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .rel.text : > { *(.rel.text) *(.rel.gnu.linkonce.t*) } > .rela.text : > > Modified: head/sys/conf/ldscript.i386 > ===================================================================== > ========= > --- head/sys/conf/ldscript.i386 Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.i386 Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -62,6 +62,11 @@ SECTIONS > PROVIDE (etext = .); > .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } > .rodata1 : { *(.rodata1) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .eh_frame_hdr : { *(.eh_frame_hdr) } > .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table > .gcc_except_table.*) } > > Modified: head/sys/conf/ldscript.mips > ===================================================================== > ========= > --- head/sys/conf/ldscript.mips Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.mips Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -63,6 +63,11 @@ SECTIONS > .gnu.version : { *(.gnu.version) } > .gnu.version_d : { *(.gnu.version_d) } > .gnu.version_r : { *(.gnu.version_r) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .rel.init : { *(.rel.init) } > .rela.init : { *(.rela.init) } > .rel.text : > > Modified: head/sys/conf/ldscript.mips.cfe > ===================================================================== > ========= > --- head/sys/conf/ldscript.mips.cfe Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.mips.cfe Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -192,6 +192,11 @@ SECTIONS > PROVIDE (etext = .); > .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } > .rodata1 : { *(.rodata1) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .reginfo : { *(.reginfo) } > .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } > .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } > > Modified: head/sys/conf/ldscript.mips.mips64 > ===================================================================== > ========= > --- head/sys/conf/ldscript.mips.mips64 Tue Jun 4 13:00:49 > 2019 (r348610) > +++ head/sys/conf/ldscript.mips.mips64 Tue Jun 4 13:07:10 > 2019 (r348611) > @@ -176,6 +176,11 @@ SECTIONS > PROVIDE (etext = .); > .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } > .rodata1 : { *(.rodata1) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .reginfo : { *(.reginfo) } > .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } > .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } > > Modified: head/sys/conf/ldscript.mips.octeon1 > ===================================================================== > ========= > --- head/sys/conf/ldscript.mips.octeon1 Tue Jun 4 13:00:49 > 2019 (r348610) > +++ head/sys/conf/ldscript.mips.octeon1 Tue Jun 4 13:07:10 > 2019 (r348611) > @@ -23,6 +23,12 @@ SECTIONS { > *(.rodata) > . = ALIGN(32); > } > + > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > > .data : { > _rwdata = .; > > Modified: head/sys/conf/ldscript.powerpc > ===================================================================== > ========= > --- head/sys/conf/ldscript.powerpc Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.powerpc Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -55,6 +55,11 @@ SECTIONS > .fini : { *(.fini) } =0 > .rodata : { *(.rodata) *(.gnu.linkonce.r*) } > .rodata1 : { *(.rodata1) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .sdata2 : { *(.sdata2) } > .sbss2 : { *(.sbss2) } > /* Adjust the address for the data segment to the next page up. */ > > Modified: head/sys/conf/ldscript.powerpc64 > ===================================================================== > ========= > --- head/sys/conf/ldscript.powerpc64 Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.powerpc64 Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -46,6 +46,11 @@ SECTIONS > .gnu.version : { *(.gnu.version) } > .gnu.version_d : { *(.gnu.version_d) } > .gnu.version_r : { *(.gnu.version_r) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .rela.text : > { *(.rela.text) *(.rela.gnu.linkonce.t*) } > .rela.data : > > Modified: head/sys/conf/ldscript.powerpcspe > ===================================================================== > ========= > --- head/sys/conf/ldscript.powerpcspe Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.powerpcspe Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -55,6 +55,11 @@ SECTIONS > .fini : { *(.fini) } =0 > .rodata : { *(.rodata) *(.gnu.linkonce.r*) } > .rodata1 : { *(.rodata1) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .sdata2 : { *(.sdata2) } > .sbss2 : { *(.sbss2) } > /* Adjust the address for the data segment to the next page up. */ > > Modified: head/sys/conf/ldscript.riscv > ===================================================================== > ========= > --- head/sys/conf/ldscript.riscv Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.riscv Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -27,6 +27,11 @@ SECTIONS > .gnu.version : { *(.gnu.version) } > .gnu.version_d : { *(.gnu.version_d) } > .gnu.version_r : { *(.gnu.version_r) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .rel.text : > { *(.rel.text) *(.rel.gnu.linkonce.t*) } > .rela.text : > > Modified: head/sys/conf/ldscript.sparc64 > ===================================================================== > ========= > --- head/sys/conf/ldscript.sparc64 Tue Jun 4 13:00:49 2019 (r348 > 610) > +++ head/sys/conf/ldscript.sparc64 Tue Jun 4 13:07:10 2019 (r348 > 611) > @@ -146,6 +146,11 @@ SECTIONS > PROVIDE (etext = .); > .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } > .rodata1 : { *(.rodata1) } > + .note.gnu.build-id : { > + PROVIDE (__build_id_start = .); > + *(.note.gnu.build-id) > + PROVIDE (__build_id_end = .); > + } > .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } > .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } > . = ALIGN(0x2000) + (. & (0x2000 - 1)); > > Modified: head/sys/kern/kern_mib.c > ===================================================================== > ========= > --- head/sys/kern/kern_mib.c Tue Jun 4 13:00:49 2019 (r348610) > +++ head/sys/kern/kern_mib.c Tue Jun 4 13:07:10 2019 (r348611) > @@ -481,6 +481,54 @@ SYSCTL_PROC(_kern, KERN_OSRELDATE, osreldate, > CTLTYPE_INT | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, > NULL, 0, sysctl_osreldate, "I", "Kernel release date"); > > +/* > + * The build-id is copied from the ELF section .note.gnu.build- > id. The linker > + * script defines two variables to expose the beginning and > end. LLVM > + * currently uses a SHA-1 hash, but other formats can be supported > by checking > + * the length of the section. > + */ > + > +extern char __build_id_start[]; > +extern char __build_id_end[]; > + > +#define BUILD_ID_HEADER_LEN 0x10 > +#define BUILD_ID_HASH_MAXLEN 0x14 > + > +static int > +sysctl_build_id(SYSCTL_HANDLER_ARGS) > +{ > + uintptr_t sectionlen = (uintptr_t)(__build_id_end - > __build_id_start); > + int hashlen; > + char buf[2*BUILD_ID_HASH_MAXLEN+1]; > + > + /* > + * The ELF note section has a four byte length for the vendor > name, > + * four byte length for the value, and a four byte vendor > specific > + * type. The name for the build id is "GNU\0". We skip the > first 16 > + * bytes to read the build hash. We will return the remaining > bytes up > + * to 20 (SHA-1) hash size. If the hash happens to be a custom > number > + * of bytes we will pad the value with zeros, as the section > should be > + * four byte aligned. > + */ > + if (sectionlen <= BUILD_ID_HEADER_LEN || > + sectionlen > (BUILD_ID_HEADER_LEN + BUILD_ID_HASH_MAXLEN)) > { > + return (ENOENT); > + } > + > + > + hashlen = sectionlen - BUILD_ID_HEADER_LEN; > + for (int i = 0; i < hashlen; i++) { > + uint8_t c = __build_id_start[i+BUILD_ID_HEADER_LEN]; > + snprintf(&buf[2*i], 3, "%02x", c); > + } > + > + return (SYSCTL_OUT(req, buf, strlen(buf) + 1)); > +} > + > +SYSCTL_PROC(_kern, OID_AUTO, build_id, > + CTLTYPE_STRING | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, > + NULL, 0, sysctl_build_id, "A", "Operating system build-id"); > + > SYSCTL_NODE(_kern, OID_AUTO, features, CTLFLAG_RD, 0, "Kernel > Features"); > > #ifdef COMPAT_FREEBSD4 >