From nobody Thu May 2 05:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1629351097; cv=none; d=zohomail.com; s=zohoarc; b=QeQ0vr/Nqt4insIl4Y3tVmR/BPuIp8hT0JIh7VerxxLuApovinXx8lM/PueooP66pCDjL3VM3rXrCjRcwPPDrlWbt73JDJOJupZWrboAFDY61Wq0wWDkSOsB/IV8bIOILGtzwNZ8T40wA4v8gE4H1ChABj1LOtGnib44GVuVEAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629351097; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=JAlAwR9/QksTzRSgjsQCc86kQ6ZiSu8rGtdbGLfgZFw=; b=WBozmJhgcV7U655/qh25ObSluY87rDDA70g++ipFMadkEJnROq3pEgAuEDkHw0FIiglZj7LxPWRYAY4PaSnIWGI24l0JRhE0NDqzvr7+m06/EC8Z2LUEjW7gLS7qbN1TJbdvG32V+0WJCqTfbYWIE3lIE6ep17VJ6AiGc8bio6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629351097594507.56949367613845; Wed, 18 Aug 2021 22:31:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168383.307434 (Exim 4.92) (envelope-from ) id 1mGads-0003rV-FE; Thu, 19 Aug 2021 05:31:04 +0000 Received: by outflank-mailman (output) from mailman id 168383.307434; Thu, 19 Aug 2021 05:31:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGads-0003rO-Bl; Thu, 19 Aug 2021 05:31:04 +0000 Received: by outflank-mailman (input) for mailman id 168383; Thu, 19 Aug 2021 05:31:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGadr-0003rI-Pp for xen-devel@lists.xenproject.org; Thu, 19 Aug 2021 05:31:03 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a3d6454f-00ae-11ec-a5b3-12813bfff9fa; Thu, 19 Aug 2021 05:31:02 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 315D41FD2D; Thu, 19 Aug 2021 05:31:01 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id F1AA31371C; Thu, 19 Aug 2021 05:31:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id WOnxOJTsHWEzFgAAGKfGzw (envelope-from ); Thu, 19 Aug 2021 05:31:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a3d6454f-00ae-11ec-a5b3-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1629351061; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=JAlAwR9/QksTzRSgjsQCc86kQ6ZiSu8rGtdbGLfgZFw=; b=qUfHRUp4JLy98LyOC+faN9t1R0hLK1Rk6uOLQQtwBdMkLLL5KQvuX5KL0Bk4a2B1Sgk4Oq kXbTG3n/EEPyvOgGxtAsnIrjYoP7hj5l5vWn2mb/Wz407/Q1TS+XLAnWZaKuT9053wUl7z 34IoPGJ/QgVjuHmTfgo19BMXmVgzwBM= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH] mini-os: netfront: fix initialization without ip address in xenstore Date: Thu, 19 Aug 2021 07:30:56 +0200 Message-Id: <20210819053056.32675-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1629351100932100001 Content-Type: text/plain; charset="utf-8" Commit 4821876fcd2ff ("mini-os: netfront: fix suspend/resume handling") introduced a NULL pointer dereference in the initialization of netfront in the case of no IP address being set in Xenstore. Fix that by testing this condition. At the same time fix a long standing bug for the same condition if someone used init_netfront() with a non-NULL ip parameter. Fixes: 4821876fcd2ff ("mini-os: netfront: fix suspend/resume handling") Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- netfront.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netfront.c b/netfront.c index f927e99..dfe065b 100644 --- a/netfront.c +++ b/netfront.c @@ -365,7 +365,7 @@ out: rawmac[5] =3D dev->rawmac[5]; } if (ip) - *ip =3D strdup(dev->ip); + *ip =3D dev->ip ? strdup(dev->ip) : NULL; =20 err: return dev; @@ -527,7 +527,7 @@ done: snprintf(path, sizeof(path), "%s/ip", dev->backend); xenbus_read(XBT_NIL, path, &dev->ip); =20 - p =3D strchr(dev->ip, ' '); + p =3D dev->ip ? strchr(dev->ip, ' ') : NULL; if (p) { *p++ =3D '\0'; dev->mask =3D p; --=20 2.26.2