From mboxrd@z Thu Jan 1 00:00:00 1970 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 E4243140E3D; Thu, 11 Apr 2024 10:23:33 +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=1712831014; cv=none; b=mddOxrFPrSldtws6lC2mqFt/2T+aR9OxW+2fIu3Y1bu4KcwDXK/VEJXNWNWvjSD6zdTAA3BG6xBden/8VNnZLubMElG7QZDNd+28WjcJJnDT2B2xZbVKobDUps14CX6cET+6GVw/YBHlnhCWqeHmx0pTz/HrxY1bBP3kTmrx480= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712831014; c=relaxed/simple; bh=1eKpx6CWaokosMV6nwBiYrd9VlsdX1EIAx9umwNeuyU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GZCzmpPI3fPcMBto1wme+At0wXwclpdD6aXMmuzicYbaawmra4fgv1nHGZTbGznoldDfCXIsJNGxpympSr2Ox3wvaRO8ns+KHm3BgD22rnJuQWg3KNzsxoQO9AxCvzWlAQ4BVxl0KoRDYGcoTEqGsgGKR8e58w4iIMM/mx/75NQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=E2VyqsXu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="E2VyqsXu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67EB3C433F1; Thu, 11 Apr 2024 10:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712831013; bh=1eKpx6CWaokosMV6nwBiYrd9VlsdX1EIAx9umwNeuyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E2VyqsXu9U9xr0gzr/Rx1pSB+eA3zUlYq7f4c+2+9PdrlJx/EPPciN6cruI7rtWZ5 F6QNu6LFR7xbUi7GH7E5nSRImVoOIfQoKRTGUIuOpi7+jF+MWb+SplQQH5m/UekHbR ok0/T3K/gtysDi6odbseKzmUC30imwEI5CtNlg9I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Arnd Bergmann , Dan Carpenter , Sasha Levin Subject: [PATCH 5.4 156/215] staging: vc04_services: changen strncpy() to strscpy_pad() Date: Thu, 11 Apr 2024 11:56:05 +0200 Message-ID: <20240411095429.569694703@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411095424.875421572@linuxfoundation.org> References: <20240411095424.875421572@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann [ Upstream commit ef25725b7f8aaffd7756974d3246ec44fae0a5cf ] 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: Dan Carpenter Link: https://lore.kernel.org/r/20240313163712.224585-1-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman Stable-dep-of: f37e76abd614 ("staging: vc04_services: fix information leak in create_component()") Signed-off-by: Sasha Levin --- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 23d869ba12e69..fab119c60cb12 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -929,8 +929,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.43.0