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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 383B0C64E7B for ; Tue, 27 Oct 2020 16:02:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E84DE20657 for ; Tue, 27 Oct 2020 16:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603814520; bh=mSnEMt0wZBdP23QbnAwNuHi2Lus+8y0UzZ/0+xcpOZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jtuR9Air9S+M72q9f9BnbNkt6ZvJRstDFxQGI3Om4PF6C6ireXgWI68lZWx5azsxS 2eNO/v6BWSuZDBEpxgnTMtFWOXiQE4CtiAmS5Oo4IxZBQ62oXG2JPnh8GHwv10Sosk Fqi+T3Qwy3ZqGe3ZNc4EgU7/sRLKq0BYVMDhvtV0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1805204AbgJ0QAl (ORCPT ); Tue, 27 Oct 2020 12:00:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:52262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1795679AbgJ0PPT (ORCPT ); Tue, 27 Oct 2020 11:15:19 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0FC0220657; Tue, 27 Oct 2020 15:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811718; bh=mSnEMt0wZBdP23QbnAwNuHi2Lus+8y0UzZ/0+xcpOZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ecGfPxLxdrfBU9q9BpyiQhWmPXFGJIh+mcMZljBupLzea59vkfrBbpprhm50zdaoP s0GEIgovJ7JU/FewiQsWD+n15zt7AJ2MOAvk7Z2hg5lMUabQSLoNOFxNwl/Nrs+zer rYGgyUi52tiEs6HrQYMcZA5nyu1XsinZfFuKYTFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qian Cai , Christoph Hellwig , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 5.8 593/633] iomap: fix WARN_ON_ONCE() from unprivileged users Date: Tue, 27 Oct 2020 14:55:36 +0100 Message-Id: <20201027135550.638920129@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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