Received: by 2002:a05:7208:13ca:b0:7f:395a:35b6 with SMTP id r10csp20973rbe; Wed, 28 Feb 2024 09:18:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTXSRf9+lyPdyu8DlOAhjURWiHAGE4Npe0XenpKziTFHATtIvr/Dc5PWxUijebv54L0hfGZlsam7azvzr8PXjorYX7ybu/FIRatblNsg== X-Google-Smtp-Source: AGHT+IGCsRTUIcJbbbabkKmo2T5lXWPo2Qu2Ye5MBXytDiHjkAzmLndkrkN3RvMQQNnm3cASl1b5 X-Received: by 2002:a05:620a:1354:b0:787:e07c:2e11 with SMTP id c20-20020a05620a135400b00787e07c2e11mr6047932qkl.57.1709140730150; Wed, 28 Feb 2024 09:18:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709140730; cv=pass; d=google.com; s=arc-20160816; b=SML4mn0b67FyPAPDSRJS9us2btom9hRoqHGwkFCZ1QVoEtgmJgFdp038GqaheP7MJz mKOpGplunUg2aomM2Zm+CLoP303WpJ2BIS01MnQoSL7LZZcf1mFM7J275wpHnM6WhsuV yxzh6nzj7yBEUFud9VHdgNYhmbKJed6REiUqxr4rrdyVJVx5DVRaJ6pCC5aQTCeLYFTK Hbq6Se1q/Yzowm2gkBReqfpkSr2xu0LBgbPo8Q7Ap+pTeTYlipk+hrj5wfwLV2bm0kCw rOErOozpov+5lbt8xylnP++5n+6C7yzwrJi1RKQBMVyAY0XpoyBe/sF2OFRH83/0iWnr l2cA== 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:to:from :dkim-signature; bh=1thNE+TSw6a29ubGw3hczldHJVUyaRqAEb3p4QN3oAw=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=uIQNvCxZkOPDcyFrNUwmMQ3iWd3XGFDGOnFfoHY1hOHlvBfx6f12NbWT+SJWKFJWMo GIrRVfK7L4FrC5I/vZhqaNzJNnSUSvFhiKSa4WCtd5N1CMnEwQ3qH9yC1z7Gdw6Y28EZ KgQS32vc7Mlp9Uci8hHwZphKGx75onykdS5ymcmbZlqj8DA0nSBV4DL9/FVTCLJeM2g3 kxh8O8JVcVLOywsgy4HKrEZa0ASZ0VN15poVOxRNhALalhR4jB8z/VpljyCktXqoi9Ya JCLs2uE6fRRcrzvaeZeRoHlDqJ34jGZdhTdOppl9c2zWZnUgo+3QTN3/RQLW4GIFDpBD 1apQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FoyyyNLF; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2190-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q20-20020a05620a0c9400b00787c13abecbsi9613989qki.279.2024.02.28.09.18.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:18:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2190-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=@gmail.com header.s=20230601 header.b=FoyyyNLF; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2190-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 E35F81C24296 for ; Wed, 28 Feb 2024 17:18:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 036863FBB8; Wed, 28 Feb 2024 17:18:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FoyyyNLF" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0836A6EEEA for ; Wed, 28 Feb 2024 17:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140723; cv=none; b=OzwmjT8wve03WxCwHsgA24Ny/16l6VUgeoqe9ICTJ4S7/UaCIUgdq1VFJx0Cde63BpvBI+Kmr3RjbsB9tvBRTbgH4Hl6+QZ66NXK1WqRwSgJ11nU6CbfMxnyE4gu3XLXZWzB8aW7bO+jdC2Nxeq73QmSbyShJ1UZRM+cQQCBFOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140723; c=relaxed/simple; bh=EbhGXVWDv4uTbN4g/cb9lNJDy8bsfocGMQd5k7SjruU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=JEvS1fiDHe+h4KMJ3WDabtpzBsL3Uw5bhS3LvYDeYeUhkGjzaq0H/+/Mrt4IwVyB/JhWya67Y/O3n8t3+tFdlBXQnvXWpshzcfhkFQYZH1XXFI5uV2Flo5g/Bvwtrc1zgil7dmKAEn89Frv/8T0vFk/VIeF+XPElStElV+txDY8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FoyyyNLF; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3c19b79535aso3087088b6e.0 for ; Wed, 28 Feb 2024 09:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709140720; x=1709745520; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=1thNE+TSw6a29ubGw3hczldHJVUyaRqAEb3p4QN3oAw=; b=FoyyyNLF6yz4Z1iiKrc/Zn5ePEylZsEdls9x928Nb211azrom15NGbZUauPMBme4e2 jfc3ih3Cx3fjEU+br8Duv9WNApOMfCFPribfu3Tk63bHcUQmTBYqhC6EwV/fCDHEaRkL uVN4KVFP7AUVhRPf/WUbvpl/a0ICWF2QlI74PgjsDycSUwz0AcBULq3YVl2Ew9Bl/Vwm ebbf845XXt9f63eZPdx4z6ujpiQwDJdtN1CZoAHtAS6y9DoF4oVyayfM0XJ9mb2ui2wa 7y0jak3tUTqDMxaDPXT/imrlnUHx7JvCp+Qr+KXF/H9CeLxQzeaxa5T9rhmcItcKAHEd q0UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709140720; x=1709745520; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1thNE+TSw6a29ubGw3hczldHJVUyaRqAEb3p4QN3oAw=; b=LzdIgDXXjEA7reqQtBmagwgTzFlySJPrADjQh7CDtqA5TeQdSfxdNbgSPRyK9tyDlX /5Waf6cuffY5LoCbUvVcRgyTbI5HxlbbDIAd/SCOYYJ19rSpDwCipoySYyalaHN3rLLd 2cWIVCpRmLT+RxPDyqPdxtwZXezsL48tpjmz7/f1b65rSUnBg3dTiNQ4f0lmv1jrHUQ6 I9h4k43dMvloPfUY3gHnJVaTsDbfydB7AFFh3ACCzPUwTGTd5USA2pVaif5BHdSGXtFs wlUorT3IKWP6Ih2nU3wJessgTlpYbL9/649YDfAhStYBzWyl0Q/LQw1VsIkHbkFVxjmn r4vw== X-Gm-Message-State: AOJu0YxYEPN7PMpocC7sg2wdXsKm6Im03T3gdIBsOEPGChtEt/ZFlBru YOoyHLxoESAF1k0QnfkiRJkA3c0pi8dXkr9MkW95aQEgTCo0Zgwp+gWxR6xx X-Received: by 2002:a05:6808:151f:b0:3c1:b181:6639 with SMTP id u31-20020a056808151f00b003c1b1816639mr5340061oiw.44.1709140720038; Wed, 28 Feb 2024 09:18:40 -0800 (PST) Received: from lvondent-mobl4.. (107-146-107-067.biz.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id q15-20020a056130028f00b007da5ea1638asm1488240uac.1.2024.02.28.09.18.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:18:39 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v1 1/4] Bluetooth: hci_core: Fix possible buffer overflow Date: Wed, 28 Feb 2024 12:18:35 -0500 Message-ID: <20240228171838.2414532-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz 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 --- 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 2821a42cefdc..3715d2f3616f 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