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]
Date:   Wed, 23 Aug 2023 15:49:36 +0200
From:   Heiko Carstens <hca@...ux.ibm.com>
To:     Justin Stitt <justinstitt@...gle.com>,
        Peter Oberparleiter <oberpar@...ux.ibm.com>
Cc:     Stefan Haberland <sth@...ux.ibm.com>,
        Jan Hoeppner <hoeppner@...ux.ibm.com>,
        Jens Axboe <axboe@...nel.dk>, linux-s390@...r.kernel.org,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH] partitions/ibm: refactor deprecated strncpy

On Tue, Aug 22, 2023 at 11:59:26PM +0000, Justin Stitt wrote:
> `strncpy` is deprecated for use on NUL-terminated destination strings [1].
> 
> A suitable replacement is `strscpy` [2] due to the fact that it
> guarantees NUL-termination on its destination buffer argument which is
> _not_ the case for `strncpy`!
> 
> Link: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings[1]
> Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@...r.kernel.org
> Signed-off-by: Justin Stitt <justinstitt@...gle.com>
> ---
>  block/partitions/ibm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/partitions/ibm.c b/block/partitions/ibm.c
> index 403756dbd50d..e5893cf71b57 100644
> --- a/block/partitions/ibm.c
> +++ b/block/partitions/ibm.c
> @@ -111,11 +111,11 @@ static int find_label(struct parsed_partitions *state,
>  		    !strcmp(temp, "LNX1") ||
>  		    !strcmp(temp, "CMS1")) {
>  			if (!strcmp(temp, "VOL1")) {
> -				strncpy(type, label->vol.vollbl, 4);
> -				strncpy(name, label->vol.volid, 6);
> +				strscpy(type, label->vol.vollbl, 4);
> +				strscpy(name, label->vol.volid, 6);
>  			} else {
> -				strncpy(type, label->lnx.vollbl, 4);
> -				strncpy(name, label->lnx.volid, 6);
> +				strscpy(type, label->lnx.vollbl, 4);
> +				strscpy(name, label->lnx.volid, 6);
>  			}
>  			EBCASC(type, 4);
>  			EBCASC(name, 6);

I'm quite sure this is not correct, since both type and name are not
necessarily NUL-terminated, and this code operates on purpose on such
strings.

Since currently Stefan and Jan are both not available, I added Peter
Oberparleiter to Cc who hopefully knows better than me.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ