* [PATCH] apparmor: store return value of unpack_perms_table() to signed variable
@ 2022-10-04 8:45 Muhammad Usama Anjum
2022-10-04 9:52 ` John Johansen
0 siblings, 1 reply; 2+ messages in thread
From: Muhammad Usama Anjum @ 2022-10-04 8:45 UTC (permalink / raw)
To: John Johansen, Paul Moore, James Morris, Serge E. Hallyn
Cc: Muhammad Usama Anjum, kernel, kernel-janitors, apparmor,
linux-security-module, linux-kernel
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>
---
security/apparmor/policy_unpack.c | 12 ++++++++----
1 file 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 {
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] apparmor: store return value of unpack_perms_table() to signed variable
2022-10-04 8:45 [PATCH] apparmor: store return value of unpack_perms_table() to signed variable Muhammad Usama Anjum
@ 2022-10-04 9:52 ` John Johansen
0 siblings, 0 replies; 2+ messages in thread
From: John Johansen @ 2022-10-04 9:52 UTC (permalink / raw)
To: Muhammad Usama Anjum, Paul Moore, James Morris, Serge E. Hallyn
Cc: kernel, kernel-janitors, apparmor, linux-security-module, linux-kernel
On 10/4/22 01:45, Muhammad Usama Anjum wrote:
> 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>
yep, thanks I have pulled this in
Acked-by: john.johansen@canonical.com <john.johansen@canonical.com>
> ---
> security/apparmor/policy_unpack.c | 12 ++++++++----
> 1 file 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 {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-04 9:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 8:45 [PATCH] apparmor: store return value of unpack_perms_table() to signed variable Muhammad Usama Anjum
2022-10-04 9:52 ` John Johansen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.