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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CD46C433FE for ; Sun, 6 Nov 2022 19:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CX+sU2JYjtc9t4eofUJ8OKvtvitkFkXeALxG2axSKgU=; b=omWp+kfPl1mKS+ KlWNaFKLPZUFQah0nVq0EHDyXhkaBCx1u271qRy4fxS2yXoxy1r+BMYA3YNLKEGi/yvFElpSopsiE kJL2XVkjT5F4qzENovnw0JGSGSeOzwBqrBMiwNeNeUqAxnEN/o5XD9hAv53IAdwko++E8JZiLt5QM 7wu5DbTCsv09S2vro+AdWcXevM8LIijxQ4+v3PsT5Fgdm4ij0dHzvfePJ9PMshqQojWYV35UbAXRf PyH8iAunkXuIDwGO5uhgO3kOUwD0UwVEY+IOTLq71okAG16uQsXKGxkY8hkkEOCzsrAz3JqEQFwlz PonC3cY5s4h4S/y6sF6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1orlXU-009RYL-HP; Sun, 06 Nov 2022 19:42:40 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1orlXQ-009RVp-P8 for linux-arm-kernel@lists.infradead.org; Sun, 06 Nov 2022 19:42:38 +0000 Received: by mail-lf1-x12b.google.com with SMTP id l12so3028683lfp.6 for ; Sun, 06 Nov 2022 11:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=soEmAuBjEszn8pf98ldLFRL5ujODoTGOCIahcsWuApw=; b=R2TvARUJtyz37zIy2kVi75Orec2ZOcXliptOV1B3feipOsEyycJ2SuXt1NmWRl8Qbw aiMMt4kIaF7uacIYnsjAyICuC0CJABfp4FySKRyqZsHPj6vd5oqakwtyU+Z9CB9jXQHS KRSV1S1YK0SIAI0hqqJ49ZYa55lxmKYsxPQxXzLQUd80eTm5NthjMv8DtykvWy5Whpb2 7ZWLk67mysZljUDbocl2R4ZEFyBvrBRsJQmdf1I1ESXu/hfwS3C++lPXJcoF008zgc8T uCG33NBtrAZfJQ+k+8gYNUYAZP/00YtyYxIR7k+R6KBeFYVfIrM8zMnISCKoP6TDzdwQ IXzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=soEmAuBjEszn8pf98ldLFRL5ujODoTGOCIahcsWuApw=; b=fETA1qqYz3GBHMpKqa6EGuNqjpDFhXapn6Jb3xWG/05d/T91hc0WJ7oyiW951m2iB+ ukhMwp/PxlJIV7Ir6yJkpcjl1OOEmFsmvVBrs+BkTbaFRA4RmfUpfL9fD4HT+9MZHreZ e6jWo7NiA/DCISGV5opyyKqDLV8kDp0p7BRqwk3ufTy750ZfsOQ9xBLm7+XZjwcCM+KH 9Niv//GHXgAnGTypZePr5VyY+/7wgtv4vg+O7GXU3Mdxmvw336/wyH/7BNdZiqnyrs63 PTX293bqNyhh890UUZNx+eWKSITyGakgRZMgBfpnbSkDAJXcgVqMzuPq2/CUNjZAKwYz k6EA== X-Gm-Message-State: ACrzQf1WoLAduUDx0Ay5ZHKjzFssizQ1U2jHymBox0BeQJjXrqeMC2WF iUlMGRgKH1SrVrXiF7VdCDo= X-Google-Smtp-Source: AMsMyM6PGenF6suyM8Ji7VFmUmk8giB/Q9bvSv8DXeQQ8bDRyRB263uzSOoyeKxQx8aZ4VRTkMTHIQ== X-Received: by 2002:a19:c503:0:b0:4a2:b966:37ec with SMTP id w3-20020a19c503000000b004a2b96637ecmr18303820lfe.319.1667763752323; Sun, 06 Nov 2022 11:42:32 -0800 (PST) Received: from [192.168.1.12] (91-159-148-109.elisa-laajakaista.fi. [91.159.148.109]) by smtp.gmail.com with ESMTPSA id u18-20020ac258d2000000b00497a32e2576sm839487lfo.32.2022.11.06.11.42.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Nov 2022 11:42:31 -0800 (PST) Message-ID: <25bd279e-f429-3772-bbea-ad56a7a810e5@gmail.com> Date: Sun, 6 Nov 2022 21:42:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v1 0/2] mm: In-kernel support for memory-deny-write-execute (MDWE) To: Joey Gouly , Catalin Marinas , Andrew Morton , Lennart Poettering , =?UTF-8?Q?Zbigniew_J=c4=99drzejewski-Szmek?= Cc: Alexander Viro , Kees Cook , Szabolcs Nagy , Mark Brown , Jeremy Linton , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-abi-devel@lists.sourceforge.net, nd@arm.com, shuah@kernel.org References: <20221026150457.36957-1-joey.gouly@arm.com> Content-Language: en-US From: Topi Miettinen In-Reply-To: <20221026150457.36957-1-joey.gouly@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221106_114236_849169_8DA7E808 X-CRM114-Status: GOOD ( 23.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 26.10.2022 18.04, Joey Gouly wrote: > Hi all, > > This is a follow up to the RFC that Catalin posted: > https://lore.kernel.org/linux-arm-kernel/20220413134946.2732468-1-catalin.marinas@arm.com/ > > The background to this is that systemd has a configuration option called > MemoryDenyWriteExecute [1], implemented as a SECCOMP BPF filter. Its aim > is to prevent a user task from inadvertently creating an executable > mapping that is (or was) writeable. Since such BPF filter is stateless, > it cannot detect mappings that were previously writeable but > subsequently changed to read-only. Therefore the filter simply rejects > any mprotect(PROT_EXEC). The side-effect is that on arm64 with BTI > support (Branch Target Identification), the dynamic loader cannot change > an ELF section from PROT_EXEC to PROT_EXEC|PROT_BTI using mprotect(). > For libraries, it can resort to unmapping and re-mapping but for the > main executable it does not have a file descriptor. The original bug > report in the Red Hat bugzilla - [2] - and subsequent glibc workaround > for libraries - [3]. > > This series adds in-kernel support for this feature as a prctl PR_SET_MDWE, > that is inherited on fork(). The prctl denies PROT_WRITE | PROT_EXEC mappings. > Like the systemd BPF filter it also denies adding PROT_EXEC to mappings. > However unlike the BPF filter it only denies it if the mapping didn't previous > have PROT_EXEC. This allows to PROT_EXEC -> PROT_EXEC | PROT_BTI with mprotect(), > which is a problem with the BPF filter. Draft PR for systemd: https://github.com/systemd/systemd/pull/25276 -Topi > > Thanks, > Joey > > [1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#MemoryDenyWriteExecute= > [2] https://bugzilla.redhat.com/show_bug.cgi?id=1888842 > [3] https://sourceware.org/bugzilla/show_bug.cgi?id=26831 > > Joey Gouly (2): > mm: Implement memory-deny-write-execute as a prctl > kselftest: vm: add tests for memory-deny-write-execute > > include/linux/mman.h | 15 ++ > include/linux/sched/coredump.h | 6 +- > include/uapi/linux/prctl.h | 6 + > kernel/sys.c | 18 +++ > mm/mmap.c | 3 + > mm/mprotect.c | 5 + > tools/testing/selftests/vm/mdwe_test.c | 194 +++++++++++++++++++++++++ > 7 files changed, 246 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/vm/mdwe_test.c > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel