Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp866189pxb; Tue, 1 Feb 2022 12:03:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJziJklBEFqcQZLFe4rzjW34j5QvsbVl45pvVNXlE8jsCk2wQhZy3kHbJhaKbqZIHud2JZIJ X-Received: by 2002:a63:6b41:: with SMTP id g62mr22030832pgc.538.1643745817189; Tue, 01 Feb 2022 12:03:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745817; cv=none; d=google.com; s=arc-20160816; b=O0TMN2pDuNH1lhjd38Cw7pWPNKajXZSaCgtaVDzQ3o1xfdPRRuLwWKNN+DlGC0C1WM UNfyaLnkRlEOH7HGDhSdti6SELtg1rgSUUwPcKM0PD5UVGEulcRnb4pTdbOhHHOJ6Do4 mR2B9b/ytJETSdBmjuslnmpSlvSX5Td4ll9BAK7vAW/IuzYdnjiT96LVu3OpO0O0q1/Y sisjXnr2U6cZY0f0VSM5Ksi196up3TLLsHzgQLSCxXiGy74YoHmgkUOog6rqfDrY1Poh qFBM/SEaQ+z3SojlO00QjS8dUKIeu8YomO3n8VJBVz/KNdA17MT11Hq1eA9PvuMyC2K8 5jww== 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=ruPgghS4ZKdHzqSmdmPo2f1gWCyW5c35U2oFcMF+UBc=; b=Fgmqm5qZEZocRNjUT5YcQLshm/h0ZzgyIW9y5eu1mj7eF07aO8L6clw5nlHncK2XYL 2yKtjvJPguqJksBoX/tNu9ygSjJubMCt95xO5aWjT030cbKWBw54wTdolt2qrMxRFLCS solJIxyarKy3TVyhsl3UEOgIZX2NBuz/fbYmhmTFANCeQLkCf4fkvuM5B5YkrQk3Z8uQ AOpukWnoiz+1nMtkdtJyLQLZBBQm5Z3hKo1pZD9g5j6t5gTBPoi8nHqYM0439sIqYMnC cpKG9DRmWgsF0hogMsFUugJ9n/LN+t0HdjtlerqXsHvYoFfIL4nzZqO03UkqCQxLITv4 4uDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mjsVgmoH; 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 mj9si2182613pjb.97.2022.02.01.12.03.24; Tue, 01 Feb 2022 12:03:37 -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=mjsVgmoH; 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 S1359432AbiAaLQw (ORCPT + 99 others); Mon, 31 Jan 2022 06:16:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377159AbiAaLJp (ORCPT ); Mon, 31 Jan 2022 06:09:45 -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 E3B2EC0604C8; Mon, 31 Jan 2022 03:06:26 -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 B0B68B82A5C; Mon, 31 Jan 2022 11:06:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F370DC340EF; Mon, 31 Jan 2022 11:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627184; bh=JJG8FPMAU2MXhrU12vj6pVtNxghJpIL8qz7OMrp+rNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mjsVgmoH7vgvJnyuW+q31Ta9StpGAWD83p2KwzZZie4FfneblOsBKYP2QKSJWNXpe Oh7yXuXxlI1OVzdlqt4nJdu4nLKcHc3g5TAgc1y9FJnW8KX1i0k8DrvUGQ8BviCriN xybWx9qJ6GMeo5KySxMvLOQ496OjlPgmL482DNNk= 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.10 100/100] block: Fix wrong offset in bio_truncate() Date: Mon, 31 Jan 2022 11:57:01 +0100 Message-Id: <20220131105223.808036007@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105220.424085452@linuxfoundation.org> References: <20220131105220.424085452@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 @@ -575,7 +575,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;