]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/ncsi: fix heap OOB read in NCSI_CMD_SEND_CMD payload length
authorHenry Martin <bsdhenrymartin@gmail.com>
Mon, 3 Aug 2026 04:36:18 +0000 (12:36 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 6 Aug 2026 00:24:57 +0000 (17:24 -0700)
ncsi_send_cmd_nl() takes the number of bytes to copy from the
attacker-controlled ncsi_pkt_hdr.length field of the in-band packet
header, while the source buffer is the NCSI_ATTR_DATA netlink
attribute whose readable size is nla_len() - sizeof(ncsi_pkt_hdr).
The two length sources are never cross-checked: only
nla_len() >= sizeof(struct ncsi_pkt_hdr) is enforced.

With hdr->length set larger than the attribute payload (up to 65535
against at most 2032 readable bytes), ncsi_cmd_handler_oem() copies
past the end of the netlink attribute buffer with unsafe_memcpy(),
leaking up to ~64KB of kernel heap memory into the transmitted NCSI
command packet. The destination skb is sized by the declared payload,
so the write side does not overflow - this is a pure OOB read /
information leak, reachable with CAP_NET_ADMIN on systems with a
registered NCSI device (e.g. OpenBMC on Aspeed BMC SoCs, where
NET_NCSI=y is standard).

Reject commands whose declared payload extends past the end of the
data attribute.

The issue was found by the autokbug dynamic kernel fuzzer at Tencent
Yunding Lab.

Fixes: 9771b8ccdfa6 ("net/ncsi: Extend NC-SI Netlink interface to allow user space to send NC-SI command")
Reported-by: Henry Martin <bsdhenrymartin@gmail.com>
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Link: https://patch.msgid.link/20260803043618.3210301-1-bsdhenrymartin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ncsi/ncsi-netlink.c

index 2f872d064396df55c2e213c525bae7740c12f62e..8cc538358f6a391c074d64fe19b8fb150e78e0ad 100644 (file)
@@ -461,6 +461,10 @@ static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)
        nca.req_flags = NCSI_REQ_FLAG_NETLINK_DRIVEN;
        nca.info = info;
        nca.payload = ntohs(hdr->length);
+       if (nca.payload > len - sizeof(*hdr)) {
+               ret = -EINVAL;
+               goto out_netlink;
+       }
        nca.data = data + sizeof(*hdr);
 
        ret = ncsi_xmit_cmd(&nca);