From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452549; b=pljrbgieLm15Uk9M3yVYryTOPkKFjrBDDg1gujaGg60b4hlxAGoDm0A9rHSJbrWnYtkh 7Qs1ZMC0feMQv5gQX9zvd2VY60nQE1sckRL/lcoZINk0YhrrhHEu7dxNHG90oq4m2oIWc 35ydOtm+McJeBpjPnpsFhWiEhV9LiDTTpEyl0GAlGQlec9lIO/eM5aZjn48NqoPRUdGoh zyKXpYHafyWDw3ZwNbXB0Z9r7hE7rE+c1n1bLyZO2D5s1NI9gEin0wcV6mjUc4eiOCcKq no9xuAr67rGDL2kzr20PFNz6a1CXieyrWS/UGsUxf92Fbr6mRSnUcSb4cmDADg8/mYA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452549; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=VU95cFkSAn69TuDw0TbCdkBN67NMzMRSRJdSDSIjX+Q=; b=z7OymXCPCAf1WE4oOzewIGK5Sj0845/FjwINjR1ovxCRQxf+yJqWxI/PZwhOWfh0JC3x 18DzR/oprafODXealG9szUxDzPnIS66oed6okU51c+oFk1rkA+XG2UEF9xau6S42iT3YP NXi4bWetoKLK+zuGAmq8AXoZ2j+LAhJn4ZO2288PdmYPidj1fF5yivxXQt7nfOR2h2Mpl Kd24A8xOWH2k1UJ0Uic6iNqZvEdPTpF/6/I/D0sOLkZMGwofmcjtBgZg3w7qhUHMa/m3N Lx9s6uRzK42/zJl+oq6C4NpVGelIT7L1LlL0A3bHid6OV8R0DCL59WXVlgZctAMmZ6g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yHn4w1Gv; arc=none smtp.remote-ip=74.125.82.179 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5E35606A339 for ; Sat, 5 Dec 2026 06:35:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C5E35606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yHn4w1Gv Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-38190551625so2013393eec.1 for ; Fri, 04 Dec 2026 22:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452548; x=1797057348; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=VU95cFkSAn69TuDw0TbCdkBN67NMzMRSRJdSDSIjX+Q=; b=yHn4w1GvbZnx3X5tVbJojoJTnsucR3NISZ05p/TwN4WS+Zq9DxO5S0Cwn/b1cvnKFT 2qpnZHYLjWednXKx0E5Pdp7Jfu1KMhVkkrKhtmlwN1fI7Py32zvSxXF+JluR8XfofIrR ObszqfqjCnHb8YBhtz2AsRUoR+/1HSilLze7esPDnOdRVhGLCf15QnEdW01QAKUT6ZFp jgJmHAmdvY+IY0sE7zZzsIKUaqm1H+zPZ4U8Zx5ERebj3hUANRLr7jJ7lV1e8jQAJLL6 KVJe6oJyaU8H6kEpfT6dkUY8QJ34kaMJlau+WF8oIUmxqApMenaj04rv8G0tUYy94cwV 3CeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452548; x=1797057348; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=VU95cFkSAn69TuDw0TbCdkBN67NMzMRSRJdSDSIjX+Q=; b=Zde8/dolRJScQFGOhE/C4tWOfIMfNSvmWnJIGYx+Yf8IVgd8K8+/MSNaCoRUXV0kwy AziPI/YitRdIV4uyUW/UVwLn9ZGpo+3EsR2KO9UuhiY+u0aR78l4CnEUROfy90PuQ2fL pA+Pb1Usw1QU8MigczaR9WC6mxprwW7p8NJyf2ECOvYmY5LIPnrqoAYvDFOi8PfwIQVp yYgc9suRw7oTXxVt8f6pIBSerig702kn7i8cCZYwrIxHsZZFBQA+DpXPuTgVxG+qFbYz kT2gaUgHuK3B7gSkAnhYg26s8gUCvcZkY2A7BdQUERm/KL2ZW6QjmN0ZW/kn+UCqp8AG 1g+g== X-Forwarded-Encrypted: i=1; AL+hErEAwfqlBv3X/1SiFit3LZVZXKK5puS+Z34bRqQUDMNS5aVEMN+vl2Od3N812p3cB8CiyBt47uM4elk97oo=@vger.kernel.org X-Gm-Message-State: AB4q+uGv7dO2GXfm3ZDeJp1wSGNEUGsPxBaCHdFrZCwYzwlF5jHzrJAz XKkJ/bdOy+6kaSGDJpAwK7OOiY2eHRaquqXnDGpSzSFT3lGEIOWabzRf X-Gm-Gg: AZFdTZfuUUJ3Q1xspVDS9A7jjSghRInBRzaaegGMStRtu6gZcmn6GNQnfiLYHjeyCxO Ne70+9tDRep6d023P9kdXua87HVMwqAf6TWuTv4GKBUQMHd1J13mxRokPOuaItCFOIYVwNUTSEK ozsad8HNOG6axm8l8lXAHNLAyCaXSZxQmKm0+Jjm/+e2M9Uzg7m+9iHnh900/BbEVgOE5CX0DVP ebWbtXKOcTG55Fg2edIhl/Tl1iwRrRiKa9WolQFJBp73ybUZDXMCessrF6UgVmvGZA8SX8QqJ4t +88qp6NmKRuiR+Ilng4MQL2YxCGtpRvWBz5lr3DVJnTEraNwzfEv1lDUZUaohQbgEmRerGt9Jhl fthk/A/k5fJ3pAbRAadxkBQq6UEZqo3kkA1PVPrVo2yRZJCjXclqy9YIEFMjmDWQibtQERzdRgL 25ZtmZXVvEKPt9N62BthSRPx8D94RibL9ltS9EdmvFCIgxsHKXvv0pFOSm1AIKdRbYyGbl+Ze0u NFdFmQrlYvc1BkPOimoMfGKic/+5oPzBw9ml6nry1xuKiRy+TR1ETIUmkQ9d90RIooDwt7zUkwP bJWoVDmHWvSBMpVyeLHu09N3eMC29iUB+DrrelcVp6SjtVDSHU2KbAe6a3bU86AWpJg= X-Received: by 2002:a05:7301:5158:b0:386:f868:8caf with SMTP id 5a478bee46e88-3875216043dmr3461551eec.8.1796452547855; Fri, 04 Dec 2026 22:35:47 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218c602sm20884183eec.7.2026.12.04.22.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:35:47 -0800 (PST) From: Praneeth Balasubramanian To: Greg Kroah-Hartman , Jiri Slaby Cc: Praneeth Balasubramanian , stable@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 1/4] tty: hvsi: fix stack overread in hvsi_version_respond() Date: Fri, 4 Dec 2026 22:35:33 -0800 Message-Id: <20261205063536.2519566-2-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261205063536.2519566-1-praneethb2002@gmail.com> References: <20261205063536.2519566-1-praneethb2002@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hvc_put_chars() always loads two unsigned long words from the buffer, 16 bytes in total, whatever count its caller passes. Its comment says the buffer must be at least 16 bytes. hvsi_version_respond() passes a struct hvsi_query_response, which is only 12 bytes. The load of the second word reads 4 bytes past the end of the stack object. This happens on every HVSI handshake, when the port answers the version query of the service processor. Copy the packet into a zeroed, aligned 16 byte buffer and pass that to hvc_put_chars(). The 4 bytes after the packet are then zero instead of stack contents. The count stays packet.hdr.len, so the service processor sees the same bytes as before. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by an LLM-based audit, part of research at UCSB SecLab. An LLM turned a kernel comment into a rule, and three LLM votes checked the code against it. The fix and changelog were drafted with GLM-5.3, then checked against the source and partly rewritten with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64 allmodconfig; powerpc pseries_defconfig), clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no reproducer. I do not have this hardware. drivers/tty/hvc/hvsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index a94068bce76f..ec91ee42ad8c 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -279,7 +279,9 @@ static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet) /* respond to service processor's version query */ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno) { - struct hvsi_query_response packet __ALIGNED__; + struct hvsi_query_response packet; + /* hvc_put_chars() reads 16 bytes even if count is smaller. */ + uint8_t buf[16] __ALIGNED__ = {}; int wrote; packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER; @@ -292,7 +294,8 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno) pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); - wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); + memcpy(buf, &packet, sizeof(packet)); + wrote = hvc_put_chars(hp->vtermno, buf, packet.hdr.len); if (wrote != packet.hdr.len) { printk(KERN_ERR "hvsi%i: couldn't send query response!\n", hp->index); -- 2.25.1