Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1198411ybb; Fri, 3 Apr 2020 21:20:01 -0700 (PDT) X-Google-Smtp-Source: APiQypKdl9CNWoLLkBvylBLkDJizYoBc8Ui1NSCzKZ+WsJi6kOhr3PPlT4AQTlf+Cbe4XAksPbp/ X-Received: by 2002:aca:52d0:: with SMTP id g199mr5649073oib.59.1585974000954; Fri, 03 Apr 2020 21:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585974000; cv=none; d=google.com; s=arc-20160816; b=AdrtpzqIqX+c92jatpsUsi2iRe+F5cvHuMRpWOgbo8iV4wEZU4p0A3xG644xcXHv4N uwRcpbCQhdfPhEDVxDJwRtDRvPa6CXTtW7rqhks6kMu3vtaww2r6BBq1nXbCMo7b8RIC qZhEwyDMeyAxkq3OxhDxY4XRBFUpSOOT98Lj5CT/RTL+VLrw7rKo76zuyPjx2fV7M4M0 4nEL6andKT4r+cJW+lkjtrJMeoLwr8YTpig2RYpCjXT9EEf1eE5cxxZp449IG5fwc8i3 DOEkLi/epimMAHoS5ufx2p0NEmJnH5411VWfHausXLbubDw3tPqirRr7pTCd9sdFjpib DbhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=3OVVO2ADZTyoYC8jre3rfDNBGTuwirm9KZaN24KTPZs=; b=MwztIi/7HowqRrRxa6mV6nkgG3XYyAleTo7kkhl2/QuhEtoBpAYT90katf9HnCccGC 1yVBvSgGi0HDA3bck7tYy0+wNLlnzKmXo1lBE4WxAIgo04bBHtqkdiUuWkIRiemMNp/D FG9mgHbrCrTN60DNpMaLtPY5t1XoioLM9ym8QpiVlmL/W8qo0XSPscX1njkcuqwSQ6kR 9TRX6SQZXMyQKqelcajqeEv/3VgyvVZAOGceoibX7Wi4bMkrKia70u+KSh5sn+rZzYK2 Iqq5v1ZxdQAeBt1rITA2Ilqwns7drsHPw3vgKp33/K+RtqIU2A8WXPN2ga6A015lL/mE +0Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ECUuerOU; 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 d63si4553223oib.224.2020.04.03.21.19.49; Fri, 03 Apr 2020 21:20:00 -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=ECUuerOU; 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 S1726410AbgDDETR (ORCPT + 99 others); Sat, 4 Apr 2020 00:19:17 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46882 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgDDETO (ORCPT ); Sat, 4 Apr 2020 00:19:14 -0400 Received: by mail-pf1-f193.google.com with SMTP id q3so4616751pff.13; Fri, 03 Apr 2020 21:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3OVVO2ADZTyoYC8jre3rfDNBGTuwirm9KZaN24KTPZs=; b=ECUuerOUIFC8DX9onGTQDa/VE/1inoBXbJbYpJKcpDIsMUzPulztXLMIcwzKtLeMfw AH2JWuRToGh6rca/dMLlK9w2thPCuel13eESSvGkURJ1LmzfPzD61SYobIw6IOp2ORSh l7J2N4hj0J+Mnp+jv2ployrdJkzE2BsB3zfDOK95aXy6wLJgpvqnT6pamk6MfWUgYjoL mMlbyUZCIwEg74ZjLUTb07+fKTesQPYPLyB4266ogQBXJEmslOInBRqGu6kkHk+Bh0tJ qNWOBVdB2U/YXUrp6UGC8QOLesbQ9Bp+lh9osa01fpI7lh/uYk0PNIDjzFD/2tvwtnC6 DM/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3OVVO2ADZTyoYC8jre3rfDNBGTuwirm9KZaN24KTPZs=; b=Y4In64D+aUKnTuvRoy3MpMODLNO97rXJtfCLPapMeFOT2GDdYbDdfYHLBHHZzFkZHn opDQkUmczHYKG57M2l6Q+TBHIPqu7CXc7YuKyYEQ38/IJP+SoGB06Bhl4Sp1Rp0DuOP1 t6TCN9668icB3dh2jbgtviDDQE26Vpb7ENbdCa3+2amZ1vGGzdIWTLDxsOFv/af0VKsY DoKIMbd5GUiV8TJpgY1di9a5TD+j7NT+Y1q53rEXZfLrYt22AFOY2ouK9r/351AF6okR MP2NiqT7tlapbGNhjX6Pt5anFdYFq/dZjWGRnXmLP0ADUaaYtiG1uw1BXd63KhgUabDe p19Q== X-Gm-Message-State: AGi0PuZPa3hlFx7KtEHlWyQGu+xG9whkL3MMDMlbRUrPD96hLTxlu4bM XW+aS6ORWq6x1x3XueytYNY= X-Received: by 2002:a63:be49:: with SMTP id g9mr11313692pgo.30.1585973951390; Fri, 03 Apr 2020 21:19:11 -0700 (PDT) Received: from localhost (n112120135125.netvigator.com. [112.120.135.125]) by smtp.gmail.com with ESMTPSA id x68sm5404129pfb.5.2020.04.03.21.19.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Apr 2020 21:19:11 -0700 (PDT) From: Qiujun Huang To: kvalo@codeaurora.org, ath9k-devel@qca.qualcomm.com Cc: davem@davemloft.net, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, anenbupt@gmail.com, syzkaller-bugs@googlegroups.com, Qiujun Huang Subject: [PATCH 4/5 resend] ath9x: Fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb Date: Sat, 4 Apr 2020 12:18:37 +0800 Message-Id: <20200404041838.10426-5-hqjagain@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200404041838.10426-1-hqjagain@gmail.com> References: <20200404041838.10426-1-hqjagain@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add barrier to accessing the stack array skb_pool. The case reported by syzbot: https://lore.kernel.org/linux-usb/0000000000003d7c1505a2168418@google.com BUG: KASAN: stack-out-of-bounds in ath9k_hif_usb_rx_stream drivers/net/wireless/ath/ath9k/hif_usb.c:626 [inline] BUG: KASAN: stack-out-of-bounds in ath9k_hif_usb_rx_cb+0xdf6/0xf70 drivers/net/wireless/ath/ath9k/hif_usb.c:666 Write of size 8 at addr ffff8881db309a28 by task swapper/1/0 Call Trace: ath9k_hif_usb_rx_stream drivers/net/wireless/ath/ath9k/hif_usb.c:626 [inline] ath9k_hif_usb_rx_cb+0xdf6/0xf70 drivers/net/wireless/ath/ath9k/hif_usb.c:666 __usb_hcd_giveback_urb+0x1f2/0x470 drivers/usb/core/hcd.c:1648 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1713 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786 Reported-and-tested-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 f227e19087ff..6049d3766c64 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; + } nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC); if (!nskb) { dev_err(&hif_dev->udev->dev, -- 2.17.1