# CVE-2024-38540: bnxt\_re: avoid shift undefined behavior in bnxt\_qplib\_alloc\_init\_hwq

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 4.4
- **CVSS:** 4.4 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: High; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.30% (percentile 15, 2026-11-26)
- **Published:** 2024-06-19T13:35:15.823Z
- **Modified:** 2026-06-17T07:40:30.030Z

## Who should check

- Anyone running Linux \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 66a9937187ac9b5c5ffff07b8b284483e56804d1; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 84d2f29152184f0d72ed7c9648c4ee6927df4e59; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< a658f011d89dd20cf2c7cb4760ffd79201700b98; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 627493443f3a8458cb55cdae1da254a7001123bc; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 8b799c00cea6fcfe5b501bbaeb228c8821acb753; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 78cfd17142ef70599d6409cbd709d94b3da58659
- Anyone running Linux 5.7

## Description

In the Linux kernel, the following vulnerability has been resolved:

bnxt\_re: avoid shift undefined behavior in bnxt\_qplib\_alloc\_init\_hwq

Undefined behavior is triggered when bnxt\_qplib\_alloc\_init\_hwq is called
with hwq\_attr-\>aux\_depth != 0 and hwq\_attr-\>aux\_stride == 0.
In that case, "roundup\_pow\_of\_two(hwq\_attr-\>aux\_stride)" gets called.
roundup\_pow\_of\_two is documented as undefined for 0.

Fix it in the one caller that had this combination.

The undefined behavior was detected by UBSAN:
  UBSAN: shift-out-of-bounds in ./include/linux/log2.h:57:13
  shift exponent 64 is too large for 64-bit type 'long unsigned int'
  CPU: 24 PID: 1075 Comm: (udev-worker) Not tainted 6.9.0-rc6+ \#4
  Hardware name: Abacus electric, s.r.o. - servis@abacus.cz Super Server/H12SSW-iN, BIOS 2.7 10/25/2023
  Call Trace:
   \<TASK\>
   dump\_stack\_lvl+0x5d/0x80
   ubsan\_epilogue+0x5/0x30
   \_\_ubsan\_handle\_shift\_out\_of\_bounds.cold+0x61/0xec
   \_\_roundup\_pow\_of\_two+0x25/0x35 \[bnxt\_re\]
   bnxt\_qplib\_alloc\_init\_hwq+0xa1/0x470 \[bnxt\_re\]
   bnxt\_qplib\_create\_qp+0x19e/0x840 \[bnxt\_re\]
   bnxt\_re\_create\_qp+0x9b1/0xcd0 \[bnxt\_re\]
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? \_\_kmalloc+0x1b6/0x4f0
   ? create\_qp.part.0+0x128/0x1c0 \[ib\_core\]
   ? \_\_pfx\_bnxt\_re\_create\_qp+0x10/0x10 \[bnxt\_re\]
   create\_qp.part.0+0x128/0x1c0 \[ib\_core\]
   ib\_create\_qp\_kernel+0x50/0xd0 \[ib\_core\]
   create\_mad\_qp+0x8e/0xe0 \[ib\_core\]
   ? \_\_pfx\_qp\_event\_handler+0x10/0x10 \[ib\_core\]
   ib\_mad\_init\_device+0x2be/0x680 \[ib\_core\]
   add\_client\_context+0x10d/0x1a0 \[ib\_core\]
   enable\_device\_and\_get+0xe0/0x1d0 \[ib\_core\]
   ib\_register\_device+0x53c/0x630 \[ib\_core\]
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   bnxt\_re\_probe+0xbd8/0xe50 \[bnxt\_re\]
   ? \_\_pfx\_bnxt\_re\_probe+0x10/0x10 \[bnxt\_re\]
   auxiliary\_bus\_probe+0x49/0x80
   ? driver\_sysfs\_add+0x57/0xc0
   really\_probe+0xde/0x340
   ? pm\_runtime\_barrier+0x54/0x90
   ? \_\_pfx\_\_\_driver\_attach+0x10/0x10
   \_\_driver\_probe\_device+0x78/0x110
   driver\_probe\_device+0x1f/0xa0
   \_\_driver\_attach+0xba/0x1c0
   bus\_for\_each\_dev+0x8f/0xe0
   bus\_add\_driver+0x146/0x220
   driver\_register+0x72/0xd0
   \_\_auxiliary\_driver\_register+0x6e/0xd0
   ? \_\_pfx\_bnxt\_re\_mod\_init+0x10/0x10 \[bnxt\_re\]
   bnxt\_re\_mod\_init+0x3e/0xff0 \[bnxt\_re\]
   ? \_\_pfx\_bnxt\_re\_mod\_init+0x10/0x10 \[bnxt\_re\]
   do\_one\_initcall+0x5b/0x310
   do\_init\_module+0x90/0x250
   init\_module\_from\_file+0x86/0xc0
   idempotent\_init\_module+0x121/0x2b0
   \_\_x64\_sys\_finit\_module+0x5e/0xb0
   do\_syscall\_64+0x82/0x160
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? syscall\_exit\_to\_user\_mode\_prepare+0x149/0x170
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? syscall\_exit\_to\_user\_mode+0x75/0x230
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? do\_syscall\_64+0x8e/0x160
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? \_\_count\_memcg\_events+0x69/0x100
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? count\_memcg\_events.constprop.0+0x1a/0x30
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? handle\_mm\_fault+0x1f0/0x300
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? do\_user\_addr\_fault+0x34e/0x640
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   ? srso\_alias\_return\_thunk+0x5/0xfbef5
   entry\_SYSCALL\_64\_after\_hwframe+0x76/0x7e
  RIP: 0033:0x7f4e5132821d
  Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 \<48\> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e3 db 0c 00 f7 d8 64 89 01 48
  RSP: 002b:00007ffca9c906a8 EFLAGS: 00000246 ORIG\_RAX: 0000000000000139
  RAX: ffffffffffffffda RBX: 0000563ec8a8f130 RCX: 00007f4e5132821d
  RDX: 0000000000000000 RSI: 00007f4e518fa07d RDI: 000000000000003b
  RBP: 00007ffca9c90760 R08: 00007f4e513f6b20 R09: 00007ffca9c906f0
  R10: 0000563ec8a8faa0 R11: 0000000000000246 R12: 00007f4e518fa07d
  R13: 0000000000020000 R14: 0000563ec8409e90 R15: 0000563ec8a8fa60
   \</TASK\>
  ---\[ end trace \]---

## Affected and fixed versions

- Linux: \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 66a9937187ac9b5c5ffff07b8b284483e56804d1; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 84d2f29152184f0d72ed7c9648c4ee6927df4e59; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< a658f011d89dd20cf2c7cb4760ffd79201700b98; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 627493443f3a8458cb55cdae1da254a7001123bc; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 8b799c00cea6fcfe5b501bbaeb228c8821acb753; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 78cfd17142ef70599d6409cbd709d94b3da58659 (cvelist)
- Linux: 5.7 (cvelist)

## Mitigation

- Upgrade Linux to 78cfd17142ef70599d6409cbd709d94b3da58659 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-38540. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-38540.md
Affected: Linux >= 0c4dcd602817502bb3dced7a834a13ef717d65a4, < 66a9937187ac9b5c5ffff07b8b284483e56804d1; >= 0c4dcd602817502bb3dced7a834a13ef717d65a4, < 84d2f29152184f0d72ed7c9648c4ee6927df4e59; >= 0c4dcd602817502bb3dced7a834a13ef717d65a4, < a658f011d89dd20cf2c7cb4760ffd79201700b98; >= 0c4dcd602817502bb3dced7…
Fixed in: Linux 66a9937187ac9b5c5ffff07b8b284483e56804d1, Linux 84d2f29152184f0d72ed7c9648c4ee6927df4e59, Linux 627493443f3a8458cb55cdae1da254a7001123bc, Linux 8b799c00cea6fcfe5b501bbaeb228c8821acb753, Linux 78cfd17142ef70599d6409cbd709d94b3da58659

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-38540 being exploited?

There is no confirmed exploitation: CVE-2024-38540 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.30% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2024-38540?

Medium: CVSS 4.4 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2024-38540?

Linux \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 66a9937187ac9b5c5ffff07b8b284483e56804d1; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 84d2f29152184f0d72ed7c9648c4ee6927df4e59; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< a658f011d89dd20cf2c7cb4760ffd79201700b98; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 627493443f3a8458cb55cdae1da254a7001123bc; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 8b799c00cea6fcfe5b501bbaeb228c8821acb753; \>= 0c4dcd602817502bb3dced7a834a13ef717d65a4, \< 78cfd17142ef70599d6409cbd709d94b3da58659; Linux 5.7.

### Is there a fix for CVE-2024-38540?

Yes. Fixed in Linux 66a9937187ac9b5c5ffff07b8b284483e56804d1, Linux 84d2f29152184f0d72ed7c9648c4ee6927df4e59, Linux 627493443f3a8458cb55cdae1da254a7001123bc, Linux 8b799c00cea6fcfe5b501bbaeb228c8821acb753, Linux 78cfd17142ef70599d6409cbd709d94b3da58659. Upgrade Linux to 78cfd17142ef70599d6409cbd709d94b3da58659 or later.

### How do I check if I'm affected by CVE-2024-38540?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/84d2f29152184f0d72ed7c9648c4ee6927df4e59>
- patch: <https://git.kernel.org/stable/c/a658f011d89dd20cf2c7cb4760ffd79201700b98>
- patch: <https://git.kernel.org/stable/c/627493443f3a8458cb55cdae1da254a7001123bc>
- patch: <https://git.kernel.org/stable/c/8b799c00cea6fcfe5b501bbaeb228c8821acb753>
- patch: <https://git.kernel.org/stable/c/78cfd17142ef70599d6409cbd709d94b3da58659>
- other: <https://git.kernel.org/stable/c/66a9937187ac9b5c5ffff07b8b284483e56804d1>
- other: <https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-38540>

HTML: <https://flawdb.com/CVE-2024-38540> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-38540>
