Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2378076lqp; Sun, 24 Mar 2024 16:43:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2g5x8NOxCX0z1G8TguzbPzrCFzMf0ee7SVzlseus+4nh5ZyTVPvBjMx7uzwedOJvgV/k/rYosvIUnBweGEGG93hSraZTuvLrLoKv/Nw== X-Google-Smtp-Source: AGHT+IFhyxWaOJc5S3gJQL7X4mezo0IEPukKgLMNohbrWKtIstOeR7/cQytJRjBbqNvKQNytDU5P X-Received: by 2002:ac8:5d10:0:b0:42e:e13c:dc30 with SMTP id f16-20020ac85d10000000b0042ee13cdc30mr8646657qtx.29.1711323805629; Sun, 24 Mar 2024 16:43:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711323805; cv=pass; d=google.com; s=arc-20160816; b=sLjZjgq7aRZZC63/ZhXA+O8hykV1RDEi4Y3txrmlXw+s0i1tThtys/4E9hSErahhkv U5xnVh/ZoVBxWVX3I+BMxSlOVqpupiT/ryw9kKsto24Bgek3Fwqxkk3vrytZXrhXcqO3 P295Xn6ZLDGXyTP2QPw2/pBq3Zj7H2pnNgRFskY8j692qt+iRvu8CMgEA78br3pKNzTj FNB5fQOisBRGfwZKyCl3DZsCcZgrRQ9MCdsODdnJ/2VZkHMknrMzZ/NT18edSmXd7BGZ +UXFkb2jYgtHz/aGyb7tYB1Sjmg7zdam/bckbaApnoAvVDP4jFukJ65r4LDqKF8eTVZD ENjg== 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=umiMdoL7M3U8Gso4hcFKBQh9f5e3YDH8JkNlbymn0GI=; fh=/TnrLxI5sd/8bhOUk5NCak+Scug04k+QZYgHCAWUD88=; b=vGbjojUuNZI9PDMq09ArewE5Ca4bh+1pAW31V8K4zJqdlv0HyBXeDKyvLHORFyEJ4K 2DixbjzbnNW1uacNbZM+RBE//drTrmRI39F7zgS5lrDc6Ov6E4wxyxuMDNMHkDB4cB75 BWoC2pMArPWlnr/vG5ToXk+lcWDQR6qZvytNrBwMidemMPalNxvXJ1zhUYPqI5pXgfNa NvCDvx8H1vMydWfdPzBcXTE+swLsusWo5+8sBPjm5K/f0iC9bfody6p4BxoXdr0zHBHe 1mVYbYU2EHaBpX+SVX12S8Dr84k+GLzW/qIKC0sBwtmCSm1mtKlZ4Um+oSvKEl79SHcr /H1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I5TzMeFs; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-113203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gd14-20020a05622a5c0e00b00430d4942c48si4526286qtb.365.2024.03.24.16.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I5TzMeFs; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-113203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113203-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4E94E1C226CD for ; Sun, 24 Mar 2024 23:43:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2446217AFA7; Sun, 24 Mar 2024 22:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I5TzMeFs" 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 0C29617C6BF; Sun, 24 Mar 2024 22:40:05 +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=1711320006; cv=none; b=HcO4tGaPcCqjxW5Au5cyU46eGPHrFI+5UO1riEvvYwEAsNVUt9j8sWjBBgljvI0Dr1KmW2+lAI6ITYyMAtLWQexKWuTBw7aAeAZngWNvgP36P/aBvD/N+0OYliYo6FAiiHEiD9h8lLRHJu+x8iTaesgi8w+51XDBCd5VxsI8f5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320006; c=relaxed/simple; bh=Ugg1J7IKQDMYXnCywrahvRSEfKqAl3Vln5nLujV8KfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iPVDOvCceebkJUQDcCWB0HlWnm9ckQL64kV1jdcRJxGPJvpZ7tBk4fi7txsLW1G3iZkF6VgFOStHbRA7w9gNs9XtDHH3nhVSF+aZn3K7RlCmT8o+aPgYvbwd2euQMj6HptC9l4XIn0EZPyrZjMu3pzfq0KHTUsWOXMOOvZkbRfI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=fail (0-bit key) header.d=kernel.org header.i=@kernel.org header.b=I5TzMeFs reason="key not found in DNS"; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 126A0C433F1; Sun, 24 Mar 2024 22:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320005; bh=Ugg1J7IKQDMYXnCywrahvRSEfKqAl3Vln5nLujV8KfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5TzMeFsJtoT3Im4TEpQLTctddumqFkAN3up8sHX/MBLiTLDPOpWLXLrbsDabWtyq SNoi5vGCIvp2ulKKugfTdxifn/x8ah7oKm/kJPnUbMxTytMugsqo0JejWCrBc5zDTi iOeH0nznx2ZGm3KDTDyi25EsJjCZzElAWMZmz4vcWhlIDhqewucMEQW4RJ1X0kDrzT UCJiDJXjFnZKwbEsL7AAWGDeyPYxIpnLDUPyNkYa4y2X+26aFh2Or8oS8mw1PG/JlZ cjda5dCkbzoRbjoj76hr690HH11GgRAeJoqiMmkhYIlH6x0Vl/4sUt34BG4uQQHz55 fydaGgrLFpVNw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.8 312/715] Bluetooth: hci_core: Fix possible buffer overflow Date: Sun, 24 Mar 2024 18:28:11 -0400 Message-ID: <20240324223455.1342824-313-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 96707deef296b..85a91c438d721 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -908,7 +908,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