[PATCH] KEYS: trusted: fix a couple error pointer dereferences

Serge E. Hallyn serge at hallyn.com
Fri Apr 16 14:08:26 UTC 2021


On Fri, Apr 16, 2021 at 06:15:58PM +0530, Sumit Garg wrote:
> Hi Serge,
> 
> On Wed, 14 Apr 2021 at 19:37, Serge E. Hallyn <serge at hallyn.com> wrote:
> >
> > On Wed, Apr 14, 2021 at 09:08:58AM +0300, Dan Carpenter wrote:
> > > If registering "reg_shm_out" fails, then it is an error pointer and the
> > > error handling will call tee_shm_free(reg_shm_out) which leads to an
> > > error pointer dereference and an Oops.
> > >
> > > I've re-arranged it so we only free things that have been allocated
> > > successfully.
> > >
> > > Fixes: 6dd95e650c8a ("KEYS: trusted: Introduce TEE based Trusted Keys")
> > > Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
> > > ---
> > >  security/keys/trusted-keys/trusted_tee.c | 24 ++++++++++--------------
> > >  1 file changed, 10 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/security/keys/trusted-keys/trusted_tee.c b/security/keys/trusted-keys/trusted_tee.c
> > > index 2ce66c199e1d..45f96f6ed673 100644
> > > --- a/security/keys/trusted-keys/trusted_tee.c
> > > +++ b/security/keys/trusted-keys/trusted_tee.c
> > > @@ -65,7 +65,7 @@ static int trusted_tee_seal(struct trusted_key_payload *p, char *datablob)
> > >       int ret;
> > >       struct tee_ioctl_invoke_arg inv_arg;
> > >       struct tee_param param[4];
> > > -     struct tee_shm *reg_shm_in = NULL, *reg_shm_out = NULL;
> > > +     struct tee_shm *reg_shm_in, *reg_shm_out;
> >
> > I don't have this file (trusted_tee.c) in my tree and there's no lore
> > link here to previous what threads this depends on.  Based on the
> > context I can't verify that reg_shm_in will always be initialized
> > before you get to the free_shm_in label.
> >
> 
> You can find trusted_tee.c here [1].
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/tree/security/keys/trusted-keys/trusted_tee.c

Thanks.  Looks good then :)



More information about the Linux-security-module-archive mailing list