Received: by 10.223.164.221 with SMTP id h29csp1432304wrb; Tue, 17 Oct 2017 03:09:25 -0700 (PDT) X-Received: by 10.101.74.193 with SMTP id c1mr10695193pgu.260.1508234965318; Tue, 17 Oct 2017 03:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508234965; cv=none; d=google.com; s=arc-20160816; b=Rz7m6RQ4puZG74XSFkMcd3NH32F1oEBfST71CbtK5d6lkS7dBbCyhhs2XQoF6noTVJ RdKLI8bbR6W9FmsnzI/UeoOWAQNlS3yowGiZ7/7ri2o7juKMF75vJsFsa2qLRNBWidDR 7JOpJyrwdE/HZzlqtd6rvgr7RfSWbGCg/fd6DKORHNCEzO2X+8vzIlm7iYByKcgpGRMJ VbkjhuwR8PIl18D9dtr1gl3gziA/xzyIRFTfmn341iYvHBRonA+yNklN++WoDxt/qlLK BmSNVsfSYR3aAwyJ+5urNGns1Jjz4+e+NLUkBhbjsBVh/UYHj9zZOoOjsUKhUeDnAXCh 6pdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Gaqn03a2s2+2pYsnrUZAaGmgXgJbLtTmXFa2bwgUvKM=; b=KkN2cIVgL3KC7yVlT9iADklB8EP3X16tRKuDBmRYPbF/EDOJjMn9YIpOiVfDKeRFZ/ B1DLGKiP0WoYhW8xmlkTNZujRioSeXftlRH/pBUcKAGq+Uz6Z8j0t+0zQXzv0Gigc2fl yWwQLSMtCqYljiE+Um/WhNiPXV3UmZEx8+1g/w1rO/EbQnC5vgX6cMINhLngTbBvSdgX kksKvp1zA46y2NJvllYNtmUfLeZn5H2c86Ado7/Vm6bJ7vSN0DtTiymKM0+aOcc1qLkc q8RBkLQmUlBhOgGofqYhB44U3UuSVmAE8g8OBesfGP02+WqSxIRJxmuPADcSXRzQxCio Gi5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=dT6mVFhQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si5257348pgs.564.2017.10.17.03.09.11; Tue, 17 Oct 2017 03:09:25 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=dT6mVFhQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757485AbdJQAxU (ORCPT + 99 others); Mon, 16 Oct 2017 20:53:20 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:53897 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754752AbdJQAxS (ORCPT ); Mon, 16 Oct 2017 20:53:18 -0400 Received: by mail-it0-f53.google.com with SMTP id n195so461490itg.2 for ; Mon, 16 Oct 2017 17:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Gaqn03a2s2+2pYsnrUZAaGmgXgJbLtTmXFa2bwgUvKM=; b=dT6mVFhQL1LW9J+CoY4w8RKFCvl3meoVIEA+ab5AXISJpDWx9gX69iQq5ydLVGaE60 Dl+NfruAVVDcxijHfRWPMiberZV4YD7UhySrJ7jgp47lTVrj8fdcxYg0ejrNIoNgmjsO OtcO/vuj3qmYEOzK9uPELTm2xbEB28+Psp50cHLAGGSQ0fNvybs6/9koLdAfpSGjt/K2 SEdVEFdyK8gXNUf3OA69M4N8lslk3sPzvdY8gYAZRMCtRMN9k9th02fhEEVZ/wEGpPZF 0q8ML4I1mG/4rDEJVDiSfoCQYJ7YUO0f4QN4M/4/LP07NE6YKhJishMIx38HTBcxKs1c Qtng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Gaqn03a2s2+2pYsnrUZAaGmgXgJbLtTmXFa2bwgUvKM=; b=dScmafhQYEXHpqA56Y966y5rzxqm3tX7MqKWyo9jXHL+Jev/aI4N2b/lChGV+Kkd/0 eo/ccAYs2Jf0tCcRkJst2bojriBxQbTDIw+EHIF7SMDVoS1jcIsPjT0BJhjnXWG4d4zv N6n+PQ2Qh4E1TivfXevRqyAXVvlMLMC36Jtl7NiEpcSiChdx5ZJtjTIEvWejAgOl0Enj tojXj0HIzkcUbV53gLrgUbT1KhQCOBsqawzl8eTELx0hIvKpmgxdfismEDMwEHWSAxN+ +8GWNpmNpUoUI5fLHk19UZxzeYrPSvLxg/Lfz5xgue2bsLXtDHg/25hOtLS7RoCUAovC Kusw== X-Gm-Message-State: AMCzsaU5YCgbLRGl8DjNDTRQnkCDGVKyigCm1KsPKe7lhKL4qVfrQrsf E/q6phloERE45z504DyDqN/ft8HN3mO0bQ/tBRBjwuIK X-Google-Smtp-Source: ABhQp+SDFG4RNXVtBpYfv1YRvTdC0bUmKc1rkQJxWCGawkrLq57BlcDzQfoOR09VMaqqoGEpDpfKlrD1GBG0M1wqHAs= X-Received: by 10.36.217.206 with SMTP id p197mr3545970itg.45.1508201597327; Mon, 16 Oct 2017 17:53:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.106.77 with HTTP; Mon, 16 Oct 2017 17:52:56 -0700 (PDT) In-Reply-To: References: <150788678482.924140.11785205105514746135.stgit@buzz> <20171013160514.GA27812@redhat.com> <3bdb5341-9ae6-265a-ce5b-45c2cfc76fad@yandex-team.ru> <20171016143628.b2ef80a9ef16d4345889b4d9@linux-foundation.org> From: Andy Lutomirski Date: Mon, 16 Oct 2017 17:52:56 -0700 Message-ID: Subject: Re: [PATCH v4] pidns: introduce syscall translate_pid To: prakash.sangappa@oracle.com Cc: Nagarathnam Muthusamy , Andrew Morton , Konstantin Khlebnikov , Oleg Nesterov , Linux API , "linux-kernel@vger.kernel.org" , Serge Hallyn , "Eric W. Biederman" , Eugene Syromiatnikov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 16, 2017 at 3:54 PM, prakash.sangappa wrote: > > > On 10/16/2017 03:07 PM, Nagarathnam Muthusamy wrote: >> >> >> >> On 10/16/2017 02:36 PM, Andrew Morton wrote: >>> >>> On Sat, 14 Oct 2017 11:17:47 +0300 Konstantin Khlebnikov >>> wrote: >>> >>>>>>> pid_t translate_pid(pid_t pid, int source, int target); >>>>>>> >>>>>>> This syscall converts pid from source pid-ns into pid in target >>>>>>> pid-ns. >>>>>>> If pid is unreachable from target pid-ns it returns zero. >>>>>>> >>>>>>> Pid-namespaces are referred file descriptors opened to proc files >>>>>>> /proc/[pid]/ns/pid or /proc/[pid]/ns/pid_for_children. Negative >>>>>>> argument >>>>>>> refers to current pid namespace, same as file /proc/self/ns/pid. >>>>>>> >>>>>>> Kernel expose virtual pids in /proc/[pid]/status:NSpid, but backward >>>>>>> translation requires scanning all tasks. Also pids could be >>>>>>> translated >>>>>>> by sending them through unix socket between namespaces, this method >>>>>>> is >>>>>>> slow and insecure because other side is exposed inside pid namespace. >>>> >>>> Andrew asked why we might need this. >>>> >>>> Such conversion is required for interaction between processes across >>>> pid-namespaces. >>>> For example to identify process in container by pid file looking from >>>> outside. >>>> >>>> Two years ago I've solved this in project of mine with monstrous code >>>> which >>>> forks couple times just to convert pid, lucky for me performance wasn't >>>> important. >>> >>> That's a single user who needed this a single time, and found a >>> userspace-based solution anyway. This is not exactly compelling! >>> >>> Is there a stronger case to be made? How does this change benefit our >>> users? Sell it to us! >> >> Oracle database is planning to use pid namespace for sandboxing database >> instances and they need an API similar to translate_pid to effectively >> translate process IDs from other pid namespaces. Prakash (cced in mail) can >> provide more details on this usecase. > > > As Nagarathnam indicated, Oracle Database will be using pid namespaces and > needs a direct method of converting pids of processes in the pid namespace > hierarchy. In this use case multiple > nested PID namespaces will be used. The currently available mechanism are > not very efficient for this use case. For ex. as Konstantin described, using > /proc//status would require the application to scan all the pid's > status files to determine the pid of given process in a child namespace. > > Use of SCM_CREDENTIALS's socket message is another way, which would require > every process starting inside a pid namespace to send this message and the > receiving process in the target namespace would have to save the converted > pid and reference it. This mechanism becomes cumbersome especially if the > application has to deal with multiple nested pid namespaces. Also, the > Database needs to be able to convert a thread's global pid(gettid()). > Passing the thread's pid(gettid()) in SCM_CREDENTIALS message requires > CAP_SYS_ADMIN, which is an issue. > > So having a direct method, like the API that Konstantin is proposing, will > work best for the Database > since pid of a process in any of the nested pid namespaces can be converted > as and when required. I think with the proposed API, the application should > be able to convert pid of a process or tid(gettid()) of a thread as well. > Can you explain what Oracle's database is planning to do with this information? From 1581476353266366824@xxx Tue Oct 17 04:09:40 +0000 2017 X-GM-THRID: 1581133950441644275 X-Gmail-Labels: Inbox,Category Forums