From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id AFBE6388A43B for ; Fri, 9 Apr 2021 17:37:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AFBE6388A43B Received: by mail-qt1-x832.google.com with SMTP id g14so641187qtu.8 for ; Fri, 09 Apr 2021 10:37:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=uDlu2jS33Kgx4ZQmoQHXeBAJU+MPbx1TM4dNldRSuyc=; b=ty9+G4OkhD9ZGCD7VaWLg+NIznt4hzPBbeR0F1MGV+VfN/BH17v38ioDcIu+Qtc+Lx 130UkwYAoMrDRD+r5APGI+fWOxKhhFFrwAdCRB07itI39EnjumwQeRUaPjC53bmdhUMT ghahBt34sDExeLogVDFh7Rw0EyymSlhNcOI4M3PyElyXOoZ4fS4q/gqCN5N0yr77085V l+FI9sGaL7e9gSGunpKNgHjzGuyoDh8vfIcDFEiOvRR1741qSzVNhcez9nJovz/pLjzV kfaC9Bh6o+osIlDzORDPkO2rfsCBIJHkAJBqYTvwGyHlN3SMpbA8x0HEBq0twLeo8429 B6OA== X-Gm-Message-State: AOAM533dNk4uromczXxPXrmQLuG6F2Hr50fj+72udKx2gEF9sT+denJG Tvic9CiZXyYw/nw6xA0+pVhhmg== X-Google-Smtp-Source: ABdhPJyyB9uw9FK8cQ45UoUyVYDJlqoEjvS/668jyCo7oYPxxir8a//PbudwIiBCel7+3yifrCdRDQ== X-Received: by 2002:a05:622a:34b:: with SMTP id r11mr13413448qtw.121.1617989856313; Fri, 09 Apr 2021 10:37:36 -0700 (PDT) Received: from [192.168.1.132] ([177.194.41.149]) by smtp.gmail.com with ESMTPSA id o124sm2315555qke.29.2021.04.09.10.37.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Apr 2021 10:37:36 -0700 (PDT) Subject: Re: [PATCH] Bug 3604: fix calls to openlog() with LOG_KERN facility To: libc-alpha@sourceware.org, Dan Raymond References: <1395b5b8-0fc7-ae01-c8e1-5e13f3a4394c@foxvalley.net> From: Adhemerval Zanella Message-ID: Date: Fri, 9 Apr 2021 14:37:33 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <1395b5b8-0fc7-ae01-c8e1-5e13f3a4394c@foxvalley.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 17:37:38 -0000 On 27/03/2021 17:07, Dan Raymond wrote: > From 93683928886a563a4740e2b42b53752a4a7d431f Mon Sep 17 00:00:00 2001 > From: Dan Raymond > Date: Sat, 27 Mar 2021 13:51:16 -0600 > Subject: [PATCH] Bug 3604: fix calls to openlog() with LOG_KERN facility I agree with Rich remarks [1] that openlog (LOG_KERN) is not a security boundary and making syslog using it after a previously openlog honors the contract interface. I also checked with my tst-syslog.c, and the patch does make KERN_LOG usage without regressions. And I really think that another proposed solution of redefining LOG_KERN to a non-zero value and remapping it when actually creating the message is cumbersome is much complex. So the patch look good, thanks. Reviewed-by: Adhemerval Zanella [1] https://sourceware.org/pipermail/libc-alpha/2021-April/124650.html [2] https://patchwork.sourceware.org/project/glibc/patch/20210409173031.1508079-1-adhemerval.zanella@linaro.org/ > > --- >  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;