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 X-Patchwork-Id: 806343 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp786130wrt; Fri, 21 Jun 2024 07:09:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCKKYaJvBpVJp1+qPkDfugVJ3FsA0HkmoZh4tyw2FTA3tnQBCxClibs+CCxWr1PV+jQdZk5eLnvJu124M8WSqK X-Google-Smtp-Source: AGHT+IHI7wjqv3GoiFKp2phe2rzg4Ld9SOyLYuaEssa2R2TYpEsvotz80mTCLS9U5vBf+om+tCcM X-Received: by 2002:a67:f954:0:b0:48d:9440:eece with SMTP id ada2fe7eead31-48f130d0706mr9727605137.34.1718978954129; Fri, 21 Jun 2024 07:09:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718978954; cv=pass; d=google.com; s=arc-20160816; b=exby9Dh5x5dBlC1zzmuN1ngKoR8tng0qRG+dB9X74S3hWVT9Pj30xEmBLLRcUy/CLu boF/95D+1RHSX9bWG2M8hokoM0/EZYLYBS0/LI8F3HaR8EnHOC8nMdv5UP99VYuuQpV3 rRDHWxICNIDifoMzrs0QZW+sVrBWpqrLrwmk8NsWT/4JqrqcBYW4g+E+T/ttIUJ3Pxqt 7KGkp3r6CO6DMi9H04lRImyLBHHI1b3ft8RoVRg6TyvdbKORIZ106cKIwMhhElA3/nxm gXAEGfQPLjHwKSSDb0olP62w2hW7Y5EIzITZ3M3B0JdktvJwRsXCD/sHDRa4EnA40Jqk P//A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=kJKQwKUn4FYDQe68ndDWEVDv/pY6i6s75q9cEs/3iZM=; fh=KB0OPycOJdCInX1nDEXFfy0M5ixXnsWAZ87F/u4DCeg=; b=DAxXyHqXwVahR1ttD5znUbEHIl2VoFaZn0YLJBBqfLWmDJhk4wiciWhE975IAQtvlX m8kmujG+QFWvRKFcr8d4hJShZerJVMxlVhzzArog76WzvYPZagPyUHbr1+avZUI/oTmR 8ONhU6kbR4Q1vup948E1XiSPeyCX3z+6JHIgTrvIDTW9UpCdZfjdG2PP7sOhA1/ipuS5 RyxHyXL9h4VlLISc0AHpNaCYxOfiYmqBUufzybdcy+mwvt8oNrvkkEjattQfPZmgdd3X eo70to8Ci0LVUnPSlsMOQh2vMFCB9rUFqRWWYzAeq3KnyyeetbPYET1scyzC75dfULi+ osug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zDyk1DO1; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ada2fe7eead31-48f33163ee3si263638137.226.2024.06.21.07.09.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 07:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zDyk1DO1; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B41633898C69 for ; Fri, 21 Jun 2024 14:09:13 +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-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+patch=linaro.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