diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2023-05-03 18:11:35 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-05-30 12:38:38 +0100 |
commit | c84733a53fe01f9387d3a1ab42c1f3a7c0d56e93 (patch) | |
tree | adbe238a4ddbd0bc5edfd75e1f76fcf8889c5e44 | |
parent | 00751a8a9b9f81ed819bef25984d1c5ed87171b8 (diff) | |
download | linux-stable-c84733a53fe01f9387d3a1ab42c1f3a7c0d56e93.tar.gz linux-stable-c84733a53fe01f9387d3a1ab42c1f3a7c0d56e93.tar.bz2 linux-stable-c84733a53fe01f9387d3a1ab42c1f3a7c0d56e93.zip |
xen/pvcalls-back: fix double frees with pvcalls_new_active_socket()
commit 8fafac202d18230bb9926bda48e563fd2cce2a4f upstream.
In the pvcalls_new_active_socket() function, most error paths call
pvcalls_back_release_active(fedata->dev, fedata, map) which calls
sock_release() on "sock". The bug is that the caller also frees sock.
Fix this by making every error path in pvcalls_new_active_socket()
release the sock, and don't free it in the caller.
Fixes: 5db4d286a8ef ("xen/pvcalls: implement connect command")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/e5f98dc2-0305-491f-a860-71bbd1398a2f@kili.mountain
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/xen/pvcalls-back.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c index b13d03aba791..e472ed057c17 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -338,8 +338,10 @@ static struct sock_mapping *pvcalls_new_active_socket( void *page; map = kzalloc(sizeof(*map), GFP_KERNEL); - if (map == NULL) + if (map == NULL) { + sock_release(sock); return NULL; + } map->fedata = fedata; map->sock = sock; @@ -431,10 +433,8 @@ static int pvcalls_back_connect(struct xenbus_device *dev, req->u.connect.ref, req->u.connect.evtchn, sock); - if (!map) { + if (!map) ret = -EFAULT; - sock_release(sock); - } out: rsp = RING_GET_RESPONSE(&fedata->ring, fedata->ring.rsp_prod_pvt++); @@ -575,7 +575,6 @@ static void __pvcalls_back_accept(struct work_struct *work) sock); if (!map) { ret = -EFAULT; - sock_release(sock); goto out_error; } |