From nobody Mon Apr 6 10:32:02 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5F3726FA6F for ; Sun, 29 Mar 2026 10:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781616; cv=none; b=Ixr/tjwqc6yzz6xY9TEbOXN3xZT9vRr/WXwKqQqeOgXY2Qsy4/guPcEaaoEit5VTbD5KuKWNgyBNqeERHvTRHj1arI+ulnBsm+b/8zW7o8Th+0MezLZimj30JCp9IfjQXwt9xcqy8Rm3GsBunUXIORP1EJEYKmBXax2D9w/a65Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781616; c=relaxed/simple; bh=Ya6zLoKlFgYC44o3rc8HUO2twEzsCTjzlk0GqAXeJ8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rym+2ThQlBO8W4+ujyk9DkXvjMWxctou2eR6W0cI3o3I+wCTryG8COLEMakI+v7SdePAPby8TPb7A22lXO2bvwiKX+gib86EjilxPhNVco3ExGYwymKINKXGizzV3gue4wHXIuy0gDE8VCGS0cd9C6iP24SIvaivlkxOQmYMnbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 638FB5BDD1; Sun, 29 Mar 2026 10:53:31 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 683DB4A0A2; Sun, 29 Mar 2026 10:53:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 6HaiCKcEyWkqcwAAD6G6ig (envelope-from ); Sun, 29 Mar 2026 10:53:27 +0000 From: David Disseldorp To: Andy Shevchenko , David Disseldorp , Petr Mladek , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Al Viro , Christian Brauner , Jan Kara , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton Subject: [PATCH v4 1/6] initramfs_test: add fill_cpio() inject_ox parameter Date: Sun, 29 Mar 2026 21:30:23 +1100 Message-ID: <20260329105307.2876-2-ddiss@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260329105307.2876-1-ddiss@suse.de> References: <20260329105307.2876-1-ddiss@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 638FB5BDD1 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: Content-Type: text/plain; charset="utf-8" fill_cpio() uses sprintf() to write out the in-memory cpio archive from an array of struct initramfs_test_cpio. This change allows callers to modify the cpio sprintf() format string so that future tests can intentionally corrupt the header with "0x" and "0X" prefixed fields. Signed-off-by: David Disseldorp Reviewed-by: Andy Shevchenko --- init/initramfs_test.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/init/initramfs_test.c b/init/initramfs_test.c index 2ce38d9a8fd0f..3ec7591660e03 100644 --- a/init/initramfs_test.c +++ b/init/initramfs_test.c @@ -27,7 +27,17 @@ struct initramfs_test_cpio { char *data; }; =20 -static size_t fill_cpio(struct initramfs_test_cpio *cs, size_t csz, char *= out) +/* regular newc header format */ +#define CPIO_HDR_FMT "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%0= 8x%s" +/* + * bogus newc header with "0x" prefixes on the uid, gid and namesize value= s. + * parse_header()/simple_str[n]toul() accept this. + */ +#define CPIO_HDR_OX_INJECT \ + "%s%08x%08x0x%06x0X%06x%08x%08x%08x%08x%08x%08x%08x0x%06x%08x%s" + +static size_t fill_cpio(struct initramfs_test_cpio *cs, size_t csz, + bool inject_ox, char *out) { int i; size_t off =3D 0; @@ -38,9 +48,8 @@ static size_t fill_cpio(struct initramfs_test_cpio *cs, s= ize_t csz, char *out) size_t thislen; =20 /* +1 to account for nulterm */ - thislen =3D sprintf(pos, "%s" - "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x" - "%s", + thislen =3D sprintf(pos, + inject_ox ? CPIO_HDR_OX_INJECT : CPIO_HDR_FMT, c->magic, c->ino, c->mode, c->uid, c->gid, c->nlink, c->mtime, c->filesize, c->devmajor, c->devminor, c->rdevmajor, c->rdevminor, c->namesize, c->csum, @@ -102,7 +111,7 @@ static void __init initramfs_test_extract(struct kunit = *test) /* +3 to cater for any 4-byte end-alignment */ cpio_srcbuf =3D kzalloc(ARRAY_SIZE(c) * (CPIO_HDRLEN + PATH_MAX + 3), GFP_KERNEL); - len =3D fill_cpio(c, ARRAY_SIZE(c), cpio_srcbuf); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, cpio_srcbuf); =20 ktime_get_real_ts64(&ts_before); err =3D unpack_to_rootfs(cpio_srcbuf, len); @@ -177,7 +186,7 @@ static void __init initramfs_test_fname_overrun(struct = kunit *test) /* limit overrun to avoid crashes / filp_open() ENAMETOOLONG */ cpio_srcbuf[CPIO_HDRLEN + strlen(c[0].fname) + 20] =3D '\0'; =20 - len =3D fill_cpio(c, ARRAY_SIZE(c), cpio_srcbuf); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, cpio_srcbuf); /* overwrite trailing fname terminator and padding */ suffix_off =3D len - 1; while (cpio_srcbuf[suffix_off] =3D=3D '\0') { @@ -219,7 +228,7 @@ static void __init initramfs_test_data(struct kunit *te= st) cpio_srcbuf =3D kmalloc(CPIO_HDRLEN + c[0].namesize + c[0].filesize + 6, GFP_KERNEL); =20 - len =3D fill_cpio(c, ARRAY_SIZE(c), cpio_srcbuf); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, cpio_srcbuf); =20 err =3D unpack_to_rootfs(cpio_srcbuf, len); KUNIT_EXPECT_NULL(test, err); @@ -274,7 +283,7 @@ static void __init initramfs_test_csum(struct kunit *te= st) =20 cpio_srcbuf =3D kmalloc(8192, GFP_KERNEL); =20 - len =3D fill_cpio(c, ARRAY_SIZE(c), cpio_srcbuf); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, cpio_srcbuf); =20 err =3D unpack_to_rootfs(cpio_srcbuf, len); KUNIT_EXPECT_NULL(test, err); @@ -284,7 +293,7 @@ static void __init initramfs_test_csum(struct kunit *te= st) =20 /* mess up the csum and confirm that unpack fails */ c[0].csum--; - len =3D fill_cpio(c, ARRAY_SIZE(c), cpio_srcbuf); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, cpio_srcbuf); =20 err =3D unpack_to_rootfs(cpio_srcbuf, len); KUNIT_EXPECT_NOT_NULL(test, err); @@ -330,7 +339,7 @@ static void __init initramfs_test_hardlink(struct kunit= *test) =20 cpio_srcbuf =3D kmalloc(8192, GFP_KERNEL); =20 - len =3D fill_cpio(c, ARRAY_SIZE(c), cpio_srcbuf); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, cpio_srcbuf); =20 err =3D unpack_to_rootfs(cpio_srcbuf, len); KUNIT_EXPECT_NULL(test, err); @@ -371,7 +380,7 @@ static void __init initramfs_test_many(struct kunit *te= st) }; =20 c.namesize =3D 1 + sprintf(thispath, "initramfs_test_many-%d", i); - p +=3D fill_cpio(&c, 1, p); + p +=3D fill_cpio(&c, 1, false, p); } =20 len =3D p - cpio_srcbuf; @@ -425,7 +434,7 @@ static void __init initramfs_test_fname_pad(struct kuni= t *test) } }; =20 memcpy(tbufs->padded_fname, "padded_fname", sizeof("padded_fname")); - len =3D fill_cpio(c, ARRAY_SIZE(c), tbufs->cpio_srcbuf); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, tbufs->cpio_srcbuf); =20 err =3D unpack_to_rootfs(tbufs->cpio_srcbuf, len); KUNIT_EXPECT_NULL(test, err); @@ -481,7 +490,7 @@ static void __init initramfs_test_fname_path_max(struct= kunit *test) memcpy(tbufs->fname_oversize, "fname_oversize", sizeof("fname_oversize") - 1); memcpy(tbufs->fname_ok, "fname_ok", sizeof("fname_ok") - 1); - len =3D fill_cpio(c, ARRAY_SIZE(c), tbufs->cpio_src); + len =3D fill_cpio(c, ARRAY_SIZE(c), false, tbufs->cpio_src); =20 /* unpack skips over fname_oversize instead of returning an error */ err =3D unpack_to_rootfs(tbufs->cpio_src, len); --=20 2.51.0 From nobody Mon Apr 6 10:32:02 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5251D2FFF9D for ; Sun, 29 Mar 2026 10:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781622; cv=none; b=bQKysBwdOueFrb4931pJksVuefHRAq283PfcE2rRM52qtOA12cUHgs+ApnXbnC9z88S7jNZtvyMVmuaohlt13hQf4w7q1Eci/KYyA/YmyTKdHo5M1mYIoFjMcsD8YjX71LE+APnU3hvIEx3guk32c9q8JqPGlioTdRcHavYtJFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781622; c=relaxed/simple; bh=yu0ekuKmhk6KF+b7EWZ4s/+CJEGCU1mvDVfuH++T5ug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbE71o80uP3WqyKyeUP4LnRt7e2F5ejtz453Tw+XSyslHkM7MRLkv0n36qBFOLx0hWu/s0bvzBYYYFdxFSBfPnE9+zT6RF5gUcznNBcYWRehzYUsrmPdnx1uO6TAyhqWKzAPBrjN81wf9jzH3o3TDin7IhASEaEBBrQhgVnLM8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=GQ02T1Zd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=F8h4+0fk; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=GQ02T1Zd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=F8h4+0fk; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GQ02T1Zd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="F8h4+0fk"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GQ02T1Zd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="F8h4+0fk" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E351D5BDD2; Sun, 29 Mar 2026 10:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1774781615; h=from:from:reply-to: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=4nM9vHfJigvCbxE7p4g2bM2ijYKPlux51hII50TNosU=; b=GQ02T1Zd/zcn4ZJnddsfTgjzwiNSoWPH5ZcIk8TWj2REttIubVep2WI8omnzIzQpvCPkfY 3eZQrrN6uCg/tvx7wj8FssRNhKRVFcc0hPQmiX+luWgEYut39bi1AAOgygaZhvAy472E83 xUT/dxq5QqbbHSkE1sAEdT69nTVDCKQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1774781615; h=from:from:reply-to: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=4nM9vHfJigvCbxE7p4g2bM2ijYKPlux51hII50TNosU=; b=F8h4+0fkfKkw/ntLs+AMzjju+1S//fe2CaZTrZNt/lryZkz5VtizfmQ1g8w3bO69Bq2rRv WLmAFk4kM3mx9oAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1774781615; h=from:from:reply-to: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=4nM9vHfJigvCbxE7p4g2bM2ijYKPlux51hII50TNosU=; b=GQ02T1Zd/zcn4ZJnddsfTgjzwiNSoWPH5ZcIk8TWj2REttIubVep2WI8omnzIzQpvCPkfY 3eZQrrN6uCg/tvx7wj8FssRNhKRVFcc0hPQmiX+luWgEYut39bi1AAOgygaZhvAy472E83 xUT/dxq5QqbbHSkE1sAEdT69nTVDCKQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1774781615; h=from:from:reply-to: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=4nM9vHfJigvCbxE7p4g2bM2ijYKPlux51hII50TNosU=; b=F8h4+0fkfKkw/ntLs+AMzjju+1S//fe2CaZTrZNt/lryZkz5VtizfmQ1g8w3bO69Bq2rRv WLmAFk4kM3mx9oAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E99D24A0A2; Sun, 29 Mar 2026 10:53:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id oMYqKKsEyWkqcwAAD6G6ig (envelope-from ); Sun, 29 Mar 2026 10:53:31 +0000 From: David Disseldorp To: Andy Shevchenko , David Disseldorp , Petr Mladek , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Al Viro , Christian Brauner , Jan Kara , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton Subject: [PATCH v4 2/6] initramfs_test: test header fields with 0x hex prefix Date: Sun, 29 Mar 2026 21:30:24 +1100 Message-ID: <20260329105307.2876-3-ddiss@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260329105307.2876-1-ddiss@suse.de> References: <20260329105307.2876-1-ddiss@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[12]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" cpio header fields are 8-byte hex strings, but one "interesting" side-effect of our historic simple_str[n]toul() use means that a "0x" (or "0X") prefixed header field will be successfully processed when coupled alongside a 6-byte hex remainder string. "0x" prefix support is contrary to the initramfs specification at Documentation/driver-api/early-userspace/buffer-format.rst which states: The structure of the cpio_header is as follows (all fields contain hexadecimal ASCII numbers fully padded with '0' on the left to the full width of the field, for example, the integer 4780 is represented by the ASCII string "000012ac"): Test for this corner case by injecting "0x" prefixes into the uid, gid and namesize cpio header fields. Confirm that init_stat() returns matching uid and gid values. This test can be modified in future to expect unpack_to_rootfs() failure when header validation is changed to properly follow the specification. Signed-off-by: David Disseldorp Reviewed-by: Andy Shevchenko --- init/initramfs_test.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/init/initramfs_test.c b/init/initramfs_test.c index 3ec7591660e03..4a7a85560ee50 100644 --- a/init/initramfs_test.c +++ b/init/initramfs_test.c @@ -503,6 +503,61 @@ static void __init initramfs_test_fname_path_max(struc= t kunit *test) kfree(tbufs); } =20 +static void __init initramfs_test_hdr_hex(struct kunit *test) +{ + char *err; + size_t len; + struct kstat st0, st1; + char fdata[] =3D "this file data will be unpacked"; + struct initramfs_test_bufs { + char cpio_src[(CPIO_HDRLEN + PATH_MAX + 3 + sizeof(fdata)) * 2]; + } *tbufs =3D kzalloc(sizeof(struct initramfs_test_bufs), GFP_KERNEL); + struct initramfs_test_cpio c[] =3D { { + .magic =3D "070701", + .ino =3D 1, + .mode =3D S_IFREG | 0777, + .uid =3D 0x123456, + .gid =3D 0x123457, + .nlink =3D 1, + .namesize =3D sizeof("initramfs_test_hdr_hex_0"), + .fname =3D "initramfs_test_hdr_hex_0", + .filesize =3D sizeof(fdata), + .data =3D fdata, + }, { + .magic =3D "070701", + .ino =3D 2, + .mode =3D S_IFDIR | 0777, + .uid =3D 0x000056, + .gid =3D 0x000057, + .nlink =3D 1, + .namesize =3D sizeof("initramfs_test_hdr_hex_1"), + .fname =3D "initramfs_test_hdr_hex_1", + } }; + + /* inject_ox=3Dtrue to add "0x" cpio field prefixes */ + len =3D fill_cpio(c, ARRAY_SIZE(c), true, tbufs->cpio_src); + + err =3D unpack_to_rootfs(tbufs->cpio_src, len); + KUNIT_EXPECT_NULL(test, err); + + KUNIT_EXPECT_EQ(test, init_stat(c[0].fname, &st0, 0), 0); + KUNIT_EXPECT_EQ(test, init_stat(c[1].fname, &st1, 0), 0); + + KUNIT_EXPECT_TRUE(test, + uid_eq(st0.uid, make_kuid(current_user_ns(), (uid_t)0x123456))); + KUNIT_EXPECT_TRUE(test, + gid_eq(st0.gid, make_kgid(current_user_ns(), (gid_t)0x123457))); + KUNIT_EXPECT_TRUE(test, + uid_eq(st1.uid, make_kuid(current_user_ns(), (uid_t)0x56))); + KUNIT_EXPECT_TRUE(test, + gid_eq(st1.gid, make_kgid(current_user_ns(), (gid_t)0x57))); + + KUNIT_EXPECT_EQ(test, init_unlink(c[0].fname), 0); + KUNIT_EXPECT_EQ(test, init_rmdir(c[1].fname), 0); + + kfree(tbufs); +} + /* * The kunit_case/_suite struct cannot be marked as __initdata as this wil= l be * used in debugfs to retrieve results after test has run. @@ -516,6 +571,7 @@ static struct kunit_case __refdata initramfs_test_cases= [] =3D { KUNIT_CASE(initramfs_test_many), KUNIT_CASE(initramfs_test_fname_pad), KUNIT_CASE(initramfs_test_fname_path_max), + KUNIT_CASE(initramfs_test_hdr_hex), {}, }; =20 --=20 2.51.0 From nobody Mon Apr 6 10:32:02 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F05CF31353C for ; Sun, 29 Mar 2026 10:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781623; cv=none; b=jFetntleKhrIb9fHe8OA2NkBWekPt1VnGKZ1986+RUGpiq3w21P97oRw1iOEdAzskCDamTvdh9YNw2qv+yYfgSerjcqp14Qz1wd/azeC+gMT50V5Y5+vtvcmwMkZPZX2/xiL5PDVcL2Ke4IpYJSvmhB0C5xSGdenRbYlJIbBYro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781623; c=relaxed/simple; bh=1LTk4jsdk68clq9+RGJhf2C8O9FUoagnfRqW72nhv+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b6SAePfim6zu+zxGvpetvRSPjvr2sVIoZwZtKByRx7XD0j6zsSC2ncCu4hSkM1fcJxzGxG3PTyeFiwXtzPPioy0tqruxLIjs2bVgUNsUR93Shfpj2CeAxEhxvFv6aoXNnWi0fcqNj9pyKWhwrz1QjIyBLPCHirPoZa2v8szeDWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6F3344D4F5; Sun, 29 Mar 2026 10:53:40 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 752304A0A2; Sun, 29 Mar 2026 10:53:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qJzDC7AEyWkqcwAAD6G6ig (envelope-from ); Sun, 29 Mar 2026 10:53:36 +0000 From: David Disseldorp To: Andy Shevchenko , David Disseldorp , Petr Mladek , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Al Viro , Christian Brauner , Jan Kara , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton Subject: [PATCH v4 3/6] initramfs: Sort headers alphabetically Date: Sun, 29 Mar 2026 21:30:25 +1100 Message-ID: <20260329105307.2876-4-ddiss@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260329105307.2876-1-ddiss@suse.de> References: <20260329105307.2876-1-ddiss@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 6F3344D4F5 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko Sorting headers alphabetically helps locating duplicates, and makes it easier to figure out where to insert new headers. Signed-off-by: Andy Shevchenko Reviewed-by: David Disseldorp --- init/initramfs.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 139baed06589a..4ed796566cf35 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -1,25 +1,25 @@ // SPDX-License-Identifier: GPL-2.0 -#include #include -#include -#include -#include -#include -#include #include -#include #include -#include -#include +#include +#include #include +#include +#include +#include #include #include #include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include =20 #include "do_mounts.h" #include "initramfs_internal.h" --=20 2.51.0 From nobody Mon Apr 6 10:32:02 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 890DB274B39 for ; Sun, 29 Mar 2026 10:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781630; cv=none; b=KTbTf/XMT1HiGlmM5+QvGpiMvbT4yOpdJGGP2U8aqTYl6l+Hbmm/0CPPirS/OjUMJFQwPd7qldUkXk+9IJUGL0bR8VbBefxO/a4mM1M0Whv1SLXpcjFY47E+giM/Dpm2MCbfLrzLhWELtEUhmTvOOtO+n9BTCIHjD22OTM17jtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781630; c=relaxed/simple; bh=tQHosTlLcdVnbXjQy+SS/ZFvnKIisj97Lu1fOzti6qE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I25bpdVVZcIF2ju+VIvwuA1bfN6HS4L1cVGpWmP2urVXcQmwpUc+YCavKFqVOH9Xq5cz74YKWE+VjmTDghnhgE0Q8ZjsyXpXthzVBYChvScvy7k5AGTTi4e5AfTiX61h6rTFFM0zjd2fgJhVM1FnHRyzRqGWeOZdxIKJdj81vHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EFFA25BCE6; Sun, 29 Mar 2026 10:53:44 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 011E74A0A2; Sun, 29 Mar 2026 10:53:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id QN0CK7QEyWkqcwAAD6G6ig (envelope-from ); Sun, 29 Mar 2026 10:53:40 +0000 From: David Disseldorp To: Andy Shevchenko , David Disseldorp , Petr Mladek , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Al Viro , Christian Brauner , Jan Kara , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton Subject: [PATCH v4 4/6] initramfs: Refactor to use hex2bin() instead of custom approach Date: Sun, 29 Mar 2026 21:30:26 +1100 Message-ID: <20260329105307.2876-5-ddiss@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260329105307.2876-1-ddiss@suse.de> References: <20260329105307.2876-1-ddiss@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: EFFA25BCE6 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko There is a simple_strntoul() function used solely as a shortcut for hex2bin() with proper endianess conversions. Replace that and drop the unneeded function in the next changes. This implementation will abort if we fail to parse the cpio header, instead of using potentially bogus header values. Co-developed-by: David Disseldorp Signed-off-by: David Disseldorp Signed-off-by: Andy Shevchenko --- init/initramfs.c | 44 +++++++++++++++++++++++++------------------ init/initramfs_test.c | 23 ++++------------------ 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 4ed796566cf35..0d38ea8e63a29 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,8 @@ #include #include =20 +#include + #include "do_mounts.h" #include "initramfs_internal.h" =20 @@ -190,26 +193,30 @@ static __initdata gid_t gid; static __initdata unsigned rdev; static __initdata u32 hdr_csum; =20 -static void __init parse_header(char *s) +static int __init parse_header(char *s) { - unsigned long parsed[13]; - int i; + __be32 header[13]; + int ret; =20 - for (i =3D 0, s +=3D 6; i < 13; i++, s +=3D 8) - parsed[i] =3D simple_strntoul(s, NULL, 16, 8); + ret =3D hex2bin((u8 *)header, s + 6, sizeof(header)); + if (ret) { + error("damaged header"); + return ret; + } =20 - ino =3D parsed[0]; - mode =3D parsed[1]; - uid =3D parsed[2]; - gid =3D parsed[3]; - nlink =3D parsed[4]; - mtime =3D parsed[5]; /* breaks in y2106 */ - body_len =3D parsed[6]; - major =3D parsed[7]; - minor =3D parsed[8]; - rdev =3D new_encode_dev(MKDEV(parsed[9], parsed[10])); - name_len =3D parsed[11]; - hdr_csum =3D parsed[12]; + ino =3D be32_to_cpu(header[0]); + mode =3D be32_to_cpu(header[1]); + uid =3D be32_to_cpu(header[2]); + gid =3D be32_to_cpu(header[3]); + nlink =3D be32_to_cpu(header[4]); + mtime =3D be32_to_cpu(header[5]); /* breaks in y2106 */ + body_len =3D be32_to_cpu(header[6]); + major =3D be32_to_cpu(header[7]); + minor =3D be32_to_cpu(header[8]); + rdev =3D new_encode_dev(MKDEV(be32_to_cpu(header[9]), be32_to_cpu(header[= 10]))); + name_len =3D be32_to_cpu(header[11]); + hdr_csum =3D be32_to_cpu(header[12]); + return 0; } =20 /* FSM */ @@ -289,7 +296,8 @@ static int __init do_header(void) error("no cpio magic"); return 1; } - parse_header(collected); + if (parse_header(collected)) + return 1; next_header =3D this_header + N_ALIGN(name_len) + body_len; next_header =3D (next_header + 3) & ~3; state =3D SkipIt; diff --git a/init/initramfs_test.c b/init/initramfs_test.c index 4a7a85560ee50..4785423f601c2 100644 --- a/init/initramfs_test.c +++ b/init/initramfs_test.c @@ -31,7 +31,8 @@ struct initramfs_test_cpio { #define CPIO_HDR_FMT "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%0= 8x%s" /* * bogus newc header with "0x" prefixes on the uid, gid and namesize value= s. - * parse_header()/simple_str[n]toul() accept this. + * parse_header()/simple_str[n]toul() accepted this, contrary to the initr= amfs + * specification. hex2bin() now fails. */ #define CPIO_HDR_OX_INJECT \ "%s%08x%08x0x%06x0X%06x%08x%08x%08x%08x%08x%08x%08x0x%06x%08x%s" @@ -507,8 +508,7 @@ static void __init initramfs_test_hdr_hex(struct kunit = *test) { char *err; size_t len; - struct kstat st0, st1; - char fdata[] =3D "this file data will be unpacked"; + char fdata[] =3D "this file data will not be unpacked"; struct initramfs_test_bufs { char cpio_src[(CPIO_HDRLEN + PATH_MAX + 3 + sizeof(fdata)) * 2]; } *tbufs =3D kzalloc(sizeof(struct initramfs_test_bufs), GFP_KERNEL); @@ -538,22 +538,7 @@ static void __init initramfs_test_hdr_hex(struct kunit= *test) len =3D fill_cpio(c, ARRAY_SIZE(c), true, tbufs->cpio_src); =20 err =3D unpack_to_rootfs(tbufs->cpio_src, len); - KUNIT_EXPECT_NULL(test, err); - - KUNIT_EXPECT_EQ(test, init_stat(c[0].fname, &st0, 0), 0); - KUNIT_EXPECT_EQ(test, init_stat(c[1].fname, &st1, 0), 0); - - KUNIT_EXPECT_TRUE(test, - uid_eq(st0.uid, make_kuid(current_user_ns(), (uid_t)0x123456))); - KUNIT_EXPECT_TRUE(test, - gid_eq(st0.gid, make_kgid(current_user_ns(), (gid_t)0x123457))); - KUNIT_EXPECT_TRUE(test, - uid_eq(st1.uid, make_kuid(current_user_ns(), (uid_t)0x56))); - KUNIT_EXPECT_TRUE(test, - gid_eq(st1.gid, make_kgid(current_user_ns(), (gid_t)0x57))); - - KUNIT_EXPECT_EQ(test, init_unlink(c[0].fname), 0); - KUNIT_EXPECT_EQ(test, init_rmdir(c[1].fname), 0); + KUNIT_EXPECT_NOT_NULL(test, err); =20 kfree(tbufs); } --=20 2.51.0 From nobody Mon Apr 6 10:32:02 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36D6D314D14 for ; Sun, 29 Mar 2026 10:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781632; cv=none; b=sk2pbCj6ZG5W+ktBz/0ISTqNXeWZU6v/gF0spFGHWrcp/AYKHM95yoepzQWh95yAhBZIs8nO/9hs3jXqnZ9BY/SRjTVvg2lJejUqPY58hZpoDhrllvTleEm2LAE8pzVAjnDGu4XXD9jfh2uBMFnMsD43vh0MzxjkVW/HKboUvtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781632; c=relaxed/simple; bh=ao2Xi9Wl17PViMKf6WGBjsNBt7xhaL8Ei3caE2OL2JE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ngdSSgCP+NsV+4/Knf1bpAX4KV3LbXD62+R2SsbmtopVVGaJfCDM05M2e7Zea1E+L8RgCGpQF6l3o07r60keFLOROW9Dey+4QOaWXav4GwK1f/wtcOgrjW0dnBogM8+xK3EoU/5Gi+qRIspIFAGVXwBtc8Wv2z8NYyXAwJa8PfI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=msLpZ3p2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=d9+kxp+0; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=msLpZ3p2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=d9+kxp+0; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="msLpZ3p2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="d9+kxp+0"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="msLpZ3p2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="d9+kxp+0" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7A1D24D4F5; Sun, 29 Mar 2026 10:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1774781629; h=from:from:reply-to: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=pxihrPW/nLjv8olLis478LzU+j9xw1IS6YSy+0ZMlcA=; b=msLpZ3p2JF9Le5y/P2RMl0uzijmZt4QDgS82P0KFMZeePfbf+E588b8+ymlVm5oQyzxrYw Po/uXCWXG6hUzh3bjx1gJ5j21oz4921ybaFvEbmTNqUaaKcIMyEVMpc+nNZTPfE4WOrSW0 QRvroVFylFzy5QVA+BK/AUSQFhgIOYk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1774781629; h=from:from:reply-to: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=pxihrPW/nLjv8olLis478LzU+j9xw1IS6YSy+0ZMlcA=; b=d9+kxp+0D5yJq/72WUMEtOq8D2SgojZ5a/ERJaBawBd67R1sVLt8IVWVMkHX6rJ6AqsN5E e+wMa07V/p88e6Bg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1774781629; h=from:from:reply-to: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=pxihrPW/nLjv8olLis478LzU+j9xw1IS6YSy+0ZMlcA=; b=msLpZ3p2JF9Le5y/P2RMl0uzijmZt4QDgS82P0KFMZeePfbf+E588b8+ymlVm5oQyzxrYw Po/uXCWXG6hUzh3bjx1gJ5j21oz4921ybaFvEbmTNqUaaKcIMyEVMpc+nNZTPfE4WOrSW0 QRvroVFylFzy5QVA+BK/AUSQFhgIOYk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1774781629; h=from:from:reply-to: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=pxihrPW/nLjv8olLis478LzU+j9xw1IS6YSy+0ZMlcA=; b=d9+kxp+0D5yJq/72WUMEtOq8D2SgojZ5a/ERJaBawBd67R1sVLt8IVWVMkHX6rJ6AqsN5E e+wMa07V/p88e6Bg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 81AA24A0A2; Sun, 29 Mar 2026 10:53:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aLfRDrkEyWkqcwAAD6G6ig (envelope-from ); Sun, 29 Mar 2026 10:53:45 +0000 From: David Disseldorp To: Andy Shevchenko , David Disseldorp , Petr Mladek , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Al Viro , Christian Brauner , Jan Kara , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton Subject: [PATCH v4 5/6] vsprintf: Revert "add simple_strntoul" Date: Sun, 29 Mar 2026 21:30:27 +1100 Message-ID: <20260329105307.2876-6-ddiss@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260329105307.2876-1-ddiss@suse.de> References: <20260329105307.2876-1-ddiss@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[intel.com:email,suse.com:email,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; R_RATELIMIT(0.00)[to_ip_from(RLg9cg5ahbkfmeaz1ygcd5onax)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 X-Spam-Level: Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko No users anymore and none should be in the first place. This reverts commit fcc155008a20fa31b01569e105250490750f0687. Signed-off-by: Andy Shevchenko Reviewed-by: David Disseldorp Acked-by: Petr Mladek --- include/linux/kstrtox.h | 1 - lib/vsprintf.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/include/linux/kstrtox.h b/include/linux/kstrtox.h index 6ea897222af1d..7fcf29a4e0de4 100644 --- a/include/linux/kstrtox.h +++ b/include/linux/kstrtox.h @@ -143,7 +143,6 @@ static inline int __must_check kstrtos32_from_user(cons= t char __user *s, size_t */ =20 extern unsigned long simple_strtoul(const char *,char **,unsigned int); -extern unsigned long simple_strntoul(const char *,char **,unsigned int,siz= e_t); extern long simple_strtol(const char *,char **,unsigned int); extern unsigned long long simple_strtoull(const char *,char **,unsigned in= t); extern long long simple_strtoll(const char *,char **,unsigned int); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 800b8ac49f53f..52ea14a08d3a5 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -129,13 +129,6 @@ unsigned long simple_strtoul(const char *cp, char **en= dp, unsigned int base) } EXPORT_SYMBOL(simple_strtoul); =20 -unsigned long simple_strntoul(const char *cp, char **endp, unsigned int ba= se, - size_t max_chars) -{ - return simple_strntoull(cp, endp, base, max_chars); -} -EXPORT_SYMBOL(simple_strntoul); - /** * simple_strtol - convert a string to a signed long * @cp: The start of the string --=20 2.51.0 From nobody Mon Apr 6 10:32:02 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E85F313E36 for ; Sun, 29 Mar 2026 10:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781636; cv=none; b=BhHKEp6ga5YSFE+NSDkXlsPqxGOMyXdLeBJ1nuQGq4wWCUEHZ2NRDAqa8JD25vrTBZJrZZSlwybMGRAqUrPhkn3nlaKnEm1UbRHjcTLlPiNhPBa4OLnOb6JIDoVt5R19n55kwVuYWOgVzzol7adWL/SD11JAWGWlJnR99q/b7ZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774781636; c=relaxed/simple; bh=NtdlBhQV2VlxX2h7MdXsFGBQD9aeOUTYJysty5gVNJ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O/Z5e9ANTkCddQ4Cr+yxpkBOYaluYvd0081SBAYLTq9b5vSg681v0HoesR8CC+W5GNJG52M79TMVoQ30VspI3GwKSAn48AMlRFSUqbNNXSuMSl+RHHjKcM82Ir6azzrr1TEFCHohoukAul3FBCEFJMws4EXCfrCNT5cgLIAzubo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0600E5BDD1; Sun, 29 Mar 2026 10:53:54 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0C1754A0A2; Sun, 29 Mar 2026 10:53:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gC6/Lb0EyWkqcwAAD6G6ig (envelope-from ); Sun, 29 Mar 2026 10:53:49 +0000 From: David Disseldorp To: Andy Shevchenko , David Disseldorp , Petr Mladek , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Al Viro , Christian Brauner , Jan Kara , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton Subject: [PATCH v4 6/6] kstrtox: Drop extern keyword in the simple_strtox() declarations Date: Sun, 29 Mar 2026 21:30:28 +1100 Message-ID: <20260329105307.2876-7-ddiss@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260329105307.2876-1-ddiss@suse.de> References: <20260329105307.2876-1-ddiss@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 0600E5BDD1 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Score: -4.00 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko There is legacy 'extern' keyword for the exported simple_strtox() function which are the artefact that can be removed. So drop it. While at it, tweak the declaration to provide parameter names. Signed-off-by: Andy Shevchenko Reviewed-by: David Disseldorp Reviewed-by: Petr Mladek --- include/linux/kstrtox.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/kstrtox.h b/include/linux/kstrtox.h index 7fcf29a4e0de4..6c92828667704 100644 --- a/include/linux/kstrtox.h +++ b/include/linux/kstrtox.h @@ -142,9 +142,9 @@ static inline int __must_check kstrtos32_from_user(cons= t char __user *s, size_t * Keep in mind above caveat. */ =20 -extern unsigned long simple_strtoul(const char *,char **,unsigned int); -extern long simple_strtol(const char *,char **,unsigned int); -extern unsigned long long simple_strtoull(const char *,char **,unsigned in= t); -extern long long simple_strtoll(const char *,char **,unsigned int); +unsigned long simple_strtoul(const char *cp, char **endp, unsigned int bas= e); +long simple_strtol(const char *cp, char **endp, unsigned int base); +unsigned long long simple_strtoull(const char *cp, char **endp, unsigned i= nt base); +long long simple_strtoll(const char *cp, char **endp, unsigned int base); =20 #endif /* _LINUX_KSTRTOX_H */ --=20 2.51.0