From patchwork Thu Mar 28 14:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13608619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88945C54E64 for ; Thu, 28 Mar 2024 14:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BzN+n3/4Nf/WVuVltyMf5kNcuKMrNOdRt5defqa844U=; b=f1GIOzZ/XH9uWv MMJv4mNdS0ngl6R/UcCuehZnXIiGPzpovHsv5nVg+9BzFrwdhmPb8R8EtJoJFXMudDhMskHUn7TlT ysz5gPuwAx4jmIsiehfALyDsqx+O3H2o5xw4hUwb6xR2w6lvkz3wgjTL1GhF9jFUHplLOlpe1D96/ r6SHt0nxjbPtc6fKqS1gC01kQ7J+symuWvziEgij85288UpmFyXIEbJL1mGPynGTeZ/EduO0V9ar/ wP1pgMxwm74rddpdUo1LpsaqrTCQ5XqBkTqU6xpG7EbeNhT+COR5A1HwHwNu/CoWmMwUwLX3+sdXL 1ls2T1//sIbiQuWzroBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpqO7-0000000EEB9-1KSs; Thu, 28 Mar 2024 14:05:51 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpqNw-0000000EE6X-2TqJ; Thu, 28 Mar 2024 14:05:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E19D16147D; Thu, 28 Mar 2024 14:05:39 +0000 (UTC) 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240328_070540_821002_93D0954B X-CRM114-Status: GOOD ( 10.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=stringop-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/drivers/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 = MMAL_MSG_TYPE_COMPONENT_CREATE; m.u.component_create.client_component = 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)); ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),