Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp734233ybc; Sat, 16 Nov 2019 07:46:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwrlDisAex7/syINz9PLSh836NjPTAdEQ4IjlRa7T0zSlodASesd2GYKZKgbH703yuT+3NB X-Received: by 2002:a17:906:9248:: with SMTP id c8mr10915563ejx.47.1573919194752; Sat, 16 Nov 2019 07:46:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919194; cv=none; d=google.com; s=arc-20160816; b=TkTn8jbmrKMngW/2xHDA7GsJxqyiqYlUhmubr6jUgSfGTL3TIt7UyfAVG7TaLDu5II ByrpmVk8oHcWR5WJPPRWqLhVmepi127NoGzws4AeGTLM7X9paOo0/rLn7fxYM+CJy/Uq 4DOO9VXkxTV6l9MA/8VFPSdbaQpxlx0JNFYKDXNwcs1FpioEOfx9geXLan5KpOLnMFlw 7+g/YN0XQdCXPCK04ejmCo0sDAsI/N4QqKPJEo5AEyra+z2xzmRv+Kqx/3N1dPc0Sfr5 D975N1x/fv7BD/Xg0vcndChJdAI2MHvIQP/CImMKnjhVjOpQrer3GJ3JvwJy1N5ot9tn UBMg== 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:date:subject:cc:to:from :dkim-signature; bh=ygOXM9a+gqJp2Ottpn2zOcyInSlims2N1EokpXS8oXI=; b=hKyrVE7iYemocdmwdH9g21C2nCml+ws62LwK41n+tEX5RN1Kufs7TO9u0qvTcqxMdq JzeTWC3/MhHr0vcd47ruS4GZZcK1oKoERLnfnR7P5BvFYP3gIgFPAVXFZQW3Z9jxixXN 8ueNhX1xUYTWgNp/D+7TGTYpTBIg9s534t72bFzLkWv/AuQ4LMHooCa0y7Q43f0PMXax P7EThXSoLwZgsqFqZQoG/amwXJJf3tPT1DrXfvcQnMPPyKEzKRLabMSouV616XYVgJXL MrlQew8EON4fPHPkechpBfAQYtvkj682w+8WjEztPcqFo8Bq/rZHJ0Fgn4gbKBGxppMJ iGVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MJpahdwD; 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=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 v23si7774711edy.287.2019.11.16.07.46.10; Sat, 16 Nov 2019 07:46:34 -0800 (PST) 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=@kernel.org header.s=default header.b=MJpahdwD; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728910AbfKPPoP (ORCPT + 99 others); Sat, 16 Nov 2019 10:44:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:48698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbfKPPoN (ORCPT ); Sat, 16 Nov 2019 10:44:13 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5E242072D; Sat, 16 Nov 2019 15:44:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919053; bh=d9nxKcst+qQU3OV1rFInKjs+FqAyZY6FfLLPYATbVhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJpahdwDRw4kEcMdqPMtCEcOKt8Ht5zr6xxmKknL4uXHA0RSHw8igCIHJCGaOMHL/ ItDQtdDBgVALVxqoCRw1fVRL/uxWseic0YTgcrZeljprCA4vcpLpgbeRP9Z5lTSmjF 3jtbTBc2ZcmWOGM3J4MhoSzx2cuYUbW5YCDJmfxk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jia-Ju Bai , Andrew Morton , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi , Changwei Ge , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL 4.19 129/237] fs/ocfs2/dlm/dlmdebug.c: fix a sleep-in-atomic-context bug in dlm_print_one_mle() Date: Sat, 16 Nov 2019 10:39:24 -0500 Message-Id: <20191116154113.7417-129-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 999865764f5f128896402572b439269acb471022 ] 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. Link: http://lkml.kernel.org/r/20180901112528.27025-1-baijiaju1990@gmail.com Signed-off-by: Jia-Ju Bai Reviewed-by: Andrew Morton Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Joseph Qi Cc: Changwei Ge Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/dlm/dlmdebug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index 9b984cae4c4e0..1d6dc8422899b 100644 --- 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); -- 2.20.1