Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751556AbdFELsq (ORCPT ); Mon, 5 Jun 2017 07:48:46 -0400 Received: from us-smtp-delivery-194.mimecast.com ([216.205.24.194]:33705 "EHLO us-smtp-delivery-194.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751335AbdFELso (ORCPT ); Mon, 5 Jun 2017 07:48:44 -0400 From: Trond Myklebust To: "baijiaju1990@163.com" , "anna.schumaker@netapp.com" CC: "linux-kernel@vger.kernel.org" , "linux-nfs@vger.kernel.org" Subject: Re: [PATCH] fs: nfs: Fix a sleep-in-atomic bug in nfs_access_add_cache Thread-Topic: [PATCH] fs: nfs: Fix a sleep-in-atomic bug in nfs_access_add_cache Thread-Index: AQHS3dIpXDpxZlvObkmGtfZIkyOg+6IWJ66A Date: Mon, 5 Jun 2017 11:48:37 +0000 Message-ID: <1496663315.3433.1.camel@primarydata.com> References: <1496649904-1855-1-git-send-email-baijiaju1990@163.com> In-Reply-To: <1496649904-1855-1-git-send-email-baijiaju1990@163.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [68.49.162.121] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR11MB1360;7:u7viuhLESXM5+YlyOwD99xEd9UHfxlVsprZUXQLQI9Hk5xbJ5zjKaZIBJMqF5Z1UYlIH5207x7GSOzSkuTTMBVql5yHh5h2yqlmMp3sp+9nXJpwzYDkg/0ZSKxQC5o4YNabXARH7nPOWT/4VOuTmC9HxXf20/HtbzxI7wq4fVGjJmy3GCTb0n1auNQWAE/CzAy7YGkBWWCo7ocxZLFp7v3RZAucFENV8Bdr1XeCAaY4j2WMSZf42vlOe7YIhv2ZlDj69Y0LDcMcied8WvlOT5ef9Q7CLE29wxlSrFOu2ycTnl3pWNl3FeQD/JFGWY3dY4viezPEYZFJ7b27JIQfSUA==;20:PPDDVzQm0deFthCXkueuNm7THu1V8L0eBdEa2opr7i/6lzkNOkIk60Cpn8E2FxDyP8nb41IO4PTYmjK9ryZT9HM6RAWI6ZNfN/qgUNoixJKebJpmqC/QwjEuFCvFy3cGNWOdVMfUyI81ExJGf1HoC5d20yzvMlyef3KeX80R6pM= x-ms-traffictypediagnostic: MWHPR11MB1360: x-ms-office365-filtering-correlation-id: 7cb92291-c73a-499e-fd37-08d4ac08cdd3 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(201703131423075)(201702281549075);SRVR:MWHPR11MB1360; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(130843839470238); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6041248)(20161123555025)(20161123564025)(20161123562025)(2016111802025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(6072148)(6043046)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR11MB1360;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR11MB1360; x-forefront-prvs: 0329B15C8A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39830400002)(39400400002)(39410400002)(39450400003)(377424004)(24454002)(102836003)(5660300001)(478600001)(122556002)(6246003)(6506006)(38730400002)(14454004)(99286003)(7736002)(6512007)(25786009)(189998001)(305945005)(103116003)(6436002)(3846002)(86362001)(8936002)(230783001)(54906002)(53936002)(3660700001)(2900100001)(2906002)(8676002)(6116002)(229853002)(3280700002)(36756003)(2950100002)(2501003)(66066001)(77096006)(4326008)(54356999)(33646002)(6486002)(76176999)(81166006)(50986999);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR11MB1360;H:MWHPR11MB1359.namprd11.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <79C7B7B18FD4CA4CA793BBBAE5FA0754@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: primarydata.com X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jun 2017 11:48:37.6989 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 03193ed6-8726-4bb3-a832-18ab0d28adb7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1360 X-MC-Unique: MQnim8CnOeey1o1d6VwR4w-1 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v55Bn2Ae027556 Content-Length: 1277 Lines: 42 On Mon, 2017-06-05 at 16:05 +0800, Jia-Ju Bai wrote: > The driver may sleep under a rcu read lock, and function call path > is: > nfs_permission (acquire the lock by rcu_read_lock) >   nfs_do_access >     nfs_access_add_cache >       kmalloc(GFP_KERNEL) --> may sleep > > To fix it, "GFP_KERNEL" is replaced with "GFP_ATOMIC". > > Signed-off-by: Jia-Ju Bai > --- >  fs/nfs/dir.c |    2 +- >  1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c > index 32ccd77..7a074db 100644 > --- a/fs/nfs/dir.c > +++ b/fs/nfs/dir.c > @@ -2333,7 +2333,7 @@ static void nfs_access_add_rbtree(struct inode > *inode, struct nfs_access_entry * >   >  void nfs_access_add_cache(struct inode *inode, struct > nfs_access_entry *set) >  { > - struct nfs_access_entry *cache = kmalloc(sizeof(*cache), > GFP_KERNEL); > + struct nfs_access_entry *cache = kmalloc(sizeof(*cache), > GFP_ATOMIC); >   if (cache == NULL) >   return; >   RB_CLEAR_NODE(&cache->rb_node); The RCU locked codepath will not ever hit nfs_access_add_rbtree(). It returns with an error code of -ECHILD after the test of "may_block". Cheers Trond -- Trond Myklebust Linux NFS client maintainer, PrimaryData trond.myklebust@primarydata.com