Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp519387lqs; Thu, 13 Jun 2024 18:30:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXT9mxxzgYQVLg3ufK2uqooDQbB1X6uB8bYIFkx3y+PkOO2QQfpcRgTtPN+zX8erIwGPFjYmD5NRvBPpTkgXWeAnfW93GT1PdzwzjqGPg== X-Google-Smtp-Source: AGHT+IEq7TTEgOhCpTqNzuQfzNNhUehzdHikrKhOc6gS9qjLEex4p8iMOcreq3V/IVOtZZIF8niE X-Received: by 2002:a05:6358:720e:b0:19f:57a9:2823 with SMTP id e5c5f4694b2df-19fb51407c2mr151939855d.31.1718328658530; Thu, 13 Jun 2024 18:30:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718328658; cv=pass; d=google.com; s=arc-20160816; b=R9n/KxO8RlDRW95Nauw28X+Y56EC56suFLPW19lLX7dtVM1DPgtkBvii90JpXUOeQ9 UATOTzx52XfvrKDRLvdG4XB8ulxeD9BAeJzNC0wXEDiiX8a8MdAgF6rIwc+4UkSVaXK/ USVOvVSj6L5siwgy9x9l6Ogd4U0HU2fm+rFuRpQopJ01D6XTNFQF4zOkvnkliNTtb5GB DM6me5g0Rcue5slvfW4nModL52TBQE1e7k6NAEHPi/eG1GGdQV+bhxdvF9DzNRist1wN X/iYL/YNRODpKIT44ccRJJ2hYxPcrEqCLwELukCf6p0QZ9197zl0EsrNp+Ee4ezGbtSJ Nwpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date; bh=3T6hOqWay9LtJo3rcg7d2fSQ0mTorglHngR0kvN9peE=; fh=+VpClYPiOO8b6mnwXI8YAbBr8WC5ou1KSdWlJNWhghM=; b=yclPIc58iFHPdLyWo0eoSe4lOtaJR90qInfJkxyEB6P5bZfeTBedB/KVb0oq6t2fgS FNfVzROvC4V8ekPwc87HkL3ZNnyq7WIab5T23wKMXnezeTU8tedlzPYa978hnFSxv9tU fXcdF3yQT7TVFBUYi2W39zvGd26YGBakhQM6ZQqExxzgX6FVYTaSTcNw5ylvr6PFyKrE TGSouGZUJXrUm6PeMQi967lx4flW2CsgFF0JDrvFxnuCy/0/n5/NBNXh6q5o7Z6BsH2f LFRXbwhI+yB+2qQP9/kURXeyJfiivRHUMRtptRXpwnObJ2QNYciGB34C0biPsPfACAOx un+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-bluetooth+bounces-5307-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5307-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee67b88f6si2452813a12.865.2024.06.13.18.30.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 18:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-5307-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-bluetooth+bounces-5307-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5307-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1A466284345 for ; Fri, 14 Jun 2024 01:30:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E04F158D8D; Fri, 14 Jun 2024 01:30:53 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id ABD831773D for ; Fri, 14 Jun 2024 01:30:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718328653; cv=none; b=KrLfPfvvw0I5pVUJ9ugIwvUder4RZdEqqfRdw7qvXPbEEHM4KwOHwJnmnEKXosB4K+wM5P88SFkA/6BPnonDqT0AcXSl2CqARw2vQ5mSPbDeIP23xshqreD95Jqb49zceaLdZkZ1DoxvY4f+RnsMq50oeBX/8e+bSMCvalpBQvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718328653; c=relaxed/simple; bh=NHfuDosNeZjSwPeDyy3cQ2MkLsMtVZXIVIVqodb7G6Y=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=XRGka9hx6IjHxiCzLrasqW5GsUWKkLmIiSbLVUKI7KD7fu0TCc+IJsM1zjF7khNPsyfEZDJrbIIaYNbAO8YBd61GuzAFGvZLnvw152xr7FLFZUmsZOJMusE3gMvAS/Wojkq+J7y6XdfrEHoEIgv9e41b+QNOGG6QMLzNDw3FKW4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 282581 invoked by uid 1000); 13 Jun 2024 21:30:43 -0400 Date: Thu, 13 Jun 2024 21:30:43 -0400 From: Alan Stern To: Greg KH Cc: syzbot , syzbot , johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, luiz.dentz@gmail.com, marcel@holtmann.org, syzkaller-bugs@googlegroups.com Subject: [PATCH] USB: class: cdc-wdm: Fix CPU lockup caused by excessive log messages Message-ID: <29855215-52f5-4385-b058-91f42c2bee18@rowland.harvard.edu> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The syzbot fuzzer found that the interrupt-URB completion callback in the cdc-wdm driver was taking too long, and the driver's immediate resubmission of interrupt URBs with -EPROTO status combined with the dummy-hcd emulation to cause a CPU lockup: cdc_wdm 1-1:1.0: nonzero urb status received: -71 cdc_wdm 1-1:1.0: wdm_int_callback - 0 bytes watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [syz-executor782:6625] CPU#0 Utilization every 4s during lockup: #1: 98% system, 0% softirq, 3% hardirq, 0% idle #2: 98% system, 0% softirq, 3% hardirq, 0% idle #3: 98% system, 0% softirq, 3% hardirq, 0% idle #4: 98% system, 0% softirq, 3% hardirq, 0% idle #5: 98% system, 1% softirq, 3% hardirq, 0% idle Modules linked in: irq event stamp: 73096 hardirqs last enabled at (73095): [] console_emit_next_record kernel/printk/printk.c:2935 [inline] hardirqs last enabled at (73095): [] console_flush_all+0x650/0xb74 kernel/printk/printk.c:2994 hardirqs last disabled at (73096): [] __el1_irq arch/arm64/kernel/entry-common.c:533 [inline] hardirqs last disabled at (73096): [] el1_interrupt+0x24/0x68 arch/arm64/kernel/entry-common.c:551 softirqs last enabled at (73048): [] softirq_handle_end kernel/softirq.c:400 [inline] softirqs last enabled at (73048): [] handle_softirqs+0xa60/0xc34 kernel/softirq.c:582 softirqs last disabled at (73043): [] __do_softirq+0x14/0x20 kernel/softirq.c:588 CPU: 0 PID: 6625 Comm: syz-executor782 Tainted: G W 6.10.0-rc2-syzkaller-g8867bbd4a056 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024 Testing showed that the problem did not occur if the two error messages -- the first two lines above -- were removed; apparently adding material to the kernel log takes a surprisingly large amount of time. In any case, the best approach for preventing these lockups and to avoid spamming the log with thousands of error messages per second is to ratelimit the two dev_err() calls. Therefore we replace them with dev_err_ratelimited(). Signed-off-by: Alan Stern Suggested-by: Greg KH Reported-and-tested-by: syzbot+5f996b83575ef4058638@syzkaller.appspotmail.com Closes: https://lore.kernel.org/linux-usb/00000000000073d54b061a6a1c65@google.com/ Reported-and-tested-by: syzbot+1b2abad17596ad03dcff@syzkaller.appspotmail.com Closes: https://lore.kernel.org/linux-usb/000000000000f45085061aa9b37e@google.com/ Fixes: 9908a32e94de ("USB: remove err() macro from usb class drivers") Link: https://lore.kernel.org/linux-usb/40dfa45b-5f21-4eef-a8c1-51a2f320e267@rowland.harvard.edu/ Cc: stable@vger.kernel.org --- drivers/usb/class/cdc-wdm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Index: usb-devel/drivers/usb/class/cdc-wdm.c =================================================================== --- usb-devel.orig/drivers/usb/class/cdc-wdm.c +++ usb-devel/drivers/usb/class/cdc-wdm.c @@ -266,14 +266,14 @@ static void wdm_int_callback(struct urb dev_err(&desc->intf->dev, "Stall on int endpoint\n"); goto sw; /* halt is cleared in work */ default: - dev_err(&desc->intf->dev, + dev_err_ratelimited(&desc->intf->dev, "nonzero urb status received: %d\n", status); break; } } if (urb->actual_length < sizeof(struct usb_cdc_notification)) { - dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n", + dev_err_ratelimited(&desc->intf->dev, "wdm_int_callback - %d bytes\n", urb->actual_length); goto exit; }