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 663E1606A69A for ; Tue, 1 Dec 2026 16:26:08 +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=Ppt/3hRV Received: by kanga.kvack.org (Postfix) id 964E16B05B1; Tue, 1 Dec 2026 11:26:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 914D16B05CE; Tue, 1 Dec 2026 11:26:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 804816B0620; Tue, 1 Dec 2026 11:26:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0CF506B05B1 for ; Tue, 1 Dec 2026 11:26:07 -0500 (EST) Received: from smtpin09.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9A7DCA85E0 for ; Tue, 1 Dec 2026 16:26:06 +0000 (UTC) X-FDA: 85495941132.09.51C16E0 Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) by imf02.hostedemail.com (Postfix) with ESMTP id C7D6880007 for ; Tue, 1 Dec 2026 16:26:04 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20260707 header.b="Ppt/3hRV"; spf=pass (imf02.hostedemail.com: domain of ndokutovich@gmail.com designates 74.125.224.45 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=1796142365; b=GZSeAn2aMUfSQltrO6jkRoxMN6PetU8LThSaHv6euGAa1guSUKAugOXnfY1VQZFKhCVXde RXuOUctek9EQUqOWf59brxAWDZfxFXvx2vSQqSqb387Or2BawejbSky52sV5lrTWCB41bz xUZ5ObrkY8aTvnK/4Ii74fDs9Pw2F/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796142365; 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=S71G/E94CeqiGEE3hDk6NKe+7pLT1nr3vXF78yfhQHY=; b=wKpjTdJwt1/f/LRHDDsVuIdZemI9kpfbSDqHXLO8KxGIEJq0mfPIy76hn8CW7BYyFU2E3V FNCx4BwDV96HeRmhgjqPu8vJS7eBPCBa0uRJDR+J8HGthwzMBRgG7l/+aCF52n/I5y3acH qe7k0ktqn2R2IWe05QU/W/dWA2IsYLk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20260707 header.b="Ppt/3hRV"; spf=pass (imf02.hostedemail.com: domain of ndokutovich@gmail.com designates 74.125.224.45 as permitted sender) smtp.mailfrom=ndokutovich@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-67be1e468a8so11600220d50.0 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=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=S71G/E94CeqiGEE3hDk6NKe+7pLT1nr3vXF78yfhQHY=; b=Ppt/3hRVhf4OARlUtCeVIBP1DICu64XSyr8zcv/L7sKq3Ke+WhciiqDgOMZd8a4Jgq bTm2/B25SHNSXuzeHT263CO+kty1iPGi0OAwJTUYBR/VzswxhF0ERMkEWdcVcixRQ/1T K6hnEhJWR4Hh3q/UrXIeSgSW1ikrS5m0+Ne7L9GEhG7Md1UtMeork1XW/mxagmiaenaM YDVXXGV4bwuFHZBRlXU6SHYxvz4mhKNotDpkme/ZSkrDZkArwkEkG34+ZxfsbcAmcRUT I3oyhKPB+m1xnzS8CoffbHzs417+3MQtfV/6+vYdfUS4cXWnKmuBKWQQfwt0EayKog5R zCXQ== 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=LixntZGVu4+84pDdOhWuOW40uEtQjzuF2vyxY9aNcBSo3myfj4KYKdNsLydv4Q5wSs w3AUfZsazFj0H4o0oIuien2/NJ548eba28kshVz9BvlPG6uF/4ZbzVW8kdn9aFS0KxnT feopHv9EfKKVQu18gFeJnBjSpAlSSV+vNot4lPTdQ6QbArrAUaaIgBK+Qmxs+y+5fIv9 LpX8L2A+G2E7FDTHGhPv17htDzcCEcBsr3VX/Cib48DP1JHCb4J9Rbs11azFwA9jlV0v ALsNSM09zR07oAJH/8I1uJ/npg+APCNKG3smxS3iscfbc9xHvkQQ8IqpX8ci9MOCeC9E +24g== X-Forwarded-Encrypted: i=1; AL+hErEKvIrqAt1+G0G56+WejDhEXSL0qLed28/jUxiaCMV9wYWMvms6etMDNeAVl6i5Vo3C8Y1RM5ueDA==@kvack.org X-Gm-Message-State: APuU4Z+cxZy6E1O6tG2Ldg3+1Q+O4Try2GAViQlh7EbF9+8mPacs44Kw nykV/oPc4Mxgje82GWUrd/CXX76jiTgsQH9NqgtmMTaod30XzhPwMO0+R2L88yUXjcpzRw== X-Gm-Gg: AZFdTZfxT/BJMdUWdS0xFvTQzUBCDpy0C2+Tgjt4yvdLR7O0A2Yx6h9xtz0IoJ9UsXQ Jqwjm5Mv85T+FefMq/ArnGq/S3d/w2GUW1FP9HKmXY8/jJr0aMlehI94f2ZqmswO67oYTjsq9Ji xNouR0dQlRp4s337h69+0pZqgh5ZTDywBi+rz1QvBcZH4x+bSfK5xPTtt+VVIArqKi1MUuVN4bH AW4QZYRJPFdEQHVIJ5aA30QJpLcjO8rulQiO1RmxrCsHrUe9C8sKH/EHUMiR284Y9nbeTqzKRDR wiM6iA8JXLTw15JL1ckZE5n4PSVFrBmDHnYXKxJE/h3VOQDhXDB50OhXaAc7F4UIbZetYygCKyt DN6giYPPzYaUr8u7SPomn00A83anluLZsrSlPpaLcgEhLfuxpBrxOUY3ReZoB2dKjA1HhkW7+ji oC48K78GuuEPXL11PRfE/h52QuOYm+XVTbBuBbAwsWR0g/r21944GoLFpGzECCwbaKnSafwRrEf i/eTIeD+QGMq0ch9gP4x2ZyIXC6qHygc7Fuo9ZP9EZ2iPXTrpdxkc93I3Z4lMIeCYEXOS0TUCYU n82RZyWYgrxAGjuSBF2ajwu+50dNHsgWnxnL1k2yJWF/knG7AYPSqiZhFv7Crg+WkoxtxGiuwhl D6M1n 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-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: C7D6880007 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-Stat-Signature: ar9qnpthmwtnwzy3om1d7i7983bh1sbz X-HE-Tag: 1796142364-840345 X-HE-Meta: U2FsdGVkX1+dam1Tva8UQaC556NYonMJ5v/HGZc3sdVAO7vxU+XKdNd1LPi4tengJ97Xh7AIwNdc7OLMecyjs7VnAP5MEWRT6NkU9IYVGsm8W1ZcjZzdzFiFokDZUcNEp6QFhsIF0XwUnYnfsU3ryIpSpj6RU5FwJlXkRVuXruxIZS1OA77fqAZoGw31pYCkxOMrWzY+Bz3oOGGQZQOs0bThNfYNN5fgomxUWvu/Fg1sS30z9vDrj5h5Irz3XaohfUMmzjEZP2kTN0s5oOt54miS98GYytOK4MxTqwlmXwfeKEZZpb12hHUeZfmeXU7l+AhRHteee0YOworSYhBjMDpI5UaRE3K7VefGTrIPw8Zorm7AmmHLrGRuYJW7qx02WyER9XGnTL7GH92M6Xk4LASiIbqf9MZ7LzOcdoefxJlWb2Uf4AgZZ1Bh8gnSdzWS+U0srf8vuiU/P+kes1SIZBS4y37LIFUMLcSSTyPikHI0sbb+EDDQpgZtV7QAlP0eycpW5kHdjY4a2NVdhfg48wxOo6uiBfacBNj+iDnFzYRmzHzbilNuuIN6le+jaApQ5naytYIJke3fybbTDdNsrzp42mh5Eiw7z12Nee7vK+jnw9q8+QEYIEppzAwCEEiv7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-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, 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