Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp536153ybk; Wed, 13 May 2020 06:40:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu6y5wL3juLhmiCQ00A8Zm0bF/p/tmd6kfIKdDU88Mwrujag8/PA6WLB/QhAidmLhhGKt5 X-Received: by 2002:a05:6402:3106:: with SMTP id dc6mr5125835edb.19.1589377240185; Wed, 13 May 2020 06:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589377240; cv=none; d=google.com; s=arc-20160816; b=SbdscpG2vPf2Su83Gm/UOaZhQg64BofNEBp8/zRl3vZM67It+2ErGu9Qxzaw3jPrCS Wp2UC6dzzViO147E2ZjDHzXDWyy1ncbt1ZUnZnvtFsIGqouiIvPn2TUlUytc+lTpONZ6 ly9+CnGOU6rh1M00UvfnfalG4Bv2SLh91yT93xgJ/KXgKX4dkylVN3ZdY1xk8CfyOXJY BUBUOlFBEv5g4ZVsR3DBSRC/6D+ITHq57VqDMr6gl28ed/2Vd+GoITT9RBE6xMQbxEGG hyUTFOyfQoK9SGXnoEY4ZkWE6iBcrNEa58IiVNGIaWc+/gUlwkIXaif0BvZ+L3pmbMFZ HITA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E0D6BkdLn12sF+QPBQ9DDFZok3hDXQNtAmE1mTHFkes=; b=C+vJ3/Pjju+Ih73ODAVw/4Ej5M7e02jGZg3ApFaqtJyRjw6+RmA+KJt9P90UEE2olJ Fj+CCXmP3yjE3wz+ZUgVeIXIAMYJy2eq/BKerkbpr48r8+kATQH8I4asFh4L+n7Mm4uh tMWNcNgdU2bUDlo/QZNPwaQ0dSjbcOe27hgnzLsu6TtxWE+EHxOgRVjQZXq3yy38ynPA 3sDuwdxmVLc/KG/yYVbXGOsINUmScrQKjMyJd+BDDBcoZX/Cd1SDU/oEegEx15WQ2NUq va+boyebAYPznCie/BnYeoLhjMCB9RvaFNogFh3DdtW3NYQiWgjhZmriQ3Aqc5E5EnRW QkRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=Kg9qJJ1o; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k16si9629152ejr.429.2020.05.13.06.40.17; Wed, 13 May 2020 06:40:40 -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=@android.com header.s=20161025 header.b=Kg9qJJ1o; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388302AbgEMNi6 (ORCPT + 99 others); Wed, 13 May 2020 09:38:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387466AbgEMNix (ORCPT ); Wed, 13 May 2020 09:38:53 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DF01C061A0E for ; Wed, 13 May 2020 06:38:53 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id f134so14416834wmf.1 for ; Wed, 13 May 2020 06:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E0D6BkdLn12sF+QPBQ9DDFZok3hDXQNtAmE1mTHFkes=; b=Kg9qJJ1o9t8EF/BBzAGeSYZEi/IVzeB/gtMvBV3ykUZcYKhBQJTacySLMWhotnuumL kaa1fEmfVhNVHZToCs0GVKJcFAJduQJBeWBU/PAINkcgzkZT8S/JJGcY/ts+BR9gkdt0 J+Ioo5EnFFigVarmb50yOe1/CFOfStep9MaGkmB30NcEplHVv9abRmrLG9xyYkwp+phD 4HkQID2tLdB3roHkDx4GCPiax4+Jbqk4rotVnmP9kNVcnMqVQrH/3E3meAnsVpLEC0zV HRnuVBnp6u9L+4CEgqTr6FyzQ/LG0oocgDekKw+2cFwClUBjLoLk5sbBsUQ59MFkV+lc HIjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E0D6BkdLn12sF+QPBQ9DDFZok3hDXQNtAmE1mTHFkes=; b=kt4Oq5KlrO68NKZcBuWrGK5bRL71In+LZ0WeKhqLM9gZo6Ysxh8at31va3au+tV3SG yOrPu5Z5TXaYOATPfGhB3BIoE7zxp56gmqCNbWUr8c4kG4yMhUFSofkeFipD2yIyx7MC jwiUkN9dXAiATxAWBEeHaE6/yP9j209BXBjdfyWbXnGDKWUUmJ+kmgEyiLoOap3pwX5P FKuRDnxGQJM7cSlbbUle8SsDF7hkv1pO5oWNeGIDkS2kIgLfE/+cGDhylUxsbypi3KGg ggpCY3GytNJ3WVgBZI+az4NneqaZVJBKtry9lkD2sKekDaokykIZGuUqmnfn66ui7zTl M2bQ== X-Gm-Message-State: AGi0PuaTq3KtFgod6MEG5IFtwhJMgEm6koBDWHy7hFZG1LiUlBU3Bf+z Ls7T6Oj6ltpFrMmedNUZS6q/kw== X-Received: by 2002:a7b:c95a:: with SMTP id i26mr29616989wml.117.1589377132142; Wed, 13 May 2020 06:38:52 -0700 (PDT) Received: from maco2.ams.corp.google.com (a83-162-234-235.adsl.xs4all.nl. [83.162.234.235]) by smtp.gmail.com with ESMTPSA id m6sm26202653wrq.5.2020.05.13.06.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 06:38:51 -0700 (PDT) From: Martijn Coenen To: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com Cc: narayan@google.com, zezeozue@google.com, maco@google.com, kernel-team@android.com, bvanassche@acm.org, Chaitanya.Kulkarni@wdc.com, jaegeuk@kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Martijn Coenen Subject: [PATCH v5 02/11] loop: Remove sector_t truncation checks Date: Wed, 13 May 2020 15:38:36 +0200 Message-Id: <20200513133845.244903-3-maco@android.com> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog In-Reply-To: <20200513133845.244903-1-maco@android.com> References: <20200513133845.244903-1-maco@android.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sector_t is now always u64, so we don't need to check for truncation. Signed-off-by: Martijn Coenen --- drivers/block/loop.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index f1754262fc94..00de7fec0ed5 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -228,24 +228,20 @@ static void __loop_update_dio(struct loop_device *lo, bool dio) blk_mq_unfreeze_queue(lo->lo_queue); } -static int +static void figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit) { loff_t size = get_size(offset, sizelimit, lo->lo_backing_file); - sector_t x = (sector_t)size; struct block_device *bdev = lo->lo_device; - if (unlikely((loff_t)x != size)) - return -EFBIG; if (lo->lo_offset != offset) lo->lo_offset = offset; if (lo->lo_sizelimit != sizelimit) lo->lo_sizelimit = sizelimit; - set_capacity(lo->lo_disk, x); + set_capacity(lo->lo_disk, size); bd_set_size(bdev, (loff_t)get_capacity(bdev->bd_disk) << 9); /* let user-space know about the new size */ kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE); - return 0; } static inline int @@ -1003,10 +999,8 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, !file->f_op->write_iter) lo_flags |= LO_FLAGS_READ_ONLY; - error = -EFBIG; size = get_loop_size(lo, file); - if ((loff_t)(sector_t)size != size) - goto out_unlock; + error = loop_prepare_queue(lo); if (error) goto out_unlock; @@ -1328,10 +1322,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) lo->lo_device->bd_inode->i_mapping->nrpages); goto out_unfreeze; } - if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit)) { - err = -EFBIG; - goto out_unfreeze; - } + figure_loop_size(lo, info->lo_offset, info->lo_sizelimit); } memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE); @@ -1534,7 +1525,9 @@ static int loop_set_capacity(struct loop_device *lo) if (unlikely(lo->lo_state != Lo_bound)) return -ENXIO; - return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit); + figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit); + + return 0; } static int loop_set_dio(struct loop_device *lo, unsigned long arg) -- 2.26.2.645.ge9eca65c58-goog