Skip to content

Commit 8d0d83f

Browse files
gegarciagregkh
authored andcommitted
apparmor: fix invalid reference on profile->disconnected
[ Upstream commit 8884ba0 ] profile->disconnected was storing an invalid reference to the disconnected path. Fix it by duplicating the string using aa_unpack_strdup and freeing accordingly. Fixes: 72c8a76 ("apparmor: allow profiles to provide info to disconnected paths") Signed-off-by: Georgia Garcia <[email protected]> Signed-off-by: John Johansen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 8762d25 commit 8d0d83f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

security/apparmor/policy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ void aa_free_profile(struct aa_profile *profile)
255255

256256
aa_put_ns(profile->ns);
257257
kfree_sensitive(profile->rename);
258+
kfree_sensitive(profile->disconnected);
258259

259260
free_attachment(&profile->attach);
260261

security/apparmor/policy_unpack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
807807
const char *info = "failed to unpack profile";
808808
size_t ns_len;
809809
struct rhashtable_params params = { 0 };
810-
char *key = NULL;
810+
char *key = NULL, *disconnected = NULL;
811811
struct aa_data *data;
812812
int error = -EPROTO;
813813
kernel_cap_t tmpcap;
@@ -873,7 +873,8 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
873873
}
874874

875875
/* disconnected attachment string is optional */
876-
(void) aa_unpack_str(e, &profile->disconnected, "disconnected");
876+
(void) aa_unpack_strdup(e, &disconnected, "disconnected");
877+
profile->disconnected = disconnected;
877878

878879
/* per profile debug flags (complain, audit) */
879880
if (!aa_unpack_nameX(e, AA_STRUCT, "flags")) {

0 commit comments

Comments
 (0)