From owner-svn-src-head@freebsd.org Thu Aug 16 15:33:41 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2ED9B106AF2A for ; Thu, 16 Aug 2018 15:33:41 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x22f.google.com (mail-io0-x22f.google.com [IPv6:2607:f8b0:4001:c06::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B136788A4B for ; Thu, 16 Aug 2018 15:33:40 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x22f.google.com with SMTP id m4-v6so4222559iop.3 for ; Thu, 16 Aug 2018 08:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=iVr2OGrth5sR5hukVWWhoW0Mm2+HpATtcsQ3lkMiOxo=; b=UR2aoQGUBDlb0mbgbU/zXg9pBgOejW4iAMUq1+6NLTj2ea2WswSrvdv4MpXax165/9 sOhFyUIqAYdEzTJot7ohBlAqMFY5j9NO+jQbuhZ8CkeqAeJqYnAjimZ0+bIByacQ+fY9 1Tr8WvI7pt2I2FcemiUwoz/QbfkW0UnBBLL+ItUDF/EVLE+Feu8cPPqdGxJrY6OrnVIx ZnzWRB4RbfBNHfGVhhYY0OxzeLTqKztrw31biHwwHMzDk0sCSxwDgxy6ClRoiLBAeP+W Qcd39M+Ld1+n9zXD8L1FfcjFtjmIOV0J97tmwHFDMSKwyvo4z20XvwyNJz0gpDDDt+v7 jN1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=iVr2OGrth5sR5hukVWWhoW0Mm2+HpATtcsQ3lkMiOxo=; b=VExSzfPLEvxIcsAqbirDcua0BoVXI0lhmnfVmqmV/AcMVVI+6O0tYrXzqiexIA0ire hkZk5tFG72NW9B5k4auou/w1JvTg74bCgE1lkOjM44R7upfY+E32t1egc3dwomemn3+G 2bkZfk8IzhEeTETGYYlDg0EP6VWk9LAGWx57GO43AzUDhcKUTY/Ch1EhSDVMYDSyRoKU vzhSqX+eVxRfbfFqT/yrzkTTYnk+WCD47Ww0pte/g31jcwWoO5aXAk6srJayg6wkTsPd bGfFt214lbNF095HNzuYshOAxnfAJWUzei0ZB0KsorhKjg8lzZ2bjASV2cWplubRNtg1 oOMg== X-Gm-Message-State: AOUpUlEZ9mfjhfLR90zXfUZA/1Jzx8YXueKYRiv8r/LF5R4Oslxa5mHi 6rARf0HXJKCNHV8ct7+5hxkibZWxtwjDPw3De1Lcxw== X-Google-Smtp-Source: AA+uWPzIsMH4TOPgnZUMyGFTda3GBI+/Koj7U9GQ9HvT2NXm+5sXAolOM93+ApIlQU7VVIB0gVVwIi6Mtn1vsa6agYI= X-Received: by 2002:a6b:7117:: with SMTP id q23-v6mr10100656iog.37.1534433619827; Thu, 16 Aug 2018 08:33:39 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:257:0:0:0:0:0 with HTTP; Thu, 16 Aug 2018 08:33:39 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <201808161434.w7GEYEsm053813@pdx.rh.CN85.dnsmgr.net> References: <201808161434.w7GEYEsm053813@pdx.rh.CN85.dnsmgr.net> From: Warner Losh Date: Thu, 16 Aug 2018 09:33:39 -0600 X-Google-Sender-Auth: _Mtyhda_J0A-mMn511C6ts7li64 Message-ID: Subject: Re: svn commit: r337887 - head/usr.sbin/bhyve To: "Rodney W. Grimes" Cc: Marcelo Araujo , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2018 15:33:41 -0000 On Thu, Aug 16, 2018 at 8:34 AM, Rodney W. Grimes < freebsd@pdx.rh.cn85.dnsmgr.net> wrote: > > On Thu, Aug 16, 2018 at 8:03 AM, Rodney W. Grimes < > > freebsd@pdx.rh.cn85.dnsmgr.net> wrote: > > > > > > Author: araujo > > > > Date: Thu Aug 16 06:31:54 2018 > > > > New Revision: 337887 > > > > URL: https://svnweb.freebsd.org/changeset/base/337887 > > > > > > > > Log: > > > > Add a comment explaining how the PSN works and why there is no > need for > > > > a null terminator. Also mark CID 1394825 as intentional. > > > > > > > > Reported by: Coverity > > > > CID: 1394825 > > > > MFC after: 1 week > > > > Sponsored by: iXsystems Inc. > > > > > > > > Modified: > > > > head/usr.sbin/bhyve/pci_nvme.c > > > > > > > > Modified: head/usr.sbin/bhyve/pci_nvme.c > > > > ============================================================ > > > ================== > > > > --- head/usr.sbin/bhyve/pci_nvme.c Thu Aug 16 06:20:25 2018 > > > (r337886) > > > > +++ head/usr.sbin/bhyve/pci_nvme.c Thu Aug 16 06:31:54 2018 > > > (r337887) > > > > @@ -1714,6 +1714,11 @@ pci_nvme_parse_opts(struct pci_nvme_softc *sc, > > > char *o > > > > } else if (!strcmp("sectsz", xopts)) { > > > > sectsz = atoi(config); > > > > } else if (!strcmp("ser", xopts)) { > > > > + /* > > > > + * This field indicates the Product Serial > Number > > > in > > > > + * 8-bit ASCII, unused bytes should be NULL > > > characters. > > > > + * Ref: NVM Express Management Interface 1.0a. > > > > + */ > > > > > > I have seen this before on ATA devices, > > > if the vendor fills all bytes of PSN, > > > there well be no unused bytes, > > > so no null byte at the end, > > > and you end up with an unterminated string. > > > > > > Can you please verify that this edge case is handled correctly? > > > Thanks, > > > Rod > > > > > > > memset(sc->ctrldata.sn, 0, sizeof(sc-> > ctrldata.sn > > > )); > > > > strncpy(sc->ctrldata.sn, config, > > > > sizeof(sc->ctrldata.sn)); > > > > > > > > > > > strncpy will not NUL terminate when there's exactly sizeof(ctrldata.sn) > > bytes in the 'config' string. Thus that case where all characters are > > non-NUL is handled properly (the standard says the string need not be NUL > > terminated). > > I get that, are we certain that all consumers of ctrldata.sn > obey this, ie it is never attempted to print this string > with a %s? Grep says "Yes." Warner