Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1747554ybh; Thu, 23 Jul 2020 17:13:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqvyTpi8ZACpRBm7rdbscZHRUW/LAGAaCTOxd/BsdqWR/X6VGbJEIRhYGtf0M7vqjNf4/J X-Received: by 2002:aa7:d88c:: with SMTP id u12mr6551366edq.29.1595549605009; Thu, 23 Jul 2020 17:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595549605; cv=none; d=google.com; s=arc-20160816; b=krO26ERfQCXmy769xgCUOAy6lOROmVxQPQRLwGmrQsg2hh2BRAu8x0ElcZSWW1279W rpHtxZqRQumXFKfM5Y8/dWkFOqXcMpdBbjxOFDvJHNzt/zZZ/53fAp0fNoD2BIQiM1nW DUb8vSwtPx6sk/QEftP6y3+DemlPaD1Y/2k8ZQeVA3YRHXx6NamyrFRCLtYTzaLwRLmb EVD+ZHTcpclOf9uq1FtuDywgXCcE9WlqJtBIJJyRwWT8g8nDmtBWl5fp55ygLKqEfLQR Hok9fbYtkGYY/mdo0rHvWbKY2nvYHjjtxSmM4sOBsnp7F4166DoiFf7TdtLgYf10SEBF k1Zg== 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 :content-disposition:mime-version:message-id:subject:cc:to:from:date; bh=EB8Tw45SbSRnNEWSvTzo7rsTrhSIWWwKE0w6LKyEhYo=; b=hWwslHIKWnDjnAy9AORASOsehQNiysqFlJXzOpRCUijFXaft05XtLb5kskHDmZOF5U ShQQyQrc4NqpCqZhIJOoyB9Lw/A/C6BGP+3q0KwMC692soATR7N3doNb1wba8qkrk3OU 8slHTx5N8yvGkbeOc4bkWUaZsAFHzIS/7cFnsrdG1PrKT2aPFBc6MXAGYIVwEC1bbYKe a0h+WELb0rlac6vxvRMFbxQfufJjzPPyu572YfYyVjhgnVbPjXyKMN2XRlj00/K7Ds26 5LnEjiOvjtfea2b+a9B8yJ9WhRFHEkCpr4b+WAkjLPI5HiobQuGw5LxYeSOeN/uGabbi kZ2g== ARC-Authentication-Results: i=1; mx.google.com; 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 p2si3014692eju.192.2020.07.23.17.13.02; Thu, 23 Jul 2020 17:13:24 -0700 (PDT) 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; 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 S1728251AbgGXAMv (ORCPT + 99 others); Thu, 23 Jul 2020 20:12:51 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:56654 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbgGXAMv (ORCPT ); Thu, 23 Jul 2020 20:12:51 -0400 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id E3DF072CCDC; Fri, 24 Jul 2020 03:12:48 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id B5F297CFF73; Fri, 24 Jul 2020 03:12:48 +0300 (MSK) Date: Fri, 24 Jul 2020 03:12:48 +0300 From: "Dmitry V. Levin" To: Alexander Viro , Serge Hallyn , Andrei Vagin , "Eric W. Biederman" Cc: =?utf-8?B?w4Frb3M=?= Uzonyi , Arnd Bergmann , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs/nsfs.c: fix ioctl support of compat processes Message-ID: <20200724001248.GC25522@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to Documentation/driver-api/ioctl.rst, in order to support 32-bit user space running on a 64-bit kernel, each subsystem or driver that implements an ioctl callback handler must also implement the corresponding compat_ioctl handler. The compat_ptr_ioctl() helper can be used in place of a custom compat_ioctl file operation for drivers that only take arguments that are pointers to compatible data structures. In case of NS_* ioctls only NS_GET_OWNER_UID accepts an argument, and this argument is a pointer to uid_t type, which is universally defined to __kernel_uid32_t. This change fixes compat strace --pidns-translation. Note: when backporting this patch to stable kernels, commit "compat_ioctl: add compat_ptr_ioctl()" is needed as well. Reported-by: Ákos Uzonyi Fixes: 6786741dbf99 ("nsfs: add ioctl to get an owning user namespace for ns file descriptor") Cc: stable@vger.kernel.org # v4.9+ Signed-off-by: Dmitry V. Levin --- fs/nsfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nsfs.c b/fs/nsfs.c index 800c1d0eb0d0..a00236bffa2c 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -21,6 +21,7 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, static const struct file_operations ns_file_operations = { .llseek = no_llseek, .unlocked_ioctl = ns_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static char *ns_dname(struct dentry *dentry, char *buffer, int buflen) -- ldv