aboutsummaryrefslogtreecommitdiffstats
path: root/security/apparmor/secid.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/apparmor/secid.c')
-rw-r--r--security/apparmor/secid.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/security/apparmor/secid.c b/security/apparmor/secid.c
index 502924853986..c2f0c1571156 100644
--- a/security/apparmor/secid.c
+++ b/security/apparmor/secid.c
@@ -142,6 +142,7 @@ int apparmor_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
142{ 142{
143 /* TODO: cache secctx and ref count so we don't have to recreate */ 143 /* TODO: cache secctx and ref count so we don't have to recreate */
144 struct aa_label *label = aa_secid_to_label(secid); 144 struct aa_label *label = aa_secid_to_label(secid);
145 int len;
145 146
146 AA_BUG(!secdata); 147 AA_BUG(!secdata);
147 AA_BUG(!seclen); 148 AA_BUG(!seclen);
@@ -150,18 +151,19 @@ int apparmor_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
150 return -EINVAL; 151 return -EINVAL;
151 152
152 if (secdata) 153 if (secdata)
153 *seclen = aa_label_asxprint(secdata, root_ns, label, 154 len = aa_label_asxprint(secdata, root_ns, label,
154 FLAG_SHOW_MODE | FLAG_VIEW_SUBNS | 155 FLAG_SHOW_MODE | FLAG_VIEW_SUBNS |
155 FLAG_HIDDEN_UNCONFINED | 156 FLAG_HIDDEN_UNCONFINED | FLAG_ABS_ROOT,
156 FLAG_ABS_ROOT, GFP_ATOMIC); 157 GFP_ATOMIC);
157 else 158 else
158 *seclen = aa_label_snxprint(NULL, 0, root_ns, label, 159 len = aa_label_snxprint(NULL, 0, root_ns, label,
159 FLAG_SHOW_MODE | FLAG_VIEW_SUBNS | 160 FLAG_SHOW_MODE | FLAG_VIEW_SUBNS |
160 FLAG_HIDDEN_UNCONFINED | 161 FLAG_HIDDEN_UNCONFINED | FLAG_ABS_ROOT);
161 FLAG_ABS_ROOT); 162 if (len < 0)
162 if (*seclen < 0)
163 return -ENOMEM; 163 return -ENOMEM;
164 164
165 *seclen = len;
166
165 return 0; 167 return 0;
166} 168}
167 169