From patchwork Wed Apr 12 15:33:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 9677633 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 37485601C3 for ; Wed, 12 Apr 2017 15:34:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28B87285E8 for ; Wed, 12 Apr 2017 15:34:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C1B628625; Wed, 12 Apr 2017 15:34:13 +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 B23A4285E8 for ; Wed, 12 Apr 2017 15:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754239AbdDLPd7 (ORCPT ); Wed, 12 Apr 2017 11:33:59 -0400 Received: from mail-ve1eur01on0107.outbound.protection.outlook.com ([104.47.1.107]:51328 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751349AbdDLPd5 (ORCPT ); Wed, 12 Apr 2017 11:33:57 -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=Fb/hSy3iVWPbEoFXd9YSCe5/e1OoBnxx0MCBbVNzbmQ=; b=SPbauU4M9MP0JdAdfZHGvDtu4BrEi2bB1j8wIhSoD0pvDGXG0bZwG5HqlOJdtPV9N2NZwosccUm1GRPzGHIKenf9NoYXLn9+8Ydik6cNyBjUmYWaenIYDSGyjdDvui1NQnleQ7E5fyP4FkVooNU40P+pxLQNGf46o5OEPmg8glw= 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 VI1PR0802MB2286.eurprd08.prod.outlook.com (10.172.13.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Wed, 12 Apr 2017 15:33:51 +0000 Subject: [PATCH v2 1/2] ns: Allow ns_entries to have custom symlink content From: Kirill Tkhai To: , , , , , , , , , , , , , , , , Date: Wed, 12 Apr 2017 18:33:47 +0300 Message-ID: <149201120318.6007.7362655181033883000.stgit@localhost.localdomain> In-Reply-To: <149201102204.6007.8628824763325355297.stgit@localhost.localdomain> References: <149201102204.6007.8628824763325355297.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR03CA0006.eurprd03.prod.outlook.com (10.163.170.144) To VI1PR0802MB2286.eurprd08.prod.outlook.com (10.172.13.141) X-MS-Office365-Filtering-Correlation-Id: 6b2a7c0f-4402-41b6-13fb-08d481b95375 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:VI1PR0802MB2286; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2286; 3:RJ/QNesSATq25aRfk1BhPWzQo0kIlZjRaxPOLA4lL8X7rp+qeqtRHSM6x8advJ4O4/GcCF1hsutU0YF/PGFuOgpfHWCZYgPB9nXj2sdAvpvHiS+jMYw95QOpBodtsGM25wbyYQdCgY0uK8dXkzsOqzqmyPS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RpexzuZkpl+3Y6ymuPfdaU+Lvad3iKZ2RmsOzjm9IpnNjUtaDpJwVTucEe7fhRuTAp/wDZT7yT0XkVW1zZnrQivgA/IT6zVJLhx1pJbqtVOZugqhPviVReqeSPdXOl/1Qws3qRsLZi7ZcZ4KJKJR8p87rvYUPjHWp10gNL8QXQbv9VLiGTKhv3au8KJJHR6FyM543e6xXteiAiOuTUMfavpxGyjK0AIrBU/EQCMhWgodwE1/ZapbC9hvT4YGGbejaw994ZNPOzZSVfzXx/9LyuMZJg4d1bOgU/rVrWSBw= 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)(10201501046)(93006095)(93001095)(3002001)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123562025)(20161123564025)(6072148); SRVR:VI1PR0802MB2286; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0802MB2286; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2286; 4:ilgWpbNcbrPx50jcbscXMcW2jbvrkZ3omSEr0Rg3bFV807G+L0BlzM+zKp/qlq53ZDllvOYsjjPTI1e7cc7xthg2k1JmCVlQzPMNEAfP+2b4SRfu/v9inUmEEQF336Wg5T2+L94ZFqTKI1yBRmh7BNrleLXM2OsBOrbKh0ReAkImmM2RA2ejf22QylOdSX3A7EoRyey1ni7I/IQQkOZMg0HSb3FJUpCe7sQRRYad0JbZpLz8NO+jNOemmyqgL767nHD6f3uVz57ly3m43LMdT4rwWtYUrQpLtEgjDwv8uOd/WIaAJUiO1Tftou9BON50gj6j6+nisKS8U/SIspmCLSzHJ+4MdB637zAVWqCNFVyPyhYeLH1y/4TnUWGl6ZlcWpBYE6Rww5hUYO6qPbbG/ltloiOOco9tlC1ZHiqXZP4WxfeUHzLlia33VZol6uXLq573S21f0baNP7DGSGqD/tzxdsNUxiCcL+skl41Q7EpYmqcB9t3Y6TtrvIP+388lDmmVhT4HNc9IHnHZ13rTJWxtqZAic8JvXrfnOHSzHAs1RiRRKT851F1Cd18DnymT75lWZWIGF879XPMuc2KSXmCuyge2db5zzysR1Ej8PP9cbcpMv4LmPkjVNmPKGkk6/5ZjRxC1hw5Mt0CuzjsiKCOKnZqCMSxFxRCyDsueqG4ZG8UAp5EKUmOBnuxAg+tL0SA2RUNvKwfpWXDHoSfGZw== X-Forefront-PRVS: 027578BB13 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39400400002)(39410400002)(39830400002)(39450400003)(54356999)(25786009)(86362001)(6506006)(55016002)(42186005)(6666003)(50986999)(76176999)(61506002)(50466002)(7416002)(103116003)(33646002)(2906002)(5660300001)(2950100002)(189998001)(6116002)(3846002)(23676002)(8676002)(230700001)(7736002)(38730400002)(305945005)(81166006)(66066001)(83506001)(4001350100001)(53936002)(2201001)(9686003)(921003)(21314002)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0802MB2286; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjA4MDJNQjIyODY7MjM6L0xkTlRpR3ZlVUR0djhyVG01QmM4Nllo?= =?utf-8?B?dlFmU09kL2RFb2tUWW9UTytzenRXWndiMVh3TXhBUXI0Q2Y3Umc5VDJQeEJo?= =?utf-8?B?bmh5aE5pQ1NZaThRSmxLOTQySElMa3RkOGpJUGpQRVNETFdjN29jSzNpVEo3?= =?utf-8?B?VitmQ2pza0pDbkIvcHJTdHB1VUVMczFDRnE4UjR6T1FxZWlvdDAzczdMd2Fu?= =?utf-8?B?c0NWY1BwM3d0OG8wbW52K1BWRnd5clgxWThER1hqRnV5dlAyNFNHbEd3cnRw?= =?utf-8?B?SVBnOE9BbGpuNE8xdkRHNDRnRzI5bWpBOHNHeHMxbytDWml0ZWcwWC81QnRB?= =?utf-8?B?VHdyWjVQcj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NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2286; 7:fw02DE5n3q+gPGoB49XRR5GFSLdZWHCjNxLwsF+3uXKEI50ORqMJxFXq3To7PG4adp1idXjcFzlZGXl5BEYh6VuOLu7nYnUQSgZx7xdRSRwqnNjRRH8DRjrdtSTN+xq8EdWOrC2DfuMIEz2/Me9fUhbgkq1qN08pAO7A/g2js35pViYMZoUtwM2DinpijGSSt2SBJmQnNMJif0nf87IZJfzxpMUdR+/rL5nEJlx8L+DNdBGRZ2UOxTVGIbSW2WXPVTq7AXCNZbVBNkaVLaRG3JtlcrtHX9qGf6/3uCQKRvUIqc9ZpVaHQsRjPucX754Rhf7Le6MR0FO8N8yirwGp9w==; 20:x3KEysa//lY063IpP2YwHAyI0MRM/HC0Qw9dnxJAPJYRni4VH68Jbf5wNgY7i23S47mfcvaPGAD/1zJYriWYGtIerEEtl29ok2/gAYNJJM508YQlwv1FUI5hVztGWRFCM32EwaxokwnCr/3XmA7Gi2MNe51DtMg4GpedDfK6QgU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2017 15:33:51.8673 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2286 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 Patch series "Expose task pid_ns_for_children to userspace". pid_ns_for_children set by a task is known only to the task itself, and it's impossible to identify it from outside. It's a big problem for checkpoint/restore software like CRIU, because it can't correctly handle tasks, that do setns(CLONE_NEWPID) in proccess of their work. If they have a custom pid_ns_for_children before dump, they must have the same ns after restore. Otherwise, restored task bumped into enviroment it does not expect. This patchset solves the problem. It exposes pid_ns_for_children to ns directory in standard way with the name "pid_for_children": ~# ls /proc/5531/ns -l | grep pid lrwxrwxrwx 1 root root 0 Jan 14 16:38 pid -> pid:[4026531836] lrwxrwxrwx 1 root root 0 Jan 14 16:38 pid_for_children -> pid:[4026532286] This patch (of 2): Make possible to have link content prefix yyy different from the link name xxx: $ readlink /proc/[pid]/ns/xxx yyy:[4026531838] This will be used in next patch. Signed-off-by: Kirill Tkhai Reviewed-by: Cyrill Gorcunov Acked-by: Andrei Vagin --- fs/nsfs.c | 4 +++- include/linux/proc_ns.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/nsfs.c b/fs/nsfs.c index 1656843e87d2..495f12b83a7b 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -195,9 +195,11 @@ int ns_get_name(char *buf, size_t size, struct task_struct *task, { struct ns_common *ns; int res = -ENOENT; + const char *name; ns = ns_ops->get(task); if (ns) { - res = snprintf(buf, size, "%s:[%u]", ns_ops->name, ns->inum); + name = ns_ops->real_ns_name ? : ns_ops->name; + res = snprintf(buf, size, "%s:[%u]", name, ns->inum); ns_ops->put(ns); } return res; diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 12cb8bd81d2d..88dba3b53375 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h @@ -14,6 +14,7 @@ struct inode; struct proc_ns_operations { const char *name; + const char *real_ns_name; int type; struct ns_common *(*get)(struct task_struct *task); void (*put)(struct ns_common *ns);