[05/11] syslog: Build with fortification

Message ID 3025a0556566ebbe0955666387d1285b39605de4.1707491940.git.fweimer@redhat.com (mailing list archive)
State Accepted
Delegated to: Adhemerval Zanella Netto
Headers
Series Build getdomainname, gethostname, syslog with fortification |

Checks

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

Commit Message

Florian Weimer Feb. 9, 2024, 3:25 p.m. UTC
  This causes /proc/self/maps to be processed for certain syslog calls
due to the use of %n.
---
 misc/Makefile      | 5 -----
 misc/bits/syslog.h | 4 ++++
 misc/syslog.c      | 3 +++
 3 files changed, 7 insertions(+), 5 deletions(-)
  

Comments

Adhemerval Zanella Feb. 13, 2024, 12:26 p.m. UTC | #1
On 09/02/24 12:25, Florian Weimer wrote:
> This causes /proc/self/maps to be processed for certain syslog calls
> due to the use of %n.

LGTM, thanks.

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

> ---
>  misc/Makefile      | 5 -----
>  misc/bits/syslog.h | 4 ++++
>  misc/syslog.c      | 3 +++
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/misc/Makefile b/misc/Makefile
> index 6d8528c925..236076a9d6 100644
> --- a/misc/Makefile
> +++ b/misc/Makefile
> @@ -207,11 +207,6 @@ routines := \
>    writev \
>    # routines
>  
> -# Exclude fortified routines from being built with _FORTIFY_SOURCE
> -routines_no_fortify += \
> -  syslog \
> -  # routines_no_fortify
> -
>  generated += \
>    tst-allocate_once-mem.out \
>    tst-allocate_once.mtrace \
> diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h
> index aadcd42000..e6f7938a3f 100644
> --- a/misc/bits/syslog.h
> +++ b/misc/bits/syslog.h
> @@ -31,11 +31,13 @@
>     redirections, e.g. long double asm redirections.  */
>  
>  #ifdef __va_arg_pack
> +# ifndef __glibc_nofortify_syslog
>  __fortify_function void
>  syslog (int __pri, const char *__fmt, ...)
>  {
>    __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
>  }
> +# endif
>  #elif !defined __cplusplus
>  # define syslog(pri, ...) \
>    __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
> @@ -43,9 +45,11 @@ syslog (int __pri, const char *__fmt, ...)
>  
>  
>  #ifdef __USE_MISC
> +# ifndef __glibc_nofortify_vsyslog
>  __fortify_function void
>  vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
>  {
>    __vsyslog_chk (__pri,  __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
>  }
> +# endif
>  #endif
> diff --git a/misc/syslog.c b/misc/syslog.c
> index 4af87f54fd..68ee3aef5f 100644
> --- a/misc/syslog.c
> +++ b/misc/syslog.c
> @@ -27,6 +27,9 @@
>   * SUCH DAMAGE.
>   */
>  
> +#define __glibc_nofortify_syslog
> +#define __glibc_nofortify_vsyslog
> +
>  #if defined(LIBC_SCCS) && !defined(lint)
>  static char sccsid[] = "@(#)syslog.c	8.4 (Berkeley) 3/18/94";
>  #endif /* LIBC_SCCS and not lint */
  

Patch

diff --git a/misc/Makefile b/misc/Makefile
index 6d8528c925..236076a9d6 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -207,11 +207,6 @@  routines := \
   writev \
   # routines
 
-# Exclude fortified routines from being built with _FORTIFY_SOURCE
-routines_no_fortify += \
-  syslog \
-  # routines_no_fortify
-
 generated += \
   tst-allocate_once-mem.out \
   tst-allocate_once.mtrace \
diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h
index aadcd42000..e6f7938a3f 100644
--- a/misc/bits/syslog.h
+++ b/misc/bits/syslog.h
@@ -31,11 +31,13 @@ 
    redirections, e.g. long double asm redirections.  */
 
 #ifdef __va_arg_pack
+# ifndef __glibc_nofortify_syslog
 __fortify_function void
 syslog (int __pri, const char *__fmt, ...)
 {
   __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
 }
+# endif
 #elif !defined __cplusplus
 # define syslog(pri, ...) \
   __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
@@ -43,9 +45,11 @@  syslog (int __pri, const char *__fmt, ...)
 
 
 #ifdef __USE_MISC
+# ifndef __glibc_nofortify_vsyslog
 __fortify_function void
 vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
 {
   __vsyslog_chk (__pri,  __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
 }
+# endif
 #endif
diff --git a/misc/syslog.c b/misc/syslog.c
index 4af87f54fd..68ee3aef5f 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -27,6 +27,9 @@ 
  * SUCH DAMAGE.
  */
 
+#define __glibc_nofortify_syslog
+#define __glibc_nofortify_vsyslog
+
 #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)syslog.c	8.4 (Berkeley) 3/18/94";
 #endif /* LIBC_SCCS and not lint */