HomeFreeBSD

netlink: fix snl_writer and linear_buffer re-allocation logic

Description

netlink: fix snl_writer and linear_buffer re-allocation logic

  • Use the correct base pointer after re-allocation to avoid buffer overflows.
  • Maintain correct snl_writer.size, which avoids redundant memory allocation, e.g. a need for ~1k bytes may end up with ~32k linear_buffer actually allocated.

This fixes a pfctl regression at least for armv7 after the addrule logic
migration to netlink:

ffbf25951e7b ("pf: convert rule addition to netlink")

The add rule command creates a bigger than default size netlink requests
which triggers the re-allocation logic.

Reviewed by: kp
MFC after: 2 weeks
Differnetial Revision: https://reviews.freebsd.org/D43003

Details

Provenance
igoroAuthored on Dec 12 2023, 6:26 PM
kpCommitted on Dec 12 2023, 8:49 PM
Parents
rG6fa843f6e647: nfsclient: Propagate copyin() errors from nfsm_uiombuf()
Branches
Unknown
Tags
Unknown