From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by dpdk.org (Postfix) with ESMTP id 6417A8042 for ; Fri, 5 Dec 2014 16:58:42 +0100 (CET) Received: by mail-wi0-f178.google.com with SMTP id em10so1827218wid.17 for ; Fri, 05 Dec 2014 07:58:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=f+mHa6geQ3GBLLl/7TKQdZZ6c/Q/NVK1OUK1kJhU+/k=; b=l2YAtwJxZK7xBdHQNxCQWO6Puj+w1g6rhcliX8ENnBysb3oeD2RN065CXeU2bXM54y LIlAMTxPTJWBRC9ikeCpmoFNU15CVUyp88SZED0+/aPTaLHHXantvNmzLfO37O4zbotu Crk/KEe4YarJNMMRG64I14EGd1ih4faybLsVtfb59nxPWbpKKZTFTQUN7qRBFsC1s62u W/nkbwmfR1en+f8rAJUx3WMi/2S7G0uF6LbVBex44P6FPsENNd6KPlCh5O3du15RWe3n eK5KwgBKlIPd0/cyfdppRgEpOcjA6mkkSgmK+jpHPSXx7CBx4BStsWR/ZwCQyrp3o8QA zatg== X-Gm-Message-State: ALoCoQmXk7d+hN8D3OwOsOOl6tVJPyoWKkPZNYocCTW5WibZzt8B853Is36WgaE5ZodXCMAqI2q7 X-Received: by 10.180.104.197 with SMTP id gg5mr5179680wib.7.1417795121878; Fri, 05 Dec 2014 07:58:41 -0800 (PST) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id j2sm45410670wjs.28.2014.12.05.07.58.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Dec 2014 07:58:41 -0800 (PST) From: Thomas Monjalon To: Alan Carew Date: Fri, 05 Dec 2014 16:58:16 +0100 Message-ID: <1536173.TcPGvUY4rp@xps13> Organization: 6WIND User-Agent: KMail/4.14.3 (Linux/3.17.4-1-ARCH; KDE/4.14.3; x86_64; ; ) In-Reply-To: <20141205155100.GA9040@bricha3-MOBL3> References: <5481BE26.9080903@6wind.com> <1417789147-5636-1-git-send-email-olivier.matz@6wind.com> <20141205155100.GA9040@bricha3-MOBL3> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v3] librte_cmdline: FreeBSD Fix oveflow when size of command result structure is greater than BUFSIZ X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2014 15:58:42 -0000 > > When using test-pmd with flow director in FreeBSD, the application will > > segfault/Bus error while parsing the command-line. This is due to how > > each commands result structure is represented during parsing, where the offsets > > for each tokens value is stored in a character array(char result_buf[BUFSIZ]) > > in cmdline_parse()(./lib/librte_cmdline/cmdline_parse.c). > > > > The overflow occurs where BUFSIZ is less than the size of a commands result > > structure, in this case "struct cmd_pkt_filter_result" > > (app/test-pmd/cmdline.c) is 1088 bytes and BUFSIZ on FreeBSD is 1024 bytes as > > opposed to 8192 bytes on Linux. > > > > The problem can be reproduced by running test-pmd on FreeBSD: > > ./testpmd -c 0x3 -n 4 -- -i --portmask=0x3 --pkt-filter-mode=perfect > > And adding a filter: > > add_perfect_filter 0 udp src 192.168.0.0 1024 dst 192.168.0.0 1024 flexbytes > > 0x800 vlan 0 queue 0 soft 0x17 > > > > This patch removes the OS dependency on BUFSIZ and defines and uses a > > library #define CMDLINE_PARSE_RESULT_BUFSIZE 8192 > > > > Added boundary checking to ensure this buffer size cannot overflow, with > > an error message being produced. > > > > Suggested-by: Olivier MATZ > > http://git.droids-corp.org/?p=libcmdline.git;a=commitdiff;h=b1d5b169352e57df3fc14c51ffad4b83f3e5613f > > > > Signed-off-by: Alan Carew > > Signed-off-by: Olivier MATZ > > Tested on FreeBSD 10 and this patch fixes the issue described. > > Tested-by: Bruce Richardson Applied Thank you all -- Thomas