Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp246635imm; Sat, 1 Sep 2018 01:14:18 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdblbv+PPnumGIQsJW8skipR5DGIZPE8dcVjltSmN36Bb/+hxetRR10O6+QMp/HKToE9qkez X-Received: by 2002:a62:e008:: with SMTP id f8-v6mr19784749pfh.208.1535789657979; Sat, 01 Sep 2018 01:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535789657; cv=none; d=google.com; s=arc-20160816; b=y1djRmC0N2LwXtr/5oW1Guyle+fe/x05U7anb6xzIfwSF11SKrJ6Lvh45oPmGnpbvh frHAuUgvsaGlcGhlZLFQ+4147Zim64Qy7cExLbbruIfyNALM6Nqc/03FmHbgGFM9U+WD TJUu8M09bcjPwqbATh/+DMzfglJyk2HUuXhyfmvBz82rQEvpfYsTmPfvZt8NtYSn4cw6 7MtH8Na4Y9B4eEFd2Koeu/HFHlRqXPXkKZcawriaJF5/nwC7l7Tiv/B9ci4h6+AIAQHr J4K6CHRBfXX4a0pCCcanTaJQMg4RNwfK/9A+BvjOh641bfp7BtutxIwQ8+DS1XLLc7sJ 3Ipw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=yc+htbF4R6nRAyGSXNiAP4+3KXevwqppPAqtSDiglT0=; b=yUPc3yM41XOv2tVThUyY+m+CsNann7+l13IJx1KjdaxxXM1ubk4BKFigNS8j/xeYGP dc9nDKrKOppJr0sxbTvQh0lBJw8zkpy0lysd82QPwIu0uSvLMcyaw0zNw6A7aArXEdzh yVW4u0Rp8ps+aVpKohDYdIC2zEXZBQoH/jLt+OBWgleOt8T+gX91BrQMlmvjzDpK1xNd ii6l3q95WGTBO/BVDJdEZtaK0F+O+zuY0hvZAwEHYNkQ2Nnz9yGpxGPOdx0rukFrw20u OsP58q0uDj+fkQFhnFMTbAhT6yb2vs86D2IK1sfzQVtYg9GEjf0wrFMfTp/8VoyMcIrt iEFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c0JVvnqB; 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 s3-v6si12944433plb.270.2018.09.01.01.14.01; Sat, 01 Sep 2018 01:14:17 -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=c0JVvnqB; 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 S1727385AbeIAMX3 (ORCPT + 99 others); Sat, 1 Sep 2018 08:23:29 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35863 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727282AbeIAMX3 (ORCPT ); Sat, 1 Sep 2018 08:23:29 -0400 Received: by mail-pg1-f193.google.com with SMTP id d1-v6so6450011pgo.3; Sat, 01 Sep 2018 01:12:20 -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; bh=yc+htbF4R6nRAyGSXNiAP4+3KXevwqppPAqtSDiglT0=; b=c0JVvnqB0wt21GivQD6Te6IHx9e80knXcCfHMeLHGW7+PRge4j5+4hVrFMwU093yc8 12AUdqsspDWUuLQsXo+u5v/E2NeDrtRx9F4BuVWH69bY1Sw7HPTnUFQ35bkCSd2d6LyQ R2g6cTWa44BybYxx4oPx72U6BDdIBW6N8NytFL8GBZc+OowKJCfN6QAJURHsLPDEDdan hDwRWCzh+UGKGvW4dJYAAA9aGjVF5U7PnThdA6hxeCpA8vS0cliynOERtvZFTTaHoR01 3mEOWDawn+CX+u0deBgYzb9xilXmPLecfog0UaGJPIlSlWo7OPHNX8dyWMWMqdYgqRwO E3Mw== 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; bh=yc+htbF4R6nRAyGSXNiAP4+3KXevwqppPAqtSDiglT0=; b=htmdt2pXFlNP4J/0qDfWG5s16bztoT1eZQPJ3OJNOGEUtLULp64lo/32a0c5vIEic4 rquMRYRcI+BRd+LjNZflaZQsa1bObmZX4De331sV+FANVXdn/Bzd/rgVHYirBt6oL6zp EcjqKecYY4rJeEM8UDhnnPNJaMMgNa+TepXeHFmz/dvzMpk8ddv18VlzOaUdoC89EHcX X5yXX+on1G/WuFydb5Ojib8yfv1B1MdayAt9vwi9t2320XCoisjaB3hkcG9r9tf64JRe ZOrJB4b4ngmZLsU7GZ9g/5xjcw6SIIdgTRNN7IRoNXF5Rlq3JqneE/nrhm2WCIqaomDD 2p7A== X-Gm-Message-State: APzg51DPVjpV+A14Zk2RqcZQTZ5sHrytXMwyX0Xr+VPnfb2vK41GMWxW TPBu7P5buFf7d7tQ7dXRHbg= X-Received: by 2002:a62:6bc5:: with SMTP id g188-v6mr15768159pfc.91.1535789540584; Sat, 01 Sep 2018 01:12:20 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:4130:91db:5d72:621b]) by smtp.gmail.com with ESMTPSA id d9-v6sm34347562pfb.86.2018.09.01.01.12.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Sep 2018 01:12:20 -0700 (PDT) From: Jia-Ju Bai To: gregkh@linuxfoundation.org, johan@kernel.org, bjorn@mork.no, mingo@kernel.org, oneukum@suse.com, viro@zeniv.linux.org.uk, mark.rutland@arm.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH v2] usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt() Date: Sat, 1 Sep 2018 16:12:10 +0800 Message-Id: <20180901081210.16655-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wdm_in_callback() is a completion handler function for the USB driver. So it should not sleep. But it calls service_outstanding_interrupt(), which calls usb_submit_urb() with GFP_KERNEL. To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool DSAC. Signed-off-by: Jia-Ju Bai --- v2: * Add more description. --- drivers/usb/class/cdc-wdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index a0d284ef3f40..632a2bfabc08 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -458,7 +458,7 @@ static int service_outstanding_interrupt(struct wdm_device *desc) set_bit(WDM_RESPONDING, &desc->flags); spin_unlock_irq(&desc->iuspin); - rv = usb_submit_urb(desc->response, GFP_KERNEL); + rv = usb_submit_urb(desc->response, GFP_ATOMIC); spin_lock_irq(&desc->iuspin); if (rv) { dev_err(&desc->intf->dev, -- 2.17.0