[ARCHIVE DEBUG 09/13] netlink_debug: instrument timing of calls by init/systemd or audit_pid
Richard Guy Briggs
rgb at redhat.com
Thu Oct 22 18:58:55 UTC 2015
Debug the timing and stalling of calls to netlink_sendmsg() for
processes we care about with any error return values.
Signed-off-by: Richard Guy Briggs <rgb at redhat.com>
---
net/netlink/af_netlink.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 05919bf..ba5eedf 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2256,6 +2256,8 @@ static void netlink_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb)
put_cmsg(msg, SOL_NETLINK, NETLINK_PKTINFO, sizeof(info), &info);
}
+extern int audit_pid;
+
static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
struct msghdr *msg, size_t len)
{
@@ -2268,10 +2270,19 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
int err;
struct scm_cookie scm;
u32 netlink_skb_flags = 0;
+ //unsigned long trytime = 0;
+ unsigned long trytime = jiffies;
+ pid_t audit_pid_cached = audit_pid;
+ int pr;
if (msg->msg_flags&MSG_OOB)
return -EOPNOTSUPP;
+ if (current->tgid == 1 || (audit_pid && audit_pid == current->tgid))
+ //pr_warn("( %lu )netlink_sendmsg apid=%d pid=%d(%s)\n",
+ //trytime = jiffies, audit_pid, current->pid, current->comm);
+ pr = 1;
+
err = scm_send(sock, msg, &scm, true);
if (err < 0)
return err;
@@ -2343,6 +2354,11 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
out:
scm_destroy(&scm);
+
+ if (pr || current->tgid == 1 || (audit_pid && audit_pid == current->tgid))
+ pr_warn("( %lu %lu )netlink_sendmsg-exit apid=%d apid-old=%d pid=%d(%s) err=%d\n",
+ trytime, jiffies - trytime, audit_pid, audit_pid_cached, current->pid, current->comm, err);
+
return err;
}
--
1.7.1
More information about the Linux-audit
mailing list