From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A7318120F; Thu, 28 Mar 2024 14:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634740; cv=none; b=JkAPNt7yoZ68jUJXSV+6YcItnIecuQSbG1IfghltNXQwoslFsNall28iUXHLIfM9/mVBNv3GiQkrogjBaVBI62AxHO4SupyhU5E+ACIVI9vfS4QdiXBdPpz+h0aX9oxfHFBmOulsIvR+TvY3Dihkasvde7VkB0pXcQm6xBKxVoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634740; c=relaxed/simple; bh=KQvW4QLqr7rEMfi/hFQOWFcSE+Lk/YdZwM/sAdZU8Ec=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UEASRvB40k7cGGe4rXIlhI8LSjeH1i/fpzMuY/cuJr3nRMtY4MZe6aiDLTLPQdXVL4LOzPlFIZlnHFL1q3CrM9hfvdMICPD/SPaVRWaTsDMyzqNpLW8bWdoRpByOnF42KyLbB1r49L5Jc8B3fg9siSwubIgsT9YpQD/k4EA6JvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PS5rxxdm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PS5rxxdm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBFD5C43394; Thu, 28 Mar 2024 14:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634739; bh=KQvW4QLqr7rEMfi/hFQOWFcSE+Lk/YdZwM/sAdZU8Ec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PS5rxxdmgygAFwMhA8Fqr1RY9HLrIBrzNT+eF5P1RzqAVY16HCcGTOFiOFllAb59v S9nizxhkPHCJYGBUcaZRpH+G4RDp9ALws5aboUqudsDYMPwLgQWp3TWxokC6vfnSBU uj5/np5TsbsyZQsQDSHFwZWOxEXxyG5Tus5znIq3DYIzxP3kRBJ21xyZaZPHoGP9x0 x/Vq23EqqFMhVLzX9xaYQo0nO6EVC6A2ZdRI54IRrEBK70XXOOGsIAGSKqy4wszunR cGBLYiJMaEGr3FK2J/Y4iHw/ynBlZKwr8bSo46fWlWT6UiG9qovFBkGKTOYDTHFr2T e7w3Z9MmUZSHw== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Florian Fainelli , Greg Kroah-Hartman Cc: Arnd Bergmann , Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev Subject: [PATCH 01/11] staging: vc04_services: changen strncpy() to strscpy_pad() Date: Thu, 28 Mar 2024 15:04:45 +0100 Message-Id: <20240328140512.4148825-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann gcc-14 warns about this strncpy() that results in a non-terminated string for an overflow: In file included from include/linux/string.h:369, from drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c= :20: In function 'strncpy', inlined from 'create_component' at drivers/staging/vc04_services/vchiq-= mmal/mmal-vchiq.c:940:2: include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' specified= bound 128 equals destination size [-Werror=3Dstringop-truncation] Change it to strscpy_pad(), which produces a properly terminated and zero-padded string. Signed-off-by: Arnd Bergmann Reviewed-by: Justin Stitt --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/driver= s/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 258aa0e37f55..6ca5797aeae5 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -937,8 +937,8 @@ static int create_component(struct vchiq_mmal_instance = *instance, /* build component create message */ m.h.type =3D MMAL_MSG_TYPE_COMPONENT_CREATE; m.u.component_create.client_component =3D component->client_component; - strncpy(m.u.component_create.name, name, - sizeof(m.u.component_create.name)); + strscpy_pad(m.u.component_create.name, name, + sizeof(m.u.component_create.name)); =20 ret =3D send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create), --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 897D382880; Thu, 28 Mar 2024 14:05:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634746; cv=none; b=pN1rcF6129xR3vkULVnwu8ddyxHrRVphYLXirm1bDch+e/VPlmi2CIeshOxQHxPquAzDBGNBSHtb9wSn2/ZlPo3Bq2v1aQtHZiT4Nnkvwra9QPiqAds6Z74BQYaGw2vzAb/ikOjj5ACK9Fyv02IDrBgCxaSPJuNwil3p75AzwPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634746; c=relaxed/simple; bh=zNvaXNiAxujiBLsJut5bqHVAOcViyLttpUXYqlyY1zw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YnUY5BWxDwW6pJVerghyXcLb40NJP6OI/IaHQRER1Szhy3KYM93sAZRX4lr54kO6DEun1NP0+xpxF/iqZsSFDd1xnDyPlKOxngrcW2A+/55okVRzBe8e1WHIDq6np5dZ79tzA06lrPcjM5sEwlTjNrsmi5z8wFN3QDq2UGijxYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V8I3yIcn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V8I3yIcn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E7EBC43399; Thu, 28 Mar 2024 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634746; bh=zNvaXNiAxujiBLsJut5bqHVAOcViyLttpUXYqlyY1zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8I3yIcnVZWurSiHgMev/PaIZPsXUsNqVQKwHJ7+mgOKCcTPUXHUqEknMBntcAITu lBy02fiZlzDY1HrIVoQ6ESWZpX1lmaA3l6htVPoAbw69TmEc+E9473jJ6QlohLlyqS UvnWqh6+PSPbvVAseM27BsB1r34XDSYPszmmLgTuVSzOnsTLT0YhDQcHTrBtUGsHQz x5iqy1CFrKZrcmoPc07sHv5F+4iVgPeDzXgUiw2CpeHLueJ835FfTGSTEMJzTp8nqF H6czJFBuYYnPeGiMFd3KYXKRYt8+RywOmtLP0YP1mcjwGDZT8kfs3lYxjMUscxR1q+ tDvHoVJ3e2TIQ== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Chris Down , Petr Mladek , Bart Van Assche , linux-scsi@vger.kernel.org Subject: [PATCH 02/11] scsi: devinfo: rework scsi_strcpy_devinfo() Date: Thu, 28 Mar 2024 15:04:46 +0100 Message-Id: <20240328140512.4148825-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann scsi_strcpy_devinfo() appears to work as intended but its semantics are so confusing that gcc warns about it when -Wstringop-truncation is enabled: In function 'scsi_strcpy_devinfo', inlined from 'scsi_dev_info_list_add_keyed' at drivers/scsi/scsi_devinf= o.c:370:2: drivers/scsi/scsi_devinfo.c:297:9: error: 'strncpy' specified bound 16 equa= ls destination size [-Werror=3Dstringop-truncation] 297 | strncpy(to, from, to_length); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reorganize the function to completely separate the nul-terminated from the space-padded/non-terminated case. The former is just strscpy_pad(), while the latter does not have a standard function. Signed-off-by: Arnd Bergmann --- drivers/scsi/scsi_devinfo.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index ba7237e83863..58726c15ebac 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -290,18 +290,28 @@ static struct scsi_dev_info_list_table *scsi_devinfo_= lookup_by_key(int key) static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length, char *from, int compatible) { - size_t from_length; + int ret; =20 - from_length =3D strlen(from); - /* This zero-pads the destination */ - strncpy(to, from, to_length); - if (from_length < to_length && !compatible) { - /* - * space pad the string if it is short. - */ - memset(&to[from_length], ' ', to_length - from_length); + if (compatible) { + /* This zero-pads and nul-terminates the destination */ + ret =3D strscpy_pad(to, from, to_length); + } else { + /* no nul-termination but space-padding for short strings */ + size_t from_length =3D strlen(from); + ret =3D from_length; + + if (from_length > to_length) { + from_length =3D to_length; + ret =3D -E2BIG; + } + + memcpy(to, from, from_length); + + if (from_length < to_length) + memset(&to[from_length], ' ', to_length - from_length); } - if (from_length > to_length) + + if (ret < 0) printk(KERN_WARNING "%s: %s string '%s' is too long\n", __func__, name, from); } --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD5C364CF2; Thu, 28 Mar 2024 14:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634777; cv=none; b=N6LDImQxgNaMV0+lwvlDJwc452zGUvT/bMu5Uxglid2AgKjLOxvKJ/hegRMG+hEpslCCPQ3pYomMaSTwn8zKChDRmyEQ+0xjdxrNWUnqmC5oLwj+8Im16vbWREGRW6o67FrwRwHPi6iyJS/DFlofMvUboLvSrJ5ysmg/vwjLBAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634777; c=relaxed/simple; bh=gMylBYrmATWxZ5d+8c6bGwHQWzKICTyrQtHLw9Ti9DA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mY01wL1joDaulSCGlZUM0WzKJdp+1LUfvS5sNeMBR5vadawt92wxcpdTi4cuOQ47z5HyueAk6PWNQRFX3a7j89TwzpNvEmpYAUMUg2WDyW98rv976D33ijTCF9WGrAwBcm1fOE9X1kaRfQkAitUm6dBt5Yoh1mgVbge5Kwwe/d4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FvgGl0TD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FvgGl0TD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03422C433F1; Thu, 28 Mar 2024 14:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634776; bh=gMylBYrmATWxZ5d+8c6bGwHQWzKICTyrQtHLw9Ti9DA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvgGl0TDBH4Ei13F0xA5j1Dfi29LBEHXzAToRTsK1pdtLFjbATzWe3pQeWq+zBVor UngHRavlLa7Kx+dH+Url/3wWbJBbf+ONDpKI6iD4QryPFLU/QRK0CIL+GskjFmnmAj NDobSqFxZdaTwUiu2SPQs0Uv0cBon2FlTQHVpdyrYy/A+xkKcZRSXQFM8hFRTrZP/B aSUEvlkgaI6UFqLUO4qJY8U3YaA/+mAFTEyrbookmYAnyvXBQ6NK8QHF6ScRnRKfFY xaCnYXF4xKEEEGuLweImK3fUKVGSnFVu/QnifeXWS8U2U21eNv4cOLmP9p3qYTMlMV HDe91isEP5b3Q== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kees Cook , Daniel Micay Cc: Arnd Bergmann , linux-staging@lists.linux.dev Subject: [PATCH 03/11] staging: replace weird strncpy() with memcpy() Date: Thu, 28 Mar 2024 15:04:47 +0100 Message-Id: <20240328140512.4148825-4-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann When -Wstringop-truncation is enabled, gcc finds a function that always does a short copy: In function 'inquiry', inlined from 'rtsx_scsi_handler' at drivers/staging/rts5208/rtsx_scsi.c= :3210:12: drivers/staging/rts5208/rtsx_scsi.c:526:17: error: 'strncpy' output truncat= ed copying between 1 and 28 bytes from a string of length 28 [-Werror=3Dstr= ingop-truncation] 526 | strncpy(buf + 8, inquiry_string, sendbytes - 8); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Since the actual size of the copy is already known at this point, just copy the bytes directly and skip the length check and zero-padding. This partially reverts an earlier bugfix that replaced the original incorrect memcpy() with a less bad strncpy(), but it now also avoids the original overflow. Fixes: 88a5b39b69ab ("staging/rts5208: Fix read overflow in memcpy") Signed-off-by: Arnd Bergmann --- drivers/staging/rts5208/rtsx_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/= rtsx_scsi.c index 08bd768ad34d..a73b0959f5a9 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -523,7 +523,7 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_c= hip *chip) =20 if (sendbytes > 8) { memcpy(buf, inquiry_buf, 8); - strncpy(buf + 8, inquiry_string, sendbytes - 8); + memcpy(buf + 8, inquiry_string, min(sendbytes, 36) - 8); if (pro_formatter_flag) { /* Additional Length */ buf[4] =3D 0x33; --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2D818626A for ; Thu, 28 Mar 2024 14:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634789; cv=none; b=BfDHXVcC37uUxh0va1fUSBbVICws5m5LQtikIIX4T5Co86JDiaK0NOFtjIe/r5goN/3lENdVDrWVpghi5TsQG86l3ePpv0WSvQWfpHtGCu7g6qV5dTJXe1R4GNUD9C+sTtYzvK3hOVcnqiD5Ok3W5u/ribzjBA9FTIWYnVINDAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634789; c=relaxed/simple; bh=FnvcZevTYWNurW3Uxd3UuYe/1VH10eeybkvsPFACC18=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pKYcU3zQQt4pkGD8iaXHInX74dqsxgNmvWsCkZKlqAKYTAbrJ00y2BwFE8bKZ5jGZMAs949TgIRtORzruj6NqoYljKhiRDfLs5UqQI02fgjkInGSaoMYcHVNREEt9anqpvF67aGZ8pSJ2qKwyhXh1bgIVjuUeldOlCoOj2ko+YE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lidp2c3m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lidp2c3m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E366C433F1; Thu, 28 Mar 2024 14:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634788; bh=FnvcZevTYWNurW3Uxd3UuYe/1VH10eeybkvsPFACC18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lidp2c3mTu2L+6vPQU0+t3T4RO7WW6KYloriGSzeh6hJ4lanRjXS2zbFyZ5c4egtR 7RHevo+rOeSp/m1mPTaUHfjHnEBTooB1q8yjwOwHIQcJm6E25WeWCmAF/jnVPu5nGI 6lBc+CyooIipfrlD6nn8jm7QUdVYgLrrUSRgqTieoMI/DU0Gn9UdArSJfLbDeVV5YP KESo4caEY31tC6fTqj/+azy3m68f6Ti5G3FU4CojpSJB7giJ9nqSTlrAY/GMhOj9BR XNm+xagVWsvXVEq5AII4DJj2GgxEutHKVQE/0zrPptXBvyo7pxxoN2yXcDn5JWr6M7 tg8USbC4P2ESw== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Mike Marshall Cc: Arnd Bergmann , Martin Brandenburg , Jeff Layton , Jan Kara , Christian Brauner , Vlastimil Babka , devel@lists.orangefs.org Subject: [PATCH 04/11] orangefs: convert strncpy() to strscpy() Date: Thu, 28 Mar 2024 15:04:48 +0100 Message-Id: <20240328140512.4148825-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann gcc warns about a truncated string copy with a 255 byte string getting copied to a buffer of the same length, losing the 0-termination: In function 'orangefs_unmount', inlined from 'orangefs_kill_sb' at arm-soc/fs/orangefs/super.c:619:6: fs/orangefs/super.c:406:9: error: 'strncpy' output may be truncated copying= 255 bytes from a string of length 255 [-Werror=3Dstringop-truncation] 406 | strncpy(op->upcall.req.fs_umount.orangefs_config_server, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 407 | devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I see that most string copies in orangefs are for the upcalls and use a buffer that is one short to get the implied termination from the zero-filled buffer, but some other instances lack the '-1' part. Convert from strncpy() to strscpy() to avoids both the warning about the buffer size and the need for the explicit padding, since strscpy guarantees a zero-terminated buffer. Signed-off-by: Arnd Bergmann --- fs/orangefs/dcache.c | 4 ++-- fs/orangefs/namei.c | 33 +++++++++++++++------------------ fs/orangefs/super.c | 16 +++++++--------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c index 8bbe9486e3a6..96ed9900f7a9 100644 --- a/fs/orangefs/dcache.c +++ b/fs/orangefs/dcache.c @@ -33,9 +33,9 @@ static int orangefs_revalidate_lookup(struct dentry *dent= ry) =20 new_op->upcall.req.lookup.sym_follow =3D ORANGEFS_LOOKUP_LINK_NO_FOLLOW; new_op->upcall.req.lookup.parent_refn =3D parent->refn; - strncpy(new_op->upcall.req.lookup.d_name, + strscpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name, - ORANGEFS_NAME_MAX - 1); + ORANGEFS_NAME_MAX); =20 gossip_debug(GOSSIP_DCACHE_DEBUG, "%s:%s:%d interrupt flag [%d]\n", diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c index c9dfd5c6a097..5e46d3bdcb05 100644 --- a/fs/orangefs/namei.c +++ b/fs/orangefs/namei.c @@ -41,8 +41,8 @@ static int orangefs_create(struct mnt_idmap *idmap, fill_default_sys_attrs(new_op->upcall.req.create.attributes, ORANGEFS_TYPE_METAFILE, mode); =20 - strncpy(new_op->upcall.req.create.d_name, - dentry->d_name.name, ORANGEFS_NAME_MAX - 1); + strscpy(new_op->upcall.req.create.d_name, + dentry->d_name.name, ORANGEFS_NAME_MAX); =20 ret =3D service_operation(new_op, __func__, get_interruptible_flag(dir)); =20 @@ -137,8 +137,8 @@ static struct dentry *orangefs_lookup(struct inode *dir= , struct dentry *dentry, &parent->refn.khandle); new_op->upcall.req.lookup.parent_refn =3D parent->refn; =20 - strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name, - ORANGEFS_NAME_MAX - 1); + strscpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name, + ORANGEFS_NAME_MAX); =20 gossip_debug(GOSSIP_NAME_DEBUG, "%s: doing lookup on %s under %pU,%d\n", @@ -192,8 +192,8 @@ static int orangefs_unlink(struct inode *dir, struct de= ntry *dentry) return -ENOMEM; =20 new_op->upcall.req.remove.parent_refn =3D parent->refn; - strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name, - ORANGEFS_NAME_MAX - 1); + strscpy(new_op->upcall.req.remove.d_name, dentry->d_name.name, + ORANGEFS_NAME_MAX); =20 ret =3D service_operation(new_op, "orangefs_unlink", get_interruptible_flag(inode)); @@ -247,10 +247,9 @@ static int orangefs_symlink(struct mnt_idmap *idmap, ORANGEFS_TYPE_SYMLINK, mode); =20 - strncpy(new_op->upcall.req.sym.entry_name, - dentry->d_name.name, - ORANGEFS_NAME_MAX - 1); - strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX - 1); + strscpy(new_op->upcall.req.sym.entry_name, + dentry->d_name.name, ORANGEFS_NAME_MAX); + strscpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX); =20 ret =3D service_operation(new_op, __func__, get_interruptible_flag(dir)); =20 @@ -324,8 +323,8 @@ static int orangefs_mkdir(struct mnt_idmap *idmap, stru= ct inode *dir, fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes, ORANGEFS_TYPE_DIRECTORY, mode); =20 - strncpy(new_op->upcall.req.mkdir.d_name, - dentry->d_name.name, ORANGEFS_NAME_MAX - 1); + strscpy(new_op->upcall.req.mkdir.d_name, + dentry->d_name.name, ORANGEFS_NAME_MAX); =20 ret =3D service_operation(new_op, __func__, get_interruptible_flag(dir)); =20 @@ -405,12 +404,10 @@ static int orangefs_rename(struct mnt_idmap *idmap, new_op->upcall.req.rename.old_parent_refn =3D ORANGEFS_I(old_dir)->refn; new_op->upcall.req.rename.new_parent_refn =3D ORANGEFS_I(new_dir)->refn; =20 - strncpy(new_op->upcall.req.rename.d_old_name, - old_dentry->d_name.name, - ORANGEFS_NAME_MAX - 1); - strncpy(new_op->upcall.req.rename.d_new_name, - new_dentry->d_name.name, - ORANGEFS_NAME_MAX - 1); + strscpy(new_op->upcall.req.rename.d_old_name, + old_dentry->d_name.name, ORANGEFS_NAME_MAX); + strscpy(new_op->upcall.req.rename.d_new_name, + new_dentry->d_name.name, ORANGEFS_NAME_MAX); =20 ret =3D service_operation(new_op, "orangefs_rename", diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index d990f4356b30..c714380ab38b 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c @@ -256,7 +256,7 @@ int orangefs_remount(struct orangefs_sb_info_s *orangef= s_sb) new_op =3D op_alloc(ORANGEFS_VFS_OP_FS_MOUNT); if (!new_op) return -ENOMEM; - strncpy(new_op->upcall.req.fs_mount.orangefs_config_server, + strscpy(new_op->upcall.req.fs_mount.orangefs_config_server, orangefs_sb->devname, ORANGEFS_MAX_SERVER_ADDR_LEN); =20 @@ -403,8 +403,8 @@ static int orangefs_unmount(int id, __s32 fs_id, const = char *devname) return -ENOMEM; op->upcall.req.fs_umount.id =3D id; op->upcall.req.fs_umount.fs_id =3D fs_id; - strncpy(op->upcall.req.fs_umount.orangefs_config_server, - devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1); + strscpy(op->upcall.req.fs_umount.orangefs_config_server, + devname, ORANGEFS_MAX_SERVER_ADDR_LEN); r =3D service_operation(op, "orangefs_fs_umount", 0); /* Not much to do about an error here. */ if (r) @@ -497,9 +497,8 @@ struct dentry *orangefs_mount(struct file_system_type *= fst, if (!new_op) return ERR_PTR(-ENOMEM); =20 - strncpy(new_op->upcall.req.fs_mount.orangefs_config_server, - devname, - ORANGEFS_MAX_SERVER_ADDR_LEN - 1); + strscpy(new_op->upcall.req.fs_mount.orangefs_config_server, + devname, ORANGEFS_MAX_SERVER_ADDR_LEN); =20 gossip_debug(GOSSIP_SUPER_DEBUG, "Attempting ORANGEFS Mount via host %s\n", @@ -546,9 +545,8 @@ struct dentry *orangefs_mount(struct file_system_type *= fst, * on successful mount, store the devname and data * used */ - strncpy(ORANGEFS_SB(sb)->devname, - devname, - ORANGEFS_MAX_SERVER_ADDR_LEN - 1); + strscpy(ORANGEFS_SB(sb)->devname, devname, + ORANGEFS_MAX_SERVER_ADDR_LEN); =20 /* mount_pending must be cleared */ ORANGEFS_SB(sb)->mount_pending =3D 0; --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D73E812B17C for ; Thu, 28 Mar 2024 14:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634794; cv=none; b=s9yyeTvGF2KmiCO7QB3PYWKo1ZDYXGLFtGRYr1gSOSiecXgELF+gPpp8OyNX2QBZZLrMnAPnzJvnmbaljmFuyqdKrta6Qy2VUPy2AivA8ZsxRquuwb4HtYFDwxnCdTfqI96WvKezgLyZcUi/VOAQolB4Iwx1mhqu9LDiG624sig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634794; c=relaxed/simple; bh=/z3penlJXNolNdo44Cwa/toSbF2yR8i4Mak3/kq291A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IEGxqkzhcu1ZgeJGSy6cfb15eHg8Kyhulf00vcPTZFqMqInqqJfKRkgkn/h5/SQA8DVDp5S32G7nQ2z+lq0HkoLqZBn3WxSwIPA8TZqM0lk18RoiFUW0xiOtoiHaKBOTXRbx9Of1jVotBPzgk0HhjslpSK5b0F4B6JEyNUGanes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tGBrVSKg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tGBrVSKg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D44CDC433F1; Thu, 28 Mar 2024 14:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634794; bh=/z3penlJXNolNdo44Cwa/toSbF2yR8i4Mak3/kq291A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tGBrVSKgykDqZ/dQD9dRPlC4fzYpN5MH+e6VEjn5Vn+S8EMrOcW+VR00oxIcEQ4WC OPmWGINlce6iA+Tsxrum92mvIhbquKTD38lqNu/4/hMjeaidIPGOQauXutFGf2OM03 JH99OxIHFRTK82X+eCbL4Noh+bK9V2TxuSEbo93wtW3aEJrkw/hGJTlBPMwiUwtsGh yGOQ8nzqXVoY6gFELp1qSs/D76NKaFg8jsEeIDgqyJ+rsuTv473vnhLq/cNSGxFqna MMJmXF1CUDmrA18LLyKd4bG59oRLVJZRHbe/g4sdeF6I0IoxWHmpvvm5IcdTz24fFl LNwgHuQw/ptnA== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Andrew Morton Cc: Arnd Bergmann Subject: [PATCH 05/11] test_hexdump: avoid string truncation warning Date: Thu, 28 Mar 2024 15:04:49 +0100 Message-Id: <20240328140512.4148825-6-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann gcc can warn when a string is too long to fit into the strncpy() destination buffer, as it is here depending on the function arguments: inlined from 'test_hexdump_prepare_test.constprop' at /home/arnd/arm-so= c/lib/test_hexdump.c:116:3: include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' output tr= uncated copying between 0 and 32 bytes from a string of length 32 [-Werror= =3Dstringop-truncation] 108 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/fortify-string.h:187:16: note: in expansion of macro '__under= lying_strncpy' 187 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ As far as I can tell, this is harmless here because the truncation is intentional, but using strscpy_pad() will avoid the warning since gcc does not (yet) know about it. Signed-off-by: Arnd Bergmann --- lib/test_hexdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c index b916801f23a8..c9820122af56 100644 --- a/lib/test_hexdump.c +++ b/lib/test_hexdump.c @@ -113,7 +113,7 @@ static void __init test_hexdump_prepare_test(size_t len= , int rowsize, *p++ =3D ' '; } while (p < test + rs * 2 + rs / gs + 1); =20 - strncpy(p, data_a, l); + strscpy_pad(p, data_a, l); p +=3D l; } =20 --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80BB144C67; Thu, 28 Mar 2024 14:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634802; cv=none; b=iuqU66yZziqBqZaBasle+gitOlFquTCJa4K/osWIRCNtEv1WEt8rzedFy9IIE9BSd+Ch3SFFDe0N7q4rHRFSA45o6ih3RfVVX9+NNZe5liAX0RGAoVHMXLf+CTankTm9i4ZobwhwTQlIJ9yxzl3t0bNnm2N0cd7vBM+dUS4+KmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634802; c=relaxed/simple; bh=lezpFM2DFivksVBQ+jcGXE6ARZQR+zJugCRJ8LauAOg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ctiy9Iy530Gmzxzvd/8dGkKT3zv2Gyte7QOrIMGIbNZ/CljMyS7TQ7KLy3k4avNl06uoL02Tp6dhFQFaBgraIDgt4hUay2HfY5nrctnegf03FYeAbvSBQLJ23CIC3emwG632VJNg7PNh7YE2PX6ucAsy+8JlocQTMtL7Dq241zo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=btfiU8CF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="btfiU8CF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD52BC433C7; Thu, 28 Mar 2024 14:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634802; bh=lezpFM2DFivksVBQ+jcGXE6ARZQR+zJugCRJ8LauAOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btfiU8CFi3ZJpE6YEYkrNSnkajZh5p/OPkCeQtqKmhP61Z3AbzPlRLr1vqjRGWgUv 4NYQxyuOXQf/UOtzHaXO+vVcXaQd9eI57v/nK4ubYyfaUR2zYLM1QftIWpy+XGNRNH swbYRDzNe3lyoL8ahTFBq+VT18N3dRNB02b+LE0+li5tYVSiO/GWzL8UjqlQsNADle oRarDv9hUrzmtQkCNacsLuTQZ5EfKu7MGIeak/pjJw/L+OWFjGMnrYvOjMn8/V8X9K jemp4ib7rMMWMLjcgQ3sci6hfss19XYHNtQDyIFwaX/u56L+Ih+NWY9xDpx/C1m6B2 6CY0kLzc2Fa3A== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Robert Moore , "Rafael J. Wysocki" , Alexey Starikovskiy , Lin Ming , Len Brown Cc: Arnd Bergmann , Len Brown , linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH 06/11] acpi: avoid warning for truncated string copy Date: Thu, 28 Mar 2024 15:04:50 +0100 Message-Id: <20240328140512.4148825-7-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann gcc -Wstringop-truncation warns about copying a string that results in a missing nul termination: drivers/acpi/acpica/tbfind.c: In function 'acpi_tb_find_table': drivers/acpi/acpica/tbfind.c:60:9: error: 'strncpy' specified bound 6 equal= s destination size [-Werror=3Dstringop-truncation] 60 | strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/acpi/acpica/tbfind.c:61:9: error: 'strncpy' specified bound 8 equal= s destination size [-Werror=3Dstringop-truncation] 61 | strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_I= D_SIZE); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~ This one is intentional, so rewrite the code in a way that avoids the warning. Since there is already an extra strlen() and an overflow check, the actual size to be copied is already known here. Fixes: 47c08729bf1c ("ACPICA: Fix for LoadTable operator, input strings") Signed-off-by: Arnd Bergmann --- drivers/acpi/acpica/tbfind.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c index 1c1b2e284bd9..472ce2a6624b 100644 --- a/drivers/acpi/acpica/tbfind.c +++ b/drivers/acpi/acpica/tbfind.c @@ -36,7 +36,7 @@ acpi_tb_find_table(char *signature, { acpi_status status =3D AE_OK; struct acpi_table_header header; - u32 i; + u32 len, i; =20 ACPI_FUNCTION_TRACE(tb_find_table); =20 @@ -46,19 +46,18 @@ acpi_tb_find_table(char *signature, return_ACPI_STATUS(AE_BAD_SIGNATURE); } =20 - /* Don't allow the OEM strings to be too long */ - - if ((strlen(oem_id) > ACPI_OEM_ID_SIZE) || - (strlen(oem_table_id) > ACPI_OEM_TABLE_ID_SIZE)) { - return_ACPI_STATUS(AE_AML_STRING_LIMIT); - } - /* Normalize the input strings */ =20 memset(&header, 0, sizeof(struct acpi_table_header)); ACPI_COPY_NAMESEG(header.signature, signature); - strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); - strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); + len =3D strlen(oem_id); + if (len > ACPI_OEM_ID_SIZE) + return_ACPI_STATUS(AE_AML_STRING_LIMIT); + memcpy(header.oem_id, oem_id, len); + len =3D strlen(oem_table_id); + if (len > ACPI_OEM_TABLE_ID_SIZE) + return_ACPI_STATUS(AE_AML_STRING_LIMIT); + memcpy(header.oem_table_id, oem_table_id, len); =20 /* Search for the table */ =20 --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC9DC84D31; Thu, 28 Mar 2024 14:06:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634808; cv=none; b=qRoMbQ0uxkfl+MOL3rvHFVyw/MqQ6XV3Snl/est9smpEbNC3gFl91boUJ/OZKET8I5UY3ZtW0RwaM/SVTPzNr0TWQJEUc8tS8WhrqSN9pOG7kztjyQrHyVLmgGbNy2pM5SsqWgjAEr8CplOaRassyRSr2UwBZyzrgsc1gdjN1P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634808; c=relaxed/simple; bh=yHFhPfrMMHs59SCQp+6DZsAO2LqRForPxbzKn/h9OZA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lnP6Gu+2h+Z0gfI1FOG37wqu+3ARzH10LbuN/gGkWignOQ1F77dpHWE5+28eLVOK/h9ts7gWgcWRtGDgVGwX0fcyuiHiAFI2CcRcHaIfFxNmEGPUeGXL9pUhFqDY0Bb75VU9+Yh1+vQChLZVXFCZR/zgN8sliwYbmN6wKWgBpqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R998RHJ3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R998RHJ3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C68FAC433C7; Thu, 28 Mar 2024 14:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634808; bh=yHFhPfrMMHs59SCQp+6DZsAO2LqRForPxbzKn/h9OZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R998RHJ3bF9lTIX5YWthw9VZaOAKxAC8PYU9VG6hxbfvkV/2ojvYP+QAo5KdLlrQ7 /wz84TbbA9274ily1eOENho1tB+8cFC9giRCQegDvg4tPyUwccnz0Bdw4+I8Moyt5s Rw0NhibOpG0YPZHN8OLMstOKFp8ZFMWrowVFFP0BQ5sTlgZ4NiVcAIGqdCXFuNq3ne uKY3f9mdvItaaz+H+E9vnv4jxK/06AW1LCwyelKi2hAuNcupkYrRwVqZD+9E7z3+B5 dAytiqSnnjaHoDp+hvabvCDcEm3Rry4aP06xRnDKpxAYTsukGYcIucItdTYFK0MG4s JHhAW59Pcv4eg== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, "Richard Russon (FlatCap)" , Jens Axboe Cc: Arnd Bergmann , linux-ntfs-dev@lists.sourceforge.net, linux-block@vger.kernel.org Subject: [PATCH 07/11] block/partitions/ldm: convert strncpy() to strscpy() Date: Thu, 28 Mar 2024 15:04:51 +0100 Message-Id: <20240328140512.4148825-8-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann The strncpy() here can cause a non-terminated string, which older gcc versions such as gcc-9 warn about: In function 'ldm_parse_tocblock', inlined from 'ldm_validate_tocblocks' at block/partitions/ldm.c:386:7, inlined from 'ldm_partition' at block/partitions/ldm.c:1457:7: block/partitions/ldm.c:134:2: error: 'strncpy' specified bound 16 equals de= stination size [-Werror=3Dstringop-truncation] 134 | strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name= )); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~ block/partitions/ldm.c:145:2: error: 'strncpy' specified bound 16 equals de= stination size [-Werror=3Dstringop-truncation] 145 | strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name= )); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~ New versions notice that the code is correct after all because of the following termination, but replacing the strncpy() with strscpy_pad() or strcpy() avoids the warning and simplifies the code at the same time. Use the padding version here to keep the existing behavior, in case the code relies on not including uninitialized data. Signed-off-by: Arnd Bergmann Reviewed-by: Justin Stitt --- block/partitions/ldm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c index 38e58960ae03..2bd42fedb907 100644 --- a/block/partitions/ldm.c +++ b/block/partitions/ldm.c @@ -131,8 +131,7 @@ static bool ldm_parse_tocblock (const u8 *data, struct = tocblock *toc) ldm_crit ("Cannot find TOCBLOCK, database may be corrupt."); return false; } - strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name)); - toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] =3D 0; + strscpy_pad(toc->bitmap1_name, data + 0x24, sizeof(toc->bitmap1_name)); toc->bitmap1_start =3D get_unaligned_be64(data + 0x2E); toc->bitmap1_size =3D get_unaligned_be64(data + 0x36); =20 @@ -142,8 +141,7 @@ static bool ldm_parse_tocblock (const u8 *data, struct = tocblock *toc) TOC_BITMAP1, toc->bitmap1_name); return false; } - strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name)); - toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] =3D 0; + strscpy_pad(toc->bitmap2_name, data + 0x46, sizeof(toc->bitmap2_name)); toc->bitmap2_start =3D get_unaligned_be64(data + 0x50); toc->bitmap2_size =3D get_unaligned_be64(data + 0x58); if (strncmp (toc->bitmap2_name, TOC_BITMAP2, --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30E34129E81; Thu, 28 Mar 2024 14:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634815; cv=none; b=n9uQjWh+xVopXwWZTLfgiKbBy2OgeDbbqkYLMHF4HWdKtpk5o9E6Mpua/mWZnFUkZ6Tlhp49PeAQCnJ9YdQRbbv8pVcaWk2S6RtmPZfoH8lv07TSZTrpjW3PHf7VWsvSKef7dNWltZ+pNmE29vDcqGwf/5hpnnshH5J0o7dD2p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634815; c=relaxed/simple; bh=4Sl2+ylJNPrkTlbZJE1y57+3AaBXLpboKEKujg0bFD0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R8WuLBFMcPJLl6cA4d4KEJJObFirVt7s+YkCpcagp+UqoIijukZQED0AOLENZMDjWjKRuePSNCS7LVR0cwrlBzxKR+RpkaryYcr3aIDsD5Q/3T00pPIgCOtJak4X+0PkpXvgFvyrffzzqPMjuaItXw//X7C7/SecbAPGggJlrzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FYCMzsrE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FYCMzsrE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDC22C433C7; Thu, 28 Mar 2024 14:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634814; bh=4Sl2+ylJNPrkTlbZJE1y57+3AaBXLpboKEKujg0bFD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FYCMzsrEVcyxP1XJhQaxTBt5DaBA2wyIYnrE2OsH3WaOj1FvDey9aFrzZt+gSz7k7 z0SUHERlLXNrgM/t0uMzYS8iMEXh9K3FJA+WUPlNG9AuANTMdfHy7G6ObmmlUaEncx g5bFeK3k200QYAg0ehIgZXN1WAcFtAhXEloKn6p8DPumCHxhJzLvdIeOx2pWWjgskr 84m6zeMItrJBAOtuwQRr01nSH6aH8kXra7LQKqhEw53WiqsGNKfIpqx8sQAYUlWPg7 hGDg++GOtZH7XAAAB08NWysoOetgdxL4fJcnq2yDXY6RGd2Pg0B9O+5Tk32VsvtUQD PD90IojI+UJ0Q== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Jens Axboe , Steven Rostedt , Masami Hiramatsu Cc: Arnd Bergmann , Mathieu Desnoyers , linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 08/11] blktrace: convert strncpy() to strscpy_pad() Date: Thu, 28 Mar 2024 15:04:52 +0100 Message-Id: <20240328140512.4148825-9-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann gcc-9 warns about a possibly non-terminated string copy: kernel/trace/blktrace.c: In function 'do_blk_trace_setup': kernel/trace/blktrace.c:527:2: error: 'strncpy' specified bound 32 equals d= estination size [-Werror=3Dstringop-truncation] Newer versions are fine here because they see the following explicit nul-termination. Using strscpy_pad() avoids the warning and simplifies the code a little. The padding helps give a clean buffer to userspace. Signed-off-by: Arnd Bergmann --- kernel/trace/blktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index d5d94510afd3..95a00160d465 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -524,8 +524,7 @@ static int do_blk_trace_setup(struct request_queue *q, = char *name, dev_t dev, if (!buts->buf_size || !buts->buf_nr) return -EINVAL; =20 - strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); - buts->name[BLKTRACE_BDEV_SIZE - 1] =3D '\0'; + strscpy(buts->name, name, BLKTRACE_BDEV_SIZE); =20 /* * some device names have larger paths - convert the slashes --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9FA483CC7; Thu, 28 Mar 2024 14:07:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634825; cv=none; b=vAPG5QLEg6MGZs5l8wxVTUyu+cgAKZNoMwHWkadTwk55dSehLxMREtY5JtsYZvwTT8nKyUYnJt42nl2Ef53kAM3B4FRuwwk1p5BxzvH0V8obSe3qBtW0LPaQjRT6N/9b4VoK0f0NQHC0EI6rWrSTMcHCJ+HyM8oxbi+PgLr3Ro8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634825; c=relaxed/simple; bh=HUhSot9xyrF+JN4xyg5gUpvdtcrLnfShBlIudVAw+0o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CuIGV2NHWIQu2LUneFJy2B9oD/OlokeM3e2Xi6iUm2vOKYxvFr57ZCxP7nhlu+kwQ4MoHdc8dQa0WpW1NCaCj3syejL5dNYaweGdnw7RO1uCahn9BILxlJidIjoKQ9VjNisfJWJ4SSlUiUoVWbyr/E45Avt4FRxg5Cd3GvDEfTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A7bAq59Z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A7bAq59Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C684BC433F1; Thu, 28 Mar 2024 14:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634824; bh=HUhSot9xyrF+JN4xyg5gUpvdtcrLnfShBlIudVAw+0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A7bAq59ZDijbhGoewi2fyU5yAVKEd6Ep8RA8WtnD2HrGJ/8zDtz2VujzucjrXWi43 DieD6Vj1woddVF3DyIj9WZEB7WSEkWbkfgvwNkhFIcEry9hUBLmUIFVCy2KF2pdTEs VihwIQtCAQ7X4TJ8+F8dtl7DVdVsIA3qL/8Yk44yUZrScpEPby3ubQQz6PsH6iH+KP g/UZoVijAAB0Uk1jqELSCyzK0MEaBNs9yfGDP+3bv+PRPNxAgldy8b6IrGe764SVaY i+CwDFJkuWexuwlXfx7KpKsPz5+0e1VOFWpVTtkbaQkLeQvlRCeR2YN0EvQe6jukrY 368+rWxdAZ3Pg== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Nathan Chancellor Cc: Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , Franziska Naepelt , Johannes Berg , Yang Yingliang , Erick Archer , linux-staging@lists.linux.dev, llvm@lists.linux.dev Subject: [PATCH 09/11] staging: rtl8723bs: convert strncpy to strscpy Date: Thu, 28 Mar 2024 15:04:53 +0100 Message-Id: <20240328140512.4148825-10-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann gcc-9 complains about a possibly unterminated string in the strncpy() desti= nation: In function 'rtw_cfg80211_add_monitor_if', inlined from 'cfg80211_rtw_add_virtual_intf' at drivers/staging/rtl8723= bs/os_dep/ioctl_cfg80211.c:2209:9: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2146:2: error: 'strncpy' = specified bound 16 equals destination size [-Werror=3Dstringop-truncation] 2146 | strncpy(mon_ndev->name, name, IFNAMSIZ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This one is a false-positive because of the explicit termination in the fol= lowing line, and recent versions of clang and gcc no longer warn about this. Interestingly, the other strncpy() in this file is missing a termination but does not produce a warning, possibly because of the type confusion and the cast between u8 and char. Change both strncpy() instances to strscpy(), which avoids the warning as w= ell as the possibly missing termination. No additional padding is needed here. Signed-off-by: Arnd Bergmann --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/st= aging/rtl8723bs/os_dep/ioctl_cfg80211.c index 65a450fcdce7..98bc5520e77d 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -884,7 +884,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, st= ruct net_device *ndev, goto addkey_end; } =20 - strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); + strscpy(param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); =20 if (!mac_addr || is_broadcast_ether_addr(mac_addr)) param->u.crypt.set_tx =3D 0; /* for wpa/wpa2 group key */ @@ -2143,8 +2143,7 @@ static int rtw_cfg80211_add_monitor_if(struct adapter= *padapter, char *name, str } =20 mon_ndev->type =3D ARPHRD_IEEE80211_RADIOTAP; - strncpy(mon_ndev->name, name, IFNAMSIZ); - mon_ndev->name[IFNAMSIZ - 1] =3D 0; + strscpy(mon_ndev->name, name, IFNAMSIZ); mon_ndev->needs_free_netdev =3D true; mon_ndev->priv_destructor =3D rtw_ndev_destructor; =20 --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E201612F38B; Thu, 28 Mar 2024 14:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634832; cv=none; b=Lvue5R+ldHCSjYyou+BsRWQittE5dP1oBhmbiif7UrumYJlFxWGIp0odKKilzlBYcarDfUHHCU1K19sC6tNF6EuZJLYTgSe62HsXc5XVk00gXvvQet8cdQ/7jQTltX+AIU/3ABiCAN7jOkjZvDUABb6QCkBWrej9Nhc8RO5Kunk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634832; c=relaxed/simple; bh=jCpFq1/rgN+7LjvFqEP/87Ucf4QQthKAvwD+RuobdII=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kaIvdv8BScpK72+0B0VDB6GHIbTPttmqmO1bXiv0C4DhlCnyvpP+uQb0Xu685xLhkve3gbTlJTxfbM3SdFQy2L9qa+P0GpMVpVYux+pSIVykbwtj4d/OXeq7o+5gjN+hbzNWTftlwY3+VVr5Wg7mkWTy0HjmiK86/r5j5xl+EmQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bIwgWdpl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bIwgWdpl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6929CC433C7; Thu, 28 Mar 2024 14:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634831; bh=jCpFq1/rgN+7LjvFqEP/87Ucf4QQthKAvwD+RuobdII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bIwgWdplCpwDNWYw4e1shf3eU4qoI/uvcSnjDOLeb+kQweNsamyY7YOT+JBBCmRzw HezFO0Fb4Y5P33syW0JRJSrC5h9C5oTkH5rBI1MZ+P561FPcxmEayw1Bi9tveYzytC pRKupfZbCAkQqUPaLBSSlJg6gVN1Fm4xeRNXMsgcNi9/x9CeOaHUG81Y4rCvtSwelR asCNEsRlXnLfHoC3uwy5v9/I5NwerDic/0Q15M2P1Idowq4iZaa4rw4QpgdLTpmQ/0 LRp05PnaEx41QBFzVv1Zw+bK9LK24zwEz5PV77deYh3nlSY03oT0Z/yE0v+NQV0HVu E3qh9p9plPG5A== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Viresh Kumar , Johan Hovold , Alex Elder , Greg Kroah-Hartman Cc: Arnd Bergmann , Christophe JAILLET , greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev Subject: [PATCH 10/11] staging: greybus: change strncpy() to strscpy() Date: Thu, 28 Mar 2024 15:04:54 +0100 Message-Id: <20240328140512.4148825-11-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann gcc-10 warns about a strncpy() that does not enforce zero-termination: In file included from include/linux/string.h:369, from drivers/staging/greybus/fw-management.c:9: In function 'strncpy', inlined from 'fw_mgmt_backend_fw_update_operation' at drivers/staging/g= reybus/fw-management.c:306:2: include/linux/fortify-string.h:108:30: error: '__builtin_strncpy' specified= bound 10 equals destination size [-Werror=3Dstringop-truncation] 108 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/fortify-string.h:187:9: note: in expansion of macro '__underl= ying_strncpy' 187 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ For some reason, I cannot reproduce this with gcc-9 or gcc-11, so I'm not sure what's going on. Changing it to strspy() avoids the warning. In this case the existing check for zero-termination would fail but can be replaced with an error check. Signed-off-by: Arnd Bergmann --- This is from randconfig testing with random gcc versions, a .config to reproduce is at https://pastebin.com/r13yezkU --- drivers/staging/greybus/fw-management.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/grey= bus/fw-management.c index 3054f084d777..35bfdd5f32d2 100644 --- a/drivers/staging/greybus/fw-management.c +++ b/drivers/staging/greybus/fw-management.c @@ -303,13 +303,13 @@ static int fw_mgmt_backend_fw_update_operation(struct= fw_mgmt *fw_mgmt, struct gb_fw_mgmt_backend_fw_update_request request; int ret; =20 - strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE); + ret =3D strscpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE); =20 /* * The firmware-tag should be NULL terminated, otherwise throw error and * fail. */ - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] !=3D '\0') { + if (ret =3D=3D -E2BIG) { dev_err(fw_mgmt->parent, "backend-update: firmware-tag is not NULL termi= nated\n"); return -EINVAL; } --=20 2.39.2 From nobody Sun Jul 12 16:45:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D24C28366; Thu, 28 Mar 2024 14:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634837; cv=none; b=sOUaQ5mIiK4lfslE2lFGb7DJznUTmmZak13W1g9YQBkNhMsMuZxlqarE4hltmmgiCdsbDHFhLCd/47sxHRx6/ZhglokGrEh15ptItcGKQ0vMjMR7t8sDcP82JkQCVsH8f9M11iXiG5MjIuh+iKBL4WPidZ5BcLmp2IIN104Bh5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634837; c=relaxed/simple; bh=HAK2CRZwQz9hSqo3RZk2zl/QdK5mJmPz2eF7SrmBSfU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BPywXUya1X1ftf+XPnG3iCHZE2QzqE3X6KYWFfTkv6xtyrjc0z57sNN3s7C4dNpbrpF5aGfepIPGIXqx7BvZqp3JYUunVy5R57oMCxXO/GgfuAn9e5bmyD28knSAdNLjOTyRbEednI3g39TwyklG2sZjxDeK6kHvcCXI+AQ4+MM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=po1GlDL4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="po1GlDL4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60A43C43399; Thu, 28 Mar 2024 14:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634836; bh=HAK2CRZwQz9hSqo3RZk2zl/QdK5mJmPz2eF7SrmBSfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=po1GlDL4BbHjc1L9zFfUcQEr8mgmdeH/RcK6z5TgS/NX1m8CA9rc2CF+P3Lyvmywx 9zHfxrISxzkmJcv81Ssn0x+Lfak+mST+xzo7kcLFC6JYIc7lJ4R0uH9+xP0kVuV7Wk gnC0KMVl5J04w34840nQ+lsnHqswfuMWlJlNU7j3AJgnLOXJ+i0siWEkg62rWTh7uH St6xby7eNX13n+EoqOKSUxJw/n6vXnAHie1A6DrXrN3yWHMmTaCzYeofwyRmt1FXAP Ee8FZxq//C3nSls9IZVsRSb4JQHYSVahcd0fKz0Xw3F/RHpoIHA0kX4GtmIdTRhGCT IC6H9IyfPGw8Q== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org Subject: [PATCH 11/11] kbuild: enable -Wstringop-truncation globally Date: Thu, 28 Mar 2024 15:04:55 +0100 Message-Id: <20240328140512.4148825-12-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann The remaining warnings of this type have been addressed, so it can now be enabled by default, rather than only for W=3D1. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index aa1c716c4812..5a25f133d0e9 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -102,7 +102,6 @@ KBUILD_CFLAGS +=3D $(call cc-disable-warning, format-ov= erflow) ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS +=3D $(call cc-disable-warning, format-truncation) endif -KBUILD_CFLAGS +=3D $(call cc-disable-warning, stringop-truncation) =20 KBUILD_CFLAGS +=3D -Wno-override-init # alias for -Wno-initializer-overrid= es in clang =20 --=20 2.39.2