Skip to contentSkip to conversation

audit netlink multicast code

DISCUSSION Zbigniew Jędrzejewski-Szmek 1 participant 1 message Aug 22, 2014 2 messages not in the archive

lore
Share & tools
lore
#2 lore raw
In reply to a message not in the archive

Hi,

it seems that current kernel code sets the nlmsg_len field in multicast audit netlink messages to a fixed size (16 bytes), and does not include the size of the payload. I'm forwarding the message from Richard Briggs below in case someone else runs into the same issue.

Quoted 14 lines · Richard Guy Briggs
Quoted 10 lines · Zbigniew Jędrzejewski-Szmek

I was looking at adding support in journald for reading audit multicast
messages, but there's something I don't quite understand. Looking at your
example code in http://people.redhat.com/rbriggs/audit-multicast-listen/audit-multicast-listen.c,
it seems that nlmsg_len field in the received messages is supposed to contain
the length of the header + payload, but it is always set to the size of the header only, i.e. 16. The example program works, because the printf
format specifies the minimum width, not "precision", so it simply prints
out the payload until the first zero byte. This isn't too much of a problem,
but precludes the use of recvmmsg, iiuc?

Quoted 2 lines

(gdb) p *(struct nlmsghdr*)nlh
$14 = {nlmsg_len = 16, nlmsg_type = 1100, nlmsg_flags = 0, nlmsg_seq = 0, nlmsg_pid = 9910}

Quoted 10 lines

Interesting. Ok, I thought I had traced down the code to verify that nlh->nlmsg_len was properly set by each step before audit_log_end(), but it appears the only time it would have been done was at audit_buffer_alloc() inside audit_log_start() and never updated after. It should arguably be done in audit_log_vformat(), but would be more efficient in audit_log_end(). I'll fix it in the latter.

Thanks for tracking this down!

Quoted 1 line

This is with kernel 3.16.1-300.playground.fc21.x86_64.

Zbyszek

--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit