Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1854417lql; Wed, 13 Mar 2024 09:55:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnEMahonfbzVRO7qbMoU8saopMAi9OmYa58Y2pJ6qLmVmW/C7g0YQBtTkCYwcLybPJUk0ZXWSR/qi39DDiDSkVrhC/QAIZOsXVpp0rWg== X-Google-Smtp-Source: AGHT+IHR8HklbQ89hqdZVgJ8PYNFpAj9XsVaOoJVYgo+piSNWPQebi6qb6dm/2YPc8ECVMbTFW2a X-Received: by 2002:a05:6a21:a5a2:b0:1a1:6b04:9f2e with SMTP id gd34-20020a056a21a5a200b001a16b049f2emr12815458pzc.9.1710348906092; Wed, 13 Mar 2024 09:55:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710348906; cv=pass; d=google.com; s=arc-20160816; b=frG0WvEFjQynbIGmjxmsm35ff4qY2sdDKJaeoKfcy5lWlsDMdmkl/+DrnNbFtOXvGO oQUXgmuuczd5DgyA2dmWzwGeiX/9I12uaPgVvKqO9vGwWj0/jrOdox/X6l464nkUj/NI sooLmOwyiieE1YxmdSE6WEkmbMKIjgPIQ9lmpbiCCLVtRvIGdZ0RWIapvFty96zwAZjV 1+JcfE49TtclUpDZZbLyU3LlcWCtrDTi2XHUzbZ/CJtN5a9z8weD5XdhpvhWecIPvnL3 RqA+zTGArequYG3zOzat3d715HeRl6w71D/RdpWMvSM2SYnva4JokNpstX7wq3aQGD2Z Ofcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=9gzLZfd+JMjIzL6/RDjFi3VNpKKHaIqnTRI+4eVsZds=; fh=1jYYbuaj/VyAqGwC3JsalollMn9yv3R3tfsFFg3yKJE=; b=In4+a7wc0S2CNT4omvbljoEgs6ALX7F0+I/A2PRial2yfshYso/x3aQv2osZl4t6Ai Kpbkk2E4SoU0mx6LFv9ZyheZTwLt0s7zsYEp8lU2aNRCR49aIkk/NeAKr8q0wgkypOCu puU300hjxxPDL1XPE/gnh438LHd9mdjJl6P331nA1Cmpb2jpQoMBqcl711YMJCkvRCA3 3C751H/GVR2eGO4/YsPoPUgvpGHz15VExi43UJ3WBBkoRXOK+OOe1bGPea3lIvcSqwVs 7YxPQtnVXRHQhQnOEEb8z/OxdnMBGJdQO7OFGjIQ0povqmKo5RsYMCqmMISLKPHhbd0N ulVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QcFccfP0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r4-20020a63ce44000000b005cdc2cc9a1dsi9396452pgi.699.2024.03.13.09.55.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:55:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QcFccfP0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 79941B21842 for ; Wed, 13 Mar 2024 16:49:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 587BF5D732; Wed, 13 Mar 2024 16:37:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QcFccfP0" 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 7016F5D460; Wed, 13 Mar 2024 16:37:21 +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=1710347841; cv=none; b=jnV4OHajy6eCbSVMUr9yfzxbqb26jLmk4ymdmWl8gARcYFtKTD0lbno4NwASSvZPQ1cyLk76gOzPdhxdaO1RbI5vOWPAXq05ixJWIy/WzOzOuhrtbJpXs1TuF2pujkXrvBbECCWnMKsBMy4mHrymstqmQgotJq9Ft0UdJ9XmW0w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347841; c=relaxed/simple; bh=KQvW4QLqr7rEMfi/hFQOWFcSE+Lk/YdZwM/sAdZU8Ec=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=l/8xOwwi9p/siTm31mLL0hG1LdBEN7KccuMveJQNh3nDjvIDMpQvjOYdLf4PFEdrd3Vxn29MNWU4d3KHkcWWQH0vJjQypzDlzuDfMF13TWAUSsTEmfoUN7HmiF+ODi2VX8qpbp0V8PgN+dm0TDnrn00QDq+a7QWNbzIAkTD/vB8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QcFccfP0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E82C43394; Wed, 13 Mar 2024 16:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710347841; bh=KQvW4QLqr7rEMfi/hFQOWFcSE+Lk/YdZwM/sAdZU8Ec=; h=From:To:Cc:Subject:Date:From; b=QcFccfP0iWyuyg7dmYSxeMED1MJH9zJ5I13qdTMpm9k+gBLWKyBb+9/mOB2KcfRh1 dGhjb9W/4N+EdKcUS06eR55r9U0S8mzyfKb8b0WFux1jA6YamOwOIkVSc08H5Y0+ei 5zYu2a2uLnMexXRWo1UTiwAn+gXmGL2KIdz73bUcJQ2fX61d8N7a9/by2Y7lSR4pHO QwFUlknS67JXAADwfnpFFhUX50hQhSq2q/rKT/TU++YuNB2FW18cOVde+ClYZbs2kW n40Y9/7SY5DtcSfsTJqg1PwTYbbfI0pqSU9J1AUR/mgG90A5sqpl8eknByDXrK8ooo UP3iMh+Rryv+w== From: Arnd Bergmann To: 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, linux-kernel@vger.kernel.org Subject: [PATCH] staging: vc04_services: changen strncpy() to strscpy_pad() Date: Wed, 13 Mar 2024 17:36:56 +0100 Message-Id: <20240313163712.224585-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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), -- 2.39.2