Skip to content

Commit f997e1b

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 74e5ce3 commit f997e1b

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
@@ -804,7 +804,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
804804
const char *info = "failed to unpack profile";
805805
size_t ns_len;
806806
struct rhashtable_params params = { 0 };
807-
char *key = NULL;
807+
char *key = NULL, *disconnected = NULL;
808808
struct aa_data *data;
809809
int error = -EPROTO;
810810
kernel_cap_t tmpcap;
@@ -870,7 +870,8 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
870870
}
871871

872872
/* disconnected attachment string is optional */
873-
(void) aa_unpack_str(e, &profile->disconnected, "disconnected");
873+
(void) aa_unpack_strdup(e, &disconnected, "disconnected");
874+
profile->disconnected = disconnected;
874875

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

0 commit comments

Comments
 (0)