Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1344259rdg; Fri, 13 Oct 2023 20:41:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8Ig50t0VfBcvzhM1r84s8ef3Bw1PkzHJ/sySeMU5AKWgDenaGGsr4Mz+lRwb6qTcyzOJU X-Received: by 2002:a17:902:c945:b0:1ca:71:ea41 with SMTP id i5-20020a170902c94500b001ca0071ea41mr3081601pla.22.1697254912927; Fri, 13 Oct 2023 20:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697254912; cv=none; d=google.com; s=arc-20160816; b=SyYVqJemzLFv2b1YRwJ675lcLHO8Y8QzlBbprE8AJJA0pL9whLMfGCxnN4dbuEzl6w jZx0lC8H1/IFmxybp9L3YmCzKMIgrThBbRAKuYilDt320yVASkXcPKJVtVf2WlNXAu6u JlkczJsDDe6kzyGG6qNatczXENL742nl09rw7S7FJuOZAWpiM7LvjvI3bZFLkODIhsrg l7PN5NMgnrFPmFhg585ww1VGvGt4rWZYVtekq09eca406G3YP6xrBtbeQOVtfQFaQd60 XnaEj0mJkEaaYCkdQNpcXXLnuMwhmyePfdEuemchnmK/hUj+XHaZgz1KomXUMjr0y0bP x+Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8+uqdmO4xgns3ugpSGvOEmhx6xIg/OI7rgx8ycNmbLk=; fh=ar1K26G0FMZoSMAiAaLVKwRkqwi6WSauIE31IKnOy+s=; b=FipTCGlgvtqX682vkxGb0nysbOyruQ0GQ4xpiOIXjVKJo7eShZr3kmTlSkKBKsYMdo ZOlfXS3htqHRRJHdgb6stJ/BLTofJADcwSf9TlJ4iuygP9ck4De3sevj6m6XaEatvbqe KPI5+LwrQjKuOiqWPi3wGYFCjUz3S+j0LgMBJkB8+twpFkPONSAYkWjdsT9Gf/vyACcy 1ccHyd1WzxNxeZfwHEcz1WgqVAz3DMSZA7yjDObbn07kTnH0sNwL2NvQVUijXM++eX7H 5+YQtJcQk+jYR6owD85XMlgQsipIm/hsuzfm45lNAqRG8ownxzag7MWbulac2iqcbKU7 TFRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=ItjQ00PP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id ij6-20020a170902ab4600b001c74d844254si5834489plb.101.2023.10.13.20.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 20:41:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=ItjQ00PP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8F9F480C3AB5; Fri, 13 Oct 2023 20:41:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbjJNDlo (ORCPT + 99 others); Fri, 13 Oct 2023 23:41:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJNDlm (ORCPT ); Fri, 13 Oct 2023 23:41:42 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0224C0 for ; Fri, 13 Oct 2023 20:41:18 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32d9d8284abso1084295f8f.3 for ; Fri, 13 Oct 2023 20:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697254877; x=1697859677; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8+uqdmO4xgns3ugpSGvOEmhx6xIg/OI7rgx8ycNmbLk=; b=ItjQ00PPlEnDC1tcuUDvWUvLQiOPtpY9hnAMUolMg016ZmvKA3bHMuTlpC9/1kab67 xZe04ZPxEBL9H53b2SXfYlV70dVUgC0/Osz8V3fc/REn203VKD33RiJrXBXCxfhwztH2 RpMP8tFUB67UHKHPBkqJbqq1LU6+xIpnZFRSXWphwJKq2aG5dHNlI34nFVZMy3Vk1yz3 RmdnJ3ELRmHFt7b53x9TSHjzT5khf6wzCn+V6SoXXDx9ZA5xn5oQljyZXqTKBaRkn9Rb QLbdKPbpN1lP5twI8nLKIDVaQm3PhPa2tnbqiRpXxts7/yU3oIIyWEyJinyscvQNHeGx Z+iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697254877; x=1697859677; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8+uqdmO4xgns3ugpSGvOEmhx6xIg/OI7rgx8ycNmbLk=; b=K14qAPr65rk2GElEYbZFx1s4HfRuSD7j2ymYF6Dk0Gq0cbDdL1ZrLByxf5CH64mfH8 Ae+yNi4RgkUgeY7eVbNXkOAy3GfvaEIHfP9EkmDgZD928AG3d71hqZPM540PlLWr2wGp IH0KPs2P26r6DAt9q3hHLH6yel0ZUKlmFC40loOc98OsdmYwH58fHPawCHC1vDbVGKwX 8GTjuCp6UL+uZgjFe/ApS/p/nROnJhiZdy8Zhrq0goFHcltLQD5BOfMv+dWi99FunyfC AgCiAz9ADkaBkUcU4BTtUKqhQ5TZLbUMC6dzhzkThdxhLpd/CreL5dui8D1Vctg3k2p6 v6yw== X-Gm-Message-State: AOJu0YxATDADIk1UmDwMlJsPe3eJdRv/NY4KSJmMmffJm8NlBLDgaHyz FrhTt2NtqyYVBw64xhR6WQXCyS06VUhb2gMnI+rPAg== X-Received: by 2002:adf:a4da:0:b0:32d:7615:372b with SMTP id h26-20020adfa4da000000b0032d7615372bmr8604025wrb.12.1697254877240; Fri, 13 Oct 2023 20:41:17 -0700 (PDT) MIME-Version: 1.0 References: <20231011065446.53034-1-cuiyunhui@bytedance.com> <87sf6gcyb3.fsf@email.froward.int.ebiederm.org> <87r0lyad40.fsf@email.froward.int.ebiederm.org> In-Reply-To: <87r0lyad40.fsf@email.froward.int.ebiederm.org> From: yunhui cui Date: Sat, 14 Oct 2023 11:41:06 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] pid_ns: support pidns switching between sibling To: "Eric W. Biederman" Cc: akpm@linux-foundation.org, keescook@chromium.org, brauner@kernel.org, jeffxu@google.com, frederic@kernel.org, mcgrof@kernel.org, cyphar@cyphar.com, rongtao@cestc.cn, linux-kernel@vger.kernel.org, Linux Containers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 13 Oct 2023 20:41:50 -0700 (PDT) Hi Eric=EF=BC=8C On Fri, Oct 13, 2023 at 9:04=E2=80=AFPM Eric W. Biederman wrote: > > yunhui cui writes: > > > Hi Eric, > > > > On Thu, Oct 12, 2023 at 11:31=E2=80=AFAM Eric W. Biederman > > wrote: > >> > >> The check you are deleting is what verifies the pid namespaces you are > >> attempting to change pid_ns_for_children to is a member of the tasks > >> current pid namespace (aka task_active_pid_ns). > >> > >> > >> There is a perfectly good comment describing why what you are attempti= ng > >> to do is unsupportable. > >> > >> /* > >> * Only allow entering the current active pid namespace > >> * or a child of the current active pid namespace. > >> * > >> * This is required for fork to return a usable pid value and > >> * this maintains the property that processes and their > >> * children can not escape their current pid namespace. > >> */ > >> > >> > >> If you pick a pid namespace that does not meet the restrictions you ar= e > >> removing the pid of the new child can not be mapped into the pid > >> namespace of the parent that called setns. > >> > >> AKA the following code can not work. > >> > >> pid =3D fork(); > >> if (!pid) { > >> /* child */ > >> do_something(); > >> _exit(0); > >> } > >> waitpid(pid); > > > > Sorry, I don't understand what you mean here. > > What I mean is that if your simple patch was adopted, > then the classic way of controlling a fork would fail. > > pid =3D fork() > ^--------------- Would return 0 for both parent and child > ^--------------- Look at pid_nr_ns to understand. > if (!pid() { > /* child */ > do_something(); > _exit(0); > } > waitpid(pid); okay, The reason here is that pid_nr_ns has no pid in the current pidns of the child process, and returns 0. Can this also support sibling traversal? If so, it means that the process also has a pid in its sibling's pidns. > > For your use case there are more serious problems as well. The entire > process hierarchy built would be incorrect. Which means children > signaling parents when they exit would be incorrect, and that parents > would not be able to wait on their children. Therefore, support for slibing pidns must be added to the entire logic of p= idns. Do you have any plans to support this, or what are the good reasons for not supporting it? Thanks, Yunhui