From owner-svn-src-all@freebsd.org Tue Mar 17 22:36:30 2020 Return-Path: Delivered-To: svn-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 4C94B274800 for ; Tue, 17 Mar 2020 22:36:30 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2m.ore.mailhop.org (outbound2m.ore.mailhop.org [54.149.155.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48hp1T44NCz45V0 for ; Tue, 17 Mar 2020 22:36:29 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1584484588; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=FazlGkkUqv4G+9VPLIOtUB3AZzdNEzE3xTrPVBcNspqG8h+ePItdWz/lXSVN1NQMYw6VNmPanZYZK Ya2bRkCNv3PUsFbAtdnylA2d08ZCBIRyuxpwGCue/mnjFysTy2o89M6fIcPOqs8Ha96xmLoUkuAjWc x3dLBWyckFU39jS7unYwEtwBZgtLKzBik/GMhtkaKgnn8wGk65qWQ8pb0Dih1QEoVfTPOTrZ2yPEOr vS7Kda+bH1jE0Sfrim2BWK9/kD543moKm5oEVHGZF6GEMZPJJaOhuGv7d0O4qsl6QtT6W22m9NsyJp H2Pmtx45rNiVzB+0oK0jvxIEopDzmHg== 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=3wmFkSzN3hS2JMKH3LHoHWqqjDQprMeWDVErk+0miMY=; b=QhKWu+4vg1eVoa30XTmO+co2XFpT/cd/zUtZGNrrWok2MyMl5Hz+R2QmRMW3k0hMx/MaXpy3JXp6Y PRMvR6LkBoj822ZW8ZjDnbUBP2s26qQw+VX2roa6DvtBm2yTAaeonBhmcxOy5rW0xN6peMlTb1Um1U rtEH+sTgnC7k6a/VR0QvFEscrW4f+Y04js5vyzfBJDQqkPrKNh34RMBifPxX5hb/q9Lfoz8oyxUdvu hi4myCAOj6a1iUJVuBXuF+tXMhkhIy45Xk6tiFiK5uBYrvM0/Twe+bKiCGIjnVX5RTKMBJw5yE9V13 BgsojPD1UXGpu7eQhiHKN0Rt9HqCNcA== 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=3wmFkSzN3hS2JMKH3LHoHWqqjDQprMeWDVErk+0miMY=; b=uvc8NzsNTCI7bpzaPz6mykx69kykUakuUEGU8DP0JuJkrnQGYDUKPs4hppBZdjxRWOFusju3V+1bk LKxtqwTW2YMeescEaJD96eKtB39J7CqJrE+kIt9+Bg7XyxV/FAkgqHCh6DsGQSkcp+Mvc7E9vlTA5u jWIEeRF4Aukt484fh3Q4uidqNGclND+f7IXlHfSjI8H/jvKK+YZLAtA+rNpCaHvfMZfUDQufdd+6vq 7TZfr507cLhHOjp4W98RhUQHjD5pokp0lV0oti6RLP0XcHS94tyh/eMyFoz66ILvYh/VV0Wstvc7Fs 7ICjP8tACrAWiQ0oMNLYXtC9utGUGPQ== X-MHO-RoutePath: aGlwcGll X-MHO-User: bc4dd746-689f-11ea-9eb3-25e2dfa9fa8d 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 bc4dd746-689f-11ea-9eb3-25e2dfa9fa8d; Tue, 17 Mar 2020 22:36:26 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 02HMaPXT073578; Tue, 17 Mar 2020 16:36:25 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <047c4edb4ff9fa6c40be6492c2f082e374f7a941.camel@freebsd.org> Subject: Re: svn commit: r359053 - head/sys/kern From: Ian Lepore To: Conrad Meyer , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Tue, 17 Mar 2020 16:36:25 -0600 In-Reply-To: <202003172227.02HMRHLM086023@repo.freebsd.org> References: <202003172227.02HMRHLM086023@repo.freebsd.org> Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 48hp1T44NCz45V0 X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [1.97 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_SPAM_LONG(1.00)[0.997,0]; NEURAL_SPAM_MEDIUM(0.98)[0.976,0]; ASN(0.00)[asn:16509, ipnet:54.148.0.0/15, country:US] 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, 17 Mar 2020 22:36:30 -0000 On Tue, 2020-03-17 at 22:27 +0000, Conrad Meyer wrote: > Author: cem > Date: Tue Mar 17 22:27:16 2020 > New Revision: 359053 > URL: https://svnweb.freebsd.org/changeset/base/359053 > > Log: > Implement sysctl kern.boot_id > > Boot IDs are random, opaque 128-bit identifiers that distinguish distinct > system boots. A new ID is generated each time the system boots. Unlike > kern.boottime, the value is not modified by NTP adjustments. It remains fixed > until the machine is restarted. > > PR: 244867 > Reported by: Ricardo Fraile > MFC after: I do not intend to, but feel free > > Modified: > head/sys/kern/kern_mib.c > > Modified: head/sys/kern/kern_mib.c > ============================================================================== > --- head/sys/kern/kern_mib.c Tue Mar 17 21:29:03 2020 (r359052) > +++ head/sys/kern/kern_mib.c Tue Mar 17 22:27:16 2020 (r359053) > @@ -448,6 +448,32 @@ SYSCTL_PROC(_kern, KERN_HOSTID, hostid, > CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, > NULL, 0, sysctl_hostid, "LU", "Host ID"); > > +static struct mtx bootid_lk; > +MTX_SYSINIT(bootid_lock, &bootid_lk, "bootid generator lock", MTX_DEF); > + > +static int > +sysctl_bootid(SYSCTL_HANDLER_ARGS) > +{ > + static uint8_t boot_id[16]; > + static bool initialized = false; > + > + mtx_lock(&bootid_lk); > + if (!initialized) { > + if (!is_random_seeded()) { > + mtx_unlock(&bootid_lk); > + return (ENXIO); > + } > + arc4random_buf(boot_id, sizeof(boot_id)); > + initialized = true; > + } > + mtx_unlock(&bootid_lk); > + > + return (SYSCTL_OUT(req, boot_id, sizeof(boot_id))); > +} > +SYSCTL_PROC(_kern, OID_AUTO, boot_id, > + CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, > + NULL, 0, sysctl_bootid, "", "Random boot ID"); > + > /* > * The osrelease string is copied from the global (osrelease in vers.c) into > * prison0 by a sysinit and is inherited by child jails if not changed at jail This seems a bit complex. Why run a sysinit to init a mutex so that you can safely do a lazy init of boot_id? Seems like it would be much easier to just use a sysinit at SI_SUB_LAST to init boot_id before sysctl can reference it. -- Ian