From patchwork Thu Sep 13 03:34:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10598675 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FD7914BD for ; Thu, 13 Sep 2018 03:34:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15479287E9 for ; Thu, 13 Sep 2018 03:34:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05F1B2ADD9; Thu, 13 Sep 2018 03:34:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2DD3287E9 for ; Thu, 13 Sep 2018 03:34:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726693AbeIMImX (ORCPT ); Thu, 13 Sep 2018 04:42:23 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40306 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbeIMImX (ORCPT ); Thu, 13 Sep 2018 04:42:23 -0400 Received: by mail-pf1-f193.google.com with SMTP id s13-v6so2003286pfi.7; Wed, 12 Sep 2018 20:34:50 -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=rV1GWKSW7XACWiwwVzeCEC8YfhT7pdyQ6PSWC3G+8SY=; b=C4xoQS4J6ra2hf8NG/HOVLUw1z7+FYk3v9JcfFu3DPUF5iqtplfSTBznLJnCBGRKLc NXq53ab7ZZXHlyRI+42sPJXNcP1AY9S4zXAygo7R9wL+q8VFNZIMYfEyJan7pSPQLEeS WHPrPbYPbK7tuhja60+Zm40YoYgS6knzVPPDCaaH7GTEqXOPPQvD264mAgkmtTGT+aer rrF3lvqL/68WxDNHdOj7LRcK6fWP1PGznbJk0xQl7omVij29MmQtnQUel4VKMDY9HNMC VXHzS5dghB5J5CmgajjdUJhJcZuaDe9K4/u3KgzPI0SH6OSpzIR/OvI1sfw/dYPPnjU7 Fu1Q== 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=rV1GWKSW7XACWiwwVzeCEC8YfhT7pdyQ6PSWC3G+8SY=; b=dlbmcshjS2L7O2TzZ1EsMSnhzFUkmc7LWIK80ZiiEQXnwUMwe/PIhuQ2bA6t/Ck5WU +2inWLY6kt9RuJt0+DR801HBlUSMtL92tkp51eHndmXj28NciW+d20Cy3Njqu7PHbBQT JzxtOTXCa4AUJJ3frs3lHWjcvQ2iEDy+VzaoXwwK/LtkDi8XQdKxO1Hb8Yodhy4ToSi3 DK4GTnU4F9MdAczmpFaM+LcdXdOW90oxk04zch/zyfz1LopG+7wVDKOAeMu0ZCANv0vt InPIMxB6NxRbVoOKM3u4fhHgG2bB0qORq5AmkPCbXudY6d2bAOPHZoRQj9kAoUoybLKJ wLTQ== X-Gm-Message-State: APzg51BqnRR11scXvFc4QCOTBYijBPCVl9ndh0U9Q/oZ0pr4HiwPy+BD YwrItsfmrtobipDYbFWTNtw= X-Google-Smtp-Source: ANB0VdZ9wXp0SEDC8CfOPuTSbRndr0gRPRqSCEQROh/XYZbP2niM7/sorCAvInYohv+1Z/n+LkmdVg== X-Received: by 2002:a63:cd4c:: with SMTP id a12-v6mr5126125pgj.15.1536809689739; Wed, 12 Sep 2018 20:34:49 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:68d1:35da:fac1:c83b]) by smtp.gmail.com with ESMTPSA id y4-v6sm4095266pfn.123.2018.09.12.20.34.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 20:34:49 -0700 (PDT) From: Jia-Ju Bai To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH V2] hid: hid-core: Fix a sleep-in-atomic-context bug in __hid_request() Date: Thu, 13 Sep 2018 11:34:32 +0800 Message-Id: <20180913033432.16336-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP hid_alloc_report_buf() has to be called with GFP_ATOMIC in __hid_request(), because there are the following callchains leading to __hid_request() being an atomic context: picolcd_send_and_wait (acquire a spinlock) hid_hw_request __hid_request hid_alloc_report_buf(GFP_KERNEL) picolcd_reset (acquire a spinlock) hid_hw_request __hid_request hid_alloc_report_buf(GFP_KERNEL) lg4ff_play (acquire a spinlock) hid_hw_request __hid_request hid_alloc_report_buf(GFP_KERNEL) lg4ff_set_autocenter_ffex (acquire a spinlock) hid_hw_request __hid_request hid_alloc_report_buf(GFP_KERNEL) This bug is found by my static analysis tool DSAC. Signed-off-by: Jia-Ju Bai --- v2: * Make the description more human readable. Thanks Jiri for good advice. --- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 3942ee61bd1c..c886af00c8c9 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1442,7 +1442,7 @@ void __hid_request(struct hid_device *hid, struct hid_report *report, int ret; u32 len; - buf = hid_alloc_report_buf(report, GFP_KERNEL); + buf = hid_alloc_report_buf(report, GFP_ATOMIC); if (!buf) return;