Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2143279rda; Tue, 24 Oct 2023 13:49:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/gF3VpeluZ/2Gjyh51eSQ1r5XFvbWwLOQ9tt65IcI2B3IAw9LUYG3Uz4Cz86sL19GLyZC X-Received: by 2002:a17:902:7d8e:b0:1bc:7001:6e62 with SMTP id a14-20020a1709027d8e00b001bc70016e62mr9685863plm.35.1698180592674; Tue, 24 Oct 2023 13:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698180592; cv=none; d=google.com; s=arc-20160816; b=yQnX8b+6gfuDreX58I5csDKFAZmWKgGMK3AMwB651bK/IVlTVzVm7ugoNbajdBawGf 1pFjU897F8cfdyJaNZMf/WGo5Oe5bv7VpY0fXlcpE7n66D3WrLYdLv+M6D7yCR1H8p/z c8OVzRiqjlMt2pi3skwVNUHDX87HZr1XpWZMq/40MHF7KJV/SNsx86hr8FDIne0X9P+5 ma/KBy7T3Rqjh+FNqwfqLmHFqdcXLVWc0mvnbTRPqEIevkOpO8V2D80VSPP/Jxu1XcUg givj9l5UybdCslL5Ga/5n5nbINGGwwrxp08erImkUeKd4QFtHEd5/hDo17u9PPs0kZt9 SlFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=n1hoWu1QQf0mXz91DzUGE4OYJa5WmwrJOSpDXP5IzqI=; fh=E6KwE/YkKVDwjSNB2hYCLG8ZIk3KpZ/KRyrtgKZSq4E=; b=0xdiCtJ8PzgWx5S4TioAoZ7c645KpxSFFolukS2JsdjQdMpqr8igYg1YD04pJ/DIO8 Bu8wDdoXyH3flfqWvFHSLoXKWMckgUWAVMx+bZYgAtrguMhY7WxXPlicc7ydt19eXf3R uq4c/uWrCzk7DisJXgNkeHMJqS9cgtYK1Ye3doHENM9Csb1jjQgPb1PTUGuK6/3k06T3 ald+RDTFTU4gVuOfQjtUnEju5wPFdu9UVfAc5AJ/qKxb4mVSMGJVifl3hzD31iQNv1D3 ZjPMYGUxofEZPcA5vUtM+t4LAV77F0BDFo5D+TV0FstNRaIp7Vbpl6tDEtvU8zCjXm9k P5Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=bWzwrTaY; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l5-20020a170902f68500b001c3a05b0b58si8893520plg.500.2023.10.24.13.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 13:49:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=bWzwrTaY; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 53FEB807C5FF; Tue, 24 Oct 2023 13:49:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344129AbjJXUtk (ORCPT + 52 others); Tue, 24 Oct 2023 16:49:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbjJXUtj (ORCPT ); Tue, 24 Oct 2023 16:49:39 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:242:246e::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DBD910CE; Tue, 24 Oct 2023 13:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=n1hoWu1QQf0mXz91DzUGE4OYJa5WmwrJOSpDXP5IzqI=; t=1698180576; x=1699390176; b=bWzwrTaYFO871kF17LNz7WP+SIeLlMVRtFbrMa5YBbdPF8R 2LJ0r4gIxXgLE6ndCjhpYXYg5MU+PsVOUiHfu4geyi8kNHXYMTO+scODdYP5Qtv+FNzSQcYarMOEf xncewFLOf33lDoy9LZd7qOtrc5JF1LGVMugShLfZm2JI/42NLn5/r0QpcPa79V+wKIiGQHhC4otQJ UAEkoLQxYGOW8L2ctWNa7YxnFZHPz4d82b4sfa3EmqPt1t+IiVI8WGfrLpdtXodtZAmSR8eMphr3q kXtIvhXVzZ3LuBQSLYxWw4SspZCFcoZAQj2Fxk9YyjQNxA5DZVlZyeniGeiv67DQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97-RC1) (envelope-from ) id 1qvOLC-00000001bbh-1i2d; Tue, 24 Oct 2023 22:49:30 +0200 Message-ID: Subject: Re: [RFC - is this a bug?] wifi: ath10k: Asking for some light on this, please :) From: Johannes Berg To: "Gustavo A. R. Silva" , Kalle Valo , Jeff Johnson Cc: ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Date: Tue, 24 Oct 2023 22:49:29 +0200 In-Reply-To: <07e9bb04-f9fc-46d5-bfb9-a00a63a707c0@embeddedor.com> References: <626ae2e7-66f8-423b-b17f-e75c1a6d29b3@embeddedor.com> <26b15f4702cef17fe70b496a62f03735874bd16a.camel@sipsolutions.net> <07e9bb04-f9fc-46d5-bfb9-a00a63a707c0@embeddedor.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-malware-bazaar: not-scanned X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 13:49:50 -0700 (PDT) On Tue, 2023-10-24 at 14:41 -0600, Gustavo A. R. Silva wrote: >=20 > It seems we run into the same issue in the function below, even in the > case this `memset()` is unnecessary (which it seems it's not): >=20 > 8920 memset(skb->data, 0, sizeof(*cmd)); >=20 > Notice that if `cap->peer_chan_len =3D=3D 0` or `cap->peer_chan_len =3D= =3D 1`, > in the original code, we have `len =3D=3D sizeof(*cmd) =3D=3D 128`: Right. > - /* tdls peer update cmd has place holder for one channel*/ > - chan_len =3D cap->peer_chan_len ? (cap->peer_chan_len - 1) : 0; > - > - len =3D sizeof(*cmd) + chan_len * sizeof(*chan); > + len =3D struct_size(cmd, peer_capab.peer_chan_list, cap->peer_cha= n_len); >=20 > skb =3D ath10k_wmi_alloc_skb(ar, len); > if (!skb) >=20 > which makes `round_len =3D=3D roundup(len, 4) =3D=3D struct_size(cmd,...,= ...) =3D=3D 104` > when `cap->peer_chan_len =3D=3D 0` And yeah, that's really the issue, it only matters for =3D=3D0. For a momen= t there I thought that doesn't even make sense, but it looks like it never even becomes non-zero. No idea then, sorry. You'd hope firmware doesn't care about the actual message size if the inner data says "0 entries", but who knows? And how many firmware versions are there? :) So I guess you'd want to stay compatible, even if it means having a chan_len =3D min(cap->peer_chan_len, 1); for the struct_size()? johannes