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 7BA62432EA; Thu, 9 Nov 2023 20:57:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 446D5402EA; Thu, 9 Nov 2023 20:57:34 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by mails.dpdk.org (Postfix) with ESMTP id 21127402E7 for ; Thu, 9 Nov 2023 20:57:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qt2oUkaZsmoz3Hr7fWUZRdmMOOSrO+j+fJvMl0JlETlbDqRoP6JrVzXmUJajscqVT/f5D7pVrGyDtNQxacLexkDXZ+8Pn/HbB7AZtPwFTrzeq7EtbWdSEQ0lu+T+isgTcjhl0iGKpOt+pBR+SBT88vSwQpAdI3Ol1zID533VUjbX/r9razIP6hAaqKZtfx8ATzC4qyCSOLKsBO4OZwCbFObDjzpboTmgjzdeKg8MW3kJXVKei2w41f0El+kESY+m07G17bvtjMomYBRBr2xoPJkrHe/rtykqZTTg4UcOY+NDaz3aeKYsFrl92xvqNBqOTYq9UKmCinYEXVLU1VaXmQ== 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=10ho38o60DslrfjU5HXgPb2KUI3X/KXPX4VQ29yAbc0=; b=oXmiIaBO0H/CbZqSRGTs3BMYgza9OgRJnoGVhsOmVRK2aP+EvVLe4i81uZmaxM8IwYdbvj+nVE4qZGkjwMgdvQBC7IB5dqWmJkO52uL9wTqRC3jxubkPX3HVr2/T2vHLJW9xPc7LyBXcTMxnCZaLMr5fnKACVnbgK6mbJIw0AWNsNpSbQVvSWFrsHCVaM49rMEXYJYN2gVMQTvfYSRfRr/rGHdUQm2x0vNjf3o2dZXdx+NqJb/Q6jM6STnhpLO8C7OyoYX7XhQZQUthWLH7FIYVB2gthD0yRQd2WZKEP0EHV2+x589k/JCiNmv21pfEEjuH1S1jn1wXcuVUzX2CHDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=10ho38o60DslrfjU5HXgPb2KUI3X/KXPX4VQ29yAbc0=; b=jhlmFbyO+2Ik7oZtdzDnafXk/ZbvZ+hVmvIGB55pTv2S0T+dmBvoInRzXN7DirVFrr3aRWVEdJM+xRp2QE2StnLQnWC6ZYiNCOXFXq2UoTA/LkZBxEqqbezXRDbYbgI3hizyubvFduQKmiZTwqU7vT6xHGJqltHPMN97IZ6PMJrT9vTiZQQ+OtFAdTDRxhIlOX9w8FYNiFGLTBqnWc0D8ss4CUqFSr9EagQv7vEYRJp1YY2qkp44cj/yI2GVXnWwqCtZUnZwbBPuCgYR882oeQXJ1VKGNpd7kWdgyQddDucff/t0mOnMEoNupK1V43hbA8Iqq/ft3ee5NaCrkJFYVw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from IA1PR12MB6332.namprd12.prod.outlook.com (2603:10b6:208:3e2::13) by DS0PR12MB9398.namprd12.prod.outlook.com (2603:10b6:8:1b3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Thu, 9 Nov 2023 19:57:30 +0000 Received: from IA1PR12MB6332.namprd12.prod.outlook.com ([fe80::43ed:468d:3105:4071]) by IA1PR12MB6332.namprd12.prod.outlook.com ([fe80::43ed:468d:3105:4071%4]) with mapi id 15.20.6954.029; Thu, 9 Nov 2023 19:57:30 +0000 Date: Thu, 9 Nov 2023 21:57:25 +0200 (IST) From: "Etelson, Gregory" To: Ferruh Yigit cc: "Etelson, Gregory" , "dev@dpdk.org" , Maayan Kashani , Raslan Darawsheh , Ori Kam , Aman Singh , Yuying Zhang Subject: Re: [PATCH] app/testpmd: fix indirect action list parameters parsing In-Reply-To: <01176d6f-7f4e-465e-b0e3-20dd6a7e6d18@amd.com> Message-ID: References: <20231108163445.422772-1-getelson@nvidia.com> <9c982259-df1f-bdce-11ff-554831abc42f@nvidia.com> <01176d6f-7f4e-465e-b0e3-20dd6a7e6d18@amd.com> Content-Type: text/plain; charset=US-ASCII; format=flowed X-ClientProxiedBy: LO4P265CA0318.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:390::17) To IA1PR12MB6332.namprd12.prod.outlook.com (2603:10b6:208:3e2::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR12MB6332:EE_|DS0PR12MB9398:EE_ X-MS-Office365-Filtering-Correlation-Id: b82bb0b9-749d-4b57-98a6-08dbe15e1b3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Th+5vDm7QWYNvSATTh6UHafOv76TDlLsL1vr1c/mSrf491W+aRqWEweVBKZ+aA92kvT5p09yx6aE+2csnGbMNPoIqfBB9HJyunufRnWYHZ30E0WZB7qIOIcuwu74hgInPLDdCrzN1RIJ11p4hMMDUwG/v1smOtblyhbMwCybcQ9yM8OJOmvfwpNxNTniO5xkZ/9KKmeLFqyzXTFRVQ8zv87f1iAbBYwYnnfXgfNs77tYY3OsHlex687bT4gkqixlf00EPGcW7ZRHxv0sp+I5ZJ/FZ2ixK47qSicV1FOsizCVzhLSWmqL8UHNQzl1TF3QPj7Op6BsmY2kgmESHL4JsGFtARmhV1TEMZC/fjRKGV06u/HbDJaE9XR5V7lVvMOZjgf7nD+k7cczzdFVH1Vm1R9klDdGb8JguYFGZpRUBNJ04E5wHk0KpPv1NDAZOh7Sa1TzdUwm3nGgE4e3A2/eYmYE355egn5tWQpsERNf2RPADRGJYL7FFatjFXpPbHcmLdsihgr7fNlGsny8mU7HxOWCTIs9JddeHRd17wne/it69vLDsgzVGvVEE66h4oXF3vxw9DYz8tLOTm0td9e6YBMBdWfi0BGPoSPC58M24QhD7iJ/+p4pF5k9t1BaxAeW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:IA1PR12MB6332.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(376002)(396003)(366004)(39860400002)(346002)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(31686004)(6506007)(6666004)(478600001)(83380400001)(38100700002)(2616005)(6512007)(2906002)(31696002)(8676002)(36756003)(41300700001)(4326008)(8936002)(5660300002)(66556008)(316002)(6486002)(66476007)(6916009)(54906003)(66946007)(86362001)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?xYvcbdqQOgXq7P4P4De7/JAtzwK3T05/MhfyQM5qu4SUvd937LM1xivNgi6a?= =?us-ascii?Q?qM4dDge9vv7YN5DDo4+8iYx5R9eaR+cx5DocmYZoqBPs6Kh7UPOjIuS0vzPA?= =?us-ascii?Q?JlEKI3P1xDhf2O/8fIDH9wrO5qg+mBvQszvY6bRCodobfMOPxrwdNm11WXrT?= =?us-ascii?Q?YF/XxnkNu0gdsBPSWfQ9DuQ/Cg/ny8O/fs50detm6ALZ000D59jyUwDskJI5?= =?us-ascii?Q?js8wgysTwqkd9tjxDIeARwKdo/qgpf0NV10WVh5xGXw8SHP/PClYWTHkK8K1?= =?us-ascii?Q?mZIWzFwalrvTUPRaEXR0BnheUpUY9Dt+erIq9kqKzTGtvK+fp/hIZs4OjcQk?= =?us-ascii?Q?xR3g59lbBzsJYsdS5QpGg81tJyNRAdsenS6sU25BO6M9yw5pQHbRTLXNqZn1?= =?us-ascii?Q?kUFrnPgowlAu/SvAFtC/weMSzVqCOlyvWCZsHSH3T8YLcyll9kLAOh5ugtly?= =?us-ascii?Q?8hrx0UycgdDLBXrh5UWOrIbyW6KPy/oNYvsAgBo1rv1hwvDZAwF96jfprTg4?= =?us-ascii?Q?wTu9vf9aswArg95Naef40A26jgpRQdtQKshptl6hNLQseuLqkSK2NnTRju7b?= =?us-ascii?Q?z4tKtsGlQ0NmZkSSQOER3rxuanrelwp8Vx7Ql+5XM1KRnh/IRLHTak5nuvAO?= =?us-ascii?Q?5HNzh5cvi44VMCbRyjC2BZ1bLO7zxFlGvT5kxedjJWAvhxzAntOtO8FUEXv5?= =?us-ascii?Q?Secu8OZeNhjEl+yWbk+irw4+unFWUMlKuHEPvBhf7QPIjDIPmiqS3BNiMz0M?= =?us-ascii?Q?51pZuinS1zjL48yYxr3eFDtw+bZySX0cNCucYr35V3U+aHJ4YkuLjUWVl5if?= =?us-ascii?Q?V765u20mh0Ir1vaWpMJDMH1i9jbVD7SU/ASAlMebQZWtffM4Ptdpc5ua8rJC?= =?us-ascii?Q?OkNedJdf98YSFBsDAWskye71v5sS5qbsl7JzpER0eLtOGF4N4syUzTHr3GBB?= =?us-ascii?Q?eNUq4F4qug3p4aHdbFvLZKCcht2gyqHYyd+dZDk7uDd1nmUabOG5mdOkyBof?= =?us-ascii?Q?NCvoEUok9Z0PVpna2AJrjJaw5Kx1Rhq75m2dPshRbOcOrOyVqlDIABzkSdzH?= =?us-ascii?Q?iADyKst37uWACsL2pamchhUtieLQH8I0eb2MvMOHpY3uQvedqbTBOlhEaoim?= =?us-ascii?Q?g3GL+O4MEqg50KR4DCQboTJDHvrvrhQEdXu4zBjS3ewSoBBcXkIRvgI1Ltmn?= =?us-ascii?Q?C6pVENRa6XpYoFGn2Be4YCouiDTrtST5n2f/elDd5YFnovFj2GFugJR8l3Bb?= =?us-ascii?Q?qBJidGuWqouNnVsRv3zuC0hkhRNnb3IGNlyxd5o+yz/NJNVG6rkoIk8+ryGM?= =?us-ascii?Q?jg3SyhhV0pdduhIYlgWZVbTa3Cf5OPSAP+qOF0mQRxTOkXCYgGiZuzBN2txC?= =?us-ascii?Q?x02xzZI3t3XwY7W5SpQs05BpNKCZ0mLyyA2gMObUfNrlztQIfN3MWthX88Rr?= =?us-ascii?Q?rHrS8uOLGRD8Wj1/B+OPgtR0FkaPmf+6LuTbcKgP3PQOiBTUYM1l7r8gE/0N?= =?us-ascii?Q?ar4JjFHd00ELNFOTGaz3oWvZW9hmaIBvJ3hw9HMmQtfuIF2NmDTv7m4Z12RS?= =?us-ascii?Q?Gq2BdcrZeKfnfHOIbbQrMR0VRjVylnM4pmBYhrowNiQY1BHk8O1TZyZAZ3BZ?= =?us-ascii?Q?ioPF2mUwyRIo1Qgkt7QjZ8lcnPH0GkrZqlXB7mpVIIcN?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b82bb0b9-749d-4b57-98a6-08dbe15e1b3f X-MS-Exchange-CrossTenant-AuthSource: IA1PR12MB6332.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2023 19:57:30.5865 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NxvUaWv08N8oiTeHcSArr7EW0Df8T4Jf1WWA/1F10d2vPtBK+GwvTQF+PE6k7H/gY7lEPEHzfbNDWq4y1fNaOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9398 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 Hello Ferruh, >>>> Indirect actions list arguments parser was configured to place target >>>> number into 64bit value, while the code provided 32bits memory. >>>> >>> >>> Hi Gregory, >>> >>> Can you please give more details why 'id' needs to be 64 bits, with >>> callstack or usecase etc? >>> And please describe what is the observed problem with current code? >>> >> >> In rte_flow.h, struct rte_flow_action_indirect_list::handle is a pointer. >> >> Testpmd ACTION_INDIRECT_LIST_HANDLE and ACTION_INDIRECT_LIST_CONF tokens >> define arguments size as uintptr_t. >> >> On 64 bits system, defining the id variable as 32 bits value >> corrupted parse_indlst_id2ptr stack. >> > > I can't see how stack corruption can happen, can you please provide call > stack and flow command? > To reproduce the crash buildtype must be release or debugoptimized. The crash will not reproduce with the debug builds. Testpmd commands I use: dpdk-testpmd -a ${PCI_ADDR},dv_flow_en=2,representor=vf0-1 -- -i port stop all flow configure 0 queues_number 12 queues_size 256 flow configure 1 queues_number 12 queues_size 256 flow configure 2 queues_number 12 queues_size 256 port start all start set raw_encap 0 eth dst is 00:16:3e:52:bd:37 src is 00:16:3e:6e:16:e0 type is 2048 has_vlan is 0 / ipv4 src is 110.240.52.255 dst is 189.68.183.147 proto is 17 fragment_offset is 0 packet_id is 1 tos is 102 ttl is 189 version_ihl is 69 / udp src is 56800 dst is 4789 / vxlan vni is 3 / end_set set sample_actions 0 represented_port ethdev_port_id 0 / end flow indirect_action 0 create action_id 5 transfer list actions sample ratio 1 index 0 / represented_port ethdev_port_id 2 / end flow actions_template 0 create transfer actions_template_id 6 template indirect_list handle 5 / end mask indirect_list handle 5 / end Result: *** stack smashing detected ***: terminated The corruption occurred in `parse_int()` called from `parse_indlst_id2ptr()`. Inside `parse_int()` the arg parameter referenced 8 bytes of memory while the target buffer was 4 bytes allocated on caller optimized stack: (gdb) p *arg $1 = { ... size = 8, ...} >>> Inside 'parse_indlst_id2ptr()', >>> 'parse_int()' can work or 32bits and 64bits variables, so that one is OK. >>> But both 'port_action_handle_get_by_id()' & >>> 'indirect_action_list_conf_get()' gets 'id' as parameter and they get >>> 32bits argument, when 'id' is 64bit won't it will be cast to 32bits and >>> loose data, should those functions needs to be updated as well. >>> > > Can you please reply to above question, about changing 'id' type impact > to other functions using it? > I've missed that. Need to re-think. Regards, Gregory > >>> >>> >>>> The patch updated variable size for translation results. >>>> >>>> Fixes: 72a3dec7126f ("ethdev: add indirect flow list action") >>>> Signed-off-by: Gregory Etelson >>>> --- >>>> app/test-pmd/cmdline_flow.c | 5 +++-- >>>> 1 file changed, 3 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c >>>> index 0d521159e9..cf1ca33208 100644 >>>> --- a/app/test-pmd/cmdline_flow.c >>>> +++ b/app/test-pmd/cmdline_flow.c >>>> @@ -11331,7 +11331,7 @@ parse_indlst_id2ptr(struct context *ctx, >>>> const struct token *token, >>>> struct rte_flow_action *action = ctx->object; >>>> struct rte_flow_action_indirect_list *action_conf; >>>> const struct indlst_conf *indlst_conf; >>>> - uint32_t id; >>>> + uint64_t id; >>>> int ret; >>>> >>>> if (!action) >>>> @@ -11350,7 +11350,8 @@ parse_indlst_id2ptr(struct context *ctx, >>>> const struct token *token, >>>> action_conf->handle = (typeof(action_conf->handle)) >>>> port_action_handle_get_by_id(ctx->port, >>>> id); >>>> if (!action_conf->handle) { >>>> - printf("no indirect list handle for id %u\n", id); >>>> + printf("no indirect list handle for id >>>> %"PRIu64"\n", >>>> + id); >>>> return -1; >>>> } >>>> break; >>> >>> > >