From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9062BC432BE for ; Fri, 30 Jul 2021 06:06:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4935061042 for ; Fri, 30 Jul 2021 06:06:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4935061042 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A1F06F3D6; Fri, 30 Jul 2021 06:06:28 +0000 (UTC) Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6007C6F3D6 for ; Fri, 30 Jul 2021 06:06:27 +0000 (UTC) Received: by mail-pl1-x632.google.com with SMTP id u2so1556896plg.10 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=qhEHlGtM+Y5MovrpWoQZ8/6Ea3QhqP0fcvKvEnusT+iypk61afjOCzn50QExZUgW04 /BsgmR7wW0jf1yzzQ7iyxVCKJLhyCJ+Doj1RgHfsAkU49uNwBG/JiY3Gk7NdB4zp4EVl HatirAa+p5WrsT7FnqruYSiuK4hCBkeIP+GaWJsfOJKlegg56vIOfZYkxRyflAeghJex YZzHB9nQ1cFZpdMFPwaYSHVfymIpNQIkGfIrxNcMDtvHW6nFbTDZulcWtLjXDbFJUCGj UE/iJj/L/QWADDNf/Yjz235W/bd7WAuSDRiJHd7wz2EJK27ENEhFhkvenfwBCSa9+379 t2sg== X-Gm-Message-State: AOAM530YzWk1GYc8vvBysAl58mUIgjODIUF6xA7/6dyGqQamvTxTCZzu HbFN/OoHV9a57Mcsz8EO6tBPdQ== X-Google-Smtp-Source: ABdhPJzeUonVBgQ9NzzIA7kKbTvq5SBrLVxVHXebCyU1ipbT+iV0p67058qXEDQM1C04AViV+Ahtag== 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> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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