From patchwork Wed Feb 28 17:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13575780 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FoyyyNLF" 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-Google-Smtp-Source: AGHT+IG1SkRh5ynL/WJcCEU3kwflNGMlHi9UddWOTZr2A6nbScNEJol/mbOyCmrpmfaiEYRUNXiDfg== 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 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; From patchwork Wed Feb 28 17:18:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13575781 Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (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 10CEC3FBB9 for ; Wed, 28 Feb 2024 17:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140725; cv=none; b=NZYCXaLncotwJ3rf2gz7eH3fW8bx+J1nvaZJ+wLRCcWiG3UyQjJCq+ZWK9kR8csQIOVUBhD4RY+UQq2GVltZl32pswvdENSVNs8wpuWzMAQlOOLeIgSCGCkRNGJwki2B7ljviBfxxgGZoEVIbByswib7+FQIwA5STUhY0NzD4hI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140725; c=relaxed/simple; bh=DDJTxigrYJNe+hvasrncv7SuwYqHmPzvt3OB4e1CUSE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mUtjyq0uC3Scg+bjR577tcNJu9eQE/5GbppUri632UZVB6M5KwgxEdfozgpndGgvHgT5iaZiOniOdt+lJiLM8nd3RKGvuYa8U5wfuBM7NAXnBBCHdto9JMLIItkDOK0m850NkN5vm/L60S8AJTOMEbP4oDKh6SaQMk9TJ0XdIZM= 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=K0OSCyiP; arc=none smtp.client-ip=209.85.217.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K0OSCyiP" Received: by mail-vs1-f44.google.com with SMTP id ada2fe7eead31-471e18cd6e3so1105514137.3 for ; Wed, 28 Feb 2024 09:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709140722; x=1709745522; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LkEQHRvIHSxiCUEkiY2X+Bz0cgrubH+U32WUM2dI5yc=; b=K0OSCyiPAVzKC63V2C3nhHITq46rRZOQlGOz9JROo500r9Z/ANU1JKuA5/PesdPDrT g4IwjTQdcVlNZt7nGCqNdzjR4VumUJovlaUcq11JP3dfgiijGuZp/KwM8mPz89ONe7pc Wq/cAw0Z++6+HcMZ7Q8oO2Ho+oDQBe0eNvwTtDbcT+jvNAiFjqAfi1ke8fR5g/C6cZBU sk6ztBJPpUgOKr3WoCiQYqkgGdNZba/NxdD8l0Eu8u0ROX6lgy1OcDldQRVrD42VXoXx 8YBJCS9RSjABphF0AkQiRRsojDbcSf4k4A5bAz8k66iuwBJV+UEP3/laSySCmrQDnan7 RCkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709140722; x=1709745522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LkEQHRvIHSxiCUEkiY2X+Bz0cgrubH+U32WUM2dI5yc=; b=vZriETPqSgH9p+1PRfpYuGU8xShUYgDg0F8GJUd3bak6j4E9v8KIj6cVdPIlPR+KDL 68hKGJiKqdwa/FArFjaEPC0i8nf7coqpBhn6xUzWLO346s2jFAw9WkrXWXRukkBnrA7G JMaOJMxKZNmQXYRfxply6j3uUWtqmPybhk5lH8DRoGmT7jdwh4+FPRXkTMh0TuVNavHz FuChm3ZA9t0CfkP7L8u8vriob7vZCLM7qz7za5Vw6VvJ9GCuX71avpG7op9U74jXypDO eB0c9xmCdK/BkbuK7yynn7tmiQl7TDU+EAxF9suBIjTgNk0G5bG7bYpsh5NGDbD+z48K 4uFQ== X-Gm-Message-State: AOJu0Yx3+w4ggLHOhOU7Elg1hKSKm8Bhtq2CkZjvyJCnXBIsMa+aE4CG bhnHzB07EcL0xmKevBreTeplqx3gW7juewOcw709jsDOymys4otOnuF0BuWq X-Google-Smtp-Source: AGHT+IHSh8oA+5/9sgD6UV6k/yoDb0cEogBBEYkW145G/m8aCtmrDnXzJpxF0z3akhXLLhKZIrEhWA== X-Received: by 2002:a05:6102:954:b0:472:71a3:6071 with SMTP id a20-20020a056102095400b0047271a36071mr210706vsi.3.1709140722294; Wed, 28 Feb 2024 09:18:42 -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.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:18:40 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v1 2/4] Bluetooth: msft: Fix memory leak Date: Wed, 28 Feb 2024 12:18:36 -0500 Message-ID: <20240228171838.2414532-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240228171838.2414532-1-luiz.dentz@gmail.com> References: <20240228171838.2414532-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz Fix leaking buffer allocated to send MSFT_OP_LE_MONITOR_ADVERTISEMENT. Fixes: 9e14606d8f38 ("Bluetooth: msft: Extended monitor tracking by address filter") Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/msft.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c index 630e3023273b..9612c5d1b13f 100644 --- a/net/bluetooth/msft.c +++ b/net/bluetooth/msft.c @@ -875,6 +875,7 @@ static int msft_add_address_filter_sync(struct hci_dev *hdev, void *data) remove = true; goto done; } + cp->sub_opcode = MSFT_OP_LE_MONITOR_ADVERTISEMENT; cp->rssi_high = address_filter->rssi_high; cp->rssi_low = address_filter->rssi_low; @@ -887,6 +888,8 @@ static int msft_add_address_filter_sync(struct hci_dev *hdev, void *data) skb = __hci_cmd_sync(hdev, hdev->msft_opcode, size, cp, HCI_CMD_TIMEOUT); + kfree(cp); + if (IS_ERR(skb)) { bt_dev_err(hdev, "Failed to enable address %pMR filter", &address_filter->bdaddr); From patchwork Wed Feb 28 17:18:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13575782 Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) (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 5270913541F for ; Wed, 28 Feb 2024 17:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140727; cv=none; b=jxV4Q7Ja9mmfKYLD0VNLqGSYP4p8r1R+3nFnbZk9ehbHydbqIIzHS651H0SCQrjBOIfXK89dcfvJIAJD4Y52t3+3K1sX9EA/6ElUfwOjM0QtUvwZFse2ouS3I4ZhxzSbJhP94C+qn3h0ht5PKCVawbm9LzjyC/c9NBLo8Af33Vk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140727; c=relaxed/simple; bh=Q7ZH8bzPPKTfWUksDeKP0xIJaWEn1+Fr0DTy+Phjze0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uu0niEg0bPaiPKIzNA7nPltzzWcS57tArGR3oTzsqjPobQNNG12JWaTCGHYmZom5mIzIYGns3v8gRBi2pYhs1OiNwrnR5Uu+owDVRrzPLXZ2hx8e3L5Cm9aHpy+DgPUFHIQV+VjyjsIm2PhV8FPgQDFRU9Q+5rxubCwF3iBNjKE= 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=FSJzP3AL; arc=none smtp.client-ip=209.85.222.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FSJzP3AL" Received: by mail-ua1-f53.google.com with SMTP id a1e0cc1a2514c-7dade974b0bso379726241.0 for ; Wed, 28 Feb 2024 09:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709140724; x=1709745524; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=felDF8qgwj7K2wUORV/pZCWpVpWKyzHzAB62pSQGbmI=; b=FSJzP3ALtcMxxz5xK80bykTO03QyTAqDgxp1uHT5hEzZx6riJCSemWa8VC1npDeRSC EhLo9dmJsQ7X2Fb6EJk3RNMFjQ+trLyHTvJp6IfRGpkJnfEeIvVx+UZXXgN3vV/BdXAF slv2y9xVWDGEgSPMcy6/Qv1P4pJ6y/6QZB79dYkjXyXiuOUqN2ebKugFSc5RfiFQnPBH tZur7Lz9TO/JfKH5DinCv+5YYlZ3Cv1JxBR3i1qAgajMSK4CXyHMFE39evbqIa9zRhLz fLV3jANGm7+iABqAdeF+ZToUPYFM62P5zcF1xkSrMTQQA4E14ErzZTkKWrzcF4FsorI0 IZ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709140724; x=1709745524; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=felDF8qgwj7K2wUORV/pZCWpVpWKyzHzAB62pSQGbmI=; b=fcR2iPTd2iUsl2Ivp8WjLGsF/EAlqe9ZRrtyv1XXm3bErhOq4C0tnpRPNlhVK1YV/m MJ6uOmtaWTY2Lz7PIlD9PyGo+V9gFHRo1nVPNACFjyO/rh/32ITgYMgj2jE3jZWXSQhg HA0prYrvYLbBAf5ibsfC/Lor3x6OlgRYPFr6D6ODkdZ+JkRocQRjZVSlQigkNRrPYytZ AhOVGo4BxGIOYUSeA0dKTTrIBNQ0Mmf62mNXANXdRM5FziCKobl02o8oMihOf5zdM0AM W3XQOtDUp8V0Hsd7Xl18m+kQKyEdiCpP2LmXFM0950WEPXP7E8ES5aFgB3GjNSGJ2eNp yZyw== X-Gm-Message-State: AOJu0YxR3FkQc0Mlmk18oCKQH8se9FkhfW7w55xpatv8wrXkdhUw9i8g Zz+Pd3A+cIP7Q9Aw6GgSxYYSCa6jl44ugimDj/O9j5VmNjpWM9spmzPGzsdC X-Google-Smtp-Source: AGHT+IGBpPPHofmQo1M+gIgPca8qpNPvQJ+WSOJiHHnUxXo8udeAZGh7v7qm5wzy5CFObRRHHeLVIw== X-Received: by 2002:a05:6102:3709:b0:472:623b:75ba with SMTP id s9-20020a056102370900b00472623b75bamr146284vst.2.1709140724058; Wed, 28 Feb 2024 09:18:44 -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.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:18:43 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v1 3/4] Bluetooth: btusb: Fix memory leak Date: Wed, 28 Feb 2024 12:18:37 -0500 Message-ID: <20240228171838.2414532-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240228171838.2414532-1-luiz.dentz@gmail.com> References: <20240228171838.2414532-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This checks if CONFIG_DEV_COREDUMP is enabled before attempting to clone the skb and also make sure btmtk_process_coredump frees the skb passed following the same logic. Fixes: 0b7015132878 ("Bluetooth: btusb: mediatek: add MediaTek devcoredump support") Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/btmtk.c | 4 +++- drivers/bluetooth/btusb.c | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c index aaabb732082c..285418dbb43f 100644 --- a/drivers/bluetooth/btmtk.c +++ b/drivers/bluetooth/btmtk.c @@ -372,8 +372,10 @@ int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb) struct btmediatek_data *data = hci_get_priv(hdev); int err; - if (!IS_ENABLED(CONFIG_DEV_COREDUMP)) + if (!IS_ENABLED(CONFIG_DEV_COREDUMP)) { + kfree_skb(skb); return 0; + } switch (data->cd_info.state) { case HCI_DEVCOREDUMP_IDLE: diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index d31edad7a056..6cb87d47ad7d 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3273,7 +3273,6 @@ static int btusb_recv_acl_mtk(struct hci_dev *hdev, struct sk_buff *skb) { struct btusb_data *data = hci_get_drvdata(hdev); u16 handle = le16_to_cpu(hci_acl_hdr(skb)->handle); - struct sk_buff *skb_cd; switch (handle) { case 0xfc6f: /* Firmware dump from device */ @@ -3286,9 +3285,12 @@ static int btusb_recv_acl_mtk(struct hci_dev *hdev, struct sk_buff *skb) * for backward compatibility, so we have to clone the packet * extraly for the in-kernel coredump support. */ - skb_cd = skb_clone(skb, GFP_ATOMIC); - if (skb_cd) - btmtk_process_coredump(hdev, skb_cd); + if (IS_ENABLED(CONFIG_DEV_COREDUMP)) { + struct sk_buff *skb_cd = skb_clone(skb, GFP_ATOMIC); + + if (skb_cd) + btmtk_process_coredump(hdev, skb_cd); + } fallthrough; case 0x05ff: /* Firmware debug logging 1 */ From patchwork Wed Feb 28 17:18:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13575783 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 8FFCD15959D for ; Wed, 28 Feb 2024 17:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140730; cv=none; b=u42C87xDFHBdbIabTZ6i0g5mhTpYbT0aVjqDlqLqVNc9P6XLgKuaQ9t8q6GXvA7MxEzdNOOEqsBmrc3Cu3ASdeMjy+F8bA6g8Pe1nMm5ImwieB7NTscw1gyFfNxuI/Nh3DtdEL/Ld2u2A3244n7okM7SMhT3IwuXVQdlsOlEMRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140730; c=relaxed/simple; bh=2HKvMexvKFoNQstf/71BaHmiEo2WU807DAkK3Kg+aE0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U0bNUqdXaPczQ1t1zrsVFjvhsppNmmcykKU2uLrllDKH4ivazTTJVXY3z8xJdXi629+yP8ZSc1jQiub/CcftNyUY8zjRI2WhY/OdEqXw5CRt23ageEJhzia9FD/W+9wLS+K6abcQoqetybg1VCJPpokIuLjFkapRFzCP05NiD8Q= 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=i+x4NZPS; arc=none smtp.client-ip=209.85.167.174 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i+x4NZPS" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3bbbc6e51d0so4269538b6e.3 for ; Wed, 28 Feb 2024 09:18:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709140726; x=1709745526; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=g7FdQ/F9u1vxZ6LbXnNQ7tOCZeaJWzRFvAytp5d8wUQ=; b=i+x4NZPSccU1VJyltzPjGJShFAHbqghcaX/qU+9O8fjLWXsiXn3wkg8dKfiKN2Mwi1 cZEiQfXClwy+nGWFb7Yr+v30dMnYfTyWzFZbZ+Dfba1++kpzNVh+x/MN+hW+i0Iq7ECn 9WGQ+7Q0ISfeEDKvvP8jNaG8CUifyMKr2QTqd82VXWQz7xh8K2LnGYVHq/3ENrcB9Pf0 HBl93ZDBT7eA6QpnZ597ExWZ6ajlrzuwF5wAluBebH7wqhxYbmp+j2MDDs9lLTAmZ/or pGyQCkf+NL0m7JVnXpF1QJ2E/YPkJR44PlrKGrdMhhpEp3wGFXp9b0l7latLeDM6xVDB lTUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709140726; x=1709745526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g7FdQ/F9u1vxZ6LbXnNQ7tOCZeaJWzRFvAytp5d8wUQ=; b=F714DBf7lBqoG88Q9lKZgM85guO75gt4mJCQ4KvVQjz0VX2j8l1SIzLlfQ4dYgH6mE PVpUrmO2S7VqVuBIQ+PQ8+UIIaTd8+9quUJkGhPjfUvkq2ZQJ6bnZMSWUxKvpJ+QHCEL 9m3h4OmcuGdafyOZmvlVp9iBxrlVGMybmnHPzGQsfK+tkeggNaMs+qdEQ7RxyGbopUmV GVOw5rbflbcGlGmr1e/x4xH2k36/qMplubKS/7UZ01jMVvfM6ntvGDvwbojWTGqwYay1 YBMViA5si0oORFvxhq9Yf3ou8vyN/vfodrUewaCi0av2Y6z9ugKIZwcLlY7q2j4zcvnB tB7Q== X-Gm-Message-State: AOJu0YxoFP8zywUit4/Cxxe/bCW7bN2uOzKIIQAnFqbkdRjDJumGFZhe lPETbxKteg1ZbbaJH/nRmhI5mtSyyyK6jBSmAUpzXlvMnmjEjLkJqZva6u6d X-Google-Smtp-Source: AGHT+IEX8FT6rkbXtq5cQlXggUUW9A+ZEBpSSWQZ1O2lhfbkLJk37om62pMj8+uFF0V9IhulVfcQIw== X-Received: by 2002:a05:6808:159d:b0:3c1:9519:1c19 with SMTP id t29-20020a056808159d00b003c195191c19mr6517641oiw.37.1709140726521; Wed, 28 Feb 2024 09:18:46 -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.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:18:44 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v1 4/4] Bluetooth: bnep: Fix out-of-bound access Date: Wed, 28 Feb 2024 12:18:38 -0500 Message-ID: <20240228171838.2414532-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240228171838.2414532-1-luiz.dentz@gmail.com> References: <20240228171838.2414532-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This fixes attempting to access past ethhdr.h_source, although it seems intentional to copy also the contents of h_proto this triggers out-of-bound access problems with the likes of static analyzer, so this instead just copy ETH_ALEN and then proceed to use put_unaligned to copy h_proto separetely. Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/bnep/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 5a6a49885ab6..a660c428e220 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -385,7 +385,8 @@ static int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb) case BNEP_COMPRESSED_DST_ONLY: __skb_put_data(nskb, skb_mac_header(skb), ETH_ALEN); - __skb_put_data(nskb, s->eh.h_source, ETH_ALEN + 2); + __skb_put_data(nskb, s->eh.h_source, ETH_ALEN); + put_unaligned(s->eh.h_proto, (__be16 *)__skb_put(nskb, 2)); break; case BNEP_GENERAL: