Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp859095pxb; Tue, 1 Feb 2022 11:55:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+M4DHsLSD3BeBImLAaBdwvC9ZE8SdbP5FlyBuaw2xEgBlGxoygx0VJuM1Eutimkq7hBf3 X-Received: by 2002:a05:6a00:2355:: with SMTP id j21mr26755104pfj.50.1643745329134; Tue, 01 Feb 2022 11:55:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745329; cv=none; d=google.com; s=arc-20160816; b=pkbP8Vz0zBEeEwMQA6L3LNuEElvrS+WxTBl14/0SDwkCyb91lGqsTwax6qMciGboyf eNKm95fLR4qc4c6veGy5VPi7pCrw0mMixX4UkuPAtwOCIEC1x+sN4BkYNiJwFGCjIMJp cy2ywvaggUHuBfMeS15UDSeMs4fUEpxihIRB+3FNvUV7UYRlaQxp6I78Bvu9HlhiSuK7 aFsGcsBCKViDI1GjpR3bP+oQ1d6ZwCiIEUERQM/oStzmiGqeco46e5R3lfaATPMvyVWS 6SqdK2VzMQvcA8JroBUNbfArBTOfZjsP89PDknaLgt8XMC+kpsTm2/thA8ReI7vrKq23 cz2w== 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=m7eatYuiCLwuxgAPfbSzUPNzOOVD4xveBgRe+EgJo70=; b=rGCu86xFMI1p1bx+Uakgxf0QjJdWVLmXR8UEIz62tpLeVORpKaK9NPozt63XIS2kRI 0f0CPx59MGo4f6HLXhuACsLvMXyzpMMgfBAY/+LsR73QeJQtDjurZ38EwIUGcPGldoLO IpUUKWoA4/oAaZ1FTTnmFJ5JYTVtCIUvZh9Au6GQrbe8vamoTQ0go7OFW7vtJFlYz9aw vpy//KFrOkHTp+vOvAKXsDMZMHxiFkk4EIThwuyaU2rE3DSgzERPh8Zyv5jeUtBQFxzD Aoy8E3j/liwxXsqlwdw5B4MT+gqaKDKpiXXAlWamksVgqR7djScxv/orQatKKncct92E pwJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wXvRjVIC; 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=pass (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 j3si19801723plr.559.2022.02.01.11.55.17; Tue, 01 Feb 2022 11:55:29 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=wXvRjVIC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359333AbiAaLFM (ORCPT + 99 others); Mon, 31 Jan 2022 06:05:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359062AbiAaLCx (ORCPT ); Mon, 31 Jan 2022 06:02:53 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE126C061777; Mon, 31 Jan 2022 03:01:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B8A6AB82A65; Mon, 31 Jan 2022 11:01:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD9F4C340EE; Mon, 31 Jan 2022 11:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643626864; bh=4vgkwUN3HLgTHzDFntrtt0VQKHQcx+ZIF7bDA5iyJlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wXvRjVICtI8jbv751SLuxm+wqSEpEJL+/SNs8rjew4jKXKkzRAGxKS6QquGobhmMQ mwz/bwe4VKaHwkLs12Ura4DUMI+OTFvzkZu0dBTQM+cj36qz9WiW+2ZhTkDiC0/lr5 wuKDoQDCzkDdrLHLfiAuk6QV48TSmz8Rn2RjKjt8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+ac94ae5f68b84197f41c@syzkaller.appspotmail.com, OGAWA Hirofumi , Ming Lei , Jens Axboe Subject: [PATCH 5.4 64/64] block: Fix wrong offset in bio_truncate() Date: Mon, 31 Jan 2022 11:56:49 +0100 Message-Id: <20220131105217.821837502@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105215.644174521@linuxfoundation.org> References: <20220131105215.644174521@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: OGAWA Hirofumi commit 3ee859e384d453d6ac68bfd5971f630d9fa46ad3 upstream. bio_truncate() clears the buffer outside of last block of bdev, however current bio_truncate() is using the wrong offset of page. So it can return the uninitialized data. This happened when both of truncated/corrupted FS and userspace (via bdev) are trying to read the last of bdev. Reported-by: syzbot+ac94ae5f68b84197f41c@syzkaller.appspotmail.com Signed-off-by: OGAWA Hirofumi Reviewed-by: Ming Lei Link: https://lore.kernel.org/r/875yqt1c9g.fsf@mail.parknet.co.jp Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/block/bio.c +++ b/block/bio.c @@ -569,7 +569,8 @@ void bio_truncate(struct bio *bio, unsig offset = new_size - done; else offset = 0; - zero_user(bv.bv_page, offset, bv.bv_len - offset); + zero_user(bv.bv_page, bv.bv_offset + offset, + bv.bv_len - offset); truncated = true; } done += bv.bv_len;