summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-10-19 19:23:44 +0100
committerMark Brown <broonie@kernel.org>2026-10-19 19:23:44 +0100
commit2dee91ee94eec85d09c13c7ca83e3005906d3732 (patch)
tree16b3ca8de599279fa3c4ed9be5d60c1c422e00f6 /rust/kernel
parentf52260f49b107fddbcf7c75f9cf2347a5031f0f7 (diff)
parentd5a821f66047c2effd06147b84775f9b2ce0f4aa (diff)
regmap: Merge up fixes
The main thing here is a fix for lockdep warnings with MMIO regmaps that use a raw spinlock and a cache, some other lockdep fixes we'd done for the benefit of the maple tree on sleeping buses meant that we were doing allocations for those MMIO regmaps under a raw spinlock. While fixing that Michael Reeves also noticed that the debugfs files were briefly available without the cache structures backing them. There's also a fix for interrupt freeing on error in regmap-irq which had been hanging around because it's not super urgent.
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/net/netlink.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/rust/kernel/net/netlink.rs b/rust/kernel/net/netlink.rs
index 22ef3dde36fa..2f8733a694a9 100644
--- a/rust/kernel/net/netlink.rs
+++ b/rust/kernel/net/netlink.rs
@@ -11,6 +11,7 @@
use kernel::{
alloc::{self, AllocError},
error::to_result,
+ num::casts::u16_as_usize,
prelude::*,
transmute::AsBytes,
types::Opaque,
@@ -86,9 +87,17 @@ impl GenlMsg {
where
T: ?Sized + AsBytes,
{
+ // `nla_len` is a 16-bit field that encodes the total attribute length
+ // (header + payload). Subtracting the header size from `u16::MAX` gives
+ // the largest payload that still fits within that field.
+ const MAX_PAYLOAD_LEN: usize = u16_as_usize(u16::MAX) - size_of::<bindings::nlattr>();
+
let skb = self.skb.skb.as_ptr();
let len = size_of_val(value);
let ptr = core::ptr::from_ref(value).cast::<c_void>();
+ if len > MAX_PAYLOAD_LEN {
+ return Err(EMSGSIZE);
+ }
// SAFETY: `skb` is valid by `NetlinkSkBuff` type invariants, and the provided value is
// readable and initialized for its `size_of` bytes.
to_result(unsafe { bindings::nla_put(skb, attrtype, len as c_int, ptr) })