public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Dan Raymond <draymond@foxvalley.net>,
	libc-alpha@sourceware.org, Rich Felker <dalias@libc.org>,
	libc-coord@lists.openwall.com
Subject: syslog and LOG_KERN - Re: [PATCH] Bug 3604: fix calls to openlog() with LOG_KERN facility
Date: Wed, 31 Mar 2021 16:27:54 -0300	[thread overview]
Message-ID: <86d18b12-c12b-9837-de7a-9dcb377ed6c4@linaro.org> (raw)
In-Reply-To: <1395b5b8-0fc7-ae01-c8e1-5e13f3a4394c@foxvalley.net>



On 27/03/2021 17:07, Dan Raymond wrote:
> From 93683928886a563a4740e2b42b53752a4a7d431f Mon Sep 17 00:00:00 2001
> From: Dan Raymond <draymond@foxvalley.net>
> Date: Sat, 27 Mar 2021 13:51:16 -0600
> Subject: [PATCH] Bug 3604: fix calls to openlog() with LOG_KERN facility
> 

Not allowing LOG_KERN by any user process seems to be de facto behavior
on all systems I am aware of:

  * FreeBSD and MUSL explicit set to previous log facility (they check
    if the priority against a mask and since on both LOG_KERN is 0 is
    set to the previous/default value).

  * Solaris 11.4 man page explicit says:

       LOG_KERN      Messages generated by the kernel. These cannot be  gener-
                     ated by any user processes.

  * AIX 7.2 is similar, but it seems to provide a special symbol for that
    (which seems to not have a man page):

       LOG_KERN      Logs messages generated by the kernel. Kernel processes 
                     should use the bsdlog routine to generate syslog messages. 
                     The syntax of bsdlog is identical to syslog. The bsdlog 
                     messages can only be created by kernel processes and must
                     be of LOG_KERN priority. The syslog subroutine cannot log 
                     LOG_KERN facility messages. Instead it will log LOG_USER 
                     facility messages.

So before to make glibc an outlier here to fix a very specific issue, I
would like to check with other implementation the possible security
implication and whether it make sense to change it.

Reference: https://sourceware.org/bugzilla/show_bug.cgi?id=3604

> ---
>  misc/syslog.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/misc/syslog.c b/misc/syslog.c
> index 2cc63ef287..bb30cd963a 100644
> --- a/misc/syslog.c
> +++ b/misc/syslog.c
> @@ -285,7 +285,7 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
> 
>      /* Get connected, output the message to the local logger. */
>      if (!connected)
> -        openlog_internal(LogTag, LogStat | LOG_NDELAY, 0);
> +        openlog_internal(NULL, LogStat | LOG_NDELAY, LogFacility);
> 
>      /* If we have a SOCK_STREAM connection, also send ASCII NUL as
>         a record terminator.  */
> @@ -299,7 +299,7 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
>          /* Try to reopen the syslog connection.  Maybe it went
>             down.  */
>          closelog_internal ();
> -        openlog_internal(LogTag, LogStat | LOG_NDELAY, 0);
> +        openlog_internal(NULL, LogStat | LOG_NDELAY, LogFacility);
>            }
> 
>          if (!connected || __send(LogFile, buf, bufsize, send_flags) < 0)
> @@ -343,7 +343,7 @@ openlog_internal(const char *ident, int logstat, int logfac)
>      if (ident != NULL)
>          LogTag = ident;
>      LogStat = logstat;
> -    if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
> +    if ((logfac &~ LOG_FACMASK) == 0)
>          LogFacility = logfac;
> 
>      int retry = 0;

  parent reply	other threads:[~2021-03-31 19:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-27 20:07 Dan Raymond
2021-03-31 15:19 ` Dan Raymond
2021-03-31 19:27 ` Adhemerval Zanella [this message]
2021-03-31 19:44   ` [libc-coord] syslog and LOG_KERN - " Alan Coopersmith
2021-04-01  1:21     ` ***SPAM***Re: " Dan Raymond
2021-04-01 15:21   ` Rich Felker
2021-04-06 16:47     ` [PATCH] fix calls to openlog() with LOG_KERN facility (Bug 3604) Dan Raymond
2021-04-09 17:37 ` [PATCH] Bug 3604: fix calls to openlog() with LOG_KERN facility Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86d18b12-c12b-9837-de7a-9dcb377ed6c4@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=dalias@libc.org \
    --cc=draymond@foxvalley.net \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-coord@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).