Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp643062ybz; Wed, 22 Apr 2020 05:21:37 -0700 (PDT) X-Google-Smtp-Source: APiQypKxqzgSo7/pEIVRNpiCpo+sHWtYbcHGvPkXgzNfjbaZXh08fa3cCLCiwBXkS+1ICX5FwYKB X-Received: by 2002:a05:6402:1596:: with SMTP id c22mr17498325edv.100.1587558097148; Wed, 22 Apr 2020 05:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587558097; cv=none; d=google.com; s=arc-20160816; b=gB5WiCwzbzf2w1TWSPkPMtZaWF5L/z6dq7T/CFvl0+2Q96pQXoqiQbGDx1VPG9CKZn Vujy3q0k6myvZSTDbH9R9+tjt+zVUVagv2U5XlIqQuqvwGZCjk0jcCRsN1tLXZcnLlaK wEuqYV4hweREd8p0fSwgpsymLdi+NIZDRA8c2ngy1N4un3z6ckOLlLhxVt8rV8IFrcGj dGGYIwNTa9JOPvpBdrZTEkiQ5mNJ93+TIchM8y9m4E7tdxFn+x2HIHdVw0eBm1phYmQm kRkOP+gKhiA8iwkfrlxSRBHMKt4MfvH5YQRb2SC0cKaGGDhByhvkVD+u/HtY49lOUKR8 JmsQ== 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=036klsi1gy6LVGjlEiXf5owP/duZTlgIzaFa2SKIQ+E=; b=D5+jhGJYzPKJ2B7yilE57ipLxL3F2tMSSDDb/RE04Ppr4dFuiO3pBvEsQQmuLKpPrO GnVk+SSsg2stJJfZOrcLcV6Ip41+ZQw5B/oIFf6aey5KJMBeXaw6EddpgXI3ZPNzARGM KwxEAho1bv4ghMPSZUHM0Ww4kVdf4nFTagxX1B6QUPK48kQNA1sNYf2ulmCP9BAJDgMl LZgNYXEEMzZ1JSjWYSjQLKiC/HZXR6wswK5XMxTT8cOrZS+hpISTGNqbip1eUxuB9PZu rEnwnxh1+NhdysmPNMs2dc4Xe7OQXdVPqFIVkHZz9CgnshAHQaIssiXz87H+xF/qRIPO 7K1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=AGnsBpbL; 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 g16si3327624ejf.272.2020.04.22.05.21.14; Wed, 22 Apr 2020 05:21:37 -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=AGnsBpbL; 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 S1728444AbgDVKG5 (ORCPT + 99 others); Wed, 22 Apr 2020 06:06:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728376AbgDVKGt (ORCPT ); Wed, 22 Apr 2020 06:06:49 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DDC8C03C1A8 for ; Wed, 22 Apr 2020 03:06:49 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id x17so929330wrt.5 for ; Wed, 22 Apr 2020 03:06:48 -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=036klsi1gy6LVGjlEiXf5owP/duZTlgIzaFa2SKIQ+E=; b=AGnsBpbL1Vv97wQdW5Fl6CpGMUP+uNTbK+GJDqlM0qWbEAKocpTbFy+1IuXyLhL9vi TmWwRi5LQEO5YyOpsIzWDbJvLb3LEfMaSZlXkExDzWHUC3QgxUtWRzgNsHU5zwA8LdGj ZabDa89WpHCUGMlYOJGVBbicZ0ydSxwBxhmnglFV1YiYSroCuVWrwvocUIvbHktgB7R0 VodH1uOLUXzAHseEhgDYgGAM30wWlsOP79P4BvWHi7aaiypzyLdnTvmgzfqciYQvYJ4Q jRV4+mind6zTplTznFQst8dF88z4c6N5KBCoNdO66ahcc97Ip/HNzklCngM2HCakzjtn RjSQ== 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=036klsi1gy6LVGjlEiXf5owP/duZTlgIzaFa2SKIQ+E=; b=J/Q3JwGK7DkqDQa2gHwalAqpVg8Yvyi/PrJABUhHWgpkwjkC5VGqpkIDNawrR/Lvbs bO/hwZfAiEkHv6as0fAAyaxAD0Ru8kr9OdEqCxkgFd0aX2XxRIn7VjenA6tK3thJnIU/ Dr3IpSHuZ2dpeQ6LcMwwyfYA+Oy0NaGpwNI+YH8w9IemBxSt2D9dvoefYs/liPsuD4EH 5ZST3ZoSMAFQUDJFIvrbtiR0ovbv/qjxI0WAhO2b3js2EwHFWyWe8IB8fBp0ClXGS6Dg fOyftdLQXKnjr1vXJzGNdSn81YfMba1y20FjKEFZoDsd5CmnzsO2SAc/F9kyh5Hvu5kG 7/qw== X-Gm-Message-State: AGi0PubFZcaFK8OCWEQOPYna7c2t4jD0Wu5CNKBSLFGR9FI4FXo71+Nf GuvaS9ZEYzglf7KLwpr4Tw5goA== X-Received: by 2002:adf:fac8:: with SMTP id a8mr20639878wrs.311.1587550007842; Wed, 22 Apr 2020 03:06:47 -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 j13sm7812462wrq.24.2020.04.22.03.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 03:06:47 -0700 (PDT) From: Martijn Coenen To: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com Cc: narayan@google.com, zezeozue@google.com, kernel-team@android.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, maco@google.com, bvanassche@acm.org, Chaitanya.Kulkarni@wdc.com, jaegeuk@kernel.org, Martijn Coenen Subject: [PATCH v2 4/5] loop: rework lo_ioctl() __user argument casting Date: Wed, 22 Apr 2020 12:06:35 +0200 Message-Id: <20200422100636.46357-5-maco@android.com> X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog In-Reply-To: <20200422100636.46357-1-maco@android.com> References: <20200422100636.46357-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 In preparation for a new ioctl that needs to copy_from_user(); makes the code easier to read as well. Signed-off-by: Martijn Coenen --- drivers/block/loop.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index f6c6036324bf..b10f1d5306a2 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1658,6 +1658,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct loop_device *lo = bdev->bd_disk->private_data; + void __user *argp = (void __user *) arg; int err; switch (cmd) { @@ -1670,21 +1671,19 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, case LOOP_SET_STATUS: err = -EPERM; if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) { - err = loop_set_status_old(lo, - (struct loop_info __user *)arg); + err = loop_set_status_old(lo, argp); } break; case LOOP_GET_STATUS: - return loop_get_status_old(lo, (struct loop_info __user *) arg); + return loop_get_status_old(lo, argp); case LOOP_SET_STATUS64: err = -EPERM; if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) { - err = loop_set_status64(lo, - (struct loop_info64 __user *) arg); + err = loop_set_status64(lo, argp); } break; case LOOP_GET_STATUS64: - return loop_get_status64(lo, (struct loop_info64 __user *) arg); + return loop_get_status64(lo, argp); case LOOP_SET_CAPACITY: case LOOP_SET_DIRECT_IO: case LOOP_SET_BLOCK_SIZE: -- 2.26.2.303.gf8c07b1a785-goog