Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8894BC4338F for ; Thu, 19 Aug 2021 07:13:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3154661100 for ; Thu, 19 Aug 2021 07:13:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3154661100 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.168398.307459 (Exim 4.92) (envelope-from ) id 1mGcEo-0005vQ-87; Thu, 19 Aug 2021 07:13:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 168398.307459; Thu, 19 Aug 2021 07:13:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGcEo-0005vJ-55; Thu, 19 Aug 2021 07:13:18 +0000 Received: by outflank-mailman (input) for mailman id 168398; Thu, 19 Aug 2021 07:13:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGcEm-0005vD-I7 for xen-devel@lists.xenproject.org; Thu, 19 Aug 2021 07:13:16 +0000 Received: from hera.aquilenet.fr (unknown [2a0c:e300::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 571c985f-85e9-4db5-b543-88f6de9b5c29; Thu, 19 Aug 2021 07:13:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id E723B261; Thu, 19 Aug 2021 09:13:12 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R9IsyADec-bF; Thu, 19 Aug 2021 09:13:08 +0200 (CEST) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 4CA19222; Thu, 19 Aug 2021 09:13:08 +0200 (CEST) Received: from samy by begin with local (Exim 4.94.2) (envelope-from ) id 1mGcEd-008yRU-Ds; Thu, 19 Aug 2021 09:13:07 +0200 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: 571c985f-85e9-4db5-b543-88f6de9b5c29 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Date: Thu, 19 Aug 2021 09:13:07 +0200 From: Samuel Thibault To: Juergen Gross Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org Subject: Re: [PATCH] mini-os: netfront: fix initialization without ip address in xenstore Message-ID: <20210819071307.zitx72bbylsusxkx@begin> Mail-Followup-To: Samuel Thibault , Juergen Gross , minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org References: <20210819053056.32675-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210819053056.32675-1-jgross@suse.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spamd-Bar: -- Authentication-Results: hera.aquilenet.fr X-Rspamd-Server: hera X-Rspamd-Queue-Id: E723B261 X-Spamd-Result: default: False [-2.50 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_ORG_HEADER(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MID_RHS_NOT_FQDN(0.50)[]; BAYES_HAM(-3.00)[100.00%] Juergen Gross, le jeu. 19 août 2021 07:30:56 +0200, a ecrit: > 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] = dev->rawmac[5]; > } > if (ip) > - *ip = strdup(dev->ip); > + *ip = dev->ip ? strdup(dev->ip) : NULL; > > err: > return dev; > @@ -527,7 +527,7 @@ done: > snprintf(path, sizeof(path), "%s/ip", dev->backend); > xenbus_read(XBT_NIL, path, &dev->ip); > > - p = strchr(dev->ip, ' '); > + p = dev->ip ? strchr(dev->ip, ' ') : NULL; > if (p) { > *p++ = '\0'; > dev->mask = p; > -- > 2.26.2