Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6687627pxv; Thu, 29 Jul 2021 23:06:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKqBhsSrvAY6j8BqagYLA1Tl3W1M6YR/H7qZSK5lt0zIPkyGMIBkJt/hQL21RICXpKyqjn X-Received: by 2002:a92:b308:: with SMTP id p8mr748323ilh.296.1627625207282; Thu, 29 Jul 2021 23:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627625207; cv=none; d=google.com; s=arc-20160816; b=ggLqv/iFO83Onx5L8KFwx+4k2IhzZ1fXeehm3hspgkOiChiyNetxhb8iLEmNDvVyBP +BM0Xhj+0LQcqVP7kqnDKYDYLmQCUneiU0vVqfo+sDw/ms7kDklDobEAZWQUDHzNIcmH az4weenhRGkCuAB3QNXW8Dg4iuhJZ8lHxuwjEKljT+GBOMy4mq3tmjjNouuRYFpwHaqv XVS6eslpIJDehqeGU1idCcjkjNavQQXsksv1+F3p4r5jjMSNiu7NCtEvmtdYJdLAi/08 dAAgfxD85WYusEjSKtuOUmwgO3Jqx1cbYrCt4V+48kKq7CvM78V9nmVthOYdMADCr5US Lhbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=IesK2FI21HpbnxZx4yJeBJ/OA9fhmSX4VPo4yVAWFag=; b=pVTYXTkhWPleAQ8PiEkqTh2D2ZDx3x1/4JnAVmTCxE8YplDUB5s0z3linm2wge4F4h lIrVL4oXjjZoX5h+NrecSvkzZj+i0xUyTY3VWkB5miau+aGG8MeM3z2FtSi7O87Np43R 3eIg0XQP2Jgl5wls4dyHAceRe0K00GtqCjX2PW6xRYfzRsdwAt7/2bjaB7siiHcT1vVe FnNvc/i4PPEUp0mm9JwDS5tR6xtHKayixaTQF8zA+QO3CrQ9P42uaMlHws7QqwfKwy0f aUHl4sa85GQKydQSM6BJTlkyageHb+FGxWb5KVvRgLxqxIGQJNObkyHyD1Lb+GQamZ5g pZqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lIobNunj; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n19si736191iop.0.2021.07.29.23.06.35; Thu, 29 Jul 2021 23:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lIobNunj; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236982AbhG3GGc (ORCPT + 99 others); Fri, 30 Jul 2021 02:06:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236430AbhG3GGb (ORCPT ); Fri, 30 Jul 2021 02:06:31 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 870C3C061796 for ; Thu, 29 Jul 2021 23:06:27 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d1so9859384pll.1 for ; Thu, 29 Jul 2021 23:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IesK2FI21HpbnxZx4yJeBJ/OA9fhmSX4VPo4yVAWFag=; b=lIobNunjbYmru1ujEnR+ElRxW3RY7/BL+bzrtIaGaicjd6cYbzyNY1lVt/hEDV779F ZbrOHXHwsPMJf6lzaIv/KY1TAEbtjPhi+LJR8ecSGlZrEWDd72yogtD/8w5N5E0J8E/9 4yNGD3XauminhdNf7u1HJO8GfDs+8YlWTPmfI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IesK2FI21HpbnxZx4yJeBJ/OA9fhmSX4VPo4yVAWFag=; b=rC+RlklZHiy+ag3XkN3H88/HCgErcT7Seiq9SrmwCgkwcElq6yNTgYupH9MtN5wJ0J MTbCrU2VDA5ithbdPJgdzdd2T7qhpBt0k5waw1hfe3xCYkxaBxOBblHCZV+F0F6BF1Uh haXpncn2c0okrdPa8CnMxQZwMHGofWM2CCWvfwPiV6+GFY2abz0ijfi+NpSSwORkzgjM xkOFzcrZJIXR44NEPFQCrkBrndPmA3bRAug4ieZswTQBTLdhP9ubY5Y4rjknVUihueQ8 8JNf9nzrC06SDWZnqrfs24HM0cLsyHAIIo66d8MeobKbUv06yt21u2rr8pmec73W+3j8 zBgw== X-Gm-Message-State: AOAM530tRItDT9kVOS/21mh7XDD7mYpgVfUUpGDUa3VxJgLab3sWrsSb LLvOADF3XXqdKlSeifeD9SPdmg== X-Received: by 2002:a17:902:aa89:b029:12c:17dc:43b0 with SMTP id d9-20020a170902aa89b029012c17dc43b0mr1167657plr.81.1627625186985; Thu, 29 Jul 2021 23:06:26 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id nl2sm714675pjb.10.2021.07.29.23.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 23:06:26 -0700 (PDT) Date: Thu, 29 Jul 2021 23:06:25 -0700 From: Kees Cook To: dsterba@suse.cz, Dan Carpenter , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" , Keith Packard , Greg Kroah-Hartman , Andrew Morton , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-staging@lists.linux.dev, linux-block@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH 02/64] mac80211: Use flex-array for radiotap header bitmap Message-ID: <202107292305.DB86BAC@keescook> References: <20210727205855.411487-1-keescook@chromium.org> <20210727205855.411487-3-keescook@chromium.org> <20210728073556.GP1931@kadam> <20210728092323.GW5047@twin.jikos.cz> <202107281454.F96505E15@keescook> <20210729104547.GT5047@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210729104547.GT5047@suse.cz> Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, Jul 29, 2021 at 12:45:47PM +0200, David Sterba wrote: > On Wed, Jul 28, 2021 at 02:54:52PM -0700, Kees Cook wrote: > > On Wed, Jul 28, 2021 at 11:23:23AM +0200, David Sterba wrote: > > > On Wed, Jul 28, 2021 at 10:35:56AM +0300, Dan Carpenter wrote: > > > > @@ -372,7 +372,7 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, > > > > ieee80211_calculate_rx_timestamp(local, status, > > > > mpdulen, 0), > > > > pos); > > > > - rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT); > > > > + rthdr->data.it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT); > > > > > > A drive-by comment, not related to the patchset, but rather the > > > ieee80211 driver itself. > > > > > > Shift expressions with (1 << NUMBER) can be subtly broken once the > > > NUMBER is 31 and the value gets silently cast to a 64bit type. It will > > > become 0xfffffffff80000000. > > > > > > I've checked the IEEE80211_RADIOTAP_* defintions if this is even remotely > > > possible and yes, IEEE80211_RADIOTAP_EXT == 31. Fortunatelly it seems to > > > be used with used with a 32bit types (eg. _bitmap_shifter) so there are > > > no surprises. > > > > > > The recommended practice is to always use unsigned types for shifts, so > > > "1U << ..." at least. > > > > Ah, good catch! I think just using BIT() is the right replacement here, > > yes? I suppose that should be a separate patch. > > I found definition of BIT in vdso/bits.h, that does not sound like a > standard header, besides that it shifts 1UL, that may not be necessary > everywhere. IIRC there were objections against using the macro at all. 3945ff37d2f4 ("linux/bits.h: Extract common header for vDSO") moved it there from linux/bits.h, and linux/bits.h now includes vdso/bits.h, so it is still ever-present. :) -- Kees Cook