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 2F6B246B24 for ; Tue, 8 Jul 2025 09:32:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02F1B40287; Tue, 8 Jul 2025 09:32:35 +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 0F98340287 for ; Tue, 8 Jul 2025 09:32:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751959952; 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=YykXMCxVy63e50qjcVEfOVtZWSrAWYdDvP5lXjyAVw4=; b=TqPHNZzkj5fgjmplLSlLECZwD+qWIFqBzG2ytEPFW6i3u3Rg6kERUnIEztLQ+lCeu24UF5 bUcLfK5Di0PmtW+6nb4Q/WqtRinpPMTrOl1Cv2vxi/7XxNLuiy1KpkXsbGwdGGfqwsCvcX x6gTh3Uoa4VTQhWDgKPaNxJyLTK4Z5I= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-npyL0KmYOqeTbhdn0JJMHw-1; Tue, 08 Jul 2025 03:32:31 -0400 X-MC-Unique: npyL0KmYOqeTbhdn0JJMHw-1 X-Mimecast-MFC-AGG-ID: npyL0KmYOqeTbhdn0JJMHw_1751959949 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-32b43616ba0so17389631fa.0 for ; Tue, 08 Jul 2025 00:32:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751959949; x=1752564749; 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=YykXMCxVy63e50qjcVEfOVtZWSrAWYdDvP5lXjyAVw4=; b=kdvSuUZHcWMjafL0jGGlgvcGWWu76p45oYlWB7X4V3xt+j8P1fUslI7vPgXPpvgw6z nCl/2x0jIvbhCAc7rg4Zv4KRTxT4YhPowvGY9EhvQ0m41CuCte5MoxuycJUpnertSAGj l+ywXZtmL/RfkwmCCJM2nLrZ2x/o6o8+bLw6soh0bW0NvUmblLIjmGsQItOLOnfILsl6 SexNNP4Wbtb+KEUK5uGskg6IwQV3Cf8sxgEIJDl6kGQ4FHxEc3ivXlKlu1hl0xhNJhSS ZXMOwtSsdj0eO+DM7knzEEl+wkXTQQxy+1uCKMczgh11hQA4TgrUMC52onPoWwtuDvdw RRbA== X-Forwarded-Encrypted: i=1; AJvYcCVUYWncC+vfJ0ixfjNOL7gzR7FLFsgAHQRs4WHjkh+yC7Rsr4EOXfnJC9LQLSlWROAbzpnhxQA=@dpdk.org X-Gm-Message-State: AOJu0YxeAL7w0Cd1ZT+zq/P+yUZxltgPXh9oqJaO+FCmy4XhIfjprBC7 AitVzTZPnu/46rxL0rDb/zEsAML3izT6Fkw5Gf/x3lZr1KojqgA3NgkYn5wBAjcfk9f5MFzIBz6 Z3gECzIgSOnBvtxC17mu3irW93C5X+CBLv6w6g6EdcKDeY5Gx1Jm5KOa09CnVmLLxAm1YQCONsz PrrhVkW7j6A4rkO7dsFgGnhzA= X-Gm-Gg: ASbGncvIohb3Kqju26rqxQDgG2+GgIczgYR0/OAXQEaVK/nVaTgSYY80ALsMTcUTXGu 0WQkevpK3GVrrhJSswNm+T2nj+VmB948x6ABY6IevFWc1Q1oz8gDB9KmaDG4PxFvVpX6aZlGjxh vaSu7Oaw== X-Received: by 2002:a2e:be83:0:b0:32b:7ddd:2758 with SMTP id 38308e7fff4ca-32f39b9fc91mr4977341fa.0.1751959949319; Tue, 08 Jul 2025 00:32:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyv9nz9uHnefPDFKFlNFNI/03PABrzGzm61MBjtutxLS5aZusoLW6OEc/RInOgMnNCaWb3f6DJSDcVZWOForc= X-Received: by 2002:a2e:be83:0:b0:32b:7ddd:2758 with SMTP id 38308e7fff4ca-32f39b9fc91mr4977171fa.0.1751959948848; Tue, 08 Jul 2025 00:32:28 -0700 (PDT) MIME-Version: 1.0 References: <20250619071037.37325-1-david.marchand@redhat.com> <20250623135242.461965-1-david.marchand@redhat.com> <20250623135242.461965-9-david.marchand@redhat.com> <70c7ba78c4324495bfd317e38e926958@huawei.com> In-Reply-To: <70c7ba78c4324495bfd317e38e926958@huawei.com> From: David Marchand Date: Tue, 8 Jul 2025 09:32:15 +0200 X-Gm-Features: Ac12FXyKV9zq-jHP7ouTZMIluAPDbth9lnKi6TRCsnRLHJgabuQn7rAGzlpGjDs Message-ID: Subject: Re: [PATCH v2 08/10] hash: fix unaligned access in predictable RSS To: Konstantin Ananyev Cc: "dev@dpdk.org" , "stable@dpdk.org" , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin , John McNamara X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bb38459MGdNq-OyzeOEhkxht5yv6Cp-KwDeZ623bLQQ_1751959949 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 Tue, Jul 1, 2025 at 10:36=E2=80=AFAM Konstantin Ananyev wrote: > > Caught by UBSan: > > > > ../lib/hash/rte_thash.c:421:8: runtime error: load of misaligned addres= s > > 0x0001816c2da3 for type 'uint32_t' (aka 'unsigned int'), > > which requires 4 byte alignment > > > > Fixes: 28ebff11c2dc ("hash: add predictable RSS") > > Cc: stable@dpdk.org > > > > Signed-off-by: David Marchand > > --- > > lib/hash/rte_thash.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c > > index 6c662bf14f..6d4dbea6d7 100644 > > --- a/lib/hash/rte_thash.c > > +++ b/lib/hash/rte_thash.c > > @@ -415,10 +415,10 @@ generate_subkey(struct rte_thash_ctx *ctx, struct= thash_lfsr *lfsr, > > static inline uint32_t > > get_subvalue(struct rte_thash_ctx *ctx, uint32_t offset) > > { > > - uint32_t *tmp, val; > > + uint32_t tmp, val; > > > > - tmp =3D (uint32_t *)(&ctx->hash_key[offset >> 3]); > > - val =3D rte_be_to_cpu_32(*tmp); > > + memcpy(&tmp, &ctx->hash_key[offset >> 3], sizeof(tmp)); > > + val =3D rte_be_to_cpu_32(tmp); > > Just wonder do you guys consider it as a real one? > AFAIK, all architectures that we care about do support unaligned load for= 32-bit integers. Well this is undefined behavior, regardless of what the architecture suppor= t. And the compiler may end up generating wrong code. I could revisit this change with the aliasing trick (used for rte_memcpy). --=20 David Marchand