From nobody Thu Sep 03 11:57:06 2026 X-Original-To: dev-commits-src-branches@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 4hbJ432YCgz6r918 for ; Thu, 03 Sep 2026 11:57:07 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hbJ4305g3z3HHN for ; Thu, 03 Sep 2026 11:57:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788436627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CL0o3X6zcINvZhmiZM543jKIury7NnjxPBZY8zzxVVc=; b=Z/g4suCM8o63syncST3jo8Pe1fZYhlLVaklON7HGTQ/97x4J5DPRyb0QuX/xysyRtiDFag oh/70D/6SrTlt+L/yhG1icqS/mOZBTRkBT4XHqbAP2C2NUNr9eseCnYXsZHtz6u//obSp6 Z0kUmyHcXt9TB2VGs4Q1eDJgzuMfoSTp8k8kkRx5H6wEV7nRvvTYFmeQXYhrXpftmi1oev +u9nYjeQSkIWfjhPw2TcQll51O/+UwVfeTDAf7EV9N86Tx35kdjwS5Iaq/tQMFaC1GBq8s VuBa2tHsuv0bAtM0DZK/fDnBhMYZM/dfAkP2ozlW0rP98TwfB0TPq60SIsYYCg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788436627; a=rsa-sha256; cv=none; b=cYr3eJO1zKMPDtUdH2ZAuovFI2jNHYjoJ3Ky3/Oaq+W4ROwfgt+EgA2Lgc+98UToDfHtLM gXJZjHJGaHT8rYUfcMls9yxenc8V7PzfoCW129fX0IbxarIrcMbDluyHT3rZeKDf7cgY3s m6/kCbZbQ1MEsrx6dxRLVn747a9SxSdC9MKXhDEdGWpFVLgfnOFgC7XIk5orJNrUPd6RgA heBmPP4qlrulxcBpF8jKX48iLtZ4uyJWwY61KTwvD2rLCNDgnAfaoXQQVR2mvCL/wl8YUN fJnK+yq//2odJEzcugzczIO9lT4knwJmW0zIfa4TG93YenhX8WkIcI31bl1Gvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788436627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CL0o3X6zcINvZhmiZM543jKIury7NnjxPBZY8zzxVVc=; b=d1JCDPVRPD6KFH5OL0IJqrR3yoJuSBaK5uGveGKOTl0lKDljgBVyT8QqfH3s2T5/56i4Qz MtJSWQHLQEpuux4/uhOMkTmdK8jsTD7i8/ikaVgLOYG0BdujQ3F+7xJEddvao5gvjB1saH epcVdurHrxQB2acvbbsxiHIHw8nEr5RSbC931ZZ/TaLuWF9s6pLa1td6Cr+1fdOO0VIky3 BirwbnOwnuRFBH1aiblgAPajDyciRd2NYNgh0TNHQLQ+EX8DI54Wznxd/6mEEjrjcfEVAd B14wCG+rWmJN6PgJ09dMbxjfendzHF4SLOGJeaXyFZ4hl+LL5DXIwRRzMz73DA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hbJ4257zFz1Qb8 for ; Thu, 03 Sep 2026 11:57:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 40861 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 03 Sep 2026 11:57:06 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Glen Barber From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 2581bc3af381 - stable/15 - hastd: Fix crash on empty message List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 2581bc3af3815e92b0eef44bee224fff92931de8 Auto-Submitted: auto-generated Date: Thu, 03 Sep 2026 11:57:06 +0000 Message-Id: <6a996092.40861.6622df9@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=2581bc3af3815e92b0eef44bee224fff92931de8 commit 2581bc3af3815e92b0eef44bee224fff92931de8 Author: Glen Barber AuthorDate: 2026-09-03 07:51:28 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-09-03 11:56:38 +0000 hastd: Fix crash on empty message A HAST message can be empty, in which case ebuf_add_tail() does nothing and ebuf_data() returns NULL because the size of the ebuf is zero, but hast_proto_recv_hdr() asserts that the return value is not NULL, resulting in an immediate crash if hastctl or hastd receive an empty message. This is trivially reproducable by running `hastctl status` or `hastctl role init` (as the rc script does prior to stopping hastd). To avoid this, don't try to grow the ebuf or receive additional data if the header size is zero. PR: 298085 MFC after: 3 days Reviewed by: kevans, gjb Differential Revision: https://reviews.freebsd.org/D59306 (cherry picked from commit 8646d65b45339642d4aab1de35a2bc79fc45f09e) --- sbin/hastd/hast_proto.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sbin/hastd/hast_proto.c b/sbin/hastd/hast_proto.c index d9f231e7b007..fc90bf59dc8a 100644 --- a/sbin/hastd/hast_proto.c +++ b/sbin/hastd/hast_proto.c @@ -150,12 +150,14 @@ hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp) eb = ebuf_alloc(hdr.size); if (eb == NULL) goto fail; - if (ebuf_add_tail(eb, NULL, hdr.size) == -1) - goto fail; - hptr = ebuf_data(eb, NULL); - PJDLOG_ASSERT(hptr != NULL); - if (proto_recv(conn, hptr, hdr.size) == -1) - goto fail; + if (hdr.size > 0) { + if (ebuf_add_tail(eb, NULL, hdr.size) == -1) + goto fail; + hptr = ebuf_data(eb, NULL); + PJDLOG_ASSERT(hptr != NULL); + if (proto_recv(conn, hptr, hdr.size) == -1) + goto fail; + } nv = nv_ntoh(eb); if (nv == NULL) goto fail;