From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21F47C433E0 for ; Mon, 1 Mar 2021 12:27:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4E3061494 for ; Mon, 1 Mar 2021 12:27:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234973AbhCAM1a (ORCPT ); Mon, 1 Mar 2021 07:27:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234960AbhCAM1L (ORCPT ); Mon, 1 Mar 2021 07:27:11 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70DCC06178A for ; Mon, 1 Mar 2021 04:26:29 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id k66so14294613wmf.1 for ; Mon, 01 Mar 2021 04:26:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KD4LJEezSXanY/+fxbjEzv3Osh9WD8nOyZFOgjBB36g=; b=CZxnxPb0K7GR6Qvt6NmYIQPiHxDX8dy8RkmKGIsYbrfrN4XPehp1iWIkNTYS7mVowK QDrM4D4Szb5W8I+1q8i6iI9DxbdpG1qXMzE5HJYTH/NssW/3qdADiDKsrBP1SKkUTmB1 g16xudG8XLlbJQ0EfEiDot43bw2aNPTV0sE57jZyG/lSyEIu65LMtUCPhA8TjjKxFGD+ 5rrZn7lz/0BsyoNl8tS0TSFDbSh4l1ZvpRmFw0XwxTdHDWbLgleGzLbPZAjBoUMCQ1jI RN6PEQvC6fc470XRrvAHDJDPueFYFRwgdMi99o6+B2mClkvg/d2SBJrJbVeBsO6GI/fx n/Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KD4LJEezSXanY/+fxbjEzv3Osh9WD8nOyZFOgjBB36g=; b=XRjglSkpxKHWiZKG5uWCJKciyD7mD37u8VtCg1YtEt6Qv3zkPPYfV3kJ4vjpmItXCL 9UHGntC5iUr4osxnX8iOKQ/tP5yGt2y0VFd0IdM58W3bLHQU1fx5jemiJ90lHFBy1Rvy s0Bq8As1y+PWpb2rRwKdu8KU2hArF3sb+zzkd2IFqy+LEVREjg6mEYEG3VgqrNO8aOPD +srxzW79MkFjnP5FNnjJBL1rVA19RpOekan1SnvY0fBZ1f6QbUUACxiV0cc2MTslsRsm K75SahZ+4McTOLPCa770Dg/2vBTeOn6uUYxleoIzALAZojT57QoxrVhF7/wX3UrMnZG1 Fv4w== X-Gm-Message-State: AOAM531H0jafJtIk211IqMZ/Ce+xlkOL80p7CD/X9KSyz5hseF2hprug mBuYHPk3STVuLAFDlpfKsy6aWw== X-Google-Smtp-Source: ABdhPJz8OhS4Q1P+hcYUzb4xUlgBO73g43l7Pd9vB1016kMqXRu1eWhWzuo+f525VTvWifU9/715fQ== X-Received: by 2002:a05:600c:21c9:: with SMTP id x9mr10711107wmj.135.1614601588566; Mon, 01 Mar 2021 04:26:28 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:3854:8f6d:e288:2080]) by smtp.gmail.com with ESMTPSA id r18sm25578444wro.7.2021.03.01.04.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Mar 2021 04:26:28 -0800 (PST) Date: Mon, 1 Mar 2021 12:26:26 +0000 From: Alessio Balsini To: Miklos Szeredi Cc: Alessio Balsini , Akilesh Kailash , Amir Goldstein , Antonio SJ Musumeci , David Anderson , Giuseppe Scrivano , Jann Horn , Jens Axboe , Martijn Coenen , Palmer Dabbelt , Paul Lawrence , Peng Tao , Stefano Duo , Zimuzo Ezeozue , wuyan , fuse-devel , kernel-team , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND V12 2/8] fuse: 32-bit user space ioctl compat for fuse device Message-ID: References: <20210125153057.3623715-1-balsini@android.com> <20210125153057.3623715-3-balsini@android.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 17, 2021 at 11:21:04AM +0100, Miklos Szeredi wrote: > On Mon, Jan 25, 2021 at 4:31 PM Alessio Balsini wrote: > > > > With a 64-bit kernel build the FUSE device cannot handle ioctl requests > > coming from 32-bit user space. > > This is due to the ioctl command translation that generates different > > command identifiers that thus cannot be used for direct comparisons > > without proper manipulation. > > > > Explicitly extract type and number from the ioctl command to enable > > 32-bit user space compatibility on 64-bit kernel builds. > > > > Signed-off-by: Alessio Balsini > > --- > > fs/fuse/dev.c | 29 ++++++++++++++++++----------- > > include/uapi/linux/fuse.h | 3 ++- > > 2 files changed, 20 insertions(+), 12 deletions(-) > > > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c > > index 588f8d1240aa..ff9f3b83f879 100644 > > --- a/fs/fuse/dev.c > > +++ b/fs/fuse/dev.c > > @@ -2233,37 +2233,44 @@ static int fuse_device_clone(struct fuse_conn *fc, struct file *new) > > static long fuse_dev_ioctl(struct file *file, unsigned int cmd, > > unsigned long arg) > > { > > - int err = -ENOTTY; > > + int res; > > + int oldfd; > > + struct fuse_dev *fud = NULL; > > > > - if (cmd == FUSE_DEV_IOC_CLONE) { > > - int oldfd; > > + if (_IOC_TYPE(cmd) != FUSE_DEV_IOC_MAGIC) > > + return -EINVAL; > > Why change ENOTTY to EINVAL? > > Thanks, > MIklos For the magic number mismatch I was thinking that EINVAL would have been more appropriate, meaning: "this ioctl is definitely something this file doesn't support". ENOTTY, could be more specific to the subset of ioctls supported by the file, so I kept this in the default case of the switch. After counting the use of ENOTTY vs EINVAL for these _IOC_TYPE checks, EINVALs were less than half ENOTTYs, so I'm totally fine with switching back to ENOTTY in V13. Thanks! Alessio