Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1272341rwb; Thu, 8 Dec 2022 08:37:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gtQ2+5RPhZavJ+xUpYOqAQasbS4D9VWidiCFECjsWDpkuDrtxM8iW5F+8DiTXacXTjDjc X-Received: by 2002:a63:ce43:0:b0:46e:d2da:8ea6 with SMTP id r3-20020a63ce43000000b0046ed2da8ea6mr67999635pgi.208.1670517423296; Thu, 08 Dec 2022 08:37:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670517423; cv=none; d=google.com; s=arc-20160816; b=DDUwe5+wl+f/6PyXqr/3linfIVCRH2eFRROayafXrPyA9e90iGHcmI9kyKTvqechmJ KQthHUs7zsLEVMfIybsQ6bBMq8cJXYk6DvvOJV7GVHIBJkdVbqfA+UEpjLTWDUVWkOg/ 383vvCL431QWLdnZTrrnT/d917ty7UQPF6OvqBRq1ElD/KzUTb53XhJSYID03HPD5BWE 20C9qR64XjAQdRrjw1x22Tzet8dk1y10woPDyxdYUOqeMlsKOl50v4MkAn29T8s6ESjb XxHw5GO5j7ytMX2em1mOPY5B/ukCmXYkvSE4hBo6h34qP7iWNr0788qNsEsIQ1OmxG/6 MRUQ== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=hrJ14ayLT7F+1zAXfd85zeuS9jwgRhVrcw7Y0+tLb6Y=; b=sW1FNrI85pw4YD7NCRMr7iPSJim1460x6Lqq6+kfsTQVU5U9xSuSn3+YGrMMzgxPba ECNRuufPXqqSFo+jUDH3kRUg/1wkA/T+wM1LkzdeSZ3JZ+Dw4dtFlVrOFiD10sZqF2XV W/0xZvDPOBAAhL2FvF3Jn3kcPd6KuT+KE2gV3WAyr9hBbCE2DzmuH1svNTgFZd8OJjN9 Df87K6ack6NOQLkPxQOh74ajAn3tjzJMwfhL3aScxRp69wmn1ZpvleJpLC/Iq3tIagtD gMv+QxcAjg1Fv6Qa1fBuIajl5tCKjulcH+Rfq3+GbkbWT1zcoIAXBrZsDpln4JvNrih1 KZlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="g8P4/eoj"; 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 23-20020a630317000000b00473c36e3b85si23779203pgd.678.2022.12.08.08.36.50; Thu, 08 Dec 2022 08:37:03 -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=@chromium.org header.s=google header.b="g8P4/eoj"; 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 S229728AbiLHQVf (ORCPT + 72 others); Thu, 8 Dec 2022 11:21:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbiLHQVd (ORCPT ); Thu, 8 Dec 2022 11:21:33 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FEC06FF01 for ; Thu, 8 Dec 2022 08:21:31 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so2040283pjj.4 for ; Thu, 08 Dec 2022 08:21:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hrJ14ayLT7F+1zAXfd85zeuS9jwgRhVrcw7Y0+tLb6Y=; b=g8P4/eojTrI2HBCiA4zp/WCQXL2NPFnOjDEnV/senXcKqmtpvz8/sl35IibIlf56Xb ZynllzhNzGK/ud3dS9sa5QvNDOO/hi6CMtTwElRCKkJcwqr16oyYBna2FSFSeQmU9wko JEFCS20QBntq7LbVs0aCBuYQzFzL9J9+gjq70= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hrJ14ayLT7F+1zAXfd85zeuS9jwgRhVrcw7Y0+tLb6Y=; b=xMLEq620ESWiCtGUIF/3HZApGXaxB6W1uR9nNODXCt0l9NbXc/xUKipyTcjDjB6Dp1 Bd30g1jrpOfAyoUbJ1gtG0lXToh+he/P7Ds2Y/a4Ab0gqGXpqxwX7+ahVAVRs5ueJ5CN SOSiry1eJS9/JhCq2nsMa4dobGrDm2QM1EGuVSJ0XlvPFm7Fnc2JpGX/ucdJKFsZVROP Y0tDstA+m5wYvx1eVzNLhCOUR2rnDczhEJ2sN+fmu1L+uzG7yw/wIMYHUQE1jzrB090L 0t9lIudIdaBUJau1ntSbjL9/DxVwRJOh3WbRakAbs9St785ReteD7Dr5MWYnqpAjawtG uz7A== X-Gm-Message-State: ANoB5plvFYXzUqEF4gfXrnMWEOQdQYNHvgzwhmgw7DdTV2p6IBv/KLF0 0m9pibdVtpqql7WPk/70757G3A== X-Received: by 2002:a17:90a:9f46:b0:219:b1db:f7e3 with SMTP id q6-20020a17090a9f4600b00219b1dbf7e3mr23917526pjv.64.1670516490729; Thu, 08 Dec 2022 08:21:30 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id pc16-20020a17090b3b9000b00212cf2fe8c3sm7924158pjb.1.2022.12.08.08.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 08:21:30 -0800 (PST) Date: Thu, 8 Dec 2022 08:21:29 -0800 From: Kees Cook To: jeffxu@chromium.org Cc: skhan@linuxfoundation.org, akpm@linux-foundation.org, dmitry.torokhov@gmail.com, dverkamp@chromium.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 Subject: Re: [PATCH v6 2/6] selftests/memfd: add tests for F_SEAL_EXEC Message-ID: <202212080818.28476A4@keescook> References: <20221207154939.2532830-1-jeffxu@google.com> <20221207154939.2532830-3-jeffxu@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221207154939.2532830-3-jeffxu@google.com> 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 autolearn=ham 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 Wed, Dec 07, 2022 at 03:49:35PM +0000, jeffxu@chromium.org wrote: > From: Daniel Verkamp > > Basic tests to ensure that user/group/other execute bits cannot be > changed after applying F_SEAL_EXEC to a memfd. > > Signed-off-by: Daniel Verkamp > Co-developed-by: Jeff Xu > Signed-off-by: Jeff Xu > --- > tools/testing/selftests/memfd/memfd_test.c | 129 ++++++++++++++++++++- > 1 file changed, 128 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c > index 94df2692e6e4..1d7e7b36bbdd 100644 > --- a/tools/testing/selftests/memfd/memfd_test.c > +++ b/tools/testing/selftests/memfd/memfd_test.c > @@ -28,12 +28,44 @@ > #define MFD_DEF_SIZE 8192 > #define STACK_SIZE 65536 > > +#ifndef F_SEAL_EXEC > +#define F_SEAL_EXEC 0x0020 > +#endif > + > +#ifndef MAX_PATH > +#define MAX_PATH 256 > +#endif I'd expect this to be named PATH_MAX, and it shouldn't need to have an #ifdef? That's a regular POSIX define. Otherwise, looks good. Though it'd be nice if this test use kselftest_harness.h, but that's not your problem. :) Reviewed-by: Kees Cook -- Kees Cook