From patchwork Fri Jun 21 14:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1950810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=zDyk1DO1; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W5K3h4SbZz1ydW for ; Sat, 22 Jun 2024 00:09:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E158D3895FE3 for ; Fri, 21 Jun 2024 14:09:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 0CFAB3895FE3 for ; Fri, 21 Jun 2024 14:08:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0CFAB3895FE3 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 0CFAB3895FE3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718978943; cv=none; b=uLCRfg23GXVuBmVfUkdHU4B24x55NBDnXJpPWGr6CtX4Xd047++V90mZvWI9BGUTynwkUzcIiGeWUOL+KH0+In8vH+4sbOoUujo414bDo1fqCMo1iiXqn801wlkJNv054pGr5SBfyp/oUt1npuW0aQXIwzCuqbKQncXyh/JweQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718978943; c=relaxed/simple; bh=aDeCOVLhbnToHlgmhQLfKEyr6qyrZAxp4E//6VEIChU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=I3MYBG/td+ETx68fpZX9k9RSbt8JfxebCaKLSipEZ30yCPK7JTGXQ1nFDSsucQmQffOxG8RZZkH1IclpjkWv9Iogsm4PrNeGP4zFvA2eOTsrGgSiVDckFmq1Yhw4iU7nQTEASCTWHJaeqNP/xS5B2f6+Ad233LrVcR2IdYpl6fk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1f9ffd24262so1594865ad.0 for ; Fri, 21 Jun 2024 07:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718978936; x=1719583736; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kJKQwKUn4FYDQe68ndDWEVDv/pY6i6s75q9cEs/3iZM=; b=zDyk1DO1DTfbzpnfm3c8hzCr1La/cAHP2A/TQf8QUpQLGtHJZB6uVzyTn6eFi8xPmP y0qOmpsy91cuc77XQESGR4peUpKA77rXP0afE9znDPOfbsmiO0ONS8s3zy6M1EIR5mWF A2gqHD6GDq0WC+zWqalAdDffGAs4eKHd5vfaQfntMtudykpHsK/LtljhjgMHD3fVPBc+ ZexoioO/2jO0m/HUn8hDtHnRx3GFthhqYtp/qUFeqMud9t+hXGa6L9UGdMKoN5I+szK5 VlVQpOTchTPZQ5Hs6YHfcEbFMk8SeQBc7Y9YZb7lmK9ksH8CI7uYeC6k7okeSYab1l85 E8YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718978936; x=1719583736; 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=kJKQwKUn4FYDQe68ndDWEVDv/pY6i6s75q9cEs/3iZM=; b=FIwm5t06CuiWMvpQu8DWe0HR69l+E8TZB63voGMZnrSRp6mVJfSLutdmMICR6zzFeO Za3gt1KJwa9bfRxX9OpgCWTFi0Tlm3TL10innxpLS2KVe/bxEKNxasbfokEeR67OvdDE ITQ3+3pGs22Rf6f5QnVo0GDYC5A4RP+0LCwQDW5KujIlMO7I1ja0D3pMXvSMm+h8voz+ SqQ/hU/dsdba3kRSmsgUNrR+wwsO96cIAlwrP/hcCA888wJ3Y6cBd6Kq7MNyuqr00C1K XifPmJkL8UehxpfG4YUc3tBX3GixHvHYflDE1F1zZw1MAKF8tN6GLguVZGs8jzhh15cd 1lTQ== X-Gm-Message-State: AOJu0Yxx4rB+WdleQ0NcPYDYbhx/hiae8/8tiaIPHgzE5fUwYol1Qidi rYWC83CFz32Zxa9pDlP2K43KLNrigeFvw6j2gUyzqREpmC+87ayHg2VAKND4qShSK8de1859n02 7 X-Google-Smtp-Source: AGHT+IFfs3qOYKAaFJA0ErtTNkISTh3cSdC1Ux8bsHGku1/Gy5uQMzRlOmcBn9pJAFA87wvSSe+b9g== X-Received: by 2002:a17:902:c406:b0:1f9:f3c6:ed37 with SMTP id d9443c01a7336-1f9f3c6f300mr15871515ad.14.1718978936285; Fri, 21 Jun 2024 07:08:56 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:5c0d:bc8d:79a8:98f2:1692]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9ebbba8dasm14290175ad.279.2024.06.21.07.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 07:08:55 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Khem Raj Subject: [PATCH] debug: Fix clang mq_open fortify wrapper (BZ 31917) Date: Fri, 21 Jun 2024 11:08:38 -0300 Message-ID: <20240621140841.2628624-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org The mqueue.h fortify wrapper for clang added by c23107effbfe5300 is not fully correct, where correct 4 argument usage are not being correctly handled. For instance, while building socat 1.8 with a yocto clang based system shows: ./socat-1.8.0.0/xio-posixmq.c:119:8: error: 'mq_open' is unavailable: mq_open can be called either with 2 or 4 arguments 119 | mqd = mq_open(name, oflag, opt_mode, NULL); | ^ [...] /usr/include/bits/mqueue2.h:66:8: note: 'mq_open' has been explicitly marked unavailable here 66 | __NTH (mq_open (const char *__name, int __oflag, mode_t mode, | ^ 1 error generated. The correct way to define the wrapper is to set invalid usage with __fortify_clang_unavailable (for the case with 5 or more arguments), followed by the expected ones. This fix make mq_open similar to current open wrappers. [1] http://www.dest-unreach.org/socat/ Reported-by: Khem Raj Acked-by: Khem Raj --- rt/bits/mqueue2.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/rt/bits/mqueue2.h b/rt/bits/mqueue2.h index d6d2d9012d..386404c0c8 100644 --- a/rt/bits/mqueue2.h +++ b/rt/bits/mqueue2.h @@ -59,13 +59,16 @@ __NTH (mq_open (const char *__name, int __oflag, ...)) } #elif __fortify_use_clang __fortify_function_error_function __attribute_overloadable__ mqd_t -__NTH (mq_open (const char *__name, int __oflag, mode_t mode)) +__NTH (mq_open (__fortify_clang_overload_arg (const char *, , __name), + int __oflag, mode_t __mode, ...)) __fortify_clang_unavailable ("mq_open can be called either with 2 or 4 arguments"); -__fortify_function_error_function __attribute_overloadable__ mqd_t -__NTH (mq_open (const char *__name, int __oflag, mode_t mode, - struct mq_attr *attr, ...)) - __fortify_clang_unavailable ("mq_open can be called either with 2 or 4 arguments"); +__fortify_function __attribute_overloadable__ mqd_t +__NTH (mq_open (__fortify_clang_overload_arg (const char *, ,__name), + int __oflag, mode_t __mode, struct mq_attr *__attr)) +{ + return __mq_open_alias (__name, __oflag, __mode, __attr); +} __fortify_function __attribute_overloadable__ mqd_t __NTH (mq_open (__fortify_clang_overload_arg (const char *, ,__name), @@ -76,11 +79,4 @@ __NTH (mq_open (__fortify_clang_overload_arg (const char *, ,__name), { return __mq_open_alias (__name, __oflag); } - -__fortify_function __attribute_overloadable__ mqd_t -__NTH (mq_open (__fortify_clang_overload_arg (const char *, ,__name), - int __oflag, int __mode, struct mq_attr *__attr)) -{ - return __mq_open_alias (__name, __oflag, __mode, __attr); -} #endif