From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE63C606A327 for ; Mon, 30 Nov 2026 17:39:58 +0000 (UTC) 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=Sr/JgFoR Received: by kanga.kvack.org (Postfix) id E04296B05C3; Mon, 30 Nov 2026 12:39:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB4796B05C6; Mon, 30 Nov 2026 12:39:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA30E6B05CB; Mon, 30 Nov 2026 12:39:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5F2A56B05C3 for ; Mon, 30 Nov 2026 12:39:57 -0500 (EST) Received: from smtpin23.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A7E2C120BB6 for ; Mon, 30 Nov 2026 17:39:56 +0000 (UTC) X-FDA: 85492498392.23.14A2849 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf12.hostedemail.com (Postfix) with ESMTP id D446740011 for ; Mon, 30 Nov 2026 17:39:54 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20260707 header.b="Sr/JgFoR"; spf=pass (imf12.hostedemail.com: domain of ndokutovich@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=ndokutovich@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796060395; b=jLQerB0Gl6ARNXVmu/IFPNL5h7BAubeU0XzPB5GINV9Ay6HyuJzMx7ItFwKzScke9ED6Ug gDQ5EOQXKQOirIBND9gcde02ObKpgU+dquU1uLmz+hrbDQeMipPl/TETxLwTLuKuK+siy9 vCR5ovwY1cyIvXsjUUBa744+i3XVevU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796060394; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=SgjJbukO5SC45lK/7bOZ744kABfBQfKwM+Z5n5QBb8k=; b=1X53Kv/6/7tZ+pPSKQ0RKlmPC/5NuRIM+jK2M03GvDPMqGMUPlnHuo2MdDBqpQbjPJxunY aLb7B0hBXg9hH8bGNK4B1gNIXMpcmXMaWE/7qzxhHi6SYYcaweLJjaZfuU/v1baAnH8ij/ OPXpjCLnl4pyPHZdSWYGANztdn5qR04= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20260707 header.b="Sr/JgFoR"; spf=pass (imf12.hostedemail.com: domain of ndokutovich@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=ndokutovich@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-5364042eecfso129935471cf.2 for ; Mon, 30 Nov 2026 09:39:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796060394; x=1796665194; darn=kvack.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=SgjJbukO5SC45lK/7bOZ744kABfBQfKwM+Z5n5QBb8k=; b=Sr/JgFoRagOTR8EgHxcWySr5rFkqOM6bkQff7LHDkDtivtNE3GO72je7M0VFKhD9EF Dzi+IGKFsXMt1td7V+CH4Q7mXn8qVtaNXhjDQYmVvyab5mgDcfrFtQ1fIlkSiTI9YGkJ DcBvFp/3kwLmvFBkNWFLBV+oC6ornMLmyPQgnJnJKwTuGzBwSvG95O3mzSpg7XaQ0XZQ SADN0RbfDn528YonONyrpmxS17pqs6EOmobPCZ7tvSYxDGrh7KalZT/iRkE9ctLMUEtP ajYbMtWmd/5U7+bMYwVCRUfYjh/ZduyCtsPXC8zaw0mZsqpqeTMbPffSg/UPeC1XAyRe MZ7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796060394; x=1796665194; 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=SgjJbukO5SC45lK/7bOZ744kABfBQfKwM+Z5n5QBb8k=; b=hHadeAaBIqEf4EkgT6eMad+gj/C95LWpWzabcRdEZd7XMpKCqu0nZy4qNSEtnUd31l rNIk6SpeKnlX9PD0R4INW4S6frUlSPHH61zPcB7gsEhOxCJcD9BWUgZuNgCuiRiR424z 1yV678kB/AWlHoH9fDq5omecQBQfcNvHL0MiSFJpYI4jjp6T6RdO/OajsbWdNAVa92WZ EnjVNbnpHHxvGqLbucXnVy3NnyV7pz7yiI9sbdcT1Ahi9LHMoDHJTZmWeZnixM3EJ9N/ lTFjVTnlfL2KsYLlR0+nB3qFw+QhQ8yCpmztGZwq7+Ftlkh9PdKIVQZ9LXtfNDODkrqI B4Fw== X-Forwarded-Encrypted: i=1; AL+hErHElSt9I1ylki03KMxyh11nvwcvFL/lX3FVdzlBXt4GWTND1kADw/spGjq7tVQTFXCSMDL3XVVfEQ==@kvack.org X-Gm-Message-State: APuU4Z/r5MZvKh+AVFZ0IX5UWVp1Oj1eaAIfcYFAW/tZiyOOg4haIJgK M/PCKGgAWQxx3HSKbwo/FIxJfe86/JWLLxP7FVSqh8AX5JwLLrO3ihw3 X-Gm-Gg: AZFdTZcjwOVodxNvdBHottFe38ktv02DGLM4dw4NWGAp0v9cZLwTfmAe6P/zTt6OpGs DQB5HAlRL84sz0JbOyDyfP9O/LMCj3Gl6U/ULgrUYAzlXJHO/I2YCWt6k9r1R2wuA+a1aZmfJa8 T8Wlr3JbW0MmIT3KabkJQzxc5x99fIOp/lCmFDLF32MMyb44Uk8ivM9LO2uPavexWzJ+nbU0rFs +LBqtJPlme2qUypYJzMQ2IZkG/1fSnTIaWoewzjSk37S3qBqXWG9RZPB2nTcJRrhHg0lvfZU7Dt hIEeF9tYfT7cUYDJ6SuXI/UlwhTqWOvq6lP/KCk5vgALQNFAwWRSyR4gj46znZKApLYrGuMf/Ya vS3F6gcdOuU4EEaujUeRVrvXFcy8fyL/AEZSPgzN14sKq5JpkohHPJXGelmSNRxd0kNmSZDXK5Y XgjjoLVK4j43+BbirFXQMaDgU21pHViUGjGe3yAea+DAWlSBaP1GccpFdDv61dya7FrZUFsOlQ5 TqimOi6cdNWa4ey9fHxGGjoe4EB6Mr5To/xs79ZlqO2tsL/v3Ee0e0/15JSggg2DnCdrxkpef3K 8ly/xsJNxWM0GxXpj5DdzP/gLs6QTGtjBCKxDVQTostoM4TrmxAAjcW9BfBYu1HMqwyMfxiiTlW nL4uA X-Received: by 2002:a05:620a:7113:b0:949:569a:a3fa with SMTP id af79cd13be357-949ba9b82f4mr6063046385a.25.1796060393850; Mon, 30 Nov 2026 09:39:53 -0800 (PST) Received: from localhost ([138.197.109.108]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949c555faf9sm2495962785a.0.2026.11.30.09.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:39:53 -0800 (PST) From: Nikolai Dokutovich To: David Hildenbrand , Andrew Morton Cc: Shuah Khan , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolai Dokutovich Subject: [PATCH v3 0/3] selftests/mm: skip tests when FOLL_FORCE writes are denied Date: Mon, 30 Nov 2026 20:39:47 +0300 Message-ID: <20261130173950.41003-1-ndokutovich@gmail.com> X-Mailer: git-send-email 2.43.0 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D446740011 X-Rspam-User: X-Stat-Signature: yen74q676butmm346uwhqtr1zxw715a1 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796060394-733989 X-HE-Meta: U2FsdGVkX1+RyKWN3GAlxPR7bqsY38yhvB+uAEQgLIzSdlTKtfKEPbO4uU9accbkB/1V1p670Uq1LYbi1JKO470YYsqU4DLd6Skf9KdvTN5X7lmix0VWEqkXidiVPwlW8Iua8hhZIAM3YZsZAiPnevasieWx3tkqGvn/TH6jowEO/65Ay1E0TkXCPHLQos4bSrj95l4MUqfvOcj9QtbseljEW3npf7piSVqWHj+DywohGT2XmUjSrHHakz0bAQtJ4wPUeWsGUt/j1XUWdn3Slz2G9ki8v28VEFCs4LRf5j3VgjhD8oSLJN5EaMimiKwO633AAnAEQddJa4k4z6BUcOy/xaNZyj60cDVMUAZWFch65Ka4oDF61G98fOl5EnQ2fSn39DEDDsiL6AIYuM9jBNAGzkwVMj9HvLcHu80gf2WR587hG15q/PhZ7tqkWbaBPp/56fCKZCQzJ6y5l1D1YQTEOspOzgSeVJyM9OZB1gV8rUCtgsfJAEqOvhZcEBjDBFVn3xznOCGpdsY6s/Ey7W+k/ADPnEm5RDeqjaMhF0UZZTU9ggqb9WeUmFPeWISATAJnRlb4uy5EcwjVo2CRHgQzWYVPON3/LKsjxOGThenVkhWVgGQvCKoYEgDYh1ML27z9qhk4IU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owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 A write through /proc/self/mem into a mapping that is not writable is performed by the kernel as a forced write. Since commit 41e8149c8892 ("proc: add config & param to block forcing mem writes") such a write is refused unless the writing task is tracing the target task, the kernel was built with CONFIG_PROC_MEM_ALWAYS_FORCE, or it was booted with proc_mem.force_override=always. Commit 599bbba5a36f ("proc: make PROC_MEM_FORCE_PTRACE the Kconfig default") made the refusal the default. Commit a3907a3169d0 ("selftests/mm: specify requirement for PROC_MEM_ALWAYS_FORCE=y") set CONFIG_PROC_MEM_ALWAYS_FORCE=y in mm/config. That fragment is merged into the kernel configuration only when it is requested, so a test binary run against a distribution kernel is not covered, and mkdirty and the ksm PROT_NONE test then report failures instead of skipping: not ok 1 write() failed not ok 5 ptrace write failed The first patch adds a probe to vm_util that reports whether such a write is permitted. The permission belongs to the kernel and the calling task, not to the mapping, so the probe takes no protection argument: it maps one read-only page and writes a byte through /proc/self/mem. A refused forced write copies zero bytes and mem_rw() reports that as -EIO, but any other zero-byte remote access reports the same, so -EIO can indicate a refusal without proving one. Only the two decisive results are cached; anything else is inconclusive, returns allowed and is not cached, so the test below still runs and can fail. This is deliberately not a check of errno on the tests' own write: that was raised in the April discussion of the mm/config fix, and checking the result of the operation under test cannot tell a policy refusal from a failure of the operation itself. The probe isolates the question, and the test then either runs unchanged or is skipped at its entry. Tested with this series on x86_64 against a kernel built from this base whose .config has CONFIG_PROC_MEM_FORCE_PTRACE=y, CONFIG_CHECKPOINT_RESTORE=n, CONFIG_USERFAULTFD=n, CONFIG_KSM=y: default boot mkdirty pass:3 skip:3 (2 probe skips, 1 no uffd) ksm_functional_tests pass:8 skip:2 (test_prot_none, 1 no uffd) boot with proc_mem.force_override=always mkdirty pass:5 skip:1 (no uffd) ksm_functional_tests pass:9 skip:1 (no uffd) When the probe causes a skip, it is reported as "FOLL_FORCE write probe returned EIO", and no other test changes its result. Changes in v3: - Reduce the probe to bool proc_mem_force_write_allowed(void), taking no protection argument and caching the answer internally, as David Hildenbrand asked. - Call it at the entry of each affected test instead of caching the result in mkdirty's main(). Nikolai Dokutovich (3): selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem selftests/mm: skip the mkdirty ptrace write tests without FOLL_FORCE selftests/mm: skip the ksm PROT_NONE test without FOLL_FORCE .../selftests/mm/ksm_functional_tests.c | 5 ++ tools/testing/selftests/mm/mkdirty.c | 10 ++++ tools/testing/selftests/mm/vm_util.c | 47 +++++++++++++++++++ tools/testing/selftests/mm/vm_util.h | 17 +++++++ 4 files changed, 79 insertions(+) -- 2.43.0