From patchwork Mon Apr 17 17:36:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 9684015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4E5060326 for ; Mon, 17 Apr 2017 17:37:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AF592018E for ; Mon, 17 Apr 2017 17:37:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D7912029C; Mon, 17 Apr 2017 17:37:10 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 F06E72018E for ; Mon, 17 Apr 2017 17:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754485AbdDQRgN (ORCPT ); Mon, 17 Apr 2017 13:36:13 -0400 Received: from mail-eopbgr40094.outbound.protection.outlook.com ([40.107.4.94]:41147 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753914AbdDQRgL (ORCPT ); Mon, 17 Apr 2017 13:36:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=WmPHBrWgZcMQzxeuImxI6HKPf7wfgwMPWKVibklWSyg=; b=WQCrH9e4QYr1h/IgBkMbwZmqSI6cTgILtx8jeK/FTLPKj+i0QuE1VikfP0+TTUkPDMh6zfxg63tcVw87pH0Mdf8wxy0XImDGSEz1uTW0PAgxlWL8itCOHYlVRLs0pSpC5t3OMaIbEx0amy11b9H1ObOINQ18P1vKTs1o9pffiMA= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=virtuozzo.com; Received: from localhost.localdomain (195.214.232.6) by AM4PR0802MB2276.eurprd08.prod.outlook.com (10.172.218.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Mon, 17 Apr 2017 17:36:05 +0000 Subject: [PATCH 1/2] nsfs: Add namespace-specific ioctl (NS_SPECIFIC_IOC) From: Kirill Tkhai To: , , , , , , , , , , , , , , , , Date: Mon, 17 Apr 2017 20:36:00 +0300 Message-ID: <149245048927.17600.6201635115178279430.stgit@localhost.localdomain> In-Reply-To: <149245014695.17600.12640895883798122726.stgit@localhost.localdomain> References: <149245014695.17600.12640895883798122726.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR02CA0001.eurprd02.prod.outlook.com (10.170.218.142) To AM4PR0802MB2276.eurprd08.prod.outlook.com (10.172.218.9) X-MS-Office365-Filtering-Correlation-Id: 6f0b097f-7719-40d2-c6aa-08d485b83ad7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:AM4PR0802MB2276; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0802MB2276; 3:5nB42LiZCuH7YZCS5tSe5UvnEl6AmbWZNRsqzh3X4F2HT/ekCSo9evowfj7+6BYhS6u+Kog5zRSvU8ZGY5glLOOuoWgtT4p45nJbbo1XBzgclMJ0zUAatWYuz1uvSzCr0dJEWMZQOvrwcTYOULuX+prhY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KsjJBY40E6mtNYbwZzzn8LKsuh77itV2PTLpJzTV2CCGCxo3PUcfc5fFm5GYBz3sd64rFiZqfc5dE2YdjBdlcke7UQKakDzo+bt2UmepxAVes90yABoqT5ab0ksEq01+WYLoIAJ/reUZN3uKMNZXJvjI2iW8uhM1LqNkCOlQx0gVg7X2UAAaa42Sd4r136TTxu5hph3lqILRCBdGu3oOTBgWkvE2xEwsdAP985SWPWfs9HukGUkA0z+M0tgVKdhLfTyd5f4zjn4ZxwkVQHH1dEi3l1QfjmYcwCFIyEdI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(6072148); SRVR:AM4PR0802MB2276; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0802MB2276; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0802MB2276; 4:HvWJ7XV07Nla0aykzM0hGSxwh3+zWyWkKwv5HoYMThZMxP5YyowKlshuNLHy3rhB1FUqBmLyjyJhkEBTxwX4ZlFBtcoqv7PmNjGJ4C4DhYCuUsOmKSn0Mvw+r9LmDxewGSWRZb0LVA6prrTh2WFWlZ1PQ1gRSFQXu+BJRupNMxzUNiSbPXvCF83kBJqF9g+fYQwC7XKZELVXW4SuZs9vDApjyXOLx9O0W0Pn+H9uFoXlb7S5Mu/2D/5LC2zl4gYEWNFDt89yKzDy/Ut5ioaMjcVdnHqg1P8CI5FbjEqE34aXWOcLlBG2eSjrW/5dx0gYPPEY3xQxJod98/V/AeSnv87XVsMAqUA48pX9ds8W4ir0iLyQ7X71hLlzWLcas09Ft+4DGR25NtAWeHAYk95FqeGo17JASuSVT0QKhUdZPddO6qHS9zylTnDgzpyxpOGsKJDtDYzbih9xqI54A5SD+FasTDCBr7cIXaSjem0qSQnSaXKiys15WD/UDcBLUmIw/WRr3ZONUDnbALz3wfI+AbH4g7tA8LCun8g6B2yvCHkArOX2XD0KmEmBzrg+/MAD0d2SpHyuZRlW0KXRMTje12HedxRqc21xO2Du9hf9J047NB8jHCItk2BUhmKVr/kn+B4bH07wo2OBy54sA9hrHrAUphBI1GVwDokSdhfStgGg3va5iRQK8zBsmFbHhqcK3yA8RVTzlXdp5MremSY3NQ== X-Forefront-PRVS: 02801ACE41 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39450400003)(39400400002)(39830400002)(6666003)(50466002)(189998001)(9686003)(7736002)(230700001)(53936002)(86362001)(83506001)(2201001)(6506006)(38730400002)(7416002)(2950100002)(305945005)(76176999)(4001350100001)(66066001)(50986999)(8676002)(6116002)(2906002)(42186005)(54356999)(103116003)(5660300001)(23676002)(81166006)(3846002)(33646002)(47776003)(25786009)(61506002)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM4PR0802MB2276; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTRQUjA4MDJNQjIyNzY7MjM6K20xamhKOGd2VVJjNzJXcFJsV1F2eGda?= =?utf-8?B?OXdpN1d3MXVzdkFNYklEV2h0UkdPdy96cmpaZlZMNVY0b1hXQTJURmxvY3g3?= =?utf-8?B?MmtsZXBQYm1tY2tGbHdRM1R5TUx0bU52bTgzUVFrOGFBYTYyR1dUV2MyUzcz?= =?utf-8?B?bXpQQUdQVksxVDFIaXFaaUpxa3NZZVNSUGpqdjc2YUhZTVdEV3NOQjByT1ln?= =?utf-8?B?Y3FVMEVRM3ROaWQzbW5EK3ZXMmRYaU5MWCt4S0lOMkpsODJxMFZudjVZR3N6?= =?utf-8?B?eXlZb0I3OU9sYS90VzFTcW5HSCszbUwyeEJ3MDdqZStrVTd0STErQituWW5I?= =?utf-8?B?cnF3b1ZZRFp2VUErTjN0Uld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JlZlRsWDVIUVlJVXl2eld1MmFCYkNVbytKTWIycEprRnVQUW1DNkdxZzJC?= =?utf-8?B?UGtHSUhFUVpFSkNoUllTRFJsMHdwNmFHVEpwczByOGVXYU1temNhZHBHaDdy?= =?utf-8?B?U0Qrc21VR2VEUXJmMXlvTGZESGdOQXdKRHB0TG1CT2c9PQ==?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR0802MB2276; 6:I+2rcpSf4elYIQ0c2L5dsEIyxEUcsBPRWi9dT+X0mMOlVBN8Y/Ely36T9K+N4qRTlP/CW2fpp0NnhahJ47LRQns2NYsiPYugYgXGResFiLg7ulGZggADIuH/w97bQOvvZBbIdd5CwcetdRMO49xqQbOJEq2Tu5kqPvpU2TnZ7xQzVzMof5HwP4cv3h9gQKR6yCfq7nRCeZx3+Gafd1fog3vuejZitWeODoM41rt2qMniX0Nmct6VNAC4U+Bn4NXfFNE0A4QPaonEKDA9F5FQmngqtCKlWPiPezpKWJEtdMm0qtLiHXsEIJZ59Wsxhv6mT6U6J+6CKoAGViiNYe+CEZUZQp8o4btkzunwUeUWJyRfTaJX6jPw/rCXS9ewV9uexxLK6gzN5vqkPNPN8Fd3/OMbwCPLRrmgXyOv07Jfm13bOHMRLYUodHDkJGnTNLALjtQN2bZFYXp+obJH1XMv6g==; 5:ILHhtF0AN1jfJ9KWMlbcwkLbv+WomYgxbKj+oE9ByNHHa/UPjJG/G/YlHGXLZxZdLdzsooQh2MMPzbTqkjAdD5ugYJ5lohebMP3QP2Gab9RY9+iVAjvo0ex7l/d2cQ/lrAi75g15pvPxqLK4Asz1kw==; 24:NLmWwbfSA2mC/Fhel6Y4uRojc8SIbU6UtkaGJ5B9IMFBqeU30e5jWHSDQ2si8f74pG8ipfyigqpNE1jeShUJjEfLMR7Sv8HM+FXA91fbBd0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR0802MB2276; 7:tfFIP1s+XCEkr2f9xzUXCk0SPI66Nw+fLmgO6oeQBBjEGWq2IxnFuXYKn+e788LcHZ3yZxHV4+qG5vcIhIFURwU/gZkjEptuQVyh0Oi54eDHL4bjLZeC28qA0UjoYuGFtyaweTeJKqJSTuuYXuNBvKjnA9Y3L/Xb0t5i93Ii45E9Pxg+wFuji9v3gevIucmfOK0py1LB420EKqoaxXd0d7UAV1SxY6MKSUSzk48XxtGDwV1UCnyQC51NH292yQ6HEc5ktrI44MId+nEuOp1IXfi3WI13EX4M2O+jQItR/I8DLcOWJMm/hQWtIAtsCd6dlssF4BhLMgxEOpngoC6LCQ==; 20:ELKtVK66xHwbDnxuYGat72Yi9CjrcM+T2TfdObFf5d3p7SFznBp4tNhHa/EK3gvN+97pbWflAdvozYD/+jV7PlIV0XNXCvuZrxSzHTrvIH90p50eBgeFFXSmZ5kBLs8u1/nc6GJ52hQKMwLT2+r9DU3aEm/1RdJYCF8fODQ55hQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2017 17:36:05.8152 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2276 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some namespaces types want have their own ioctls. For, example, pid namespace needs a ioctl, allowing to set vector of ns_last_pid on namespaces hierarchy. This patch introduces proc_ns_operations::ns_ioctl() to allow namespaces determine specific ioctls. Signed-off-by: Kirill Tkhai --- fs/nsfs.c | 4 ++++ include/linux/proc_ns.h | 1 + include/uapi/linux/nsfs.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/fs/nsfs.c b/fs/nsfs.c index 1656843e87d2..fed7e5c59e9c 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -185,6 +185,10 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, argp = (uid_t __user *) arg; uid = from_kuid_munged(current_user_ns(), user_ns->owner); return put_user(uid, argp); + case NS_SPECIFIC_IOC: + if (!ns->ops->ns_ioctl) + return -ENOTTY; + return ns->ops->ns_ioctl(ns, arg); default: return -ENOTTY; } diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 12cb8bd81d2d..c645a2174933 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h @@ -20,6 +20,7 @@ struct proc_ns_operations { int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); struct user_namespace *(*owner)(struct ns_common *ns); struct ns_common *(*get_parent)(struct ns_common *ns); + long (*ns_ioctl)(struct ns_common *ns, unsigned long arg); }; extern const struct proc_ns_operations netns_operations; diff --git a/include/uapi/linux/nsfs.h b/include/uapi/linux/nsfs.h index 1a3ca79f466b..544bbb661475 100644 --- a/include/uapi/linux/nsfs.h +++ b/include/uapi/linux/nsfs.h @@ -14,5 +14,7 @@ #define NS_GET_NSTYPE _IO(NSIO, 0x3) /* Get owner UID (in the caller's user namespace) for a user namespace */ #define NS_GET_OWNER_UID _IO(NSIO, 0x4) +/* Execute namespace-specific ioctl */ +#define NS_SPECIFIC_IOC _IO(NSIO, 0x5) #endif /* __LINUX_NSFS_H */