aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-09-30 23:55:03 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-30 23:55:03 -0400
commite993835441734c184d70d3716eed78a08eeb71c2 (patch)
tree583aa17813cdae1c4640e353f8c6df3f197e7548 /security/selinux
parent360f654e7cda850034f3f6252a7a7cff3fa77356 (diff)
parent1bdfd554be94def718323659173517c5d4a69d25 (diff)
Merge branch 'master' into upstream
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/hooks.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e4d81a42fca4..e9969a2fc846 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -398,7 +398,7 @@ static int try_context_mount(struct super_block *sb, void *data)
398 /* Standard string-based options. */ 398 /* Standard string-based options. */
399 char *p, *options = data; 399 char *p, *options = data;
400 400
401 while ((p = strsep(&options, ",")) != NULL) { 401 while ((p = strsep(&options, "|")) != NULL) {
402 int token; 402 int token;
403 substring_t args[MAX_OPT_ARGS]; 403 substring_t args[MAX_OPT_ARGS];
404 404
@@ -1923,18 +1923,40 @@ static inline void take_option(char **to, char *from, int *first, int len)
1923 if (!*first) { 1923 if (!*first) {
1924 **to = ','; 1924 **to = ',';
1925 *to += 1; 1925 *to += 1;
1926 } 1926 } else
1927 else
1928 *first = 0; 1927 *first = 0;
1929 memcpy(*to, from, len); 1928 memcpy(*to, from, len);
1930 *to += len; 1929 *to += len;
1931} 1930}
1932 1931
1932static inline void take_selinux_option(char **to, char *from, int *first,
1933 int len)
1934{
1935 int current_size = 0;
1936
1937 if (!*first) {
1938 **to = '|';
1939 *to += 1;
1940 }
1941 else
1942 *first = 0;
1943
1944 while (current_size < len) {
1945 if (*from != '"') {
1946 **to = *from;
1947 *to += 1;
1948 }
1949 from += 1;
1950 current_size += 1;
1951 }
1952}
1953
1933static int selinux_sb_copy_data(struct file_system_type *type, void *orig, void *copy) 1954static int selinux_sb_copy_data(struct file_system_type *type, void *orig, void *copy)
1934{ 1955{
1935 int fnosec, fsec, rc = 0; 1956 int fnosec, fsec, rc = 0;
1936 char *in_save, *in_curr, *in_end; 1957 char *in_save, *in_curr, *in_end;
1937 char *sec_curr, *nosec_save, *nosec; 1958 char *sec_curr, *nosec_save, *nosec;
1959 int open_quote = 0;
1938 1960
1939 in_curr = orig; 1961 in_curr = orig;
1940 sec_curr = copy; 1962 sec_curr = copy;
@@ -1956,11 +1978,14 @@ static int selinux_sb_copy_data(struct file_system_type *type, void *orig, void
1956 in_save = in_end = orig; 1978 in_save = in_end = orig;
1957 1979
1958 do { 1980 do {
1959 if (*in_end == ',' || *in_end == '\0') { 1981 if (*in_end == '"')
1982 open_quote = !open_quote;
1983 if ((*in_end == ',' && open_quote == 0) ||
1984 *in_end == '\0') {
1960 int len = in_end - in_curr; 1985 int len = in_end - in_curr;
1961 1986
1962 if (selinux_option(in_curr, len)) 1987 if (selinux_option(in_curr, len))
1963 take_option(&sec_curr, in_curr, &fsec, len); 1988 take_selinux_option(&sec_curr, in_curr, &fsec, len);
1964 else 1989 else
1965 take_option(&nosec, in_curr, &fnosec, len); 1990 take_option(&nosec, in_curr, &fnosec, len);
1966 1991
@@ -3594,7 +3619,9 @@ static void selinux_sock_graft(struct sock* sk, struct socket *parent)
3594 struct inode_security_struct *isec = SOCK_INODE(parent)->i_security; 3619 struct inode_security_struct *isec = SOCK_INODE(parent)->i_security;
3595 struct sk_security_struct *sksec = sk->sk_security; 3620 struct sk_security_struct *sksec = sk->sk_security;
3596 3621
3597 isec->sid = sksec->sid; 3622 if (sk->sk_family == PF_INET || sk->sk_family == PF_INET6 ||
3623 sk->sk_family == PF_UNIX)
3624 isec->sid = sksec->sid;
3598 3625
3599 selinux_netlbl_sock_graft(sk, parent); 3626 selinux_netlbl_sock_graft(sk, parent);
3600} 3627}