Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1532949
| From | Richard Guy Briggs <rgb@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] audit: remove the audit freelist |
| Date | 2016-11-30 05:50 +0100 |
| Message-ID | <sJ50d-1gP-5@gated-at.bofh.it> (permalink) |
| References | <sDLOz-5pg-65@gated-at.bofh.it> <sITip-2kT-5@gated-at.bofh.it> <sIUob-311-59@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 2016-11-29 18:24, Florian Westphal wrote:
> Richard Guy Briggs <rgb@redhat.com> wrote:
> > > static void audit_buffer_free(struct audit_buffer *ab)
> > > {
> > > - unsigned long flags;
> > > -
> > > if (!ab)
> > > return;
> > >
> > > kfree_skb(ab->skb);
> > > - spin_lock_irqsave(&audit_freelist_lock, flags);
> > > - if (audit_freelist_count > AUDIT_MAXFREE)
> > > - kfree(ab);
> > > - else {
> > > - audit_freelist_count++;
> > > - list_add(&ab->list, &audit_freelist);
> > > - }
> > > - spin_unlock_irqrestore(&audit_freelist_lock, flags);
> > > + kfree(ab);
> > > }
> [..]
>
> > > nlh = nlmsg_put(ab->skb, 0, 0, type, 0, 0);
> > > if (!nlh)
> > > - goto out_kfree_skb;
> > > + goto err;
> > >
> > > return ab;
> > >
> > > -out_kfree_skb:
> > > - kfree_skb(ab->skb);
> > > - ab->skb = NULL;
> >
> > Why is the kfree_skb() skipped on error from nlmsg_put()? I don't see
> > much risk in nlmsg_put() failing considering the very simple arguments,
> > however the code path is not trivial either.
>
> if nlmsg_put fails we jump to err and ...
>
> > > err:
> > > audit_buffer_free(ab);
> > > return NULL;
>
> ... ab->skb gets free'd by audit_buffer_free() here.
Duh, thank you! It was already redundant in plain sight in your patch.
Sorry for the brain fart. :)
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
- RGB
--
Richard Guy Briggs <rgb@redhat.com>
Kernel Security Engineering, Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH] audit: remove the audit freelist Richard Guy Briggs <rgb@redhat.com> - 2016-11-29 17:20 +0100
Re: [PATCH] audit: remove the audit freelist Florian Westphal <fw@strlen.de> - 2016-11-29 18:30 +0100
Re: [PATCH] audit: remove the audit freelist Richard Guy Briggs <rgb@redhat.com> - 2016-11-30 05:50 +0100
csiph-web