]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
apparmor: fix signedness bug in unpack_tags()
authorMassimiliano Pellizzer <mpellizzer.dev@gmail.com>
Tue, 10 Feb 2026 17:15:38 +0000 (18:15 +0100)
committerJohn Johansen <john.johansen@canonical.com>
Wed, 18 Feb 2026 19:50:20 +0000 (11:50 -0800)
Smatch static checker warning:
    security/apparmor/policy_unpack.c:966 unpack_pdb()
    warn: unsigned 'unpack_tags(e, &pdb->tags, info)' is never less than zero.

unpack_tags() is declared with return type size_t (unsigned) but returns
negative errno values on failure. The caller in unpack_pdb() tests the
return with `< 0`, which is always false for an unsigned type, making
error handling dead code. Malformed tag data would be silently accepted
instead of causing a load failure.

Change return type of unpack_tags() from size_t to int to match the
functions's actual semantic.

Fixes: 3d28e2397af7 ("apparmor: add support loading per permission tagging")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Massimiliano Pellizzer <mpellizzer.dev@gmail.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_unpack.c

index e68adf39771fd41ed585ac9db20839c13382f98c..dc908e1f5a880845938d2abe93f79d64a1a47dad 100644 (file)
@@ -835,7 +835,7 @@ fail_reset:
 }
 
 
-static size_t unpack_tags(struct aa_ext *e, struct aa_tags_struct *tags,
+static int unpack_tags(struct aa_ext *e, struct aa_tags_struct *tags,
        const char **info)
 {
        int error = -EPROTO;