From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BFC53FFD for ; Fri, 24 Apr 2026 01:11:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776993066; cv=none; b=VUk7kXnsm0tvyTkiXH2eEj37b1HT9VJQdchjzi5HEH8UwGxm2YIZFpEEAzENrxTAvLIBomKSAfTLxyntjLLDAw6NLq+1hIkxPewOZepQZmlr8/NUFoJtTIVBabFotzInOOdDwz8ARukkUJZoFkAedVjkq5BB6pL3uzepD2zQrH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776993066; c=relaxed/simple; bh=Y9bLUcuTCRut5pFhgSO21XY9FQGBwpGxmhcjk7IgMIg=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=OuCWa2CgP0bpkGowwV9Z1RZJAj8+a49n8xLnY7BAlGgrlC1hMRjaDLwd3Pf8aj1uTfOFbHYwwTF+JwbV7SaJZkxE9+nLPMOdNvC9Bs7JZiGQ3uaPVHBqYlxuy/S1RXZ++ZVbp6pjRj2bP57vOXBaTa/3Mhr8o24xnM2OeIggLZg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-6853c2438b9so13366765eaf.3 for ; Thu, 23 Apr 2026 18:11:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776993064; x=1777597864; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w1EHGkk5+PisOMBnAH3vULAfwEMofqhJ7r+e/Q2eEUk=; b=jIu5AId+IEDGpxbIeLorQxaIv1y5m1nmTvL3r2NPtuIKXb3HwV3PeFFnj6vlWyL3/b 8PRQUi8zixCDj1tKMWyGkGRqzp7oshz6JV2hEd5WA4kylRoBuOMHPEZJdfZlS2L4VImY wpYMDKNZBU94VZKuOzFOP3XJLOOi0scXkL/sM5oczSdUXDj+w+AgKMN5gHJ7mtv7e/Qq IuCuWEdAKmFfpszbQtSP1B+gCDNouc6RXf2b+DSOGWgnAB8drWFIOHLVgpU/E9m/hk0m InrhmIefFa/Eaexc6y0OS+YqtwpzI9GGcZvs4/xTvfy7dKiC6VXjABItnZZDSjsqmj8g Od0g== X-Gm-Message-State: AOJu0Yz7e8mep4BJbqId5kTz5h85/qgoykv31czSp/TTNw7qpUzCH27q LiYUOqZq2luH+rhAtXdhchRcekCwzavM4IsdUfxNq3aT/nQ8AWrrofRN4auJJ5TWCFEbOLKohxl Q4eihvd9lJSxcFYDNgF2Ct9Bsd7RwZs/FEg78zFoul5RxitgaFzSHt4KvyzY= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:290c:b0:694:979e:333d with SMTP id 006d021491bc7-694979e352dmr7542155eaf.37.1776993064094; Thu, 23 Apr 2026 18:11:04 -0700 (PDT) Date: Thu, 23 Apr 2026 18:11:04 -0700 In-Reply-To: <69eab802.a00a0220.17a17.0049.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69eac328.a00a0220.9259.002e.GAE@google.com> Subject: Forwarded: [PATCH] wifi: carl9170: fix stack-out-of-bounds in carl9170_cmd_callback From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] wifi: carl9170: fix stack-out-of-bounds in carl9170_cmd_callback Author: kartikey406@gmail.com #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing carl9170_cmd_callback() does not return after calling carl9170_restart() when an invalid command response is detected. This causes a fall-through into the memcpy block below, where ar->readbuf is written with a device-controlled length (len - 4) instead of the expected ar->readlen bytes. A malicious or fuzzing USB device can send an oversized response (e.g. 60 bytes) causing a stack-out-of-bounds write into ar->readbuf, as detected by KASAN. Fix this by adding a return after carl9170_restart() to match the original intent stated in the comment ("Do not complete"). Also cap the memcpy with min_t() as defense-in-depth to prevent overflow even if the control flow changes in future. The bug has been present since the initial driver submission in 2010. Fixes: a84fab3cbfdc ("carl9170: 802.11 rx/tx processing and usb backend") Reported-by: syzbot+5c1ca6ccaa1215781cac@syzkaller.appspotmail.com Signed-off-by: Deepanshu Kartikey --- drivers/net/wireless/ath/carl9170/rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/carl9170/rx.c b/drivers/net/wireless/ath/carl9170/rx.c index 6833430130f4..6a5923495a01 100644 --- a/drivers/net/wireless/ath/carl9170/rx.c +++ b/drivers/net/wireless/ath/carl9170/rx.c @@ -145,12 +145,14 @@ static void carl9170_cmd_callback(struct ar9170 *ar, u32 len, void *buffer) * and we get a stack trace from there. */ carl9170_restart(ar, CARL9170_RR_INVALID_RSP); + return; } spin_lock(&ar->cmd_lock); if (ar->readbuf) { if (len >= 4) - memcpy(ar->readbuf, buffer + 4, len - 4); + memcpy(ar->readbuf, buffer + 4, + min_t(u32, len - 4, ar->readlen)); ar->readbuf = NULL; } -- 2.43.0