Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21648752rwd; Thu, 29 Jun 2023 20:19:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ759pG4KXW8webUwfsycgCh3F5b5wRSE9Sk5P8BfAT23DaNGoOD2ARQXa63AWLYQnSdZcZx X-Received: by 2002:aca:6707:0:b0:3a3:7eab:28a7 with SMTP id z7-20020aca6707000000b003a37eab28a7mr1272913oix.30.1688095189593; Thu, 29 Jun 2023 20:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688095189; cv=none; d=google.com; s=arc-20160816; b=mCsNaDx7b7Kyg6L9l6XWPrdMQKa7dZkATzMbzfjzrdmUTcLZZdo3in0Q8jN1/6yxfx QqkKPw6xwcTO7n1fJgExgOqT8gozUn7GuzjnIfodbr8xb+yK8FtPFTt7cZ+jmdX8ZtMY JvBC/HXVadjEf1J1bToV9HXGkLtRJGHVWdmWpryCysDH53uh4lMjWut2Nuzz5DPPtWaa s4HpJu+s9IA5cB/5Fk+spwQr0q1l/7GEdHqjvIcl+B6lvOiM+akPMSs6gN2QRGEL+LNK FXQQf6KU7hjy3S/I7Zv5/EbKvQQdeaZsUKBFq0NEkSzhVbAHt4DgTMsFv9kdg7kykhs4 6WHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/4tMW9nYu8CG1Kx5U0JNQJGDDgvExBfXDekuGxOI5L0=; fh=+wFwOUChBMDyUEg63FIGralHY9qRggLvyZTCULGydUc=; b=dRuDgoXQUlABynGbfDBIGmp2aJiH9IzLLnkI2pKpLReE9/qVeLdx5m/kuu9Y82IkUL vjey8WCvz50jIFVM4ecMf9Cw2dop0bV5JChLVr+q0kdfnuXd1VzsQeZAC+S4R92kParJ bmbiOorc6pgmxhD93LX+GB381ULCxa61jOts+kQovdUZW74YDBPSPUjmcIVCwng2ypkN 97+xic6E5AdkLjQwy8whj+9mylDuWzYy2zQVzr4LPyJj+2KlNNhZicglOWvzo8CXROHK Z1ViUKyIh7ueI5oCE8eRmMStmrUTU1j3TBrDNepX0dYkRY1VpGeyvDgIhgtG85Pyo383 E9+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KPAc3EBd; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f9-20020a056a00238900b0065300b42889si1107853pfc.363.2023.06.29.20.19.37; Thu, 29 Jun 2023 20:19:49 -0700 (PDT) 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=@chromium.org header.s=google header.b=KPAc3EBd; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231743AbjF3DRc (ORCPT + 99 others); Thu, 29 Jun 2023 23:17:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbjF3DR1 (ORCPT ); Thu, 29 Jun 2023 23:17:27 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C4853594 for ; Thu, 29 Jun 2023 20:17:26 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6b7541d885cso1185651a34.3 for ; Thu, 29 Jun 2023 20:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1688095046; x=1690687046; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/4tMW9nYu8CG1Kx5U0JNQJGDDgvExBfXDekuGxOI5L0=; b=KPAc3EBdnLrZTuhZ0JBA91GkCQdZi1yBfADyAF7KOgyzmnpDl4S+IGni/BtmgUcrH3 sbgYHnHSeF3KErNlwH76FXcDGpT0YJHsPG42/z5A2rpu6t71HdZ1FdW+/DfA4ASgCAHE ryqzVSoM0Cg4D98+NoLyA6oKWkl5NF8mEgGUI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688095046; x=1690687046; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/4tMW9nYu8CG1Kx5U0JNQJGDDgvExBfXDekuGxOI5L0=; b=kJ1fh6BSjJKW1Zowdr4kqeS3/Odc6uPtxIvifMWuOIznUiVl4bL6OjaUFObEMBuXt9 NYZ62+tlGZFSEAn6S09egs1myGnIyostPgoSgMPeZP1dsPcLxEmPiX5ARLRbkgpeYPEb fUW1mVTTH24jiVdMO+kh2fWaUFxNJ/ebrAJ36j9hFubIYy/CSlAODV1K9pqLBlx2tneY 7oQOUS3aXYdtECTx+VyLuC4saY+86/lXQIXPutf2YFoy7jD3I22YCcsQRrV6EqpMKGvy j1gKqit+KwbXV2tprDo1/uqVByRe6PYpgY2CiqzDaHl4wgVMWjPlOHIkisxjzvOaJTTC okDw== X-Gm-Message-State: ABy/qLYH/TO+qIZCIuzCgPzbuymEK0w6g1PoYNYOHEgYEsIqEd1sJMF2 2YFm1g41T0giE+a6GYw15k6eGw== X-Received: by 2002:a05:6359:bb0:b0:134:cb1d:6737 with SMTP id gf48-20020a0563590bb000b00134cb1d6737mr1429484rwb.7.1688095045912; Thu, 29 Jun 2023 20:17:25 -0700 (PDT) Received: from localhost (183.43.230.35.bc.googleusercontent.com. [35.230.43.183]) by smtp.gmail.com with UTF8SMTPSA id jh2-20020a170903328200b001b3fb1119fdsm3668851plb.297.2023.06.29.20.17.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jun 2023 20:17:25 -0700 (PDT) From: jeffxu@chromium.org To: skhan@linuxfoundation.org, keescook@chromium.org Cc: akpm@linux-foundation.org, dmitry.torokhov@gmail.com, dverkamp@chromium.org, asmadeus@codewreck.org, hughd@google.com, jeffxu@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, linux-security-module@vger.kernel.org Subject: [PATCH v1 0/2] mm/memfd: fix sysctl MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED Date: Fri, 30 Jun 2023 03:17:18 +0000 Message-ID: <20230630031721.623955-1-jeffxu@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 From: Jeff Xu When sysctl vm.memfd_noexec is 2 (MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED), memfd_create(.., MFD_EXEC) should fail. This complies with how MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED is defined - "memfd_create() without MFD_NOEXEC_SEAL will be rejected" Thanks to Dominique Martinet who reported the bug. see [1] for context. [1] https://lore.kernel.org/linux-mm/CABi2SkXUX_QqTQ10Yx9bBUGpN1wByOi_=gZU6WEy5a8MaQY3Jw@mail.gmail.com/T/ Jeff Xu (2): mm/memfd: sysctl: fix MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED selftests/memfd: sysctl: fix MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED mm/memfd.c | 48 +++++++++++----------- tools/testing/selftests/memfd/memfd_test.c | 5 +++ 2 files changed, 30 insertions(+), 23 deletions(-) -- 2.41.0.255.g8b1d071c50-goog