diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-11-25 00:58:33 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-11-25 01:00:11 +0100 |
commit | 3ce73c1552cee7b7ad8307e01368cc2655d94d6c (patch) | |
tree | c11bbb86bbf01f0f0aec59b0f91553a56afb0fff | |
parent | 201f28bd1d0a5e75e572e21f13dceaac0a5284e9 (diff) | |
download | neard-3ce73c1552cee7b7ad8307e01368cc2655d94d6c.tar.gz neard-3ce73c1552cee7b7ad8307e01368cc2655d94d6c.tar.bz2 neard-3ce73c1552cee7b7ad8307e01368cc2655d94d6c.zip |
netlink: Check for netlink message sender PID
If PID is not 0 (i.e. this is not the kernel sending us the message),
the message is skipped.
Code review done by Sebastian Krahmer <krahmer@suse.de>.
-rw-r--r-- | src/netlink.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/netlink.c b/src/netlink.c index 65e42a8..f34dbce 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -676,10 +676,17 @@ static int nfc_netlink_event_tm_deactivated(struct genlmsghdr *gnlh) static int nfc_netlink_event(struct nl_msg *n, void *arg) { + struct sockaddr_nl *src = nlmsg_get_src(n); struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(n)); DBG("event 0x%x", gnlh->cmd); + if (src->nl_pid) { + near_error("WARNING: Wrong netlink message sender %d", + src->nl_pid); + return NL_SKIP; + } + switch (gnlh->cmd) { case NFC_EVENT_TARGETS_FOUND: DBG("Targets found"); |