From nobody Tue Nov 30 18:12:42 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4B34118C7FAE; Tue, 30 Nov 2021 18:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3Vgb0DpYz3Mj1; Tue, 30 Nov 2021 18:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D25791AF44; Tue, 30 Nov 2021 18:12:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AUICgjq088429; Tue, 30 Nov 2021 18:12:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AUICgqZ088428; Tue, 30 Nov 2021 18:12:42 GMT (envelope-from git) Date: Tue, 30 Nov 2021 18:12:42 GMT Message-Id: <202111301812.1AUICgqZ088428@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 943c446629e3 - main - Revert "libc: Some enhancements to syslog(3)" List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 943c446629e33739d3f72795069a5c944e8f329e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638295963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=O7JOSCwYAXDVUgW7vlNjI8MzN6Py84Hf/kwSBAjnJRk=; b=FfP55uwmx2XKjeGxk+XL+MJHfo3cCmTvMzdGsZTLEWg5qkeJGn2zlucgB8up9Qo70CGrf1 qkq2D2WH5yBZSe5JN9TrcKnPBGsXltTbcN6zopFRzmGqV32ppJuvkglUb0ylcnQNZ3qxZs tWwsGkPIJCEhJa9x7cuVvlcBSuNHepHzIJ9JWfgH/cBly67LLpakIBnrZvEWlPhXcGwusk KC1mliWCeXAYTvl1rH/hYFFLSjeB1i7TX/MS19zw5prpqjUzjrYSCPLmupMlBz4W6tjJta u+73x9QKR9x8pcXzC0YZKQ5gjidwTGSTcz3Lw2OgdpaZdqXgI2iN0D5rqhHRaQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638295963; a=rsa-sha256; cv=none; b=C5GmeA62iGksPzzARSIRqTRO/GFGlDQ3mZU4xlmzkr0pnoh2E7/XapgH4aiG0ev2lQiLe5 GgoCzTpFVEzHsLUlItMjeY+6ycLjBcwc2qhhdhEgv44GQN4LJst4bVN52KQaayT821YIkI 38SqM2Jo3RcjwXt4FWXRHh5g5R3Og8myRY3poWPMG1Upu4SZXp1PytFfA6lcGeGfHwADn5 9jJypL3UpRQFfMUI+TPCHjLl7kKzzzPXcQymwvhF/x8ZFxu/FuNRHIrLxYlx4deD83C4bC YDV5c+5sBhiC5m0GFwv4rV4tJlmmBsl91E/Y7EuFE0nYHNL7Gopu3dWac2E0Pw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=943c446629e33739d3f72795069a5c944e8f329e commit 943c446629e33739d3f72795069a5c944e8f329e Author: Alan Somers AuthorDate: 2021-11-30 17:06:25 +0000 Commit: Alan Somers CommitDate: 2021-11-30 18:11:43 +0000 Revert "libc: Some enhancements to syslog(3)" This reverts commit 2886c93d1bca231260ebc01d4205743ca781f3c7. The original commit has two problems: * It sets SO_SNDBUF to be as large as MAXLINE. But for unix domain sockets, the send buffer is bypassed. Packets go directly to the peer's receive buffer, so setting and querying SO_SNDBUF is ineffective. To ensure that the socket can accept messages of a certain size, it would be necessary to add a SO_PEERRCVBUF socket option that could query the connected peer's receive buffer size. * It sets MAXLINE to 8 kB, which is larger than the default sockbuf size of 4 kB. That's ok for the builtin syslogd, which sets its recvbuf to 80 kB, but not ok for alternative sysloggers, like rsyslogd, which use the default size. As a consequence, writing messages of more than 4 kB with syslog() as a non-root user while running rsyslogd would cause the logging application to spin indefinitely within syslog(). PR: 260126 MFC: 2 weeks Sponsored by: Axcient Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D33199 --- lib/libc/gen/syslog.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 797c7389d1a2..19d44db0075a 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -57,9 +57,6 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" -/* Maximum number of characters of syslog message */ -#define MAXLINE 8192 - static int LogFile = -1; /* fd for log */ static int status; /* connection status */ static int opened; /* have done openlog() */ @@ -144,7 +141,7 @@ vsyslog1(int pri, const char *fmt, va_list ap) char ch, *p; long tz_offset; int cnt, fd, saved_errno; - char hostname[MAXHOSTNAMELEN], *stdp, tbuf[MAXLINE], fmt_cpy[MAXLINE], + char hostname[MAXHOSTNAMELEN], *stdp, tbuf[2048], fmt_cpy[1024], errstr[64], tz_sign; FILE *fp, *fmt_fp; struct bufcookie tbuf_cookie; @@ -399,19 +396,9 @@ connectlog(void) struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ if (LogFile == -1) { - socklen_t len; - if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) return; - if (_getsockopt(LogFile, SOL_SOCKET, SO_SNDBUF, &len, - &(socklen_t){sizeof(len)}) == 0) { - if (len < MAXLINE) { - len = MAXLINE; - (void)_setsockopt(LogFile, SOL_SOCKET, SO_SNDBUF, - &len, sizeof(len)); - } - } } if (LogFile != -1 && status == NOCONN) { SyslogAddr.sun_len = sizeof(SyslogAddr);