Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7680763rwb; Tue, 6 Dec 2022 08:35:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5mKnDdGQ8keVBIQSvGwz0hytlcAxc33Hfjt+iZQA7oiyRbqi8Bf8Dj5NzT5eyD4MHztPtR X-Received: by 2002:aa7:c844:0:b0:461:a130:ea3c with SMTP id g4-20020aa7c844000000b00461a130ea3cmr75829417edt.272.1670344514946; Tue, 06 Dec 2022 08:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670344514; cv=none; d=google.com; s=arc-20160816; b=qjzTEPBnCr6GC0SFymDHuSw+W9rYg/D/1KcTy42hof6o9WuPr4sIC3DAYMr1AMsc7a myLQ5AXPNuJwMOtDcy26sKCVQY8ln58v8aN1pb7IrpXYn161Fa5ipH/hlIlYynzPyFvs P38bQUI0idbElHFEwmm+HVyKCwUwqnb0r2y/8BU3ktXwo4MRkKckZsutw6XmxUi95IO/ ftRaZUkYleeBhHvfPFhX+BtR7IvIpHCbxduuYAbdhEyR7AGPXjLE+oGYBcZGX5ngd2KR KIrEmCOlswX2nzTEKfUaK/oRMCy9QTZDTDKTZM58cPXVBXkNRhJWRvFODlwOfgMxpi3k AG5g== 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=JgcwRFCL6hgvtdlBwWhPhxTax1zzqSSsoj4r1eWsJf8=; b=0hqFHUqEYMe48Ia9CtRPwL4jVeZAM4oAUblUgcDZuiNsqk2dXUIG1nMk9zMfBJ5ZUX MVS8991hzXbPRbh2EVDwfXdCZ6eIgksISRnKhIZ3puJ0eGPObNpQfqNqTi248IGNbjC+ KFotOTSH1UWYXfAfHMCOrLEZ6F0EH5jntC88JeZrJmlHeAEFEHiMD68wOGkOJiUmuces CKQP/iEMjdpL0zy2wobBzEou3Of0q+myZpFAqahPOHKYCKRlnIRm5Pnsk/ATfUmhfxO9 741be3x0rxbbb76Axt8iOTZIB+WhqNqxJ146pdixHo/S34nVVmwOkGCNUywprch3M1Jn 3jCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kX76ACCq; 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 e19-20020a056402191300b0046cc7679846si2707753edz.311.2022.12.06.08.34.56; Tue, 06 Dec 2022 08:35:14 -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=kX76ACCq; 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 S234982AbiLFQ1N (ORCPT + 77 others); Tue, 6 Dec 2022 11:27:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234609AbiLFQ1I (ORCPT ); Tue, 6 Dec 2022 11:27:08 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785A52A72A for ; Tue, 6 Dec 2022 08:27:07 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d3so14421957plr.10 for ; Tue, 06 Dec 2022 08:27:07 -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=JgcwRFCL6hgvtdlBwWhPhxTax1zzqSSsoj4r1eWsJf8=; b=kX76ACCqquYYKdhd1CIgHnXMEB2+Uj5oj5pOCkG3xpDvEjeGvYakYAHNTo4wWv1Van orDE+qDfaC0K8lfHIRXqpbTTSJsqAwKTpg+INljBF1UtTncqnct1mbu2+iludo6zKmuu /8T7g0T9RN+U5tahdeL4X8SR6sJ15P44WttkcoX+reAZm1lQ0+KFBuys2PB9G6kKdPyz uScMqulZdXKQVT1rGNWJk6ZImu+IhtQto2OHZWinW3bNNeVOaYX3a47I3EivU73HYpCg 66o2MTbUlicj+QFikjOsTay/QFP8D1ExET45mn7CByRgZkObBnQy5L04v6XncpO5XC3K l5Bg== 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=JgcwRFCL6hgvtdlBwWhPhxTax1zzqSSsoj4r1eWsJf8=; b=Qw/Hdy5iI7QyBVo8DPE4ojnknuHuwFX9oHVza5pDA0GnxNHfMbTwPscGWCgTDaRs0r mTWxdKLuDOBmSGpIK+/yx4QVUhjWyeze/sNzxKH0r9T6muxht3z0vVFySiMD0FoUZ+BR Bm4YDXkMoVKein5MpzNvOi741PSTFWtLYOGZiCAJQlYVyQuUbBXWreRWHpBdoq4MfSMX cWd9HEE2nTqJenavQ3aOX9pOhBaqUMITd5BRDGykN35kDHRbs2rMshGCNa6+/s6MbIRH I2Sqs4tF1/bPEU04IXac3rOaX+8lXywCdv5ODx3MW6VfnVCzPz4WLZRsWVHIWZdHxJAY 9e4w== X-Gm-Message-State: ANoB5pl+CwdHlpdJASQLfWtTkm+W/b+vWgfyNNOgvTolhOFAudXVA8Mi GeflPFkQFM7nSI+nuUwpl2whq+k36H0YuT48P921PA== X-Received: by 2002:a17:90a:5295:b0:219:a43b:1006 with SMTP id w21-20020a17090a529500b00219a43b1006mr17831027pjh.195.1670344026725; Tue, 06 Dec 2022 08:27:06 -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 08:26:30 -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: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. Do you have a sample code pattern (link/function) that I can follow? Thanks Jeff > > > + > > return ns; > > > > out_free_idr: > > @@ -255,6 +260,45 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) > > return; > > } > > > > +#if defined(CONFIG_SYSCTL) && defined(CONFIG_MEMFD_CREATE) > > Same here. > > thanks, > > greg k-h