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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4772C4332F for ; Mon, 18 Oct 2021 13:10:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 969346103C for ; Mon, 18 Oct 2021 13:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbhJRNM7 (ORCPT ); Mon, 18 Oct 2021 09:12:59 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:32303 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbhJRNM7 (ORCPT ); Mon, 18 Oct 2021 09:12:59 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1634562648; h=Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=2iZh5xPrIPUDbVFXGh7W2cb2/hGVEE7gEkCaxI5tQ2Y=; b=hS0uANKZd4oOmh+Y5BBJF6ajbSr55BRRE7Fr+Ts5qqjShvRa07xCCvuICypnpVJS0Ax2hoSY dVgkIy7ETwf3DJjrucHt2waCyeZxZy74Ynn66G++wmrha2H+PLvHpkM4zOYg3Rk9r36LkSJ3 drnukEVCAnkP19jCd0qQ70+RI80= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-east-1.postgun.com with SMTP id 616d72490605239689a079b0 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 18 Oct 2021 13:10:33 GMT Sender: kvalo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id AAA0BC4361C; Mon, 18 Oct 2021 13:10:32 +0000 (UTC) Received: from tykki (tynnyri.adurom.net [51.15.11.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id D04D4C4338F; Mon, 18 Oct 2021 13:10:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org D04D4C4338F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org From: Kalle Valo To: Arnd Bergmann Cc: Alagu Sankar , Arnd Bergmann , "David S. Miller" , Jakub Kicinski , Brian Norris , Wen Gong , Tamizh Chelvam , Carl Huang , Miaoqing Pan , Ben Greear , Erik Stromdahl , Fabio Estevam , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ath10k: fix invalid dma_addr_t token assignment References: <20211014075153.3655910-1-arnd@kernel.org> Date: Mon, 18 Oct 2021 16:10:21 +0300 In-Reply-To: <20211014075153.3655910-1-arnd@kernel.org> (Arnd Bergmann's message of "Thu, 14 Oct 2021 09:51:15 +0200") Message-ID: <87fssytr5u.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Arnd Bergmann writes: > From: Arnd Bergmann > > Using a kernel pointer in place of a dma_addr_t token can > lead to undefined behavior if that makes it into cache > management functions. The compiler caught one such attempt > in a cast: > > drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_add_interface': > drivers/net/wireless/ath/ath10k/mac.c:5586:47: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] > 5586 | arvif->beacon_paddr = (dma_addr_t)arvif->beacon_buf; > | ^ > > Looking through how this gets used down the way, I'm fairly > sure that beacon_paddr is never accessed again for ATH10K_DEV_TYPE_HL > devices, and if it was accessed, that would be a bug. That's my understanding as well. beacon_paddr is only accessed in ath10k_wmi_event_host_swba() and only low latency (ATH10K_DEV_TYPE_LL) should use that function. > Change the assignment to use a known-invalid address token > instead, which avoids the warning and makes it easier to catch > bugs if it does end up getting used. > > Fixes: e263bdab9c0e ("ath10k: high latency fixes for beacon buffer") > Signed-off-by: Arnd Bergmann > --- > drivers/net/wireless/ath/ath10k/mac.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c > index 7ca68c81d9b6..c0e78eaa65f8 100644 > --- a/drivers/net/wireless/ath/ath10k/mac.c > +++ b/drivers/net/wireless/ath/ath10k/mac.c > @@ -5583,7 +5583,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, > if (ar->bus_param.dev_type == ATH10K_DEV_TYPE_HL) { > arvif->beacon_buf = kmalloc(IEEE80211_MAX_FRAME_LEN, > GFP_KERNEL); > - arvif->beacon_paddr = (dma_addr_t)arvif->beacon_buf; > + arvif->beacon_paddr = DMA_MAPPING_ERROR; In the pending branch I added a comment here: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=02a383c9bf959147a95c4efeaa4edf35c4450fac -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches