From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796564907; b=eK3i/SL90y6+3TPBA3pCu/Bvu6V1pLRHslBtO59Ald7eFv59g9bfVkDDZMQJ1ZtJ8uOt r3ulSDWZC55Z0lvyQor+sld99OCRuJ1niy/PJYsPPTD8RmkwHoIdHw4tbRcxzWTvy/2Oh OusP1heqR2maMOLA+zTs0mcnnH7a9BqYc4d5nydc9LYsmfe9Lj+bhBqBFvQ8KLTDmUodM zCC7aoO5gEkLie/roJuDsxr/Lws3VU4l94KdV1fzfc3LIMSTlYI1bZxr4YD5Fs+dHGfm/ DaVh+842J3XxDWOpsAT/X1ofk0BZDTJsnFfEtJh53KtDot6niWggvhQlLQQSbtDON0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796564907; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=azy560duWpvH4N23x/8DfEoLQM+GAXi3rOXmWJ981w0=; b=321PB8Glc1KoI3QQ5g8xzpbkHKAcikRSV7sUX1S5xa/KcmwAIwNo5vfUeZQl+y+bLQR1 k3bmncUobOso/bOXuxCC4C69u0RzlCj/1kWpT2YkuTkawdjuvyIoQCEn2sJ8txL9WBWJf YhnMSBzoyWczXOy1ZkFszmt0qyx02yffD9oBlFDukT+8/WvcjBNRfDBgumSB+T67ow9/G UJG1uLFzrMAicMzUtfjWqla8ngdU3tfUp5lBcYEhA7zByYOPUm4bkpK1LUFdUXhmfd5mp CxKcubr5Abmv7AfA0MvL/O97rsDD13wMKZrOzanzpJbcHbIN3q+6NJx1jYDAaQm7g7Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=minyard.net; spf=pass smtp.mailfrom=minyard.net; dkim=pass header.d=minyard.net header.i=@minyard.net header.a=rsa-sha256 header.s=google header.b=bCu1PjBx; arc=none smtp.remote-ip=209.85.160.46 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 1D05A606A31F for ; Sun, 6 Dec 2026 13:48:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1D05A606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=minyard.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=minyard.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=minyard.net header.i=@minyard.net header.a=rsa-sha256 header.s=google header.b=bCu1PjBx Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-4cde045b023so1536388fac.2 for ; Sun, 06 Dec 2026 05:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minyard.net; s=google; t=1796564906; x=1797169706; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:reply-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=azy560duWpvH4N23x/8DfEoLQM+GAXi3rOXmWJ981w0=; b=bCu1PjBxHztRiJJb/ZjTTfO9wGgVCbvinZ0uZ1UF5fiooc9aOYo4UZ/RWKggtQvbtP Mjq/7ovHGJ8+eU0r5W2y7NM7jdXem0KqX7t+9hEIZCvqWyEIlqnmF5zw7owd/9EFV/hb Lr3Fi12DRwERE2HZBMgsNFTMagT+ereQ3sJW/WfezIn44tEUkziOp2KHr2z9Ho6fQC23 cl0toFqECQbkUJzoAluCz4X9rOTGkhpOswJzgP8g2qAwxDPa74q/oyW0DBSFLIpKht7y pqed+kFncTkFdr4QyqdBm5xuxSXyDGzcECAa20W5TntawTZC3Y7NOWOFMf48+NWkoxyj zDNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796564906; x=1797169706; h=in-reply-to:content-disposition:content-type:mime-version :references:reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=azy560duWpvH4N23x/8DfEoLQM+GAXi3rOXmWJ981w0=; b=hxrq3ieCVYkInPNoN24cnfzf/O9pbM1cKj/uONcj6XygqgPwOvKYz9KnPM4D6/2tm5 Yn8N+isME4JomDzHtKctwl8NKWixp/lMa9ebODFyS1jOAUxSk3wCbL1thtaV9PmwpiKD rvGJCp/Lzrt8g3jI6DFM1mext+NWkoL8mqqurrHaAI4ny9DfvrAIzfCH6qgqO/upF7so cOPjwp0EpPw3zcH7QS/UnGDEcFa1KvSXkIwfW/Uc2C4znGZ3sQjuKXjf7MOSZbEhN+Ra 2Hlwn1yPeWMoFpOS1EKYnwWO/pwZaUOkAz1z1Pi7rx/8VzHbsLIRJ8n+uKk6cVQ4qrGf YAKw== X-Forwarded-Encrypted: i=1; AL+hErHSqkQSw2Pk81CYFadHYFJyB3b0EI92rA9FO5BcSUFNeWK/QssBvMH17tzMeA1NEE2L/yuMlNk=@vger.kernel.org X-Gm-Message-State: AB4q+uFwiH057AZ1MweNHXxdqH/lU2sLoG2snSM95oB3MVAk3FyY3w+Z ZUbkfHhNJq65vAueJIxpxbVkwoNLY3crQUcMugS54dIIct+6USZj0hzYXfi7v2rfmcM= X-Gm-Gg: AZFdTZeQ3+xeWbquGVne70Zk6NF25Ez54dvbAIBoaWY2WNCg4t235kcghbgra2zZNqR LO2VOQgGJAB6GOgABuV2cb8v90HIhGBHCYPRFeLAeUys4vsWKixZ7PbYOAzZjYxo0JHPpjmXbM0 RZpp9Tl7mVpsKh26sqHXr63sDB/8OnJKpzJcoe8tT6VFw8P3itQk3zdwREtl4Vp9WQgdA9Bkyj2 SMzSS4TWqeBnKTOKLC3/dHIx395pU8j00PXTPMSS6cVPRUsIOfCYf29kdKU9LCgDIxALKm5oDYs 0NDM+aOOzWGEdg7Spj7IHdFpcoBDJWLuAE00M3a66aB5caG7i8fPtYVfDjQEwO2jW5/ulUgWno4 tKbIxWeHrhQf200p/6Xr24KTWGAM5og9iLskF5lmgATsNR3KUGYXe2bDI7XoMg3GXS3Q3dNhmkA 0VCkAciXZrqBDXp/44SquOoF2kXf0YPDJxsId4TVUVMGOwjg1YsQMkdP9hcHUrsum8LKjazJhXA xn/CS46TkMi60y0+/o1OS8K0Z+oHINwqwodFmiU8iRKT7VlgsGSiRo80V6CujExKDPlEXaAT1ak 5xGjsQstucBeE9T1PSywoF2lZKb4OIjKbe6YZ+BrA9H6I22ElfL8DaG699RmpPepXsD1IO78V9T +chhPsw/+qp7JWbja/itFxdJdN81KBuXDj50THVDsdbeWC5fe7wLGc4tnl+otBZPIRtFtWw== X-Received: by 2002:a05:6870:218c:b0:4a9:5bde:8484 with SMTP id 586e51a60fabf-4e3d7db6fcdmr6520943fac.51.1796564905975; Sun, 06 Dec 2026 05:48:25 -0800 (PST) Received: from mail.minyard.net ([2001:470:b8f6:1b:e12b:df64:db65:69b3]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4e3bfdb1747sm5608972fac.7.2026.12.06.05.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 05:48:25 -0800 (PST) Date: Sun, 6 Dec 2026 07:48:19 -0600 From: Corey Minyard To: Eric Yun Lin Chiang , Quan Nguyen Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] ipmi: ssif_bmc: keep received bytes inside the part buffer Message-ID: Reply-To: corey@minyard.net References: <20261203050134.3568574-1-ericyunlinchiang@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203050134.3568574-1-ericyunlinchiang@gmail.com> On Thu, Dec 03, 2026 at 01:01:34PM +0800, Eric Yun Lin Chiang wrote: > The handle_write_received() stores every byte after the length byte > into part_buf.payload[] for as long as msg_idx is at most > MAX_TRANSACTION (36). msg_idx is 1 on the length byte, so up to 35 > bytes go into the 32-byte payload: the 33rd lands in the pec field, > the 34th in part_buf.index itself, and the next one at payload[index], > where index is now the value the SMBus master just sent. A master that > writes a few bytes more than the protocol allows can therefore place a > byte up to 255 bytes past the payload, in the response and request > buffers that follow part_buf in struct ssif_bmc_ctx. > > A valid 32-byte part with a PEC relies on the same layout: the PEC is > stored in payload[32], which is the pec field, and > validate_request_part() reads it back from there. > > Give the PEC its own slot in payload[]. Stop storing once the buffer > is full but keep counting, so a part longer than its length byte still > fails validation. Reject a length larger than > MAX_PAYLOAD_PER_TRANSACTION before the payload is used, since the > count alone no longer catches it. This looks correct to me. Adding Quan for comment, but I have queued this for next release. -corey > > Fixes: dd2bc5cc9e25 ("ipmi: ssif_bmc: Add SSIF BMC driver") > Cc: stable@vger.kernel.org > Signed-off-by: Eric Yun Lin Chiang > --- > Notes (not for the changelog): > > - Testing: KUnit on UML with KASAN (CONFIG_SSIF_IPMI_BMC_KUNIT_TEST), > with three new cases that are kept out of this patch and are > available to the maintainers on request: > - a 32-byte part followed by four more bytes: before, the bytes after > part_buf change and part_buf.index ends at 49; after, unchanged; > - a length byte of 34 followed by 34 bytes: before, rejected only > because the index had been overwritten; with the storage change > alone it is accepted and copied out of a 33-byte buffer; with the > length check, rejected; > - a full 32-byte part with a valid PEC: accepted before and after. > The nine existing cases pass. KASAN reports nothing before or after, > since every write stays inside struct ssif_bmc_ctx. > Built for ARM (aspeed_g5_defconfig plus SSIF_IPMI_BMC) with W=1, no > new warnings. Not run on hardware. > - Tool use: found, and this change and its test drafted, with the help > of an AI coding assistant (Claude). > > drivers/char/ipmi/ssif_bmc.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/char/ipmi/ssif_bmc.c b/drivers/char/ipmi/ssif_bmc.c > index 545c9cb78..b21a09b5e 100644 > --- a/drivers/char/ipmi/ssif_bmc.c > +++ b/drivers/char/ipmi/ssif_bmc.c > @@ -53,7 +53,8 @@ struct ssif_part_buffer { > u8 address; > u8 smbus_cmd; > u8 length; > - u8 payload[MAX_PAYLOAD_PER_TRANSACTION]; > + /* room for the PEC byte that follows a full part */ > + u8 payload[MAX_PAYLOAD_PER_TRANSACTION + 1]; > u8 pec; > u8 index; > }; > @@ -500,7 +501,12 @@ static void handle_write_received(struct ssif_bmc_ctx *ssif_bmc, u8 *val) > ssif_bmc->part_buf.length = *val; > ssif_bmc->part_buf.index = 0; > } else { > - ssif_bmc->part_buf.payload[ssif_bmc->part_buf.index++] = *val; > + struct ssif_part_buffer *part = &ssif_bmc->part_buf; > + > + /* Keep counting past the buffer so validation sees the length mismatch. */ > + if (part->index < sizeof(part->payload)) > + part->payload[part->index] = *val; > + part->index++; > } > > ssif_bmc->msg_idx++; > @@ -513,6 +519,11 @@ static bool validate_request_part(struct ssif_bmc_ctx *ssif_bmc) > u8 cpec; > u8 addr; > > + if (part->length > MAX_PAYLOAD_PER_TRANSACTION) { > + ret = false; > + goto exit; > + } > + > if (part->index == part->length) { > /* PEC is not included */ > ssif_bmc->pec_support = false; > -- > 2.53.0 >