From nobody Sun May 24 21:36:37 2026 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09C3E368D5A for ; Thu, 21 May 2026 09:07:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779354456; cv=none; b=AifDeoRoeOUAu92uwRTN7ZH071B6eSsvHmbt38p72UFIsBrIMRTPTDYMLiKZOoTR/DmtQRmx6Aiwddntmj89ifcz7I1evX0LFwU+kpcnQWFpg3F705mJilqmm2odrXDZnbkg7mqdLSRfAjks+JTs+qnY4Hzs2NwO+RMGrCxYcKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779354456; c=relaxed/simple; bh=d+sRF5H30DnHl8zsHElEvlBRcbP5jT6jopR0Zg0fwzQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nAygB0k2EY9tQ0nallAMktyVdfs7wsazRrBrs0H57Vj0ybjmTI7dZJ0QKS196+oWOAgyStKn2SFk5fv+Gpp5pzbSALNRGPV3re+noqXqLX7UXu72aC8fM2ICbsfSvBC3LX5Ubcql5HP/1xRA02r97ViR170PW904tSVzatnO2VQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=CY66bobv; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="CY66bobv" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779354452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DXhh/3pfw6eWOrAj3wFcgN8+CS5myBHUR35TRSpaluM=; b=CY66bobv7cI+tfUFCA/g4Yu0zOZlao4OPUOIFKNduJpYTF+RzbO31IbRX6KWQ+V63drLZu XRtEH4aCF3fEdbyuTAH7LHMMYNz7Kd8pSynWJcRysuoMQLxvNa8akJpyPBZWiYGIOotGyO 4s0MP7fuJF/W87waK+o0wlBfxrSuH4U= From: Thorsten Blum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Kees Cook , Andy Shevchenko , Yury Norov , David Laight Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH v2 1/2] vdso: move offset_in_page() from linux/mm.h to vdso/page.h Date: Thu, 21 May 2026 11:06:57 +0200 Message-ID: <20260521090655.160282-5-thorsten.blum@linux.dev> In-Reply-To: <20260521090655.160282-4-thorsten.blum@linux.dev> References: <20260521090655.160282-4-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1390; i=thorsten.blum@linux.dev; h=from:subject; bh=d+sRF5H30DnHl8zsHElEvlBRcbP5jT6jopR0Zg0fwzQ=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFl8p83L2YoD9YrWr2m+xXYp2k3SYM0CL4mSWtO66ezv3 ujvFvvTUcrCIMbFICumyPJg1o8ZvqU1lZtMInbCzGFlAhnCwMUpABP5pM7I8GsVQ3HH+8xfPgvC XjPkV8g0Zhac5a3P2nxxqbSQQGmDEiPDxOOfXd5Utv4U27LX+cHEXSl8tscvHQjWTTrhvEd9olQ YEwA= X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Move offset_in_page() out of linux/mm.h so users that only need page offset calculations can include the lightweight vdso/page.h header instead of pulling in the large linux/mm.h. Include vdso/page.h from linux/mm.h so existing users of offset_in_page() continue to build. Signed-off-by: Thorsten Blum Reviewed-by: Lorenzo Stoakes --- include/linux/mm.h | 2 +- include/vdso/page.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9cedc5e75aa9..d5c7f1ca80ef 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -37,6 +37,7 @@ #include #include #include +#include =20 struct mempolicy; struct anon_vma; @@ -3023,7 +3024,6 @@ static inline void clear_page_pfmemalloc(struct page = *page) */ extern void pagefault_out_of_memory(void); =20 -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) #define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio)= - 1)) =20 /* diff --git a/include/vdso/page.h b/include/vdso/page.h index bc47186c07fc..948b13091084 100644 --- a/include/vdso/page.h +++ b/include/vdso/page.h @@ -28,4 +28,6 @@ #define PAGE_MASK (~(PAGE_SIZE - 1)) #endif =20 +#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) + #endif /* __VDSO_PAGE_H */ From nobody Sun May 24 21:36:37 2026 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8BB2366822 for ; Thu, 21 May 2026 09:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779354459; cv=none; b=uR7av0FNwp/w7E5gGuwkg4JURwE5aXoOWMVtGdr/KEFN6okvSHMzUu5maaPRnPjkDZS8E/bqcCKsZTo1ARDWTPLYAmG/cFpCU+I+eQR4LKubNV38P54rOwxR6t+Ek83BG7LIdKfX4BekXo4OuILmgoItVXfgN73oCtwWgBw5RH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779354459; c=relaxed/simple; bh=91QQINpqJQ4LAne0V/WZIX3VWZlJe2bHssd2YEiaLxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=quw4Zxgm69y2Yy+PoKcfMUmd42Hv5lLBngsHq27tBjHXpYneHFBMqKdx2YnSzljmNxjLTuM6KCjaEcymydXfV3Qma1Mcry60A0G/lxUSq9Djv0m6V/fj4wE55f0oj8TpJMyQwX3Rdm6LHkQtvR5A2WqZToYw2nzyDxghrROa3UE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qGfzm4vu; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qGfzm4vu" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779354454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q6PIi1QDLQ8OiWtIk4Ayg6HwJRAUJXMtOoaQbIBan90=; b=qGfzm4vuEPBnDO187cwa572J3ejFLntC1T/y7X1WjBIPlOg3kHCqJdTijZrXfSErHvbwns 5Vf3ljA32GuaKOtDg7JLcOPDLwhdgg+C0a4YAmn5OfeMYO487+rkuh++OARMWcqPBM6zW/ hvOMHpTIA12WgP8Y9knM9oZomCfTa3o= From: Thorsten Blum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Kees Cook , Andy Shevchenko , Yury Norov , David Laight Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH v2 2/2] string: use offset_in_page() in sized_strscpy() Date: Thu, 21 May 2026 11:06:58 +0200 Message-ID: <20260521090655.160282-6-thorsten.blum@linux.dev> In-Reply-To: <20260521090655.160282-4-thorsten.blum@linux.dev> References: <20260521090655.160282-4-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=960; i=thorsten.blum@linux.dev; h=from:subject; bh=91QQINpqJQ4LAne0V/WZIX3VWZlJe2bHssd2YEiaLxo=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFl8p81fnDSdb7vixZyanNulm5Xna/Z33i5Y61e++1dBR sO/lTy7O0pZGMS4GGTFFFkezPoxw7e0pnKTScROmDmsTCBDGLg4BWAiPd8YGf4uahT3FL1nzpNe wzrVcaPbB6/ZepKqMeePsR/nWnJqXw0jw7bW7/MiLqk+VfKXfjiB5bR/4gQnBc9ji7e5mxzadfT rLlYA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace the open-coded implementation with offset_in_page() to simplify sized_strscpy(). Signed-off-by: Thorsten Blum --- lib/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/string.c b/lib/string.c index 1f9297e9776a..7c72adc7377c 100644 --- a/lib/string.c +++ b/lib/string.c @@ -25,6 +25,7 @@ #include #include #include +#include =20 #include #include @@ -127,7 +128,7 @@ ssize_t sized_strscpy(char *dest, const char *src, size= _t count) * since we don't know if the next page is mapped. */ if ((long)src & (sizeof(long) - 1)) - max =3D min(PAGE_SIZE - ((long)src & (PAGE_SIZE - 1)), max); + max =3D min(PAGE_SIZE - offset_in_page(src), max); #else /* If src or dest is unaligned, don't do word-at-a-time. */ if (((long) dest | (long) src) & (sizeof(long) - 1))