mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Ichikawa <masami256@gmail.com>
To: paul@paul-moore.com, eparis@redhat.com
Cc: masami256@gmail.com, linux-audit@redhat.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH] Free skb at error context in auditd_send_unicast_skb().
Date: Tue, 18 Jul 2017 00:50:54 +0900	[thread overview]
Message-ID: <20170717155054.31948-1-masami256@gmail.com> (raw)

I got following memory leak reports by kmemleak.

unreferenced object 0xffff965962fa0600 (size 256):
  comm "auditd", pid 401, jiffies 4294671604 (age 62.331s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffffb8859baa>] kmemleak_alloc+0x4a/0xa0
    [<ffffffffb8238a96>] kmem_cache_alloc_node+0x146/0x1f0
    [<ffffffffb870e52b>] __alloc_skb+0x5b/0x1e0
    [<ffffffffb814fc5c>] audit_make_reply+0x5c/0xd0
    [<ffffffffb815160a>] audit_receive_msg+0xa1a/0xe60
    [<ffffffffb8151aa3>] audit_receive+0x53/0xa0
    [<ffffffffb875e95b>] netlink_unicast+0x18b/0x220
    [<ffffffffb875ecb5>] netlink_sendmsg+0x2c5/0x3c0
    [<ffffffffb8705008>] sock_sendmsg+0x38/0x50
    [<ffffffffb870558f>] SYSC_sendto+0x13f/0x180
    [<ffffffffb870608e>] SyS_sendto+0xe/0x10
    [<ffffffffb8003a57>] do_syscall_64+0x67/0x140
    [<ffffffffb8865ca7>] return_from_SYSCALL_64+0x0/0x6a
    [<ffffffffffffffff>] 0xffffffffffffffff
unreferenced object 0xffff96595a9da600 (size 512):
  comm "auditd", pid 401, jiffies 4294671604 (age 62.331s)
  hex dump (first 32 bytes):
    14 00 00 00 31 05 00 00 00 00 00 00 00 00 00 00  ....1...........
    91 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffffb8859baa>] kmemleak_alloc+0x4a/0xa0
    [<ffffffffb823c8a3>] __kmalloc_node_track_caller+0x233/0x2f0
    [<ffffffffb870d9d1>] __kmalloc_reserve.isra.38+0x31/0x90
    [<ffffffffb870e557>] __alloc_skb+0x87/0x1e0
    [<ffffffffb814fc5c>] audit_make_reply+0x5c/0xd0
    [<ffffffffb815160a>] audit_receive_msg+0xa1a/0xe60
    [<ffffffffb8151aa3>] audit_receive+0x53/0xa0
    [<ffffffffb875e95b>] netlink_unicast+0x18b/0x220
    [<ffffffffb875ecb5>] netlink_sendmsg+0x2c5/0x3c0
    [<ffffffffb8705008>] sock_sendmsg+0x38/0x50
    [<ffffffffb870558f>] SYSC_sendto+0x13f/0x180
    [<ffffffffb870608e>] SyS_sendto+0xe/0x10
    [<ffffffffb8003a57>] do_syscall_64+0x67/0x140
    [<ffffffffb8865ca7>] return_from_SYSCALL_64+0x0/0x6a
    [<ffffffffffffffff>] 0xffffffffffffffff

These skb objects have been allocated in audit_replace().
If some error happened in auditd_send_unicast_skb(), skb is needed
to be freed.

Signed-off-by: Masami Ichikawa <masami256@gmail.com>
---
 kernel/audit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/audit.c b/kernel/audit.c
index 833267bbd80b..789f4cc1f481 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -659,6 +659,7 @@ static int auditd_send_unicast_skb(struct sk_buff *skb)
 err:
 	if (ac && rc == -ECONNREFUSED)
 		auditd_reset(ac);
+	kfree_skb(skb);
 	return rc;
 }
 
-- 
2.13.0

             reply	other threads:[~2017-07-17 15:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 15:50 Masami Ichikawa [this message]
2017-07-18 12:26 ` Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170717155054.31948-1-masami256@gmail.com \
    --to=masami256@gmail.com \
    --cc=eparis@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@paul-moore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®