Received: by 2002:a05:7208:13ca:b0:7f:395a:35b6 with SMTP id r10csp21242rbe; Wed, 28 Feb 2024 09:19:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpmSefC2TPuGa58TxP4am8nHhlry5es0HJQ/NZx8GmpEUS1ze+ZZqOIMaCYTz7jXxUSXsqZCT7g1u+Pq3/ZxcNySK/GjP5LclWk9AyUQ== X-Google-Smtp-Source: AGHT+IFXI7vJ0IYxLY9Htv/wfMGIGpWGDfVx9iOWvvqJRC9sZAtoadKhjP/EXGRq0WmKCgeOoFs0 X-Received: by 2002:a05:6214:20ec:b0:68f:301b:5482 with SMTP id 12-20020a05621420ec00b0068f301b5482mr6744111qvk.8.1709140759497; Wed, 28 Feb 2024 09:19:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709140759; cv=pass; d=google.com; s=arc-20160816; b=jJHZ4n/1Bgfv0Yk+gOxyQeOkEW/S1dvrSFJwBVkU4E4a4C/NXlI5bYUAf5Ab6DTT4P DlKm7cI3v473AjMSi+LJT8ZwEoqN8DoLfnm5t5TJtmh3zASY++yoKE0oUaMMjL7AX+as Y1I3ZZD+tOFwnxJSG+69noI4p1NZX3W1PQMqkVoVE2ObS31V+TVEgZa34Jcih70wdgJK NPyNixKlAkcpWQw/m8gfUHTikkBwwz7mGZ6iKyNqpJAgnmeKvE3ScFE2n/pLzbZy8/x1 GWtnMAwXf1tqW5kLZp4Og4n7kDK0klfUM5xFAjtqCJCQ4+XZeyjTaDqQgDUHbkZZRg7e tKLw== 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:to:from:dkim-signature; bh=g7FdQ/F9u1vxZ6LbXnNQ7tOCZeaJWzRFvAytp5d8wUQ=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=iDA0Yzp/7ATZha+UXKwwV7EDyD7l1+gY1HNVXrHJO9Sl3JXivJOOXN4eVUku+mESTw gOCqAvOmaZKvu/wK8WOK86LytJnXyLea1Z3eMFMMP+E5f/hGdz/qathFkLtGK19MyUmQ ZeDzDqdHOs/F43s4HD31KF6/evpLfKMpMXIDkClVlUkqmjNpqHAzsThu0Pr5kasCefMR P6U6JB/OU1+QNQJlFJ4b8CzQbMOwWMBeHLU6ib9EgDzP45DGCPS+cKv2OVz/N0BxBKWV zB3+auBeyfME7i6WoRH5FNDE+H05NE/v1qOEUzpqGuFOMs8RPHJ6HxbTQyrR0GErQ3SV d/Jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i+x4NZPS; 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-2193-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2193-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 e8-20020a0562140d8800b0068fbd79c519si10009737qve.373.2024.02.28.09.19.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:19:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2193-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=i+x4NZPS; 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-2193-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2193-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 434C81C23709 for ; Wed, 28 Feb 2024 17:19:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A5273FBAA; Wed, 28 Feb 2024 17:18:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i+x4NZPS" X-Original-To: linux-bluetooth@vger.kernel.org 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 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-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 Content-Transfer-Encoding: 8bit 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: -- 2.43.0