Re: [PATCH] net: dpaa2-eth: fix use-after-free in dpaa2_eth_remove

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux