From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id 3B1313858C98 for ; Sat, 22 Jun 2024 05:23:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B1313858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3B1313858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719033829; cv=none; b=wnaq39f7swdq3MKt9PalwJ0xhAB7OhZCaUCAp0NjQWQ2I/ez+ihwCPsr7w7+jhzSOVGsKA+OEHMYRD5EghP6FRvATJPw/fjziWJCqwlRKLhWHAmhH3Pdit6ELgGvXA0p1wO0N4CWJMS1AwC8OB+Z+z7jSbYzbdD7qPge4HHP6dQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719033829; c=relaxed/simple; bh=cTJIxzLfUhLlgDRH6lUj/JTD0lL9ZoPT1P8o7U88WaI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=n4cwrq2l/i38d2xu7D7/EftzjAfqD71g5EqQOF8BQmbVsqDvEURv0Cx8KTslFvdZYbvMrTR15OJDo5sZObA60rqCkVZHUCqqxdWfwE8v3RHtd7N5bSEi3IsFKbaGcIadyWGo/4XyDuZ7hdTwoCfoBpD8FE0oW4RxGYlToKjDrNw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-25caf76158cso1532389fac.0 for ; Fri, 21 Jun 2024 22:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719033826; x=1719638626; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ts3bXpUiP/QYOeoz1UmQQrfmxR9fbI2jy7jE9bnQRFo=; b=g6AVkZKi3gJRhHYdnOesapZNvGHsKFTdtashbDYtYJjIz3JUtkOIX2zf1Pb2K688wN g0zVgszvW9sQIeIxZM7RWPZOPw1IkSL5uY49QcEAIhwyCghHuAHClw81rPvW+8HH/L/E 249HRsTYR7Edpt1I6s3At/n3cVz0WPoq0tCe3eJS7aDIbaXPCsT0UCGwBfHEOyx3czXe FkrjihgYheV/QTJxLUuw3dIFG72B+AsAG62Sl3p4iHLjYlzs119MUXLvZyWD/YtH0Wm2 bcnGQW4FGZI3hjOBeaBPcUHHL+J1dp9jbQBuG4U75qacdga1QXCdVU0BW/Le/HDZHCmm jytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719033826; x=1719638626; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ts3bXpUiP/QYOeoz1UmQQrfmxR9fbI2jy7jE9bnQRFo=; b=kOlYky0RmdfI9qz6TQS9zNQ1zw5rVTkVv6G6E3w9gvLbA3DHT7C58egv825XLX6IHt R0zLhtlWRekEojUELp7Jo7WNRR21bhyc+QZg2b5tm2Wk6qeMHCGmQttbd2N/zFOBjjYV DmlIIl7w1PuuGqZfKI3NjiK6sESGbmvSld7evPZNhR0gdygte3ncetfwgdSOnPbRbi/q mOCOhY77TRmwwBfh5P8Jpfma7CCjH/T7L7Py/PLnRAv/YoeLGTF/ZT6B19HOeODWzKFk 8uV5Jaq0NgokkK1EanObOULWnFeB0K3TIIU3WOX4ih92n01B/6a4wBZM0BonsALI//3I opmA== X-Gm-Message-State: AOJu0YwNdeDEKzacjfmJIK2zImAs5OOShELUXUDPBM0rimnjtUuC5gzw BRUTOEi0AvIpzp+kTXQNpY8cDXO2wk0V03n+inl7qUzlHXMMm9GW5wzx54t+Y6ZkUyOIeagQf82 sC5VAaBIcDTZKZ6IpOFwuyRuLRMdVfQ== X-Google-Smtp-Source: AGHT+IHxsN2njHagIu+5/QzB4aQ0Nknnx3r3VM+o0ZBgFt6sCKn7WWFY/DVOeFBdNzJs479okCA0HtflURknOG+ffzk= X-Received: by 2002:a05:6870:b52c:b0:254:9ded:a3b7 with SMTP id 586e51a60fabf-25c94dc5e75mr10808004fac.56.1719033826229; Fri, 21 Jun 2024 22:23:46 -0700 (PDT) MIME-Version: 1.0 References: <20240621140841.2628624-1-adhemerval.zanella@linaro.org> In-Reply-To: <20240621140841.2628624-1-adhemerval.zanella@linaro.org> From: Khem Raj Date: Fri, 21 Jun 2024 22:23:19 -0700 Message-ID: Subject: Re: [PATCH] debug: Fix clang mq_open fortify wrapper (BZ 31917) To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 List-Id: This works ok here with clang/main and failing cases are working fine. Acked-by: Khem Raj On Fri, Jun 21, 2024 at 7:08=E2=80=AFAM Adhemerval Zanella wrote: > > 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: m= q_open can be called either with 2 or 4 arguments > 119 | mqd =3D mq_open(name, oflag, opt_mode, NULL); > | ^ > [...] /usr/include/bits/mqueue2.h:66:8: note: 'mq_open' has been explic= itly 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 > --- > 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 o= r 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 o= r 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 ch= ar *, ,__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 > -- > 2.43.0 >