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=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,LOTS_OF_MONEY,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, USER_AGENT_NEOMUTT 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 8EE49C43381 for ; Fri, 22 Feb 2019 14:47:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6425C206A3 for ; Fri, 22 Feb 2019 14:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726325AbfBVOru (ORCPT ); Fri, 22 Feb 2019 09:47:50 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36320 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725978AbfBVOru (ORCPT ); Fri, 22 Feb 2019 09:47:50 -0500 Received: by mail-wr1-f67.google.com with SMTP id o17so2679702wrw.3 for ; Fri, 22 Feb 2019 06:47:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=o5CN6FawEI8TlFD8oHKDqQL+JDLwuuFIB4WVAiMNW3Y=; b=RDzQNAto46UzGBb/mK4PRmvWPrh8Vt7pPiqPCOiaNHnQQOpqbPa35Xt+b2AmscS9r0 1HSaUVG6quKCcP0WoQmE50vgp0a5XoCIO5WPHI5bqGE1DnMSiqTuE8FY23uHWqBwG4Bn dzFI57tJu5yjPPddopHxcDjOD4T8NyNkMD2sBQPWxiW07fMYvUKZY1c7lrm0OiThAyRa M6GlJvGvXgbwaj9yTdEfu9thNmb6mN/0MxHqaqOmpq586GPzCDV2gxPT9jEQbPlsUjKx q4qhygxhR+8/249ZAZFlTTHRsjAAi2umk6Lu0FJLIb03fqSlF3DTXCIwlHcWi2wF4oYp IlJg== X-Gm-Message-State: AHQUAubHXsn8eawupG0eW9uXZHBoFyvpnWAtfS80ooHvt+S3zv69QPpZ uMH2kTMDNNjPi6vTEgmTX9OwzWpX+TE= X-Google-Smtp-Source: AHgI3Ibuf3BcJe0GkIe0TRwn065JdQ0KgbJachsouuekaXzj9eq7yHYG4wahaMwPmLzszbQuR7ixNQ== X-Received: by 2002:adf:efc2:: with SMTP id i2mr3232590wrp.44.1550846868679; Fri, 22 Feb 2019 06:47:48 -0800 (PST) Received: from hades.usersys.redhat.com (ip-89-103-126-188.net.upcbroadband.cz. [89.103.126.188]) by smtp.gmail.com with ESMTPSA id n2sm2124135wrq.58.2019.02.22.06.47.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 06:47:47 -0800 (PST) Date: Fri, 22 Feb 2019 15:47:46 +0100 From: Carlos Maiolino To: linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fs: fix guard_bio_eod to check for real EOD errors Message-ID: <20190222144746.vwre45gnl5gkvqvr@hades.usersys.redhat.com> References: <20190222141311.24694-1-cmaiolino@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190222141311.24694-1-cmaiolino@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org > MNT=/mnt > IMG=./DISK.img > DEV=/dev/loop0 > My apologies. I forgot to mention I had ./DISK.img already created in my working tree, it's a simple `dd if=/dev/zero of=./DISK.img bs=1m count=20`. The image should be slighter larger than 16247280, so the FS attempts to step out of the device. > mkfs.vfat $IMG > mount $IMG $MNT > cp -R /etc $MNT &> /dev/null > umount $MNT > > losetup -D > > losetup --find --show --sizelimit 16247280 $IMG > mount $DEV $MNT > > find $MNT -type f -exec cat {} + >/dev/null > > Kudos to Eric Sandeen for coming up with the reproducer above > > Signed-off-by: Carlos Maiolino > --- > > P.S. I'm not 100% proficient in bio internals, so I'm not sure if this is the > right fix, so comments are much appreciated. > Thanks > > fs/buffer.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/buffer.c b/fs/buffer.c > index 784de3dbcf28..32dc5cd2f6ba 100644 > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -3063,6 +3063,13 @@ void guard_bio_eod(int op, struct bio *bio) > /* Uhhuh. We've got a bio that straddles the device size! */ > truncated_bytes = bio->bi_iter.bi_size - (maxsector << 9); > > + /* > + * The bio contains more than one segment which spans EOD, just return > + * and let IO layer turn it into an EIO > + */ > + if (truncated_bytes > PAGE_SIZE) > + return; > + > /* Truncate the bio.. */ > bio->bi_iter.bi_size -= truncated_bytes; > bvec->bv_len -= truncated_bytes; > -- > 2.17.2 > -- Carlos