Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2109339pxb; Fri, 25 Mar 2022 11:14:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU6o+uqrMa5NKN/sXjsWPjI+6CBxHdTJRtBeixAAMZaLPTUccw1PZxVevz6Stc0W9RUgmZ X-Received: by 2002:a05:6a00:843:b0:4f7:2830:6d81 with SMTP id q3-20020a056a00084300b004f728306d81mr11004506pfk.76.1648232087450; Fri, 25 Mar 2022 11:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648232087; cv=none; d=google.com; s=arc-20160816; b=ZvvtndodiyJAmz3x+NaL6U32WGYIR3Xl/XkhWZYSslXNN5vRw5WENmzCWrYRZx9xJo bY+25Klza8VUOSvZP7+KsluUsYUEuzfI7qBbZn3aRhLhkN3b4VQ+rfbxSMR49bYcgvaA zXQDYNozoKW5VUouN6NeLxeHI9hQJVGrhwmqGhUghpr1XvyDsf+PBzm37326l+5Ca4uy 90v8zumhnilieKPE4GWbY+vMzQ1GBAe0leHfLANO+aqAlwlWFrtvsRKYfJBOoPpx7w8+ CnX00zaQR18a69Dw7BkIgVD6u/osEAHEClsQmYSNeYpk0ocvkvQAhWblve1W+wgdI9TB e8ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=HxLYjRZYthrAFdFm4P1htTvkLkwyDbxjtajKk5ztIaY=; b=CYyUIMnRBwyGD17fVUasUihol34xI8V1kWv5ptCluav/y7F3d74CngqRIpEIL9AFNC ufJCFidnq8BN/0f7gpjncc/mvfpyuVdwthKXeaoqxioD/LPDgZn1oscKr2M9cybMMGbb 1yTReybmQFwDhpDDdRJ3r0cvymd424ur21AsfnEtV6XzUZz/o0DMCSRtusjWauHg4DPW 3SUcLdugpcPHejFlvD9/8HOURhx2UF00QRkMJXjK6M69in1YpdiRFrn6cSDk/Vhb82YL 5wRNjoRlNeFzhmi5pxk5BcMOsZRA0aR4EPC/OkgH6bt1sQrCKaCT+NBc9Unj7xJW0ton WdWA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v21-20020a17090331d500b00153bd10da70si2852774ple.239.2022.03.25.11.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:14:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3F8514A91A; Fri, 25 Mar 2022 10:44:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346339AbiCYNby (ORCPT + 99 others); Fri, 25 Mar 2022 09:31:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237277AbiCYNbw (ORCPT ); Fri, 25 Mar 2022 09:31:52 -0400 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3CE252B02 for ; Fri, 25 Mar 2022 06:30:18 -0700 (PDT) Received: from in02.mta.xmission.com ([166.70.13.52]:49962) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nXk1A-002XcK-Rr; Fri, 25 Mar 2022 07:30:16 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:35450 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nXk19-0036C5-SP; Fri, 25 Mar 2022 07:30:16 -0600 From: "Eric W. Biederman" To: Petr Vorel Cc: linux-kernel@vger.kernel.org, Christian Brauner , Alexey Gladkov , "Serge E . Hallyn" , Vasily Averin , Andrew Morton References: <20220325112127.18026-1-pvorel@suse.cz> Date: Fri, 25 Mar 2022 08:29:25 -0500 In-Reply-To: <20220325112127.18026-1-pvorel@suse.cz> (Petr Vorel's message of "Fri, 25 Mar 2022 12:21:27 +0100") Message-ID: <87o81u88ju.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1nXk19-0036C5-SP;;;mid=<87o81u88ju.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.174.4;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19QVxhJidXPA7KZs1oAQPDdsHbodYjthcs= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Virus: No X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;Petr Vorel X-Spam-Relay-Country: X-Spam-Timing: total 325 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.3 (1.0%), b_tie_ro: 2.3 (0.7%), parse: 0.67 (0.2%), extract_message_metadata: 8 (2.5%), get_uri_detail_list: 1.05 (0.3%), tests_pri_-1000: 3.8 (1.2%), tests_pri_-950: 1.00 (0.3%), tests_pri_-900: 0.79 (0.2%), tests_pri_-90: 72 (22.1%), check_bayes: 71 (21.7%), b_tokenize: 5 (1.6%), b_tok_get_all: 4.3 (1.3%), b_comp_prob: 1.43 (0.4%), b_tok_touch_all: 57 (17.6%), b_finish: 0.73 (0.2%), tests_pri_0: 225 (69.3%), check_dkim_signature: 0.60 (0.2%), check_dkim_adsp: 2.2 (0.7%), poll_dns_idle: 0.68 (0.2%), tests_pri_10: 1.78 (0.5%), tests_pri_500: 6 (1.9%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 1/1] ns: Move MAX_PID_NS_LEVEL to ns_common.h, reuse it X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Petr Vorel writes: > Move MAX_PID_NS_LEVEL to ns_common.h and reuse it in check in > user_namespace.c. What is the motivation for this change? Is it just that there is a bare number in create_user_ns and that is a little ugly? Or is there something more motivating this? Eric > > Signed-off-by: Petr Vorel > --- > Hi Christian, all, > > I don't see putting MAX_PID_NS_LEVEL into ns_common.h as an elegant > solution but IMHO better than use a hardwired number or redefinition in > user_namespace.h. > > Kind regards, > Petr > > include/linux/ns_common.h | 3 +++ > include/linux/pid_namespace.h | 3 --- > kernel/user_namespace.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h > index 0f1d024bd958..173fab9dadf7 100644 > --- a/include/linux/ns_common.h > +++ b/include/linux/ns_common.h > @@ -4,6 +4,9 @@ > > #include > > +/* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */ > +#define MAX_PID_NS_LEVEL 32 > + > struct proc_ns_operations; > > struct ns_common { > diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h > index 07481bb87d4e..f814068012d0 100644 > --- a/include/linux/pid_namespace.h > +++ b/include/linux/pid_namespace.h > @@ -11,9 +11,6 @@ > #include > #include > > -/* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */ > -#define MAX_PID_NS_LEVEL 32 > - > struct fs_pin; > > struct pid_namespace { > diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c > index 5481ba44a8d6..6ea6e263403d 100644 > --- a/kernel/user_namespace.c > +++ b/kernel/user_namespace.c > @@ -87,7 +87,7 @@ int create_user_ns(struct cred *new) > int ret, i; > > ret = -ENOSPC; > - if (parent_ns->level > 32) > + if (parent_ns->level > MAX_PID_NS_LEVEL) > goto fail; > > ucounts = inc_user_namespaces(parent_ns, owner);