Skip to content

Build on Linux 7.2 and 7.3 - #373

Merged
CGarces merged 3 commits into
Mange:realtek-4.4.xfrom
iav:fix/strncpy-removed-in-7.2
Sep 6, 2026
Merged

CGarces merged 3 commits into
Mange:realtek-4.4.xfrom
iav:fix/strncpy-removed-in-7.2

Conversation

@iav

@iav iav commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the 7.2/7.3 CI question in #366; not a one-liner after all.
7.2 removed strncpy(): 28 call sites become memcpy() (byte-count copies, where strscpy() would drop the last character) or strscpy() (destination-sized copies, manual terminators dropped). 7.2 also added rx_addr to remain_on_channel().
7.3 passes the cookie to remain_on_channel()/mgmt_tx() by value; before 7.3 the driver still generates it and writes it back through the pointer.
Built against 7.2.3 headers (arm64), module links. Independent of #366.

iav added 3 commits September 5, 2026 18:21
Linux 7.2 dropped strncpy(), so the driver no longer builds there:

  os_dep/linux/os_intfs.c:1455: error: implicit declaration of function 'strncpy'

Two kinds of call sites, with different replacements:

- Copies of exactly n bytes into buffers the surrounding code already
  zero-fills or terminates (snprintf chunks in rtw_debug.c,
  ParseQualifiedString(), the band/path/sign selectors in
  PHY_ConfigRFWithTxPwrTrackParaFile(), the FW trace handler, the
  "wlan10" ifname, the netlink ring_name): memcpy(). strscpy() would
  reserve one of the n bytes for the terminator and drop the last
  character. ring_name keeps the strncpy() bound of
  MIN(sizeof(ring_name) - 1, nla_len), so the copy never reads past
  the attribute payload; the buffer is zero-initialised.

- Copies bounded by the destination size (old_ifname, crypt.alg,
  mon_ndev->name): strscpy(), which always terminates, so the manual
  dst[size - 1] = 0 lines go away.

The WoWLAN pattern parser copies the last token with a fixed length of
2 even when the token is empty; strncpy() stopped at the terminator,
so bound the memcpy() by strnlen() and zero the 2-byte member first to
keep the padding strncpy() provided.

strscpy() exists since 4.3, so no version guard is needed.

Assisted-by: Claude:claude-fable-5.1
Linux 7.2 added `const u8 *rx_addr` to the remain_on_channel cfg80211
op, so the ops-table initialiser fails with an incompatible pointer
type. Take the argument on 7.2 and newer; the driver has no use for it.

Assisted-by: Claude:claude-fable-5.1
Linux 7.3 changed remain_on_channel() and mgmt_tx() to receive the
cookie as `u64` instead of `u64 *`: cfg80211 now assigns the cookie
itself and expects the driver to report completions with that value.

Keep one local per function (roc_cookie / tx_cookie) that holds the
cookie in use. On 7.3+ it is the value cfg80211 passed in; before 7.3
the driver still generates it and writes it back through the pointer,
because cfg80211 hands in an uninitialised variable and reads it back
to identify the request in later cancel calls.

Based on EvilOlaf/rtl8192eu-linux-driver a236269 and 84c4bfd.

Assisted-by: Claude:claude-fable-5.1
@CGarces
CGarces merged commit c629cc9 into Mange:realtek-4.4.x Sep 6, 2026
10 checks passed
@iav
iav deleted the fix/strncpy-removed-in-7.2 branch September 6, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants