Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp454624imm; Wed, 3 Oct 2018 20:15:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV62drsb1SD7rzYiYYIIwtqwrf+PB6uWaZ+DMrbhOgeRv9d1BwovSGbxE5e7PyGwg5yOFXNHA X-Received: by 2002:a17:902:8d82:: with SMTP id v2-v6mr4587696plo.9.1538622919404; Wed, 03 Oct 2018 20:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538622919; cv=none; d=google.com; s=arc-20160816; b=oDjmV9ylZMiquPEKCZx9iWyMye8UUuRwVxuGjJ1UkwIORFQ0sH+JLKyB+ecDRpnTNk n7nsN6ftzPFBhRkRAEbZpUbRIJ98ZX4oPvhnLy+CZH6Sm37htzkAM6+GzRpDwDCvTX4p ltJ2Q/+hksqWVCjIkNKkG17OdaM4Ki16uP1Kn47S17P/jmKQVC56AfrGl93JFhz/V4TS KI81K/qSFXGD/COn4x4qKOghi0sTOeRPhYC5t4ZA69fvGwpGbrb3rIujoSNVaRIq51en O/s9jRAYpFCIB7kGULTX8XDOPxrzYV89ZubvhBJKo1ijFgqfnq1Hv/mtp0LspLdKvLyO U0cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Ot+SY8vO4yMITcD1BSzHRJIs5K5VhRWdb/JZjmg3njo=; b=gy4V746tK28IRyz/jeMdEprxLueI1K0lQnDuIhytYteChmmJ7I0jhPpMMoUiGi0G/j MghnbOwel30y6r572dAHQXvR7++o4+G/sJSi+XNBv9OF1JRNa8TMJoBcs+IarofmDk6U HR0XByt0LAN2A9sVOznDej3VIa9IneI4fNMr58CPyfuvK0TkR74REILTiyr1NgeWG8Cz 7Cjp/W/lgZY2WNc19Ih+7ahR3B5sGGvk7Bq9WaNqM1MeHJxfnw9QHZDR+/oO5jOg+/nR 4DwFitUgTCY9/GExQnbprQ4PXgnxwzYiTNTMFwgDluQ3zTt8+jlOoAtWRc2k1LC1KwCl KRww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pD+7Ms7d; 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 h189-v6si2210919pge.174.2018.10.03.20.15.03; Wed, 03 Oct 2018 20:15:19 -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=pD+7Ms7d; 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 S1727314AbeJDKGH (ORCPT + 99 others); Thu, 4 Oct 2018 06:06:07 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44382 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbeJDKGH (ORCPT ); Thu, 4 Oct 2018 06:06:07 -0400 Received: by mail-pg1-f194.google.com with SMTP id g2-v6so2446825pgu.11; Wed, 03 Oct 2018 20:14:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=Ot+SY8vO4yMITcD1BSzHRJIs5K5VhRWdb/JZjmg3njo=; b=pD+7Ms7dBzM8aX01qbzg4xjSB8GrwdSv/FFxgjfQJ2rEPPVPpx76wu8J7BmaD8GK9d Hic66c+dut2MQzcoKRAitmrLjlrNogdpcu7cci09s6/WzUGGxckwjZCl49q2D/Sp3lDL oXZaXbpuFuD3Ok5UtEFe5h9/pzdYevwOp3npVRPPkIOh7oYE0sFk+BtqxO/SKETgQBn+ a8C2e+ZtHfcnbQp+x0BIn3ziDULexxRBHU8d+ysRMx1WPAJk62AHX+CtYUO21rKca3k0 5Uo//HRZjnxmgw71YYsyQTWYBTSQyQX6kZBsiTBQBqCLKANUKklDn21mEPklQphuQBi4 D2bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Ot+SY8vO4yMITcD1BSzHRJIs5K5VhRWdb/JZjmg3njo=; b=TEqTt+5T/bgWXY/sfme5a1YK1FWrUSH47SjGjT4ToD/hbCJWZo9cTLzeep/+xQ+Ai+ DuWlUz4Q/LcXC7SgnWBjc+AgFVFQ+lCqgWi4rrOaU39RDf36diCRxlVzR//e9TBwccbs pkemIGL5cMRUQm3L5LKLB6CSnDnx4+8mZeHhgnHbxAdBbp9Ei85E2BJZXJQIA/WCkAER 94TzuL+1B5vVNaMKbwtxK1pu09DAIsQjm8wwtjYqcF6NT3HEHH7ysE3SvoAhx/b1wBSl pJuRqcFcRbwMr0cMS6hU3sQsg+Nih8MDAoCkQATVqGCFJz2k35M7VWrm+wKOutsCnCU5 xLPQ== X-Gm-Message-State: ABuFfogn2ANdrjzhOYgC37vDmOQgGDDirjT6RlTS50UqyQZj66gUPE5a 9Lo5n+xgVPii41qnCHXin5xUVqJW X-Received: by 2002:a63:e00d:: with SMTP id e13-v6mr3852051pgh.114.1538622897081; Wed, 03 Oct 2018 20:14:57 -0700 (PDT) Received: from ?IPv6:2402:f000:1:1501:200:5efe:166.111.71.3? ([2402:f000:1:1501:200:5efe:a66f:4703]) by smtp.gmail.com with ESMTPSA id z63-v6sm6005978pfz.31.2018.10.03.20.14.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 20:14:56 -0700 (PDT) Subject: Re: [PATCH V2] hid: hid-core: Fix a sleep-in-atomic-context bug in __hid_request() To: Jiri Kosina Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180913033432.16336-1-baijiaju1990@gmail.com> <4c0096c6-3745-963c-5086-5f579792599b@gmail.com> From: Jia-Ju Bai Message-ID: <6bea4185-3325-b04d-56ed-2fdf4c74d8ae@gmail.com> Date: Thu, 4 Oct 2018 11:14:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/9/30 3:20, Jiri Kosina wrote: > On Sat, 29 Sep 2018, Jia-Ju Bai wrote: > >>>> 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) >>> Hm, so it's always drivers calling out into core in atomic context. So >>> either we take this, and put our bets on being able to allocate the buffer >>> without sleeping, >> In my opinion, I prefer this way. > Why? Forcing all the report buffer to be limited to be non-sleeping > allocations just because of two drivers, looks like an overkill, and > actually calls for more issues (as GFP_ATOMIC is of course in principle > less likely to succeed). > Okay, I thought that using GFP_ATOMIC is the simplest way to fix these bugs. But I check the Linux kernel code again, and find that hid_hw_request() are called at many places. So changing this function may affect many drivers. I agree to only change the two drivers, and explicitly anotate __hid_request() with might_sleep(). Best wishes, Jia-Ju Bai