Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3288553pxk; Mon, 21 Sep 2020 09:46:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl8t1jz50QV/bRFix+L0d8ngnkheePPshNAtDo2O+dNwHKAua4MdZ7KRLSHLaezb75i9+s X-Received: by 2002:a17:906:6158:: with SMTP id p24mr330264ejl.35.1600706799758; Mon, 21 Sep 2020 09:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706799; cv=none; d=google.com; s=arc-20160816; b=Okhl+iQ9FDan46aQB/YEqiaihEeY5d+iBAPOEFKs3TTQSAM3+bc1FTU15+7vD319sY KSiUUHaDQmYGSkqNI2i5w6/25QxK58E4N5y8Am32x3/mzbqDnu3KSwMVI3piY3Jg5Mhg lrhhYEnY0fuBsB+e5+dyMMcb4EMqqUkcIMNCtEgWTao0Xzyq4xKPFiQyUXjKJt+3UJuU Pya+WC89EhdEKZBKBipPhaAKXff4iQxFtz0DZSZuqVwCHy14I73A177g6NWBiOT2YkKV kxIJJZQtUVyG7TOytw1PUmMvwFlfHdd3U46RGaamUgYBsGaXu/YiMpfQ2pbKu/D+g86p M4KA== 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=TEjNk5a/GZTTxB6LIwGVlrZPZOioi9rsqcjKaF77rmk=; b=k8pDYjI9zOriJaU3m4Ng/8NuAPEv5ROhL1m4z3uGDfliu80RFL40auykwlGiLVwP6I NW2hwuQ6EYw8zQdGANCc7Vpg51ILS9fG8orUAhQhIMNtm7zUH8w3gvkLglgIbXn9jZmU sD23tgCPqJYsVlcFweELpZ16fuzFw/6gQkVu7TJrSskfbYfXNvAaLGOybhv8eE2Ah0YJ syk66md8PqGa91urC/5o0cSYszHxAObLY+qYiHOCE8d/OMOJMJCOG/ZlRS+OC3IW3tKG Ogo69bmaWOh8MNLhRLPd45XWVoHY1zGW5CFp9P1dXRKxbJw4KHuetuyoYI8coBHUMiJp zngw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ujO9qxJD; 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=fail (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 v12si1798449ejy.233.2020.09.21.09.46.16; Mon, 21 Sep 2020 09:46:39 -0700 (PDT) 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=@kernel.org header.s=default header.b=ujO9qxJD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729644AbgIUQnx (ORCPT + 99 others); Mon, 21 Sep 2020 12:43:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729635AbgIUQno (ORCPT ); Mon, 21 Sep 2020 12:43:44 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3A0C9238E6; Mon, 21 Sep 2020 16:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706622; bh=42fnfEc8RLB+21VT9GxDtA29pgj9XX4YzmOC2aE1PTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujO9qxJDHxKjNvkik09zLNZg8DzRzBe2SwFQtmA5+X/nYo9MCMzuN9KDfe74e4QLa j6IO7hBCdmvEKr9pSHgKK3a5JMyuKvcll0r0T33eDHTLMTkWTZvhlvwGjXaxN9jL9+ eOYxEPEl6+As7Lehv4bAis57/GO3aWcQwENeDEPU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lennart Poettering , Yang Xu , Martijn Coenen , Jens Axboe Subject: [PATCH 5.8 007/118] loop: Set correct device size when using LOOP_CONFIGURE Date: Mon, 21 Sep 2020 18:26:59 +0200 Message-Id: <20200921162036.684858019@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@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: Martijn Coenen commit 79e5dc59e2974a48764269fa9ff544ae8ffe3338 upstream. The device size calculation was done before processing the loop configuration, which meant that the we set the size on the underlying block device incorrectly in case lo_offset/lo_sizelimit were set in the configuration. Delay computing the size until we've setup the device parameters correctly. Fixes: 3448914e8cc5("loop: Add LOOP_CONFIGURE ioctl") Reported-by: Lennart Poettering Tested-by: Yang Xu Signed-off-by: Martijn Coenen Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/loop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1114,8 +1114,6 @@ static int loop_configure(struct loop_de mapping = file->f_mapping; inode = mapping->host; - size = get_loop_size(lo, file); - if ((config->info.lo_flags & ~LOOP_CONFIGURE_SETTABLE_FLAGS) != 0) { error = -EINVAL; goto out_unlock; @@ -1165,6 +1163,8 @@ static int loop_configure(struct loop_de loop_update_rotational(lo); loop_update_dio(lo); loop_sysfs_init(lo); + + size = get_loop_size(lo, file); loop_set_size(lo, size); set_blocksize(bdev, S_ISBLK(inode->i_mode) ?