When SADB_UPDATE changes the addresses of an SA, key_updateaddresses()
replaces the SA with a clone. For an SA that names an offload interface
it allocated a buffer for the clone's copy of the name, and then called
strncpy() with the arguments swapped. The clone was left with an
uninitialized name, and the name of the old SA was overwritten with the
contents of the new buffer.
Copy the name from the old SA to the new one.
Also, the clone starts as a bcopy() of the old SA, so its natt and
accel_ifname pointers refer to memory owned by the old SA until they are
replaced. If one of the offload allocations failed, the error path freed
that memory, and key_cleansav() freed it again with the last reference
to the old SA. Clear both pointers right after the copy.
Reported by: llm-postcr
Fixes: ef2a572bf6bd ("ipsec_offload: kernel infrastructure")
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")