From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 11112427F7; Tue, 21 Mar 2023 14:50:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB9C7410D1; Tue, 21 Mar 2023 14:50:16 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 63A1C40A7F for ; Tue, 21 Mar 2023 14:50:15 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jcwG+rNNYa4+DZhelH47LmOEFMIVxPNR8q6vr8eikrcx05u9h6mBmjo139Bwirlzg60gp6vThx1xXeSPojSlyucrTp/I3ItIBw+KRp6KppxZyqx13x688soBve5DXb4Z8BxjrAGGb4YOHcGilebMpPuCzoSqbsLeKQdV1avA88eJHIBHrnltnKsa/LAxzpZdJIbGh3Mub/3j1zgEpJ8fHfnwf+Xj/mXP7zDnkdLoc2x9BhhHkbDlIHIHwKzge9CVvUA/tydp9xLJ+XrInBH/k7MpXgizopiEDRBDaLCzXuwPpBLu+vJOTz1GbSKTV2OKMDCOaFfF4omeSPqkMwayag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rPmxcmfLL1nh2FzhymUS9G97xcXXGZMbvFoGsOU0hEA=; b=c6omWOsx/siq7MippnBEpmvKykysOWiB2zReLik6PZSRv1zBfic0NiaxWhIKq23Y45VchGYbssV/xfz+cK2Db1kQQMAUG++yZxLf9wHgD5c+38j6ZdA1En/VOHwO2hK0bFAon4TI9RylWtDppkGl6mABo5hT+1JHDovlyvjGr18gdJOzBlF/zjLDBHq75k8mHRMboLOCUAhzLx40D0u4QjW0w7bih5jnCuzlTU0lKD1veawEhaX+aO5VIQMAzjugK4PfK01oEOO2NIwzmxzg4RqLkn4zo+/nspM6YUMJRR+QEM5KD5YWmipJai9SaurlTGFZuFX/Ef0avWxN2n/LxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rPmxcmfLL1nh2FzhymUS9G97xcXXGZMbvFoGsOU0hEA=; b=f/r2BLHLMVmOKUBTKq/uI0+Alv2POVNILsWPoyXkAIM1oseFgET3c8ylu161iaHMFM/8CYeoX9p79SRuiATjGaJa2e6sKyh9+Qc3j5wrxH0/4Eio3S975G4f6SUW7Fns2Z6N3R6NOuDvOm/l1xdKXi2wqj22zg4PD0OdIQRS2JE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by MN2PR12MB4501.namprd12.prod.outlook.com (2603:10b6:208:269::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Tue, 21 Mar 2023 13:50:13 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::dd5a:8a5c:f493:9640]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::dd5a:8a5c:f493:9640%5]) with mapi id 15.20.6178.037; Tue, 21 Mar 2023 13:50:13 +0000 Message-ID: <75f7ed07-3e9d-0ac6-2c14-64c598b434ec@amd.com> Date: Tue, 21 Mar 2023 13:50:06 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Content-Language: en-US To: fengchengwen , thomas@monjalon.net, Olivier Matz Cc: dev@dpdk.org, David Marchand References: <20230314124813.39521-1-fengchengwen@huawei.com> <53326af4-26ab-eba7-047f-42917e8f3b00@amd.com> From: Ferruh Yigit Subject: Re: [PATCH 0/5] fix segment fault when parse args In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0159.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c7::9) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|MN2PR12MB4501:EE_ X-MS-Office365-Filtering-Correlation-Id: 896ccbd4-23c8-465f-a272-08db2a1331b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QS0pnq29gxpdk8VvuBCjtTUYGeqzIhddB+7pjKajwT99L3TB0JifjOLmlNAXRn1RpwQZV2GJOlgpeEWRisqZ2eWU17hQ/CfqHdkUeFRXVuygZWVcpMjzn+cmbRV5irZ4YbcysBM41jbyQxi7ghdNKBoIfn2b1caA4BLiFZvcg2PZ6JVuGbxDfq9csdvP/zxoSDn+ZWuVozvw/u5nOiYJhUygQtGodmnV1jUxxK/hJy0PV56zf8b5vrjv3D6eZfOdlUn8HrAkMXjxk+7dHfhY14iSWuCrhUiHx6zmm4znvnVmHtCOPU9GdnTsibb4xTpw0pK2ahQRT3xpNbk7mhAn5hjHBK974G6wxcg7Vvxk1hHkmyUcOr6HaI3uDbSOI/ltwLwgUjs14PkpMIkgG/2Qj4Z2T/Po6mKCgIOzLTY+VYH45uBk2OrWlo0cnPwoCgkdPBHw+ojvg0S+Htiisghx6GSP/SsDRt+PGWAcg2TukKZYUikNeWFP4Ghm3qS00vtyMGV3l3ls4MCZDKTCZiRazn1/j469nBhFvMYVim5O2egIfBzbgOLm5D119KK2gAS6kNluNbE2A56eoUpW6kA/TCUnF4zZE+SCNMrHG3NtUiRcbN/MIWnpbQtqTgAk4OHx7tSm4oQEi96bSuRwghfI7EY3PJyKcxhqJKPElOnQTLeJN4idTZ+YDNMq09pqrOA7jrvPQl9Hm/SsiCxmHgLDmpXbi154E3kXRN7PrrkDU0U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(136003)(366004)(346002)(396003)(376002)(39860400002)(451199018)(31686004)(2616005)(6666004)(6486002)(26005)(53546011)(186003)(6512007)(6506007)(38100700002)(31696002)(2906002)(478600001)(86362001)(316002)(44832011)(110136005)(4326008)(8676002)(66556008)(5660300002)(8936002)(66476007)(41300700001)(66946007)(36756003)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YVZOSzFaSFRIYjE4WFZ6QVZYTkhiWHMvSk9SNFY1b1MyaFA3NUVOV0JlR1Qv?= =?utf-8?B?M2JRKzFnRERzcW54MlFMTC9od3ZTcE9BOE83eXpDeWFCSlBFWHI4aTdMd2RT?= =?utf-8?B?R3E0TmgvVzNhek04YUt1dHRuT1VRZW5SaUhDS1MxRnFTNUZFK1krQ2Z3c3JB?= =?utf-8?B?aFVHT3NlWFVtckpZSVh5RDE4b3dsTjUyS0h0ZmNUd09hRlZ4MEY5cFdQOFRI?= =?utf-8?B?YVQ1c2xCdHltZWw5OS9yUFU1OTFCQTRPb2l2bjhKb0FXUzVpSG5sd2ZTTHNo?= =?utf-8?B?b0dBZHhTVGRNU29zK1BnL2ZaY3NDYk10UFhoN05HM1JTSG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+40?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 896ccbd4-23c8-465f-a272-08db2a1331b0 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2023 13:50:13.2899 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IeEWM5WzfQ6G/X1HSe1ZT+sH43/TEn8dnjuDTlJVDeergY2ZbYDg04HyxZgRBgJo X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4501 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 3/17/2023 2:43 AM, fengchengwen wrote: > On 2023/3/17 2:18, Ferruh Yigit wrote: >> On 3/14/2023 12:48 PM, Chengwen Feng wrote: >>> The rte_kvargs_process() was used to parse KV pairs, it also supports >>> to parse 'only keys' (e.g. socket_id) type. And the callback function >>> parameter 'value' is NULL when parsed 'only keys'. >>> >>> It may leads to segment fault when parse args with 'only key', this >>> patchset fixes rest of them. >>> >>> Chengwen Feng (5): >>> app/pdump: fix segment fault when parse args >>> net/memif: fix segment fault when parse devargs >>> net/pcap: fix segment fault when parse devargs >>> net/ring: fix segment fault when parse devargs >>> net/sfc: fix segment fault when parse devargs >> >> Hi Chengwen, >> >> Did you scan all `rte_kvargs_process()` instances? > > No, I was just looking at the modules I was concerned about. > I looked at it briefly, and some modules had the same problem. > >> >> >> And if there would be a way to tell kvargs that a value is expected (or >> not) this checks could be done in kvargs layer, I think this also can be >> to look at. > > Yes, the way to tell kvargs may lead to a lot of modifys and also break ABI. > I also think about just set value = "" when only exist key, It could perfectly solve the above segment scene. > But it also break the API's behavior. > What about having a new API, like `rte_kvargs_process_extended()`, That gets an additional flag as parameter, which may have values like following to indicate if key expects a value or not: ARG_MAY_HAVE_VALUE --> "key=value" OR 'key' ARG_WITH_VALUE --> "key=value" ARG_NO_VALUE --> 'key' Default flag can be 'ARG_MAY_HAVE_VALUE' and it becomes same as `rte_kvargs_process()`. This way instead of adding checks, relevant usage can be replaced by `rte_kvargs_process_extended()`, this requires similar amount of change but code will be more clean I think. Do you think does this work? > > Or continue fix the exist code (about 10+ place more), > for new invoking, because the 'arg_handler_t' already well documented (52ab17efdecf935792ee1d0cb749c0dbd536c083), > they'll take the initiative to prevent this. > > > Hope for more advise for the next. > >> . >>