From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 F394D18C36 for ; Tue, 14 May 2024 05:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715665798; cv=none; b=ENeOwfsHXkbwnw5w/IY8Bcou8K8DlRtPU1SBLrE7WGxp/oTzplcwt2ZeRdgiSPJ+iQZpaDQW5xR8IDtUwMktM1N4IFSo6+ATdTo2w55TKgZTgtjGBVJ+LOXf2m0lIdVdvwF8KqLx+7aeh99ftr243jz5YKPDy2UAILeHkOsXkNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715665798; c=relaxed/simple; bh=N7yQDXUwAdMII/0o6Jb7o7sMy9XOiB5X0F3FoWxeWrE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mYyfmQ/MSC++t91Ok48n0fy1pa5zJCjOO1p5c8GLJAsEjgyxXJAkCTVTXo7rdT50KLhc8+pzPf77owTKY9cU7dEXU7fgEsMU+UWxnbWqDRghv+dKb2vaWWSVh08klwcdjFGy0pFDsRm/z4kqtZS8evMqCF69TQtJVej8mi5bQFo= 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=b098mQF6; arc=none smtp.client-ip=209.85.210.171 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="b098mQF6" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6f447260f9dso4097940b3a.0 for ; Mon, 13 May 2024 22:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715665796; x=1716270596; 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=rk/9cCSuKPAzQ7d7k8DYOmgE1U27tp+avu7N/6VE0BI=; b=b098mQF6X9bHmfJOj2UMxXvYNCOYEBZ7lxcJloMkNOepgQOJE/fvCx5/jMqxkaF/Ye t9mmXKtCU4cLwUTnndJ/bvhsoq7dFNVbVqXewwDusQpQ0JVEqVdHc2GDUK5HWCc17s7O 0adQnUHRagfAp3L4ShnKjCCiuHsOJpZZUhSDY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715665796; x=1716270596; 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=rk/9cCSuKPAzQ7d7k8DYOmgE1U27tp+avu7N/6VE0BI=; b=S5XWF0nmP11q8gDXWg3Y/TX8XRnv2hIN7rslFjRfpD9nhcX5e2STyMGFhPFVYtZvif o5hv7iSM0B98ah3P/s9aA6cEHgs2SVOl3UMBDM3YC/gpVVR7+a6gfz+WyaBNPhoW6HU9 H/2tynN/6hUKxSu//b6wtmzG9iy7aby3DPZvM9an8QThCBuFxisSQLFZACqi8A+7pwxP ILbaD1NAbmRoLWzDFcqq6yWxN0QVBRWinIr4EkQihT24BIXC8nmK8ha8O6wMHq9qNsdO 8J5O5woQ/ZFroilf9BIy+syDBScQsKNeIvpWLrQm95HAsrIVKPFIohcdXO/7x/18isTD 9RGw== X-Forwarded-Encrypted: i=1; AJvYcCXl+2SpI5UanJyb2nPO05IVj9iNX8dK04/gBth++VqH2bar3JQhtmN2dJQSViwBrDsmTj0OiepNNhdoJKM7s2OAmsXVCzop X-Gm-Message-State: AOJu0YzJLjIGvA9KaQZBqZCH2Lt8VSMCPPkEcZ2pWPq22ZOwdDmKjtHX QrL0sU3uZKBqVuEizFjLUNNxaMbXp7ECcn1lVXur9zuHHS3Big8g7UW/lJO1Yw== X-Google-Smtp-Source: AGHT+IEPTKz5GyCkr08NrFCu81IdrD63NGlNxv736d9HhFlB58SSNTeMeE90nf4HCldQN4VyiI9ANQ== X-Received: by 2002:a05:6a00:2d8e:b0:6e6:946b:a983 with SMTP id d2e1a72fcca58-6f4e02ac8e1mr13440522b3a.10.1715665796214; Mon, 13 May 2024 22:49:56 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2ae0f7fsm8289079b3a.120.2024.05.13.22.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 22:49:55 -0700 (PDT) Date: Mon, 13 May 2024 22:49:54 -0700 From: Kees Cook To: Sam James Cc: chunkeey@gmail.com, chunkeey@googlemail.com, davem@davemloft.net, edumazet@google.com, helmut.schaa@googlemail.com, johannes@sipsolutions.net, kernel@quicinc.com, kuba@kernel.org, kvalo@kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, pkshih@realtek.com, quic_jjohnson@quicinc.com, stf_xl@wp.pl, toke@toke.dk Subject: Re: [PATCH v2 2/2] mac80211: Use flexible array in struct ieee80211_tim_ie Message-ID: <202405132245.017023A@keescook> References: <202308301529.AC90A9EF98@keescook> <87jzjxgfnt.fsf@gentoo.org> Precedence: bulk X-Mailing-List: netdev@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: <87jzjxgfnt.fsf@gentoo.org> On Tue, May 14, 2024 at 05:51:02AM +0100, Sam James wrote: > I think I've just hit this, unless it's been fixed since and it's just > similar. > > ``` > [ 291.051876] ================================================================================ > [ 291.051892] UBSAN: array-index-out-of-bounds in /var/tmp/portage/sys-kernel/gentoo-kernel-6.6.30/work/linux-6.6/include/linux/ieee80211.h:4455:28 > [ 291.051901] index 1 is out of range for type 'u8 [1]' > [ 291.051908] CPU: 2 PID: 627 Comm: kworker/2:3 Not tainted 6.6.30-gentoo-dist-hardened #1 > [ 291.051917] Hardware name: ASUSTeK COMPUTER INC. UX305FA/UX305FA, BIOS UX305FA.216 04/17/2019 > [ 291.051922] Workqueue: events cfg80211_wiphy_work [cfg80211] > [ 291.052082] Call Trace: > [ 291.052088] > [ 291.052096] dump_stack_lvl (lib/dump_stack.c:107) > [ 291.052114] __ubsan_handle_out_of_bounds (lib/ubsan.c:218 (discriminator 1) lib/ubsan.c:348 (discriminator 1)) > [ 291.052130] ieee80211_rx_mgmt_beacon (include/linux/ieee80211.h:4455 net/mac80211/mlme.c:6047) mac80211 This looks like it's this line in ieee80211_rx_mgmt_beacon(): ieee80211_check_tim(elems->tim, elems->tim_len, vif_cfg->aid)) { which is: static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim, u8 tim_len, u16 aid) { ... return !!(tim->virtual_map[index] & mask); ^^^^^^^^^^^^^^^^^^^^^^^ } UBSAN says it's because the array is defined as "virtual_map[1]": struct ieee80211_tim_ie { u8 dtim_count; u8 dtim_period; u8 bitmap_ctrl; /* variable size: 1 - 251 bytes */ u8 virtual_map[1]; } __packed; This was fixed in commit 2ae5c9248e06 ("wifi: mac80211: Use flexible array in struct ieee80211_tim_ie") which was part of the v6.7 release. > (It was a fun mini-adventure to get the trace usable and I should send > some patches to decode_stacktrace.sh, I think...) Please do! :) -- Kees Cook