You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we look at what are trying to memset, we'll see that it is program text! Further, if we go stack diving, we'll see that this was actually what was returned from umem_alloc by topo_zalloc. So the question is how did we get this heap corruption. Thankfully, this problem was dead reproducible, so we were able to set UMEM_DEBUG=default and run it. The good news, is that this provides the smoking gun:
So we were trying to free something that is garbage. If we look at the code here, there's a single set of freeing paths that always iterates over the lancfg.ilc_ipv6_nroutes even though not all of them have been initialized. That is problematic, but would have probably led to us trying to free a NULL pointer. That doesn't quite get us here. However, if any other goto out is taken before we initialize ipv6_routes, we'll try to free it and it's an uninitialized pointer on the stack. Even worse, because we assume it's a valid array, that'll wreak havoc. The solution here is to fix the free path to account for what's actually been allocated and what hasn't been. Simply relying on the lancfg isn't sufficient. While it is zeroed initially, there is a bunch that can fail between it being initialized by calling ipmi_lan_get_config() and the actual allocation of the routes.
The text was updated successfully, but these errors were encountered:
Tested by adding IPv6 routes to an IPMI I have control over. It makes fmtopo dump core without the fix, but with the fix it no longer dumps core and behaves like an IPMI with no IPv6 routes.
A user was booting on an HP DL360 Gen 9 and saw that syseventd was crashing on startup. Here was the stack trace:
If we look at what are trying to memset, we'll see that it is program text! Further, if we go stack diving, we'll see that this was actually what was returned from umem_alloc by topo_zalloc. So the question is how did we get this heap corruption. Thankfully, this problem was dead reproducible, so we were able to set UMEM_DEBUG=default and run it. The good news, is that this provides the smoking gun:
So we were trying to free something that is garbage. If we look at the code here, there's a single set of freeing paths that always iterates over the
lancfg.ilc_ipv6_nroutes
even though not all of them have been initialized. That is problematic, but would have probably led to us trying to free a NULL pointer. That doesn't quite get us here. However, if any othergoto out
is taken before we initializeipv6_routes
, we'll try to free it and it's an uninitialized pointer on the stack. Even worse, because we assume it's a valid array, that'll wreak havoc. The solution here is to fix the free path to account for what's actually been allocated and what hasn't been. Simply relying on the lancfg isn't sufficient. While it is zeroed initially, there is a bunch that can fail between it being initialized by callingipmi_lan_get_config()
and the actual allocation of the routes.The text was updated successfully, but these errors were encountered: