From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B245DA00BE for ; Tue, 19 May 2020 11:17:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 873371D5B2; Tue, 19 May 2020 11:17:40 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id EC8EA1D17E for ; Tue, 19 May 2020 11:17:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589879857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=T4CFsAYP3Y/MQeQRcLBebroBCVIFMpsqrqmWRaMjI/s=; b=IriBWJkGqlVQui6ZRqdV73GDq3q5RH8luDTivJi/ijrLmqshZV4tVbUPlppIsAq7KJB5Nz 77VJDv51ZRykrAwKZ0d4RxWInUnfV7A1yqezkm0haSISbXIV2vQhrtakvrlPk10SHFCfqz cXrbEkUUnl9O5x7UvMlwORgc6kuoYW8= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-dJfp0BOKN-6JnFG4sUndNw-1; Tue, 19 May 2020 05:17:35 -0400 X-MC-Unique: dJfp0BOKN-6JnFG4sUndNw-1 Received: by mail-vk1-f200.google.com with SMTP id y192so5657539vky.2 for ; Tue, 19 May 2020 02:17:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=T4CFsAYP3Y/MQeQRcLBebroBCVIFMpsqrqmWRaMjI/s=; b=jlS1loCt25sAWS1vJqdnCJwj+BZPzvgZBg34G/NLqJV+wPppRr5v2yFDVE1grPfszZ ju5SlM2UpybJp3Wa3QEQFHgXmDNhJYTvXn5xJhjceImrNDmYd9MnaiW902Jp/a/3PG8U uzlrQvxA6/UCZU2iL95WieQkM8fnIuTsxiCWYKeEqPRAFcwUXB1kmjt/6pGRN3Nw+dzm Uodrmm4mWCbCJH4rrTZbA2c87rxSAQU51lMPXlGgaoWNbF8LdbYZJoDwGX8LE29otB65 r8b+5Ca7LB9I0eZFfJ8+4DWQlEgYpzGug0fe3YgWpCItB/ODioSZFJdHcgWfNmSOcRqW 7o2Q== X-Gm-Message-State: AOAM5315+5qf0McUMASFw30wTja56BsZ5KakDSkl3gcyKjG2dGECOF6y nbqxOysBLr2fcskr1PIK84QVuUyO8kNe1iWLjqW8E2UfJXrew2a02jHLEe3pQJwe451798BuS2R bUsHLnzHiePIOQNOcHn/E6zQ= X-Received: by 2002:a1f:8fd1:: with SMTP id r200mr11300010vkd.56.1589879855203; Tue, 19 May 2020 02:17:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxP7q1KeQqaFFluXTzYBNeXDXsd1HgemY4q2hjtyUfwK/ml28eOpuCO3CloJbQScxkpuPWfA3qPNs+Vo0pPSNc= X-Received: by 2002:a1f:8fd1:: with SMTP id r200mr11299999vkd.56.1589879854988; Tue, 19 May 2020 02:17:34 -0700 (PDT) MIME-Version: 1.0 References: <20200513104751.46466-1-grive@u256.net> <20200513104751.46466-2-grive@u256.net> In-Reply-To: <20200513104751.46466-2-grive@u256.net> From: David Marchand Date: Tue, 19 May 2020 11:17:24 +0200 Message-ID: To: Gaetan Rivet Cc: dev , dpdk stable , Luca Boccassi , Kevin Traynor X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v1 1/2] pci: fix allowing underflow when parsing PCI id X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Wed, May 13, 2020 at 12:48 PM Gaetan Rivet wrote: > > The function strtoul will not return ERANGE if the input is negative, as > one might expect. > > 0000:-FFFFFFFFFFFFFFFB:00.0 > > is not a better way to write 0000:05:00.0. > To simplify checking for '-', forbid using spaces before the field value. > > 0000: 00: 2c.0 > > Should not be accepted. > > Fixes: af75078fece3 ("first public release") > Cc: stable@dpdk.org Not sure about backporting this one, will let stable maintainers reconsider this. > Signed-off-by: Gaetan Rivet Acked-by: Darek Stojaczyk > --- > lib/librte_pci/rte_pci.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c > index d1ab6b414..e4ecdc32f 100644 > --- a/lib/librte_pci/rte_pci.c > +++ b/lib/librte_pci/rte_pci.c > @@ -35,6 +35,12 @@ get_u8_pciaddr_field(const char *in, void *_u8, char dlm) > if (*in == '\0') > return NULL; > > + /* PCI field starting with spaces is forbidden. > + * Negative wrap-around is not reported as an error by strtoul. > + */ > + if (*in == ' ' || *in == '-') > + return NULL; > + > errno = 0; > val = strtoul(in, &end, 16); > if (errno != 0 || end[0] != dlm || val > UINT8_MAX) { > @@ -70,6 +76,12 @@ pci_dbdf_parse(const char *input, struct rte_pci_addr *dev_addr) > unsigned long val; > char *end; > > + /* PCI id starting with spaces is forbidden. > + * Negative wrap-around is not reported as an error by strtoul. > + */ > + if (*in == ' ' || *in == '-') > + return EINVAL; Should be -EINVAL, fixed. > + > errno = 0; > val = strtoul(in, &end, 16); > if (errno != 0 || end[0] != ':' || val > UINT16_MAX) > -- > 2.26.2 > Applied, thanks. -- David Marchand