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: <Z_WigcRfU7iWnTVv@google.com>
Date: Tue, 8 Apr 2025 15:26:09 -0700
From: Joel Becker <jlbec@...lplan.org>
To: Zijun Hu <zijun_hu@...oud.com>
Cc: Pantelis Antoniou <pantelis.antoniou@...sulko.com>,
	Al Viro <viro@...iv.linux.org.uk>, linux-kernel@...r.kernel.org,
	Zijun Hu <quic_zijuhu@...cinc.com>
Subject: Re: [PATCH 3/4] configfs: Correct error value returned by API
 config_item_set_name()

On Tue, Apr 08, 2025 at 09:26:09PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@...cinc.com>
> 
> kvasprintf() failure is often caused by memory allocation which has error
> code -ENOMEM, but config_item_set_name() returns -EFAULT for the failure.
> 
> Fix by returning -ENOMEM instead of -EFAULT for the failure.

The original code would return -ENOMEM on allocation failure before
calling vsnprintf().  The -EFAULT was because vsnprintf() failed.

This changed in 707c62352909a when vsnprintf() was changed to
kvasprintf().  Since kvasprintf() only really fails on -ENOMEM, the
error code should have been updated at the time.


> Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>

Reviewed-by: Joel Becker <jlbec@...lplan.org>

> ---
>  fs/configfs/item.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/configfs/item.c b/fs/configfs/item.c
> index 254170a82aa337d95cbfbdf1a2db1023db3a2907..c378b5cbf87d28387a509c3cabb93eccfb520c9c 100644
> --- a/fs/configfs/item.c
> +++ b/fs/configfs/item.c
> @@ -66,7 +66,7 @@ int config_item_set_name(struct config_item *item, const char *fmt, ...)
>  		name = kvasprintf(GFP_KERNEL, fmt, args);
>  		va_end(args);
>  		if (!name)
> -			return -EFAULT;
> +			return -ENOMEM;
>  	}
>  
>  	/* Free the old name, if necessary. */
> 
> -- 
> 2.34.1
> 

-- 

Life's Little Instruction Book #274

	"Leave everything a little better than you found it."

			http://www.jlbec.org/
			jlbec@...lplan.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ