aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/selinuxfs.c
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2015-10-21 17:44:25 -0400
committerPaul Moore <pmoore@redhat.com>2015-10-21 17:44:25 -0400
commit44be2f65d979291ffb2a47112449507ffe1f9726 (patch)
tree9f3732d534de8425f6bf5d7519812263d0c292c9 /security/selinux/selinuxfs.c
parent44d37ad3602b3823764eeb0f6c1ee3ef6c4fb936 (diff)
selinux: introduce security_context_str_to_sid
There seems to be a little confusion as to whether the scontext_len parameter of security_context_to_sid() includes the nul-byte or not. Reading security_context_to_sid_core(), it seems that the expectation is that it does not (both the string copying and the test for scontext_len being zero hint at that). Introduce the helper security_context_str_to_sid() to do the strlen() call and fix all callers. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Paul Moore <pmoore@redhat.com>
Diffstat (limited to 'security/selinux/selinuxfs.c')
-rw-r--r--security/selinux/selinuxfs.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 5bed7716f8ab..c02da25d7b63 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -731,13 +731,11 @@ static ssize_t sel_write_access(struct file *file, char *buf, size_t size)
731 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 731 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
732 goto out; 732 goto out;
733 733
734 length = security_context_to_sid(scon, strlen(scon) + 1, &ssid, 734 length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL);
735 GFP_KERNEL);
736 if (length) 735 if (length)
737 goto out; 736 goto out;
738 737
739 length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid, 738 length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL);
740 GFP_KERNEL);
741 if (length) 739 if (length)
742 goto out; 740 goto out;
743 741
@@ -819,13 +817,11 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
819 objname = namebuf; 817 objname = namebuf;
820 } 818 }
821 819
822 length = security_context_to_sid(scon, strlen(scon) + 1, &ssid, 820 length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL);
823 GFP_KERNEL);
824 if (length) 821 if (length)
825 goto out; 822 goto out;
826 823
827 length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid, 824 length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL);
828 GFP_KERNEL);
829 if (length) 825 if (length)
830 goto out; 826 goto out;
831 827
@@ -882,13 +878,11 @@ static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size)
882 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 878 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
883 goto out; 879 goto out;
884 880
885 length = security_context_to_sid(scon, strlen(scon) + 1, &ssid, 881 length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL);
886 GFP_KERNEL);
887 if (length) 882 if (length)
888 goto out; 883 goto out;
889 884
890 length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid, 885 length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL);
891 GFP_KERNEL);
892 if (length) 886 if (length)
893 goto out; 887 goto out;
894 888
@@ -940,7 +934,7 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size)
940 if (sscanf(buf, "%s %s", con, user) != 2) 934 if (sscanf(buf, "%s %s", con, user) != 2)
941 goto out; 935 goto out;
942 936
943 length = security_context_to_sid(con, strlen(con) + 1, &sid, GFP_KERNEL); 937 length = security_context_str_to_sid(con, &sid, GFP_KERNEL);
944 if (length) 938 if (length)
945 goto out; 939 goto out;
946 940
@@ -1000,13 +994,11 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)
1000 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 994 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
1001 goto out; 995 goto out;
1002 996
1003 length = security_context_to_sid(scon, strlen(scon) + 1, &ssid, 997 length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL);
1004 GFP_KERNEL);
1005 if (length) 998 if (length)
1006 goto out; 999 goto out;
1007 1000
1008 length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid, 1001 length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL);
1009 GFP_KERNEL);
1010 if (length) 1002 if (length)
1011 goto out; 1003 goto out;
1012 1004