Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7852316rwb; Tue, 6 Dec 2022 10:37:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf64wjcM+O5utsVg2fM6ZESB46Y2++Ep0u1Oz76cctj8xg929Zqnrk0iSDqZWBokGuulWFHX X-Received: by 2002:a17:902:e5c6:b0:189:a50d:2a1d with SMTP id u6-20020a170902e5c600b00189a50d2a1dmr33725169plf.18.1670351827322; Tue, 06 Dec 2022 10:37:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670351827; cv=none; d=google.com; s=arc-20160816; b=XQeYQRNmOx43fixKkdY42lW6DE/symf1Wj83s8obvyKpQVsnylVAhg1Fxv5QFVUpfY YwEHu7BVpZF/lz2MX+EWzQisuRhdUZPDZmxYZLTsoI2+KEtgU9R7Tiw76yQs2aOl/c/Y vr1W8/p7HbcfjgNX5eYGvXZt87Hlb0Ahb8UhKPocNI5yB/hyd9KEhLJD363tuS3hCGt3 sv0YvftSrMZOkpjiaa8YwD6c8FJ125CrGeNjVG50HXu6AJi7xuWotHX7Hq7p9FkW8RHm OXYbY/JmmHCBxS+n5PB4ikQ6yowRT/1rBLirlL6Gddy58m/r4xGL4QMB+PSA7OkBOi03 Q//g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ICtZNQQIECcoUV2T8DPLv/5CjLxlJxo5ELk63KJMTWM=; b=XhNwL82kBW24A18I5IW/N1FITHu6npDCRO1diQGepyy5ztEJLS9Qed6S+axzvgb47q +WlTo6RAUN6KIsrdGuw7eExYc79WYcUA+B/RZqN6H4cvsGg4P+hmReg9HkoV4ye3i+2P VE2ZflEqhyvrN3A+2urVbIcvKRcDTFJ+VMuLVCNN9tH7U/rKTYgqR4jgJLW6Ab2jhOKf fUIBMAzcL8IogL206zT706qGOKTBuDF6TzjDY4Q2tqt4ApM2k7kwrQwsPX5m1UMFmufK XP3egsEQsxJ82NMDyM3mBFn6XN9Z1X713TR1UJZb63UMGy1wP0DBJLO8Tge2Hlw1k7xi e/KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=D4UWvQHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc7-20020a17090b1c0700b0020de23fa58csi22720181pjb.12.2022.12.06.10.36.57; Tue, 06 Dec 2022 10:37:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=D4UWvQHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbiLFRtg (ORCPT + 77 others); Tue, 6 Dec 2022 12:49:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiLFRte (ORCPT ); Tue, 6 Dec 2022 12:49:34 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23D89209BB for ; Tue, 6 Dec 2022 09:49:33 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id q1so14012572pgl.11 for ; Tue, 06 Dec 2022 09:49:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ICtZNQQIECcoUV2T8DPLv/5CjLxlJxo5ELk63KJMTWM=; b=D4UWvQHkPpgWRIW2yCKzG63FY3IVtUaX+fckriYTJL9at6/DIqcow4qEB3G+XDMzA9 15EMESvE9DUNnWk3bNgQBDV4fp5ii+A6nV+tVNtmFLFJd9AY7Tppx8po2Icy0sMmBHdO BzLf6DUFG5CELzKIYP90gz+QdqwyjKpWZWXpBvGqT1AXk+res7180LhmgdJ6o99cdHAE 9HVJL0Yxb4kkVnjrzcQuQBDKIyu1yn8sCMP/xb1V6VaGb9onh9PDG0dPDj9AcqS9E8Ee E6UzfsUrtwoSANqGJOTYJJeX8GHGrdTnhPR7wtn98ekltN3Zxk7DHgMqqgG3O89sGICo 54tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=ICtZNQQIECcoUV2T8DPLv/5CjLxlJxo5ELk63KJMTWM=; b=ARrWy+KiMinVszSqTKH7sTBYeY6WayTXMvHoQGCaOGWbCnLYOeVUN1Ecue/khscV81 B4Nz+TuDJXe4R8Zl9s7FLTTogHhPWJVy/Hg/++QWfM6dyPd/JAtv2p5KF4NT0lj6e/5+ Vq9OD6Fccv28du8onfrImfy5CE4C62EwM8sj3X8Ja2DoyHYNFmdDh/EGekHsw1lqzebp GLpSUhh2h8Kmfm4/Tu+7Ioy9QWWqa9uOHrQMxFX9ZMMlGXm0wYfVXobnjzMiZQwunGmi 63Ah+svx0YCadxzJFNntCWTUP7m7vEhTCBWLPRBXbCLorzByGwauNl+SmX76T6QnLOEC 8qUg== X-Gm-Message-State: ANoB5pm9IWbKWQ1XR+HvYi8i8XMLEVDtXHJHiy+Eu6sHRA7AmNdNTXbr 4gGkKFTEwWocoQIn3BHWdxDdB2dCZcdqR4nZu9sV1Q== X-Received: by 2002:a63:f04d:0:b0:470:5d17:a62e with SMTP id s13-20020a63f04d000000b004705d17a62emr61433446pgj.620.1670348972272; Tue, 06 Dec 2022 09:49:32 -0800 (PST) MIME-Version: 1.0 References: <20221206152358.1966099-1-jeffxu@google.com> <20221206152358.1966099-4-jeffxu@google.com> In-Reply-To: From: Jeff Xu Date: Tue, 6 Dec 2022 09:48:55 -0800 Message-ID: Subject: Re: [PATCH v5 3/6] mm/memfd: add MFD_NOEXEC_SEAL and MFD_EXEC To: Greg KH Cc: jeffxu@chromium.org, skhan@linuxfoundation.org, keescook@chromium.org, akpm@linux-foundation.org, dmitry.torokhov@gmail.com, dverkamp@chromium.org, hughd@google.com, jorgelo@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, jannh@google.com, linux-hardening@vger.kernel.org, kernel test robot Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Tue, Dec 6, 2022 at 8:35 AM Greg KH wrote: > > On Tue, Dec 06, 2022 at 08:26:30AM -0800, Jeff Xu wrote: > > On Tue, Dec 6, 2022 at 8:04 AM Greg KH wrote: > > > > > > On Tue, Dec 06, 2022 at 03:23:55PM +0000, jeffxu@chromium.org wrote: > > > > --- a/kernel/pid_namespace.c > > > > +++ b/kernel/pid_namespace.c > > > > @@ -110,6 +110,11 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns > > > > ns->ucounts = ucounts; > > > > ns->pid_allocated = PIDNS_ADDING; > > > > > > > > +#if defined(CONFIG_SYSCTL) && defined(CONFIG_MEMFD_CREATE) > > > > + ns->memfd_noexec_scope = > > > > + task_active_pid_ns(current)->memfd_noexec_scope; > > > > +#endif > > > > > > .c files should never have #if in them. Can't you put this in a .h file > > > properly so that this does not get really messy over time? > > > > > > > > Thanks for reviewing. > > It seems to me that checking for CONFIG_XXX is common in c code in > > kernel/ path. > > Maybe, but please don't make it any worse if at all possible. It's > tough to maintain code like that. > > > Do you have a sample code pattern (link/function) that I can follow? > > Any of the zillions of #if statements in .h files :) > Thanks. I will take the approach of having real/stub implementation in the h file, and the c file using it without a compile flag. Please kindly let me know if this is not right. Thanks Jeff > thanks, > > greg k-h