From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796142366; b=Bw/rwuOMCn7HA5O1P3pkBD2A2O//U73REyYSLJOA4VT8N00t1QY27hcpjD9Q2AKGkTLp ejT9IVOyrcQ048V0bZaUrCvzBzd6E7TXt97hh/aI8IMqWLDYPnJA/QHjybH30YJv/OuSN nDNxv7vLlYMnmLZJkxl8dTg6oTKcK1ZIEYGcwlSEHKktVZKfvhQCgKo2hdWo0iLr4xaIi Gz4/zg/ldW9BIkyUBG4HRdhGQOC9RVS8och/641hHHfluEukfTRpXgEWuUjyZiPN5mKP2 0MO0Sb3eUu7EuBFSDNYqDJoYPjLt3p1x8IHvZpDH5Iv4GCaHbUo0d/77TgZjudQxOkg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142366; 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=S71G/E94CeqiGEE3hDk6NKe+7pLT1nr3vXF78yfhQHY=; b=4U7SdJkrlop8Ml7MODbnVRZVYhpf2dqTmx4MqxQz9bErdmU4pVaydFDGZ6NUQbip86Zu IW7ApvfQp/rHXC5xs1UGwZKbhPx8y+WE3G8fp3vCpTL/5y6PpEA5cTDwF/vUtVikIFBE8 edWFyAZU36KzKhNcrrnf5C+5Hqsm9X8qXhMziEQwpeEynPOgVIat2WwUb5VSDWlrtE1yO dIEyeuYO8iaF9cemT2aqCvi7P8vv8YUTnSHISlZPdt/cAjtjuJj7SANJ2GsTfh1+eFTdb gK+4mK/KT5+OYggIHly7s4W13rYQeE2nwk6hn/Mp1JKKS4svHz+TrOATi6fslgxnISQ== 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="zkBos/NX"; arc=none smtp.remote-ip=74.125.224.46 Received: from mail-yx1-f46.google.com (mail-yx1-f46.google.com [74.125.224.46]) (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 DC844606A685 for ; Tue, 1 Dec 2026 16:26:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC844606A685 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=zkBos/NX Received: by mail-yx1-f46.google.com with SMTP id 956f58d0204a3-67db6d4054eso13362852d50.1 for ; Tue, 01 Dec 2026 08:26:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796142364; x=1796747164; 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=S71G/E94CeqiGEE3hDk6NKe+7pLT1nr3vXF78yfhQHY=; b=zkBos/NXbXGZYyr53lR6nMDqfqiU0e+4PLdfM5cdYmFVH43nvzv+JAeChInl/uEaHX zZVLXoajLd65NmQJZfe4TFDVChn1not2flMq11YzzmhfnFxh1WCrwtB9Zhyn+YJ6CIR4 Qg12xg3B7qfL3/ATgwzhSKyP1691Iqo+1dlIuuXIL+1eggp3gSSj/ac3YxJHDmhLl8KD 9oKcGcPCk4S9MYYEFqrvZlhmbJanV4RLg8wmX3RRUFctLhtohBcqmC/Qs8ZooqudEOGL FW4dl68V+OdCPRmoidEwXcm/bhAlsnRM+OVhf4g9YpQ4VQ6xxeqf/zx8vWXoFmtaoRDR 5vCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796142364; x=1796747164; 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=S71G/E94CeqiGEE3hDk6NKe+7pLT1nr3vXF78yfhQHY=; b=gxQRD3S7ige518ahHZMMc+QDxY6kmbhrmCKd8jJHFr8mQ6gH9N0992sILal0zDX5Cl 1HtKFG6LgWwZku9nz7KeoN5APzL3Y9jTcQaLWaqeNpk9/OPodoBnJ4J00WXPYTzwhROY m67AckMT6gWW6bRTz+mXbsqRla6PFMxIXYfzo5P6RMASJX1885eiaAt7GzzVkARuVSLC lXgPnAZRlysg57zfOeUhbBZYESI2Eoq+qy2/a6AtkEsVEVKXkRD1fv9GSZBzN3WkC96x gUtvfgi/ra/kGhhLVf/d5Nbo3R57WlTjlQkjh1YkqpLHGisYHiciU8IvWngxurT73Zfu ZKtw== X-Forwarded-Encrypted: i=1; AL+hErGjfK5eYIZiD0qPEgUsMSgr7efiYHtaax2T2fdktG0NyEe+HUL4Kto9satZsFjLwd+EuMflcQqfLvs0UqU=@vger.kernel.org X-Gm-Message-State: APuU4Z/J9nexxPAaaGsH2tUVSg6nlMPSCqyuJOmyMmotqHNoZZVINZfB bjpCqueHe8J1l5YZ3ywzL/tvbNEZdsVESc5fIe4NdFpg68RmVEVMQjtA X-Gm-Gg: AZFdTZep4teAYfRkWYE4L0uPfPtBjLEHmA2c6mb6bXdJTopSKeJX9v1un9jNw7xfd0/ Ko/KGP0Pt4JERE8VDWgWTGoCwT3vrzArlg/fXVZt7kZyN1Kdgv8mfJFHl4TpXDswjQ09N5SVlY/ 2LKy9mWpLDi7QjHqe4iHe7v2bZUwf8gwk05Eb8ihC0FqHKdLFgiE8IXoE64oedw/xwvDGb4rkso NDbP06hMNeh5DPJs4j0j4h3UrwiYSdK4Il7D58NQo1etUKme0NS73boBThhoLNrSelVoHagR82W qKqJXfTXLjgOowiz2H6jNOzMz55tGeqDmVCItOi6fzpRvAvjRjby3yo/UUjJ28no2I/XbTNc9qb PACQ1MdrWDxN6vrRxDLZ6uVjR8HfdN81v0me4rZ79KPOKLz0tdf03iFZn1V8kiBdtlJQBwrP5SD ibYkAcNLuCqMDOlIPOo3l6YvXrgYxcXwmHcuVMfLWl4TaJTlII0b12bl6rsbji67Q9ZsbbjiTv5 y5lwpXLnxGml9nDnq6C9op9uzZrhB86uoYJJG2Cw8leQ23tIAz8mTtN2yHqYHR3VvcIMSIzDff2 WvE/24Z8PFMd85ckOT2dJAKjsJ0HeM7BuzcN1CzgydqlWHvhiDz4Ckti8nXRbAMr0OrjC26RtT8 K3AFM X-Received: by 2002:a05:690e:1446:b0:67c:8a0:db52 with SMTP id 956f58d0204a3-67ea360cef2mr1922531d50.67.1796142363760; Tue, 01 Dec 2026 08:26:03 -0800 (PST) Received: from localhost ([138.197.109.108]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921349b50besm323914286d6.9.2026.12.01.08.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 08:26:03 -0800 (PST) From: Nikolai Dokutovich To: David Hildenbrand , Andrew Morton Cc: Shuah Khan , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Xu Xin , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolai Dokutovich Subject: [PATCH v4 0/3] selftests/mm: skip tests when FOLL_FORCE writes are denied Date: Tue, 1 Dec 2026 19:25:57 +0300 Message-ID: <20261201162600.42818-1-ndokutovich@gmail.com> X-Mailer: git-send-email 2.43.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 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, the test reports "FOLL_FORCE write got EIO (CONFIG_PROC_MEM_ALWAYS_FORCE)", and no other test changes its result. The name is a hint rather than a diagnosis: a kernel booted with proc_mem.force_override=never denies the write even when CONFIG_PROC_MEM_ALWAYS_FORCE is set. Changes in v4: - Extend the skip message to point at CONFIG_PROC_MEM_ALWAYS_FORCE, as Xu Xin suggested. 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