Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2390418imu; Thu, 29 Nov 2018 04:20:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/XXG56vZS1xGJ8QKyt5gaHER/ODl0e4DLwMghzJxYmuwx+2eCG8vB/4cyJL+juaSKsO6hkt X-Received: by 2002:a62:1709:: with SMTP id 9mr1138206pfx.249.1543494052754; Thu, 29 Nov 2018 04:20:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543494052; cv=none; d=google.com; s=arc-20160816; b=MZrEyw/QBECG309Q/8PKKhqg+L0ZquiXYE/gU7atmlOrxS15tiLo6dBRzJB5plIs/i pvBVQH5BaZEHN7Zp5F5bwc5YKDsDJenyC1nLx/mXifMnXHNujsvSj3k+fRi0i7WSRYsH ephSvGcq9rW9pGdlNmo7Z0f8Yaw5/0zH3oXoMNEzYDlhRo3GHF8Vf8v2UcLxZujuQqej E9eIjSAjWd/nSKaG5pi2AQ2meftH+ZP9laJePoXYmOaisY6S4OLw8QRKzTUhZ6mxuMY0 vsuOr+5IQaQU1B+UbLeSeJlQXhy3tlwZMmVY2FggprqUVXC5nRawi0NFfhEnyT6cBpDj 14XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XYNZZjQ5vfpMwe5QCl4QtsYX1g5NSWBnF3hPR1d+PzA=; b=wH+LV0ReB86n2y6Y1jZua3yO1Pit70ooYRQCe0bgVX1lT+KfuhNeTKUGsnBL/XUgVY KLABYF4cvP+QOnmMiGMoPRa/jZr3ugU6aa5grbHVdr6RN5flTqJpMGcxVc9QJNNJv6LT 69OxriAYKA42/wlpaEVNPtPFY1B03vRb5oGplh7MlZRkjZ5Wrz0MgDbdD4h71UPp8vYu zrAFmFkoJheHNia8r/qd+U9OmmnWPxAWU8BJNAVCRIsFS1gMYv2BDASLcoDkMRnmrrA4 DtMZkMyIAnw6oB9B9bvZp0bfPz2Yee7RHNVQqL3cuVoVUaB7Je/rcnuuJiDhWbnqMH+u lnmQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si1955326plt.68.2018.11.29.04.20.36; Thu, 29 Nov 2018 04:20:52 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728261AbeK2XYg (ORCPT + 99 others); Thu, 29 Nov 2018 18:24:36 -0500 Received: from ipmail01.adl6.internode.on.net ([150.101.137.136]:52910 "EHLO ipmail01.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726683AbeK2XYg (ORCPT ); Thu, 29 Nov 2018 18:24:36 -0500 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail01.adl6.internode.on.net with ESMTP; 29 Nov 2018 22:49:23 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1gSLHu-00065Z-JD; Thu, 29 Nov 2018 23:19:22 +1100 Date: Thu, 29 Nov 2018 23:19:22 +1100 From: Dave Chinner To: Sasha Levin Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH AUTOSEL 4.19 52/68] iomap: sub-block dio needs to zeroout beyond EOF Message-ID: <20181129121922.GL19305@dastard> References: <20181129055559.159228-1-sashal@kernel.org> <20181129055559.159228-52-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181129055559.159228-52-sashal@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 12:55:43AM -0500, Sasha Levin wrote: > From: Dave Chinner > > [ Upstream commit b450672fb66b4a991a5b55ee24209ac7ae7690ce ] > > If we are doing sub-block dio that extends EOF, we need to zero > the unused tail of the block to initialise the data in it it. If we > do not zero the tail of the block, then an immediate mmap read of > the EOF block will expose stale data beyond EOF to userspace. Found > with fsx running sub-block DIO sizes vs MAPREAD/MAPWRITE operations. > > Fix this by detecting if the end of the DIO write is beyond EOF > and zeroing the tail if necessary. > > Signed-off-by: Dave Chinner > Reviewed-by: Christoph Hellwig > Reviewed-by: Darrick J. Wong > Signed-off-by: Darrick J. Wong > Signed-off-by: Sasha Levin > --- > fs/iomap.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/fs/iomap.c b/fs/iomap.c > index fa46e3ed8f53..82e35265679d 100644 > --- a/fs/iomap.c > +++ b/fs/iomap.c > @@ -1678,7 +1678,14 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length, > dio->submit.cookie = submit_bio(bio); > } while (nr_pages); > > - if (need_zeroout) { > + /* > + * We need to zeroout the tail of a sub-block write if the extent type > + * requires zeroing or the write extends beyond EOF. If we don't zero > + * the block tail in the latter case, we can expose stale data via mmap > + * reads of the EOF block. > + */ > + if (need_zeroout || > + ((dio->flags & IOMAP_DIO_WRITE) && pos >= i_size_read(inode))) { > /* zero out from the end of the write to the end of the block */ > pad = pos & (fs_block_size - 1); > if (pad) Same again - what's the test plan for these cherry-picked data corruption fixes? Cheers, Dave. -- Dave Chinner david@fromorbit.com