Skip to content

Commit 620fd7d

Browse files
committed
Merge: CVE-2025-22104: ibmvnic: Use kernel helpers for hex dumps
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6815 JIRA: https://issues.redhat.com/browse/RHEL-89020 CVE: CVE-2025-22104 ``` commit d93a6ca Author: Nick Child <[email protected]> Date: Thu Mar 20 16:29:51 2025 -0500 ibmvnic: Use kernel helpers for hex dumps Previously, when the driver was printing hex dumps, the buffer was cast to an 8 byte long and printed using string formatters. If the buffer size was not a multiple of 8 then a read buffer overflow was possible. Therefore, create a new ibmvnic function that loops over a buffer and calls hex_dump_to_buffer instead. This patch address KASAN reports like the one below: ibmvnic 30000003 env3: Login Buffer: ibmvnic 30000003 env3: 01000000af000000 <...> ibmvnic 30000003 env3: 2e6d62692e736261 ibmvnic 30000003 env3: 65050003006d6f63 ================================================================== BUG: KASAN: slab-out-of-bounds in ibmvnic_login+0xacc/0xffc [ibmvnic] Read of size 8 at addr c0000001331a9aa8 by task ip/17681 <...> Allocated by task 17681: <...> ibmvnic_login+0x2f0/0xffc [ibmvnic] ibmvnic_open+0x148/0x308 [ibmvnic] __dev_open+0x1ac/0x304 <...> The buggy address is located 168 bytes inside of allocated 175-byte region [c0000001331a9a00, c0000001331a9aaf) <...> ================================================================= ibmvnic 30000003 env3: 000000000033766e Fixes: 032c5e8 ("Driver for IBM System i/p VNIC protocol") Signed-off-by: Nick Child <[email protected]> Reviewed-by: Dave Marquardt <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>``` Signed-off-by: CKI Backport Bot <[email protected]> --- <small>Created 2025-04-30 09:23 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12334433&issuetype=1&priority=4&summary=backporter+webhook+issue&components=kernel-workflow+/+backporter)</small> Approved-by: Kamal Heib <[email protected]> Approved-by: Michal Schmidt <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Augusto Caringi <[email protected]>
2 parents 04d0ea3 + 1a0b34d commit 620fd7d

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4684,6 +4684,18 @@ static void vnic_add_client_data(struct ibmvnic_adapter *adapter,
46844684
strscpy(vlcd->name, adapter->netdev->name, len);
46854685
}
46864686

4687+
static void ibmvnic_print_hex_dump(struct net_device *dev, void *buf,
4688+
size_t len)
4689+
{
4690+
unsigned char hex_str[16 * 3];
4691+
4692+
for (size_t i = 0; i < len; i += 16) {
4693+
hex_dump_to_buffer((unsigned char *)buf + i, len - i, 16, 8,
4694+
hex_str, sizeof(hex_str), false);
4695+
netdev_dbg(dev, "%s\n", hex_str);
4696+
}
4697+
}
4698+
46874699
static int send_login(struct ibmvnic_adapter *adapter)
46884700
{
46894701
struct ibmvnic_login_rsp_buffer *login_rsp_buffer;
@@ -4794,10 +4806,8 @@ static int send_login(struct ibmvnic_adapter *adapter)
47944806
vnic_add_client_data(adapter, vlcd);
47954807

47964808
netdev_dbg(adapter->netdev, "Login Buffer:\n");
4797-
for (i = 0; i < (adapter->login_buf_sz - 1) / 8 + 1; i++) {
4798-
netdev_dbg(adapter->netdev, "%016lx\n",
4799-
((unsigned long *)(adapter->login_buf))[i]);
4800-
}
4809+
ibmvnic_print_hex_dump(adapter->netdev, adapter->login_buf,
4810+
adapter->login_buf_sz);
48014811

48024812
memset(&crq, 0, sizeof(crq));
48034813
crq.login.first = IBMVNIC_CRQ_CMD;
@@ -5173,15 +5183,13 @@ static void handle_query_ip_offload_rsp(struct ibmvnic_adapter *adapter)
51735183
{
51745184
struct device *dev = &adapter->vdev->dev;
51755185
struct ibmvnic_query_ip_offload_buffer *buf = &adapter->ip_offload_buf;
5176-
int i;
51775186

51785187
dma_unmap_single(dev, adapter->ip_offload_tok,
51795188
sizeof(adapter->ip_offload_buf), DMA_FROM_DEVICE);
51805189

51815190
netdev_dbg(adapter->netdev, "Query IP Offload Buffer:\n");
5182-
for (i = 0; i < (sizeof(adapter->ip_offload_buf) - 1) / 8 + 1; i++)
5183-
netdev_dbg(adapter->netdev, "%016lx\n",
5184-
((unsigned long *)(buf))[i]);
5191+
ibmvnic_print_hex_dump(adapter->netdev, buf,
5192+
sizeof(adapter->ip_offload_buf));
51855193

51865194
netdev_dbg(adapter->netdev, "ipv4_chksum = %d\n", buf->ipv4_chksum);
51875195
netdev_dbg(adapter->netdev, "ipv6_chksum = %d\n", buf->ipv6_chksum);
@@ -5412,10 +5420,8 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq,
54125420
netdev->mtu = adapter->req_mtu - ETH_HLEN;
54135421

54145422
netdev_dbg(adapter->netdev, "Login Response Buffer:\n");
5415-
for (i = 0; i < (adapter->login_rsp_buf_sz - 1) / 8 + 1; i++) {
5416-
netdev_dbg(adapter->netdev, "%016lx\n",
5417-
((unsigned long *)(adapter->login_rsp_buf))[i]);
5418-
}
5423+
ibmvnic_print_hex_dump(netdev, adapter->login_rsp_buf,
5424+
adapter->login_rsp_buf_sz);
54195425

54205426
/* Sanity checks */
54215427
if (login->num_txcomp_subcrqs != login_rsp->num_txsubm_subcrqs ||

0 commit comments

Comments
 (0)