From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7BF6D3858D28 for ; Tue, 20 Feb 2024 22:05:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BF6D3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7BF6D3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708466733; cv=none; b=oX6STSW6Kx7EooTDCip41DLts6HWK1byCSW8UDb2zbVyJNOnrY9JE+7VnWdsgPBTOKlxWfSl1OiLpRw116Gpi/gL6TeUj/HxF5HSh4S3k2IAwozO34AncXZDRvOzK2Yj9CZMNRe4mIA6biTK+PUl1rhHjPNgfSk4r5XxeNXSbxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708466733; c=relaxed/simple; bh=cDNMg3YyMSkd9eb6dVSW8Xb8LiWP4n5QVRnMWTWx3JE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=wAjOdjSVzi5pmYdbAb9NIzdBvoccqVq8pXgjVf8ifU+2iwL7zU6EMZeBlIR7zJWDGFOvrmP/zqUGkAG3E8EQDWMJMl/v3xSIRbSkUYwrPa4EWq4ir9WsCa6LUVe0X/g+wSZJMp9/ZG/dO/IUA0uQHFfU1QWbe34drGxAxiCQqyE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708466727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qImMcDqjurwzPnnmkeXI47WiHuP1fS28Nq2curaU890=; b=VVxPn9/8Ki8Zkf+3L1liNmic8briHfGonT11nV5dGNrrNGa2PcIc7BMl3EBfvdS3gZHw2n vVAWM1r3xoANDLXDpuzjEV9SRkqROTrObZvjBgtAvEcidp/SjKlpAsVLEJ2p97cKFdxqKp 3XSG3HHt88hSpJfi9Eek/3aTNyQhgDM= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-yybWvZgKMMaJ4cBpt3hinQ-1; Tue, 20 Feb 2024 17:05:26 -0500 X-MC-Unique: yybWvZgKMMaJ4cBpt3hinQ-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-42dc9d738cfso65807941cf.2 for ; Tue, 20 Feb 2024 14:05:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708466725; x=1709071525; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qImMcDqjurwzPnnmkeXI47WiHuP1fS28Nq2curaU890=; b=TrHCq3w/zLCew0JwM4H/LycCmDEXIu5Hb6yO/BZnotqdH5jw0vrvL5w1JFNW/Ic92R LCfc7RCoWXQqRXVVKMutbKK75jqNzWyGgf562xH+VmMJtPlm82ByRcFenvktLaZpUbxb 2SWVtl1bwvZuX/g0r+BPedNWSDg6EfcYHTTFShKCaC3ipHHu2W9i3q7QFgWzpx7Ezlxr +jCh0MeMPCGhu7m0BaPRSfNrcSuGpb0/1GpI8bUd85RFHp478xg82iMNoFber3OQoLIb 6tS6dTKRIhxYDmbCPWmUpL82d0zRnNwung9/v/Rfm57VByd9s2p5gwCVzmk68Pm7t8tQ GT8A== X-Forwarded-Encrypted: i=1; AJvYcCXLoUwlGSusKoqo/tARYHnvPyZPh0/kC8+9CX/HQzIHvNEfvxR9WaHPIxlw/+VhFh/vmNyFRkrj2/BSD47Ad2qreSLmClsP9zxL X-Gm-Message-State: AOJu0YzYoWgsANUrAp7S/OX6FCDSebKAw57p5NLXr/Fiwa0cPmYCrzV+ yrGAJ127oEdB8rLhdHAeq2bBeN9R2Du8H5D9l6tjASRG1TTp46KToPcfZR3Wbreg651Brf8f8u+ fPHLwmj1TpNiQ4Qqw2+BZAG+K19XHTppvS0wvALgEckYUmKMLD2zUYseByg== X-Received: by 2002:a05:622a:3d0:b0:42c:71ea:9b28 with SMTP id k16-20020a05622a03d000b0042c71ea9b28mr22410636qtx.32.1708466725010; Tue, 20 Feb 2024 14:05:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7r8ZSK4tYXYhetXzl79DlogcYiE5FXjl7s4zXC5A2fckDQYwIepvpFBd6P/KSR00DDhI3uw== X-Received: by 2002:a05:622a:3d0:b0:42c:71ea:9b28 with SMTP id k16-20020a05622a03d000b0042c71ea9b28mr22410409qtx.32.1708466723049; Tue, 20 Feb 2024 14:05:23 -0800 (PST) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id i11-20020ac871cb000000b0042dfb466c85sm3200509qtp.64.2024.02.20.14.05.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Feb 2024 14:05:22 -0800 (PST) Message-ID: Date: Tue, 20 Feb 2024 17:05:22 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 10/10] debug: Improve mqueue.h fortify warnings with clang To: Adhemerval Zanella , libc-alpha@sourceware.org Cc: Siddhesh Poyarekar References: <20240208184622.332678-1-adhemerval.zanella@linaro.org> <20240208184622.332678-11-adhemerval.zanella@linaro.org> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <20240208184622.332678-11-adhemerval.zanella@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,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 List-Id: On 2/8/24 13:46, Adhemerval Zanella wrote: > It improve mq_open. The compile and runtime checks have similar > coverage as with GCC. > LGTM. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell > Checked on aarch64, armhf, x86_64, and i686. > --- > rt/bits/mqueue2.h | 29 +++++++++++++++++++++++++++++ > rt/mqueue.h | 3 +-- > 2 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/rt/bits/mqueue2.h b/rt/bits/mqueue2.h > index 0f9d67966f..d6d2d9012d 100644 > --- a/rt/bits/mqueue2.h > +++ b/rt/bits/mqueue2.h > @@ -29,6 +29,8 @@ extern mqd_t __mq_open_2 (const char *__name, int __oflag) > extern mqd_t __REDIRECT_NTH (__mq_open_alias, (const char *__name, > int __oflag, ...), mq_open) > __nonnull ((1)); > + > +#ifdef __va_arg_pack_len > __errordecl (__mq_open_wrong_number_of_args, > "mq_open can be called either with 2 or 4 arguments"); > __errordecl (__mq_open_missing_mode_and_attr, > @@ -55,3 +57,30 @@ __NTH (mq_open (const char *__name, int __oflag, ...)) > > return __mq_open_alias (__name, __oflag, __va_arg_pack ()); > } > +#elif __fortify_use_clang > +__fortify_function_error_function __attribute_overloadable__ mqd_t > +__NTH (mq_open (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)) > + __fortify_clang_prefer_this_overload > + __fortify_clang_error ((__oflag & O_CREAT), > + "mq_open with O_CREAT in second argument needs 4 arguments") > +{ > + 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); > +} OK. > +#endif > diff --git a/rt/mqueue.h b/rt/mqueue.h > index 787cc36df2..d39334ba16 100644 > --- a/rt/mqueue.h > +++ b/rt/mqueue.h > @@ -110,8 +110,7 @@ extern int __REDIRECT (mq_timedsend, (mqd_t __mqdes, > #endif > > /* Define some inlines helping to catch common problems. */ > -#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \ > - && defined __va_arg_pack_len > +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function OK. > # include > #endif > -- Cheers, Carlos.