summaryrefslogtreecommitdiff
path: root/scripts/basic/split-include.c
diff options
context:
space:
mode:
authorYounes Akhouayri <git@younes.io>2026-09-05 17:16:51 +0200
committerMiguel Ojeda <ojeda@kernel.org>2026-09-06 03:44:00 +0200
commitc6709d5e14072d0e3d02f291daee46a199e5dad3 (patch)
tree883f2dae074963f7d105db1f19273f4942c948e1 /scripts/basic/split-include.c
parent97f8cb91a8c5658fe2ae6f5c2ff6e95474a5eb2f (diff)
downloadlinux-stable-c6709d5e14072d0e3d02f291daee46a199e5dad3.tar.gz
linux-stable-c6709d5e14072d0e3d02f291daee46a199e5dad3.zip
rust: num: seal Integer
Bounded relies on Integer implementations to describe primitive integer semantics correctly. In particular, it uses Integer::BITS and Signedness to justify unchecked operations. Integer is currently safe and externally implementable, so an implementation can violate those assumptions and make safe Bounded operations reach undefined behavior. For example, an Integer implementation for a u8 wrapper can report BITS = 16. Safe code can then cast a Bounded<u16, 9> containing 256 to that wrapper. Its TryFrom<u16> implementation returns Err, and Bounded::cast() calls unwrap_unchecked() on it, causing undefined behavior. Seal Integer so only the primitive implementations provided by the kernel crate can satisfy it. Fixes: 01e345e82ec3 ("rust: num: add Bounded integer wrapping type") Reported-by: Miguel Ojeda <ojeda@kernel.org> Closes: https://lore.kernel.org/rust-for-linux/CANiq72mOfR33s4y+Ueivd5NrC5yre+Pcp57ZOBz0msw9A4AP1Q@mail.gmail.com/ Cc: stable@vger.kernel.org Suggested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Younes Akhouayri <git@younes.io> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260905-feature-rust-num-seal-integer-v2-1-f1311ffbe6e7@younes.io Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'scripts/basic/split-include.c')
0 files changed, 0 insertions, 0 deletions