From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795924829; b=R2upZM75l1ntk0LzEPQpzsGRzWjAHX2gYic6PA6123ssj/UoEBRgJGsvheVcda60c+Jw ShASL5p+2d7We7lZxHk51rMcxerZ5qbzaKx6AqeS2nEgdcpxZOIMebIrJSf9lnprELJ+o SmX5AoDBUzKZ7WcBkNuqUgJ5CGSuqAK/EjGZXDKU9XqPVtEwzNrmLg1U396KGXBeS4Jar VfHL5GN8WKAlO4rAFGwMkvqvBYiajl2OubQVdaepQSsrFdXBbYXdhqYWzk0oQ/sy8JLly gWv1tqOXH+V0IbW43CH06C4jJn3kD3BUER2kuWjmG5m7ZAEe5jJ6elntr/sTB4CnC2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795924829; 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=3RiB+GbX6ia3xNdyzjVaBIouLdSoOQbe41/d1OlMynDXDn1lgLlS9rwLTH2Ay6eufqpd xSXKdn4AZQjBsF5XzfJvFVVCYORp4/icy4+JcnfbrFikuzmPA6X1jMedq70ierr7HhLWE cQe1OIxid1/iX66XaLDnGrFlhh/Toil/qP0a1yGAQIqySPkyEl9Co/RWXe77D6t6wSS+0 KKvXS/5Z2fm9TQ4Z0iMyvt4eiOLdIskyBto6Rl392t1uYuSlHK+mRLx94lhrbC6uPfdDE vGG9GSwF9x+Su0dJOeIpFlfJtM1X2gOEfmYQ/PMJHWPelvWK7tkhXfQRwAiTf/nehhA== 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=Qe0dcMXg; arc=none smtp.remote-ip=209.85.222.177 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 25781606A31C for ; Sun, 29 Nov 2026 04:00:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 25781606A31C 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=Qe0dcMXg Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-9495f083657so1009661885a.0 for ; Sat, 28 Nov 2026 20:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795924828; x=1796529628; 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=Qe0dcMXgjre6FWppDbtDwFKc0CM2bWQcyvDHzUY9qXhcjOkRD055EZ2Elqt51en16w CELmPJkZ24mQezHr02L84HhR8PyBUfVylwQ9ydsO3lxRx0RUxiZOdghwGPa9e4Nv1GM1 VBTPmVkTuxh2SSeY/wjIpPj+BwwzekaKbY+EFInVxAoltdDVkpe8XwWi5pztUVW5eG51 +LU6WHGa/qxSus5jfxqj9wlVThgsf9+wo3UQfMQ8Veh5QpXNKSIdBIao7fxsP0f189L8 A+cZ4C23CczdGla2bG8E/7JKtNoMiCpvrxaLvy7NNshGc2el74pLrHTCLDZxRTAaxYus 9hpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795924828; x=1796529628; 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=d99TMTD6x8Ik0zzPPMkRAfUchTJg+i2EfREVJlehmyZIryNumNhc9o9/6l1kf3NjGp /r9ErU4+gnrrJBHt0uZSubKUCgbnSdXKlII66RCZOwLsufGrFNTQbyG6PBRR9k7YXE9M o20VVUcKFbQEUfbINTXu64lu6oVAs8QQh+xfhYbZdnM3LONaGWxvtFK9zKN/GkZlAYEv xuQIGezEtWBlG9tn1imL36+bh4XuJS2k/nPqdOhLL+dIcgmqWfU6uk5kxdR4fIArxiYo 4hFvkMqI40KYoBR/092nGBG0QWJjNNdr4TARUpf8ycRL8BIqdcfRW4+uGJCYoQ3b7W8J Um/g== X-Forwarded-Encrypted: i=1; AL+hErHVqCBAThb9HSw0oP0P5xDi8CWCbSMpDKlvZxQVq+bVMOt0wFiJP4mEbzQm7uv0OecOEp41Wusa9MI8RYA=@vger.kernel.org X-Gm-Message-State: APuU4Z9WHhom6izt7BlTaT3Jy1vr4FjyoZA30fOw2hqPrWBHheBDuP0y lehSf5XokL4e3DJ9cvJyGEdaZdW6pvkj3w9iIDElUAc03nObG6uaVdbK9Ro+vuswmZ3E+w== X-Gm-Gg: AZFdTZdvReXwpeR7raFWy+Lcre2BUnP7UEll/+mp06ea+LhtVu2f/KiSAxMdO7HMYHT FCCXAxc1UEMp4i5+NLHGurynwWFcCB/eRjXtv6DzFAdHn93au/EFJ/ogvAvKqKU9AVEjKVltGcD EA6V5ePN+256VoKrlnWONf78RqV/OaMCq0yShW9vETQamClge1J+E18CaWCBizSFaE0Vg5qsqe2 fGR6c6WBqqTTchTIbDKtXdNDvTan+lGz1tQxXupws+MBYhhvsovfzADQZw3jEzcGS3o1kHYvgEM uMTej9oVM6QNfQhw/umWMZ1wnDtSBPd+N08UrSYfZA4l8YZygK95wbwEasUJB3I5E4rL3qbnK7u YEcrBAfgovXyvcMNkCq9Tubk1syxk4VOGckv7k7+SsnAl5CtF4mzDuyvrKOdEIPvxhB8feqgBs3 EoICt4VzGSpQv6OQU2JVmc65mnCoPUw3TAnxW6OTdWzJXVO1BB1IFcXl4BxU9ivL8pmtXIxjq9N JU1UsnnslTi0IHNoJ3h+fYWYGBX9vYMkujK5xoW/UbhLkxqzaFqydUEbuDDPrzBYLcUgKqip/F6 CToM5NI76bEocNWs1H44igi4/qbkDb7RNv2svdR2pqw9wqAZ3ggOy9gJ63O+QCtEiergcfRrp+E wrV1BQD+kYNy3FHVRusJKwAtoFQ== X-Received: by 2002:a05:620a:2550:b0:949:70ec:7e98 with SMTP id af79cd13be357-949baa13290mr5530703785a.40.1795924827876; Sat, 28 Nov 2026 20:00:27 -0800 (PST) Received: from localhost ([138.197.109.108]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb0315f4sm2190843985a.3.2026.11.28.20.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 20:00:27 -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:22 +0300 Message-ID: <20261129040025.37113-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