Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1870234imm; Tue, 2 Oct 2018 15:44:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV6107nZVOixoLO0RLDbXCtm95Y7qk+gqRvzCUdm3QlnzSvJXpX0oWEsIADNEHLlTLFfSerdj X-Received: by 2002:a63:545c:: with SMTP id e28-v6mr10144200pgm.316.1538520269170; Tue, 02 Oct 2018 15:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538520269; cv=none; d=google.com; s=arc-20160816; b=V980wDftsDR4OSPEnb4mNKdw4SdQLLK6tuIvesnUEoAWqYvn8aoDzSDQJ4JjCgIq6k RZwKGXcVdlGOEpb1Bnb7AkdR9nynFs+tru49nFMz9MTU0id8alkdtFcUoag42MflvkuX G8Fcef52GcMdVNuNbHR7KX65AVZRa5xwbwvV6D/TrdNMka4VvozafXTkLRtPN0FX7reJ MrMRH3Uz9XSgFLU2fFTAAj4fhkADcIpOnHvlp3SBpsXElIned5A68EZYCnmoBScS2Lhz WJIlatdux8ShRol8kZyUHwQLu1BjyYZ9Wg4UWDXidF61Yi8N/YVAV4VcqS2ixl6QQ2mP EIHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=F5GwlfJYisOQKCKMx3zc/ou2d69INjiayUdqCeMaXT8=; b=xoS4FOcKDViyVvo6WGHPce770L5HVyPCeXveK3TKxjJQejNWnjyquUCJ8KN82sr5uv ZGWJcbAb7MaGtbwLK6MbWfMMQ1HB2i29tFHOLMh2yNRGxD9ZkNrrh+4rD5LrGwq7uIZq ZQBA33vau34rylN5d9nhcI9cnU6ccITqUJC56YWOoerxjPM5oABhcMEyxK5ddwTkxajk 0h6Z6NeULHjPIK3GgZoM9EzYBErczZGMIn82DcWVSfiaoEyevVCs/2rfx9M0Oiivdr+z Zsx9R4HirlS4yaVpCZeU89sB2fIDYrtAyTaRmvTRKjiKQGYHq40XWkPR3dfMIw7magj/ mU+g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si18382571pfj.137.2018.10.02.15.44.14; Tue, 02 Oct 2018 15:44:29 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbeJCF33 (ORCPT + 99 others); Wed, 3 Oct 2018 01:29:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59282 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbeJCF33 (ORCPT ); Wed, 3 Oct 2018 01:29:29 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E46CACBC; Tue, 2 Oct 2018 22:43:48 +0000 (UTC) Date: Tue, 2 Oct 2018 15:43:47 -0700 From: Andrew Morton To: Jia-Ju Bai Cc: mark@fasheh.com, jlbec@evilplan.org, ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs: ocfs2: dlm: Fix a sleep-in-atomic-context bug in dlm_print_one_mle() Message-Id: <20181002154347.01e026b4e644d6b7efc76180@linux-foundation.org> In-Reply-To: <20180901112528.27025-1-baijiaju1990@gmail.com> References: <20180901112528.27025-1-baijiaju1990@gmail.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 1 Sep 2018 19:25:28 +0800 Jia-Ju Bai wrote: > The kernel module may sleep with holding a spinlock. > > The function call paths (from bottom to top) in Linux-4.16 are: > > [FUNC] get_zeroed_page(GFP_NOFS) > fs/ocfs2/dlm/dlmdebug.c, 332: get_zeroed_page in dlm_print_one_mle > fs/ocfs2/dlm/dlmmaster.c, 240: dlm_print_one_mle in __dlm_put_mle > fs/ocfs2/dlm/dlmmaster.c, 255: __dlm_put_mle in dlm_put_mle > fs/ocfs2/dlm/dlmmaster.c, 254: spin_lock in dlm_put_ml > > [FUNC] get_zeroed_page(GFP_NOFS) > fs/ocfs2/dlm/dlmdebug.c, 332: get_zeroed_page in dlm_print_one_mle > fs/ocfs2/dlm/dlmmaster.c, 240: dlm_print_one_mle in __dlm_put_mle > fs/ocfs2/dlm/dlmmaster.c, 222: __dlm_put_mle in dlm_put_mle_inuse > fs/ocfs2/dlm/dlmmaster.c, 219: spin_lock in dlm_put_mle_inuse > > To fix this bug, GFP_NOFS is replaced with GFP_ATOMIC. > > This bug is found by my static analysis tool DSAC. > > ... > > --- a/fs/ocfs2/dlm/dlmdebug.c > +++ b/fs/ocfs2/dlm/dlmdebug.c > @@ -329,7 +329,7 @@ void dlm_print_one_mle(struct dlm_master_list_entry *mle) > { > char *buf; > > - buf = (char *) get_zeroed_page(GFP_NOFS); > + buf = (char *) get_zeroed_page(GFP_ATOMIC); > if (buf) { > dump_mle(mle, buf, PAGE_SIZE - 1); > free_page((unsigned long)buf); Fair enough. It's pretty sad code here, replying on the page allocator in this situation. But it's only debug stuff so nobody is likely to care much. (And that page didn't need to be zeroed!)