Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2624229lqp; Mon, 25 Mar 2024 04:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0J34WYxDHYVEse1ZINv7cVQOkOOmIAM6i2MtknzKXKdr2VIHPUw7zqHgx0bZGNmmOIvflcbRWvIscXmpELtCcUlDQsF2OfBZBVGsCng== X-Google-Smtp-Source: AGHT+IGRghdsOz4LegmK5fPRwbz2i+89HQQdOdZ46oTz8c/0Wer/eCJABPpgfHkWq26DFGGeDkEi X-Received: by 2002:a05:6359:4106:b0:17e:f422:5e48 with SMTP id kh6-20020a056359410600b0017ef4225e48mr7765061rwc.13.1711367870113; Mon, 25 Mar 2024 04:57:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711367870; cv=pass; d=google.com; s=arc-20160816; b=CWTv02WTpYdVHmU5Ht0SaR7hjGsi37UN9YDwgJLz8/RZQNfWsXHVlQ6MMLhgTp/Qz/ F9eESS6LB/N9GCObaQ+pKRcspcw3K1FS2Vup282FRcwxbqowk+uFAw2Qf8GJRfKtzBV0 qes8nQxBSbclv8r+gMlCqRsPmwjjDNGRDqUonME6w1TH3lFXbn+V/vWygt6WXn5rsjes xUAjZ2rdnqxglDolerzynIP03tB8JaZj9aefureRqSHY08KIlFonQUkSOS/KYNaVd8D1 04CZiuqysu27DPzQoQmc72KTELfXBopVPFwgrmATINSsczlrZPGB4K0Dps5ZF7aCM2SW QrfQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sWOZN13jxoQRwJUzaRT0qw/zW8SlFDQm+xm07uL/mB4=; fh=/TnrLxI5sd/8bhOUk5NCak+Scug04k+QZYgHCAWUD88=; b=FjIA5uc4G787/sGJUa5naUEqSzbSfv0YF5DaFYqbwJ3NJu6fz+ZTWu1PD8/0YMkL4R KsXbJBJ00Xfc9bqpr7zwO+doJiDqSOrmnyHNc8WpQ7i2RU1yMWuPfM8ZKngtE/z+5KOW ABZNTKRVzJzQ2XJp8RTjewAxkgSw11Sxw79DJuq5nsPxyhKvEgDbHikPM15RiLyFUqv5 +sEKsXfr1UlILejjd2QlwMK/F8/8f1p8JEETe7DQniLTvMn9h7jIn1efy9qfkK5E1BiJ yUb082EnGhzgK/XNyyeCNJVQuf/uf7JqEYWdCTMHdRV4glh0uBFWXoC6lHSusRRLKH3G MAwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a+7kqFEB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116152-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 a7-20020a63cd47000000b005dc359329fasi7102390pgj.23.2024.03.25.04.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116152-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=a+7kqFEB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116152-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 5A762B27CBC for ; Mon, 25 Mar 2024 10:16:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90C893B1E3B; Mon, 25 Mar 2024 03:32:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a+7kqFEB" 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 20E0417AF96; Sun, 24 Mar 2024 23:41: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=1711323714; cv=none; b=fvVYG5IKWO1laSnpbikj6DRzX7/9/DVQbfW2NNyqntQc1O3p+jgu6NkbBPKrlNm7kHeLD2cdUPvyhdS3uT4x1LNsNOF5YgyDr1ONYgyjBOu+71xx1tCiGZunKIOvVbsJRiVHBC6+VPRbw3/Z6E/u1yMpOqWCNr4RvDz4PG6RGQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323714; c=relaxed/simple; bh=zIHIDGYrNQow1bY9+uueUFMQRpndkPOjwaPDjx2YMEo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ky+Oqx44g80sHWZygT7QHLHdFXnwFwvy+5QkjBGWqZFbph/VoqgdH/2mkXuSyTWUf9DSsGrmXeLG4Qbl1zybTb4L8KD5mTT6lFGA0v6rqIYlhHiRF94KRaUGi2IM1x11H4Zwg0HrP/JTRd2lfN2o7fIj2X8MTySSihzOjOiJ0EU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a+7kqFEB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7967EC433F1; Sun, 24 Mar 2024 23:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323714; bh=zIHIDGYrNQow1bY9+uueUFMQRpndkPOjwaPDjx2YMEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+7kqFEBdAp67vwgqEq1Akidu/W0XrmgOvrVL6R6vfjEDS88rGjqu4zxti15fNYRB 8a7K+D0ak3h3+vH4SUX/ZR4OUhyX6Jwd6QtiA6RSN+FwKFB+g1EGa7UMgdAWKA5Mzd NBS6+UyMCxrQKKWE/HO6AHpEoWJQ+4T0P6tzAId49MBDgF5RLrIGJy9FhzrQoJxIcB RYf+0FmTpsWrdzjLmdjtMHquP3kgAjLT8h1hfFHDgkTaDtpl+Wn4Wl81mHgqFbXr9P OBl9iOAobosBw6qDUjFQ0D9nkgNT2y31WqeazzSa5R+6He98TdzYvYa9ErJ1Rn9FRv J2wYh3QKuCB8g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.10 087/238] Bluetooth: hci_core: Fix possible buffer overflow Date: Sun, 24 Mar 2024 19:37:55 -0400 Message-ID: <20240324234027.1354210-88-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz [ Upstream commit 81137162bfaa7278785b24c1fd2e9e74f082e8e4 ] struct hci_dev_info has a fixed size name[8] field so in the event that hdev->name is bigger than that strcpy would attempt to write past its size, so this fixes this problem by switching to use strscpy. Fixes: dcda165706b9 ("Bluetooth: hci_core: Fix build warnings") Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5f1fbf86e0ceb..b9cf5bc9364c1 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2175,7 +2175,7 @@ int hci_get_dev_info(void __user *arg) else flags = hdev->flags; - strcpy(di.name, hdev->name); + strscpy(di.name, hdev->name, sizeof(di.name)); di.bdaddr = hdev->bdaddr; di.type = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x03) << 4); di.flags = flags; -- 2.43.0