Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6363691pxb; Wed, 17 Feb 2021 02:27:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm+gsqitg/4QLNNu/5bmiviILP5qNbkg108xeqFivGQ3LVFuSHRdJXzw35ThbuxcyupaGL X-Received: by 2002:a17:907:2058:: with SMTP id pg24mr24562078ejb.441.1613557629898; Wed, 17 Feb 2021 02:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613557629; cv=none; d=google.com; s=arc-20160816; b=w6bGpNoJcJz7HREZMnvLCLDx/8TdQh5sNyQLgVXHORkg+TqTz8Jc6h/JyQ2WuyhpBH OrOpIRSs8S2pokN4FkU/MaRLGqHI1Mu1vkKSax+aZtxnBF0xwW4zsaLX8fHVwRee4JqM mGUurj7aSQdDiqfk3rKj7ZajAiNnjQTpFKdZIhGnBCpZpcp1dq3pRJksfvbOpJjaKCkx Z0A0XMR6iDOcXm937FnQ7eL+f8mD+VGLJVtHX6aAHpL2vzisARIWM3ObmH3lIk8wrXJ8 M6Q6ljcgdnnIl4kDyebEW4+teLDQaSR4OPxnvVM7SIywzhfi7TlvNioYhwPD8eOy30/U XKLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=x7YMLJjk40HzAWELqN5l9m4d4X7by6+aJQrjOvMUw0Q=; b=rIY5PFSgonyUb9uYXR91BI29SqEtlERfMbC0tx9CaDu/FRg9p/PWSiPw+JQEaPmdLp s8rs5LFpSMTSs6E7Few5bmnKotJz7WHIB16KVR3OH/p5DGwZPfYJ/17UcKHnIZpfHxy/ xYG+Wn8+iL6jJqwzOjCwnT0RYFcwaTafJpkuyDkcAj9qBQTeGZj9lFqwKu9125OU8Jf4 W2bcc/kykKnBrRJpfZf5XWBrdDgby6jyYWx696YeynTNybMeSKC30tPBzGbmhNkA7c+g l1yOuib/XLMecTHU31AiKYaFq4dwBFxm7o5HpNxseyuqx9uY4NZi8yf7oHiCoxY/fTAm pmiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=aBwQ8vyy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si976959eds.116.2021.02.17.02.26.47; Wed, 17 Feb 2021 02:27:09 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=aBwQ8vyy; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232333AbhBQKWI (ORCPT + 99 others); Wed, 17 Feb 2021 05:22:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbhBQKV4 (ORCPT ); Wed, 17 Feb 2021 05:21:56 -0500 Received: from mail-ua1-x92d.google.com (mail-ua1-x92d.google.com [IPv6:2607:f8b0:4864:20::92d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20158C061574 for ; Wed, 17 Feb 2021 02:21:16 -0800 (PST) Received: by mail-ua1-x92d.google.com with SMTP id 62so2365218uar.13 for ; Wed, 17 Feb 2021 02:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x7YMLJjk40HzAWELqN5l9m4d4X7by6+aJQrjOvMUw0Q=; b=aBwQ8vyyLXdPiYxmIPMn+u8n+zN5eUz3evKEEiKLz4mVAKmiI3e66LQTfkGf+EtYqd kDoQCHP6JkV0WZmQjMXp/DFk/mneY+9FkiRtxShWfVzgVmy1nU7k4IGY9g4VzYAS1tw6 i4evrmjCbdiZVTlI8LSS19oFCVD42xFpHt/vE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x7YMLJjk40HzAWELqN5l9m4d4X7by6+aJQrjOvMUw0Q=; b=f7dB0Ot9VYLpbfM7RvDvGdSyuWPBz4EDK07OSCf5ASvXQ+afZLqtsM4ctQsytmTw+M HCyAYnKKrC3384A1R0nkmf5zDnT3LWGubkPSHAJebhmK+7nxI6peD1M09jPXLnCQlY1o wD0SZH9NA5li+G39Wq6FylgTEllJaBd6/BlODdJnRlAiNn5FNCl8DQY7zqkHxnogWdxi 10DoJN1/MEvI1nJtWUaghdANe2yPOtWGrd/l+JQojSFp9ewb4NBRqmbYCL+EniWmellN qPle28Rcca16HFUmlxSRQ7jIqH7xF1LJ0/qdSQ/N4uU+gCHd7QbPCT7jdLVAavgLrX6l tCjA== X-Gm-Message-State: AOAM5323D5Btmgn7S/A9zDnd0AoqILOvnXQwlIc7pinPqkUd9/rl2ftt XP0lH4VP1ShYLGlDpPZKlFnuoqO/69S0Zm9WExF1Uw== X-Received: by 2002:ab0:5963:: with SMTP id o32mr14151409uad.11.1613557275372; Wed, 17 Feb 2021 02:21:15 -0800 (PST) MIME-Version: 1.0 References: <20210125153057.3623715-1-balsini@android.com> <20210125153057.3623715-3-balsini@android.com> In-Reply-To: <20210125153057.3623715-3-balsini@android.com> From: Miklos Szeredi Date: Wed, 17 Feb 2021 11:21:04 +0100 Message-ID: Subject: Re: [PATCH RESEND V12 2/8] fuse: 32-bit user space ioctl compat for fuse device To: Alessio Balsini Cc: 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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