lkml.org 
[lkml]   [2021]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] net: dpaa2-eth: fix use-after-free in dpaa2_eth_remove
On Mon, 15 Nov 2021 11:08:17 +0300 Dan Carpenter wrote:
> > @Dan, is there a smatch checker for straigthforward use after free bugs?
> > Like acessing pointer after free was called? I think, adding
> > free_netdev() to check list might be good idea
> >
> > I've skimmed througth smatch source and didn't find one, so can you,
> > please, point out to it if it exists.
>
> It's check_free_strict.c.
>
> It does cross function analysis but free_netdev() is tricky because it
> doesn't free directly, it just drops the reference count. Also it
> delays freeing in the NETREG_UNREGISTERING path so this check might
> cause false positives?

I'd ignore that path, it's just special casing that's supposed to keep
the driver-visible API sane. Nobody should be touching netdev past
free_netdev(). Actually if you can it'd be interesting to add checks
for using whatever netdev_priv(ndev) returned past free_netdev(ndev).

Most UAFs that come to mind from the past were people doing something
like:

struct my_priv *mine = netdev_priv(ndev);

netdev_unregister(ndev);
free_netdev(ndev);

free(mine->bla); /* UAF, free_netdev() frees the priv */

> I'll add free_netdev() to the list of free
> functions and test it overnight tonight.
>
> register_free_hook("free_netdev", &match_free, 0);

\
 
 \ /
  Last update: 2021-11-16 02:39    [W:0.063 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site