From nobody Wed Apr 1 22:08:25 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83E3E36308B for ; Wed, 1 Apr 2026 15:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775056054; cv=none; b=AF9VkIGqMgcET/qvKFBlS4Tvy8X+xoxSMknwJG6/wDeiU/iztSbf7lINHw6Ys5O6eCbSwEROSvuzjR4gxVfCTIvIFH6dMgjt6NOBhcUkk6UFEzeNO/mhOTNJDFTXmLXAWM+iv31+mNtsJ4+9fYjAaUW5X95DjFMRW00ZI9+TFIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775056054; c=relaxed/simple; bh=dj4a7yIFkUuuOErayl1USgUNCE2PkTOo08S0tvg3kp0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j/jw9G0R+A5MSLRSENoyocOvNVGFIRbvSfZwM8j4HxHjnm10Lv3atZkNyU1pTzQ5fUHlXlVwWtJmhdhnZPSDueL7TzPVPfSMS/vDHCUYIAU7Qxt8vCUfXBrPZybLIKARka/mvngX9w7q/dGxgfu11eJ+6AnsQBY/cSLUBjNPM3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=CsjUxl6O; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="CsjUxl6O" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1775056050; bh=dj4a7yIFkUuuOErayl1USgUNCE2PkTOo08S0tvg3kp0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CsjUxl6ODSyH+kAcxLlp1LZhBvhjtanp4LyrBW960MEZMOW7xq3lgcGOcFLD/+SIw GSBoW8870dlWS75EKKeCrvLeYtgxjjFktjyxlKfnSCFYawgzgkcpBvLMTvsXxxvrCG xnYP79yyn8Ppj42XMv9RlhKVeFa9B1Qv3PStPVjE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 01 Apr 2026 17:07:27 +0200 Subject: [PATCH 1/3] tools/nolibc: use __builtin_offsetof() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260401-nolibc-asprintf-v1-1-46292313439f@weissschuh.net> References: <20260401-nolibc-asprintf-v1-0-46292313439f@weissschuh.net> In-Reply-To: <20260401-nolibc-asprintf-v1-0-46292313439f@weissschuh.net> To: Willy Tarreau Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1775056050; l=916; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=dj4a7yIFkUuuOErayl1USgUNCE2PkTOo08S0tvg3kp0=; b=BWOAmifYTfooOp/hwM6OaQMepahdTB3crDfRTQAdnSK8yi0GKvlRAW/uW281DpyEG3QN0yf8x wys5bOecVagCvaugEPWAIIVga4qFjvepx6CPNTyi5YY+V47nnHAhCZx X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The current custom implementation of offsetof() fails UBSAN: runtime error: member access within null pointer of type 'struct ...' This means that all its users, including container_of(), free() and realloc(), fail. Use __builtin_offsetof() instead which does not have this issue and has been available since GCC 4 and clang 4. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/stddef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/stddef.h b/tools/include/nolibc/stddef.h index ecbd13eab1f5..a3976341afdd 100644 --- a/tools/include/nolibc/stddef.h +++ b/tools/include/nolibc/stddef.h @@ -18,7 +18,7 @@ #endif =20 #ifndef offsetof -#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD) +#define offsetof(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD) #endif =20 #endif /* _NOLIBC_STDDEF_H */ --=20 2.53.0