On Sat, Nov 13, 2021 at 08:20:13PM +0300, Pavel Skripkin wrote: > Access to netdev after free_netdev() will cause use-after-free bug. > Move debug log before free_netdev() call to avoid it. > > Cc: stable@xxxxxxxxxxxxxxx # v4.19+ > Signed-off-by: Pavel Skripkin <paskripkin@xxxxxxxxx> > --- > > Note about Fixes: tag. The commit introduced it was before this driver > was moved out from staging. I guess, Fixes tag cannot be used here. > Please, let me know if I am wrong. > You should still use the Fixes tag. > Cc: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > > @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'll add free_netdev() to the list of free functions and test it overnight tonight. register_free_hook("free_netdev", &match_free, 0); regards, dan carpenter