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 DCC1B606A68C for ; Wed, 2 Dec 2026 16:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HQz9FFDB Received: by kanga.kvack.org (Postfix) id 0D6076B065C; Wed, 2 Dec 2026 11:28:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 087D96B065D; Wed, 2 Dec 2026 11:28:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDF2C6B066A; Wed, 2 Dec 2026 11:28:24 -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 C836E6B065C for ; Wed, 2 Dec 2026 11:28:24 -0500 (EST) Received: from smtpin15.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 638FCA7EDE for ; Wed, 2 Dec 2026 16:28:24 +0000 (UTC) X-FDA: 85499575728.15.99CF3C2 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf09.hostedemail.com (Postfix) with ESMTP id B50FB140005 for ; Wed, 2 Dec 2026 16:28:22 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=HQz9FFDB; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796228902; b=Yev9jKFgOUeUJy1tNZolKjo0ASes/zzPMu9SYrXYEd3ukaNU6mdor0o8V2AQ25uGHKCz7S /mhy0iq7mUVnTg+veOxaFkhQD9rLlx9q6J2jqo0IEZDNdd2fRNixGsFd5RGkTgaNVxO0k7 wvCNQz4t0bibxJ6Y7acz1lOw3E74nlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796228902; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vu3NMDR9tM4HgcObSPtWIVtyBZqqODQiwVX39HvcYyE=; b=7EFGccQVosn2RtEmvf5njE7HJBQP70qsb+I70sGj1ZJhhq+T/EdTmrUkBIC9EsKz/cI2Mf hkHIB6k9X8T3bkEyed4y4Is1Km/KfOzu5uN3hUMPIecZXg93DrnwxoVqhx4F11aQOENWBa W1IHFm02jWrwk1Y42n5y1L3fQAnRKtI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=HQz9FFDB; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id DC16D41F4C; Wed, 2 Dec 2026 16:28:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 169B21F0092A; Wed, 2 Dec 2026 16:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796228901; bh=vu3NMDR9tM4HgcObSPtWIVtyBZqqODQiwVX39HvcYyE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=HQz9FFDBd6bA/OsJoxr925o1jK7E0HPwWvWf4LDXZoylymRgITZWbn4ov/zOIy8Ps aXqE0f9FlQBWK0KmDrDM9hUVa7enMiqetV+zW3/argtnZiCUdJYIhLNpjzI/GRDuUF BxcIOMUApZl9UYWjARB/+I42PhPn99pmwHE8zCuAzHY0bAejE1vtDc4of1/lYeb92d MvCdfoJBaI3a65Gc8MjFJlRNXpFsMqWWQ1gXG2Qpa8jmIOcGQcNAklKYosNaLZh3JQ US/X45paWbqPv5rfvlEA6uScktNx4hYhel9h9nMmk0K+CTx7Obp9qb5pI+0Jnyj2mx nUSOOuDqR2N6Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 1/3] selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem Reply-To: sashiko-reviews@lists.linux.dev To: "Nikolai Dokutovich" , "David Hildenbrand" , "Andrew Morton" Cc: "Shuah Khan" , "Liam R. Howlett" , "Vlastimil Babka" , "Mike Rapoport" , "Michal Hocko" , "Xu Xin" , linux-mm@kvack.org In-Reply-To: <20261201162600.42818-2-ndokutovich@gmail.com> References: <20261201162600.42818-1-ndokutovich@gmail.com> <20261201162600.42818-2-ndokutovich@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 16:28:20 +0000 X-Rspamd-Queue-Id: B50FB140005 X-Stat-Signature: 5u7jsrfjj5kn48opempjop4rqn6zgjg4 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1796228902-625043 X-HE-Meta: U2FsdGVkX1/yARu1tU0gGk6P14GBKACGz6t4D3wZimio12EgZ9KpuHjeITg2RDdmt12cNQz+3zAf5snihgYqfOJH9mUMZ5Cias1DMDMieXOb7FGEB//bvFxLJ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f094hnSFPGm2PeiLz6nxbl17Sbb9mz7kJGsy2z57CDfDB2+RUUEr3J6P+g4ZGLFkNa8XFfNHoCCq1bPcOWqnCXkoWaFcwWQyPr6g2WVgtObW7fICP9yEjdGzWfnL+VjscUtBsYy0gZ3763hszrbBvhsC7RIfBxW0ss8Om+5H+aMwsGuXw9G2FnTVz446+u/AmCYlZC6IbL6oUc4QnAOAirSbK0s84JSggMv79wAag2eleb4NyIq+hQynUGHn1CZHBOuxBji18HFvOkBoZuwAMOTZIpQQAO1OhLmbE0RwdRmqtFxLWsRFXYLvoNmuROI7nok28QAbD52duKn4ku4VJoFFKzF+9qFsDtn1NU32j/CnEJVIBg8xRfwXjBR00Ov7sKmggie5ZA36KT+PFbuFt+oD4gcPFM2wq/IcG5ED17BEZdHpg+/RLCRUuxEeRb722PVNxOcfMqoGkjpho2j4gOnnN3ejU7Hnvw4vsqekm3tU4QgCzKTXpG21BdexX2x/HVbxQDlW2AGbZh8wp4YCPswCd+Qb4k3xRL+L4u5Di07UaVRn9Ckv4pm2MSOuF90VkWX2DKtvFza9Swyp+ug4i0m5CjOaVEaQJ/UYeJtzG8hRBaGPEiEKeI6JcykVZ3XN1OlEsX4g4VvPyd7PD+Ncbq8uHf8BEt0bBmFPsxQVu9gfqWnC0u Sender: 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] selftests/mm: unaddressed v3 feedback in proc_mem_force_write_allowed() -- commit 08995802b6cf0750e79384ecbd8c2d42d5886d8d Author: Nikolai Dokutovich selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem This commit adds a proc_mem_force_write_allowed() helper to vm_util to probe and cache whether forced writes to read-only mappings through /proc/self/mem are permitted by the running kernel. > diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftes= ts/mm/vm_util.c > index b5485326fa0bc..2df6d92e5afd6 100644 > --- a/tools/testing/selftests/mm/vm_util.c > +++ b/tools/testing/selftests/mm/vm_util.c > @@ -1176,3 +1176,50 @@ void shm_limits_prepare(unsigned long length) > shmall =3D val; > } > } > + > +bool proc_mem_force_write_allowed(void) > +{ > + static int allowed =3D -1; > + const size_t pagesize =3D getpagesize(); > + ssize_t ret; > + char data =3D 1; > + char *mem; > + int fd; > + > + if (allowed >=3D 0) > + return allowed; > + > + mem =3D mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1= , 0); > + if (mem =3D=3D MAP_FAILED) > + return true; > + > + fd =3D open("/proc/self/mem", O_RDWR); > + if (fd < 0) { > + munmap(mem, pagesize); > + return true; > + } > + > + if (lseek(fd, (off_t)(uintptr_t)mem, SEEK_SET) =3D=3D (off_t)-1) { > + close(fd); > + munmap(mem, pagesize); > + return true; > + } > + > + ret =3D write(fd, &data, 1); > + if (ret < 0) > + ret =3D -errno; > + close(fd); > + munmap(mem, pagesize); > + > + /* > + * A refused forced write transfers zero bytes and mem_rw() reports > + * that as -EIO, but any other zero-byte remote access reports the > + * same. Cache only the two decisive results and leave anything else > + * to the test. > + */ > + if (ret !=3D 1 && ret !=3D -EIO) > + return true; > + > + allowed =3D (ret =3D=3D 1); > + return allowed; > +} > diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftes= ts/mm/vm_util.h > index 6fd92a3ee6996..2898cd8877cec 100644 > --- a/tools/testing/selftests/mm/vm_util.h > +++ b/tools/testing/selftests/mm/vm_util.h > @@ -81,6 +81,23 @@ static inline void force_read_pages(char *addr, unsign= ed int nr_pages, > =20 > bool detect_huge_zeropage(void); > =20 > +/* > + * Whether a write through /proc/self/mem into a mapping that is not > + * writable is permitted. The kernel performs such a write as a forced > + * (FOLL_FORCE) write. The answer depends on the kernel configuration, > + * the boot parameters and whether the writing task traces the target, > + * not on the mapping, so a decisive result is cached after one probe. > + * This holds for the self probe only: another target or a policy that > + * could change during the run would not be safe to cache. > + * > + * A successful write returns true; -EIO returns false, although -EIO can > + * also mean another zero-byte remote access and so indicates a refusal > + * without proving one. Any other result is inconclusive: the probe > + * returns true and caches nothing, so the test runs and reports its own > + * failure instead of skipping. > + */ > +bool proc_mem_force_write_allowed(void); [Severity: Low] As reported by David Hildenbrand (Arm) on v3 [1], why does proc_mem_force_write_allowed() need special handling to distinguish -EIO from other write() failures on a freshly mapped read-only anonymous page, and could this two-paragraph comment in vm_util.h be reduced to a brief summary? [1] https://lore.kernel.org/r/b9714a42-e690-440b-8eba-474c6b8dcfbf@kernel.o= rg --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201162600.4281= 8-1-ndokutovich@gmail.com?part=3D1