Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3531107imm; Wed, 5 Sep 2018 01:30:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYSxVbHqz02MzC0cU5YMpws/3EUl7rO/yS7WxET4zB2ulc64vCkGD0xTKvkDanSWNhM8HXn X-Received: by 2002:a63:1363:: with SMTP id 35-v6mr35462492pgt.202.1536136253689; Wed, 05 Sep 2018 01:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536136253; cv=none; d=google.com; s=arc-20160816; b=EYL0/G1nBFMLHFZLchjMqFRXOdo5RZMLSdelhXVGgXekNLq5+geYbIcWBfpLp8DkME /b6PiszD7RJHwPBOa5EpcyoyUzCJZU45b1CSNHHXmHQnbbluMbQ6hiLStpYwqpRo0az/ Kc3OEoWAr4wyE7dxCLyMubiD9y1JtXBbIv45yKEzO0I4cn5cEO8kkm55uDVumpFk6+fK 0Y7Ztw9igsRCpW2X4DNp0FkM9zKf0Xu0CJlyBM56DwA88lBQ30wXr1er1+DGXBAiSzIa jrLozcWnNBxBXX8sYw8ZBHgUU4X/s/RhVXbtyzTyn70UnJHCWzubEjaIK593WpF92R/g 5FNA== 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 :message-id:in-reply-to:subject:cc:to:from:date; bh=8fCMSZR7e/vpeeOy5gbv3WU7E2l7+7zK1pyTIX2nmik=; b=n9L3uzFEUnwtzBk3CDlrW0tETH12A43NNlslIQaLYsPND85GtJk6l8Pki3FkEF0lYs 5NTdzbL8KJlAfYfI/Uf+sRqSFNSAvWE0UvHCyO6mi5OiUwB/yrq5505YxvNXawy3vU0e 8gtZGuhgTGCynOiGS5WE+vrz7YiObl4jedKipfm6sdJF45dWNzHEvQ/R7a5s4LRAQpPM czueF41eNugRePfFvbK+4dPOmrGcdN5R4oWUf1NiH6lEMhIAWqJTrAs0pym0SXVbY2F8 O1/fDlR9WgfWYx51dJVlrK71VhekHm3X6BpjlNSDce4oZuOK/Sujig0HDnpGJzThkC8u /DUg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18-v6si1316518pll.344.2018.09.05.01.30.38; Wed, 05 Sep 2018 01:30:53 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727764AbeIEM6h (ORCPT + 99 others); Wed, 5 Sep 2018 08:58:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:54482 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726401AbeIEM6h (ORCPT ); Wed, 5 Sep 2018 08:58:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6CFDDAEA5; Wed, 5 Sep 2018 08:29:30 +0000 (UTC) Date: Wed, 5 Sep 2018 10:29:29 +0200 (CEST) From: Jiri Kosina To: Jia-Ju Bai cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hid: hid-core: Fix a sleep-in-atomic-context bug in __hid_request() In-Reply-To: <20180901121659.1257-1-baijiaju1990@gmail.com> Message-ID: References: <20180901121659.1257-1-baijiaju1990@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 1 Sep 2018, Jia-Ju Bai wrote: > The driver may sleep with holding a spinlock. > > The function call paths (from bottom to top) in Linux-4.16 are: > > [FUNC] hid_alloc_report_buf(GFP_KERNEL) > drivers/hid/hid-core.c, 1435: > hid_alloc_report_buf in __hid_request > ./include/linux/hid.h, 1023: > __hid_request in hid_hw_request > drivers/hid/hid-picolcd_core.c, 111: > hid_hw_request in picolcd_send_and_wait > drivers/hid/hid-picolcd_core.c, 100: > _raw_spin_lock_irqsave in picolcd_send_and_wait > > [FUNC] hid_alloc_report_buf(GFP_KERNEL) > drivers/hid/hid-core.c, 1435: > hid_alloc_report_buf in __hid_request > ./include/linux/hid.h, 1023: > __hid_request in hid_hw_request > drivers/hid/hid-picolcd_core.c, 245: > hid_hw_request in picolcd_reset > drivers/hid/hid-picolcd_core.c, 235: > _raw_spin_lock_irqsave in picolcd_reset > > [FUNC] hid_alloc_report_buf(GFP_KERNEL) > drivers/hid/hid-core.c, 1435: > hid_alloc_report_buf in __hid_request > ./include/linux/hid.h, 1023: > __hid_request in hid_hw_request > drivers/hid/hid-picolcd_fb.c, 215: > hid_hw_request in picolcd_fb_reset > drivers/hid/hid-picolcd_fb.c, 206: > _raw_spin_lock_irqsave in picolcd_fb_reset > > [FUNC] hid_alloc_report_buf(GFP_KERNEL) > drivers/hid/hid-core.c, 1435: > hid_alloc_report_buf in __hid_request > ./include/linux/hid.h, 1023: > __hid_request in hid_hw_request > drivers/hid/hid-lg4ff.c, 465: > hid_hw_request in lg4ff_play > drivers/hid/hid-lg4ff.c, 441: > _raw_spin_lock_irqsave in lg4ff_play > > To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC. > > This bug is found by my static analysis tool DSAC. Could you please rewrite the changelog so that it's human readable? The above is a bit hard to understand, I think something along the lines of "__hid_request() has to be allocating with GFP_ATOMIC because there are the following callchains leading to __hid_request() being an atomic context: ... a->b->c.._hid_request()" etc. Thanks, -- Jiri Kosina SUSE Labs