Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2206360pxb; Fri, 25 Mar 2022 13:02:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5BBo6DMakenqvM21RTzMj2vC5eCAB9nPGWjbPgoAAP0Q/1+efnQstngVE9cB+6TfHUtP2 X-Received: by 2002:a17:902:e80b:b0:155:c75a:42f with SMTP id u11-20020a170902e80b00b00155c75a042fmr8482705plg.67.1648238559608; Fri, 25 Mar 2022 13:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648238559; cv=none; d=google.com; s=arc-20160816; b=dC3SSxkADHI9tsX3Iv2x45YkLawGXs3ZUec5iYkIIKNUPTSzo+z5rvDgqlCshuzJ5P wt5Dn9kzk26LPz+BM6wdgaA4mFpeNlVPp3NkU9iXb7XzuYaYbuKbWXXhMakCIVYtUyTr Bzmd8QedSBrXrLYiNnnoNk/3sC4GvmhSJTKclteo+3zI6Ffr7dkT4PGPB/Y2RsMOwKgV 3o1dABagUHE+qn9HlBvnldeF1fYKDMyGwTCBb7ePlF39A5D31/gTeHlAyPP5TU/+YWhS 6JVea3h45sijdxmCk5Yu6QbPXxxyus1Pa+AargX08A6WrvIEO/9PSLWJ+u+8R4/Msmyw 3sAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=ai5cculYaBCNGgkNRTrUS8pZjDUPLZBEnhlK8ay5zH4=; b=gozgQZEkoKu9EYxjwXcHJUe9QkYPVOEwhmni5QOpkmQQhCnMkYWdvYI42IB+kzgxOC hTGGxCAtNZSp+T6VlUjBoZjJl+X5eWAGK2FXmyLA2ovifHqObdCL4TCedmJySNV4JMlN jguARow/y1kSvtzZ8JuZ98qqtZd9FlG6VQLBYkUgnUh3n0hxlqkOWYE8SiGK2ydvA8iL q02j2VFYCiL/YcHnwd5L5wioRV3/CxvnUK4NzkL8+N0+lAWMeKJek/KI0dF/Z5kTxnWO j59mEoChFOwSk6CKEcgM6Lf50XDSfUpgFlxyOsMPgPEUolDh+MbykpbkTXpakejdWIMg H1AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=XkAcMTAQ; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j9-20020a633c09000000b003816043f135si3215639pga.810.2022.03.25.13.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 13:02:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=XkAcMTAQ; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9F60239ADDE; Fri, 25 Mar 2022 11:52:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352262AbiCYQFy (ORCPT + 99 others); Fri, 25 Mar 2022 12:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236383AbiCYQFw (ORCPT ); Fri, 25 Mar 2022 12:05:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E3BDA76E1 for ; Fri, 25 Mar 2022 09:04:18 -0700 (PDT) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A74291F7AC; Fri, 25 Mar 2022 16:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1648224256; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ai5cculYaBCNGgkNRTrUS8pZjDUPLZBEnhlK8ay5zH4=; b=XkAcMTAQrWZS6pKxT4yxgBKsP1lWNb8/BjqiHUZIvMe/LrfG4liVmm1/Ez2ES/8C6Cyraq PHoS+LYh9WKPFGEYqw+nQRv5wU5CiTXrkwBHOw26xu6pB6/syYfSYJjoJUA6Og6IreoNub Ta60PqnofHCaHB+urQfxh4gJR3DTciM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1648224256; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ai5cculYaBCNGgkNRTrUS8pZjDUPLZBEnhlK8ay5zH4=; b=6LQc1v/PdRk3Gnnxf6oLcDFDPyoG88ZdvGtMv8bXKyXzx8gT9KWTfb2zIsxowYoF2DqrmH aKsFMt6j2hLFhFAg== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 5762B1339C; Fri, 25 Mar 2022 16:04:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id gIdWEgDoPWLLLQAAGKfGzw (envelope-from ); Fri, 25 Mar 2022 16:04:16 +0000 Date: Fri, 25 Mar 2022 17:04:13 +0100 From: Petr Vorel To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Christian Brauner , Alexey Gladkov , "Serge E . Hallyn" , Vasily Averin , Andrew Morton Subject: Re: [PATCH 1/1] ns: Move MAX_PID_NS_LEVEL to ns_common.h, reuse it Message-ID: Reply-To: Petr Vorel References: <20220325112127.18026-1-pvorel@suse.cz> <87o81u88ju.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o81u88ju.fsf@email.froward.int.ebiederm.org> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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? Well, nothing more than to have constant which gives some description. Kind regards, Petr > 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);