From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C05133A1A23 for ; Sun, 16 Aug 2026 17:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786900024; cv=none; b=baG+LJpJ9tXA+LEV5Be6g1iXF+4rK7yAt9xelbVI7Mfc6Wl2yN5fobE/Ik9RLooK6UzwYDA1dK7d9I8M92/MYZbvDb/aKhncy0IN/dtNmZ7kfNYfy5IUPG4fqJs852qejGeOMFMGoTVN7akaC68BzEl0hpcvikfDiK22u3NvIiA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786900024; c=relaxed/simple; bh=UjKZbgfnH1XMHC6xC5BUOWE08XCJYVIJ9QrIeEmUvZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O/yPWBIyjmyhaTySdL1ncWPOl+yv65JTmEuagPdP7re+apiBP+YU0UbGJACnjyunLMuSZe0VIU7/nB7wcJfrqbA/E87RgJbYUR/XV6sFXyGnBk62Kk6xTNJWdoEuT0Kixir+oujUcuLNPE5ZuTwNwnXjlB+Trkz2H7KXf63dUOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=om0R+S7v; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="om0R+S7v" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4956869750eso17583055e9.2 for ; Sun, 16 Aug 2026 10:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786900021; x=1787504821; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HVcyBope6DGMi/80lpE9C+i3r+YlYpBjseKIjfNL3rQ=; b=om0R+S7v5h63SVYRNsYOkpVe9ssIC8V3cXmzJx9kngHNEJzXQ0O8Uk26corHOJBoMO yUCS7YQn8ngL1UtQC0LcpObHmJbZQWXtYCaDJUtAi+/fU6VQKhfwGr7rS+cdLCY2Dbb+ lyQjGAvUwet1e6/+395kQcuDmqQV7NwyvtPopMS//l5ze7mqkmNXu+R0dDjCGR1qxwmd ia8LSPxwgKiuV3Otctvq/6ZQ/6mtq00skbEnUZrnzxkBYfZ7UZj+wBHrHtYiKMeOTSPO USIIMVUcVWzCZ/PgonoS3I4LGn3bSQZYmWAgqcF0L1iIGkwCZRiyL8+tlH7re2DAiF02 WytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786900021; x=1787504821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=HVcyBope6DGMi/80lpE9C+i3r+YlYpBjseKIjfNL3rQ=; b=dRwsAMaV3vgHcAf97xKCPd0SjlnixjpkJTv9pQpE0UlS8BEkT0OACGDGnvYF/Swo7N KBj87mjJU+QWLYZoUBgdBrPP9jmilL7Ke7IqOmRv4V5YYiEZu+/u0HeAwiyj7O3wnptU gXkusDuERTaxaQSgxS1CmtgvCNpEnUIuwJvvJNnyIneHOTgTTPfOeJ9+HEdEhC5RfWlT dq1sz9xp1aJ4cpUl8oiMQfk/6iehzHly1bfxNam7YG4bcoUf983pUSEpYUPTzbcOiLUw QaRXAu/rq+L8gC6mBhE6SQjptzfkOgZPqNLzsD+5IkxNJvzCRI/ANHjQ9J/flhd5VMg9 DD7g== X-Gm-Message-State: AOJu0YyIBr8LPJNipKaThUQHLdL39xY1wLAg1xTZ4AzEoLNwxYpwRnme rWRzGgTP0CZ33i6RSLLJtzdWo0Xb9Nfmp/CLPTSZYnfkn5PIt6lWKTYC X-Gm-Gg: AR+sD10ms48MuMg2tPxbJlnD8rD/9XrYCnVmd4VfMOfg45y6T3zQl+LfJGMt9zzhqCB 5M59A24foZgzw6IIaDGiM6zw/Egm5nI76jFrCbPDNLQ+Jg6iDGVI9BOnz9IqohDi/KsdvvCPP3x yBNhP1bF4KJozeZBbwhw9jeP3Yo+jRAvZ7TORSu9X6UJn/CgzSFgyOcJ1aN5g1oyv3XmzrQhyov psF9dxZTDPZBq0jRaPAt1TgbsKt2sn0+1I/yUMDaxhHN0L7yNs1ZQZ4bb+bFt5q/FtvddSI+yOp T9Q/Bz8B+Qr4Sv/CWgBYsJRRjBvRVuV1izgljvWSfaZaTT4CLXqL3ZsiWeRqdHufJID1tXzA9Ca 0K0qV45Z7CaP7JeAmJpdWuZUHJ4mH4W8yvXCXtemULLKuHEmFmTYxcK6lpKaVyN5pRNqrYx6KdO ttTunTt08+Ma+SDJkQZ0Vi5OYg3O3kgbYhuQBjwrquih51KydjVFPYpXObrtLXt9MwyWj2BzvaV TyDtEe8ZYZamgcHPF7FoOlXdzM/iuy59PeJqb56djkUK4djupQevzjRNxahwWVWyYw3bmKCCIvt p01upPjSIKQitIw2WFaNA4/P0RnmReDL27lZtpY= X-Received: by 2002:a05:600c:3485:b0:499:8758:8cb4 with SMTP id 5b1f17b1804b1-49987935eecmr314132475e9.5.1786900020748; Sun, 16 Aug 2026 10:07:00 -0700 (PDT) Received: from localhost.localdomain (p54a14b85.dip0.t-ipconnect.de. [84.161.75.133]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4999618acafsm55671335e9.14.2026.08.16.10.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Aug 2026 10:07:00 -0700 (PDT) From: Bernard Ladenthin To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, pablo@netfilter.org, fw@strlen.de, netfilter-devel@vger.kernel.org, kunit-dev@googlegroups.com, davem@davemloft.net, Bernard Ladenthin Subject: [PATCH 3/4] textsearch: align ts_state.cb like skb->cb Date: Sun, 16 Aug 2026 19:05:39 +0200 Message-ID: <20260816170541.3384-4-bernard.ladenthin@gmail.com> X-Mailer: git-send-email 2.49.0.windows.1 In-Reply-To: <20260816170541.3384-1-bernard.ladenthin@gmail.com> References: <20260816170541.3384-1-bernard.ladenthin@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit struct ts_state carries a 48-byte control buffer that callers cast to their own state structure. lib/textsearch.c casts it to struct ts_linear_state. net/core/skbuff.c casts it to struct skb_seq_state via TS_SKB_CB(). Both contain pointers and so need 8-byte alignment on 64-bit. cb sits at offset 4, right after the unsigned int offset field, and struct ts_state itself has only 4-byte alignment. Any allocation aligned to 8 or more therefore places cb on a 4-mod-8 address. kmalloc() guarantees at least ARCH_KMALLOC_MINALIGN, which is 8 or larger, so a heap-allocated ts_state has a misaligned cb every time. For a stack-allocated one it depends on where the compiler happens to put it. No in-tree caller is affected today. The only struct ts_state is a stack local in skb_find_text(). The cast is undefined behaviour regardless, and on architectures without efficient unaligned access it is a trap for whoever allocates one of these on the heap. struct sk_buff already marks its cb[48] __aligned(8) for exactly this reason. Do the same here. Signed-off-by: Bernard Ladenthin --- This is my first kernel submission. Corrections on anything I got wrong in the process are welcome. include/linux/textsearch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h index 4933777404d6..e117f9c9de59 100644 --- a/include/linux/textsearch.h +++ b/include/linux/textsearch.h @@ -23,7 +23,7 @@ struct ts_config; struct ts_state { unsigned int offset; - char cb[48]; + char cb[48] __aligned(8); }; /** -- 2.49.0.windows.1