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 5FB184548D; Tue, 18 Jun 2024 15:13:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E1B94064A; Tue, 18 Jun 2024 15:13:22 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id E3C06402B4 for ; Tue, 18 Jun 2024 15:13:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718716400; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y6hO+NqTy3T9HTKBIZA4h3g0x3VFKLHB7vWaf9j3wxk=; b=ibSqKnnShCDdiWnSrFClts66iotZPPzL/adiuOpdZ0AQJPNIQEKkg+QdMRT39g5uQSfdXi LFTrUADBTDVY4Dpuqtc5vn5siqcum2jWw1yun3TNv8qALZu3DaE7El4mlOXHHuagL9rpuB gfkUZ3w0qO6t5qfQYGOgESisWDnWIfQ= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-277-6HU0bMbnNYOu90UPxHobDA-1; Tue, 18 Jun 2024 09:13:19 -0400 X-MC-Unique: 6HU0bMbnNYOu90UPxHobDA-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ec3cb4354bso176051fa.3 for ; Tue, 18 Jun 2024 06:13:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718716397; x=1719321197; 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=Y6hO+NqTy3T9HTKBIZA4h3g0x3VFKLHB7vWaf9j3wxk=; b=tAPDbnvzpmIZp4Aw96fz4T3+jU5JEWvkr17Ui6+de3SZQR/LmpTGFQD5+Cu5zWu8Sr dJ0dCXmJ/XdW1ZtRMEBvXTSveQqtxjUznTvUoKe/07US+ulby9OYsBdGJBS2sDU9DaXf ISTj75TjLEAYYQ+MoGmMWkW1UQ5NO/evRrveG+dLu3PI/XcF0nxPoJPwwf4QvWpds7WX sNt6Xx+wDQ7hcHrpcQYJ/Podn97rKXybgkwrgKEP2yyou+576GKon4AMMmbFOosJPy9H aKYqtpN1xsbIoHs3TzVXBYOcRAgq/5FELaYdkMlB7zJtjwVBD9OscvyJX4WkOvjT3mn8 KsJQ== X-Gm-Message-State: AOJu0YwEOJPyejAaO0M9d5qnaNg8otacKVt/WK45KdA+8g1gyGuGt7S5 CRvonJzD3cHYgJRG+YJsUI71ePapZjLdLt7qkyVAXweG5ngd1CBEkOxMM14AdeetGi8VYaBvu4I D6OHqieuQVaozaesp3xaVOua4+InkOcw8edc7HdGAHI8rY/qPxfkJ6UZN8QyRWxIeUMgOemC5J9 KGO6SElPmrW9Dl+XA= X-Received: by 2002:a2e:3505:0:b0:2eb:f82a:d8d2 with SMTP id 38308e7fff4ca-2ec0e5a041cmr74849771fa.41.1718716397730; Tue, 18 Jun 2024 06:13:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFKWVsuaw8Gwf7X0O3wwBxDbHqikMi5SSNgjI4g/qnD1XuWQWUEJy46dnqcZ1vcWdIOxsewKr7udlW5huJ7P8= X-Received: by 2002:a2e:3505:0:b0:2eb:f82a:d8d2 with SMTP id 38308e7fff4ca-2ec0e5a041cmr74849531fa.41.1718716397414; Tue, 18 Jun 2024 06:13:17 -0700 (PDT) MIME-Version: 1.0 References: <20240618092324.54166-2-rjarry@redhat.com> In-Reply-To: <20240618092324.54166-2-rjarry@redhat.com> From: David Marchand Date: Tue, 18 Jun 2024 15:13:04 +0200 Message-ID: Subject: Re: [PATCH v3] graph: avoid id collisions To: Robin Jarry Cc: dev@dpdk.org, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Tue, Jun 18, 2024 at 11:24=E2=80=AFAM Robin Jarry wr= ote: > > 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. > > Update unit tests to ensure it works as expected. Fixes: a91fecc19c5c ("graph: implement create and destroy") Cc: stable@dpdk.org > > Signed-off-by: Robin Jarry Acked-by: Kiran Kumar Kokkilagadda Applied, thanks. --=20 David Marchand