apparmor: fix unsigned len comparison with less than zero
authorColin Ian King <colin.king@canonical.com>
Thu, 27 Jun 2019 13:09:04 +0000 (14:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Jan 2020 18:18:22 +0000 (19:18 +0100)
commit4f13232aa6370e09616563514ed7ef9d81c69f0e
treeff50cb6fef4dd3399f62b3ab760fd428ba23f413
parentadeec3de92221e6f32935b95e96b7418f14ea457
apparmor: fix unsigned len comparison with less than zero

[ Upstream commit 00e0590dbaec6f1bcaa36a85467d7e3497ced522 ]

The sanity check in macro update_for_len checks to see if len
is less than zero, however, len is a size_t so it can never be
less than zero, so this sanity check is a no-op.  Fix this by
making len a ssize_t so the comparison will work and add ulen
that is a size_t copy of len so that the min() macro won't
throw warnings about comparing different types.

Addresses-Coverity: ("Macro compares unsigned to 0")
Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/apparmor/label.c