From nobody Fri Nov 14 18:17:37 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761072179; cv=none; d=zohomail.com; s=zohoarc; b=nUhATXfL26lwz5geTBQ7tJ99whmh6jIChuGgOpn1GyQyCqABelY3P+rG5o1v1QIE6ftTIX1eqMUADPt/JlC1ZsG6KKLuA/El5ABkLmHCFe2no3vQViyhe/UfKRtcQlZsZxV0eeYdmSQ+f8233nFyppNlKvVwrYe9r0l8MSbiW6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761072179; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8PhYYBUPdMAoLP+z5Vb+cys5nIJwgm1vQ8NpBfF6sNI=; b=F6XTorBjgrJXskGuSqTnPB7jTHvxs+n/G+ZzfpFxc5px8/7yC6foet/ti2DGNAmrj5VnpoZpmzLdcvRtbRNPngbLf5mc85/t+G/fZCO5N6Dfuhf5x3ZBeEkkuQaQgdV4UZoD/UWNb0NVmFk332THtGulM+5tm+Ov98kaXXYjcYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761072179972185.24209875174415; Tue, 21 Oct 2025 11:42:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBHIn-0008Cq-Ec; Tue, 21 Oct 2025 14:41:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBHIl-0008CI-GT for qemu-devel@nongnu.org; Tue, 21 Oct 2025 14:41:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBHIj-0004OK-EK for qemu-devel@nongnu.org; Tue, 21 Oct 2025 14:41:43 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-374-NzvswkZGONamV7666lx9Mg-1; Tue, 21 Oct 2025 14:41:38 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-87c6f88fda2so5317656d6.1 for ; Tue, 21 Oct 2025 11:41:38 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87cf51fd3easm74244966d6.10.2025.10.21.11.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Oct 2025 11:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761072100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8PhYYBUPdMAoLP+z5Vb+cys5nIJwgm1vQ8NpBfF6sNI=; b=BwwODp1k+4V3OoSzG/RgKdbYPHlORFauEvTlH1pGG8+TQsqejp8IZRy594ZMN+j0z6ir8K ozuugQhqXcnhD5GOvQTdBXMmZh9h54FG3h7y8JuIb0rJR2crXj5JZhJc6G4rrRj2wJOwIH mSFDrqq2x9LCvXKgw43p2/tSnEOBLTU= X-MC-Unique: NzvswkZGONamV7666lx9Mg-1 X-Mimecast-MFC-AGG-ID: NzvswkZGONamV7666lx9Mg_1761072098 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761072097; x=1761676897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8PhYYBUPdMAoLP+z5Vb+cys5nIJwgm1vQ8NpBfF6sNI=; b=jcl60MMT+O+tIih7xihH+rXGiD5aATrHsNNoKeJZKSbY1gmJb0SmFRUD1TuLbiK2aO LgqDj3RK/U4w0r2coCGSuuNxgKCtXFtaMKKP3cR5Hebcr70uDPBpD8sKZdAUSzotT3zO 2yZ+KBLv8PCdgBSN1vnjp7LSY22QAkufEsBcZiP3WB0t92HY2oih3Q7TWI2r3mI+6Waf +jxxAJCpEyR2WLeEoDqNSyWM/gVm8lAIr6ieHD6qwl71aXF+W9aGFh3sg8HXSzFnkC9R 8ffnirsJ4w2aFMvYRWQFULL9fNRg3NlTzM+Y/paCCAo43HTnQaLHtmtkrjYnP1Taq11E Jl7g== X-Gm-Message-State: AOJu0YyOsJNQCW1d1Ujz388KOjDw9au7FAl+C6zixkn+2YF9NUQKAsTN cQl49lw5uzdHIfaLAkYI+UXtpdOScmogM7t2aL6xk/Ce0RxUPOkLwQirhs3fYqtR1BU6LjAwdsA va4wfxxKsC06VO+fJblRGR+xpcYKfqiMWr0UgnSJNhiutMJczDw9pwkp7B5Dho/wDMF0FjRDb/E ARr72sIBK5tauIo9bl2sUfgrxt8BjHLxHrBUw3rA== X-Gm-Gg: ASbGncuclDBrrKV57ue9du1it8ggwtrnMpKNsNG05/tn2xGcuZtRf1cIUDF4B/9g8dV QVYWseS5htQTVOps385RG0mjyt1zlpITYoleGo9VQxCJ/JtelAfF9wKrmNv5WNetCKhYOWcbFjc Qme13AuZDZDBham6tUpIGK3L+Dlk6KqSNTk2ojODbnrar6RlyYNszPYWez8Uk9xRQT+0HIOqhKJ X/8tPUfk3cyN+snF5nPh/1aeDJjd4rKUwE48/P98GIpG7h09cRZOxsZ13d2pvp7jjG8VjWIcctz QT71PY8YW18FyGz2IVPkKk10WDEzXHMnpcB/O2b4vg4udVMV+cKnJi89idwsggMq X-Received: by 2002:a05:6214:d03:b0:87c:19af:4b76 with SMTP id 6a1803df08f44-87df6535524mr9740926d6.17.1761072097443; Tue, 21 Oct 2025 11:41:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYzkWhJhTSfGQl6qtPRO3zgOxbmgV3dKvEu7sJb2nXcITPORBfiTThh/NUCW2rU1zpIQQPRQ== X-Received: by 2002:a05:6214:d03:b0:87c:19af:4b76 with SMTP id 6a1803df08f44-87df6535524mr9740576d6.17.1761072096903; Tue, 21 Oct 2025 11:41:36 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Arun Menon , peterx@redhat.com, Fabiano Rosas , Peter Maydell , Juraj Marcin Subject: [PATCH 1/3] migration: Fix error leak in postcopy_ram_listen_thread() Date: Tue, 21 Oct 2025 14:41:30 -0400 Message-ID: <20251021184132.2635958-2-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021184132.2635958-1-peterx@redhat.com> References: <20251021184132.2635958-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1761072181066154100 Content-Type: text/plain; charset="utf-8" As reported and analyzed by Peter: https://lore.kernel.org/r/CAFEAcA9otBWtR7rPQ0Y9aBm+7ZWJzd4VWpXrAmGr8XspPn+z= pw@mail.gmail.com Fix it by freeing the error. When at it, always reset the local_err pointer in both paths. Cc: Arun Menon Resolves: Coverity CID 1641390 Fixes: 94272d9b45 ("migration: Capture error in postcopy_ram_listen_thread(= )") Signed-off-by: Peter Xu --- migration/savevm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index aafa40d779..635fa2f918 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2136,17 +2136,18 @@ static void *postcopy_ram_listen_thread(void *opaqu= e) if (postcopy_state_get() =3D=3D POSTCOPY_INCOMING_RUNNING && !migrate_postcopy_ram() && migrate_dirty_bitmaps()) { - error_report("%s: loadvm failed during postcopy: %d. All state= s " + error_report("%s: loadvm failed during postcopy: %s. All state= s " "are migrated except dirty bitmaps. Some dirty " "bitmaps may be lost, and present migrated dirty " "bitmaps are correctly migrated and valid.", - __func__, load_res); + __func__, error_get_pretty(local_err)); + g_clear_pointer(&local_err, error_free); load_res =3D 0; /* prevent further exit() */ } else { error_prepend(&local_err, "loadvm failed during postcopy: %d: ", load_res); migrate_set_error(migr, local_err); - error_report_err(local_err); + g_clear_pointer(&local_err, error_report_err); migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIV= E, MIGRATION_STATUS_FAILED); } --=20 2.50.1 From nobody Fri Nov 14 18:17:37 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761072158; cv=none; d=zohomail.com; s=zohoarc; b=ixTJKLLYl3xG+nEywADrMRADft5PjHrtfV6aYscu6xDmn+TSY1Sr0wNmLOW1iLHEtmvyaS1ofQXmstQJ4V0KI4NcjEG9LDWrA16KXiPKR1zi0BD3QKtSTCvWjZ5sPmsJcBoid7DpHsji400WcD2cBHvawcdnvhAfohe14xfUNJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761072158; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RNORQyf4LYhiSCJxxMC/zAQkaMIFfQ2/DE+ncYUKrT8=; b=OMwzTE3FdJehpUTw8KzHa/J6g2gXlljX9pe8rwMtxmmRnHTl3Ys/mIfUc67hPhGri67RCJAM9mGaqh2mS+lMoTPQu+0qrx4TFQ5laarOGyCR5gcpzzEAqag7T7VNyOq1KoC9ajD9Mw10sbyhIgCyPNm+XzrlqY2v/lGv46Y928w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761072158955820.7994612527596; Tue, 21 Oct 2025 11:42:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBHIp-0008DI-Gj; Tue, 21 Oct 2025 14:41:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBHIm-0008Ch-GZ for qemu-devel@nongnu.org; Tue, 21 Oct 2025 14:41:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBHIk-0004OO-Hx for qemu-devel@nongnu.org; Tue, 21 Oct 2025 14:41:44 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-446-DfOPY8AfNQ2LBPRxBc25WQ-1; Tue, 21 Oct 2025 14:41:40 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-87c171369aaso6167396d6.0 for ; Tue, 21 Oct 2025 11:41:40 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87cf51fd3easm74244966d6.10.2025.10.21.11.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Oct 2025 11:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761072101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RNORQyf4LYhiSCJxxMC/zAQkaMIFfQ2/DE+ncYUKrT8=; b=aiVFWsMcVd6XJOZVMdsHCYXQ0pqJOXxpcBijhi1qYF11QFuU6xAnkCzc8FiRQyEjVmqhHn Hg9qinpl3KF7kskr/lLUbbFWiadi1LGFnLw2iv5ZEDA/eKR/Mmuy9diX2fOHclS8fml2h/ m5ARE1T9VIQf7TJVugvO76N6v7Fw7Rk= X-MC-Unique: DfOPY8AfNQ2LBPRxBc25WQ-1 X-Mimecast-MFC-AGG-ID: DfOPY8AfNQ2LBPRxBc25WQ_1761072099 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761072099; x=1761676899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RNORQyf4LYhiSCJxxMC/zAQkaMIFfQ2/DE+ncYUKrT8=; b=UsDMzMbns152UQEzZMW88E9e9zjx8kGpZeZRMpeRhtf3mj81SdstQksi/p1LhilsH+ pTMXE+UGBPY1umaCKmoueFhkarV55UnxveVxDgu+mYSOdzZ/P03pNZ/op2CAnLBOLm46 tiODOVIVJvtJLpxzC0gHS2/PelYcbaNxahTL2ukIQThCI4Eq749xH3yhazEDTPoLuMCr c4LHHZnbxCDePDpysFTXZpVdaIJ49thIXB5Vb8qTa+pCVjdTcGJprD9w1f9roblv///8 EtWuiEOlP6KvEMuXd/wDy9ekC1oBLAx/70anJoYGHjrwPSIiNBdzTqAdcCJ1BTu/BCqW Easg== X-Gm-Message-State: AOJu0Yzb8QHgOw0GPiOEW1i4l1L89z51J3Cg6W/DHWw0c0kSKANNxn2m eWPBElJs8sODfQpbs+O2FkV64C9e0SJKEdGq8pXFIN92KAhC2ageeSYJwSPxQkZNnKnEIzey9vZ uLwMj6nbvykFtqQ40Q1XG1S16FRBfoxQ3Qy6+dOgXy6dVVl/pxJz2wRRsE1eSNVIzQodjmj+ATJ 3kAD4VzzE4XYTZOoFcnkVGn3cx9zgzDhSeH/TE4g== X-Gm-Gg: ASbGncsMuXwUdQzb45UUZmfXOqzQ+yN2eplixY8GEjcdNxj6jvnwPYik+GfIQbybXia V+i5EGMv/6N/YyJWgskQgTmq7v081A3N1cJy2wPp+txCCUD33SghjURT1wOQNgzUa/WsV5fTn8J zpcjLYQzxrlfWx0AWKVvyQ5ldA+cqgMfIAPm0hRN6UcPABFYNDhZ3F/pQ3adbZYG7izOIMwISVH btWWs2hZ8na9hI7R11GjQbkFn3c1VielPP/704iSiazC4WKqfGkL5t9nNqlt/+eTSVwieUzgox8 JwDddROjYFIW1js9SOLVhgg0dBndtav6A9sx4+JRIRpmj79UzgLVtyN8zZOo86Dk X-Received: by 2002:a05:6214:2407:b0:78d:592d:fd03 with SMTP id 6a1803df08f44-87df675872bmr9851726d6.25.1761072099158; Tue, 21 Oct 2025 11:41:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1jlSQGhbCpN019pcFjlzyYnG33XD7O/NAOHoH8SxMaOcjyh+CpLT6F+Dcowa1H4FGZS0ezQ== X-Received: by 2002:a05:6214:2407:b0:78d:592d:fd03 with SMTP id 6a1803df08f44-87df675872bmr9851306d6.25.1761072098594; Tue, 21 Oct 2025 11:41:38 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Arun Menon , peterx@redhat.com, Fabiano Rosas , Peter Maydell , Juraj Marcin Subject: [PATCH 2/3] migration/cpr: Fix coverity report in cpr_exec_persist_state() Date: Tue, 21 Oct 2025 14:41:31 -0400 Message-ID: <20251021184132.2635958-3-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021184132.2635958-1-peterx@redhat.com> References: <20251021184132.2635958-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1761072161386154100 Content-Type: text/plain; charset="utf-8" Per reported and analyzed by Peter: https://lore.kernel.org/r/CAFEAcA_mUQ2NeoguR5efrhw7XYGofnriWEA=3D+Dg+Ocvyam= 1wAw@mail.gmail.com mfd leak is a false positive, try to use a coverity annotation (which I didn't find manual myself, but still give it a shot). Fix the other one by dumping an error message if setenv() failed. Resolves: Coverity CID 1641391 Resolves: Coverity CID 1641392 Fixes: efc6587313 ("migration: cpr-exec save and load") Signed-off-by: Peter Xu --- migration/cpr-exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migration/cpr-exec.c b/migration/cpr-exec.c index d57714bc5d..3cf44634a9 100644 --- a/migration/cpr-exec.c +++ b/migration/cpr-exec.c @@ -43,13 +43,16 @@ static QEMUFile *qemu_file_new_fd_output(int fd, const = char *name) void cpr_exec_persist_state(QEMUFile *f) { QIOChannelFile *fioc =3D QIO_CHANNEL_FILE(qemu_file_get_ioc(f)); + /* coverity[leaked_storage] - mfd intentionally kept open across exec(= ) */ int mfd =3D dup(fioc->fd); char val[16]; =20 /* Remember mfd in environment for post-exec load */ qemu_clear_cloexec(mfd); snprintf(val, sizeof(val), "%d", mfd); - g_setenv(CPR_EXEC_STATE_NAME, val, 1); + if (!g_setenv(CPR_EXEC_STATE_NAME, val, 1)) { + error_report("Setting env %s =3D %s failed", CPR_EXEC_STATE_NAME, = val); + } } =20 static int cpr_exec_find_state(void) --=20 2.50.1 From nobody Fri Nov 14 18:17:37 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761072160; cv=none; d=zohomail.com; s=zohoarc; b=VjI2WisZAz92yyKKwlWEqwdgdW7FD9s7+iCfkbtRLFdIXPT5GIm1UA5D+qEAJl1z2Od5A5o246EjsZWaiyN0jkfxey+AWo4UhcPDLfavt3l4+gd1AUF0cxnUCb+g4iAmviRbxTmyIwAGqpPKRJJjkvLafUUht+RN1vwafw/ptL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761072160; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XNj6muN3REu90/r8+JwwKM3AGlDFFoXJNEx1Ju3t0lU=; b=hYz7T0pdDMKzFgBl7ghuT9InLY6GFVbFU8anSvY0ib8xHU8y3ccxqVJow2yaL0kG18D0ZE0s0QrHUpQn6s0bJRMZNmySgKcoTT219JjpUArx42SzCDuCEtR4pl2USb83pO2AdygjCn69QXjOSXvNu2+9cQo7+UD4F+8X4SVi4Rk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761072160475353.6119046902436; Tue, 21 Oct 2025 11:42:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBHIq-0008Ds-51; Tue, 21 Oct 2025 14:41:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBHIn-0008Cs-Ew for qemu-devel@nongnu.org; Tue, 21 Oct 2025 14:41:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBHIl-0004OY-Kb for qemu-devel@nongnu.org; Tue, 21 Oct 2025 14:41:45 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-102-nB6os1LSNVK2UcUmQhRo2Q-1; Tue, 21 Oct 2025 14:41:41 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-87c1cc5a75dso311150706d6.0 for ; Tue, 21 Oct 2025 11:41:41 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-87cf51fd3easm74244966d6.10.2025.10.21.11.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Oct 2025 11:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761072102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XNj6muN3REu90/r8+JwwKM3AGlDFFoXJNEx1Ju3t0lU=; b=CSn3z5JjZZ4sNFmVr5eYOtPLDtVpEYolBgkbCbDDdgI+Ui6ma3vazQi0L8e9nOBAcO4YWU HPPjFi04BVdN7l39pwv2l+UbjIizxZawafKvBjfpo7dLp3nFwTJO2Rl3pfokeg09wWkH8C OklC91VJvE3iWf/dEoYYb3DuVBdN9jU= X-MC-Unique: nB6os1LSNVK2UcUmQhRo2Q-1 X-Mimecast-MFC-AGG-ID: nB6os1LSNVK2UcUmQhRo2Q_1761072101 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761072101; x=1761676901; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XNj6muN3REu90/r8+JwwKM3AGlDFFoXJNEx1Ju3t0lU=; b=s7Czqpx95BOyoRRTu/6g2G6Fnj0kwKu59W6QhpP+HozsW03FGFHC/r7BTVx37manon 11ZOTQQP/ZZ93hT53c8DdXxrXRbfVCOaI09qvYYAe1JKNNl3NAqrh/qSOWtg4i+cNg+y Fd1CcvKCa5i2k4HbiUB+I/gYS0mKZ94f2P4l0XS0uS/xhtbs5jS9xxQZ1R7o3aT38S3A oDLG8/wcwNynO0DMUpOUnsZAVqUS5eLfGA7ktYaJ9YoxpSQH1ykddRHcJTfx7+8uE1IQ S736dLF0yaxsv6CmZxxOOy4VGFgCeuduPTaTnnIWbAvWdAe2Lrw5Uk5x0CGydFoqKTyB aOpA== X-Gm-Message-State: AOJu0YxBytT11st91Ky5P5eJFdOOwxYv0ruR2VSZ5QqcpzD+NJyP3QFT Ekg3xIGQqDsbqJz0GfUfiTeYLtCA9ppmS9s4FNT2xhHLasWqWf6204FN9NyRbd/J+duGZbIIfLX 9sVxr1rbtm5Ci3eIaGBFdMLuchYLtziGAwO7RE4qYyYAT6oo5cbv4cBD0e65zX7uBQj87xPQN4n RCwMdawOsbHfjHBTm9dxdwnPQv3kK2tSGcB8c+Jw== X-Gm-Gg: ASbGncurclzdLklKNwVhjr5Bzo3lOFPNv3tIPZiI2Aa2W7nDr6FtlUfzOlI+BcDYbdi VAfFKUOTYyFUBXaHnbJjnsdZDBv/q3+f8gp3/x4qpCfyK72oq9rYZGqv9YLLY60PP3i3jKGOOMC clSHGus25lyAEvicVZPh8n1FmnN3Zc5IpNM/5mSruOc9KPKcQFdNBP0jHkwnoNcuPJmUHLSz2y5 r+dYfbso79z8I9E/pEoAO+mxaTRGQ/XzcgA1eYQRl1aVpKBMF67FypRH0pAT6D24LP7so/3N37S RhZ0w6MiZdN6Y62w7vTCG/7D/3AdZk+Jbn9Viwp8fNcMGNrVVfVygC9Xta8xvXnH X-Received: by 2002:a05:6214:1c0d:b0:820:8fa6:1312 with SMTP id 6a1803df08f44-87c20426b0emr201034286d6.0.1761072100742; Tue, 21 Oct 2025 11:41:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHv2SbAAI00QdBhHdK+EUwHTq3n6TvuybtxEyqg6FXcHK14qq/G5S/DME5KeTlY0gBkfSZggA== X-Received: by 2002:a05:6214:1c0d:b0:820:8fa6:1312 with SMTP id 6a1803df08f44-87c20426b0emr201033986d6.0.1761072100223; Tue, 21 Oct 2025 11:41:40 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Arun Menon , peterx@redhat.com, Fabiano Rosas , Peter Maydell , Juraj Marcin Subject: [PATCH 3/3] migration/cpr: Fix UAF in cpr_exec_cb() when execvp() fails Date: Tue, 21 Oct 2025 14:41:32 -0400 Message-ID: <20251021184132.2635958-4-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251021184132.2635958-1-peterx@redhat.com> References: <20251021184132.2635958-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1761072167654158500 Content-Type: text/plain; charset="utf-8" Per reported and analyzed by Peter: https://lore.kernel.org/r/CAFEAcA82ih8RVCm-u1oxiS0V2K4rV4jMzNb13pAV=3De2ivm= iDRA@mail.gmail.com Fix the issue by moving the error_setg_errno() earlier. When at it, clear argv variable after freed. Resolves: Coverity CID 1641397 Fixes: a3eae205c6 ("migration: cpr-exec mode") Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/cpr-exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/cpr-exec.c b/migration/cpr-exec.c index 3cf44634a9..15c9895a11 100644 --- a/migration/cpr-exec.c +++ b/migration/cpr-exec.c @@ -149,10 +149,10 @@ static void cpr_exec_cb(void *opaque) * exec should only fail if argv[0] is bogus, or has a permissions pro= blem, * or the system is very short on resources. */ - g_strfreev(argv); + error_setg_errno(&err, errno, "execvp %s failed", argv[0]); + g_clear_pointer(&argv, g_strfreev); cpr_exec_unpreserve_fds(); =20 - error_setg_errno(&err, errno, "execvp %s failed", argv[0]); error_report_err(error_copy(err)); migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); migrate_set_error(s, err); --=20 2.50.1