From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751402AbdEBVTy (ORCPT ); Tue, 2 May 2017 17:19:54 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:46736 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750710AbdEBVTu (ORCPT ); Tue, 2 May 2017 17:19:50 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Kirill Tkhai Cc: Oleg Nesterov , , , , , , , , , , , , , , References: <149245014695.17600.12640895883798122726.stgit@localhost.localdomain> <149245057248.17600.1341652606136269734.stgit@localhost.localdomain> <20170426155352.GA12131@redhat.com> <785e1986-da03-72aa-06c0-234ed2dbc0fd@virtuozzo.com> <20170427161255.GA19350@redhat.com> <20170427162254.GB19579@redhat.com> <43249645-f621-511e-dfa8-7bd78c547d2c@virtuozzo.com> <20170502163324.GA25036@redhat.com> Date: Tue, 02 May 2017 16:13:29 -0500 In-Reply-To: (Kirill Tkhai's message of "Tue, 2 May 2017 20:33:00 +0300") Message-ID: <8737cngdxi.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1d5fCx-0003qc-Js;;;mid=<8737cngdxi.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.233.227;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1863lN2NpLgoeu6t9mW4QCv9yI2Lm80Y54= X-SA-Exim-Connect-IP: 67.3.233.227 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Kirill Tkhai X-Spam-Relay-Country: X-Spam-Timing: total 5302 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 2.4 (0.0%), b_tie_ro: 1.65 (0.0%), parse: 0.80 (0.0%), extract_message_metadata: 11 (0.2%), get_uri_detail_list: 1.49 (0.0%), tests_pri_-1000: 6 (0.1%), tests_pri_-950: 1.18 (0.0%), tests_pri_-900: 1.01 (0.0%), tests_pri_-400: 27 (0.5%), check_bayes: 25 (0.5%), b_tokenize: 7 (0.1%), b_tok_get_all: 9 (0.2%), b_comp_prob: 3.8 (0.1%), b_tok_touch_all: 2.8 (0.1%), b_finish: 0.66 (0.0%), tests_pri_0: 305 (5.8%), check_dkim_signature: 0.88 (0.0%), check_dkim_adsp: 3.2 (0.1%), tests_pri_500: 4944 (93.3%), poll_dns_idle: 4938 (93.1%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 2/2] pid_ns: Introduce ioctl to set vector of ns_last_pid's on ns hierarhy X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kirill Tkhai writes: > On 02.05.2017 19:33, Oleg Nesterov wrote: >> sorry for delay, vacation... >> >> On 04/28, Kirill Tkhai wrote: >>> >>> On 27.04.2017 19:22, Oleg Nesterov wrote: >>>> >>>> Ah, OK, I didn't notice the ns->child_reaper check in pidns_for_children_get(). >>>> >>>> But note that it doesn't need tasklist_lock too. >>> >>> Hm, are there possible strange situations with memory ordering, when we see >>> ns->child_reaper of already died ns, which was placed in the same memory? >>> Do we have to use some memory barriers here? >> >> Could you spell please? I don't understand your concerns... >> >> I don't see how, say, >> >> static struct ns_common *pidns_for_children_get(struct task_struct *task) >> { >> struct ns_common *ns = NULL; >> struct pid_namespace *pid_ns; >> >> task_lock(task); >> if (task->nsproxy) { >> pid_ns = task->nsproxy->pid_ns_for_children; >> if (pid_ns->child_reaper) { ^^^^^^^^^^^^^^^^^^^^ Oleg my apologies I missed this line earlier. This does look like a valid way to skip read_lock(&tasklist_lock); >> ns = &pid_ns->ns; >> get_pid_ns(ns); ^^^^^^^^^^^^^ This needs to be: get_pid_ns(pid_ns); >> } >> } >> task_unlock(task); >> >> return ns; >> } >> >> can be wrong. It also looks more clean to me. >> >> ->child_reaper is not stable without tasklist, it can be dead/etc, but >> we do not care? > > I mean the following. We had a pid_ns1 with a child_reaper set. Then > it became dead, and a new pid_ns2 were allocated in the same memory. task->nsproxy->pid_ns_for_children is always changed with task_lock(task) held. See switch_task_namespaces (used by unshare and setns). This also gives us the guarantee that the pid_ns reference won't be freed/reused in any for until task_lock(task) is dropped. > A task on another cpu opens the pid_for_children file, and because > of there is no memory ordering, it sees pid_ns1->child_reaper, > when it opens pid_ns2. > > I forgot, what guarantees this situation is impossible? What guarantees, > the renewed content of pid_ns2 on another cpu is seen not later, than > we can't open it? Eric