Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp390754pxx; Wed, 28 Oct 2020 07:18:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9FbbM12F45aZzZhMSPDXd6qlUlxrBLIZfY5XS1ae2eFWusKML5NZmIAGIMVDyDZacypbL X-Received: by 2002:a17:906:2f97:: with SMTP id w23mr8113868eji.54.1603894734576; Wed, 28 Oct 2020 07:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603894734; cv=none; d=google.com; s=arc-20160816; b=eD5qYxtlkKIcYznUFBMs4gLk+ghTmNGm1tbWjPQVnbFPjb0Z6IwfOOZOS/N4Z7j6jS mmXyFpERAj2h8QCb4cuMYZDGKSkWRCwKuceIOfv2dIXme6bxeqOF1C15ow7Ga1gVxFr3 tu9krfyu33GLrQ5nc1acW0t4XgNZZgIHGatUBXaTm0bZLjHI7C5Kg36+BCxdJiwJUVPr NCSdMz/B4QG+HisL3H10j44GFwcMXH8kHUPWONuGmBEaBXuIFlCE+x83obTrOK/1G6P5 hyRVbZ7eHoNHMD8ZWDPbgWLPn9aI5XWDCXcUQboF80fTnrDGgoLTPS31KvIyS8G9zizl ANjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2YAgcJIZl38UC8UIcRDt71nggqbWqpAtOfQYjs1gikk=; b=IR8k6zWN1ptdYykJUgg1ye9DeEIbOGcXT92Qihm62M0LYl8NM07VO0tutrgJvcTbVI 9ydU33oRIgZrsouyA0rDT+mzRwbcJvyWHa5jkiPHG9cArx54ns+pDpNqnEMfErQipQyQ 5GiyIsanBMw5IL8jL1aTmghrSD5nm2TXav4+aPzvtgGFnI80V72jTm9Fu315+mKPZVwg Pa5+krq+MQIdgGsLFG4nbXcHkigoSO8vqaNQeN8aLroHIwLyuKDwOP2/0vCI90I+znkv aG66+UGCJZo5nF84/M6almZTccy+VhKdIOjVrs1oz4QvekwuJJ+cr9ik2+cEIU9FYcai BjJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ecGfPxLx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr1si3058858ejb.164.2020.10.28.07.18.31; Wed, 28 Oct 2020 07:18:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ecGfPxLx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1805196AbgJ0QAj (ORCPT + 99 others); Tue, 27 Oct 2020 12:00:39 -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