libio: Fix oversized __io_vtables

Message ID 20230907193828.126271-1-ajax@redhat.com
State Superseded
Headers
Series libio: Fix oversized __io_vtables |

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

Adam Jackson Sept. 7, 2023, 7:38 p.m. UTC
  IO_VTABLES_LEN is the expected size of the struct in bytes, not the
number of __IO_jump_t's in the array. Drops just under 384kb from
.rodata on LP64 machines.

Fixes: 3020f72618e ("libio: Remove the usage of __libc_IO_vtables")
Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 libio/vtables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Florian Weimer Sept. 8, 2023, 11:20 a.m. UTC | #1
* Adam Jackson:

> IO_VTABLES_LEN is the expected size of the struct in bytes, not the
> number of __IO_jump_t's in the array. Drops just under 384kb from
> .rodata on LP64 machines.

Ouch, thanks for spotting this.

I think it's this Debian and Ubuntu bug:

  djbdns: Fix for tests with new glibc 2.38
  <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050371>

  tinydns: allocation failures with glibc 2.38/s390x
  <https://bugs.launchpad.net/ubuntu/+source/djbdns/+bug/2031909>

> Fixes: 3020f72618e ("libio: Remove the usage of __libc_IO_vtables")
> Signed-off-by: Adam Jackson <ajax@redhat.com>
> ---
>  libio/vtables.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libio/vtables.c b/libio/vtables.c
> index 1d8ad612e94..7cb894d751d 100644
> --- a/libio/vtables.c
> +++ b/libio/vtables.c
> @@ -86,11 +86,11 @@
>  
>  # pragma weak __wprintf_buffer_as_file_overflow
>  # pragma weak __wprintf_buffer_as_file_xsputn
>  #endif
>  
> -const struct _IO_jump_t __io_vtables[IO_VTABLES_LEN] attribute_relro =
> +const struct _IO_jump_t __io_vtables[IO_VTABLES_NUM] attribute_relro =
>  {
>    /* _IO_str_jumps  */
>    [IO_STR_JUMPS] =
>    {
>      JUMP_INIT_DUMMY,

Maybe use [] and

_Static_assert (array_length (__io_vtables) == IO_VTABLES_NUM,
                "initializer count);

after the definition?

Let me know if you want to make this change.  I've got a machine
checkout that can build glibc on all supported architectures fairly
quickly.

Thanks,
Florian
  
Adam Jackson Sept. 8, 2023, 7:54 p.m. UTC | #2
On Fri, Sep 8, 2023 at 7:20 AM Florian Weimer <fweimer@redhat.com> wrote:

Maybe use [] and
>
> _Static_assert (array_length (__io_vtables) == IO_VTABLES_NUM,
>                 "initializer count);
>
> after the definition?
>
> Let me know if you want to make this change.  I've got a machine
> checkout that can build glibc on all supported architectures fairly
> quickly.
>

Sure. I'll send a new patch, I spotted a grammar-o in the commit message.

- ajax
  

Patch

diff --git a/libio/vtables.c b/libio/vtables.c
index 1d8ad612e94..7cb894d751d 100644
--- a/libio/vtables.c
+++ b/libio/vtables.c
@@ -86,11 +86,11 @@ 
 
 # pragma weak __wprintf_buffer_as_file_overflow
 # pragma weak __wprintf_buffer_as_file_xsputn
 #endif
 
-const struct _IO_jump_t __io_vtables[IO_VTABLES_LEN] attribute_relro =
+const struct _IO_jump_t __io_vtables[IO_VTABLES_NUM] attribute_relro =
 {
   /* _IO_str_jumps  */
   [IO_STR_JUMPS] =
   {
     JUMP_INIT_DUMMY,