[Drbd-dev] [PATCH] drbd: dynamically allocate shash descriptor
Arnd Bergmann
arnd at arndb.de
Mon Jun 17 22:38:49 CEST 2019
On Mon, Jun 17, 2019 at 4:36 PM Roland Kammerer
<roland.kammerer at linbit.com> wrote:
> > @@ -5572,6 +5579,7 @@ static int drbd_do_auth(struct drbd_connection *connection)
> > kfree(response);
> > kfree(right_response);
> > shash_desc_zero(desc);
> > + kfree(desc);
> >
> > return rv;
> > }
>
> Hi Arnd,
>
> are you sure your cleanup is okay?
>
> > shash_desc_zero(desc);
> > + kfree(desc);
>
> You shash_desc_zero() a potential NULL pointer. memzero_expicit() in the
> function then dereferences it:
>
> memzero_explicit(desc,
> sizeof(*desc) + crypto_shash_descsize(desc->tfm));
>
> Maybe some if (desc) guard?
Good catch. I guess kzfree() would have been the right thing to call.
Arnd
More information about the drbd-dev
mailing list