Skip to content

Commit 08020db

Browse files
m-pellizzerjrjohansen
authored andcommitted
apparmor: fix signedness bug in unpack_tags()
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: 3d28e23 ("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>
1 parent 1b51bd7 commit 08020db

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

security/apparmor/policy_unpack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ static int unpack_tag_headers(struct aa_ext *e, struct aa_tags_struct *tags)
835835
}
836836

837837

838-
static size_t unpack_tags(struct aa_ext *e, struct aa_tags_struct *tags,
838+
static int unpack_tags(struct aa_ext *e, struct aa_tags_struct *tags,
839839
const char **info)
840840
{
841841
int error = -EPROTO;

0 commit comments

Comments
 (0)