From patchwork Sat Dec 15 01:22:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Bowler X-Patchwork-Id: 10731949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D745924 for ; Sat, 15 Dec 2018 01:22:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A7CB2D02C for ; Sat, 15 Dec 2018 01:22:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2F422D035; Sat, 15 Dec 2018 01:22:24 +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 96E382D02C for ; Sat, 15 Dec 2018 01:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728620AbeLOBWY (ORCPT ); Fri, 14 Dec 2018 20:22:24 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:35070 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbeLOBWX (ORCPT ); Fri, 14 Dec 2018 20:22:23 -0500 Received: by mail-it1-f194.google.com with SMTP id p197so12345377itp.0 for ; Fri, 14 Dec 2018 17:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=draconx-ca.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tB1VVJP4XTq+ZYiN+8w06NFJBP0UDRkbcNZBjv374kQ=; b=Gw3jmdGPC4sUClJeVBSH+NvPyUFl9Fe61dozufWzXLKHwTM3oFL10YUmLVTTC3STm3 aFtcCjGD/VbTHiwoArpvwYFKjG3JPZyZLGVZn8JX8PiidDFwjo1SyesmjG9PC6wqhUUc 1mA3bPEeBEfiNUkNIX02vM572c+Y0/OiVhB/r6mGP0O69Lrn0rvdzvMGwPjfgGqhWE00 AdFSR6hIXYkCHcN7Evpcg6c4oAck53cFs9a4X6qEP7eDSdZFBeHii+JtpDtd7nT2HJwi OTkMQke1qKxOTIpG1mbKfRZluylGTkjQichJtl9UoXpU7CSoA60IU5tujWXhV1MF6+QA zxOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tB1VVJP4XTq+ZYiN+8w06NFJBP0UDRkbcNZBjv374kQ=; b=Pr1MGRfBIPvON98X399EgG6QIN+Qxcyetp9gniQ9uXC3v38YsuoW3M/E3moKJoruec IudP3LMhVHHZVck/xxaKWoQws3+6b9odeaaLBNMn4JgiRDbVT6uVtLFiRLDHlAXG02tX poayx6Duo5UiGw2rnKJAct8kpWd//4gVdj6eoa24fZwvteLkVWEGYEB9i/NyB/TO9eJ5 MmzT9MZYtwfzseoX7O8tAwVUfzlho6bBBoLJet6pcDMUrMwAHCyAqQn379auErqPA1PU 31BbUK2A+8U2wuG9UrZiAZ8QLEzzR+CAqyzeolEjng/ipgr1eDh0LBaaKmarmIfjr3uQ 7IhA== X-Gm-Message-State: AA+aEWbgGsx3J6SqjsQFa3rjhZUVWSee8ePPjUIixqU8fas/ZM27P0qD wLts9xJwIgJUjSuMdV/n28Bvi1E98ZRj7spS X-Google-Smtp-Source: AFSGD/Xer7ucpkGYglS+4LfHm+pK6sEJFBB9fS8jTaeQTNEXkwZKetpJr/UD4NJivwJoeBtLrJ8jAw== X-Received: by 2002:a24:3752:: with SMTP id r79mr4477232itr.121.1544836942311; Fri, 14 Dec 2018 17:22:22 -0800 (PST) Received: from localhost (ip-24-156-181-89.user.start.ca. [24.156.181.89]) by smtp.gmail.com with ESMTPSA id w8sm1127993iom.26.2018.12.14.17.22.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Dec 2018 17:22:21 -0800 (PST) From: Nick Bowler To: linux-xfs@vger.kernel.org Cc: Brian Foster , Dave Chinner , "Darrick J. Wong" Subject: [RFC PATCH v2 3/3] xfs: Fix x32 ioctls when cmd numbers differ from ia32. Date: Fri, 14 Dec 2018 20:22:59 -0500 Message-Id: <20181215012259.28358-4-nbowler@draconx.ca> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181215012259.28358-1-nbowler@draconx.ca> References: <20181215012259.28358-1-nbowler@draconx.ca> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Several ioctl structs change size between native 32-bit (ia32) and x32 applications, because x32 follows the native 64-bit (amd64) integer alignment rules and uses 64-bit time_t. In these instances, the ioctl number changes so userspace simply gets -ENOTTY. This scenario can be handled by simply adding more cases. Looking at the different ioctls implemented here: - All the ones marked 'No size or alignment issue on any arch' should presumably all be fine. - All the ones under BROKEN_X86_ALIGNMENT are different under integer alignment rules. Since x32 matches amd64 here, we just need both sets of cases handled. - XFS_IOC_SWAPEXT has both integer alignment differences and time_t differences. Since x32 matches amd64 here, we need to add a case which calls the native implementation. - The remaining ioctls have neither 64-bit integers nor time_t, so x32 matches ia32 here and no change is required at this level. The bulkstat ioctl implementations have some pointer chasing which is handled separately. Signed-off-by: Nick Bowler Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_ioctl32.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 1cdc75dca779..bd9ffad0f65e 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -579,8 +579,12 @@ xfs_file_compat_ioctl( case FS_IOC_GETFSMAP: case XFS_IOC_SCRUB_METADATA: return xfs_file_ioctl(filp, cmd, p); -#ifndef BROKEN_X86_ALIGNMENT - /* These are handled fine if no alignment issues */ +#if !defined(BROKEN_X86_ALIGNMENT) || defined(CONFIG_X86_X32) + /* + * These are handled fine if no alignment issues. To support x32 + * which uses native 64-bit alignment we must emit these cases in + * addition to the ia-32 compat set below. + */ case XFS_IOC_ALLOCSP: case XFS_IOC_FREESP: case XFS_IOC_RESVSP: @@ -593,8 +597,16 @@ xfs_file_compat_ioctl( case XFS_IOC_FSGROWFSDATA: case XFS_IOC_FSGROWFSRT: case XFS_IOC_ZERO_RANGE: +#ifdef CONFIG_X86_X32 + /* + * x32 special: this gets a different cmd number from the ia-32 compat + * case below; the associated data will match native 64-bit alignment. + */ + case XFS_IOC_SWAPEXT: +#endif return xfs_file_ioctl(filp, cmd, p); -#else +#endif +#if defined(BROKEN_X86_ALIGNMENT) case XFS_IOC_ALLOCSP_32: case XFS_IOC_FREESP_32: case XFS_IOC_ALLOCSP64_32: