Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2616617ybz; Mon, 27 Apr 2020 00:44:54 -0700 (PDT) X-Google-Smtp-Source: APiQypLCruJQDJtVuv9xDKuR666uzuuIY5AA1qKWV3DAz0YM2h46naxSIbT94rjseWdRXxKPmgzq X-Received: by 2002:a17:906:200a:: with SMTP id 10mr3088991ejo.294.1587973493894; Mon, 27 Apr 2020 00:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587973493; cv=none; d=google.com; s=arc-20160816; b=hF8VVcssS18/AnLfWiAgIBSFYQXIam41unj1AenGUbw2AiIQJlNP74Nw61dkipNTXM mmOxxkvaPBWx8fnn8sX+SrV+PoF6DQHGvdPACY8HRTPvnoMcXTCo9WvZEti2caooKYqW MJroGJD54B6DHKJfdHuSBMt6Yf5/c3CnjJBztEI3c+AHQlDeCwZg+4Ipp8JINRYel6LP JVrVal15DtLde5tkCUbhUiRbOkDPbw9fTjkP5fqLMWU/DNT1fc8Xa3YOYaugEvqzcLDs +t7EPGo/VF3o7vjl7p0Vwi6Lk+D36gESPCTfu5ScJvjSSrNo5cQIcEZpkl3ShkuCKARp PWNQ== 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=rCmoWGSBp0bkzJg26kKRHWQrBipKAajMKVFOcPDe3LA=; b=k7Q1h7rhLLsV+aNOzgXFkyJSEJ5r8QZ7LAmIk9zj9z/l6V82hAnSfJ6Jm3GhdQfwmg WzX5yoHHVtVyUz1XXVyUO1ZeuIyCTMJup1LWXtI3YOlA2LRJLc4bcLntr7f3FuK+B0v6 7y+DH3ExFt5gU9ArczhfrGtPJQWPb7jL/raHPW3jmzxLxJmynoxR0H2DbjyFyQPL/46x zh4iucKdJ7TdTZeQ/QghlHlaGlPCl8B8oCNISO8qXE6oj62cA/GiR0jVqu4zpgEWAIar T9uO/WBWitRqZUoe3UkNu8J7Z6l8lWxpfO0aJRt5e4HYBOxAuYxM/GqBa440sqKzXYMr ZmeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b="Fpxnl/UA"; 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 m5si7603695edq.498.2020.04.27.00.44.30; Mon, 27 Apr 2020 00:44:53 -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="Fpxnl/UA"; 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 S1726803AbgD0Hms (ORCPT + 99 others); Mon, 27 Apr 2020 03:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbgD0Hmo (ORCPT ); Mon, 27 Apr 2020 03:42:44 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54B58C061A10 for ; Mon, 27 Apr 2020 00:42:44 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id j1so19299011wrt.1 for ; Mon, 27 Apr 2020 00:42:44 -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=rCmoWGSBp0bkzJg26kKRHWQrBipKAajMKVFOcPDe3LA=; b=Fpxnl/UAJRSu0MlJX/eTcPVQag3sJsu1tNWj/IhwcCrALMssjX1D99A/8Pf06ZRJm6 DfAGzVGkwco3mmYXL0yWR54tkAPJAAf+yQcA1MEaQn2Jf3OxWsY6W0gxjuIw4e7zuTWo RNniWSsJ3DojLB7zizi27lOPQZjG8Kn9AsJgdziHXKnnFPx/MioQSmvhTjNTVFZqxG4I WTT34OXOr8Nqhtc0wj175eXmlHwJFehGqmLASAfuw+xxfuipMG5hrfxmUv3sj6Ke569A H1jV+WQj8KCiVKzn63y86pH9x1SNV73l4zPWXeWLV/O5ZwOeChPNcp7YKR05Bdf33brv juiQ== 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=rCmoWGSBp0bkzJg26kKRHWQrBipKAajMKVFOcPDe3LA=; b=AAoJwyjNhNnCPMDr7b0WKm7eIpawb+xljZwT7jA5Jvr9ZMLz527yhjSnyVXjAdLNvN Z8dR/5w02b6GTs+b+tCaOB62PuUQOS+kz33T6O9w+jUOReTPvCRphjFCuHCU3Nhs5Iay SICQMAu6arhJpvpSBvkOwi60xdlBjlKhhIFsJy5DJuf4FhI2+CCCIGZ7TEYK3ScRLK42 pa0bQh78viJvDr2VzB577IxfaZnWDyzy8DkpLGNsnaD8x+5SlvoKn72e1/C1+HqvJEYb dK31LhqGEeJOows+w9ZSg+qUIT5etqDWBbDDEp8Z7qMpmGnFPrr3R8/b0SdP/Hw8Ldse 7JEQ== X-Gm-Message-State: AGi0PubdfeIMRgXgiz0pOnp5xR4OeuOdSmXpBZnxNzyDeUs97kxqp8JR ChZHphKRG73wqXIJB9T97cVaGg== X-Received: by 2002:adf:cd0a:: with SMTP id w10mr25344895wrm.404.1587973363097; Mon, 27 Apr 2020 00:42:43 -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 x132sm15091658wmg.33.2020.04.27.00.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 00:42:42 -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 v3 8/9] loop: Rework lo_ioctl() __user argument casting Date: Mon, 27 Apr 2020 09:42:21 +0200 Message-Id: <20200427074222.65369-9-maco@android.com> X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog In-Reply-To: <20200427074222.65369-1-maco@android.com> References: <20200427074222.65369-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 cd1efe0eec5a..92bbe368ab62 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1660,6 +1660,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) { @@ -1672,21 +1673,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