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 B241A146580; Thu, 11 Apr 2024 10:04: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=1712829861; cv=none; b=PNPZil7ShOhpe1P8Bk0jNSWfiHVSsujE+v4H62hmtmHMm5ZwidYiBu1psg5M+i6JWpbUwBTCTReLauBXW68paRAH6wEZobWbBQLYOF+EzyV1cLL33Nb490mGemxEktJalCLpzAQP5819mWhFsJJAW7N+vTto8GgtfUMFNHx9zSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712829861; c=relaxed/simple; bh=PoQsOrLHEmjXyaBrThmjKevPN05h+/VChBg8NU8A8FM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H7bLak5KaIASsIJe8dvpYvmBm2Ws0K78apnaVagbDrHN06xrlgYLaK2JIAby8QEagUfQUlaF0nWNTQHrp5yxuboNo3bPLIp3uN3tMrjrPLDib/9TdJh32oUUX9AuQG3m80M5ItsoeCP2LGvhLj7d2VTQy4JDuG7mYJTxKfwnS7s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KEwVBhNO; 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="KEwVBhNO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38F68C433C7; Thu, 11 Apr 2024 10:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712829861; bh=PoQsOrLHEmjXyaBrThmjKevPN05h+/VChBg8NU8A8FM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KEwVBhNOT3NWA/SJW6oDCBS7CvNOTHR0lCB+veJW5qPb71JlsFCRkSCxQTCF9AN30 BYTUCXG6mKqV3MtTH5fxqUlU5GqiwHGUtsyRXwh1lDQtY4c/KMUELJ++KyX1PdqKiu Y8MyoBIGIw0VcMpCMvt9dHspY9Qt2M8mn5ojfagU= 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 4.19 131/175] staging: vc04_services: changen strncpy() to strscpy_pad() Date: Thu, 11 Apr 2024 11:55:54 +0200 Message-ID: <20240411095423.508245814@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411095419.532012976@linuxfoundation.org> References: <20240411095419.532012976@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 4.19-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 2794df22224ad..5d1fb582fde60 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -921,8 +921,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