From owner-freebsd-virtualization@freebsd.org Wed Apr 7 15:30:39 2021 Return-Path: Delivered-To: freebsd-virtualization@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 72F3F5BA88A for ; Wed, 7 Apr 2021 15:30:39 +0000 (UTC) (envelope-from bogorodskiy@gmail.com) Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFpHy40Mdz3l6P for ; Wed, 7 Apr 2021 15:30:38 +0000 (UTC) (envelope-from bogorodskiy@gmail.com) Received: by mail-lf1-x133.google.com with SMTP id n138so29227119lfa.3 for ; Wed, 07 Apr 2021 08:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition; bh=aJBdBi40lgDS8hUO1xiwTYtn+VFuHCJYugYd5iz0iLw=; b=X/m+GDyl9aEUip9KK/Z1SCypSYFFlYYnm92KJjWIZw37j3s5fdIEk5nCrJxWjeka+Q pUUr8vVP+XT2wM3V0byFF56nTOxoGsaeoPSugjZX+LUYoM1PJvyc7ph5CEd9RwJGdmEt OExgVW5FWM+vWgHMgidtrwNLKjxmsGo+TnQTsyLAkmJlXfJjpd9HmgSLEic01sWC/+vO pEeYtp/WW3bqaX0HGzncCCsQzBWcC0wcY3lIIdzEPw8yzcj0xHyeV415E58cmiPjMTaN 4wAwMVONmP9pxq5u8w7pCUu/dzC6h1vR9sqNWAehho7ikl1TMJ3SD6dHr3PpjWcoYO3u HjNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:subject:message-id :mime-version:content-disposition; bh=aJBdBi40lgDS8hUO1xiwTYtn+VFuHCJYugYd5iz0iLw=; b=LRVVDKaoZfzMTxHd50WlbcUX//4YS83cXL2rx4Rf3jRXbd3vF81rXZHh+KoTkVDjwD XAFzrzaWaJ8mdHanDjelZ6ZGbddNzh0HwqL/M3XUdbc850NfgVRRblcPMCmlJiX70g/S pw+EGvCX488G6gEjqpaGa1TugF1xiWiob4F3hvPlbnX2feV+nGANgety3gKDkWh3fhlR THDQkBlKOoa7oILhdyIId2GCq1EyLiDZl/ynDLQKpmYxq4C6A0vCNia6HSx6yR97XyU0 87fgA6JnV6dSOKzS/HNGIPBSh4+qv97kmfKSh6FlXqg4kvH+nfz8vXLIg8CZU3IE8+b4 bWVg== X-Gm-Message-State: AOAM533QOrkg+7mcvnGW+3Vgjs1qyxdGnwW98RzJotwhUmeOyvwtdixP t1t8lEm9Iismn4TiykDohA/CLbblt8m4nA== X-Google-Smtp-Source: ABdhPJxBPwEZxatf85pqRIRltyTdwSLAUHA/Wap2KsTpAc/vej+nkn9mhrVWEBXdERdiTwVlp1IMtQ== X-Received: by 2002:a05:6512:3132:: with SMTP id p18mr2736001lfd.642.1617809435931; Wed, 07 Apr 2021 08:30:35 -0700 (PDT) Received: from kloomba ([5.227.221.57]) by smtp.gmail.com with ESMTPSA id j22sm2527697lfr.37.2021.04.07.08.30.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 08:30:35 -0700 (PDT) Sender: Roman Bogorodskiy Date: Wed, 7 Apr 2021 19:30:25 +0400 From: Roman Bogorodskiy To: freebsd-virtualization@freebsd.org Subject: bhyve: regression in virtio-9p option parsing Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NM/+hEyntSvwDaB0" Content-Disposition: inline X-Rspamd-Queue-Id: 4FFpHy40Mdz3l6P X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=X/m+GDyl; dmarc=none; spf=pass (mx1.freebsd.org: domain of bogorodskiy@gmail.com designates 2a00:1450:4864:20::133 as permitted sender) smtp.mailfrom=bogorodskiy@gmail.com X-Spamd-Result: default: False [-4.79 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; NEURAL_HAM_SHORT(-0.99)[-0.985]; SIGNED_PGP(-2.00)[]; FORGED_SENDER(0.30)[novel@freebsd.org,bogorodskiy@gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[5.227.221.57:received]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[novel@freebsd.org,bogorodskiy@gmail.com]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::133:from]; TO_DOM_EQ_FROM_DOM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-virtualization@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::133:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::133:from]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-virtualization] X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 15:30:39 -0000 --NM/+hEyntSvwDaB0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I'm noticing a behavior that looks like a regression in virtio-9p option parsing. I have a command line that has been working for me for a while, relevant part is: bhyve ... -s 7:0,virtio-9p,distfiles=/workspace/distfiles ... At some point it started to fail with: virtio-9p: more than one share name given Even though there's only one share name. As I can see, the relevant code for that is: static int pci_vt9p_legacy_config(nvlist_t *nvl, const char *opts) { char *sharename, *tofree, *token, *tokens; if (opts == NULL) return (0); tokens = tofree = strdup(opts); while ((token = strsep(&tokens, ",")) != NULL) { if (strchr(token, '=') != NULL) { if (sharename != NULL) { EPRINTLN( "virtio-9p: more than one share name given"); return (-1); } sharename = strsep(&token, "="); set_config_value_node(nvl, "sharename", sharename); set_config_value_node(nvl, "path", token); } else set_config_bool_node(nvl, token, true); } free(tofree); return (0); } And it fails at the first iteration, likely because the sharename was not initialised and points to some arbitrary non-NULL value. Explicitly setting it to NULL like this: diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index e27159eb22cb..830e13878a71 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -232,7 +232,7 @@ pci_vt9p_notify(void *vsc, struct vqueue_info *vq) static int pci_vt9p_legacy_config(nvlist_t *nvl, const char *opts) { - char *sharename, *tofree, *token, *tokens; + char *sharename = NULL, *tofree, *token, *tokens; if (opts == NULL) return (0); appears to fall back to the normal behavior: it accepts a single share name just fine, but shows that error if I try to specify more than one share name, e.g.: -s 7:0,virtio-9p,distfiles=/workspace/distfiles,foo=bar It looks like the regression was introduced by the global variables commit (https://reviews.freebsd.org/D26035). The old code had "char *sharename = NULL". Roman Bogorodskiy --NM/+hEyntSvwDaB0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEi6TfKtFPmbY34ABwyW1f/gjCImoFAmBt0A4ACgkQyW1f/gjC ImoPjwf/WUHc/7A2HuZcDNS+V39ZgqvQmGw/3dy7yRqXGY/dNhQJKvcesd1qRF3K 3HXbW6aQ150qXSq86fdI3HVoCuAnqKSaLuEOieKOpu3stMnuyY/We86ewHwiGd5W yDsl6SK2RY0Dgl+NRTBFUxaGOdC9PGSbIYNR+G6Fw5/b7DlpkJWUwQceKIHkj+8O Ow7pjoor9V7UyHttCIIiH+0VIppbte4z0GqNSL7+UzVGh87ghJ0pgWKBPwHtCqkp 3HeU5XuTu+tB7FKet2pe3MsvV4Q9lXsNrX8X6pP6fOCAAb/6H0u2fggS5m8prJ8h u2dN5+I+YPUpZQIPFQrmhbWNIBTY2A== =/aLQ -----END PGP SIGNATURE----- --NM/+hEyntSvwDaB0--