Received: by 10.213.65.68 with SMTP id h4csp1605439imn; Thu, 5 Apr 2018 00:04:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx49YXg1QoGWdv2xKrfPWT450hjTogP9xTymlk1S6u/CfSfpYhMowvJ+mbCNfEKHTntltkUAZ X-Received: by 10.99.112.70 with SMTP id a6mr14074136pgn.5.1522911873610; Thu, 05 Apr 2018 00:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522911873; cv=none; d=google.com; s=arc-20160816; b=b7qGfOiueGUWNwfkzNbzPceBNLvtXrE0QjqkU4yUtey0SMTI6isq+Sb8xhCcsd3ZCJ gHcwH0+wzDyLAf7JPA/1O8r1Ti2PYMiyZ1GcGxhmni/yyrDxO7pz5uC5HmoXR7HRSKSS qS1qHbrQh9Pz0dJZun5lwVNOPG6mQQl76OYWk8MEL6/bWM9JcGfa220C+OODyCjUg83W gDoB7z/J3lZ884vEvG7R+M4Ia9+Qq0AFBhnRCEczPe2CdpsDHbLYIv+uFWybsD8qVAyl Z4CJtzpNb8PMbEZMeQ8SMLGhZOGrgBgQt8Rzm8vVg4V8Cl7xIaWswqqChJwP6se04IxF dl7Q== 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-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=iWk4fCwbqPTcGiZa6ifjw7THXXeIoQrgAt7tj1RZ+9g=; b=u3/6tK+4Jr5Nn/gmC0fAj/T9obN2tIg2os8RTHoi1KuBTZzmk1A9E7M8SpCeD60Ky8 4kKWebEf5P/9+0p2fYUecVM6zsbTSGUzoc3D6mmmm4A7xZMj0Zd+TFhwG+g8hVXkJRKe IzgUAJfjlICnYpEPpTtyx0y6/E0NhwDlxiL16k6lNxJh1JEahNEcfwyXE2as991ycHYu h3V9znJTohejyp3iJRPjcv1qsoVk3XenWxRG5v/X1hEon9/y9Mv/BwrzpmNDJjYnIH9X 9hmVT23oLRjOvFCX0COFujVa2LfPHYl35mvhFaR6wan4ggoBLowTJ3/VWi4+vhVO1vy1 stmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=EpaVDSs8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si7653559pld.172.2018.04.05.00.04.19; Thu, 05 Apr 2018 00:04:33 -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=@yandex-team.ru header.s=default header.b=EpaVDSs8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751353AbeDEHCr (ORCPT + 99 others); Thu, 5 Apr 2018 03:02:47 -0400 Received: from forwardcorp1o.cmail.yandex.net ([37.9.109.47]:40177 "EHLO forwardcorp1o.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751104AbeDEHCq (ORCPT ); Thu, 5 Apr 2018 03:02:46 -0400 Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:10]) by forwardcorp1o.cmail.yandex.net (Yandex) with ESMTP id 87D6B216B4; Thu, 5 Apr 2018 10:02:43 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtpcorp1p.mail.yandex.net (Yandex) with ESMTP id 807826E409F4; Thu, 5 Apr 2018 10:02:43 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:b010:d002::1:63]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id TlmqQp1Tv5-2hduJVR4; Thu, 05 Apr 2018 10:02:43 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1522911763; bh=iWk4fCwbqPTcGiZa6ifjw7THXXeIoQrgAt7tj1RZ+9g=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=EpaVDSs8MKHD17vNy7gs+LLv+1eRmAa0nJKF9tLx/5q/Qs5iJYeZ92K/tVqynALoB u9op9g+C1UaSZDpNI6saMA4I2fQCegbji0qCkST9sgOYT01PFI0A8fOhCA2/XR8idK j14Cs+EN8yukQWTnxa7aPkWBqINhsZuUX44hWz7g= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: Re: [PATCH RFC v5] pidns: introduce syscall translate_pid To: "Eric W. Biederman" , Nagarathnam Muthusamy Cc: linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Jann Horn , Serge Hallyn , Oleg Nesterov , Andy Lutomirski , Prakash Sangappa , Andrew Morton References: <152286911105.615669.14053871624892399807.stgit@buzz> <87h8oqhagl.fsf@xmission.com> From: Konstantin Khlebnikov Message-ID: <112c7cac-1982-3a2e-ffc0-878bc5ae4bb6@yandex-team.ru> Date: Thu, 5 Apr 2018 10:02:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <87h8oqhagl.fsf@xmission.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.04.2018 01:29, Eric W. Biederman wrote: > Nagarathnam Muthusamy writes: > >> On 04/04/2018 12:11 PM, Konstantin Khlebnikov wrote: >>> Each process have different pids, one for each pid namespace it belongs. >>> When interaction happens within single pid-ns translation isn't required. >>> More complicated scenarios needs special handling. >>> >>> For example: >>> - reading pid-files or logs written inside container with pid namespace >>> - attaching with ptrace to tasks from different pid namespace >>> - passing pids across pid namespaces in any kind of API >>> >>> Currently there are several interfaces that could be used here: >>> >>> Pid namespaces are identified by inode number of /proc/[pid]/ns/pid. > > Using the inode number in interfaces is not an option. Especially not > withou referencing the device number for the filesystem as well. This is supposed to be single-instance fs, not part of proc but referenced but its magic "symlinks". Device numbers are not mentioned in "man namespaces". > >>> Pids for nested Pid namespaces are shown in file /proc/[pid]/status. >>> In some cases conversion pid -> vpid could be easily done using this >>> information, but backward translation requires scanning all tasks. >>> >>> Unix socket automatically translates pid attached to SCM_CREDENTIALS. >>> This requires CAP_SYS_ADMIN for sending arbitrary pids and entering >>> into pid namespace, this expose process and could be insecure. >>> >>> This patch adds new syscall for converting pids between pid namespaces: >>> >>> pid_t translate_pid(pid_t pid, int source_type, int source, >>> int target_type, int target); >>> >>> @source_type and @target_type defines type of following arguments: >>> >>> TRANSLATE_PID_CURRENT_PIDNS - current pid namespace, argument is unused >>> TRANSLATE_PID_TASK_PIDNS - task pid-ns, argument is task pid >> >> I believe using pid to represent the namespace has been already >> discussed in V1 of this patch in https://lkml.org/lkml/2015/9/22/1087 >> after which we moved on to fd based version of this interface. > > Or in short why is the case of pids important? > > You Konstantin you almost said why they were important in your message > saying you were going to send this one. However you don't explain in > your description why you want to identify pid namespaces by pid. > Open of /proc/[pid]/ns/pid requires same permissions as ptrace, pid based variant doesn't have such restrictions. Most pid-based syscalls are racy in some cases but they are here for decades and everybody knowns how to deal with it. So, I've decided to merge both worlds in one interface which clearly tells what to expect.