debug: Fix clang open fortify wrapper (BZ 31927)

Message ID 20240628192018.137313-1-adhemerval.zanella@linaro.org
State Committed
Commit 9f80d8134a15235732586e238ac28cea459fb60b
Headers
Series debug: Fix clang open fortify wrapper (BZ 31927) |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Adhemerval Zanella Netto June 28, 2024, 7:20 p.m. UTC
  The clang open fortify wrapper from 4228baef1a94e8bde84ad74 added
a restriction where open with 3 arguments where flags do not
contain O_CREAT or O_TMPFILE are handled as invalid.  They are
not invalid, since the third argument is ignored, and the gcc
wrapper also allows it.

Checked x86_64-linux-gnu and with a yocto build for some affected
packages.
---
 io/bits/fcntl2.h | 5 -----
 1 file changed, 5 deletions(-)
  

Comments

Adhemerval Zanella Netto July 1, 2024, 7:49 p.m. UTC | #1
On 28/06/24 16:20, Adhemerval Zanella wrote:
> The clang open fortify wrapper from 4228baef1a94e8bde84ad74 added
> a restriction where open with 3 arguments where flags do not
> contain O_CREAT or O_TMPFILE are handled as invalid.  They are
> not invalid, since the third argument is ignored, and the gcc
> wrapper also allows it.
> 
> Checked x86_64-linux-gnu and with a yocto build for some affected
> packages.

If no-one opposes I will commit this shortly.

> ---
>  io/bits/fcntl2.h | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h
> index c8888b50c1..0cced392e7 100644
> --- a/io/bits/fcntl2.h
> +++ b/io/bits/fcntl2.h
> @@ -61,13 +61,8 @@ open (const char *__path, int __oflag, ...)
>    return __open_alias (__path, __oflag, __va_arg_pack ());
>  }
>  #elif __fortify_use_clang
> -__fortify_function_error_function __attribute_overloadable__ int
> -open (__fortify_clang_overload_arg (const char *, ,__path), int __oflag, ...)
> -     __fortify_clang_unavailable ("open can be called either with 2 or 3 arguments, not more");
> -
>  __fortify_function __attribute_overloadable__ int
>  open (__fortify_clang_overload_arg (const char *, ,__path), int __oflag)
> -     __fortify_clang_prefer_this_overload
>       __fortify_clang_error (__OPEN_NEEDS_MODE (__oflag),
>  			    "open with O_CREAT or O_TMPFILE in second argument needs 3 arguments")
>  {
  
Khem Raj July 1, 2024, 8:06 p.m. UTC | #2
Seems to work ok for the package otherwise was failing to build with clang

Tested-by: “Khem Raj <raj.khen@gmail.com>”

On Mon, Jul 1, 2024 at 12:49 PM Adhemerval Zanella Netto <
adhemerval.zanella@linaro.org> wrote:

>
>
> On 28/06/24 16:20, Adhemerval Zanella wrote:
> > The clang open fortify wrapper from 4228baef1a94e8bde84ad74 added
> > a restriction where open with 3 arguments where flags do not
> > contain O_CREAT or O_TMPFILE are handled as invalid.  They are
> > not invalid, since the third argument is ignored, and the gcc
> > wrapper also allows it.
> >
> > Checked x86_64-linux-gnu and with a yocto build for some affected
> > packages.
>
> If no-one opposes I will commit this shortly.
>
> > ---
> >  io/bits/fcntl2.h | 5 -----
> >  1 file changed, 5 deletions(-)
> >
> > diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h
> > index c8888b50c1..0cced392e7 100644
> > --- a/io/bits/fcntl2.h
> > +++ b/io/bits/fcntl2.h
> > @@ -61,13 +61,8 @@ open (const char *__path, int __oflag, ...)
> >    return __open_alias (__path, __oflag, __va_arg_pack ());
> >  }
> >  #elif __fortify_use_clang
> > -__fortify_function_error_function __attribute_overloadable__ int
> > -open (__fortify_clang_overload_arg (const char *, ,__path), int
> __oflag, ...)
> > -     __fortify_clang_unavailable ("open can be called either with 2 or
> 3 arguments, not more");
> > -
> >  __fortify_function __attribute_overloadable__ int
> >  open (__fortify_clang_overload_arg (const char *, ,__path), int __oflag)
> > -     __fortify_clang_prefer_this_overload
> >       __fortify_clang_error (__OPEN_NEEDS_MODE (__oflag),
> >                           "open with O_CREAT or O_TMPFILE in second
> argument needs 3 arguments")
> >  {
>
  

Patch

diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h
index c8888b50c1..0cced392e7 100644
--- a/io/bits/fcntl2.h
+++ b/io/bits/fcntl2.h
@@ -61,13 +61,8 @@  open (const char *__path, int __oflag, ...)
   return __open_alias (__path, __oflag, __va_arg_pack ());
 }
 #elif __fortify_use_clang
-__fortify_function_error_function __attribute_overloadable__ int
-open (__fortify_clang_overload_arg (const char *, ,__path), int __oflag, ...)
-     __fortify_clang_unavailable ("open can be called either with 2 or 3 arguments, not more");
-
 __fortify_function __attribute_overloadable__ int
 open (__fortify_clang_overload_arg (const char *, ,__path), int __oflag)
-     __fortify_clang_prefer_this_overload
      __fortify_clang_error (__OPEN_NEEDS_MODE (__oflag),
 			    "open with O_CREAT or O_TMPFILE in second argument needs 3 arguments")
 {