Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2835312rwb; Sat, 8 Oct 2022 15:38:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5N4UTrC/HF4tASpoT/qZPv684UOVh/gvjAAo2GmN7Koq7eto8ZrUWaCokb1PuTMl9V7rKK X-Received: by 2002:a05:6402:278e:b0:45a:35dc:ebc8 with SMTP id b14-20020a056402278e00b0045a35dcebc8mr7596313ede.314.1665268685524; Sat, 08 Oct 2022 15:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665268685; cv=none; d=google.com; s=arc-20160816; b=Vw1iEqLamaqHHyeSyW8qpmUD/fEgQMXEXMnGWiR2+2IBprq3d6oV4IdqrcK3mWburi L6pDbu0VW7fd1vDUz3Hubuv9icany6aGkdM5G7rRvVQHRkkHp2D4cFD9GR9fr53SEHi2 LOlhEz6GxMh3Hkza/20eKwGc4uIaKANR8AbpZD41xQcvzy9A7r2K9MmbjeQl/1TyaL7J YbLGmlWjAFmcaG9jTIFOGYGS8Fr5mNvbMcoEm+4OMFgCXJMpd3DC7ScOAKFv0sEXH9cz F07cHHtzpPtVLOFpOz4PvFr/bJgLeWq+FrwVgfDCYaDez66g2b6xhxXuWYd07bS1GcSp VXuw== 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 :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :from; bh=UBsfIk1cg7jUe/HvO/iyiK7+egJdhm8BQh0pnKAGs5E=; b=QfxyLtWq3dbhb8Ft4czXj+TJSJXETvmhazl7HEUJ9ZDUmvcHwy36uA/T4ZpKxuYjj9 KepJQVY1KWFi4LSQx9vGwzmGOannVP7vkYtnzOHk/xyckkPWeYjB3A6Vv/e2c9NfbZ/n v5+9Og8Kd6huuJZD60nDSrMDzg7pgrRAmMNFtmXPiHZgaovY6AzEBS232CWpD8ZPQajQ 8Omwcb6N3rtz+9buSJhr5Fv304pmM7ZT0bAduVPNsVD0JsYfLrKzp1FCkQt+CAXJBDf3 2tb9AIn4qv/2jjBM0K00DoWYi2e/ORIN8n4mGupwhZtTGPBs1bUmLHBLPxPbS8MlBlFC 41cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=YqyQ0Omi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z26-20020aa7c65a000000b004599cb57915si5305321edr.112.2022.10.08.15.37.48; Sat, 08 Oct 2022 15:38:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@toke.dk header.s=20161023 header.b=YqyQ0Omi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229590AbiJHWgL (ORCPT + 61 others); Sat, 8 Oct 2022 18:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiJHWgL (ORCPT ); Sat, 8 Oct 2022 18:36:11 -0400 Received: from mail.toke.dk (mail.toke.dk [45.145.95.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4047E100E; Sat, 8 Oct 2022 15:36:08 -0700 (PDT) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1665268565; bh=UBsfIk1cg7jUe/HvO/iyiK7+egJdhm8BQh0pnKAGs5E=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=YqyQ0OmiGn9gsYcMYCYt4ZsBV5huzThrVCX01QS04vaAaf/NC7TJJXZIvcz1MranD 8+Sq4/PRR7B9MIx+jbhaYNPM6DzkvNpLU/TtzAMoRqhJBwLXymGHjx1/5YPkrdtpaC Dj/iKDnuhlc2VUxpbGsOjedQO7ZFz9eJ3FJBEMfQN+ad8tUXL2y/urtZXxYeEuHl2n h7dcvnfYcXv5rn04P0+ZatvVBLbpg938HCUVy6zyzwOZEmB3OBLD8zWoOaZqiVhbam G3ZHVHXZm05lxDqmLQIxMOW7SFv2sxDMdaQKVG/hI9jjzgBunJYUi62n3sao3uBMTL 5ghPMw85Ew44A== To: Fedor Pchelkin , Kalle Valo Cc: Fedor Pchelkin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: Re: [PATCH v2] ath9k: hif_usb: Fix use-after-free in ath9k_hif_usb_reg_in_cb() In-Reply-To: <20221008114917.21404-1-pchelkin@ispras.ru> References: <20221008114917.21404-1-pchelkin@ispras.ru> Date: Sun, 09 Oct 2022 00:36:05 +0200 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <87pmf2rlii.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-wireless@vger.kernel.org Fedor Pchelkin writes: > It is possible that skb is freed in ath9k_htc_rx_msg(), then > usb_submit_urb() fails and we try to free skb again. It causes > use-after-free bug. Moreover, if alloc_skb() fails, urb->context becomes > NULL but rx_buf is not freed and there can be a memory leak. > > The patch removes unnecessary nskb and makes skb processing more clear: it > is supposed that ath9k_htc_rx_msg() either frees old skb or passes its > managing to another callback function. > > Found by Linux Verification Center (linuxtesting.org) with Syzkaller. > > Fixes: 3deff76095c4 ("ath9k_htc: Increase URB count for REG_IN pipe") > Signed-off-by: Fedor Pchelkin > Signed-off-by: Alexey Khoroshilov Acked-by: Toke H=C3=B8iland-J=C3=B8rgensen