smack: get rid of match_token()
same issue as with selinux... [fix by Andrei Vagin folded in] Reviewed-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
55c0e5bd07
commit
c3300aaf95
@ -59,14 +59,31 @@ static LIST_HEAD(smk_ipv6_port_list);
|
|||||||
static struct kmem_cache *smack_inode_cache;
|
static struct kmem_cache *smack_inode_cache;
|
||||||
int smack_enabled;
|
int smack_enabled;
|
||||||
|
|
||||||
static const match_table_t smk_mount_tokens = {
|
#define A(s) {"smack"#s, sizeof("smack"#s) - 1, Opt_##s}
|
||||||
{Opt_fsdefault, SMK_FSDEFAULT "%s"},
|
static struct {
|
||||||
{Opt_fsfloor, SMK_FSFLOOR "%s"},
|
const char *name;
|
||||||
{Opt_fshat, SMK_FSHAT "%s"},
|
int len;
|
||||||
{Opt_fsroot, SMK_FSROOT "%s"},
|
int opt;
|
||||||
{Opt_fstransmute, SMK_FSTRANS "%s"},
|
} smk_mount_opts[] = {
|
||||||
{Opt_error, NULL},
|
A(fsdefault), A(fsfloor), A(fshat), A(fsroot), A(fstransmute)
|
||||||
};
|
};
|
||||||
|
#undef A
|
||||||
|
|
||||||
|
static int match_opt_prefix(char *s, int l, char **arg)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(smk_mount_opts); i++) {
|
||||||
|
size_t len = smk_mount_opts[i].len;
|
||||||
|
if (len > l || memcmp(s, smk_mount_opts[i].name, len))
|
||||||
|
continue;
|
||||||
|
if (len == l || s[len] != '=')
|
||||||
|
continue;
|
||||||
|
*arg = s + len + 1;
|
||||||
|
return smk_mount_opts[i].opt;
|
||||||
|
}
|
||||||
|
return Opt_error;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SECURITY_SMACK_BRINGUP
|
#ifdef CONFIG_SECURITY_SMACK_BRINGUP
|
||||||
static char *smk_bu_mess[] = {
|
static char *smk_bu_mess[] = {
|
||||||
@ -689,23 +706,23 @@ out_opt_err:
|
|||||||
static int smack_parse_opts_str(char *options,
|
static int smack_parse_opts_str(char *options,
|
||||||
void **mnt_opts)
|
void **mnt_opts)
|
||||||
{
|
{
|
||||||
char *p;
|
char *from = options;
|
||||||
int rc = -ENOMEM;
|
|
||||||
int token;
|
|
||||||
|
|
||||||
if (!options)
|
if (!options)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while ((p = strsep(&options, ",")) != NULL) {
|
while (1) {
|
||||||
substring_t args[MAX_OPT_ARGS];
|
char *next = strchr(from, ',');
|
||||||
const char *arg;
|
int token, len, rc;
|
||||||
|
char *arg = NULL;
|
||||||
|
|
||||||
if (!*p)
|
if (next)
|
||||||
continue;
|
len = next - from;
|
||||||
|
else
|
||||||
|
len = strlen(from);
|
||||||
|
|
||||||
token = match_token(p, smk_mount_tokens, args);
|
token = match_opt_prefix(from, len, &arg);
|
||||||
|
arg = kmemdup_nul(arg, from + len - arg, GFP_KERNEL);
|
||||||
arg = match_strdup(&args[0]);
|
|
||||||
rc = smack_add_opt(token, arg, mnt_opts);
|
rc = smack_add_opt(token, arg, mnt_opts);
|
||||||
if (unlikely(rc)) {
|
if (unlikely(rc)) {
|
||||||
kfree(arg);
|
kfree(arg);
|
||||||
@ -714,6 +731,9 @@ static int smack_parse_opts_str(char *options,
|
|||||||
*mnt_opts = NULL;
|
*mnt_opts = NULL;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
if (!from[len])
|
||||||
|
break;
|
||||||
|
from += len + 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user