From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796468157; b=QJDOk0U28L3xQW2lFfzYuhKKYhEPEZOQImCpO3MwsZIOWg2zblYHFs/mvovxHmD/jtfI 0r7KGeT01BmlfWNMhNmUr7cV/b04e+g5LjSAIZXyjFMO4CVqdPtvXACKLTMHLsKxH8wOu Ze+jhNqTmzgwW5KoTfD5MRtuUYgElQ4zLdmc2124+eBquPaCRT2AzEw2anKFl15bY2iM5 /RoAgF2ViYG6o2Csltn9Q4OmD9fL56ytqgvfALIyJTB6plUhzK2oAzcTaDFQQlLDo0eJt jesyYREe39VaPhrAOtWVkwRxMPEtGsNzUXCWqNSzw9Ace5fyJCV086b/aAeEhNEvYVg== 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=fxbnVBEi4aHPwcIHhAoatKoI7n9gd6Dap4y3eb0/Ejaedc0s5DSF8y6nuj9tBRdhLopb pIWO+EIMe6WrcpSCJnaU+PcYfARyPBUZ7zcsbs6fFOYAHYLxGJVpdOKGEk9e3rjIv5/iu vZlEzwkBYC7arIQ9hKhAOlf2nmJUO3n8Fdkbxpi2PmXl3xi0n7U1mbm10yt4lv5fzLt0H 7+9ZV+/cjxMfXDJBCTXolSesoLR9pIR71I7cCAbkfhFe/KkeeCl3eQNIlqtsKZo7BZCvJ +1F463oK8IPxq3l9dSarykJWd6m0Gi513ypxSwBwZnhDyzRfLepAWQSs6JI2CSRFneA== 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.175 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (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 2EAA7606A330 for ; Sat, 5 Dec 2026 10:55:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2EAA7606A330 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-f175.google.com with SMTP id 5a478bee46e88-386c71feeeaso2281611eec.0 for ; Sat, 05 Dec 2026 02:55:57 -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=2wdgiaWt/6PX0IRQ/ae9jA2InvzdQmu+7zCtnNEUhl/hWRttdHjSBnIi8Ew8WW9xrc Zd8aq7j9KwLHjkDfxgkyKh3nfz/xdRo5bbfOnPsyFU0ecP4kfqoxjU8I1SmGN7RQeh1/ 598k0PKk2m1vNFm2ihllcF4RgsmJ2OBUjFuAe0Rg3hfZgc058Ck5mpLonBsZTQhUFBXQ oXjSHSRqxFPH941P0RY/TuB1K/WQiP3s6SbTwLYwsg9V5QiXR6Zx9NIbvydGbgzPamk9 R4gG1Op5h8r24fYVJSXltC4FIqnspHyAeoOoH5YCTFaMRVyk1RjqlR+CXq4NyfiWpdnL KUug== X-Forwarded-Encrypted: i=1; AL+hErHmhCzzHbbBWIzheuqdUnMmIU3imJVkked5FoUbhhxmfVTCCW7KhTXo+12c0X9/8BWU2keV6VgU1Dz82rY=@vger.kernel.org X-Gm-Message-State: AB4q+uF2kXx5AWgkiRPZMjjq2WJCW3atPc9PCX1E5Rdv8h7vs9YX0xca 0ynNxM6Zbllg7lI0zMob1gsx4EFz7wxQ9Aj8/6uPvwt7gvMyQYmQKYHm X-Gm-Gg: AZFdTZf8GJcuEvbvIC/TGRdRmxLrp03qhN0BqlK6Wn9Ws8S3On6F1gYxw+Dm3XXgIrI ObWF70VgC0kjBfvWj5UpMPaGdMnw7iJeTBB+MbIR/QEgZVe4A2291Wi9cfpB2Kghibb0e+BtMGG P7SyK3hyYl/13/jGFqush/zN1DSe2TD1J3QzUZKUtF3AlNNEqfiJJ7aHlpW6ADlHCH+Uk9qQXRg VwAQhddyD8Y//6bFH0Q5GazOBoO9dvD7hrjti+l3qczVJJ8AIiaHmIxO7gr7LkYaodJHhUQCi0D 48Q7im92FAO8TJHboNmRwsSEzHHdkHcH3LSuZBDRCfd/nAss0CaGsTodm6R1oJYs9+dX6Tq+rV/ Y8nZ/6Hn2vz55+VLh1OwoyfrInHY9rsmDVtpIWx0RatqCyQwyWOTvCtVpYBpPIu/rlOe4roCcQh go5Q/drYQjC4AeiHRly2U1DCPFMz1nuDUjJzw27IDjHC1VsO/9GbAeKrXRYV9VyHYKNNmhlUW7c mjI9M1QWtSCp8TjWlk26hrURwMquWUF/BVqnvyAI1W2BAQk5c3r6xVt8IherU2C0H+H6xup/Mnr /fnhADvubuxUb4iI+2gR1Obku7iKNjcMwCH+uAS8TgXz7PEjPik97nMc076f68dlecIwTfizUNg 9L9BVWq2bpE8= 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-kernel@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