Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp637412yba; Wed, 24 Apr 2019 07:15:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6Rftzl4U/1CFP1SXCW/06pFqV1QRbbOcnWs3LIxMEIMPXt5jnHJBsrhA/ZlUiNNYwf8DE X-Received: by 2002:a17:902:e01:: with SMTP id 1mr33594033plw.128.1556115350066; Wed, 24 Apr 2019 07:15:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556115350; cv=none; d=google.com; s=arc-20160816; b=EZO2YN+1V8cqxd7YG0+clzG1k1gZvwGgnBTX82Zw6xn3Tu3wZmfh2CoRHypUNG35PN N7ul4dT1a+DMCwmK+pcxPy+/Hq96pfX9aE58rtxuUdYMLlyATN9lT3Llt9UXe5X74ACI CQ7uc93HJ7W47zWN0xXxNcEFH5poEH0rgrTfGfGeKZFPWny+7NaZvDXhdLE/Ic4XeeaM 35mwdAZJcWoBc80CSAgtNHT/+He1jF6d4fFjTK8s9ea3taqpPEb/6vzBBsRrq/nLoJr9 PSFNrbU7dMinOHdfYp8OUT63giYQ3AJK56siWsu9tUFu16jZdzSV6UQnvNT57KGiKwzT dKBA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/NLjiioFz6rUiXZJIyDDuk+YV3mLVbRKbBWhaLciluU=; b=q8EI6OJRA7AIUoWvQqJCbH7LL9TXAYAoqTz7H9RJwg79x5v8Ifi6EQBUe1/wIcJQyY pNFfcvFMgCbmmIwnJaANoMjt0PfOjRGuEihv8iDX6ezTjY4cWrh1Ey9hmy4arEJVB69V ccUr6sKMIHK5bk84Av3yQm4Zmf8afQrNNJfjIFcUBsrywxUqxXI2v6Mzg8A6nhbfxrAJ M1UhlSqOHDJATg9e7FgjUztEpwA/8Y7y8OQcs/T+C43Vwf1mx8H1+JCNKo+Cz2+p/pB2 Q9Tvtm0qrGjETpj8SmlDtNvJdvy3da12i+SVFtnCmrZD9PwJfS/Bt0J8mWfBMBMnSS0n EZ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20190130-41we5z8j header.b=CKcJvo9G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si5795926pgf.512.2019.04.24.07.15.33; Wed, 24 Apr 2019 07:15:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20190130-41we5z8j header.b=CKcJvo9G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbfDXOOY (ORCPT + 99 others); Wed, 24 Apr 2019 10:14:24 -0400 Received: from smtp73.ord1d.emailsrvr.com ([184.106.54.73]:41850 "EHLO smtp73.ord1d.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725954AbfDXOOY (ORCPT ); Wed, 24 Apr 2019 10:14:24 -0400 Received: from smtp10.relay.ord1d.emailsrvr.com (localhost [127.0.0.1]) by smtp10.relay.ord1d.emailsrvr.com (SMTP Server) with ESMTP id 89344A01FA; Wed, 24 Apr 2019 10:14:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20190130-41we5z8j; t=1556115262; bh=dEOzUVrDYVD8a9AiBp7EenF4AaDSnNVwKFYaReUz2zA=; h=From:To:Subject:Date:From; b=CKcJvo9GlqbDlwLiMJkNyv27AgYlrCrCmDvx73ZMg63KjVPNsv4SOq/d5KX0/GnAZ bLSjsr0ZywDRbEgd37LjQkcfiaFcWJbRHrIIcJx7Ly2wFVMi7VSa5TwG16GcYaCZRx kMtEZA/lhTvRSHL5qJ+xruB5pWFl1V8exSqn2IUI= X-Auth-ID: abbotti@mev.co.uk Received: by smtp10.relay.ord1d.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id C97A7A020B; Wed, 24 Apr 2019 10:14:21 -0400 (EDT) X-Sender-Id: abbotti@mev.co.uk Received: from ian-deb.inside.mev.co.uk (remote.quintadena.com [81.133.34.160]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256) by 0.0.0.0:465 (trex/5.7.12); Wed, 24 Apr 2019 10:14:22 -0400 From: Ian Abbott To: linux-fsdevel@vger.kernel.org Cc: Miklos Szeredi , linux-kernel@vger.kernel.org, Ian Abbott Subject: [PATCH] fuse: Add ioctl flag for x32 compat ioctl Date: Wed, 24 Apr 2019 15:14:11 +0100 Message-Id: <20190424141411.24418-1-abbotti@mev.co.uk> X-Mailer: git-send-email 2.20.1 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 Currently, a CUSE server running on a 64-bit kernel can tell when an ioctl request comes from a process running a 32-bit ABI, but cannot tell whether the requesting process is using legacy IA32 emulation or x32 ABI. In particular, the server does not know the size of the client process's `time_t` type. For 64-bit kernels, the `FUSE_IOCTL_COMPAT` and `FUSE_IOCTL_32BIT` flags are currently set in the ioctl input request (`struct fuse_ioctl_in` member `flags`) for a 32-bit requesting process. This patch defines a new flag `FUSE_IOCTL_COMPAT_X32` and sets it if the 32-bit requesting process is using the x32 ABI. This allows the server process to distinguish between requests from requesting client processes using IA32 emulation or the x32 ABI and so infer the size of the client process's `time_t` type and any other IA32/x32 differences. Signed-off-by: Ian Abbott Cc: Miklos Szeredi --- This is based on an earlier patch titled "fuse: Add ioctl flag for compat ioctl with 64-bit time_t" that focussed specifically on `time_t` compatibility. At the insistence of Miklos, I have changed it to focus on x32 compatibility. -- Ian Abbott --- fs/fuse/file.c | 7 ++++++- include/uapi/linux/fuse.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 06096b60f1df..44d52c54dd75 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2576,8 +2576,13 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, #if BITS_PER_LONG == 32 inarg.flags |= FUSE_IOCTL_32BIT; #else - if (flags & FUSE_IOCTL_COMPAT) + if (flags & FUSE_IOCTL_COMPAT) { inarg.flags |= FUSE_IOCTL_32BIT; +#ifdef CONFIG_X86_X32 + if (in_x32_syscall()) + inarg.flags |= FUSE_IOCTL_COMPAT_X32; +#endif + } #endif /* assume all the iovs returned by client always fits in a page */ diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 2ac598614a8f..c8ba8230639e 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -335,6 +335,7 @@ struct fuse_file_lock { * FUSE_IOCTL_RETRY: retry with new iovecs * FUSE_IOCTL_32BIT: 32bit ioctl * FUSE_IOCTL_DIR: is a directory + * FUSE_IOCTL_COMPAT_X32: x32 compat ioctl on 64bit machine (64bit time_t) * * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs */ @@ -343,6 +344,7 @@ struct fuse_file_lock { #define FUSE_IOCTL_RETRY (1 << 2) #define FUSE_IOCTL_32BIT (1 << 3) #define FUSE_IOCTL_DIR (1 << 4) +#define FUSE_IOCTL_COMPAT_X32 (1 << 5) #define FUSE_IOCTL_MAX_IOV 256 -- 2.20.1