From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934308AbdDZS1n (ORCPT ); Wed, 26 Apr 2017 14:27:43 -0400 Received: from emsm-gh1-uea10.nsa.gov ([8.44.101.8]:31675 "EHLO emsm-gh1-uea10.nsa.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934002AbdDZS1e (ORCPT ); Wed, 26 Apr 2017 14:27:34 -0400 X-IronPort-AV: E=Sophos;i="5.37,255,1488844800"; d="scan'208";a="6376450" IronPort-PHdr: =?us-ascii?q?9a23=3A41nknxZMXLPFm3FFrF9pD1T/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZps2yZx7h7PlgxGXEQZ/co6odzbGH7ea8BSdZu8rJmUtBWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6?= =?us-ascii?q?OPn+FJLMgMSrzeCy/IDYbxlViDanb75/KBS7oR/eu8QZjoduN7g9xxTUqXZUZu?= =?us-ascii?q?pawn9lK0iOlBjm/Mew+5Bj8yVUu/0/8sNLTLv3caclQ7FGFToqK2866tHluhnF?= =?us-ascii?q?VguP+2ATUn4KnRpSAgjK9w/1U5HsuSbnrOV92S2aPcrrTbAoXDmp8qlmRAP0hC?= =?us-ascii?q?oBKjU063/chNBug61HoRKhvx1/zJDSYIGJL/p1Y6fRccoHSWZdQspdUipMDY2m?= =?us-ascii?q?b4sLEuEPI+BWoYfgrFcKtBeyGxWgCObpxzRVhHH5wLc63vwiHw/b3AIuAdwAv3?= =?us-ascii?q?barNXyKKgcVu+6wqbTwDXfbP5bwyvx5ZLUfh0jp/yHQLJ+cdDWyUkqDw7Lk0mQ?= =?us-ascii?q?ppL9PzOVyOsNtXWQ4fdlVe21j24nrx9+oziyzcorkYnGm5kVx0vY9SR53Ik1Jd?= =?us-ascii?q?q4RFR9Yd6/CpRcrS6aN4xoQs47RWxjpSU0yqUetJKmcyUHx44ryh7CZ/CdbYSF?= =?us-ascii?q?7QzvWPyMLTp+mXlrYqiwhwyo/kil0uD8U86030tUoSddidnMs2wN1wTU6siaVv?= =?us-ascii?q?tx5keh1iiL1wDU8uxEPVo7lbDaK5482b48jIYTsETfES/2n0X6lqmWeVk/+ue0?= =?us-ascii?q?8ejnZ7TmppuEO491jAHxLLgul9SiDek3PQUCRWiW9fmm2LH98kD1Xq9GguAunq?= =?us-ascii?q?ncqp/aJMAbpqCjAw9S14Yu8w2/ACq90NkDgXkGLE5KeBKAj4TzPVHOO+r3Ae2w?= =?us-ascii?q?g1Srjjdn3+rGMaH5ApXRMnjDl6/sfbRn5E5Z1gUz1spT55ZOBrEEJ/LzQFXxtN?= =?us-ascii?q?3DDhIiNAy02fzoB8l51owAQ26AHqiZMKbKu1+S+u0vO/WMZJMSuDvlMPgq/OPu?= =?us-ascii?q?jX4imV8Geqmp24AaZ22lEfRgOUmWfX3sgtIZG2cQogU+VPDqiEGFUTNLY3ayXq?= =?us-ascii?q?Q85iw0CY6/DofMWJqtgLqf0ye/BZBWeG9GBU6WEXvydIWLRe0MaCSMLc9liDAE?= =?us-ascii?q?UqKhS4A53xG0qAD606ZnLvbT+iAAsZLj1d515/DclB0r7jx7EdiS03yXT2F1gm?= =?us-ascii?q?MJRyY63KV4oUNg11eD1bZ3judGFdxc+fxJSB02NZ3CwOxgDdD9RAbBcs2OSFa8?= =?us-ascii?q?TdWsGSsxQc4pw98Sf0Z9HM2vjgvY0Cq3Ar8VjKeLBJsy8q7Gwnf+OsB9xm3J1K?= =?us-ascii?q?kklVYmQ89POXe6ia548giAT7LOxn6Una+xaaUR2mbn6WaY1m2I9BVDWhNxSr7C?= =?us-ascii?q?WzYTak3+otHw50eERLirX/BvNgpH1N7HMaZBd8fokUQDQfDvJdDTS3y+ln32Bh?= =?us-ascii?q?uSwL6IKo3wdCFV2CTbFVhBkA0J+3uCHRYxCz3noG/ECjFqU1X1bAek6uR6qXWm?= =?us-ascii?q?Xmco3gqKaAtnzLPz9RkL1tKGTPZG5a4JoCcsrX1PGV+529/HQ46bqxFJYLRXYd?= =?us-ascii?q?R75kxOk23eqVoubdSbM6l+iwtGIExMtET02kAyU98YnA=3D=3D?= X-IPAS-Result: =?us-ascii?q?A2GUBADH5QBZ/wHyM5BcGgEBAQECAQEBAQgBAQEBFgEBAQM?= =?us-ascii?q?BAQEJAQEBgwEpgW2DaJouAQEBAQEHgSaXeoYkAoQqVwEBAQEBAQEBAgECaCiCM?= =?us-ascii?q?yIBgkABBSMPAUYQCQINAQoCAiYCAlcGARKIBYIJDY0PnWGCJiYCin0BAQEBAQE?= =?us-ascii?q?BAwEBAQEBAQEhgQuFA4U+gTyGKYJfAQSdTpMLggKJEAyGQJQnWIEHHgkCGwgfD?= =?us-ascii?q?4UwAQwQgX8kNYY6K4IQAQEB?= Message-ID: <1493231502.32540.12.camel@tycho.nsa.gov> Subject: Re: [PATCH 3/3] selinux: expose policy SHA256 checksum via selinuxfs From: Stephen Smalley To: Sebastien Buisson , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov Cc: Sebastien Buisson , james.l.morris@oracle.com Date: Wed, 26 Apr 2017 14:31:42 -0400 In-Reply-To: <1493218936-18522-3-git-send-email-sbuisson@ddn.com> References: <1493218936-18522-1-git-send-email-sbuisson@ddn.com> <1493218936-18522-3-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 On Thu, 2017-04-27 at 00:02 +0900, Sebastien Buisson wrote: > Expose policy SHA256 checksum via selinuxfs. > > Signed-off-by: Sebastien Buisson > --- >  security/selinux/selinuxfs.c | 20 ++++++++++++++++++++ >  1 file changed, 20 insertions(+) > > diff --git a/security/selinux/selinuxfs.c > b/security/selinux/selinuxfs.c > index ce71718..b2d5deb 100644 > --- a/security/selinux/selinuxfs.c > +++ b/security/selinux/selinuxfs.c > @@ -30,6 +30,7 @@ >  #include >  #include >  #include > +#include >   >  /* selinuxfs pseudo filesystem for exporting the security policy > API. >     Based on the proc code and the fs/nfsd/nfsctl.c code. */ > @@ -99,6 +100,7 @@ enum sel_inos { >   SEL_STATUS, /* export current status using mmap() */ >   SEL_POLICY, /* allow userspace to read the in kernel > policy */ >   SEL_VALIDATE_TRANS, /* compute validatetrans decision */ > + SEL_POLICYCKSUM,/* return policy SHA256 checkum */ >   SEL_INO_NEXT, /* The next inode number to use */ >  }; >   > @@ -313,6 +315,22 @@ static ssize_t sel_read_policyvers(struct file > *filp, char __user *buf, >   .llseek = generic_file_llseek, >  }; >   > +static ssize_t sel_read_policycksum(struct file *filp, char __user > *buf, > +     size_t count, loff_t *ppos) > +{ > + size_t tmpbuflen = SHA256_DIGEST_SIZE*2 + 1; > + char tmpbuf[tmpbuflen]; > + ssize_t length; > + > + length = security_policydb_cksum(tmpbuf, tmpbuflen); > + return simple_read_from_buffer(buf, count, ppos, tmpbuf, > length); > +} Should we also include information about the hash used, in case it changes in the future? > + > +static const struct file_operations sel_policycksum_ops = { > + .read = sel_read_policycksum, > + .llseek = generic_file_llseek, > +}; > + >  /* declaration for sel_write_load */ >  static int sel_make_bools(void); >  static int sel_make_classes(void); > @@ -1825,6 +1843,8 @@ static int sel_fill_super(struct super_block > *sb, void *data, int silent) >   [SEL_POLICY] = {"policy", &sel_policy_ops, S_IRUGO}, >   [SEL_VALIDATE_TRANS] = {"validatetrans", > &sel_transition_ops, >   S_IWUGO}, > + [SEL_POLICYCKSUM] = {"policycksum", > &sel_policycksum_ops, > +      S_IRUGO}, >   /* last one */ {""} >   }; >   ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files);