Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4663920rwb; Tue, 17 Jan 2023 04:02:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXtaq948kX/lTkUIILS4OOQQ69CgcjAggxYqHx50d6j8waxmD63oA8Kgb7NswJHlUs26PLto X-Received: by 2002:aa7:cfd6:0:b0:461:b8bf:ce1b with SMTP id r22-20020aa7cfd6000000b00461b8bfce1bmr16034357edy.34.1673956964257; Tue, 17 Jan 2023 04:02:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673956964; cv=none; d=google.com; s=arc-20160816; b=IIz9rFfEglFwHG3puDxizo6S/Hj6iWLuX7ItlgMZvRzKZ/Q6JwUTrXlIKtHh1wWcdE vMOCwr6KjpBuuBZi+Ii1unr/BxTFdYEtZYoxu1kJ2huOlhl+wsS7PtoDxHT48O7dcXtD +eAMLcyT7cHhcgoEQhdDNW4KNqBrPR+FUHyu4vjyloquRXllNPx9WYNaEc1BJRgVfuxu Ql890ousHJVQv7HpCsDX2U8AgkmYjaVgca0M85UsepILAdTvEnj6iQXxoAKQ+7V1atXq o5lhR5/J2jU6g2DEkYDATXkq54IPnvbJgyJml8mSIBlYAa6g+P43gXuKgHakI/nq2n7P m2XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:user-agent:cc:to:references :in-reply-to:from:subject:content-transfer-encoding:mime-version :dkim-signature; bh=pHaFkwysUCADh9a2MKsBgACeq4LTb0zJO96bYVBMmbk=; b=ipIMvzLX5akqeycHGL7mf+1XDbKqxKsXpJWsWAVw70ECqjRntNlrKFpBrYPbQ3vgkH GXP898l2+beDmhR0u4qdy/uNwTuI5P29PKnvIbGb6WCX1bDzNa/MbeUTAGxtnc3ajarI d14iz6S8dPY9nhsGdeFsbL3UJrgzNSiwvxNsd7GdDihFUFb9reh4ZlwsEL6owIZGBAvL E+lOXvmNMRAIsU21kET/K71AcJNr9r5QJSPRPjI2AT4cf25NKyu7Fij9OoOMvuHuRZ2V Nqdma+mvNDzWgcqijlDARkazNfxw1RGD/pRVq861IARBhrhltBNswRd6cmLIBZiXIXiY UKKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m4zzAj9O; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb6-20020a0564020d0600b0046dbf1fd79csi40069370edb.612.2023.01.17.04.02.32; Tue, 17 Jan 2023 04:02:44 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=m4zzAj9O; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236932AbjAQLyO (ORCPT + 48 others); Tue, 17 Jan 2023 06:54:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236919AbjAQLyF (ORCPT ); Tue, 17 Jan 2023 06:54:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6993C3609B; Tue, 17 Jan 2023 03:54:04 -0800 (PST) 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 A9F51612ED; Tue, 17 Jan 2023 11:54:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1820C433EF; Tue, 17 Jan 2023 11:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673956443; bh=iES5WuSh2BX4eOE4bMY9bqndaB6ME85FZx8qtHTXm/Q=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=m4zzAj9OXqabVPimStr8Y0eqTEDSJE5iPcTipqilIyslW/mxyaCuDYcLc1P0CnE1E 99y9IrfL8k90zxGwZc+A/34Kjms0+cIdmPFmZEj6XRefLHVhMIJAeVUpOBHcSpO96z IQwIXxmkQoWyselLRPyWLnEQsjXencLkriRhvw/QqFnueugN/RLY4ZhS+sQtzOiJjk p07EBPLMyB1MkBYIwyX7+ebSEdNcDzutpOB6LOAaHjoPV82qdCVzajzh6wWCYTsgQs Novkp/mFuIZbJIjCVbNBTUAW6w3xWvXxqkZWfG6S46DcpfZgIllv01s94AxwyjjSxF aBXeqxwyUe6oA== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [PATCH v3] wifi: ath9k: hif_usb: clean up skbs if ath9k_hif_usb_rx_stream() fails From: Kalle Valo In-Reply-To: <20230104123615.51511-1-pchelkin@ispras.ru> References: <20230104123615.51511-1-pchelkin@ispras.ru> To: Fedor Pchelkin Cc: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Fedor Pchelkin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zekun Shen , Joe Perches , "John W. Linville" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, syzbot+e9632e3eb038d93d6bc6@syzkaller.appspotmail.com User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.7.3 Message-ID: <167395643773.22891.16285001709469402107.kvalo@kernel.org> Date: Tue, 17 Jan 2023 11:53:59 +0000 (UTC) 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 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 Fedor Pchelkin wrote: > Syzkaller detected a memory leak of skbs in ath9k_hif_usb_rx_stream(). > While processing skbs in ath9k_hif_usb_rx_stream(), the already allocated > skbs in skb_pool are not freed if ath9k_hif_usb_rx_stream() fails. If we > have an incorrect pkt_len or pkt_tag, the input skb is considered invalid > and dropped. All the associated packets already in skb_pool should be > dropped and freed. Added a comment describing this issue. > > The patch also makes remain_skb NULL after being processed so that it > cannot be referenced after potential free. The initialization of hif_dev > fields which are associated with remain_skb (rx_remain_len, > rx_transfer_len and rx_pad_len) is moved after a new remain_skb is > allocated. > > Found by Linux Verification Center (linuxtesting.org) with Syzkaller. > > Fixes: 6ce708f54cc8 ("ath9k: Fix out-of-bound memcpy in ath9k_hif_usb_rx_stream") > Fixes: 44b23b488d44 ("ath9k: hif_usb: Reduce indent 1 column") > Reported-by: syzbot+e9632e3eb038d93d6bc6@syzkaller.appspotmail.com > Signed-off-by: Fedor Pchelkin > Signed-off-by: Alexey Khoroshilov > Acked-by: Toke Høiland-Jørgensen > Signed-off-by: Kalle Valo Patch applied to ath-next branch of ath.git, thanks. 0af54343a762 wifi: ath9k: hif_usb: clean up skbs if ath9k_hif_usb_rx_stream() fails -- https://patchwork.kernel.org/project/linux-wireless/patch/20230104123615.51511-1-pchelkin@ispras.ru/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches