apparmor: fix invalid reference on profile->disconnected
[ Upstream commit 8884ba07786c718771cf7b78cb3024924b27ec2b ]
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: 72c8a76864
("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>
This commit is contained in:
parent
cef064fdde
commit
6cb0495d36
|
@ -218,6 +218,7 @@ void aa_free_profile(struct aa_profile *profile)
|
||||||
|
|
||||||
aa_put_ns(profile->ns);
|
aa_put_ns(profile->ns);
|
||||||
kfree_sensitive(profile->rename);
|
kfree_sensitive(profile->rename);
|
||||||
|
kfree_sensitive(profile->disconnected);
|
||||||
|
|
||||||
aa_free_file_rules(&profile->file);
|
aa_free_file_rules(&profile->file);
|
||||||
aa_free_cap_rules(&profile->caps);
|
aa_free_cap_rules(&profile->caps);
|
||||||
|
|
|
@ -656,7 +656,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
|
||||||
const char *info = "failed to unpack profile";
|
const char *info = "failed to unpack profile";
|
||||||
size_t ns_len;
|
size_t ns_len;
|
||||||
struct rhashtable_params params = { 0 };
|
struct rhashtable_params params = { 0 };
|
||||||
char *key = NULL;
|
char *key = NULL, *disconnected = NULL;
|
||||||
struct aa_data *data;
|
struct aa_data *data;
|
||||||
int i, error = -EPROTO;
|
int i, error = -EPROTO;
|
||||||
kernel_cap_t tmpcap;
|
kernel_cap_t tmpcap;
|
||||||
|
@ -710,7 +710,8 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disconnected attachment string is optional */
|
/* disconnected attachment string is optional */
|
||||||
(void) aa_unpack_str(e, &profile->disconnected, "disconnected");
|
(void) aa_unpack_strdup(e, &disconnected, "disconnected");
|
||||||
|
profile->disconnected = disconnected;
|
||||||
|
|
||||||
/* per profile debug flags (complain, audit) */
|
/* per profile debug flags (complain, audit) */
|
||||||
if (!aa_unpack_nameX(e, AA_STRUCT, "flags")) {
|
if (!aa_unpack_nameX(e, AA_STRUCT, "flags")) {
|
||||||
|
|
Loading…
Reference in New Issue