Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp55852pxb; Tue, 2 Mar 2021 19:00:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5LZt6c7jq/VaieADzrFjsCU437apSlLH3RI7XskS+wbCAZIHFO5ZTYKRdBe6lAmgxteDI X-Received: by 2002:a17:907:a06b:: with SMTP id ia11mr12605244ejc.294.1614740406280; Tue, 02 Mar 2021 19:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614740406; cv=none; d=google.com; s=arc-20160816; b=h257z2oPrYb+kyInGA+Q02e/8uvHZSvKcGwMEGyJIn42oH7Vq0IY83nMCWFe5VW7DF GkdzJMw/rbomuZSikpijRYJIcHm6gy3P+pB/J9evOWYOSevJd+YGIHO6FKvf6OjTlFu3 hasjyKXTfM+RIPzJzVXz0TMvBJOAh4yl80j1R9hHkkPRtb454JcSpoo8YdUvRI/wXKam sr73rg1HE/YtDcLorLijV0bxUjZIqnrxWKO8R8KqgqG5oARlmvhwR3GgJtY2LyqqIYFh dELn0+mZq7v9OtIkoxtfzcJmxBGU/dD9y6pKGxmtWSVWDY47Q5ssOi9S6IlINetZ4mVk xSrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KD4LJEezSXanY/+fxbjEzv3Osh9WD8nOyZFOgjBB36g=; b=Mi0mZHzoAr4P2AsmWlMvPNEUuv8xcnhMAwmddfxscbGiLpxEVUal20q4F/GxOH0PEb jiIeEf0qrQXiO3BYQf3ljr63XRhGX4xWq7ySgBaszI9+7+riIP4T08IB5f/ZrAusqCMJ J39l5sJ3ZpIZXUOLWifigwFsKnDORldXdD4P2vVzyosyNPiOCbrcV8QhBGUU1wrQNTeB OMeDuKmbJQyJU4Cbu2zOCa3ahNaGGRgyifCQqQMBYke0oMxgljSVTYcXLHfsdMBRJaV8 L6XsaRwBSHeGW7TZzkXWJyoyWWhw50OzHLKSxj2zzbzTaoZUMUYmSLDbq8qRVnheHSQ6 RX8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=CZxnxPb0; 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 s15si15298450edj.492.2021.03.02.18.59.44; Tue, 02 Mar 2021 19:00:06 -0800 (PST) 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=CZxnxPb0; 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 S234966AbhCAM1R (ORCPT + 99 others); Mon, 1 Mar 2021 07:27:17 -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-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