public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/26] vfprintf rework to remove vtables
@ 2022-03-17 19:28 Florian Weimer
  2022-03-17 19:28 ` [PATCH 01/26] libio: Convert tst_swprintf to the test framework Florian Weimer
                   ` (25 more replies)
  0 siblings, 26 replies; 49+ messages in thread
From: Florian Weimer @ 2022-03-17 19:28 UTC (permalink / raw)
  To: libc-alpha

This started out as an attempt to fix bug 27124, the vtable hardening
bypass involving obstack_printf.

The new buffers are modeled after the write pointer/end pointer
abstraction used for inline putc_unlocked.  They have considerably lower
setup overhead than the internal stdio-compatible streams used by
sprintf.  Performance seems to be at least on par with the old
implementation, and a bit better for floating point formatting.

The new internal interfaces are added in commit “stdio-common: Introduce
buffers for implementing printf”.  The bulk of the conversions happen in
“stdio-common: Convert vfprintf and related functions to buffers”.
Initially, I converted things piece by piece, but that required
implementing additional bounce buffers for translation, so this one
commit converts the majority of the functions.  The commit message of
this large commit has some suggestions for review order.

Tested on i686-linux-gnu and x86_64-linux-gnu.  Built with
build-many-glibcs.py.

Thanks,
Florian

Florian Weimer (26):
  libio: Convert tst_swprintf to the test framework
  libio: Flush-only _IO_str_overflow must not return EOF (bug 28949)
  stdio-common: Add wide stream coverage to tst-vfprintf-user-type
  stdio-common: Add tst-printf-width-i18n to cover numeric field width
  vfprintf: Move argument processing into vfprintf-process-arg.c
  vfprintf: Consolidate some multibyte/wide character processing
  __printf_fphex always uses LC_NUMERIC
  stdio-common: Add tst-memstream-string for open_memstream overflow
  stdio-common: Add printf specifier registry to <printf.h>
  stdio-common: Move union printf_arg int <printf.h>
  stdio-common: Simplify printf_unknown interface in vfprintf-internal.c
  locale: Call _nl_unload_locale from _nl_archive_subfreeres
  locale: Remove cleanup function pointer from struct __localedata
  locale: Remove private union from struct __locale_data
  locale: Add more cached data to LC_CTYPE
  locale: Implement struct grouping_iterator
  stdio-common: Introduce buffers for implementing printf
  stdio-common: Add __printf_function_invoke
  stdio-common: Add __translated_number_width
  stdio-common: Convert vfprintf and related functions to buffers
  stdio-common: Add lock optimization to vfprintf and vfwprintf
  libio: Convert __vsprintf_internal to buffers
  libio: Convert __vasprintf_internal to buffers
  libio: Convert __vdprintf_internal to buffers
  libio: Convert __obstack_vprintf_internal to buffers (bug 27124)
  libio: Convert __vswprintf_internal to buffers (bug 27857)

 include/printf.h                              |   79 +-
 include/printf_buffer.h                       |  332 +++++
 libio/iovdprintf.c                            |   69 +-
 libio/iovsprintf.c                            |   70 +-
 libio/obprintf.c                              |  170 +--
 libio/strops.c                                |    5 +-
 libio/tst-vtables-common.c                    |    9 +-
 libio/tst_swprintf.c                          |  110 +-
 libio/vasprintf.c                             |  141 +-
 libio/vsnprintf.c                             |  131 +-
 libio/vswprintf.c                             |  100 +-
 libio/wstrops.c                               |    5 +-
 locale/C-address.c                            |    2 +-
 locale/C-collate.c                            |    2 +-
 locale/C-ctype.c                              |    9 +-
 locale/C-identification.c                     |    2 +-
 locale/C-measurement.c                        |    2 +-
 locale/C-messages.c                           |    2 +-
 locale/C-monetary.c                           |    2 +-
 locale/C-name.c                               |    2 +-
 locale/C-numeric.c                            |    2 +-
 locale/C-paper.c                              |    2 +-
 locale/C-telephone.c                          |    2 +-
 locale/C-time.c                               |    2 +-
 locale/findlocale.c                           |    2 +-
 locale/loadarchive.c                          |    8 +-
 locale/loadlocale.c                           |   89 +-
 locale/localeinfo.h                           |   48 +-
 locale/setlocale.c                            |    2 +-
 manual/stdio.texi                             |    7 +-
 stdio-common/Makefile                         |   29 +-
 stdio-common/Xprintf_buffer_done.c            |   40 +
 stdio-common/Xprintf_buffer_flush.c           |   72 +
 stdio-common/Xprintf_buffer_pad_1.c           |   44 +
 stdio-common/Xprintf_buffer_putc_1.c          |   29 +
 stdio-common/Xprintf_buffer_puts_1.c          |   37 +
 stdio-common/Xprintf_buffer_write.c           |   43 +
 stdio-common/Xprintf_function_invoke.c        |   42 +
 stdio-common/grouping_iterator.c              |  125 ++
 stdio-common/grouping_iterator.h              |   65 +
 stdio-common/printf-parse.h                   |   23 -
 stdio-common/printf_buffer-char.h             |   24 +
 stdio-common/printf_buffer-wchar_t.h          |   24 +
 stdio-common/printf_buffer_as_file.c          |  148 ++
 stdio-common/printf_buffer_as_file.h          |   87 ++
 stdio-common/printf_buffer_done.c             |   21 +
 stdio-common/printf_buffer_flush.c            |   81 ++
 stdio-common/printf_buffer_pad_1.c            |   21 +
 stdio-common/printf_buffer_putc_1.c           |   21 +
 stdio-common/printf_buffer_puts_1.c           |   21 +
 stdio-common/printf_buffer_to_file.c          |  122 ++
 stdio-common/printf_buffer_to_file.h          |   57 +
 stdio-common/printf_buffer_write.c            |   21 +
 stdio-common/printf_fp.c                      |  736 +++++-----
 stdio-common/printf_fphex.c                   |  271 ++--
 stdio-common/printf_function_invoke.c         |   22 +
 stdio-common/reg-printf.c                     |    7 -
 stdio-common/translated_number_width.c        |   42 +
 stdio-common/tst-grouping_iterator.c          |  262 ++++
 stdio-common/tst-memstream-string.c           |   85 ++
 stdio-common/tst-printf-width-i18n.c          |   95 ++
 stdio-common/tst-vfprintf-user-type.c         |  128 +-
 stdio-common/vfprintf-internal.c              | 1189 +++--------------
 stdio-common/vfprintf-process-arg.c           |  489 +++++++
 stdio-common/wprintf_buffer_as_file.c         |  153 +++
 stdio-common/wprintf_buffer_done.c            |   21 +
 stdio-common/wprintf_buffer_flush.c           |   42 +
 stdio-common/wprintf_buffer_pad_1.c           |   21 +
 stdio-common/wprintf_buffer_putc_1.c          |   21 +
 stdio-common/wprintf_buffer_puts_1.c          |   21 +
 stdio-common/wprintf_buffer_to_file.c         |   55 +
 stdio-common/wprintf_buffer_write.c           |   21 +
 stdio-common/wprintf_function_invoke.c        |   22 +
 stdlib/strfmon_l.c                            |  196 ++-
 stdlib/strfrom-skeleton.c                     |   38 +-
 sysdeps/ia64/fpu/printf_fphex.c               |    8 +-
 .../ieee754/ldbl-128/printf_fphex_macros.h    |   36 +-
 sysdeps/ieee754/ldbl-128ibm/printf_fphex.c    |   36 +-
 sysdeps/ieee754/ldbl-96/printf_fphex.c        |   22 +-
 sysdeps/x86_64/fpu/printf_fphex.c             |   21 +-
 time/alt_digit.c                              |   49 +-
 time/era.c                                    |   49 +-
 time/lc-time-cleanup.c                        |    5 +-
 wcsmbs/wcsmbsload.c                           |   27 +-
 wcsmbs/wcsmbsload.h                           |   11 +-
 85 files changed, 4275 insertions(+), 2531 deletions(-)
 create mode 100644 include/printf_buffer.h
 create mode 100644 stdio-common/Xprintf_buffer_done.c
 create mode 100644 stdio-common/Xprintf_buffer_flush.c
 create mode 100644 stdio-common/Xprintf_buffer_pad_1.c
 create mode 100644 stdio-common/Xprintf_buffer_putc_1.c
 create mode 100644 stdio-common/Xprintf_buffer_puts_1.c
 create mode 100644 stdio-common/Xprintf_buffer_write.c
 create mode 100644 stdio-common/Xprintf_function_invoke.c
 create mode 100644 stdio-common/grouping_iterator.c
 create mode 100644 stdio-common/grouping_iterator.h
 create mode 100644 stdio-common/printf_buffer-char.h
 create mode 100644 stdio-common/printf_buffer-wchar_t.h
 create mode 100644 stdio-common/printf_buffer_as_file.c
 create mode 100644 stdio-common/printf_buffer_as_file.h
 create mode 100644 stdio-common/printf_buffer_done.c
 create mode 100644 stdio-common/printf_buffer_flush.c
 create mode 100644 stdio-common/printf_buffer_pad_1.c
 create mode 100644 stdio-common/printf_buffer_putc_1.c
 create mode 100644 stdio-common/printf_buffer_puts_1.c
 create mode 100644 stdio-common/printf_buffer_to_file.c
 create mode 100644 stdio-common/printf_buffer_to_file.h
 create mode 100644 stdio-common/printf_buffer_write.c
 create mode 100644 stdio-common/printf_function_invoke.c
 create mode 100644 stdio-common/translated_number_width.c
 create mode 100644 stdio-common/tst-grouping_iterator.c
 create mode 100644 stdio-common/tst-memstream-string.c
 create mode 100644 stdio-common/tst-printf-width-i18n.c
 create mode 100644 stdio-common/vfprintf-process-arg.c
 create mode 100644 stdio-common/wprintf_buffer_as_file.c
 create mode 100644 stdio-common/wprintf_buffer_done.c
 create mode 100644 stdio-common/wprintf_buffer_flush.c
 create mode 100644 stdio-common/wprintf_buffer_pad_1.c
 create mode 100644 stdio-common/wprintf_buffer_putc_1.c
 create mode 100644 stdio-common/wprintf_buffer_puts_1.c
 create mode 100644 stdio-common/wprintf_buffer_to_file.c
 create mode 100644 stdio-common/wprintf_buffer_write.c
 create mode 100644 stdio-common/wprintf_function_invoke.c


base-commit: e297d33c73aa22c86228170343c7b2f9bfac6f1e
-- 
2.35.1


^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2022-05-23  7:20 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17 19:28 [PATCH 00/26] vfprintf rework to remove vtables Florian Weimer
2022-03-17 19:28 ` [PATCH 01/26] libio: Convert tst_swprintf to the test framework Florian Weimer
2022-03-18 17:40   ` Adhemerval Zanella
2022-03-17 19:28 ` [PATCH 02/26] libio: Flush-only _IO_str_overflow must not return EOF (bug 28949) Florian Weimer
2022-03-18 18:11   ` Adhemerval Zanella
2022-03-17 19:28 ` [PATCH 03/26] stdio-common: Add wide stream coverage to tst-vfprintf-user-type Florian Weimer
2022-03-18 18:30   ` Adhemerval Zanella
2022-03-18 19:19     ` Florian Weimer
2022-03-17 19:28 ` [PATCH 04/26] stdio-common: Add tst-printf-width-i18n to cover numeric field width Florian Weimer
2022-05-20 13:22   ` Adhemerval Zanella
2022-05-20 13:33     ` Adhemerval Zanella
2022-05-23  6:39       ` Florian Weimer
2022-03-17 19:28 ` [PATCH 05/26] vfprintf: Move argument processing into vfprintf-process-arg.c Florian Weimer
2022-05-20 13:28   ` Adhemerval Zanella
2022-03-17 19:28 ` [PATCH 06/26] vfprintf: Consolidate some multibyte/wide character processing Florian Weimer
2022-05-20 14:16   ` Adhemerval Zanella
2022-03-17 19:29 ` [PATCH 07/26] __printf_fphex always uses LC_NUMERIC Florian Weimer
2022-05-20 14:21   ` Adhemerval Zanella
2022-05-23  6:55     ` Florian Weimer
2022-03-17 19:29 ` [PATCH 08/26] stdio-common: Add tst-memstream-string for open_memstream overflow Florian Weimer
2022-05-20 17:44   ` Adhemerval Zanella
2022-05-23  7:03     ` Florian Weimer
2022-03-17 19:29 ` [PATCH 09/26] stdio-common: Add printf specifier registry to <printf.h> Florian Weimer
2022-05-20 17:49   ` Adhemerval Zanella
2022-03-17 19:30 ` [PATCH 10/26] stdio-common: Move union printf_arg int <printf.h> Florian Weimer
2022-05-20 17:51   ` Adhemerval Zanella
2022-03-17 19:30 ` [PATCH 11/26] stdio-common: Simplify printf_unknown interface in vfprintf-internal.c Florian Weimer
2022-05-20 18:07   ` Adhemerval Zanella
2022-03-17 19:30 ` [PATCH 12/26] locale: Call _nl_unload_locale from _nl_archive_subfreeres Florian Weimer
2022-05-20 18:09   ` Adhemerval Zanella
2022-05-23  7:14     ` Florian Weimer
2022-03-17 19:30 ` [PATCH 13/26] locale: Remove cleanup function pointer from struct __localedata Florian Weimer
2022-05-20 18:16   ` Adhemerval Zanella
2022-03-17 19:30 ` [PATCH 14/26] locale: Remove private union from struct __locale_data Florian Weimer
2022-05-20 18:22   ` Adhemerval Zanella
2022-03-17 19:30 ` [PATCH 15/26] locale: Add more cached data to LC_CTYPE Florian Weimer
2022-05-20 18:29   ` Adhemerval Zanella
2022-05-23  7:20     ` Florian Weimer
2022-03-17 19:31 ` [PATCH 16/26] locale: Implement struct grouping_iterator Florian Weimer
2022-03-17 19:31 ` [PATCH 17/26] stdio-common: Introduce buffers for implementing printf Florian Weimer
2022-03-17 19:31 ` [PATCH 18/26] stdio-common: Add __printf_function_invoke Florian Weimer
2022-03-17 19:31 ` [PATCH 19/26] stdio-common: Add __translated_number_width Florian Weimer
2022-03-17 19:31 ` [PATCH 20/26] stdio-common: Convert vfprintf and related functions to buffers Florian Weimer
2022-03-17 19:31 ` [PATCH 21/26] stdio-common: Add lock optimization to vfprintf and vfwprintf Florian Weimer
2022-03-17 19:31 ` [PATCH 22/26] libio: Convert __vsprintf_internal to buffers Florian Weimer
2022-03-17 19:31 ` [PATCH 23/26] libio: Convert __vasprintf_internal " Florian Weimer
2022-03-17 19:31 ` [PATCH 24/26] libio: Convert __vdprintf_internal " Florian Weimer
2022-03-17 19:32 ` [PATCH 25/26] libio: Convert __obstack_vprintf_internal to buffers (bug 27124) Florian Weimer
2022-03-17 19:32 ` [PATCH 26/26] libio: Convert __vswprintf_internal to buffers (bug 27857) Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).