string: Add hidden builtin definition for __strcpy_chk.

Message ID 20240205132206.1603576-1-stli@linux.ibm.com
State Committed
Commit fa3eb7d5e7d32ca1ad48b48a7eb6d15b8382c3a7
Headers
Series string: Add hidden builtin definition for __strcpy_chk. |

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 Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed

Commit Message

Stefan Liebler Feb. 5, 2024, 1:22 p.m. UTC
  Otherwise on at least x86_64 and s390x there is an unwanted PLT entry
in libc.so when configured with --enable-fortify-source and build
with -Os.

This is observed in elf/check-localplt
Extra PLT reference: libc.so: __strcpy_chk

The call to PLT entry is in inet/ruserpass.c.
---
 debug/strcpy_chk.c | 1 +
 include/string.h   | 1 +
 2 files changed, 2 insertions(+)
  

Comments

Adhemerval Zanella Netto Feb. 5, 2024, 6:12 p.m. UTC | #1
On 05/02/24 10:22, Stefan Liebler wrote:
> Otherwise on at least x86_64 and s390x there is an unwanted PLT entry
> in libc.so when configured with --enable-fortify-source and build
> with -Os.

I think it would be useful to add that it also requires --enable-fortify-source=3
to trigger it.

> 
> This is observed in elf/check-localplt
> Extra PLT reference: libc.so: __strcpy_chk
> 
> The call to PLT entry is in inet/ruserpass.c.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  debug/strcpy_chk.c | 1 +
>  include/string.h   | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/debug/strcpy_chk.c b/debug/strcpy_chk.c
> index e54780ddde..dd2c453417 100644
> --- a/debug/strcpy_chk.c
> +++ b/debug/strcpy_chk.c
> @@ -31,3 +31,4 @@ __strcpy_chk (char *dest, const char *src, size_t destlen)
>  
>    return memcpy (dest, src, len + 1);
>  }
> +libc_hidden_builtin_def (__strcpy_chk)
> diff --git a/include/string.h b/include/string.h
> index 86d1fa4abe..3b4c6007d7 100644
> --- a/include/string.h
> +++ b/include/string.h
> @@ -215,6 +215,7 @@ libc_hidden_builtin_proto (__mempcpy_chk)
>  libc_hidden_builtin_proto (__memset_chk)
>  libc_hidden_builtin_proto (__stpcpy_chk)
>  libc_hidden_builtin_proto (__strncpy_chk)
> +libc_hidden_builtin_proto (__strcpy_chk)
>  
>  #endif
>
  
Stefan Liebler Feb. 6, 2024, 8:19 a.m. UTC | #2
On 05.02.24 19:12, Adhemerval Zanella Netto wrote:
> 
> 
> On 05/02/24 10:22, Stefan Liebler wrote:
>> Otherwise on at least x86_64 and s390x there is an unwanted PLT entry
>> in libc.so when configured with --enable-fortify-source and build
>> with -Os.
> 
> I think it would be useful to add that it also requires --enable-fortify-source=3
> to trigger it.
I've double checked with my builds. For me it is also level 3. I've
adjusted it in the commit message.
> 
>>
>> This is observed in elf/check-localplt
>> Extra PLT reference: libc.so: __strcpy_chk
>>
>> The call to PLT entry is in inet/ruserpass.c.
> 
> LGTM, thanks.
> 
> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
> 
Thanks for reviewing. I've just committed the patch
  

Patch

diff --git a/debug/strcpy_chk.c b/debug/strcpy_chk.c
index e54780ddde..dd2c453417 100644
--- a/debug/strcpy_chk.c
+++ b/debug/strcpy_chk.c
@@ -31,3 +31,4 @@  __strcpy_chk (char *dest, const char *src, size_t destlen)
 
   return memcpy (dest, src, len + 1);
 }
+libc_hidden_builtin_def (__strcpy_chk)
diff --git a/include/string.h b/include/string.h
index 86d1fa4abe..3b4c6007d7 100644
--- a/include/string.h
+++ b/include/string.h
@@ -215,6 +215,7 @@  libc_hidden_builtin_proto (__mempcpy_chk)
 libc_hidden_builtin_proto (__memset_chk)
 libc_hidden_builtin_proto (__stpcpy_chk)
 libc_hidden_builtin_proto (__strncpy_chk)
+libc_hidden_builtin_proto (__strcpy_chk)
 
 #endif