From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795924845; b=HiNC8/Kfc91TuSDmk2fcLWCYvjMXzsvxOYoKdH1pSjgVNQBf8Sv+OCQj1wlHZyBSz+w6 Wb6WoIp6/togpUON6CO2QHxZLh+qLDyOFTebowf5FgpMKaZaRnxvSr9oVGcbSEXKAZ46R P2XfJUOYmgoOVYF12BO20ELbC9pJG7QkO0hgf5g7/xgBohmbf1HguE+yGXLtzBlf4kbHV o1bIrhf0yJAPzdgwfaLN8gLSAfxfvU+eCF5V/gUq923EmlfZTIXZg0t4+VBi5bFRlcCM4 wunfnRwdWV20+g72FYYOCCCr+SPsz4NjbKRQhgRuTqDBrzgGxDFjTqHWWOdRUbImWng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795924845; 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=4JZqjSgBAFYKQMgzEoIcRwtGfoj05XHN+eKinR94o/I=; b=R4PwL3wJdnjpjqd+O/pFMKsmVvW50yKvuTaoAnrP0E96avZi3ysBCNO8QF4OWv+WeIz0 s9aQTIfaYCAZYqdS8vYy7auIo96+bIPKp2+uCjUHb5watnC61HLp1gjg0KP6FIvim4Lyy aItm74O5EDsQwJy6zQ/uyP+ntabHmnR2yrxeoUHXyOvmyTx4C6L0msK0NbsEIg0FLkEAk P1j+cnfTJlwLbewszReuYNbD4w1sN3hgXAkA20TZGXKWxBPxO6B9f3Bu8nuqlDt1yTUAv 2/UbNK6vozLwf4qum9bMdKYBYdY5Qd+vEfI7tTqi0HhSi3nlOJsW5Ol0rR6AhF4T9Og== 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=WzeUGKX3; arc=none smtp.remote-ip=209.85.160.181 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 5E765606A329 for ; Sun, 29 Nov 2026 04:00:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5E765606A329 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=WzeUGKX3 Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-5366ae57896so95367741cf.3 for ; Sat, 28 Nov 2026 20:00:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795924844; x=1796529644; 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=4JZqjSgBAFYKQMgzEoIcRwtGfoj05XHN+eKinR94o/I=; b=WzeUGKX3QFkcKaFjiCit/vYAC5CFuoTM1SJfP1zrnrUMlEpGAaDXD3Zf9NjCj6RZf/ 4WGcTVz4Y2Jyk11V6NYAHJcGDa8yc28RXASr1yiJEUOACezTx53D1vwz1HUGWKkog1ah LVF+2sfjTV/a2gG6muR6W5yRdf7ZMnQy8xRUNQ2kczckGjDl/fb/VSFiZpenXR3sfcpV ZeegR8L1VjqqETpZ0Osml0X66oVt8vfiksVt5C6F5CtDXTDAGRfspsRzoRiTsOCIy81y zTqybsZKMrJ2xqyCWiIQ/hiya6+wW67DLLUSfP1pzMW0uUe6OzUV3e6V0iAJxT7JHtnl P59w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795924844; x=1796529644; 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=4JZqjSgBAFYKQMgzEoIcRwtGfoj05XHN+eKinR94o/I=; b=UyqqTRKfsNT6HO+QSBRyZLme46dqdHE1ZbNFqBW91yZInqRYwBK6T0r8BjUZheOA/7 h0KrL7IstUxde7rScNkVBNhajILxdrJ/FPnOv4U/+/RnMp9+/I2fVWqq4auybMy8Tfu1 cdYRbBQRdgMpN+aEh0dcV8ZOa13JmFze0TmMI1u/C4uLI4Rwu/jqwJ7qLS91Ocmamz4M QbcU1Y/fB+20PjfQwqi5Pc0Qcrp2vQQPkR0/cm3T1V3L2HthSiMmHN37bt1grrev3PUp cOthhiPMOzXVvezikk2AO3T8QTLTNe5vexBhK0m1DlLlo1FD7b7O7l2R3RASlAzivYZz 2D9A== X-Forwarded-Encrypted: i=1; AL+hErGjDGRax1RV1slUYUV86MROknWGBj6zeIZT7Cl2PI4jSE8lyda/OPQixHZxG4fCcshALKOaTWJ9jGKei3s=@vger.kernel.org X-Gm-Message-State: APuU4Z+7XpEDAspvtWGIn9YhhbxUP2P4VVCSfw82F6XupW4Xb2XWAtRK rD/Tl9vdgBMIi/rhw3+rzyHhefCrXnHeN3mlPsjlXJxsLzfGl6sAuyca X-Gm-Gg: AZFdTZdv1cFOYTlY7Tli/QI8LZ1cgbD0fauZzHHSrz11MBGZS2/UMFeb/ZNUK3xXI6g 68Hb3J1udDy56IGwCrN1pdsajh7UOeqQRUT8+3A2aOvNHt79XPpMG9JMYZmzpe3UcRHSBtG+hnM F88dGv50j8R//YdRZVjDgcyBzzAH4RSIZ5TdVta1jxpXGZzsPRjVyzY3WSZVuV46QiFJc5nZqPr /KlQYSL4lv7MJQ7TAGm1dDupi8PewkeWBwqp5SwHKCqRz5DfZOMwnpHFMRyQ3ASWO1EOLWTeylo BqMrC8uOT0ZkE2XCSVbRnZRGYHz6aTmKGJ5F/56m1u5aM1wUabtQEWcw8DZJD3XIoH3O+KCMOSj 9WgmhHtsO5+356W+t9Gz2zOaeCTHwyMRx6xGIEgbJBu+qfuTZapHoLLFW0CDSTG4N6nmznTDFdC Se63gMQui6og5idpH/NB9QTjg7ad2tTd3hkj8I8XoXh7JR81w3j7uM+xIY53DDXmcV2yYs6G6Tt 8Apr6u2TilbpNGe7EveP8XwCiAQgDHaYhRMGf1pOSFBM/qtE+dAUMZ8B1Nga08/d58a5RoaZD0r Wx4fDbzOhWOyWX8b/oUDR2vjPMo1/pO/s6Xoc4d7Z/P49WAEBvKK8Nu8bvzUMlt7qBQxNg5u/Th fx1Ef3XBfNMZmb9gz42IbcWYSTA== X-Received: by 2002:a05:622a:a946:10b0:55d:846e:5b43 with SMTP id d75a77b69052e-55d846e83b4mr402376861cf.42.1795924844248; Sat, 28 Nov 2026 20:00:44 -0800 (PST) Received: from localhost ([138.197.109.108]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-92134bfe82dsm255511266d6.0.2026.11.28.20.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 20:00:43 -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 0/3] selftests/mm: skip tests when FOLL_FORCE writes are denied Date: Sun, 29 Nov 2026 07:00:38 +0300 Message-ID: <20261129040041.37139-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 kernel reports a refused forced write as -EIO, because the transfer copies zero bytes and mem_rw() maps that to -EIO. The same error also covers any other zero-byte remote access, so the probe treats -EIO as a refusal but returns a distinct value for every other outcome: the tests skip only on -EIO, and once the probe is allowed a real fault in the test below still fails. 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 on x86_64 with 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 EIO from the probe, 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 into a ... mapping returned EIO", and no other test changes its result. 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 | 13 ++++++ tools/testing/selftests/mm/vm_util.c | 42 +++++++++++++++++++ tools/testing/selftests/mm/vm_util.h | 16 +++++++ 4 files changed, 76 insertions(+) -- 2.43.0