From nobody Mon Feb 9 04:15:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1674490155; cv=none; d=zohomail.com; s=zohoarc; b=QQlDrPSKG4bWGBCKz7TgyDgERcJ7n7TcNCLpH1muf09aPTWUSi4xOA3WY70sf1R5kQKuZ/QJEf9d+9akN7jnrHpjx7Q3F3I+KHq3I3+CFdedDIqSvo+6ymDu0jU2iaVCQg2Zx2esSz13BoHZbFiaWkZTbZiO9PFG5KV5Ftzz/ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674490155; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wj6vGQkywJfVjw2xiXGmQ1QT8vp5jo6dBo3Ci55j0gc=; b=Q5cUFfSDwxxwhl2xW0PWgmA5DwsB05c8JzHHOVSa7/vAPZUHxn0nw1lyyRfoL9Q6dKgnkWxhzzCVH9qnZevsqBqFPY9rCZi9LbdmfFkMTWktRIEUQI+WLUvWe5j2DpHrNLb207YBr/2/Odr5oBkcC61er8HT2cn9XdcofHwFnwY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1674490155124539.9805568939671; Mon, 23 Jan 2023 08:09:15 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-VruETNcWOd-IGLZiW1BaDA-1; Mon, 23 Jan 2023 11:09:10 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3225C802C1D; Mon, 23 Jan 2023 16:09:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CE8A1121339; Mon, 23 Jan 2023 16:09:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7F1B419465A0; Mon, 23 Jan 2023 16:09:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0C8781946589 for ; Mon, 23 Jan 2023 16:09:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E700040C2004; Mon, 23 Jan 2023 16:09:03 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DD1C40C2008 for ; Mon, 23 Jan 2023 16:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674490153; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Wj6vGQkywJfVjw2xiXGmQ1QT8vp5jo6dBo3Ci55j0gc=; b=dXpC9YK0tLmdV5jz8j1HbN/peuG4ul0x36K0aGcXheMh2BScRKR4B/A/iZJH4IOJTM+4hW RST4uUkGS7/c/wIHfGS1J4fCPEZ6l/zq29Iap/fN4iDVf8i5wBjBuCq6s5GI7jE2EjiZw0 jtRKLHICxB+Ttp/Fou9JHCFAfJFDDeI= X-MC-Unique: VruETNcWOd-IGLZiW1BaDA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/5] virNetLibsshSessionAuthAddPasswordAuth: Don't access unlocked 'sess' Date: Mon, 23 Jan 2023 17:08:54 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674490156755100001 Content-Type: text/plain; charset="utf-8" 'sess->authPath' is modified before locking the 'sess' object. Additionally on failure of 'virAuthGetConfigFilePathURI' 'sess' would be unlocked even when it was not yet locked. Fixes: 6917467c2b0e8f655999f3e568708c4651811689 Signed-off-by: Peter Krempa --- src/rpc/virnetlibsshsession.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 8de7c86a41..d2e9e20ff2 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -846,16 +846,17 @@ virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSe= ssion *sess, int ret; virNetLibsshAuthMethod *auth; + virObjectLock(sess); + if (uri) { VIR_FREE(sess->authPath); if (virAuthGetConfigFilePathURI(uri, &sess->authPath) < 0) { - ret =3D -1; - goto cleanup; + virObjectUnlock(sess); + return -1; } } - virObjectLock(sess); if (!(auth =3D virNetLibsshSessionAuthMethodNew(sess))) { ret =3D -1; --=20 2.38.1