Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp166925imm; Wed, 12 Sep 2018 20:35:17 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYs+tdwOElHfHhGSn3FxG/gUgeyLFiGW+s5HyUt15d/JNQfMFQIqLkzJLcDCj3thgqNvoLC X-Received: by 2002:a62:9992:: with SMTP id t18-v6mr5314527pfk.239.1536809717583; Wed, 12 Sep 2018 20:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536809717; cv=none; d=google.com; s=arc-20160816; b=B97StZZiLQ009bpbpoFEIi3bbksa+pJCMdXc2ZpZKmZSG4ti3rM2kfq4UGeD/y4s6L ULekPsQMwx6MBtpMQHZSbBV6Of0TfgQpkYHs4/bv9otxGJan4yTNzdRd62/XXOI9OjuR k6DKTwMKseWYVzpYkQt+WOggKbWX2fJXgwDgr6kBE/1gAKP9FZ1hY7hKVDD744EI8C6b ooPDdVSTE97GkY/AfnSehJ/lkUxjO7CplP3jc8TJy/7UP1i62CIlYXAHsXPWIdnKA9bj S57tERxSroVnP4U7oEepT3nGrE3nhUFrz3a7nBixo0XUYivo0ODv7HN6yVA110I1Fx1Y eUEg== 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; bh=rV1GWKSW7XACWiwwVzeCEC8YfhT7pdyQ6PSWC3G+8SY=; b=NLM24MHrgFwjAEB0JVsnqjxuPluh60Q94BGkJFmRbS0Rfwb3T7ZdUBAyPbgZd0uIaV nVLbiU22ugVi5ym6ihPBrclpgL5eUc9flLNpk1H0YaiFu7g1lAGkFZ8DKPrGqQHR9CcD ESmEEx/CVvYWzqlYiXJxCaJZBXFUNmIVgplfk+xNPy7kMDefGYOEUJnA4dleWMuYdJEK 1D4X62ObQwf5XO5rSL2Z93ByZfxiwr021ZeeJYCijOnnkrdyCfF4eoiWXpo9G+Cj7pPS 0AbXtd1Aw++t5ieNhDzp94MfvU4uGmE0uWS7UMcm0BYTseD2VUExxzXkXZpmBk6hRrCG 9yhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=C4xoQS4J; 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 z15-v6si2816441pga.117.2018.09.12.20.35.02; Wed, 12 Sep 2018 20:35: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=C4xoQS4J; 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 S1726799AbeIMImX (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.17.0