Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4848488pxb; Wed, 20 Apr 2022 11:17:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT5BD/YzC4jfUe2MkGVkLdfe1GkccqdP5bBbHNG46wjeiyoXNScZ+pBhbgs1DQoSSPSc4g X-Received: by 2002:a05:6a00:4211:b0:506:5061:3e38 with SMTP id cd17-20020a056a00421100b0050650613e38mr24514989pfb.74.1650478655221; Wed, 20 Apr 2022 11:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478655; cv=none; d=google.com; s=arc-20160816; b=o/y62tZYXBMCBKWQCLakQ3cuSkBf7oLAHHzj/POEl/gawPpgLlJBNVtcI3XBa/SKXU w3yXWYp0IQorG+3wXaWtD6MUeFzsG3TFA8L708d8+bYTtpT0YU9NlWd5bBqI1p8Hj3cy JxBD7nPC1YXu3vT/SHh3xSqYhjP8WRD9PyBme2NYTrOqF1Ah0OHvaasVWPpMUn0yRBjQ wfNGd0nDFeQUx/HrD4Obz9EoDOhd4a5aDok6ADV0csIUts6APdEKaPecaHlflBfmU7Tx S3OFCe7pVEZZe1OQAhvNIfvOjHxEzL12OagB9qXyT5YU4BPdTZSrjEk2lmOwNNInfsSu B3bg== 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=7vsnFxZUazHY7Pn7tdmoevLtC/tC/uZZcMiik3Ik2CI=; b=UbzoGPtmbXJdUbn54kKqSIqDol2nrMUyKlWI10B1zyCZ1wpDsSsIYTgBRIletLWAUS zLsRbzrPhKYE614une1bAT/y8OFk5yjByf95pabEIJZiHNLqwbTXNh8bla8fF/Zb6jr9 8gwf0lr1gMttovuTuHQXBk5bOnYccVqXVs4MCrM/3fjhZMkuxvmfMu+VMKpxxeCfgHnw 2mb7ktsK/esbQfjT+LkX2+6YYkSkPK5NtidaZMnC8Bgq+IO5uYcBw3DqxUgm5w7tSX+P yMcQstwF8leDbusmoZBNlt+9dE/drC2IJc94+MAaj6VcE8zFxNvG3lXwTXD14DHSaEbW 6Q4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vD1tO03k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u21-20020a056a00159500b004fa895878afsi3097547pfk.254.2022.04.20.11.17.16; Wed, 20 Apr 2022 11:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vD1tO03k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239110AbiDRMeX (ORCPT + 99 others); Mon, 18 Apr 2022 08:34:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239052AbiDRM1l (ORCPT ); Mon, 18 Apr 2022 08:27:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 604101EAD4; Mon, 18 Apr 2022 05:21:13 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 7CD5E60F5E; Mon, 18 Apr 2022 12:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87021C385AB; Mon, 18 Apr 2022 12:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284472; bh=HBOleFK0d5W1x+uOvPz9btdF/LbqfYF/mI57FVMzAdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vD1tO03k8z9ddJcjj9RSRPAJSgRDmzd/j8LSCVQ4Cnu88B8tjaFUO7pIxd4pesDMk cY2EmXII3yZoi77Pgj42g1qEXAM6n1XkceWsl70voFe/TNArdoqM1ok4VDH1qvNbBa 9465AtOStMk8DcT6w66AtmR1GLI60/CQGHmr8hQM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitanya Kulkarni , Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH 5.17 126/219] block: fix offset/size check in bio_trim() Date: Mon, 18 Apr 2022 14:11:35 +0200 Message-Id: <20220418121210.423946873@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei [ Upstream commit 8535c0185d14ea41f0efd6a357961b05daf6687e ] Unit of bio->bi_iter.bi_size is bytes, but unit of offset/size is sector. Fix the above issue in checking offset/size in bio_trim(). Fixes: e83502ca5f1e ("block: fix argument type of bio_trim()") Cc: Chaitanya Kulkarni Signed-off-by: Ming Lei Link: https://lore.kernel.org/r/20220414084443.1736850-1-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 1be1e360967d..342b1cf5d713 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1570,7 +1570,7 @@ EXPORT_SYMBOL(bio_split); void bio_trim(struct bio *bio, sector_t offset, sector_t size) { if (WARN_ON_ONCE(offset > BIO_MAX_SECTORS || size > BIO_MAX_SECTORS || - offset + size > bio->bi_iter.bi_size)) + offset + size > bio_sectors(bio))) return; size <<= 9; -- 2.35.1