From patchwork Mon Jul 3 15:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1802856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=qVSX5vWi; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qvr216Bs7z20ZF for ; Tue, 4 Jul 2023 01:48:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1A5E385840B for ; Mon, 3 Jul 2023 15:48:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1A5E385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688399335; bh=WgcinOEUetU34xu6g+SjsuFx1b7Toa6w9U6LnfvGrFE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=qVSX5vWiBStKlsAFlvKwoZYl2xupiL0V7q2VnnWOLyt9RLlcWVsVlmsAL85VUeTdo OlHOmnHPBMKDaJuezMG3DqQ9vb4MlOhAXp4TP9TF4ayRoTX3FVdqUehOLGdIlMynUv 4ObzL0mLVkZawLxSj0u+VWWTg1UAvJ8roQVMAx6U= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id 7A0303858D28 for ; Mon, 3 Jul 2023 15:48:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A0303858D28 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-1b0627731d1so4716236fac.1 for ; Mon, 03 Jul 2023 08:48:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688399317; x=1690991317; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WgcinOEUetU34xu6g+SjsuFx1b7Toa6w9U6LnfvGrFE=; b=f6XKzVqfwGlBapb4th20EBhExA9fXdCRgJ6TDnNZPEFREHDXGgIJSGkPeTsy5RjBxY rcCc8fs7giTEO/K5LE+EXsmv3Jw6ZQrPnL6j2JzQf1bPo5hfdQBHbe+iVd29BXLJzW8X F2e21AOPBq7dQeAUiftwsG0QBml5AO0KiM30ck3P9hCxia0qVOuBq/KAZPxaUtkKRb1v xDnnL1A/6zEBa2z7v84PHlrqcTuNshIdf+F2kyIDvB/kbUzdcFG1pHvNb5mYLSbSMi9/ Twi/H2QNU17vJaveqwuJDzMEHvES1qJ4XM2nYQOiu5Jo1Yepgv+fhvj5IKV7mxzt8UYE n5mA== X-Gm-Message-State: ABy/qLaqhtQHuBdT5X7FSF156LBBkKDtH1FvzuEcU/xZlCaJPTqsDB5t ZqMOkWErmm18pxvHJJaJwdDybMeqpBqwMWZcTCeB9A== X-Google-Smtp-Source: ACHHUZ7PSONdelkac5WjAB8QawNALyxOurk+vV+g814pcDgNSo92nXt4L7KbIAv7ME0BhqtOwA00OA== X-Received: by 2002:a05:6870:1706:b0:192:5cba:4c10 with SMTP id h6-20020a056870170600b001925cba4c10mr12060150oae.40.1688399317436; Mon, 03 Jul 2023 08:48:37 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:665c:ecc5:4952:8dae:2a84]) by smtp.gmail.com with ESMTPSA id v21-20020a9d7d15000000b006b466ed0484sm6195143otn.67.2023.07.03.08.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 08:48:37 -0700 (PDT) To: libc-alpha@sourceware.org, Paul Pluzhnikov Cc: Alan Zhao Subject: [PATCH] debug: Fix fortified realpath C++ ODR violation (BZ 30516) Date: Mon, 3 Jul 2023 12:48:33 -0300 Message-Id: <20230703154833.3529850-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Although fortify wrappers are built with always_inline attribute, C++ modules imports a (precompiled) header module foo.pcm generated from foo.h which may differ if the translation unit includes or not limit.h. Although GCC does not fully support C++ modules yet, this is a problem when using C++ modules with clang. The build check is removed and the runtime check is improved with a better error message. Checked on x86_64-linux-gnu. --- debug/realpath_chk.c | 5 +++-- stdlib/bits/stdlib.h | 10 ---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/debug/realpath_chk.c b/debug/realpath_chk.c index adfc09237c..71a7e3ded3 100644 --- a/debug/realpath_chk.c +++ b/debug/realpath_chk.c @@ -16,17 +16,18 @@ . */ #include +#include #include #include #include - char * __realpath_chk (const char *buf, char *resolved, size_t resolvedlen) { #ifdef PATH_MAX if (resolvedlen < PATH_MAX) - __chk_fail (); + __fortify_fail ("second argument of realpah must be either NULL or at " + "least PATH_MAX bytes long buffer"); return __realpath (buf, resolved); #else diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h index c6c0082ad5..6c8854cab0 100644 --- a/stdlib/bits/stdlib.h +++ b/stdlib/bits/stdlib.h @@ -26,12 +26,6 @@ extern char *__realpath_chk (const char *__restrict __name, extern char *__REDIRECT_NTH (__realpath_alias, (const char *__restrict __name, char *__restrict __resolved), realpath) __wur; -extern char *__REDIRECT_NTH (__realpath_chk_warn, - (const char *__restrict __name, - char *__restrict __resolved, - size_t __resolvedlen), __realpath_chk) __wur - __warnattr ("second argument of realpath must be either NULL or at " - "least PATH_MAX bytes long buffer"); __fortify_function __wur char * __NTH (realpath (const char *__restrict __name, char *__restrict __resolved)) @@ -41,10 +35,6 @@ __NTH (realpath (const char *__restrict __name, char *__restrict __resolved)) if (sz == (size_t) -1) return __realpath_alias (__name, __resolved); -#if defined _LIBC_LIMITS_H_ && defined PATH_MAX - if (__glibc_unsafe_len (PATH_MAX, sizeof (char), sz)) - return __realpath_chk_warn (__name, __resolved, sz); -#endif return __realpath_chk (__name, __resolved, sz); }