From patchwork Thu May 31 20:54:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Marshall X-Patchwork-Id: 10441959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AA57602BC for ; Thu, 31 May 2018 20:54:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B17A2915C for ; Thu, 31 May 2018 20:54:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FC7B2917A; Thu, 31 May 2018 20:54:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2E672915C for ; Thu, 31 May 2018 20:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753986AbeEaUyJ (ORCPT ); Thu, 31 May 2018 16:54:09 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:41280 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753881AbeEaUyI (ORCPT ); Thu, 31 May 2018 16:54:08 -0400 Received: by mail-yw0-f194.google.com with SMTP id s201-v6so6259717ywg.8 for ; Thu, 31 May 2018 13:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omnibond-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qu6wnG5+5ta9KWoCxsA4u4fFMCALiwNUCAe558MdSps=; b=fyoPkShCNeiHKO7EVFvop4SQGQ78f5NWHdLP4vZrKTvpt9Uhp4qr8xoKPNUJIrpDA4 0E4yFTOL/Kb4G22fjSsCT2UsgqfIi7sOgTap4ktlVSgKiY5AfiHyT2x+Og5pw3And7l+ njjJUyyFqxEVjlWVRzUOBSjZYei1pX+bgMaygW6PqH2bgWH/Qhw+skpodgOaXhUa+5UM /3N70M42oDrq5iNVXCXpGqMMLsyNOeFZiJGpEq7MKDK5vOsTp+jSO6MtoFv2cf7NExys v3j22t+riyiIcO0cDX9HeoLyiWYYzHXpApxggk6oYgABTLKYJaGWEjq3y/jqW+5hqDUd pWeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qu6wnG5+5ta9KWoCxsA4u4fFMCALiwNUCAe558MdSps=; b=nCKJU2t6D2dlmf1MJQfa4snkGz5MIy8dbNKNS/7CFXoCQ7CFVSM+tveY7yYeK/Me8G ClEoGdNX6U8oDE22u7Au+F3QpVR1obZH1CtJsbf3Z7RyIvMMI0eFJZS+0w6TUXSOYig2 xaR8kDagb+97CmRTNhusudTd36EJQu6K8NHjV0NE7zG3HxKx/bYOSoAQOgt1Ih0cz2fb CdxdHq21pt564I5gLj1kINuzRw9hqSLllj9u9F3NkdkqChRy2pEaGhMIqgGgnb8O5Ubp RHlQVvLaJzpLTecYhOs+Z3Rw+/YacFd5EyklzG7jKY0ANJlbeSUFhTEt1lBJ0RbCr7fp LDuQ== X-Gm-Message-State: ALKqPwepfvMOkb++AQpvlW9EUdo5fhT3MxmbHk7zq1mL7rxJf1PG8c+Z BD70DGETJQFyh7HV6Z20S1uAJ4D/p3Ex0Dgx6JS9Mtsv X-Google-Smtp-Source: ADUXVKJKzw2L5RJz2Yg/KCZvXCeEQFa4E9u/f07KOYOeBBzcSqDBDo5K/Epk2LAFetm73gvG4SiaV4XiyygDtd3Ovw4= X-Received: by 2002:a0d:c045:: with SMTP id b66-v6mr4376032ywd.461.1527800047455; Thu, 31 May 2018 13:54:07 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:bf8d:0:0:0:0:0 with HTTP; Thu, 31 May 2018 13:54:06 -0700 (PDT) In-Reply-To: <20180528222013.18402-4-viro@ZenIV.linux.org.uk> References: <20180528175430.GC30522@ZenIV.linux.org.uk> <20180528222013.18402-1-viro@ZenIV.linux.org.uk> <20180528222013.18402-4-viro@ZenIV.linux.org.uk> From: Mike Marshall Date: Thu, 31 May 2018 16:54:06 -0400 Message-ID: Subject: Re: [PATCH 4/4] orangefs: simplify compat ioctl handling To: Al Viro Cc: linux-fsdevel Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Thanks for the cleanup. This runs through xfstests with no regressions on 4.17-rc7. I studied what to do about the sparse warning, looked at the code, and looked for hints from the original authors in the pvfs svn commit messages. No luck with the old commit messages. I got the sparse warning to quit with this change, which also runs through xfstests with no regressions, does it seem OK? $ git diff Please add: Tested-by: Mike Marshall -Mike On Mon, May 28, 2018 at 6:20 PM, Al Viro wrote: > From: Al Viro > > no need to mess with copy_in_user(), etc... > > Cc: Mike Marshall > Signed-off-by: Al Viro > --- > fs/orangefs/devorangefs-req.c | 54 ++++++++++--------------------------------- > 1 file changed, 12 insertions(+), 42 deletions(-) > > diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c > index 66369ec90020..8581daf19634 100644 > --- a/fs/orangefs/devorangefs-req.c > +++ b/fs/orangefs/devorangefs-req.c > @@ -716,37 +716,6 @@ struct ORANGEFS_dev_map_desc32 { > __s32 count; > }; > > -static unsigned long translate_dev_map26(unsigned long args, long *error) > -{ > - struct ORANGEFS_dev_map_desc32 __user *p32 = (void __user *)args; > - /* > - * Depending on the architecture, allocate some space on the > - * user-call-stack based on our expected layout. > - */ > - struct ORANGEFS_dev_map_desc __user *p = > - compat_alloc_user_space(sizeof(*p)); > - compat_uptr_t addr; > - > - *error = 0; > - /* get the ptr from the 32 bit user-space */ > - if (get_user(addr, &p32->ptr)) > - goto err; > - /* try to put that into a 64-bit layout */ > - if (put_user(compat_ptr(addr), &p->ptr)) > - goto err; > - /* copy the remaining fields */ > - if (copy_in_user(&p->total_size, &p32->total_size, sizeof(__s32))) > - goto err; > - if (copy_in_user(&p->size, &p32->size, sizeof(__s32))) > - goto err; > - if (copy_in_user(&p->count, &p32->count, sizeof(__s32))) > - goto err; > - return (unsigned long)p; > -err: > - *error = -EFAULT; > - return 0; > -} > - > /* > * 32 bit user-space apps' ioctl handlers when kernel modules > * is compiled as a 64 bit one > @@ -755,25 +724,26 @@ static long orangefs_devreq_compat_ioctl(struct file *filp, unsigned int cmd, > unsigned long args) > { > long ret; > - unsigned long arg = args; > > /* Check for properly constructed commands */ > ret = check_ioctl_command(cmd); > if (ret < 0) > return ret; > if (cmd == ORANGEFS_DEV_MAP) { > - /* > - * convert the arguments to what we expect internally > - * in kernel space > - */ > - arg = translate_dev_map26(args, &ret); > - if (ret < 0) { > - gossip_err("Could not translate dev map\n"); > - return ret; > - } > + struct ORANGEFS_dev_map_desc desc; > + struct ORANGEFS_dev_map_desc32 d32; > + > + if (copy_from_user(&d32, (void __user *)args, sizeof(d32))) > + return -EFAULT; > + > + desc.ptr = compat_ptr(d32.ptr); > + desc.total_size = d32.total_size; > + desc.size = d32.size; > + desc.count = d32.count; > + return orangefs_bufmap_initialize(&desc); > } > /* no other ioctl requires translation */ > - return dispatch_ioctl_command(cmd, arg); > + return dispatch_ioctl_command(cmd, args); > } > > #endif /* CONFIG_COMPAT is in .config */ > -- > 2.11.0 > diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h index 61ee8d64c842..d403cf29a99b 100644 --- a/fs/orangefs/protocol.h +++ b/fs/orangefs/protocol.h @@ -342,7 +342,7 @@ enum { * that may be 32 bit! */ struct ORANGEFS_dev_map_desc { - void *ptr; + void __user *ptr; __s32 total_size; __s32 size; __s32 count;