Message ID | 20240729122818.947756-1-wintera@linux.ibm.com (mailing list archive) |
---|---|
State | Accepted |
Commit | f558120cd709682b739207b48cf7479fd9568431 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net/iucv: fix use after free in iucv_sock_close() | expand |
Hello: This patch was applied to netdev/net.git (main) by Paolo Abeni <pabeni@redhat.com>: On Mon, 29 Jul 2024 14:28:16 +0200 you wrote: > iucv_sever_path() is called from process context and from bh context. > iucv->path is used as indicator whether somebody else is taking care of > severing the path (or it is already removed / never existed). > This needs to be done with atomic compare and swap, otherwise there is a > small window where iucv_sock_close() will try to work with a path that has > already been severed and freed by iucv_callback_connrej() called by > iucv_tasklet_fn(). > > [...] Here is the summary with links: - [net] net/iucv: fix use after free in iucv_sock_close() https://git.kernel.org/netdev/net/c/f558120cd709 You are awesome, thank you!
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index c3b0b610b0aa..c00323fa9eb6 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -335,8 +335,8 @@ static void iucv_sever_path(struct sock *sk, int with_user_data) struct iucv_sock *iucv = iucv_sk(sk); struct iucv_path *path = iucv->path; - if (iucv->path) { - iucv->path = NULL; + /* Whoever resets the path pointer, must sever and free it. */ + if (xchg(&iucv->path, NULL)) { if (with_user_data) { low_nmcpy(user_data, iucv->src_name); high_nmcpy(user_data, iucv->dst_name);