From nobody Thu Feb 03 20:33:05 2022 X-Original-To: dev-commits-src-all@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 7431619893D6; Thu, 3 Feb 2022 20:33:06 +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 4JqVjZ1XMRz3GVj; Thu, 3 Feb 2022 20:33:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643920386; 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=BSbuuHzHMDcF8cF7CY+W0hjXh3isA//fZULxiFAHw0c=; b=H2GsUaqWeZf25GVZPtq/f/MdlZBF2wGMNYHePiKcxSWrrIW1ZaoX+fDkJ5bFgN7hHdaWUp AWGhc1GL7yuKtX12ZGt9d3kZ7os/Mw+LCjsvthKV5wiIXHSd7Me1sckwc5HmF4Woa+2igk bfK77Mad/bAsLv0169Hua75/BD0Aq3PKGikduvO95xFs8zhUjgVamTwExSIkCPYOQMzC2U NJPVUCdjsxcq6vtw2cWjj5fsdojBOjWRupBPRbEhhFT0+p5f6VgZKWpAUoQBZUfsiYJixn ABZFT14UYjzPEh2/6cEjkyXR72vh2+8DExBZ+Qwikv0e9K7k68qwX1sypOwBuw== 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 13C551EAE8; Thu, 3 Feb 2022 20:33:06 +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 213KX52j022005; Thu, 3 Feb 2022 20:33:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 213KX5cb022003; Thu, 3 Feb 2022 20:33:05 GMT (envelope-from git) Date: Thu, 3 Feb 2022 20:33:05 GMT Message-Id: <202202032033.213KX5cb022003@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 3b248a211382 - main - APEI: Make sure event data fit into the buffer. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3b248a2113829e43c382f5e2b1f85c626c01f024 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643920386; 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=BSbuuHzHMDcF8cF7CY+W0hjXh3isA//fZULxiFAHw0c=; b=xGt2rcP1hzO4B7aS/oA7WCo6uMRXAQY6fvJ+TAfPxpOoEisoXaTlsnoNS+SkWdQVh3r3AH ngQz8bnJANLif/Q42tX79QGk9h5wFpGWWggwE0rgPsPQjL6y/jWD53n0nVWdzkU8q7lAYG vk+fsWmypBXMSPIsh1JjsOKYATToCFEIE4F4OfBJXcb2D2XQFhYjz5Q8tJt8IAuPcvH2kg LKknSKJ3i9qWINpJE2fZ6dH3jS9lfr8iWb61Julv14dFPP40p+ALQKUSoXOSVfhW4JSwXg BiC7PmBEmjFqWUeFYGZsVNqBfkoJ0w3qq1j+kngSfapk5spy+y5M9gZ3rdZ1fw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643920386; a=rsa-sha256; cv=none; b=SkiAqzeEbsb3SGEes81bioOwB4zlN56ynWwOSxr8WV+6vtYtcXXVGbIexvQ8ARsjExW5Mr U+AaYergCfQSGDxw8mk95XXW0lB+zsfL3W//DwH7AqTIPiZ6sN15Hg87Vog5v9n7jCi7Xq YccGeggy0tTTRjX6QLxQAzXM2Rj9uJs26LdxF+V9YhSwPMZikH7hxhQlfa/4C3cbiTTBFj sj+fHMcth1uc7chrhslhL6ShJLKiPRoavpamp6aUgBgWsbJ0iLWulh5pt6svIUrtnwwLn6 w6xdWmZbAlma+ktUXdGr9YsI5iTvQL41dtraG0RZy3o/2GR6CF+zjFhVo7/LTQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=3b248a2113829e43c382f5e2b1f85c626c01f024 commit 3b248a2113829e43c382f5e2b1f85c626c01f024 Author: Alexander Motin AuthorDate: 2022-02-03 20:18:31 +0000 Commit: Alexander Motin CommitDate: 2022-02-03 20:33:01 +0000 APEI: Make sure event data fit into the buffer. There seem to be systems returning some garbage here. I still don't know why, but at least I hope this check fix indefinite printf loop. MFC after: 2 weeks --- sys/dev/acpica/acpi_apei.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/dev/acpica/acpi_apei.c b/sys/dev/acpica/acpi_apei.c index c957959317ce..35bab30a68f1 100644 --- a/sys/dev/acpica/acpi_apei.c +++ b/sys/dev/acpica/acpi_apei.c @@ -371,8 +371,9 @@ apei_ge_handler(struct apei_ge *ge, bool copy) uint8_t *buf = copy ? ge->copybuf : ge->buf; ACPI_HEST_GENERIC_STATUS *ges = (ACPI_HEST_GENERIC_STATUS *)buf; ACPI_HEST_GENERIC_DATA *ged; + size_t off, len; uint32_t sev; - int i, c, off; + int i, c; if (ges == NULL || ges->BlockStatus == 0) return (0); @@ -381,8 +382,11 @@ apei_ge_handler(struct apei_ge *ge, bool copy) sev = ges->ErrorSeverity; /* Process error entries. */ - for (off = i = 0; i < c && off + sizeof(*ged) <= ges->DataLength; i++) { + len = MIN(ge->v1.ErrorBlockLength - sizeof(*ges), ges->DataLength); + for (off = i = 0; i < c && off + sizeof(*ged) <= len; i++) { ged = (ACPI_HEST_GENERIC_DATA *)&buf[sizeof(*ges) + off]; + if ((uint64_t)GED_SIZE(ged) + ged->ErrorDataLength > len - off) + break; apei_ged_handler(ged); off += GED_SIZE(ged) + ged->ErrorDataLength; }