Re: [PATCH 1/1] file capabilities: get_file_caps cleanups

From: Serge E. Hallyn
Date: Thu Jun 28 2007 - 12:49:41 EST


Quoting Andrew Morgan (morgan@xxxxxxxxxx):
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Serge E. Hallyn wrote:
> >>>> kfree(dcaps);
> > Move this two lines down (rc defaults to 0 in goto above):
> > from here-->
> >>>> +clear_caps:
> >>>> + if (rc) {
> > to here-->
> >
> >> Hmm? But if we succeeded we still want to free dcaps if we
> >> kmalloc()'d it.
>
> I wasn't clear enough... Let me try again with different words.
>
> If you look at your patch, you will see that the only use of the label
> 'clear_caps:' is as a jump target from a location in which rc=0. As
> such, you will *not* clear the bprm->cap_* sets... This is the reverse
> of what you intended to do.
>
> You need to put the jump target 'inside' the 'if (rc) { <-here ... }'.

Oops! Good catch, thanks. New patch follows: