All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libmnl 0/5] libmnl: fix memory safety issues found by static analysis
@ 2026-11-06 19:18 Florian Stosse
  2026-11-06 19:18 ` [PATCH libmnl 1/5] nlmsg: fix overlapping copy in mnl_nlmsg_batch_reset() Florian Stosse
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Florian Stosse @ 2026-11-06 19:18 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Pablo Neira Ayuso, Florian Stosse

Hi,

This series fixes five bugs found while analysing libmnl with Frama-C
(Eva, WP and E-ACSL-instrumented fuzzing). Each one was then confirmed
on current master with a small standalone program under ASan/UBSan.

None of them can be triggered by netlink data received from the kernel
through the usual parsing path. They all need a caller that uses the
API in a less common, but valid or near-valid, way, so I am sending
them as ordinary fixes.

Patch 1 is the most relevant one. When the message that overflowed a
batch is larger than the messages already in it, mnl_nlmsg_batch_reset()
memcpy()s it onto an overlapping range and then reads nlmsg_len back
from the overwritten location. With limit = 100, a 20-byte message
followed by a 92-byte one leaves mnl_nlmsg_batch_size() returning
0x97969594 on glibc/x86-64, and the next mnl_nlmsg_batch_next() uses
b->buf + 0x97969594.

Patches 2 and 3 fix out-of-bounds accesses on unusual input:
- The *_check() builders compare the unaligned nlmsg_len against
  buflen while the attribute is written at MNL_ALIGN(nlmsg_len), so
  they can write up to 3 bytes past the buffer.
- mnl_attr_get_payload_len() wraps for nla_len < 4, which makes
  mnl_attr_parse_nested() read past the end of the nest.

Patches 4 and 5 are minor:
- mnl_nlmsg_fprintf() can read up to 3 bytes past an unaligned message.
- mnl_cb_error() can compute -INT_MIN.

I can send the reproducers if they are useful.

Thanks,
Florian

Florian Stosse (5):
  nlmsg: fix overlapping copy in mnl_nlmsg_batch_reset()
  attr: account for alignment padding in the *_check() builders
  attr: do not wrap mnl_attr_get_payload_len() for nla_len < 4
  nlmsg: do not read past nlmsg_len in mnl_nlmsg_fprintf()
  callback: avoid signed overflow on INT_MIN error code

 src/attr.c     | 7 +++++--
 src/callback.c | 5 ++++-
 src/nlmsg.c    | 8 +++++---
 3 files changed, 14 insertions(+), 6 deletions(-)

-- 
2.56.0.windows.4


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-13 11:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 19:18 [PATCH libmnl 0/5] libmnl: fix memory safety issues found by static analysis Florian Stosse
2026-11-06 19:18 ` [PATCH libmnl 1/5] nlmsg: fix overlapping copy in mnl_nlmsg_batch_reset() Florian Stosse
2026-11-10  0:51   ` Pablo Neira Ayuso
2026-11-06 19:18 ` [PATCH libmnl 2/5] attr: account for alignment padding in the *_check() builders Florian Stosse
2026-11-06 19:18 ` [PATCH libmnl 3/5] attr: do not wrap mnl_attr_get_payload_len() for nla_len < 4 Florian Stosse
2026-11-06 19:18 ` [PATCH libmnl 4/5] nlmsg: do not read past nlmsg_len in mnl_nlmsg_fprintf() Florian Stosse
2026-11-13 10:46   ` Pablo Neira Ayuso
2026-11-06 19:18 ` [PATCH libmnl 5/5] callback: avoid signed overflow on INT_MIN error code Florian Stosse
2026-11-13 11:05   ` Pablo Neira Ayuso
2026-11-13 11:47 ` [PATCH libmnl 0/5] libmnl: fix memory safety issues found by static analysis Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.