Skip to content

Commit 6cb0495

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 <georgia.garcia@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cef064f commit 6cb0495

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
@@ -218,6 +218,7 @@ void aa_free_profile(struct aa_profile *profile)
218218

219219
aa_put_ns(profile->ns);
220220
kfree_sensitive(profile->rename);
221+
kfree_sensitive(profile->disconnected);
221222

222223
aa_free_file_rules(&profile->file);
223224
aa_free_cap_rules(&profile->caps);

security/apparmor/policy_unpack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
656656
const char *info = "failed to unpack profile";
657657
size_t ns_len;
658658
struct rhashtable_params params = { 0 };
659-
char *key = NULL;
659+
char *key = NULL, *disconnected = NULL;
660660
struct aa_data *data;
661661
int i, error = -EPROTO;
662662
kernel_cap_t tmpcap;
@@ -710,7 +710,8 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
710710
}
711711

712712
/* disconnected attachment string is optional */
713-
(void) aa_unpack_str(e, &profile->disconnected, "disconnected");
713+
(void) aa_unpack_strdup(e, &disconnected, "disconnected");
714+
profile->disconnected = disconnected;
714715

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

0 commit comments

Comments
 (0)