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 6C51C46B8A for ; Wed, 16 Jul 2025 10:25:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D127402D4; Wed, 16 Jul 2025 10:25:56 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 21ABF4021E for ; Wed, 16 Jul 2025 10:25:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752654353; 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=+DAv7Cwa2M5K4W7g85onwsd+ksTkHxVsqh+94X0pknw=; b=Rhn3ayVoCXkl5jxEEJ581koeVJ/MNC+QVVI1YOIqIVf/5XrlhiABZCUgELomrbTIGjhLmV ThvY75RaSx8v64WMBNXr39yyMspCvpwyAG1J/C19n3YEqEZQ6jMTRk7nwUtj5gg2qB50Yq vvVDPzHl+uW/ZtbXpA2s0yphWs8RFB0= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-61RM0XwPPJCc2qrem7QsZA-1; Wed, 16 Jul 2025 04:25:51 -0400 X-MC-Unique: 61RM0XwPPJCc2qrem7QsZA-1 X-Mimecast-MFC-AGG-ID: 61RM0XwPPJCc2qrem7QsZA_1752654350 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-32b3ce96f8dso27503611fa.0 for ; Wed, 16 Jul 2025 01:25:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752654349; x=1753259149; 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=+DAv7Cwa2M5K4W7g85onwsd+ksTkHxVsqh+94X0pknw=; b=JPQLyW+LRhXbvKId3n2pUr1/oD+xK3jmHkgQrqKlpfPEdHVRZGHUFoeyUbR3gTNGY9 VwfIO/JUlNy+gWAYcg/O49EOesu8KBTAFxnm6358umw0tTzf9eD+9BvJ8xvySOBVZ40S mt6oKC5ByAv6t3IxdO0pJHBnlY8uK5EMuAHc/5FSjDoutVwDJ7Llg5es281KyaU8BhEJ K6202zAQyU0nYSkbcnkUdd6AWnp7xCm5g42yRK8GPJkdZQNc7dQicqZ3E6FyjBahTtmQ P0/jL7daGeQ74R+O7SaHNqrfGEY0NFl/43FVkVGYSDVLJm7SJsTSaXtUXaFcLhgjMFeI WISg== X-Forwarded-Encrypted: i=1; AJvYcCUFMW1SgSEzso+BXYosOyn20rt5goRclru3j3lsvm9TawT4eHxp9C6RCxlGM4uc9KHa/POydvY=@dpdk.org X-Gm-Message-State: AOJu0YxYawi5ahk+CD1jyepBzKgr16A8gQ44VuquOl9RWwS/RBGYDG5e o1Igc6CGpB7FoeI4Tbd6jjYzMbVb1TQW8E8L3M72TZJpS8YwtJIYw1jDJEKEaJbQ3mG12n87CV9 I3x5x2kG+sIz744eMAEK8D8jIhnUF9qhxuoUIq5A673IezG8CCdo+D3IIte+apqtl9+qmQILE+l /aEJdATEKRUZjlb1wdWfyW2R995MMoq2o= X-Gm-Gg: ASbGncszlW8gpaNZ8hUbvPAiLUceXacdT1BPi95K1+aiPZf9yEPoYxW161FB8Cw8fgu nCWgDNjiJYb8Q+pk1Th2PgRWfpkVCfXatgNAlrmMDlfdkHsIO8zJI4sl3/5zmKThJJaBawEgxVY NYlOyqeDYcOPzoex+HpPnN+Eg= X-Received: by 2002:a2e:8a8d:0:b0:32b:3c94:992d with SMTP id 38308e7fff4ca-3308f5e6936mr4543681fa.28.1752654349516; Wed, 16 Jul 2025 01:25:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxoeLzdhYuVdYEpmf7iam8rpXWYB4dGpbZJyEnRuXLztF2mjSprPXbuHLPUlorvMNqcL/cD2nyBq4EV2tfydk= X-Received: by 2002:a2e:8a8d:0:b0:32b:3c94:992d with SMTP id 38308e7fff4ca-3308f5e6936mr4543531fa.28.1752654348965; Wed, 16 Jul 2025 01:25:48 -0700 (PDT) MIME-Version: 1.0 References: <20250619071037.37325-1-david.marchand@redhat.com> <20250623135242.461965-1-david.marchand@redhat.com> <20250623135242.461965-8-david.marchand@redhat.com> <609759a6e0cf4187a34d1a12bf9bcd59@huawei.com> In-Reply-To: <609759a6e0cf4187a34d1a12bf9bcd59@huawei.com> From: David Marchand Date: Wed, 16 Jul 2025 10:25:37 +0200 X-Gm-Features: Ac12FXy64bQ0joyk_L8LX7NOGsPuBlFJYVsxQqaSIORgGAQywDH1vrn4ltYh4_E Message-ID: Subject: Re: [PATCH v2 07/10] tailq: fix cast macro for null pointer To: Marat Khalili Cc: "dev@dpdk.org" , "stable@dpdk.org" , Bruce Richardson , Tyler Retzlaff , Neil Horman X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: TNW0lV8-VANU7o9l5dBKnjJV_6qhR7gxst0HPtq4uwk_1752654350 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Mon, Jun 30, 2025 at 6:06=E2=80=AFPM Marat Khalili wrote: > > > -----Original Message----- > > From: David Marchand > > Sent: Monday 23 June 2025 14:53 > > To: dev@dpdk.org > > Cc: stable@dpdk.org; Bruce Richardson ; Tyl= er > > Retzlaff ; Neil Horman > > > > Subject: [PATCH v2 07/10] tailq: fix cast macro for null pointer > > > > Doing arithmetics with the NULL pointer is undefined. > > > > Caught by UBSan: > > > > ../app/test/test_tailq.c:111:9: runtime error: > > member access within null pointer of type 'struct rte_tailq_head' > > > > Fixes: f6b4f6c9c123 ("tailq: use a single cast macro") > > Cc: stable@dpdk.org > > > > Signed-off-by: David Marchand > > Acked-by: Bruce Richardson > > --- > > lib/eal/include/rte_tailq.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/eal/include/rte_tailq.h b/lib/eal/include/rte_tailq.h > > index 89f7ef2134..c23df77d96 100644 > > --- a/lib/eal/include/rte_tailq.h > > +++ b/lib/eal/include/rte_tailq.h > > @@ -54,7 +54,7 @@ struct rte_tailq_elem { > > * Return the first tailq entry cast to the right struct. > > */ > > #define RTE_TAILQ_CAST(tailq_entry, struct_name) \ > > - (struct struct_name *)&(tailq_entry)->tailq_head > > + (tailq_entry =3D=3D NULL ? NULL : (struct struct_name *)&(tailq_e= ntry)- > > >tailq_head) > > > > /** > > * Utility macro to make looking up a tailqueue for a particular struc= t easier. > > First tailq_entry is missing parentheses. Also, it is worrying that we no= w use macro argument twice. E.g. RTE_TAILQ_LOOKUP may become twice slower a= s a result. > > Could we perhaps simplify the macro to `(struct struct_name *)(tailq_entr= y)`. I tried to find or understand the reasons behind the original construc= tion, but could not. Thanks for the comment, it made me relookup at this code. I realise this macro should be called with a correct object in the first pl= ace. Instead the lookup macro itself is the part that is undefined behavior (wrt comment in case of an error). --=20 David Marchand