From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC5A8C77B75 for ; Fri, 5 May 2023 16:43:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460816B0075; Fri, 5 May 2023 12:43:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F2EB6B0078; Fri, 5 May 2023 12:43:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D9216B007D; Fri, 5 May 2023 12:43:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by kanga.kvack.org (Postfix) with ESMTP id 05D856B0075 for ; Fri, 5 May 2023 12:43:07 -0400 (EDT) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-52c6504974dso1707991a12.2 for ; Fri, 05 May 2023 09:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683304986; x=1685896986; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=24yRi1qjnWZisFpP+n/4/JukjZ0Kcgnz8WEqUSF8Rwc=; b=S2sfM88FxwFvchAFp3KAzpcSRt0acemz7/xmUrNhlF4medSZEG9Ip5zbYeVTGLiBX0 Uy+XgOUgvess51BrTKJYsOb3s8LbQeJgD8LBDSmVk1brOb9vmAxj++qdO+tTKoffexYc 2MlUtSoNk2SlF0bqCkexSkpSDDM3uZHWykvKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683304986; x=1685896986; h=content-transfer-encoding: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=24yRi1qjnWZisFpP+n/4/JukjZ0Kcgnz8WEqUSF8Rwc=; b=GP+kFLHqPhssP9qZYHTrhjh1Leq5/DO+QR6qEwhiHkzBVGTxfqn0/CP/HAihVeD0Sl Kv4DkTBmJKP+4NZXlf/4Ky6M1q5YZAp3SsB2yr9KREYIaBbYzfeejBTFVcm5wPF9uz36 PRpmEwXronLJ3DHnVktBbzlTq5ou0HONz7/XlnBzIzv4Ma+kmwwzcEWGLGNbsV5KF8Lm iwUnX6PUuo+XG+M8AFnucJiUaqaX8riBpBOqCS6ydCEbWTXDUckSjTT9YZ0Z0FJXyD8J DR6eS4v8IhSJWCEQV1GL3tQik05oji8IFV1cLZbEdQ4zZ839yVkIRjDKauS/VwzJsLBT W6/g== X-Gm-Message-State: AC+VfDyBipI0fQUGxRMQrXX1O1HSVD2nyASCc5NrJy85st+s+7oAkgQX 5vhE7bQW8BLUyq9A78AbiAYPuwCNeOFLovMl+p/u4Q== X-Google-Smtp-Source: ACHHUZ4lwwbxB9MtVTfIyIDKgv5PXNKsUEoOM+vA2CiBMedBi+yFNJzbUGwCseHog53wvxF/F6fMSYXIQzA38qxlhqk= X-Received: by 2002:a17:90b:1d0c:b0:247:1997:6a1f with SMTP id on12-20020a17090b1d0c00b0024719976a1fmr2327984pjb.12.1683304986334; Fri, 05 May 2023 09:43:06 -0700 (PDT) MIME-Version: 1.0 References: <20230504170942.822147-1-revest@chromium.org> <20230504170942.822147-5-revest@chromium.org> <66900d0ad42797a55259061f757beece@ispras.ru> In-Reply-To: <66900d0ad42797a55259061f757beece@ispras.ru> From: Florent Revest Date: Fri, 5 May 2023 18:42:55 +0200 Message-ID: Subject: Re: [PATCH 4/4] kselftest: vm: Add tests for no-inherit memory-deny-write-execute To: Alexey Izbyshev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, catalin.marinas@arm.com, anshuman.khandual@arm.com, joey.gouly@arm.com, mhocko@suse.com, keescook@chromium.org, david@redhat.com, peterx@redhat.com, nd@arm.com, broonie@kernel.org, szabolcs.nagy@arm.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, May 4, 2023 at 10:30=E2=80=AFPM Alexey Izbyshev wrote: > > On 2023-05-04 20:09, Florent Revest wrote: > > Add some tests to cover the new PR_MDWE_NO_INHERIT flag of the > > PR_SET_MDWE prctl. > > > > Signed-off-by: Florent Revest > > --- > > tools/testing/selftests/mm/mdwe_test.c | 95 ++++++++++++++++++++++++-- > > 1 file changed, 89 insertions(+), 6 deletions(-) > > > > diff --git a/tools/testing/selftests/mm/mdwe_test.c > > b/tools/testing/selftests/mm/mdwe_test.c > > index 91aa9c3099e7..9f08ed1b99ae 100644 > > --- a/tools/testing/selftests/mm/mdwe_test.c > > +++ b/tools/testing/selftests/mm/mdwe_test.c > > @@ -22,6 +22,8 @@ > > > > TEST(prctl_flags) > > { > > + EXPECT_LT(prctl(PR_SET_MDWE, PR_MDWE_NO_INHERIT, 0L, 0L, 7L), 0); > > + > > PR_MDWE_NO_INHERIT is defined to an int constant, so passing it to > prctl() without a cast to long or similar may produce wrong code on > 64-bit targets (ABIs typically don't require the compiler to clear the > upper 32 bits of a 64-bit register when passing a 32-bit argument, so > va_arg(arg, unsigned long) in prctl() implementation might get junk). Ah, good catch Alexey! :) > Arguably, defining PR_MDWE_* to plain int constants is a bug, or at > least a footgun for users of uapi headers. As part of the next version of this series, I'm happy to: 1- change the existing PR_MDWE_REFUSE_EXEC_GAIN to 1UL 2- introduce PR_MDWE_NO_INHERIT as 2UL But I'm surprised that most of the macros in include/uapi/linux/prctl.h are the same sort of footguns already ? Hasn't it been an issue for other prctls yet ?