Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3403703ybb; Tue, 31 Mar 2020 04:40:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtGSH2J0pPFBS9HsG/0nWZuntD3AseXdRh/F+lv1HLwLfgtJQsq19F+BhnAI6UZM4aZOWfs X-Received: by 2002:a9d:837:: with SMTP id 52mr11923144oty.354.1585654842429; Tue, 31 Mar 2020 04:40:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585654842; cv=none; d=google.com; s=arc-20160816; b=lGlgPq3I2C4yA13N8BvQ4ijihXDc2CAEDttWdae5eD28U7weaeRPp19SA6buIiEo9Z mfYUwCC/RTmN87U3lugQByp9dt33ijvNigIAwRv9aXJYz4Gb8pQA9gQPtA+pYlRemA8W LWlGcLZWXQxzrKyKSH3XJ2/WUflr+Kd0LC/0mKuPk3JlMzpGEPyjKEkWp9X3yz9MQe1n XYf4caNMYABEamioyj1D8jbT8YE1NOWnaS1e1owL5Na3ogOR8vdGHS835+lmQ2bjUjAW lCTvSFwS1tb8jdzca953RP45FclS033NFVCLYxVWXHm1TgzGB3D/hBfrkCKiMq3nRKM+ rBRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GvfMZgwwya4ZSH2OS8e5IKouh92EbNGvwaXpIPfmMZU=; b=jweRpk4HpwgvY6bDsn0+qQ0tdORP0Q0vg8mU1RmDjcAvf2g1YhRXQk3AD785iabFb/ 8QVqlBjSWa8CVyMXUMSCEDSUNB034vIXxWV5ixHQSYsXp0y/h1SlZlkGGhJt1e5gG5lk HPb+43tvt1Lzoh0YRNtIaTY7lXdQDKLInaWqvU5E7hOViLCy8kjFRCskMOvG2/y03wev 6y8tJg9ioia0c8immJwTea+5DKrrnjx9OOeUEjhgfQzIhmvvUtBkdCYi8NARqdkmHsEj jWjvgt+Og23eZHuaOx/mKaXMWkCnTtYY11gCbmnJNEh7R/2wI9kipzDH4D15r2BUHYI3 J4tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HS3MXxUz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x64si6868309oig.34.2020.03.31.04.40.28; Tue, 31 Mar 2020 04:40:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HS3MXxUz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730561AbgCaLkK (ORCPT + 99 others); Tue, 31 Mar 2020 07:40:10 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:34490 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730343AbgCaLkK (ORCPT ); Tue, 31 Mar 2020 07:40:10 -0400 Received: by mail-io1-f66.google.com with SMTP id h131so21322731iof.1; Tue, 31 Mar 2020 04:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GvfMZgwwya4ZSH2OS8e5IKouh92EbNGvwaXpIPfmMZU=; b=HS3MXxUze51pqFaHc52OMaPkf+JHkR9fOcDmckzaIhHmhnG6RnivzmAx7X/1bSOW7W TXGjPqGU+CeKwCa9KP9JhXaNOngahNLeHUdjTKYEU+t+gQ8IdNiGf5ode1Wy7nMe5uF+ 41LboL1lOLWLZqPTsVX6AxSFLxYY8AtfPQla33L1MOLcI9Yv5U+riazFwhaoZvE45dCY ICXrPXX0mpGK+r4dPIh9Y2i4onsrVUIY9vTsvhTpaWbI6ciOnL1jF6Wrme2dCsW2THEp a4cf57cgiJpybFo/ihMtVg7qOU2gMZZT696Dm5dBxbpX7tz+BBsLUkJpcdjI0d1Hjog9 qpiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GvfMZgwwya4ZSH2OS8e5IKouh92EbNGvwaXpIPfmMZU=; b=QiUYWDgq/me77eGel8HsZRzStH2GROMyprkFl8brXHIwWmwmJAuscFzaMzXU2LqbyN MyDpLP2bEK+scIAK9h9C+OxPXB/m+XSlgHLCsNYcEqjRgBEymoKs3+SrMkssKs/Qw2zA +4ETx9cx2us1hBR741WYBGVxpmF5sJP/dSTm3LpEcb/PzzFOHwxHiuAtxV3FZZMhMTt9 9mzIyBYw6oi7lffCzUMBNFeiwS7ZPkjKsGr3pMvJ4xblb2aUlrOAgXQ0Tr7HEGvIVhLt ze8PWy1ndkdb95U8QCFtX/NuvjWn3NlfqkpVS8GGgybDEsbvQcc34DyCbbUiqsmsgYoY S8bA== X-Gm-Message-State: ANhLgQ2fX+z5yGsWml7LbAQSq5NXTw7TxZfiU82KX05BdtBuEt3tE+AL 9+W8/KClkCi7JicdCK2MXsuMPT2IWVgEO2dvFuw= X-Received: by 2002:a5d:984b:: with SMTP id p11mr1163615ios.175.1585654808716; Tue, 31 Mar 2020 04:40:08 -0700 (PDT) MIME-Version: 1.0 References: <1585625296-31013-1-git-send-email-hqjagain@gmail.com> <87bloc23d1.fsf@kamboji.qca.qualcomm.com> In-Reply-To: <87bloc23d1.fsf@kamboji.qca.qualcomm.com> From: Qiujun Huang Date: Tue, 31 Mar 2020 19:39:51 +0800 Message-ID: Subject: Re: [PATCH] ath9k: fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb To: Kalle Valo Cc: ath9k-devel@qca.qualcomm.com, "David S. Miller" , linux-wireless@vger.kernel.org, netdev , LKML , anenbupt@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 31, 2020 at 7:03 PM Kalle Valo wrote: > > Qiujun Huang writes: > > > Add barrier to accessing the stack array skb_pool. > > > > Reported-by: syzbot+d403396d4df67ad0bd5f@syzkaller.appspotmail.com > > Signed-off-by: Qiujun Huang > > --- > > drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c > > index dd0c323..c4a2b72 100644 > > --- a/drivers/net/wireless/ath/ath9k/hif_usb.c > > +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c > > @@ -612,6 +612,11 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, > > hif_dev->remain_skb = nskb; > > spin_unlock(&hif_dev->rx_lock); > > } else { > > + if (pool_index == MAX_PKT_NUM_IN_TRANSFER) { > > + dev_err(&hif_dev->udev->dev, > > + "ath9k_htc: over RX MAX_PKT_NUM\n"); > > + goto err; the barrier ensure pool_index <= MAX_PKT_NUM_IN_TRANSFER > > + } > > What about 'pool_index >= MAX_PKT_NUM_IN_TRANSFER' just to be on the > safe side? Ah, but then error handling won't work: It looks ok? it can handle the case: pool_index == MAX_PKT_NUM_IN_TRANSFER > > err: > for (i = 0; i < pool_index; i++) { > RX_STAT_ADD(skb_completed_bytes, skb_pool[i]->len); > ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i], > skb_pool[i]->len, USB_WLAN_RX_PIPE); > RX_STAT_INC(skb_completed); > } > > Maybe that should use 'min(pool_index, MAX_PKT_NUM_IN_TRANSFER - 1)' or > something? Or maybe it's just overengineerin, dunno. > > -- > https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches