From nobody Fri Jul 24 22:17:47 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0D38D42122F for ; Wed, 22 Jul 2026 21:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754356; cv=none; b=DcPfg09Ti8oBvXwWg0nskPiPrlkNctrqKbSDWGL+DclHcRjvgnGUDsK4S0IbsRFMuwVCN79TYmYODpW0xbslyw0ScLwvEiWx5AatGAgJKdIYZi/GG8X9NBTiVd5VlUyypF6rt2vizKP564Qu1m10SYlyGowLbNo7NZ+HfA+KuUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754356; c=relaxed/simple; bh=udX1cwjp2CRQQSKvxIyXgO/nmMA9P1XiVrFYnRq3ldE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rCGuRmRFSXMWB+X9XjeDtnoEhY5ktVsLDJxvY4Sx4N6bLK/IYuO6DMUgq3PS/WxEEApxD7OjQR3LOC8Of+6t5eVYti5CGeM9HrNCmR7+RubVpuf/UUCYltiewZwuco1KeoO4hcwo+Wae1gZPxsMawPlTZoN4QqWZCMn5mqK012w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bYTu0T8z; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bYTu0T8z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B65251F00A3A; Wed, 22 Jul 2026 21:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784754354; bh=YhNcuw4b4HgJphga+WRCnVyLPkYz8tiNzWfnPMrXAbg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=bYTu0T8zGgidw7j+ZlvCqZe2FcOSW1KE+iAzH7TGFCUnz+8SVRSHAT0R+KPORYhnQ PyYkTtWIyOI65YcnlFzeFbMqFzwNFxSgA52ThqkxUeIFvVkcGmnB6SyKnUct9sgnbF tIPQBre3u2Uoq2WqaBU9A8x66IaVxwMbdk0V8L+m2evDp1r3+gXFg+l9NzbW1NpFva OlLar18TGNjy6ER7DifkfIjK6xvt4ULfYZ/ZJDGHeONEZhyuKVsrdF4ZZ8bZs6prtW r0YVsHNjNTp+Vmy4txa/9QsD/Havaar7i/+ipQOS+sNRWL4gi4cx+4i2fJL/sCHuF0 Bv2MJBlfJIpXg== From: Vincent Mailhol Date: Wed, 22 Jul 2026 23:04:52 +0200 Subject: [PATCH 1/2] lib/ucs2_string.c: fix indentation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260722-fix-ucs2_strnlen-v1-1-ba5bade2b026@kernel.org> References: <20260722-fix-ucs2_strnlen-v1-0-ba5bade2b026@kernel.org> In-Reply-To: <20260722-fix-ucs2_strnlen-v1-0-ba5bade2b026@kernel.org> To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Vincent Mailhol X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2187; i=mailhol@kernel.org; h=from:subject:message-id; bh=udX1cwjp2CRQQSKvxIyXgO/nmMA9P1XiVrFYnRq3ldE=; b=owGbwMvMwCV2McXO4Xp97WbG02pJDFmJBuvfS/1XP/5T/ilnzr+zl/rcHaeG3H23T63i09HYw PKCj1Mud0xgYRDjYrAUU2RZVs7JrdBR6B126K8lzBxWJpAh0iINDEDAwsCXm5hXaqRjpGeqbahn CGToGDFwcQrAVPfKMPwP6itpvyQVw71g5iNbw2h+zv+rv01mkwnm/zSv9Z9f5Ep+hh/nT0nkpZt cdL88W8JH9uqf56kb+LSOtj6V6EpK8C50ZgcA X-Developer-Key: i=mailhol@kernel.org; a=openpgp; fpr=ED8F700574E67F20E574E8E2AB5FEB886DBB99C2 checkpatch.pl reports a total of 19 incorrect use of spaces instead of tabulations in lib/ucs2_string.c. Apply ./scripts/checkpatch.pl --fix-inplace lib/ucs2_string.c to fix them all. Signed-off-by: Vincent Mailhol --- lib/ucs2_string.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/ucs2_string.c b/lib/ucs2_string.c index dfb4f2358cab..f07fcdad764b 100644 --- a/lib/ucs2_string.c +++ b/lib/ucs2_string.c @@ -6,18 +6,18 @@ unsigned long ucs2_strnlen(const ucs2_char_t *s, size_t maxlength) { - unsigned long length =3D 0; + unsigned long length =3D 0; =20 - while (*s++ !=3D 0 && length < maxlength) - length++; - return length; + while (*s++ !=3D 0 && length < maxlength) + length++; + return length; } EXPORT_SYMBOL(ucs2_strnlen); =20 unsigned long ucs2_strlen(const ucs2_char_t *s) { - return ucs2_strnlen(s, ~0UL); + return ucs2_strnlen(s, ~0UL); } EXPORT_SYMBOL(ucs2_strlen); =20 @@ -28,7 +28,7 @@ EXPORT_SYMBOL(ucs2_strlen); unsigned long ucs2_strsize(const ucs2_char_t *data, unsigned long maxlength) { - return ucs2_strnlen(data, maxlength/sizeof(ucs2_char_t)) * sizeof(= ucs2_char_t); + return ucs2_strnlen(data, maxlength/sizeof(ucs2_char_t)) * sizeof(ucs2_ch= ar_t); } EXPORT_SYMBOL(ucs2_strsize); =20 @@ -87,19 +87,19 @@ EXPORT_SYMBOL(ucs2_strscpy); int ucs2_strncmp(const ucs2_char_t *a, const ucs2_char_t *b, size_t len) { - while (1) { - if (len =3D=3D 0) - return 0; - if (*a < *b) - return -1; - if (*a > *b) - return 1; - if (*a =3D=3D 0) /* implies *b =3D=3D 0 */ - return 0; - a++; - b++; - len--; - } + while (1) { + if (len =3D=3D 0) + return 0; + if (*a < *b) + return -1; + if (*a > *b) + return 1; + if (*a =3D=3D 0) /* implies *b =3D=3D 0 */ + return 0; + a++; + b++; + len--; + } } EXPORT_SYMBOL(ucs2_strncmp); =20 --=20 2.54.0 From nobody Fri Jul 24 22:17:47 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 75DA04399F7 for ; Wed, 22 Jul 2026 21:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754357; cv=none; b=WDQAOB3CpvnZRQubWUf7udNdCf+vqVC8FfP76mkY9bGnt8pSVPl+1uep5JU4MwluKezZQ/v4oZAH+nQ94RHU+ztrdh+bSq1eeF++sLKJx+GT7yLV/1nau589rmNdimzzXHGcQNQ6e+bhOunO9OnKD7/vAaCksMn7BTSllk5oK3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784754357; c=relaxed/simple; bh=EMtQKYybNj47JrlGfLsjLz+AjZGThwkxH4uO0rS3X/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iBVV2S7JNWJmGNt4/Ab9z7LQ9GrmEaIjsrQFP6/CCl5j3qPz+B5rtwosBlJa7ATCHhzaK83UOtYT+dNsTU4ciTSR25af+ZEMVY9/ELGZn8jiJGPA4OG8dIBuUmYZhUyhtw9PKU1nEQeQrBioRmaUapqu8U+cxwQbHzkB7jxexxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MIsrGM5O; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MIsrGM5O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3622E1F000E9; Wed, 22 Jul 2026 21:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784754356; bh=VhRBkvEuXDvZWZd33ZCLAU+z1laggCqij2b/PDVKGTI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=MIsrGM5O8RgbcNXnM3wOfiPMirZv6/c/k2Mb4NjHH6F5URj+nCiKwnokqwRHZYinE GMQuaBlLIbJHPh4LNRXWTV6cGR9dqMo+s6cMXi6sZ1QLQbXXpTeGyt2Xf/tmbuCMBR b6epckj30YeUkPELQ2P6nNAF8FcYuy/qC3d2y+tfrPdenGFpZ6vLbtdwuvxztQ2jYJ V27oz6wkQLhqCjZPFleYW4BACI+xSSSNqCK+OOQft8V7JKC6a9dOMnyN/vnNRtZk3X cEcu3OXnhrbpm2iZQZ2teCkUT8PusQjpD+8I+xfT0vEV9QNylRbUY2pF+ZHCrA+MrO gbzvR6T0xkG7w== From: Vincent Mailhol Date: Wed, 22 Jul 2026 23:04:53 +0200 Subject: [PATCH 2/2] lib/ucs2_string.c: fix out-of-bounds read in ucs2_strnlen() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260722-fix-ucs2_strnlen-v1-2-ba5bade2b026@kernel.org> References: <20260722-fix-ucs2_strnlen-v1-0-ba5bade2b026@kernel.org> In-Reply-To: <20260722-fix-ucs2_strnlen-v1-0-ba5bade2b026@kernel.org> To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Vincent Mailhol X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1494; i=mailhol@kernel.org; h=from:subject:message-id; bh=EMtQKYybNj47JrlGfLsjLz+AjZGThwkxH4uO0rS3X/s=; b=owGbwMvMwCV2McXO4Xp97WbG02pJDFmJButrrXoeH08ulpD5siju3qG9Dh9XWTImpMzc2Cp1g NV0h/fmjoksDGJcDJZiiizLyjm5FToKvcMO/bWEmcPKBDJEWqSBAQhYGPhyE/NKjXSM9Ey1DfUM gQwdIwYuTgGY6t9yDP+TzT0PF36L4K5iVjz9O8T0+M3Q1YyTHFgXxMyucavcGvKDkeHxfB7mRoa 9z7p6zp5REFuxuvZ4Ufpvm5SGNnG7xxsvfGEBAA== X-Developer-Key: i=mailhol@kernel.org; a=openpgp; fpr=ED8F700574E67F20E574E8E2AB5FEB886DBB99C2 ucs2_strnlen() checks the current character before checking whether the caller-provided maximum length has been reached. If the input is not NUL-terminated within that bound, the loop can read one ucs2_char_t past the limit. Test the length before dereferencing to prevent an off-by-one out-of-bounds read. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Vincent Mailhol --- Concerning the Fixes: tag, the ucs2_strnlen() function can be traced as follow: - commit 0635eb8a54cf ("Move utf16 functions to kernel core and rename") renames it from utf16_strnlen() to ucs2_strnlen() as we know it today. - commit a2940908391f ("efivars: String functions") renames utf8_strlen() to utf16_strnlen(). - utf8_strlen() is present since the begining of the git history in commit 1da177e4c3f4 ("Linux-2.6.12-rc2") And that of-by-one issue was present since the beginning and survived all the renamings. This is why I picked 1da177e4c3f4 in the Fixes tag. --- lib/ucs2_string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ucs2_string.c b/lib/ucs2_string.c index f07fcdad764b..1f7dd4eb640a 100644 --- a/lib/ucs2_string.c +++ b/lib/ucs2_string.c @@ -8,7 +8,7 @@ ucs2_strnlen(const ucs2_char_t *s, size_t maxlength) { unsigned long length =3D 0; =20 - while (*s++ !=3D 0 && length < maxlength) + while (length < maxlength && *s++ !=3D 0) length++; return length; } --=20 2.54.0