From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 7656B1FF141 for ; Tue, 02 Jun 2026 13:39:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6AEF011127; Tue, 2 Jun 2026 13:39:45 +0200 (CEST) Message-ID: Date: Tue, 2 Jun 2026 13:39:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH qemu-server] fix #7654: prevent use after free To: Dominik Csapak , pve-devel@lists.proxmox.com References: <20260601121654.2421101-1-d.csapak@proxmox.com> Content-Language: en-US From: Fiona Ebner In-Reply-To: <20260601121654.2421101-1-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1780400314986 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.009 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: Z2YXOB6T3A3QHE2QGY2RX4GVIJTTVKRO X-Message-ID-Hash: Z2YXOB6T3A3QHE2QGY2RX4GVIJTTVKRO X-MailFrom: f.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Am 01.06.26 um 2:16 PM schrieb Dominik Csapak: > to prevent a use after free on a client struct, instead of freeing it > inline in 'cleanup_client', only set a boolean flag 'pending_free' > and free it in the main 'handle_client' function. > > the call graphs look like this: > > handle_client > `-> cleanup_client > `-> handle_qmp_handshake > `-> cleanup_client > `-> send_qmp_cmd > `-> cleanup_client > `-> handle_qmp_event > `-> terminate_check Nit: there's an additional `-> send_qmp_cmd here (terminate_check() does not call cleanup_client() directly). > `-> cleanup_client > `-> handle_qmp_return > `-> terminate_check Nit: same here > `-> cleanup_client > > In addition, if we cleanup a 'vzdump' client, the corresponding vm wll s/vm wll/VM client will/ > be looked up and 'terminate_check' will be called for it. If that > resulted in a cleanup, we have to free that immediately. > > cleanup_client will not be called in other paths, so handling the > freeing in handle_client should suffice. > > Signed-off-by: Dominik Csapak Reviewed-by: Fiona Ebner Thanks!