Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1631532 > unrolled thread
| Started by | Sebastien Buisson <sbuisson.ddn@gmail.com> |
|---|---|
| First post | 2017-04-26 17:30 +0200 |
| Last post | 2017-04-27 03:10 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/3] selinux: expose policy SHA256 checksum via selinuxfs Sebastien Buisson <sbuisson.ddn@gmail.com> - 2017-04-26 17:30 +0200
Re: [PATCH 3/3] selinux: expose policy SHA256 checksum via selinuxfs Stephen Smalley <sds@tycho.nsa.gov> - 2017-04-26 20:30 +0200
Re: [PATCH 3/3] selinux: expose policy SHA256 checksum via selinuxfs James Morris <jmorris@namei.org> - 2017-04-27 03:10 +0200
| From | Sebastien Buisson <sbuisson.ddn@gmail.com> |
|---|---|
| Date | 2017-04-26 17:30 +0200 |
| Subject | [PATCH 3/3] selinux: expose policy SHA256 checksum via selinuxfs |
| Message-ID | <tAx3e-46S-59@gated-at.bofh.it> |
Expose policy SHA256 checksum via selinuxfs.
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
---
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 <linux/uaccess.h>
#include <linux/kobject.h>
#include <linux/ctype.h>
+#include <crypto/sha.h>
/* 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);
+}
+
+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);
--
1.8.3.1
[toc] | [next] | [standalone]
| From | Stephen Smalley <sds@tycho.nsa.gov> |
|---|---|
| Date | 2017-04-26 20:30 +0200 |
| Message-ID | <tAzRo-5Yn-25@gated-at.bofh.it> |
| In reply to | #1631532 |
On Thu, 2017-04-27 at 00:02 +0900, Sebastien Buisson wrote:
> Expose policy SHA256 checksum via selinuxfs.
>
> Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
> ---
> 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 <linux/uaccess.h>
> #include <linux/kobject.h>
> #include <linux/ctype.h>
> +#include <crypto/sha.h>
>
> /* 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);
[toc] | [prev] | [next] | [standalone]
| From | James Morris <jmorris@namei.org> |
|---|---|
| Date | 2017-04-27 03:10 +0200 |
| Subject | Re: [PATCH 3/3] selinux: expose policy SHA256 checksum via selinuxfs |
| Message-ID | <tAG6t-1KR-1@gated-at.bofh.it> |
| In reply to | #1631651 |
On Wed, 26 Apr 2017, Stephen Smalley wrote: > > + 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? > Good idea, yes. -- James Morris <jmorris@namei.org>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web