lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAEqDhD-wCGY7ykjSsNgCri4ykWPi9cP3j1zoQPWddB4r92Kqw@mail.gmail.com>
Date:   Fri, 17 Jul 2020 18:35:03 +0300
From:   Konsta Karsisto <konsta.karsisto@...il.com>
To:     Tyler Hicks <tyhicks@...ux.microsoft.com>,
        linux-integrity@...r.kernel.org
Cc:     Mimi Zohar <zohar@...ux.ibm.com>,
        Dmitry Kasatkin <dmitry.kasatkin@...il.com>,
        James Morris <jmorris@...ei.org>,
        "Serge E . Hallyn" <serge@...lyn.com>,
        Lakshmi Ramasubramanian <nramas@...ux.microsoft.com>,
        Prakhar Srivastava <prsriva02@...il.com>,
        linux-kernel@...r.kernel.org, linux-security-module@...r.kernel.org
Subject: Re: [PATCH v3 08/12] ima: Shallow copy the args_p member of
 ima_rule_entry.lsm elements

Hi,

Found one glitch with this change, see below:

On Thu, Jul 9, 2020 at 9:22 AM Tyler Hicks <tyhicks@...ux.microsoft.com> wrote:
>
> The args_p member is a simple string that is allocated by
> ima_rule_init(). Shallow copy it like other non-LSM references in
> ima_rule_entry structs.
>
> There are no longer any necessary error path cleanups to do in
> ima_lsm_copy_rule().
>
> Signed-off-by: Tyler Hicks <tyhicks@...ux.microsoft.com>
> ---
>
> * v3
>   - No change
> * v2
>   - Adjusted context to account for ima_lsm_copy_rule() directly calling
>     ima_lsm_free_rule() and the lack of explicit reference ownership
>     transfers
>   - Added comment to ima_lsm_copy_rule() to document the args_p
>     reference ownership transfer
>
>  security/integrity/ima/ima_policy.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index 9842e2e0bc6d..b02e1ffd10c9 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -300,10 +300,13 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry)
>                         continue;
>
>                 nentry->lsm[i].type = entry->lsm[i].type;
> -               nentry->lsm[i].args_p = kstrdup(entry->lsm[i].args_p,
> -                                               GFP_KERNEL);
> -               if (!nentry->lsm[i].args_p)
> -                       goto out_err;
> +               nentry->lsm[i].args_p = entry->lsm[i].args_p;
> +               /*
> +                * Remove the reference from entry so that the associated
> +                * memory will not be freed during a later call to
> +                * ima_lsm_free_rule(entry).
> +                */
> +               entry->lsm[i].args_p = NULL;

This assignment necessitates a change in the code below...

>                 security_filter_rule_init(nentry->lsm[i].type,
>                                           Audit_equal,
> @@ -314,11 +317,6 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry)
>                                 (char *)entry->lsm[i].args_p);

... you should refer to nentry->lsm[i].args_p here!

Other than that,

Reviewed-by: Konsta Karsisto <konsta.karsisto@...il.com>


Konsta

>         }
>         return nentry;
> -
> -out_err:
> -       ima_lsm_free_rule(nentry);
> -       kfree(nentry);
> -       return NULL;
>  }
>
>  static int ima_lsm_update_rule(struct ima_rule_entry *entry)
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ