From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796468157; b=F59/VnxCjFEoED2lZPBlhKzCBF34HyvyKxHy519HxF8AhOLPmRxR0gYD7yeY3ug1g7kz ddc6P6SVhTy7Q7ldfE47bwWTd1nsCVWkM3/ZRKN+Mv95bqRgNvLrXScFvxwMnSWp4VKPl 40kBvERV4vqfKZMc3FCLOpQyeSIdz4ZJw+FkQCoMjNLr2isBiIXpa+Qykf51c3k0c+R3S 7PGhI4QLikdAZGYU/Lxxt/3TknQY+ce+5ldvB3y6dutKyrxF7dkL8sUFrKzWhM/lHVbaP 3PAgisYLslWQu85i553eyazJF1Gx2VypSrdEYf9awYAR2L4yqxul8RWBAWPzht44SGw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796468157; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=YQK/Tfb/SLXbbavTjIYFSWU7QEhkW9fXeE5pwc72QEk=; b=XKb3XqqG66wQ0IaB9CApV1CMPeuPmxUTUebzdy/IUkqpE2Xq7mPqR0a3iNIRAGb6gsbK 6kTahpd/UO5KJMpB3lLeYxa/ZQyAFQQSX5wx5zEotc+oqM521d8G6nI+pDhfV+YAnuJyQ aCTtMcl27um8YmBcf6yc6mFtYd8cpkVWNd9tt5CEeCZDmNXmVvAXtptv5hxoVdvWUJ2dg Wi9bt66T1WKQaBrwneef4uamZ6/mNkVLJglzdHZb8jz2nJibELgoSKlbThxzpYDdRo3/V QcGeLQBcUtNTiDsneD+sq5FrjXhy7Xhg11BkhJarAYtKoT4tGnOS26FsvH9SINia8Ig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vz9hbG1p; arc=none smtp.remote-ip=74.125.82.174 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 242E9606A322 for ; Sat, 5 Dec 2026 10:55:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 242E9606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vz9hbG1p Received: by mail-dy1-f174.google.com with SMTP id 5a478bee46e88-386c71feeeaso2281604eec.0 for ; Sat, 05 Dec 2026 02:55:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796468156; x=1797072956; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=YQK/Tfb/SLXbbavTjIYFSWU7QEhkW9fXeE5pwc72QEk=; b=vz9hbG1pmEsagRg0Zls4E+ICieQaM10YAkT0osdBmazpLHMTvs2inRnahGgWYtaIVw AAZFbh2bIJbZMUerPMGp5OdstKzGlMhomnDWnnoiyy12ERlgq6NX1YU8zQG686WriWmL /WQBXZ+ntUcytSuTt/F+TXCXkMPZmkNNKfhKvOsZT8FjPJ6FrcSri/rxR32SdGygY1Zk rQ81NN9l1Fmp1M6Jvclxkd+gRL2PmGzeBSgaLok/jUxtaePW9C/oTutJ/m9id9sCR4Uh hPNL1uqQvIA4MeweIrCpPfGPVc8NDgy/vatoq0XThHRp0U1qHlzqYzMX4BjLjZ+E/kK7 qmlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796468156; x=1797072956; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YQK/Tfb/SLXbbavTjIYFSWU7QEhkW9fXeE5pwc72QEk=; b=q79NanXEuFZuN5nlrJAqmUMV7+Ydz+SUsz/bADZyhN3HHbEuj2EoMcfURTH06nv3Lu ZrOplyG7OwjIU0aAAm2/JaG/Nin2ARvj/gUYrMziz0AvSH0RjeTpPKvH3Cg8IuZ1btUQ 5AwYNvsb2SmlFxSvNDUWlSraAyTXC9g8PI4vgeyCIQMBYR3HjllxYyi4AunIjmczrtp0 4YW3bne2myK9BgsVRhcz0+36f49ntXPq7SEiHYujzhQ5n3FZzjK2u2HQ5QoDISmy0waU 8cR8g1qEhaC9rbPeI2gPI1zYgcMyq27/b/GmVlvErUQgzXntjy3qTWOKW9n8UL9mjIV6 F0Bg== X-Forwarded-Encrypted: i=1; AL+hErG9cgSgQo60YDHJs9F29V7zpYw2yuS/LcO8jat1YrzMSwEJR0oUt2/uniAI/fZSH38cNTUzvLImGmQ=@vger.kernel.org X-Gm-Message-State: AB4q+uFPkb2WTlZqbo7A8N19e+mK0Q0C6f6Xk9t64VryODBGOqeOIcxD P1Bak0tKtN278pptJdNOxwzTOaIhiARYlQRlqzwNjHIUbWQv7UDvmkUb X-Gm-Gg: AZFdTZem6kKThqbBqkwdz0YSd/v9e3oPLh/rCRIDZw6xxanJy5GP2h3SMX0+gby13WD Jpch67NgzDIutsQK4zmw9MMRy2hDG7QMnjXLNFdpYZKeBAoeE4S3XtyjpUq0p4WNtjZ9WwarIuw twkqhed2IT84Tp7lCG2Gz9kG9k6KMgyb5SgWfU328KgwZOLmhNx0pm4hYQRtosINOlYJZZcQY3j kCqbvnB8GguU+Z8SQffMh6ACo2UOqq3aiRkhrsNNvHVtxMsC2TcJwL/tOePxMye4Vpv7ZTrVlUJ Q9v6gNwZYnCSMx7NIngMHmrDJVzlP90lkeY+Ym82XB7ryu0JmjQ08W052RWMvbEnWzJ2LHTGOPI lOUGO77PjirPz9xxzdyr6uIC35C/zXG8Pq9WiQ+JPX+GF+Zovz0zD2LCLg8/QmHZ/HwaU18ARhA eOttjvE0RXgDBqb+7EIm5rkB3UJB1yCjKkBNg2fu406dNNUyN2HEpBF7mqqUeMLmgz0rM5QME04 fHZOVSGniGW7OnX2YZsGHFV3AE3MzPxCZ9KzDimIbRCnTHq7QNHbAXerHweX8DWB8azfVCKS/IG pV2NpGHeWm++smNZOWee4ZBgvrchaBnFH+3PZPvJmX2LWICy5QLBcYpaBUqrC1Hnja6p8jZA4k3 gR0ZIRCUop2g= X-Received: by 2002:a05:7300:1c1b:b0:381:1926:dba3 with SMTP id 5a478bee46e88-38751e4fc8fmr4326726eec.0.1796468155986; Sat, 05 Dec 2026 02:55:55 -0800 (PST) Received: from 6610b1a2ef46 ([203.116.140.24]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875224312fsm18084565eec.26.2026.12.05.02.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 02:55:55 -0800 (PST) From: Hang Zhengyang To: Andrew Morton , Kees Cook Cc: Lorenzo Stoakes , Chris Mason , Catalin Marinas , Joey Gouly , Christian Brauner , Alexander Viro , Jan Kara , David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Suren Baghdasaryan , Shuah Khan , Gregory Price , Jann Horn , Pedro Falcato , Florent Revest , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-hardening@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/2] exec: don't honor PT_GNU_STACK PF_X under MDWE Date: Sat, 5 Dec 2026 10:55:45 +0000 Message-ID: <20261205105547.1251214-1-hang.zhengyang1010@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Under MDWE, a program whose PT_GNU_STACK has PF_X still gets a writable and executable stack at execve(). Patch 1 drops VM_EXEC there, and patch 2 adds a test. Failing the exec is the other choice, and the one Kees Cook suggested for such programs on the RFC that led to MDWE [1]. I chose to drop VM_EXEC because the marking can be an accident, and today such a program runs under MDWE unless it creates threads with glibc. The cost is that a program that runs code from its stack gets SIGSEGV instead of failing to start. I can switch to failing the exec. Patch 1 leaves the arch default alone, so a program without PT_GNU_STACK can still get an executable stack where that is the default. "mm/vma: make brk mappings non-executable under MDWE" [2] in mm-unstable drops VM_EXEC for brk() in that case too. I can do the same for the stack. Tested on mm-unstable in an x86_64 KVM guest: under MDWE, the stack of a -z execstack program goes from rwxp to rw-p, and the new test cases under MDWE fail without patch 1 and pass with it. [1] https://lore.kernel.org/all/202204200952.F2B1F58D6B@keescook/ [2] https://patch.msgid.link/20261121-some-more-ai-fixes-v1-7-236e925d9b64@kernel.org I used Claude Code to find the issue, write the patches and run the tests. I reviewed the patches. Hang Zhengyang (2): exec: don't honor PT_GNU_STACK PF_X under MDWE selftests/mm: test exec of a PT_GNU_STACK PF_X program under MDWE fs/exec.c | 17 ++++++-- tools/testing/selftests/mm/Makefile | 3 ++ tools/testing/selftests/mm/mdwe_execstack.c | 44 +++++++++++++++++++++ tools/testing/selftests/mm/mdwe_test.c | 43 ++++++++++++++++++++ 4 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 tools/testing/selftests/mm/mdwe_execstack.c base-commit: 2d2d9f22c9c7ae457ba93480ba82ebf57cbf0df8 -- 2.53.0