From nobody Tue Nov 4 15:26:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 153021599570928.901792784636655; Thu, 28 Jun 2018 12:59:55 -0700 (PDT) Received: from localhost ([::1]:38248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYd4y-0003Ka-LE for importer@patchew.org; Thu, 28 Jun 2018 15:59:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYd36-0002DE-B8 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 15:57:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYd35-0000W6-KT for qemu-devel@nongnu.org; Thu, 28 Jun 2018 15:57:48 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:55366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYd35-0000UB-Di for qemu-devel@nongnu.org; Thu, 28 Jun 2018 15:57:47 -0400 Received: by mail-wm0-x244.google.com with SMTP id v16-v6so11034033wmv.5 for ; Thu, 28 Jun 2018 12:57:47 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id d102-v6sm12516646wma.10.2018.06.28.12.57.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 12:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=SJWSu/co/e56+DQruRImg1DYHL9dO8HtFEc5qpwCORQ=; b=u8SQNNvvNR2T+1SB5VEBr6SIZWc64FPkD+bfiEhYopJa4jyBvMoKbzXvjAktVySBV1 6cbudqX+eVxgQo+CcaYLP7NrG+YfEkaLDnBQvMCc+ry6E0cbHAQZJyYvxrROnKdy65Us SlQ441eo43TgliF6k2cerEh8bqa2KbfZDZDcDRB5s8znQqgnVJ1qharpGiueBD96K/Q1 7Kks58Q61WkVJmiGy+k0pFzCR6qZ7qAxmfbfEz7TzSQpBqfW819d3VMOX5W2zs3CcZtb IY/TPKmezsW1KIPxQTpo9DlWc30s/IdwBWiAZVeYuCJNZXoYMBFWkS3oVRZfB3RZA3Py 2jOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=SJWSu/co/e56+DQruRImg1DYHL9dO8HtFEc5qpwCORQ=; b=H31dsF7FeD40RCMLQs+xO+RYm/uxMybkXMvogiC6vCdnToBh0PT5fscBRlJHuS3c9j 5StECfEs+b31huG6bleLE51UxfBRBXANTHrneZ/0OaYWZpzF86XG8xdK42DvYXRo3ecY ytrbP8RChGYQl6Q0onLQR7rgDpwcbZGlB5XoPcvP4om97AEW7y99hFRI/dl2Zb9fQr3i 5TWvQYz/9WtyJ3mqpimsKrUqv3hZqASzHT94ziZIdx/On5JGGrG8Zuxc0b4Gk0QRff2J hcLalLeBP08nMn9g8FQvP9tfmFbvvWvV2t/VjQgKBMub5xvgFRKTFdasGoEILdKNAle8 GqLA== X-Gm-Message-State: APt69E0JtLm9gRvJuAh2loxh66KjCp8Z7gJGyRQfGnoVie8JOGO06vcK wZmkvpB9yE6WoUTH4GSQIa2nVDGh X-Google-Smtp-Source: AAOMgpckCJkJhdrNURu5TrhNR5SATk1f3x/WUCcqJi887wkcG0xJ2wM7KH79ULRTcghA4WnBSErK3g== X-Received: by 2002:a1c:850c:: with SMTP id h12-v6mr8987230wmd.116.1530215866009; Thu, 28 Jun 2018 12:57:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 21:57:35 +0200 Message-Id: <1530215858-1525-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530215858-1525-1-git-send-email-pbonzini@redhat.com> References: <1530215858-1525-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH 3/6] pr-manager-helper: avoid SIGSEGV when writing to the socket fail X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When writing to the qemu-pr-helper socket failed, the persistent reservation manager was correctly disconnecting the socket, but it did not clear pr_mgr->ioc. So the rest of the code did not know that the socket had been disconnected, accessed pr_mgr->ioc and happily caused a crash. To reproduce, it is enough to stop qemu-pr-helper between QEMU startup and executing e.g. sg_persist -k /dev/sdb. Reviewed-by: Michal Privoznik Signed-off-by: Paolo Bonzini --- scsi/pr-manager-helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 82ff6b6..0c0fe38 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -71,6 +71,7 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mg= r, if (n_written <=3D 0) { assert(n_written !=3D QIO_CHANNEL_ERR_BLOCK); object_unref(OBJECT(pr_mgr->ioc)); + pr_mgr->ioc =3D NULL; return n_written < 0 ? -EINVAL : 0; } =20 --=20 1.8.3.1