Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

apparmor: fix invalid reference on profile->disconnected

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: 72c8a768641d ("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>

authored by

Georgia Garcia and committed by
John Johansen
8884ba07 efea5b0d

+4 -2
+1
security/apparmor/policy.c
··· 255 255 256 256 aa_put_ns(profile->ns); 257 257 kfree_sensitive(profile->rename); 258 + kfree_sensitive(profile->disconnected); 258 259 259 260 free_attachment(&profile->attach); 260 261
+3 -2
security/apparmor/policy_unpack.c
··· 804 804 const char *info = "failed to unpack profile"; 805 805 size_t ns_len; 806 806 struct rhashtable_params params = { 0 }; 807 - char *key = NULL; 807 + char *key = NULL, *disconnected = NULL; 808 808 struct aa_data *data; 809 809 int error = -EPROTO; 810 810 kernel_cap_t tmpcap; ··· 870 870 } 871 871 872 872 /* 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; 874 875 875 876 /* per profile debug flags (complain, audit) */ 876 877 if (!aa_unpack_nameX(e, AA_STRUCT, "flags")) {