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: <ce770d0f-20b4-8040-8625-365758351998@mojatatu.com>
Date: Fri, 9 Jun 2023 09:30:11 -0300
From: Pedro Tammela <pctammela@...atatu.com>
To: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>, jhs@...atatu.com
Cc: xiyou.wangcong@...il.com, jiri@...nulli.us, davem@...emloft.net,
 edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
 Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH] net/sched: act_pedit: Use kmemdup() to replace kmalloc +
 memcpy

On 09/06/2023 04:01, Jiapeng Chong wrote:
> ./net/sched/act_pedit.c:245:21-28: WARNING opportunity for kmemdup.
> 
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5478
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>

LGTM,

Reviewed-by: Pedro Tammela <pctammela@...atatu.com>

> ---
>   net/sched/act_pedit.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> index fc945c7e4123..8c4e7fddddbf 100644
> --- a/net/sched/act_pedit.c
> +++ b/net/sched/act_pedit.c
> @@ -242,14 +242,12 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
>   	nparms->tcfp_flags = parm->flags;
>   	nparms->tcfp_nkeys = parm->nkeys;
>   
> -	nparms->tcfp_keys = kmalloc(ksize, GFP_KERNEL);
> +	nparms->tcfp_keys = kmemdup(parm->keys, ksize, GFP_KERNEL);
>   	if (!nparms->tcfp_keys) {
>   		ret = -ENOMEM;
>   		goto put_chain;
>   	}
>   
> -	memcpy(nparms->tcfp_keys, parm->keys, ksize);
> -
>   	for (i = 0; i < nparms->tcfp_nkeys; ++i) {
>   		u32 offmask = nparms->tcfp_keys[i].offmask;
>   		u32 cur = nparms->tcfp_keys[i].off;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ