From nobody Mon Nov 23 22:28:43 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794315017; b=QcSIeYKkJvnxQAeIb5CIOTg1T0dwKNRJbJP4opnBNiiNa/lEBkwFKIb8SVmk4SLfb9+L 0+9BkSA4OU/MFzpmO6jIsKJmIUy52tuDdFBKfpoOv1xIdAwWqWi6eTiSHev/9JAmPiYji lhlBmwKsMgo0trGSnake7vrHNomZ2QXT5IDKS2BXylQitCMVWQ7pSyHR0eBxS9bB6OoF8 3w7pMpOD22uo+XjaH+DJbV1LYT382Z/F2EQ9Gc6OjaTCM5Qp87pbNLUZRRIFbKIwZX6kL zi5mGf/cx4Fjr2eMptFAAHN8cx5mBmqc1ySX0qpC1k0blxWeYl8nN/7Tt7xdybMsGyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794315017; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=0zzG+r0Nc7NWPddTHndjZ7UDJBk8q3WCOKQ3/5tvZ+I=; b=P7OjrgvT/nx5BW8t9l7GJ1khQ3/nMZ0nmp/2zVKInI1b1xP4J9aTKTCN+ZJ1OKUo1EyJ 9gCTFOf2Gt9oIXby4j5VKQyeERE47/S6lPThIdOFZJZRGw03glzl8QOI9W7hRf+U9/HJc s2PK5YZVkdAX0Bs56seqV0fHzMPIVpYX6MiFk2H/Tt/l9O+IstHnCBKLTIiLEqMs9tEHH haNfYoE/t3xylQBNEo9t8adlp9xYFGgpQMwaR7tlt6+3jzhJlV/53ZV/hEO5ao8UulL/0 n96PVoRBq/Q5nJMpyVj5fViV8M8OwK99JI+PptDyFTPbMRUHy3xxhpZck+Q1afZh3TQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail header.from=isslab.korea.ac.kr; spf=none smtp.mailfrom=isslab.korea.ac.kr; dkim=pass header.d=isslab-korea-ac-kr.20260707.gappssmtp.com header.i=@isslab-korea-ac-kr.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=aLSXYx5I; arc=none smtp.remote-ip=74.125.82.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C886606A332 for ; Tue, 10 Nov 2026 12:50:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3C886606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=isslab.korea.ac.kr Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=isslab.korea.ac.kr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=isslab-korea-ac-kr.20260707.gappssmtp.com header.i=@isslab-korea-ac-kr.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=aLSXYx5I Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1b3b4bcbfc9so1842202c88.1 for ; Tue, 10 Nov 2026 04:50:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isslab-korea-ac-kr.20260707.gappssmtp.com; s=20260707; t=1794315015; x=1794919815; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0zzG+r0Nc7NWPddTHndjZ7UDJBk8q3WCOKQ3/5tvZ+I=; b=aLSXYx5IE7s3+I/A09i7uWy0l/SSW+CBdZn/OaVlU6HaCGRt13AWe7g7sv9g2xBG6F AvDvwNYSY7oAJVZypDcAMPNcdWnGAOEF+u+j29VqzreY106VVduBcS6NxU8QdVhl+QiS NomtotTmZEGZXTMZvcenvnTx3ZQIZiL/q0OctCAXjEqKqRGp3/UxMYPaRc3LNOiCzuFX rnmwaVS3BuS4RHh4Y8NaHa0cAS0knvaWs5U6lhMZx7IBFjm3hnC0i3psdUlLWQrwB6ix DY8Wwv1Q+uwirBTc2Rnk+DNZQ806BlSxXKGTvU5/PP3G/n/T5mtnqHNailmymMkuRHAi 6RZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794315015; x=1794919815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0zzG+r0Nc7NWPddTHndjZ7UDJBk8q3WCOKQ3/5tvZ+I=; b=NI508X4pjzQG6Y/hAzClofChuF7ekLOY3qrS4N7soidydve0wQBf2AM8yfsYPd9O5n 4KSFXvEi6IZxyeQ9ecwiibgTqeL5pGzbEDlP2UDcOt4z2+Blj/e48HgekjbqlM0r8KYO em/3eI5RdBPKLEHj8nOAsMdJwR6W52L09qo4wo8Wv/RP54o6Bp0m3VWB/X6UFwWPjdfl eBh4ZcoyZ47r6mgzvME9LAYntrp5eLYaN+L5oXSyReMYP+3fZmLB/s/xJpCf7ptkBU2O jbw8TwJgYjU7+iERBWz7TU3llCP6+b78Tw88HZnVOp4uKs+RW9QJs6NVzNraGySq4Ym+ 3MOg== X-Forwarded-Encrypted: i=1; AL+hErGURqOUHh13W/u7724b0MvHtHnbVjuam8wKgiI63iHmAfcMvSypWnanYwAfTvsmLbvUUS9P9uuX8DZI30s=@vger.kernel.org X-Gm-Message-State: APuU4Z8Erm7Q4LiyrR3H//pnH3szv5m47DPh4aZOsA8X4HgY0AN6LXSh QTZbx80h5E3VwjVc8cf2Qzib+rGfvBJBx63lrzkDpDTKkyU/OzBQv6u97uiYNFSGAkTqMR0pg4A 0DSSIpP8= X-Gm-Gg: AYBFou0+++/NJnAyNqeez619+RF/VFzEsaRa/12qmvBnMqaBEc9G/eTYHjWgdiVCYuJ eeajzorWEwnH7jM1DhrGS0zs/la1mTOjP641VkfaDnVc2WdSwdFNpPn91dI8K3jCpVqV7jwbDUk gyu8FCeKBRdWuPcoxW0Qxx34dCRk7aWOK4YSw0bTIPnLA1VQNtGpnvD+KYeQ5/o89DtGE/FxhDs IBbfxqqPT5r3iN+rO+y57aFymIk5aQ8OHzi5sJSENJRdfAT4LaeRkB68sygJRu2kBrc/R7hsMrT ipTGs1ucVcRuwt+RfL8QiEIH8/EXmAVmogv9Wm/9e2nfkgzCo/eGboPyruNP382O0tsJykKkJrr FbcjSvCfAt3wEMutf6nrsZky5WBkqB0ZaJ7QRdhmfNR9QcWqSpWmVxkzdSdnMXmL+8x2fQk+0uw Xsz+AR7fDCX12MhwGs3Gub4UER+vz/829pn6mcJ7ocPbHB9RKqRmK9pZHnYt8DD17EBSY/vjPq/ KVkggmndEviI9xFsZ4xesLNezsWkcyFJSaWOFdIUlXVubycuoXifJyMbqLpw6CYO58NAl2XCE2G k9ZUGsI/zvJ6VmlPFnq0MSvMEbuLruRjlLO0LODA7raP9HheKP4D74ApAZTL16FrgTai9ZY5BF1 ahv621zBlJ6KrU3YLLfQKN5iQt5mlTAemgE8bt1LK9plNV9/tiItUlS1Of5c= X-Received: by 2002:a05:701b:465c:b0:1b3:a8a3:c6de with SMTP id a92af1059eb24-1b3b5e65237mr3442597c88.5.1794315014837; Tue, 10 Nov 2026 04:50:14 -0800 (PST) Received: from yhlee-960QFG.Davolink ([2406:5900:1044:110c:88e2:4271:a9b8:cc50]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b3b5b79649sm7614830c88.21.2026.11.10.04.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 04:50:14 -0800 (PST) From: Yehyeong Lee To: jgross@suse.com, sstabellini@kernel.org Cc: oleksandr_tyshchenko@epam.com, boris.ostrovsky@oracle.com, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/2] xen/pvcalls: unwind pvcalls_new_active_socket() step by step Date: Tue, 10 Nov 2026 21:50:01 +0900 Message-ID: <20261110125002.46683-2-yhlee@isslab.korea.ac.kr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261110125002.46683-1-yhlee@isslab.korea.ac.kr> References: <20261110125002.46683-1-yhlee@isslab.korea.ac.kr> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Every error path in pvcalls_new_active_socket() jumps to one shared label that does list_del(&map->list) and then hands map to pvcalls_back_release_active(). But map comes from kzalloc() and its list_head is only published at the very end of the function, after the last of those jumps: down(&fedata->socket_lock); list_add_tail(&map->list, &fedata->socket_mappings); up(&fedata->socket_lock); so on the error path map->list is still {NULL, NULL} and __list_del() writes through a NULL pointer. A frontend gets there with one value it owns: the ring_order field of the page it granted. Anything above MAX_RING_ORDER takes the second goto, and nothing else in the function has run by then. The result is an oops in whichever context handled the request - the pvcalls-back threaded IRQ handler for PVCALLS_CONNECT, mappass->wq for PVCALLS_ACCEPT - and because it happens after down(&fedata->socket_lock) that semaphore is never released, so every later operation on the frontend blocks on it and the backend never completes backend_disconnect(). (With CONFIG_DEBUG_LIST the list_del() only reports and returns, and pvcalls_back_release_active() then runs on a map whose irq is still 0 and whose bytes, ioworker.wq and saved_data_ready are all NULL.) A frontend asking for ring_order 5, on a dom0 built with KASAN (the request was issued by a test-only change to the frontend): [ 133.728877] pvcalls_new_active_socket frontend requested ring_order 5, w= hich is > MAX (4) [ 133.732868] Oops: general protection fault, probably for non-canonical a= ddress 0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI [ 133.737910] KASAN: null-ptr-deref in range [0x0000000000000008-0x0000000= 00000000f] [ 133.741666] CPU: 0 UID: 0 PID: 133 Comm: irq/39-pvcalls- Not tainted 7.3= .0-kCTLblk2-15482-g21a7f44fd076-dirty #1 PREEMPT(full) [ 133.746986] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.1= 6.3-debian-1.16.3-2 04/01/2014 [ 133.751512] RIP: 0010:pvcalls_new_active_socket+0x821/0xb90 [ 133.754237] Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 f6 01 00 00 48 = 8d 79 08 4c 8b 6b 08 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80= > 3c 02 00 0f 85 14 02 00 00 4c 89 ea 4c 89 69 08 48 b8 00 00 00 [ 133.763126] RSP: 0018:ffffc900004afb38 EFLAGS: 00010202 [ 133.765861] RAX: dffffc0000000000 RBX: ffff88810886c900 RCX: 00000000000= 00000 [ 133.769348] RDX: 0000000000000001 RSI: 0000000000000246 RDI: 00000000000= 00008 [ 133.772787] RBP: 1ffff92000095f6b R08: 0000000000000001 R09: fffff520000= 95f58 [ 133.776260] R10: 0000000000000003 R11: ffff888100077320 R12: ffff8881085= 8b410 [ 133.779823] R13: 0000000000000000 R14: ffff88810858b460 R15: ffff8881085= 8b400 [ 133.783382] FS: 0000000000000000(0000) GS:ffff8881b034c000(0000) knlGS:= 0000000000000000 [ 133.787351] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 133.790308] CR2: 00000000006042c0 CR3: 0000000108400001 CR4: 00000000007= 70ef0 [ 133.793822] PKRU: 55555554 [ 133.795347] Call Trace: [ 133.796778] [ 133.798082] ? __pfx_pvcalls_new_active_socket+0x10/0x10 [ 133.800801] ? security_socket_post_create+0x4d/0x60 [ 133.803275] ? release_sock+0x1a/0x1d0 [ 133.805182] pvcalls_back_event+0x1b09/0x23e0 [ 133.807431] ? __pfx_pvcalls_back_event+0x10/0x10 [ 133.809814] ? __pfx__raw_spin_lock_irqsave+0x10/0x10 [ 133.812251] ? __pfx_pvcalls_back_event+0x10/0x10 [ 133.814554] irq_thread_fn+0x86/0x150 [ 133.816468] irq_thread+0x2da/0x580 [ 133.818363] ? __pfx_irq_thread_fn+0x10/0x10 [ 133.820586] ? __pfx_irq_thread+0x10/0x10 [ 133.822670] ? __kthread_parkme+0x88/0x170 [ 133.824803] ? __pfx_irq_thread+0x10/0x10 [ 133.827153] ? __pfx_irq_thread+0x10/0x10 [ 133.829304] kthread+0x2c8/0x3b0 [ 133.831176] ? recalc_sigpending+0x15c/0x1e0 [ 133.833570] ? __pfx_kthread+0x10/0x10 [ 133.835572] ret_from_fork+0x373/0x5b0 [ 133.837581] ? __pfx_ret_from_fork+0x10/0x10 [ 133.839978] ? __switch_to+0x3c4/0xb40 [ 133.841984] ? __pfx_kthread+0x10/0x10 [ 133.843970] ret_from_fork_asm+0x1a/0x30 [ 133.846031] [ 133.847420] Modules linked in: [ 133.849240] ---[ end trace 0000000000000000 ]--- Give each failure its own label, so that only resources that were actually acquired are released and the list the map was never added to is left alone. The map is not published anywhere at that point, so the error path needs no socket_lock at all. sock_release() stays in the callee on every error path, the way commit 8fafac202d18 ("xen/pvcalls-back: fix double frees with pvcalls_new_a= ctive_socket()") arranged it. Fixes: 5db4d286a8ef ("xen/pvcalls: implement connect command") Cc: stable@vger.kernel.org Reviewed-by: Stefano Stabellini Signed-off-by: Yehyeong Lee --- v2: no change (Reviewed-by added). v1: https://lore.kernel.org/all/2026110= 9122324.30134-1-yhlee@isslab.korea.ac.kr/ drivers/xen/pvcalls-back.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c index ba62651a7f338b..dcefa91a40cd05 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -337,7 +337,7 @@ static struct sock_mapping *pvcalls_new_active_socket( =20 ret =3D xenbus_map_ring_valloc(fedata->dev, &ref, 1, &page); if (ret < 0) - goto out; + goto out_map; map->ring =3D page; map->ring_order =3D map->ring->ring_order; /* first read the order, then map the data ring */ @@ -345,19 +345,19 @@ static struct sock_mapping *pvcalls_new_active_socket( if (map->ring_order > MAX_RING_ORDER) { pr_warn("%s frontend requested ring_order %u, which is > MAX (%u)\n", __func__, map->ring_order, MAX_RING_ORDER); - goto out; + goto out_unmap_ring; } ret =3D xenbus_map_ring_valloc(fedata->dev, map->ring->ref, (1 << map->ring_order), &page); if (ret < 0) - goto out; + goto out_unmap_ring; map->bytes =3D page; =20 ret =3D bind_interdomain_evtchn_to_irqhandler_lateeoi( fedata->dev, evtchn, pvcalls_back_conn_event, 0, "pvcalls-backend", map); if (ret < 0) - goto out; + goto out_unmap_bytes; map->irq =3D ret; =20 map->data.in =3D map->bytes; @@ -365,7 +365,7 @@ static struct sock_mapping *pvcalls_new_active_socket( =20 map->ioworker.wq =3D alloc_ordered_workqueue("pvcalls_io", 0); if (!map->ioworker.wq) - goto out; + goto out_unbind; atomic_set(&map->io, 1); INIT_WORK(&map->ioworker.register_work, pvcalls_back_ioworker); =20 @@ -381,11 +381,16 @@ static struct sock_mapping *pvcalls_new_active_socket( write_unlock_bh(&map->sock->sk->sk_callback_lock); =20 return map; -out: - down(&fedata->socket_lock); - list_del(&map->list); - pvcalls_back_release_active(fedata->dev, fedata, map); - up(&fedata->socket_lock); + +out_unbind: + unbind_from_irqhandler(map->irq, map); +out_unmap_bytes: + xenbus_unmap_ring_vfree(fedata->dev, map->bytes); +out_unmap_ring: + xenbus_unmap_ring_vfree(fedata->dev, (void *)map->ring); +out_map: + sock_release(sock); + kfree(map); return NULL; } =20 --=20 2.43.0 From nobody Mon Nov 23 22:28:43 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794315018; b=izZnOIWc7sc1+U8j7w3/tUWCXfoh5qEEALcI2OjNdBvmI9CF4BIe81I1mdyizkxaiVxk IPx5TkJrTs0AFZuyaXyRjjFFsCOj6bWDb+syOIK0DjJGOTguDS5HGdTHMickLLXPOJXIV ADcyBxQRH7kV3q0ANWOrwzc5dU/qAKGSRaqaR6yC0rV3jyQUf+MgnLKz7QrKQ/XLXvu3r 6XMHF3u9hchvNyEPn+ZnqQy+1ki2mvtQA47uAGFRFowYIFQCgjuvZ2BCUSNLXnB2EZLLR Wa+JHV+PxqlM/WCTfCN94SLFsP/3qCIz5gAXt7Fy3nEw9OiWXzGNn8ktN7pAow1Tvkg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794315018; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=hIqePvJF9vqtDiaaoJWj4mMGLwExY1SZs6wpgpJb2hI=; b=YDZuFbivHFUAiKT3I617z/nTOf7lSqb9vbfAkAFzZGNhmWpf9t/PazkyGMxXZVujfURx 1QnoqhTXn09LSjyL/xqBliCsWb/dgKcAC5JAibXzw+5IhnAqH+2lpCWa8ak7qc2P9nP21 igQDrqkhb3Qxnnvsd0gi8lblf+9aaniCJ9GLLhGRUteiKE6Vcf1jv5zrseRka0U/9HUPQ lEbelsTic+Il4m0NI2QF5AJ26ugon1x1Jcs066xFBYGKqM7kyTzTJ7XL6FHstvZmOQ3iD vUYLqll0KeJb3qpeZMFeQE3Uhgef4hOYtvcErUC/ZaVe4c/0w6EHar+/pDUAfw1qK5Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail header.from=isslab.korea.ac.kr; spf=none smtp.mailfrom=isslab.korea.ac.kr; dkim=pass header.d=isslab-korea-ac-kr.20260707.gappssmtp.com header.i=@isslab-korea-ac-kr.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=IotGoqC+; arc=none smtp.remote-ip=74.125.82.41 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EDF560A2603 for ; Tue, 10 Nov 2026 12:50:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5EDF560A2603 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=isslab.korea.ac.kr Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=isslab.korea.ac.kr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=isslab-korea-ac-kr.20260707.gappssmtp.com header.i=@isslab-korea-ac-kr.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=IotGoqC+ Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-170135e43c7so2998890c88.0 for ; Tue, 10 Nov 2026 04:50:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isslab-korea-ac-kr.20260707.gappssmtp.com; s=20260707; t=1794315017; x=1794919817; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hIqePvJF9vqtDiaaoJWj4mMGLwExY1SZs6wpgpJb2hI=; b=IotGoqC+GmG2HPnZoenFwtMfa8+hS1ddNGLnLGzjf0QcmNQlfehryt8YZELOvNqyAU EIPz4rdTVIWYGt5P7G2457HW5qSQ4cEYKOjXx9BoxkllcA8luwYoXt71Zb0rJ+EMa8Of ZgZxSbx0a5NJOg08UEhgDJU5fsEVrYdShGgK4dSNbJSbLiLHyMvJ2PhDmyicgGcHOwCg /ofvq9VB3632C6AIp8UbNl2Wossa3ScvUZIsuJm8WWgIVaAqOCWv8LW5sXahzDJoxdzf RSMCElxmOedIRXNcObQaefNGpbPh2JrDNneTpwEPwbelqcSyorj+tBIP8jJe6nnlVLkd 59Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794315017; x=1794919817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=hIqePvJF9vqtDiaaoJWj4mMGLwExY1SZs6wpgpJb2hI=; b=wOxS/H6cDx9LyePEYrb1SKRvhDcaKoMfJf00o2S6bckixIhlws1mcY8apdnVCq99wh xBLXuxZDf/BrRSdec6jQxWXkAlOR3zKFcdU7KNL4xytt5uPxFq0dHNvyCYdn8PV2qiJf zV1s1TzlXgEE8YYkw8RGAN1ZRtybeg5pFmGLvXyM1uzszPjYiBIMDECIVe5UJ1OVl69b oXvXiYeSgFh3Xxz1hvy3KhveM4BkeJrxYyKY+YJVjRDeCFxvxlQ30QmCBHFrlUBMjd4E eHJcnECDrNGJwPtcYEtHkRZRP/oVyaUJeJWritX/3fSf9sZgi09f4c6XHe7VBXEr6Xen feQg== X-Forwarded-Encrypted: i=1; AL+hErFRfHWZ+816quOWXbtapb4PzsnQ1a6q5mN0fdhL5SQfEoGk9rllFdB2nSWt1gsWO2LyGOyuKuGYNVMtuso=@vger.kernel.org X-Gm-Message-State: APuU4Z/uXgjOPZZmOF10m8gYgv/vf+X13sW6qKmtKbLLAS1LiumCaKQC pu26cTKPQELT9daegelT6x7K8exVoesqCYgs6czo3DgijLuCe4XIkaqtua1ywxhqs2I= X-Gm-Gg: AYBFou0jbyXGSnkhmCMeIMb0/NARqCA4QpLtwgYSdLvTrbCI3zaAQzLgUkIbsiMOq4j myq5Oj4D5ubSeP13+1dqFBeNCYCo76yT72yIyxFGDVVyLQ6ocIAgPD0WLQ5TpLSXq59GHQeEbTm 6SEwiTmLptl0H6gTGeCvoWUMvq2GWppVwiLEiwJVcEGb6rs/+iHGPUIvkpvjf1ft5oDaSUBl+py fjnPtk3bwYpHoslTVrcv4fK1Bmels92aYO2CHdkOGtMzt5EzehcnvOpGQY8nlDEBIT/dVyCEnOS oaeSOac5Y/CS5SyWA4DISQFHIVdkAapq0cQkeA5G/IwP0Cda32ZryY9ptEEPB1/kHnMiL7aeTlk BCMEn/+4mCc4FJv1A5pz3va7IEkCajvtsyuIwORrfZu3L0UZolQbwlCScFtJIWn5NiwnHPZKNJt GB8yDgvml0xVkhyM5/kdCBHyZq7/cB3MSy70z4gUAzSo4YfjyiVYe4Gljz162SB7dKqutsDX/Of qB6NuXPshtjHOirK2TzlqucHgmqKBnbj3qqZg6vyuz1+HLLV4iZYtPGWY6DmTQDh6qIbZVyJ/Bg /R48q5wEWKsUj1tjHvHo22DhaJNCNpipqxOI3IylfJ2XtwqeI3iSgJFq6JGu+5Vpu4UKEnA29I7 NRAiDW/UUd4Kiu+o5VoT/3SZZCxQ3tiZ+82ZsoA== X-Received: by 2002:a05:7022:ed02:b0:196:aa86:fcf3 with SMTP id a92af1059eb24-1b3ba7b2b01mr1258881c88.26.1794315017171; Tue, 10 Nov 2026 04:50:17 -0800 (PST) Received: from yhlee-960QFG.Davolink ([2406:5900:1044:110c:88e2:4271:a9b8:cc50]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b3b5b79649sm7614830c88.21.2026.11.10.04.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 04:50:16 -0800 (PST) From: Yehyeong Lee To: jgross@suse.com, sstabellini@kernel.org Cc: oleksandr_tyshchenko@epam.com, boris.ostrovsky@oracle.com, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/2] xen/pvcalls: destroy the per-socket workqueue on release Date: Tue, 10 Nov 2026 21:50:02 +0900 Message-ID: <20261110125002.46683-3-yhlee@isslab.korea.ac.kr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261110125002.46683-1-yhlee@isslab.korea.ac.kr> References: <20261110125002.46683-1-yhlee@isslab.korea.ac.kr> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pvcalls_new_active_socket() gives every active socket its own ordered workqueue: map->ioworker.wq =3D alloc_ordered_workqueue("pvcalls_io", 0); and nothing ever destroys it. pvcalls_back_release_active() flushes map->ioworker.register_work and frees map, but the workqueue and its pool_workqueues stay allocated, so a frontend leaks a workqueue per socket it connects and releases - a loop a guest can run as long as it likes. Destroy it right after flush_work(): the IRQ is disabled and sk_data_ready restored by then, so nothing can queue new work, and the rings are still mapped while it drains - pvcalls_conn_back_read() reads map->ring and map->data, which xenbus_unmap_ring_vfree() takes away a few lines later. pvcalls_back_ioworker() does not take fedata->socket_lock, which the backend_disconnect() caller holds here - only the socket's own sk_receive_queue lock - so draining it from this point is safe; the flush_work() just above already has the same requirement. Fixes: 5db4d286a8ef ("xen/pvcalls: implement connect command") Cc: stable@vger.kernel.org Reviewed-by: Stefano Stabellini Signed-off-by: Yehyeong Lee --- v2: destroy_workqueue() moved to just after flush_work() (Stefano). v1: ht= tps://lore.kernel.org/all/20261109122324.30134-1-yhlee@isslab.korea.ac.kr/ drivers/xen/pvcalls-back.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c index dcefa91a40cd05..d97c5eca5f3513 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -452,6 +452,7 @@ static int pvcalls_back_release_active(struct xenbus_de= vice *dev, =20 atomic_set(&map->release, 1); flush_work(&map->ioworker.register_work); + destroy_workqueue(map->ioworker.wq); =20 xenbus_unmap_ring_vfree(dev, map->bytes); xenbus_unmap_ring_vfree(dev, (void *)map->ring); --=20 2.43.0