From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:54700 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753982AbcIRSOi (ORCPT ); Sun, 18 Sep 2016 14:14:38 -0400 Message-ID: <1474222407.2428.2.camel@decadent.org.uk> Subject: Re: [PATCH 2/9] exec: turn self_exec_id into self_privunit_id From: Ben Hutchings To: Jann Horn , Alexander Viro , Roland McGrath , Oleg Nesterov , John Johansen , James Morris , "Serge E. Hallyn" , Paul Moore , Stephen Smalley , Eric Paris , Casey Schaufler , Kees Cook , Andrew Morton , Janis Danisevskis , Seth Forshee , "Eric . Biederman" , Thomas Gleixner , Benjamin LaHaise Cc: linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, security@kernel.org Date: Sun, 18 Sep 2016 19:13:27 +0100 In-Reply-To: <1474211117-16674-3-git-send-email-jann@thejh.net> References: <1474211117-16674-1-git-send-email-jann@thejh.net> <1474211117-16674-3-git-send-email-jann@thejh.net> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-pSCgxp+KFuk+UgsRCLLp" Mime-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --=-pSCgxp+KFuk+UgsRCLLp Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2016-09-18 at 17:05 +0200, Jann Horn wrote: > This ensures that self_privunit_id ("privilege unit ID") is only shared b= y > processes that share the mm_struct and the signal_struct; not just > spatially, but also temporally. In other words, if you do execve() or > clone() without CLONE_THREAD, you get a new privunit_id that has never be= en > used before. [...] > +void increment_privunit_counter(void) > +{ > + BUILD_BUG_ON(NR_CPUS > (1 << 16)); > + current->self_privunit_id =3D this_cpu_add_return(exec_counter, NR_CPUS= ); > +} [...] This will wrap incorrectly if NR_CPUS is not a power of 2 (which is unusual but allowed). Ben. =C2=A0 --=20 Ben Hutchings Klipstein's 4th Law of Prototyping and Production: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0A fail-sa= fe circuit will destroy others. --=-pSCgxp+KFuk+UgsRCLLp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQIcBAABCgAGBQJX3tlHAAoJEOe/yOyVhhEJ1LoP/0cv5oXqdmnjKkt7Vet/Zusm Du+1LvsWd3D2aPfhFkvuW5/vp+wg6PtNIPN9GLNgN4P0ME2qpvho8L9isiVtWUwQ dRrJR0wkbkc7/5cI7nuoaFWRBg9XHgFK2kCYhGqlmKnGy01P85CThIuibmzZvH/v jnTnEXGPn1jaTmdIIEk8fjnnl1ODQBaCqKXXSBOFGV1KxnIUX+a8dfejHMU6nutA 2Emd0rzIHYD9wstts9oeG2tfe0wVFRSjidc5UtFg6l7kfkMRbrwp6M5lS3pD43SK 5JYESQ+9nJphY/gTIwJPAiKERR3r3fYvCHpwk8L4EWXNo93IrtzK+B+/ngeYvtXk LGCNk2nGu4OrNQrYJ3zqacJLlU/GjnRXmQkZhTIiZB8jX1t5486r4PsdLWDyhZHE BiZLb9j9WOmgKCQLJ4Lw8kvz4fsOc/yYj4SJicHoFljXtp6mpUU/Va2wNNowpeAt pmIzH+juDSCF2EP/qsM85v/vL3UuYHtPnAcwW39T+2j7A0JqeYeBak3IH1f16vyC cmwYyvb7GhkrxBUYMncmfSQ208uRSKGV8TWITNEBKO9e7T7M3Rg46LYDiOtGvFpD wk9dhwc5MfhDBBLWQnLYhB9sU2+hM57xKRnn0md9eQwsEeSYBR4mQsZfgEHfYPxF elfy+kzaW6BdREo5C+GM =MAOL -----END PGP SIGNATURE----- --=-pSCgxp+KFuk+UgsRCLLp--