Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1592042lqa; Mon, 29 Apr 2024 12:57:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8RUKWP5f8Y1kPppbRaGWbT9nDxkESBkxjRlYm0UAoAcn4WxrJfIgXGhU43Jl5H5JVs0WkdHyam0L1VlpJO7oSEomZEUpBWDp3E75Cmw== X-Google-Smtp-Source: AGHT+IEXUfrk898Bk+oIDFFwAoSKoEChjDpEgr0Ck8/uzrLic4VvPghKs+dIjXo2+Es1VVgv13/O X-Received: by 2002:a17:906:c188:b0:a58:bdfe:95a with SMTP id g8-20020a170906c18800b00a58bdfe095amr7750858ejz.26.1714420634650; Mon, 29 Apr 2024 12:57:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714420634; cv=pass; d=google.com; s=arc-20160816; b=ByQrM/6o9/9Wn0RusNaxNVEWrVWF8/ChUakIIbeUHFoSJ7mLfM2AhxpvXikIx64+Ki MpygDazmDAWOxSRQHFgII8NZZc08mlW4eRi4jp1HyXsUXpiVu/PtDUgEzOoIT9zcRbHi mPZtuiySg9dOWNcM/gfhB6GGLfLdhcngBQTtPBbO+H+/JrqkhdJhwhSSSnBKtwN/Vgw0 ql/CqiTzfF4XBhbW+54RjgkFTpUD5Wi83eRsWZZdGq9TSPK1hFtu5wGEfHT/5c3NlYzW obStgah8D4KaApzf21VXzwnWCdtomMT7brE4DYZhmjfnMlgwVCppuj1H0bRQLAk4wvaG lr9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wzh3iHAkozkq9gOCrjq5RtMClk8JbO8nQV/YvwV7pkc=; fh=wjk8fW+/YK59ffsGHu//M8OULHp0C/GmlHzMy2pST2o=; b=FYYg7Gsm51/RgS4O+kNrRkxt81GDnH4eO8jWu6Dq3yH/hhROOYJcY3C/nbSiM7TV2j zLc6AYxX3s5vGalGH+KXO8nbIpdx6++9M5cDiEhsdIre93cca6uLFKkQWD2emCiIr6L0 mCIKYo5gII2a15RD9qW+auZSgKc/80BmtEde8HijiCUnx4bgKe/OZ9FUwaZMeFMIrNvq HCNtYnwp6WrYr8P0aifTf8TsD8UOJr52l4t4XKgXl9cfEgBn9MzpuUKT1fma9UAhOPZq sDs36ezuZ1dVV+pNLf+Q36YTANOaMhvCrxc9OJS2qVloUs7aGVW+mbqswpqXWC+HuzF/ 0wlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JsvB94Cz; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4166-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qa30-20020a170907869e00b00a590d44d4e8si615416ejc.722.2024.04.29.12.57.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 12:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JsvB94Cz; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4166-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 61DF01F210B1 for ; Mon, 29 Apr 2024 19:57:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7786D1411CB; Mon, 29 Apr 2024 19:56:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="JsvB94Cz" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 64BD913B588 for ; Mon, 29 Apr 2024 19:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714420618; cv=none; b=mTAxJnYKkO7pblSoSD6eJg51xxrnokm/9Uq6wVX6hchkAJEDM54T36dT38iOi/C/OLCtVEXdqMqwftP6MdUlV5BrfEmAk7ohCQopaZG20lRk/fBUjmkvJP6d4uofiHEG2EawY/Xfd31rGRTAPwAREYC4t6hWTsKylm7C5I9+2Fc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714420618; c=relaxed/simple; bh=Oz/47XesLfkXt3OtQ8v9MvqsWPB9C7AkbnLE6S4xd+0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VB6RXPce9qW0sLqlvkIsmKETdF06EQU5KgfUx7Q29s+K7YZn80TBt8pCuZvH4aQU4ZvraY/WX33giUUwgXz6jCYdUczZbDZsPDrZDlQDq2gk2Fs6GW+mKNTTthiv3uxN9vOzDe/m0hpADNIzUZsm8YmiViM/tmuI8RJXXDZVzK0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=JsvB94Cz; arc=none smtp.client-ip=209.85.161.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5aa17c29ba0so3367612eaf.3 for ; Mon, 29 Apr 2024 12:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714420615; x=1715025415; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=wzh3iHAkozkq9gOCrjq5RtMClk8JbO8nQV/YvwV7pkc=; b=JsvB94Cz6WnIh1RlkEGNxgEezpzne+ubUr/OV9Vpk062DbWJ3hkngLFckDrVlw/WVm ubDQpwitE4Mcg2Vq8pD5ukDd8G6G4Esz5Ujb/ElSJ5NO+4FZ74gnm//727RV4lVNercC MB9hVtr5/RiqrZz15WqE5FHZmnFGXXvEyjquY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714420615; x=1715025415; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wzh3iHAkozkq9gOCrjq5RtMClk8JbO8nQV/YvwV7pkc=; b=cmQwXPw0swu5oReKn7IehIOmu1LrUpXsmZS+VyVBJXwC4hnhzCpdLZGSGO8fUPqUJ7 Jh3hOVlYth4D6PqMc4jMVpTPimL279pp8xROMMVMHfSfGimrKpGRudXwTTFM9pfBECL1 w5dsT6M7TgKky0JR7rTbYaswdTa6D6eqWjlRnAkiWynmL439Nzf8R8osOF0zbvw3lmER RbK4FCo1ZkSlVZt3hhasYypFAoM6SdGvoC1Iw/1DatUo6Z8m8aWfnyq9aq05BHHmDC/Z H4YB8DlNN7Gx8pSbXQpL6CYSH63NfML0qTwgPGuyWDS7Pl4qkXOEZWH0AG7Q3//NYu5y Z7yQ== X-Forwarded-Encrypted: i=1; AJvYcCVsGRa3QFlN9RO8S8l9VO1SqwTEvybb3cgUX7sk/bpK1dhGwcgYqZzoA3qn8BphTvjGU1kaMkFLMvbtozhoKnHOdLgAXyNymviXVoTzVyU6 X-Gm-Message-State: AOJu0YwEsnjrDGc8MVpH69sLK+0UE37cvDvJS8Cg+5Dsai8mKU9IQOtS lGsU5hz+ZzNzAfFj08teutxQXl/5bTduTwQvGq6cs68Kc0gj9lu3MxQq/+6sLw== X-Received: by 2002:a05:6358:3916:b0:18a:62fd:b874 with SMTP id y22-20020a056358391600b0018a62fdb874mr11846383rwd.17.1714420615575; Mon, 29 Apr 2024 12:56:55 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id f13-20020a63380d000000b00615707f8078sm723421pga.17.2024.04.29.12.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 12:56:55 -0700 (PDT) Date: Mon, 29 Apr 2024 12:56:54 -0700 From: Kees Cook To: "Gustavo A. R. Silva" Cc: "Gustavo A. R. Silva" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2][next] Bluetooth: hci_conn, hci_sync: Use __counted_by() in multiple structs and avoid -Wfamnae warnings Message-ID: <202404291253.106D020@keescook> References: <202404291110.6159F7EA5@keescook> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Apr 29, 2024 at 01:50:46PM -0600, Gustavo A. R. Silva wrote: > > > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h > > > index fe23e862921d..c4c6b8810701 100644 > > > --- a/include/net/bluetooth/hci.h > > > +++ b/include/net/bluetooth/hci.h > > > @@ -2026,7 +2026,7 @@ struct hci_cp_le_set_ext_adv_data { > > > __u8 operation; > > > __u8 frag_pref; > > > __u8 length; > > > - __u8 data[]; > > > + __u8 data[] __counted_by(length); > > > } __packed; > > > > I noticed some of the other structs here aren't flexible arrays, so it > > made me go take a look at these ones. I see that the only user of struct > > hci_cp_le_set_ext_adv_data uses a fixed-size array: > > > > struct { > > struct hci_cp_le_set_ext_adv_data cp; > > u8 data[HCI_MAX_EXT_AD_LENGTH]; > > } pdu; > > > > Let's just change this from a flex array to a fixed-size array? > > mmh... not sure about this. It would basically mean reverting this commit: > > c9ed0a707730 ("Bluetooth: Fix Set Extended (Scan Response) Data") That change doesn't seem to need to make them flex arrays, though -- there's no savings at all (the same amount is stack allocated). Anyway, not a big deal, I guess. It's an improvement to be using __counted_by, so good! :) Reviewed-by: Kees Cook -- Kees Cook