Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1820930imm; Mon, 3 Sep 2018 10:17:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYDbfsYTcC/N8+aMGJsd6jhYCAHrC71F5OKWbqvNcL6HhhOgTP2/wrHFIINocNCbYxaM0Q1 X-Received: by 2002:a63:ba1c:: with SMTP id k28-v6mr27013284pgf.76.1535995031377; Mon, 03 Sep 2018 10:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995031; cv=none; d=google.com; s=arc-20160816; b=oRPBm2npsQgVhq7J1A7+UumJUq3YweHxOOwxBMp8TllGsp97KeSqi0w+bV0d7QyXvJ ydYlYB3Xcbvt5cRLAyMi5kNHaQKeBRN8pgqkd6HnXccdi3+UsDj/J8C1l5e54ykb5K1F pnjb7qJ/rfQhD0xlmXnk03VggjyKhWEEkR+Wqwt17gCPmu9Xj7mUEUdVm1JqLkBiSYm9 qPhINKVr83SGn7vxbytEwCneuECSCwRej4wqaSND00cQsLDlm9aHCsfArOCllzJHvr5k Eiyi2RwSfm8egQI4mI69iXHKjTzyayN/FlkSFfCm9HRj55QyCWuDyzI7lbmD4fMb8No1 s37g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Aq3VnwmN3uWjxIJaMcLKnqd613UKRY6mY61l3keKkd8=; b=CF934p+QfpX99sfZQROOnFFPccEi1BRhjSxImPPz0OwV1xLKqwZR0ycFVSMVEVqzSS PBxYJKKn8uUo3bJz48fvjKvgmkVmN6AiB+zB6FngxQzkg84mRDnd6n1WggkKODwjqA8b Xdlqqkni7IvopD3U3L3vQkJvXS0MveM3xWWps7wGgA82madPw4Ucc2SmuKPTsQJzdTr4 IXo2SwHRT2hEDORloeaLZxLrTXHk9OVv92cuowJxQEDRnfQXRRzJd/2zdI6BczmMlcbp 1kosxpTy4Ol/LAIK5BOPqk4OeyQVGLY4tFvk4c4ioUsL88bvum/Ujy6nEJ0Ttpa6T/RA M8Qw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24-v6si17908540pfo.54.2018.09.03.10.16.56; Mon, 03 Sep 2018 10:17:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729773AbeICVg4 (ORCPT + 99 others); Mon, 3 Sep 2018 17:36:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42456 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728222AbeICVg4 (ORCPT ); Mon, 3 Sep 2018 17:36:56 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C206CD06; Mon, 3 Sep 2018 17:15:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 017/165] usb: gadget: r8a66597: Fix a possible sleep-in-atomic-context bugs in r8a66597_queue() Date: Mon, 3 Sep 2018 18:55:03 +0200 Message-Id: <20180903165655.891250346@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jia-Ju Bai [ Upstream commit f36b507c14c4b6e634463a610294e9cb0065c8ea ] The driver may sleep in an interrupt handler. The function call path (from bottom to top) in Linux-4.16.7 is: [FUNC] r8a66597_queue(GFP_KERNEL) drivers/usb/gadget/udc/r8a66597-udc.c, 1193: r8a66597_queue in get_status drivers/usb/gadget/udc/r8a66597-udc.c, 1301: get_status in setup_packet drivers/usb/gadget/udc/r8a66597-udc.c, 1381: setup_packet in irq_control_stage drivers/usb/gadget/udc/r8a66597-udc.c, 1508: irq_control_stage in r8a66597_irq (interrupt handler) To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool (DSAC-2) and checked by my code review. Signed-off-by: Jia-Ju Bai Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/r8a66597-udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -1193,7 +1193,7 @@ __acquires(r8a66597->lock) r8a66597->ep0_req->length = 2; /* AV: what happens if we get called again before that gets through? */ spin_unlock(&r8a66597->lock); - r8a66597_queue(r8a66597->gadget.ep0, r8a66597->ep0_req, GFP_KERNEL); + r8a66597_queue(r8a66597->gadget.ep0, r8a66597->ep0_req, GFP_ATOMIC); spin_lock(&r8a66597->lock); }