In the Linux kernel, the following vulnerability has been resolved:
bonding: fix oops during rmmod
"rmmod bonding" causes an oops ever since commit cc317ea3d927 ("bonding: remove redundant NULL check in debugfs function"). Here are the relevant functions being called:
bondingexit() bonddestroydebugfs() debugfsremoverecursive(bondingdebugroot); bondingdebugroot = NULL; <--------- SET TO NULL HERE bondnetlinkfini() rtnllinkunregister() _rtnllinkunregister() unregisternetdevicemanynotify() bonduninit() bonddebugunregister() (commit removed check for bondingdebugroot == NULL) debugfsremove() simplerecursiveremoval() downwrite() -> OOPS
However, reverting the bad commit does not solve the problem completely because the original code contains a race that could cause the same oops, although it was much less likely to be triggered unintentionally:
CPU1 rmmod bonding bondingexit() bonddestroydebugfs() debugfsremoverecursive(bondingdebug_root);
CPU2 echo -bond0 > /sys/class/net/bondingmasters bonduninit() bonddebugunregister() if (!bondingdebugroot)
CPU1 bondingdebugroot = NULL;
So do NOT revert the bad commit (since the removed checks were racy anyway), and instead change the order of actions taken during module removal. The same oops can also happen if there is an error during module init, so apply the same fix there.