From patchwork Wed Jun 3 00:04:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 136341 X-Patchwork-Delegate: dj@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04D1D4BA2E2E for ; Wed, 3 Jun 2026 00:13:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04D1D4BA2E2E Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=IJljqe+E X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by sourceware.org (Postfix) with ESMTPS id 1EC504BA2E3A for ; Wed, 3 Jun 2026 00:07:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EC504BA2E3A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1EC504BA2E3A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780445239; cv=none; b=oStqGBlgPpDpbfQSGiGlc7oIL7naySNNIW/pYSRwQPIH0DDjPoPVnCfDxT9/8AF6ATYSuPjA2/KTgKTC6fi9sbY9nzBvj4eVdOBKZwWCJC8KCBcQhnQpeYjDghWXTmVPWfFfQLcdk36P7OnsI3GXHaw3kBBdWGLZ8UVMmYNuczA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780445239; c=relaxed/simple; bh=3uq8Yy2nIU+IMrW+c0BAUf3R0z/PAj8Q9cr6mvhqO/U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JT+TptAPc+gbyc9OS/vtsRmIKmNKXTVChgx6wB1x1G6w8JwCB6SqIWw/U2e6ucxKz+wlmU02fbzZcHgsJmhNVMvx4ck3NOBMkim+fYWEKGaS1Zq45Bap1Og2JymBk1gK0fpKvB/lEKQzLK09pVPU9povfnpoSribhIfSlzkvbLQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=IJljqe+E DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EC504BA2E3A Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-7ea16f090b4so8316477b3.2 for ; Tue, 02 Jun 2026 17:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780445238; x=1781050038; darn=sourceware.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; bh=RuPEPlWBm7V/cIZFKT1Bc0CuGf5WDZASciM4hscENsc=; b=IJljqe+EOznfKSDUeZ+FggNDwEKAwExfeECjmW3mdW6QfiTpnRUJjJzX/r//zR8mja n27LghoHYgwNWwEJxUUCyIXKWRHq0+NtD8UMC10W1yfmoSusAzrNaNNsdNi4WVkFKDdT runOhLXu1Dr7SCNQA+cs6rgTKvYXn7iQbKRWOUnRoSUlgRYM86BPHKpTJGvWNdMxICcg 0BA9IQgEahbhU/rt6nCLQWVTN4UzWsMloq6LOiXV2nOrGWibhhx+FAPQRO3SSvim1d1D Ex7pRkLOkgbU1ANKs4WCQkXddx1H5DA5hSzlc/h1xagzfU7z7rUHAz5lnFiCv8VoJcQS 0Baw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780445238; x=1781050038; 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; bh=RuPEPlWBm7V/cIZFKT1Bc0CuGf5WDZASciM4hscENsc=; b=pAJkIgkWqInKqlwlrh8lLNFJ+Uu0JOCsIaGxJcIKp1/I0bR2glGUoJ4U4EnI397CPX kRADsnPDQNohVeYi3st+Kq1V8I2O3Y6WmsHXRyD8ohvDWlXvtTVrZNjz/lHBcc4Bpbkk X6ngifCDpM7Nuru5zvgdVBrEJNnmSr4qi840Ix6Yeji2zqRuvC4ohkzN/1DcIZT///ky SfWhhXkQFeZWF9b1Y9/WHUkkKa9WCSUE7P7RDSpb9EwbXPDoJfRt59/qmCrAtcb+QLSC BbP2tHxncES4GCQBvc1GVc0qq0fDIyoXtsgxTiq30phYRMlv/RtjMVT/oBq27gts03W7 Egqw== X-Gm-Message-State: AOJu0YyBYU/0THJcPd7oHx+cbaR/peAVyqBXiWurCNHVHivq8Mh2R4Hh 3TI0YFQJYjSQkSy56Kok8oiOpo92bK/0ZG2TialXbODuP3LchfbwPKj3X7z9pYhZ41t1o1kJ6Pq aZhGd X-Gm-Gg: Acq92OH+P/O2M2lVWJafZr9O7FX/uSlqV5KLcNW4Y6+ufbsWSn54WQCuA9KKu6YCAz9 aylLJ9EtOKRJyRB8DQKGadYSw1YBzKBA8vKbxfiZn8jX7LeheIRtMDaw3byqM0RrQ7gTu50hHU7 WRnId3DWdeExrrn1B4CmE73suY165A0oxxR7kZ7Z0kM3oEa/0Ljliyy5qowmBjaoMmJacyTtBZs 2KeaugK/egSUlQrq/rwL9O96ulRo60WTQUCqelatadnHrU0v2YmDyWpWhP7EpZmyQeUX8iJM0Sp p7hkdn+DKOox8EBf8PhIKTduBvgp5cBsLLTBTEoaySjHBRrrJNA+d8qJVJwYDLq8pnUKWO0Fdmn /DpuJp4zOiObYInpw8sfWXF03waHCkNzld+YtYiEa0gG3PMQlLWQnX0m9AeWp5rEap8rjLBJ11Y 150JzyboPhyc6fzwayuEFOdnw6Z4YxUVVI1kEggxQhwpg0C1Iz/1alo2sV X-Received: by 2002:a05:690c:3587:b0:79b:d56a:a7c2 with SMTP id 00721157ae682-7ea4b9d7d15mr11752377b3.48.1780445238374; Tue, 02 Jun 2026 17:07:18 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:efc6:8f41:550d:2b14:9278]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7ea23a9946bsm7332207b3.37.2026.06.02.17.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 17:07:17 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Anderson Nascimento , Carlos O'Donell Subject: [PATCH 7/8] Consolidate dl-osinfo.h into the generic implementation Date: Tue, 2 Jun 2026 21:04:38 -0300 Message-ID: <20260603000656.3287796-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603000656.3287796-1-adhemerval.zanella@linaro.org> References: <20260603000656.3287796-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The generic and the Linux _dl_setup_stack_chk_guard and _dl_setup_pointer_guard are identical when the kernel provides the AT_RANDOM auxiliary vector, which is always the case on the supported Linux kernels; the generic version only adds a fallback for a missing AT_RANDOM. Remove the Linux-specific dl-osinfo.h and use the generic one for all targets. The removed header pulled in , which is what transitively declared __libc_enable_secure for dl-parse_auxv.h; include there directly so it no longer relies on that. Include in the generic header so it is self-contained. Reviewed-by: DJ Delorie --- sysdeps/generic/dl-osinfo.h | 1 + sysdeps/unix/sysv/linux/dl-osinfo.h | 54 ------------------------- sysdeps/unix/sysv/linux/dl-parse_auxv.h | 1 + 3 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/dl-osinfo.h diff --git a/sysdeps/generic/dl-osinfo.h b/sysdeps/generic/dl-osinfo.h index de46926abc9..5bb55cfe8a1 100644 --- a/sysdeps/generic/dl-osinfo.h +++ b/sysdeps/generic/dl-osinfo.h @@ -18,6 +18,7 @@ #include #include +#include static inline uintptr_t __attribute__ ((always_inline)) _dl_setup_stack_chk_guard (void *dl_random) diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h deleted file mode 100644 index 5ff92b76f96..00000000000 --- a/sysdeps/unix/sysv/linux/dl-osinfo.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Operating system specific code for generic dynamic loader functions. Linux. - Copyright (C) 2000-2026 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include -#include - -static inline uintptr_t __attribute__ ((always_inline)) -_dl_setup_stack_chk_guard (void *dl_random) -{ - union - { - uintptr_t num; - unsigned char bytes[sizeof (uintptr_t)]; - } ret; - - /* We need in the moment only 8 bytes on 32-bit platforms and 16 - bytes on 64-bit platforms. Therefore we can use the data - directly and not use the kernel-provided data to seed a PRNG. */ - memcpy (ret.bytes, dl_random, sizeof (ret)); -#if BYTE_ORDER == LITTLE_ENDIAN - ret.num &= ~(uintptr_t) 0xff; -#elif BYTE_ORDER == BIG_ENDIAN - ret.num &= ~((uintptr_t) 0xff << (8 * (sizeof (ret) - 1))); -#else -# error "BYTE_ORDER unknown" -#endif - return ret.num; -} - -static inline uintptr_t __attribute__ ((always_inline)) -_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard) -{ - uintptr_t ret; - memcpy (&ret, (char *) dl_random + sizeof (ret), sizeof (ret)); - return ret; -} diff --git a/sysdeps/unix/sysv/linux/dl-parse_auxv.h b/sysdeps/unix/sysv/linux/dl-parse_auxv.h index 69b6905f7ce..d1cd4373239 100644 --- a/sysdeps/unix/sysv/linux/dl-parse_auxv.h +++ b/sysdeps/unix/sysv/linux/dl-parse_auxv.h @@ -22,6 +22,7 @@ #include #include #include +#include /* For __libc_enable_secure. */ typedef ElfW(Addr) dl_parse_auxv_t[AT_MINSIGSTKSZ + 1];