Message ID | 1354883813-7201-2-git-send-email-luis.henriques@canonical.com |
---|---|
State | New |
Headers | show |
Does userspace have the equivalent of WARN_ON_ONCE() ? This could still be a real log stuffer.
Tim Gardner <tim.gardner@canonical.com> writes: > Does userspace have the equivalent of WARN_ON_ONCE() ? This could still be a > real log stuffer. I don't think syslog has such facility, but if I remember correctly, it does handle a flood of similar messages by merging them together. Cheers, -- Luis
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 2984ffb..60a8e29 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c @@ -727,13 +727,19 @@ int main(void) len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0, addr_p, &addr_l); - if (len < 0 || addr.nl_pid) { + if (len < 0) { syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s", addr.nl_pid, errno, strerror(errno)); close(fd); return -1; } + if (addr.nl_pid) { + syslog(LOG_WARNING, "Received packet from untrusted pid:%u", + addr.nl_pid); + continue; + } + incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data;