From owner-svn-src-head@freebsd.org Thu Aug 16 14:26:44 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 DD08D1067B51 for ; Thu, 16 Aug 2018 14:26:43 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22b.google.com (mail-it0-x22b.google.com [IPv6:2607:f8b0:4001:c0b::22b]) (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 62C1284DCD for ; Thu, 16 Aug 2018 14:26:43 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22b.google.com with SMTP id s7-v6so6500010itb.4 for ; Thu, 16 Aug 2018 07:26:43 -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=W0AjuYMKI/wKDM3kqg45MWRImSLQKJ1Ufp5CgNw/2Zw=; b=feqsV8gHmwGKbxAx9WwMY/sU58B1+T8iT0K0xE45x1NLXNaLCP1TYKqj76qWuG3dF9 xYZvm5MdXjDzFHsN2gRHwVB0ZRWv+180UzyfCBObvqIXBUX6rStDTqh2CsoKDkPJMZyH fghJjELJFHmXzJuNadS6b7aBDC0L2fbNmgLbESdhNmaWEf3uDYp+AOnaoQcUZM1kjBor FEdyq4ZPMICllXmbLPDXgUTYEitfnNYrTTja8XHKQMxd0NDTPcwH3cwgoGHoVZ+/VS6z QS0ralwcTDkiN5YI8BulmhV/SRBhT0wCmhwHZsyu3Rd+//V6Hs8WkYX707ZpU9pTdCJ6 AXuw== 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=W0AjuYMKI/wKDM3kqg45MWRImSLQKJ1Ufp5CgNw/2Zw=; b=BC/DPDrCT+tlKgyBn/62DmVt6B8I8Wu/qrVkjvXDuAQ2JGKv+LQekPSs7xvXBtCfMd gQCTpCQx6YvNgEETrqHhcqaxaxlEK8u7ZGW0Sw1E1hI50WiFX3n7SwP2aPDyM91R+DxT Yq8jt5YJdRpPk2RHYWUW7DgoydNAMtTXvx+nTmqkXR2h63LWgVgL+qMQBYH0bBeDUO00 alkKHVf+zPM1o+s1SMD/pLZUqVwpvMooracXOyRe2oVpmHfHx1YWrMiKL6Ifx2tO0OyN LbW+t4asiDbUzUYfNjmNd0pCdjcx2Exc1yR4Co79AxlVQZaRkxPC0nLg0/9uFfRUvZMO 4HbQ== X-Gm-Message-State: AOUpUlGq/KeySu9BTPJq1GTw9Sra/806mNx7T5ReMbeNJawAvm0XnYGL yMpB7IW71Groi9bEArqPGYdnUyL/4qaKHtZObbWIMA== X-Google-Smtp-Source: AA+uWPwfNkF7nHI0U8hGb7KWkQTxJrqmLkcnWHfG/+xZ8fnzfSR25F/UaeiH4rOzbGCdJuXgT2blEvevYQ7PqSAz/b0= X-Received: by 2002:a02:a701:: with SMTP id k1-v6mr27332670jam.140.1534429602567; Thu, 16 Aug 2018 07:26:42 -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 07:26:42 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <201808161403.w7GE3q3l053696@pdx.rh.CN85.dnsmgr.net> References: <201808160631.w7G6VsS8064579@repo.freebsd.org> <201808161403.w7GE3q3l053696@pdx.rh.CN85.dnsmgr.net> From: Warner Losh Date: Thu, 16 Aug 2018 08:26:42 -0600 X-Google-Sender-Auth: bxUfy_OsOdvo_NA04YdDgnVC3hc 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 14:26:44 -0000 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). Keep in mind, though, that ATA is 100% irrelevant to NVMe, since the NVMe standard specifies everything. I've sent a followup to marcelo though about the 8-bit and NUL details, however, since I have conflicting info about that. Warner