diff options
author | John Johansen <john.johansen@canonical.com> | 2018-02-05 12:26:46 -0500 |
---|---|---|
committer | John Johansen <john.johansen@canonical.com> | 2018-02-09 14:30:02 -0500 |
commit | a0781209cb894e5115bb00c269b1d94c4b632d6a (patch) | |
tree | 95d74ef6676a6cdfff0c6b11b823c8382f4fe107 | |
parent | cf91600071a973c28cebf314e618610a20ec4d6d (diff) |
apparmor: cleanup: simplify code to get ns symlink name
ns_get_name() is called in only one place and can be folded in.
Signed-off-by: John Johansen <john.johansen@canonical.com>
-rw-r--r-- | security/apparmor/apparmorfs.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 8cdab3c5bc63..1e63ff2e5b85 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c | |||
@@ -119,9 +119,7 @@ static int aafs_count; | |||
119 | 119 | ||
120 | static int aafs_show_path(struct seq_file *seq, struct dentry *dentry) | 120 | static int aafs_show_path(struct seq_file *seq, struct dentry *dentry) |
121 | { | 121 | { |
122 | struct inode *inode = d_inode(dentry); | 122 | seq_printf(seq, "%s:[%lu]", AAFS_NAME, d_inode(dentry)->i_ino); |
123 | |||
124 | seq_printf(seq, "%s:[%lu]", AAFS_NAME, inode->i_ino); | ||
125 | return 0; | 123 | return 0; |
126 | } | 124 | } |
127 | 125 | ||
@@ -2392,29 +2390,18 @@ static const char *policy_get_link(struct dentry *dentry, | |||
2392 | return NULL; | 2390 | return NULL; |
2393 | } | 2391 | } |
2394 | 2392 | ||
2395 | static int ns_get_name(char *buf, size_t size, struct aa_ns *ns, | ||
2396 | struct inode *inode) | ||
2397 | { | ||
2398 | int res = snprintf(buf, size, "%s:[%lu]", AAFS_NAME, inode->i_ino); | ||
2399 | |||
2400 | if (res < 0 || res >= size) | ||
2401 | res = -ENOENT; | ||
2402 | |||
2403 | return res; | ||
2404 | } | ||
2405 | |||
2406 | static int policy_readlink(struct dentry *dentry, char __user *buffer, | 2393 | static int policy_readlink(struct dentry *dentry, char __user *buffer, |
2407 | int buflen) | 2394 | int buflen) |
2408 | { | 2395 | { |
2409 | struct aa_ns *ns; | ||
2410 | char name[32]; | 2396 | char name[32]; |
2411 | int res; | 2397 | int res; |
2412 | 2398 | ||
2413 | ns = aa_get_current_ns(); | 2399 | res = snprintf(name, sizeof(name), "%s:[%lu]", AAFS_NAME, |
2414 | res = ns_get_name(name, sizeof(name), ns, d_inode(dentry)); | 2400 | d_inode(dentry)->i_ino); |
2415 | if (res >= 0) | 2401 | if (res > 0 && res < sizeof(name)) |
2416 | res = readlink_copy(buffer, buflen, name); | 2402 | res = readlink_copy(buffer, buflen, name); |
2417 | aa_put_ns(ns); | 2403 | else |
2404 | res = -ENOENT; | ||
2418 | 2405 | ||
2419 | return res; | 2406 | return res; |
2420 | } | 2407 | } |