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>] [day] [month] [year] [list]
Message-ID: <8c451435-4609-55a6-e92a-ac325690234b@schaufler-ca.com>
Date:   Tue, 7 Jun 2022 06:47:53 -0700
From:   Casey Schaufler <casey@...aufler-ca.com>
To:     "GONG, Ruiqi" <ruiqi.gong@...com>,
        James Morris <jmorris@...ei.org>,
        Serge E Hallyn <serge@...lyn.com>
Cc:     linux-security-module@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Wang Weiyang <wangweiyang2@...wei.com>,
        Xiu Jianfeng <xiujianfeng@...wei.com>,
        GONG Ruiqi <gongruiqi1@...wei.com>,
        Casey Schaufler <casey@...aufler-ca.com>
Subject: Re: [PATCH] smack: Replace kzalloc + strncpy with kstrndup

On 6/6/2022 1:17 AM, GONG, Ruiqi wrote:
> From: "GONG, Ruiqi" <gongruiqi1@...wei.com>
>
> Simplify the code by using kstrndup instead of kzalloc and strncpy in
> smk_parse_smack(), which meanwhile remove strncpy as [1] suggests.
>
> [1]: https://github.com/KSPP/linux/issues/90
>
> Signed-off-by: GONG, Ruiqi <gongruiqi1@...wei.com>

Thank you. I will take this for the Smack tree.

> ---
>   security/smack/smack_access.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
> index d2186e2757be..585e5e35710b 100644
> --- a/security/smack/smack_access.c
> +++ b/security/smack/smack_access.c
> @@ -465,12 +465,9 @@ char *smk_parse_smack(const char *string, int len)
>   	if (i == 0 || i >= SMK_LONGLABEL)
>   		return ERR_PTR(-EINVAL);
>   
> -	smack = kzalloc(i + 1, GFP_NOFS);
> -	if (smack == NULL)
> +	smack = kstrndup(string, i, GFP_NOFS);
> +	if (!smack)
>   		return ERR_PTR(-ENOMEM);
> -
> -	strncpy(smack, string, i);
> -
>   	return smack;
>   }
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ