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 CFCAF43D51; Tue, 26 Mar 2024 13:48:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FCE340265; Tue, 26 Mar 2024 13:48:51 +0100 (CET) Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by mails.dpdk.org (Postfix) with ESMTP id B441740261 for ; Tue, 26 Mar 2024 13:48:49 +0100 (CET) Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-696609f5cf2so28752396d6.3 for ; Tue, 26 Mar 2024 05:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711457329; x=1712062129; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5rrlxgaHvPK70R7btzU1WuRaPqtE25J1ME9jDooxMjY=; b=dDikRAtZCu3klSnkhZu59BbbaTYGuBQVcwoTjbr/f50fYF5qkO+rHo+6BYceIioTTY NYi+qKNu+CbLah/EzVatwvYZUxGcb9fBko8ME1OhSMg/FLjKs6hMGjSiujIRtLDfD208 vDnViDWH3esxVIOlQGDMY6UmAvEO8RYP4o72aeGVL2tG2Uxl07Chk6QD+qnBdXF2aM1K xREhS7FS24LKNtFZBVFD4GW0/CnBwojiP68PEprufUMqeItoWronc/ooWeNc4QDR1Hb7 +gJwnFB23OdHFf1Bmrxcz/YVlSBJl7es46jgOnYmBLRZlbJUt3ZagTxY1Uf4OESrXXFQ Cemw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711457329; x=1712062129; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5rrlxgaHvPK70R7btzU1WuRaPqtE25J1ME9jDooxMjY=; b=RyGySQUbNc09FUbqKNH0gvYJx4qvCpG7EnfJK8nbtJ74teJ1QeEQExPIis6aEWo/R+ LXvSRaah8A3d1NPgI9n3yE7CdS7IpAC4shUeW/m+TkXUcKi0EGts/PR6cbSTK3t4OOUg yjMVfN4DYgt68+UmPTwMwsD6TABctpGRqmIQwtZQr4JY7G7Y8rLgh4JC8vVpcsvjHaVI HAgwi53Z9QR8CtnCOEptD2CjgjLlJnWb+VP5XQvknJ8g9VllFWqQYF5RU/q2dcT321BF nsFHiyWAHUXi5VZ1xlJrool2anQzhfamXwX1JOOlZxUaLcjp/Qwn4K6lyBSW0cZcgdgL ClPQ== X-Gm-Message-State: AOJu0YxiKEQByxZ5PG8PJrHUl905eNBdwN9l0KnDU4Ktg3vORlwdq1PM hRtL8M140LqvNqKJZerblaP3O8a/MDQ1IM+cJK6RcwxOASD+wOo6YGisNTc2mGsMd7dOf9vtPcC ZyTTWbdwlxHXKm+aAEVTSRR+OJBM= X-Google-Smtp-Source: AGHT+IG6DjS7TdIJlcM/cc6C7PB2nnfYbWGXTmfI1P20fWiE+pkBpSdxT7pUqHWz7tGsx6d0Tic6qd1r/q/EEIikf+M= X-Received: by 2002:ad4:5905:0:b0:696:a386:9ee with SMTP id ez5-20020ad45905000000b00696a38609eemr542996qvb.8.1711457328927; Tue, 26 Mar 2024 05:48:48 -0700 (PDT) MIME-Version: 1.0 References: <20240325155354.770676-2-rjarry@redhat.com> In-Reply-To: <20240325155354.770676-2-rjarry@redhat.com> From: Jerin Jacob Date: Tue, 26 Mar 2024 18:18:22 +0530 Message-ID: Subject: Re: [PATCH] graph: avoid id collisions To: Robin Jarry Cc: dev@dpdk.org, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Mon, Mar 25, 2024 at 9:24=E2=80=AFPM Robin Jarry wro= te: > > The graph id is determined based on a global variable that is > incremented every time a graph is created, and decremented every time > a graph is destroyed. This only works if graphs are destroyed in the > reverse order in which they have been created. > > The following code produces duplicate graph IDs which can lead to > use-after-free bugs and other undefined behaviours: > > a =3D rte_graph_create(...); // id=3D0 graph_id=3D1 > b =3D rte_graph_create(...); // id=3D1 graph_id=3D2 > rte_graph_destroy(a); // graph_id=3D1 > c =3D rte_graph_create(...); // id=3D1 graph_id=3D2 (duplicate with b) > rte_graph_destroy(c); // frees memory still used by b > > Remove the global counter. Make sure that the graph list is always > ordered by increasing graph ids. When creating a new graph, pick a free > id which is not allocated. Please update app/test/test_graph.c to test this case. > > Signed-off-by: Robin Jarry