From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLACK,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AACF4C433DF for ; Sun, 18 Oct 2020 19:48:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77FA222268 for ; Sun, 18 Oct 2020 19:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603050536; bh=mSnEMt0wZBdP23QbnAwNuHi2Lus+8y0UzZ/0+xcpOZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lP9hxOr0CT+sIWFVdAa5Ox0qT2WuCOtu28wKOavr/NQMNIhRuicnp0uzU8LcaNYhM r9jbQqNTN0C9g7bRFo60R/ssemTLAhWwO/lQUPLb6dX2BQ6vKJwe9Pw7LMBAYQRmnW CsSl5Sv88ne2TeXCKMUeDDwGGtLNsDuLa/ipn8S0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387659AbgJRTsw (ORCPT ); Sun, 18 Oct 2020 15:48:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727667AbgJRTVv (ORCPT ); Sun, 18 Oct 2020 15:21:51 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 157C5222B9; Sun, 18 Oct 2020 19:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603048910; bh=mSnEMt0wZBdP23QbnAwNuHi2Lus+8y0UzZ/0+xcpOZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UX9TNnf3PyX2QI+SODi+vziLHoRhCuAE6ioW2fl93lxDLpWKRE2t/n8jUQkimAG3+ AsBuMxZ1rCPMhW4/2OBlYbZmP/YU225tqcZVhPhqFoMDAHMG7/8o7KoXgyovTflFKM peZ8hC+HIo2hnPGJA8urDu70eD5iHa3YQfiLtZ98= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qian Cai , Christoph Hellwig , "Darrick J . Wong" , Sasha Levin Subject: [PATCH AUTOSEL 5.8 070/101] iomap: fix WARN_ON_ONCE() from unprivileged users Date: Sun, 18 Oct 2020 15:19:55 -0400 Message-Id: <20201018192026.4053674-70-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201018192026.4053674-1-sashal@kernel.org> References: <20201018192026.4053674-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qian Cai [ Upstream commit a805c111650cdba6ee880f528abdd03c1af82089 ] It is trivial to trigger a WARN_ON_ONCE(1) in iomap_dio_actor() by unprivileged users which would taint the kernel, or worse - panic if panic_on_warn or panic_on_taint is set. Hence, just convert it to pr_warn_ratelimited() to let users know their workloads are racing. Thank Dave Chinner for the initial analysis of the racing reproducers. Signed-off-by: Qian Cai Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- fs/iomap/direct-io.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index ec7b78e6fecaf..28d656b15300b 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -387,6 +387,16 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length, return iomap_dio_bio_actor(inode, pos, length, dio, iomap); case IOMAP_INLINE: return iomap_dio_inline_actor(inode, pos, length, dio, iomap); + case IOMAP_DELALLOC: + /* + * DIO is not serialised against mmap() access at all, and so + * if the page_mkwrite occurs between the writeback and the + * iomap_apply() call in the DIO path, then it will see the + * DELALLOC block that the page-mkwrite allocated. + */ + pr_warn_ratelimited("Direct I/O collision with buffered writes! File: %pD4 Comm: %.20s\n", + dio->iocb->ki_filp, current->comm); + return -EIO; default: WARN_ON_ONCE(1); return -EIO; -- 2.25.1