Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754097AbdDLMJg (ORCPT ); Wed, 12 Apr 2017 08:09:36 -0400 Received: from smtp.nsa.gov ([8.44.101.9]:10757 "EHLO emsm-gh1-uea11.nsa.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752379AbdDLMJ1 (ORCPT ); Wed, 12 Apr 2017 08:09:27 -0400 X-IronPort-AV: E=Sophos;i="5.37,190,1488844800"; d="scan'208";a="4819349" IronPort-PHdr: =?us-ascii?q?9a23=3Abtw4Rxa1cnUIOSLREP+Ml6r/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZpsi7ZB7h7PlgxGXEQZ/co6odzbGH7ea5Bydcv96oizMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVr?= =?us-ascii?q?O+/7BpDdj9it1+C15pbffxhEiCCzbL52LRi6txjdu8gZjYZtK6s61wfErGZPd+?= =?us-ascii?q?lK321jOEidnwz75se+/Z5j9zpftvc8/MNeUqv0Yro1Q6VAADspL2466svrtQLe?= =?us-ascii?q?TQSU/XsTTn8WkhtTDAfb6hzxQ4r8vTH7tup53ymaINH2QLUpUjms86tnVBnlgz?= =?us-ascii?q?ocOjUn7G/YlNB/jKNDoBKguRN/xZLUYJqIP/Z6Z6/RYM8WSXZEUstXWSNBGIe8?= =?us-ascii?q?ZJYRAeQHM+hTso3xq0IQoReiAAWhAv7kxD1ViX/sxaA00PkvHwHY0gIuHd0Ovn?= =?us-ascii?q?PUo8nyOqgdXu6417XIwDbZYv9Kwzrx9IrFfxY8qv+MR7Jwds/RxFEyGQPZkFqQ?= =?us-ascii?q?sYzlMC2T1u8Qrmab6vBvVeari2E5qwB6vz+ixtwxhYnSnY8V1lDF+jl5wIYyP9?= =?us-ascii?q?G4TlV7bsS+HJtfsCGaKZJ7T8U/SG9roCY30qAKtJG0cSQQyJkr2gTTZ+KIfoSW?= =?us-ascii?q?+B7vSeCcKipiin1/YrKwnROy/FClyu37S8a7zk5HrjFAktnQrnAN0AHT6tSfRv?= =?us-ascii?q?t94Eih3TGP2hjP6u5eO0A0lLfbK4U7zr4slpscrUTDHijslEXwkKCWbVkr9vKt?= =?us-ascii?q?6+TmZrXqvp6cN4lqhQHiKqkih8OyDOsiPgUOQmSX4/qw2bL98UHjXblGlvg2nb?= =?us-ascii?q?PYsJDeK8QbvKm5AwpN34Y49hm/FCyr0MgYnHYbLFJFfwiLj47yO17UOvz4AvC/?= =?us-ascii?q?g0q0nDdx2//GJqHhAonKLnXbi7fuZqt9609HyAooytBf4YlZBawcL/L1QEP+qN?= =?us-ascii?q?vYDhohOQyu3+nnEMl91p8ZWW+XGq+WKr7SsVuT6+I3OeaMeYsVtC/4K/gi4P7u?= =?us-ascii?q?l2E2lUUBcqmu2JsdcGq4Eeh+I0WFfXrshc8MHnkSvgUkVuzqiUaCXCVLZ3moRa?= =?us-ascii?q?I85yo7CJqiDYjZWo+inqaN3CChHp1ZfmpGEEyDEW/0d4WYXPcBcCCSLdVkkjMa?= =?us-ascii?q?TritUYsh2QurtA/90bpnNOvU+jYDuJLkzth6/fHclRUs+jBuE8ud1GSNRXlunm?= =?us-ascii?q?wUXz82wLx/oUtlx1eYz6d4mfNYGsJI6vNJSAg6MZrczux8C9zoRg3BedKJQk68?= =?us-ascii?q?Qtq6GTExUs4xw9gWbkdzGtWiihTD3yuwDL8QjbCEGIY48rjb33fqOcl90WrG1L?= =?us-ascii?q?I6glknRMtPKXOphqpl+wfPAI7Jll2Tl7y2eqQEwC7N6GCDwHKKvEFZVg5wTKrE?= =?us-ascii?q?UWkcZkTIt9T54F3NT7u1BLQ5PQtO19SCJrFJatL3l1VGQunsONDEb2K2gWewCg?= =?us-ascii?q?6CxqmQY4ryZ2UdwCLdBVAAkwAS+3aGKAc/Cj66o23AEDNuCEjvY0Lw8eh+sX+7?= =?us-ascii?q?S0g0wByXb01lybW44QAVhfOCRPMJxL4Euzkuqy9yHFmj29LaEd2ApxBufK9Ee9?= =?us-ascii?q?My/E9H1X7Ftwx6JpGgNLtthkMfcwRspEPu0BN3Bp9dnsc3qnMn1wVyKaeC31NA?= =?us-ascii?q?czOUx4z/OrrSKjq6wBf6UKPc00rC0duQso0S6e8jrFOr6BqjC0s56HJhldVZ1V?= =?us-ascii?q?OT45zLCEwZVpenFg4z9h5nt/TBbyIg/YLIxDhpNqWptjLqxd0kHq0mxwymctMZ?= =?us-ascii?q?N7mLUEf2EssHF42tJfYsllyBcB0JJqZR+bQyMsfgcOGJnOawMeJhmi+2pXhW64?= =?us-ascii?q?B6lESX/mxzTfCb8YwCxqSjwgafVzr6xGyku8TzlJEMMSoeBUKj2CPkA8hXfaQ0?= =?us-ascii?q?coEVXzT9a/arz8lz0sa+E0VT80SuUhZfgpek?= X-IPAS-Result: =?us-ascii?q?A2HSBADgF+5Y/wHyM5BcGwEBAQMBAQEJAQEBFwEBBAEBCgE?= =?us-ascii?q?Bgn8pgWyDZpo0AQEBAQEBBoEjkH2Ga4YkAoN1VwEBAQEBAQEBAgECaCiCMyIBg?= =?us-ascii?q?kABBSMPAUYQCQINAQoCAiYCAlcGARKIBYIEDYslnV2CJiYCik8BAQEBAQEEAQE?= =?us-ascii?q?BAQEBIoELhQCFOodcgl8BBJ0KkmGKfoZGSJM6WIEFHAkCFAgeD4UcHIF/JDWJI?= =?us-ascii?q?gEBAQ?= Message-ID: <1491999202.3881.3.camel@tycho.nsa.gov> Subject: Re: [PATCH] selinux: add selinux_is_enforced() function From: Stephen Smalley To: Sebastien Buisson , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov Cc: william.c.roberts@intel.com, serge@hallyn.com, james.l.morris@oracle.com, eparis@parisplace.org, paul@paul-moore.com, Sebastien Buisson Date: Wed, 12 Apr 2017 08:13:22 -0400 In-Reply-To: <1491988018-4120-1-git-send-email-sbuisson@ddn.com> References: <1491988018-4120-1-git-send-email-sbuisson@ddn.com> Organization: National Security Agency Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-2.fc25) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3054 Lines: 100 On Wed, 2017-04-12 at 18:06 +0900, Sebastien Buisson wrote: > Add selinux_is_enforced() function to give access to SELinux > enforcement to the rest of the kernel. > > Signed-off-by: Sebastien Buisson > --- >  include/linux/selinux.h             | 5 +++++ >  security/selinux/exports.c          | 6 ++++++ >  security/selinux/hooks.c            | 2 ++ >  security/selinux/include/avc.h      | 6 ------ >  security/selinux/include/security.h | 1 + >  5 files changed, 14 insertions(+), 6 deletions(-) > > diff --git a/include/linux/selinux.h b/include/linux/selinux.h > index 44f4596..1007321 100644 > --- a/include/linux/selinux.h > +++ b/include/linux/selinux.h > @@ -24,12 +24,17 @@ >   * selinux_is_enabled - is SELinux enabled? >   */ >  bool selinux_is_enabled(void); > +bool selinux_is_enforced(void); >  #else >   >  static inline bool selinux_is_enabled(void) >  { >   return false; >  } > +static inline bool selinux_is_enforced(void) > +{ > + return false; > +} >  #endif /* CONFIG_SECURITY_SELINUX */ >   >  #endif /* _LINUX_SELINUX_H */ > diff --git a/security/selinux/exports.c b/security/selinux/exports.c > index e75dd94..016f1e2 100644 > --- a/security/selinux/exports.c > +++ b/security/selinux/exports.c > @@ -21,3 +21,9 @@ bool selinux_is_enabled(void) >   return selinux_enabled; >  } >  EXPORT_SYMBOL_GPL(selinux_is_enabled); > + > +bool selinux_is_enforced(void) > +{ > + return selinux_enforcing; > +} > +EXPORT_SYMBOL_GPL(selinux_is_enforced); > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index e67a526..da2baeb 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -109,6 +109,8 @@ static int __init enforcing_setup(char *str) >   return 1; >  } >  __setup("enforcing=", enforcing_setup); > +#else > +int selinux_enforcing; >  #endif >   >  #ifdef CONFIG_SECURITY_SELINUX_BOOTPARAM > diff --git a/security/selinux/include/avc.h > b/security/selinux/include/avc.h > index 0999df0..ff98351 100644 > --- a/security/selinux/include/avc.h > +++ b/security/selinux/include/avc.h > @@ -19,12 +19,6 @@ >  #include "av_permissions.h" >  #include "security.h" >   > -#ifdef CONFIG_SECURITY_SELINUX_DEVELOP > -extern int selinux_enforcing; > -#else > -#define selinux_enforcing 1 > -#endif If CONFIG_SECURITY_SELINUX_DEVELOP=n, then selinux_enforcing is supposed to always be 1, i.e. global permissive mode is not supported. Your patch breaks that. That's in addition to the points raised by others about needing an in-tree user and use of a LSM hook interface instead. > - >  /* >   * An entry in the AVC. >   */ > diff --git a/security/selinux/include/security.h > b/security/selinux/include/security.h > index f979c35..1e67e268 100644 > --- a/security/selinux/include/security.h > +++ b/security/selinux/include/security.h > @@ -64,6 +64,7 @@ >  struct netlbl_lsm_secattr; >   >  extern int selinux_enabled; > +extern int selinux_enforcing; >   >  /* Policy capabilities */ >  enum {