Thread (33 messages) 33 messages, 4 authors, 2016-12-14

Re: [RFC PATCH v3] audit: use proper refcount locking on audit_sock

From: Cong Wang <hidden>
Date: 2016-12-14 06:37:47
Also in: lkml

On Tue, Dec 13, 2016 at 8:00 PM, Richard Guy Briggs [off-list ref] wrote:
On 2016-12-13 16:19, Cong Wang wrote:
quoted
On Tue, Dec 13, 2016 at 7:03 AM, Richard Guy Briggs [off-list ref] wrote:
quoted
@@ -1283,8 +1299,10 @@ static void __net_exit audit_net_exit(struct net *net)
 {
        struct audit_net *aunet = net_generic(net, audit_net_id);
        struct sock *sock = aunet->nlsk;
+       mutex_lock(&audit_cmd_mutex);
        if (sock == audit_sock)
                auditd_reset();
+       mutex_unlock(&audit_cmd_mutex);
This still doesn't look correct to me, b/c here we release the audit_sock
refcnt twice:

1) inside audit_reset()
The audit_reset() refcount decrement corresponds to a setting of
audit_sock only if audit_sock is still non-NULL.
Hmm, thinking about it again, looks like the sock == audit_sock
and audit_sock != NULL checks can guarantee we are safe. So,

Reviewed-by: Cong Wang <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help