summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorMuhammad Usama Anjum <usama.anjum@collabora.com>2022-10-04 13:45:15 +0500
committerJohn Johansen <john.johansen@canonical.com>2022-10-04 02:34:29 -0700
commit5515a8e30eaa8ae0d57ec59c908716cf2af114ae (patch)
tree3c05f5a57eeb4a328dc41362f90bb4e93c427276 /security
parent32490541682bf8ea445e9bd29c866981851e0912 (diff)
downloadlinux-5515a8e30eaa8ae0d57ec59c908716cf2af114ae.tar.gz
linux-5515a8e30eaa8ae0d57ec59c908716cf2af114ae.tar.bz2
linux-5515a8e30eaa8ae0d57ec59c908716cf2af114ae.zip
apparmor: store return value of unpack_perms_table() to signed variable
The unpack_perms_table() can return error which is negative value. Store the return value to a signed variable. policy->size is unsigned variable. It shouldn't be used to store the return status. Fixes: 2d6b2dea7f3c ("apparmor: add the ability for policy to specify a permission table") Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/policy_unpack.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
index 45c9dfdc8e0d..09f316943951 100644
--- a/security/apparmor/policy_unpack.c
+++ b/security/apparmor/policy_unpack.c
@@ -734,14 +734,18 @@ static int unpack_pdb(struct aa_ext *e, struct aa_policydb *policy,
{
void *pos = e->pos;
int i, flags, error = -EPROTO;
+ ssize_t size;
- policy->size = unpack_perms_table(e, &policy->perms);
- if (policy->size < 0) {
- error = policy->size;
+ size = unpack_perms_table(e, &policy->perms);
+ if (size < 0) {
+ error = size;
policy->perms = NULL;
*info = "failed to unpack - perms";
goto fail;
- } else if (policy->perms) {
+ }
+ policy->size = size;
+
+ if (policy->perms) {
/* perms table present accept is index */
flags = TO_ACCEPT1_FLAG(YYTD_DATA32);
} else {