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: <50564a28-9c75-497f-a50c-22e08b1f794f@linux.alibaba.com>
Date: Fri, 15 Nov 2024 09:01:45 +0800
From: Joseph Qi <joseph.qi@...ux.alibaba.com>
To: Daniel Yang <danielyangkang@...il.com>, Mark Fasheh <mark@...heh.com>,
 Joel Becker <jlbec@...lplan.org>,
 "open list:ORACLE CLUSTER FILESYSTEM 2 (OCFS2)"
 <ocfs2-devel@...ts.linux.dev>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ocfs2: heartbeat: replace simple_strtoul with kstrtoul



On 11/13/24 4:41 PM, Daniel Yang wrote:
> The function simple_strtoul is deprecated due to ignoring overflows and
> also requires clunkier error checking. Replacing with kstrtoul() leads
> to safer code and cleaner error checking.
> 
> Signed-off-by: Daniel Yang <danielyangkang@...il.com>
> ---
>  fs/ocfs2/cluster/heartbeat.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
> index dff18efbc..4fc1b23f1 100644
> --- a/fs/ocfs2/cluster/heartbeat.c
> +++ b/fs/ocfs2/cluster/heartbeat.c
> @@ -1537,8 +1537,9 @@ static int o2hb_read_block_input(struct o2hb_region *reg,
>  	unsigned long bytes;
>  	char *p = (char *)page;

Please define 'ret' here to make code style consistent.
>  
> -	bytes = simple_strtoul(p, &p, 0);
> -	if (!p || (*p && (*p != '\n')))
> +	int ret = kstrtoul(p, 0, &bytes);
> +

The above blane line can be eleminated.

> +	if (ret)
>  		return -EINVAL;
>  
>  	/* Heartbeat and fs min / max block sizes are the same. */
> @@ -1627,8 +1628,9 @@ static ssize_t o2hb_region_blocks_store(struct config_item *item,
>  	if (reg->hr_bdev_file)
>  		return -EINVAL;
>  
> -	tmp = simple_strtoul(p, &p, 0);
> -	if (!p || (*p && (*p != '\n')))
> +	int ret = kstrtoul(p, 0, &tmp);
> +

Ditto.

> +	if (ret)
>  		return -EINVAL;
>  
>  	if (tmp > O2NM_MAX_NODES || tmp == 0)
> @@ -2142,8 +2144,9 @@ static ssize_t o2hb_heartbeat_group_dead_threshold_store(struct config_item *ite
>  	unsigned long tmp;
>  	char *p = (char *)page;
>  
> -	tmp = simple_strtoul(p, &p, 10);
> -	if (!p || (*p && (*p != '\n')))
> +	int ret = kstrtoul(p, 10, &tmp);
> +

Ditto.

Thanks,
Joseph
> +	if (ret)
>                  return -EINVAL;
>  
>  	/* this will validate ranges for us. */


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ