Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1124355pxx; Tue, 27 Oct 2020 08:48:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo7H0Tm2CppR1zrzow7kny0vcYctMIEPFIE47TMEKqjVh3fr56zXJJmKc2qQgj9kMNW2Mg X-Received: by 2002:aa7:c7d9:: with SMTP id o25mr3018628eds.318.1603813716362; Tue, 27 Oct 2020 08:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813716; cv=none; d=google.com; s=arc-20160816; b=mLLSzhA9Vlk/IRXFswjJsOU3BIzbPVnPs8qxYhUAqmqpBCjacUsID/lVJVSUlkXfc2 AJ0UEjq1INjF6+7/Fe9WYu9QsIlSuhqXuPsyd10RxuWfpKKCiNddjy+16XaEIAx1WPc8 kPR7polL0UgDh/cvfKkessj/l4/a4IdUqYW1vhHEQ+B0vk9oY3E6HX/uTzWzeE1478eY Sy/+0mrSI84g3pZNQcenVcVhJ0BKw3N8TMhZaX/d6Rs8prG0lRqlx8o+Gjxxaby7bhDX EpHN04hBBM54Zacz/pPNfC7MqQQFe7o4KzA54xPH6sZiaF8oWkeGKQ3khBCkx+UAqlfb IfXQ== 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=YmiL2ALQCBvFl472RhcNhabqT6TtMPtpVG79cJao5ZQ=; b=tHC7qJGJjl7nZf/8Q0TOt4tONMBURn1L9vOGkLtYAb6wYCkSmzWFuu+9Fv6wxuGdnT FBUD/GYlzNSDGlJ0kYAC8M3mbmLC0d8Fb+D9Hu+B1yfeXPaeKf8ELpD5DEueotEobtWd 0IrYi0krL/Y6QB9H1XVKOBjBR7VtIkrXBd/ZnhJUwZTkxWNhQMJ+MCgrbh9qiSsMsNew VWCkXQBJVdMWrop2AitrPvmgxNh8zHyC8VoAjzbhxRm44uTAKTvspyhts17OmTBdXwbF tPVc04z3UflQ567WyBRdwrAMaZFeLtrQwbpaJg+bZv+k/Dlpv1JhADa8v0H3u7K8Wcq3 +5rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AzOFhNpr; 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 l12si1158416edk.163.2020.10.27.08.48.12; Tue, 27 Oct 2020 08:48:36 -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=AzOFhNpr; 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 S1752741AbgJ0O5V (ORCPT + 99 others); Tue, 27 Oct 2020 10:57:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:45626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763964AbgJ0Opo (ORCPT ); Tue, 27 Oct 2020 10:45:44 -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 70FEB206E5; Tue, 27 Oct 2020 14:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809944; bh=pczS5DlWXVa6fiIHMoBSKiiTtWrg4VUKcYl1CkNJuok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AzOFhNprI73cIuIoLj7ApcS/jKMJA8cwWSqQ4xU6cmRsCL9kseesA24/XNLSyspeg k2MsEFQH129f5vYi8vCX5k9j60jHa8PTao/h5MwzYaLMCylszYFmE5X3RxrWbz2u59 pvlVYPtZf7cqaTrKkkmJHeK2X8a3KyG0Wo67vH+Q= 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.4 374/408] iomap: fix WARN_ON_ONCE() from unprivileged users Date: Tue, 27 Oct 2020 14:55:12 +0100 Message-Id: <20201027135512.352207543@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 7b5f76efef02d..8c98fd92bf665 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -377,6 +377,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