Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407917rwa; Tue, 23 Aug 2022 04:23:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR631ymh3x0AGs5lNxp4RB7FhX/qe3bz1kO0XTs7FGULL0mh9tF+SPdVumu6gfx6Byk7jVqy X-Received: by 2002:a63:4916:0:b0:427:d463:55e with SMTP id w22-20020a634916000000b00427d463055emr20735056pga.374.1661253821158; Tue, 23 Aug 2022 04:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253821; cv=none; d=google.com; s=arc-20160816; b=swv4uZz9mNrB6/xcckH7ehaL52GQZ1KhLPgwHG930fZEvzPwKYs5CVa2cBDI8owJI9 NgYCfpeR2YKtBfghEA15fjxbLq6N6OJsFpD4pUZLeid6gvQLvGkpl3URBBqoP/7Wku5G TcYj0TF5630aUreOdhEDOebzNOwGsLB9sFY1IRlggorswVpvdxH+a60O7LcwhqLm1Ncr JwwwTAuwPye8PsTfOG6WU5zO+ssK/UkhMQQL3jBKgt8vdyi0Nk/Gwv7OTtvaF2z7WEPg Ppj+MJg6I04T8QTTngV/tI4bvS6Mf9/UHf3mzfqK/fUgTWs7RHyHdbRg1Ny4eiyi7SVo RKrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LNw2CaPaYMdv0gKHNfz7S46Us8NVJ5rkS4aSwwZy5WQ=; b=ZuDV8rbSi+usz2Iz0/Q2cozpviUax8//hrSUgGcO6NB7Lo+ZTsa5izt+bVtTTMnRFE wNP5Y+BGw7Tow3ugK9OvttD+fzQg3e4bptpeULdDf2cBxxKVwOqMNWgqAtXN3uwMgYWQ L8/OC0f3/lLYtB/ZP5HEJzcdU9/QZvxDVxcxVpsPAWeW+rhdcGmlO1R513bpkySiQawO WF+0jm7dPsBZgolGDRIgU0Li4h5dDXTr51chnKZ4pmg7T0AQBfMcvES+jnv3PYmEHai3 +MxuTekmTPjTKx3mwhE+Br9f/Gj0vezRgDi0BluapVWnFAYOCS6edoyUpOkynQkEEnlJ 7FMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D3pcOf6z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a170903028900b0016ef2ee72b3si11362579plr.242.2022.08.23.04.23.28; Tue, 23 Aug 2022 04:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D3pcOf6z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354970AbiHWKeM (ORCPT + 99 others); Tue, 23 Aug 2022 06:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353653AbiHWKSG (ORCPT ); Tue, 23 Aug 2022 06:18:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3A0180EAD; Tue, 23 Aug 2022 02:01:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5401461530; Tue, 23 Aug 2022 09:01:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B20FC433D6; Tue, 23 Aug 2022 09:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245304; bh=1DV94zophLjpcEDGwBTmbdo/8rx+MYKlO0RwTEpo6bI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3pcOf6zoQkwOCCp0to2zO3s6H3T89sC2oPO1z++5Jl8TKYxkIWaDEk33M0mDcZrF 0X/2NXDFBLHfnhyqygP0Bx8I7vc+xIjj1EqfDOnCAPQIQgRWiRH1rKwgzU601eB/Sh RsadMJu0vFD81kwIhZNg1Zp3Jh7rfSRpNfNQCNqQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Jeongik Cha Subject: [PATCH 4.19 006/287] wifi: mac80211_hwsim: use 32-bit skb cookie Date: Tue, 23 Aug 2022 10:22:55 +0200 Message-Id: <20220823080100.475833180@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg commit cc5250cdb43d444061412df7fae72d2b4acbdf97 upstream. We won't really have enough skbs to need a 64-bit cookie, and on 32-bit platforms storing the 64-bit cookie into the void *rate_driver_data doesn't work anyway. Switch back to using just a 32-bit cookie and uintptr_t for the type to avoid compiler warnings about all this. Fixes: 4ee186fa7e40 ("wifi: mac80211_hwsim: fix race condition in pending packet") Signed-off-by: Johannes Berg Cc: Jeongik Cha Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/mac80211_hwsim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -552,7 +552,7 @@ struct mac80211_hwsim_data { bool ps_poll_pending; struct dentry *debugfs; - atomic64_t pending_cookie; + atomic_t pending_cookie; struct sk_buff_head pending; /* packets pending */ /* * Only radios in the same group can communicate together (the @@ -1067,7 +1067,7 @@ static void mac80211_hwsim_tx_frame_nl(s int i; struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES]; struct hwsim_tx_rate_flag tx_attempts_flags[IEEE80211_TX_MAX_RATES]; - u64 cookie; + uintptr_t cookie; if (data->ps != PS_DISABLED) hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); @@ -1136,7 +1136,7 @@ static void mac80211_hwsim_tx_frame_nl(s goto nla_put_failure; /* We create a cookie to identify this skb */ - cookie = (u64)atomic64_inc_return(&data->pending_cookie); + cookie = atomic_inc_return(&data->pending_cookie); info->rate_driver_data[0] = (void *)cookie; if (nla_put_u64_64bit(skb, HWSIM_ATTR_COOKIE, cookie, HWSIM_ATTR_PAD)) goto nla_put_failure; @@ -3146,10 +3146,10 @@ static int hwsim_tx_info_frame_received_ /* look for the skb matching the cookie passed back from user */ spin_lock_irqsave(&data2->pending.lock, flags); skb_queue_walk_safe(&data2->pending, skb, tmp) { - u64 skb_cookie; + uintptr_t skb_cookie; txi = IEEE80211_SKB_CB(skb); - skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; + skb_cookie = (uintptr_t)txi->rate_driver_data[0]; if (skb_cookie == ret_skb_cookie) { __skb_unlink(skb, &data2->pending);