From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452397; b=QKuooeWXmYonpt4dwalq36Hd0OHrOziy8r9va937lboee9aA4hYyiHhFSE9lSLli2Yvl GaU6uoCJY7uIuJOqoX10/ZnHhmEl1CYZG3uGQFHyMhOumnwRZwAnRxxD/5yVjf7pPD5C/ CqiHBixy0AZWxHomII7pT/xT6GYR3X0VtHfwinzh3HpCQcVi206sKlEESAxHs7k7pgc8h c8E2sOpBTFWOh2W8PVIwxpl1eQeRqPpMCDH6RJeWORjstKrDc8s7GE3HBBJG5dmhifsVD 57/h/0hrpE56ZsZt7ASfaEYUQSy6c6owXnD+euEPdJsJP0C+D42V54aCi8TywIDUp3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452397; 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=8JuYU4MEYDCRZjkSJ7brK8HwdzYzvtXEoJHK0t0Bqnw=; b=m1iQ/F8FDAQd5JVzHgSxcrTXKf6X3mktXhXP1ClEY/fEjbA+Cxo1KBsFbmsAROi6rc19 FUnPAga494CBAOP1cMYip1wslWGqsSf5UVtWpdc/h3h7gmuoZmGrzBBAjXhaC6tNsrftf 2NpGC4ZJ1FaSGY4kuQ+EzYzogOtJJSpHaS48AXwrvLJVuxscpRqXwDeAD/Abqy6AXKDId HDIJP+YSCpRojHaTMJgAskCFQJ3RWwITEV7tD8bwvprGJLS/mJZF8iq4ihOyJOQ8Bqvm6 N4I03vZntVh8BI6JZUZ48iOEmUqEvFAPaF4oaZ22iWrUOfS/2U5/mFACuj1Iibvxzyg== 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=UcTWkziM; arc=none smtp.remote-ip=74.125.82.50 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (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 2A69760A2600 for ; Sat, 5 Dec 2026 06:33:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2A69760A2600 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=UcTWkziM Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-1b5d5f3d5b8so1766609c88.0 for ; Fri, 04 Dec 2026 22:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452396; x=1797057196; 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=8JuYU4MEYDCRZjkSJ7brK8HwdzYzvtXEoJHK0t0Bqnw=; b=UcTWkziM8/uhpwJpWr9bvVETLBZAua4Gs9AH6Lq+kHpVa99llEaQFztG03ER7PjN/z t1MAmp0wAqrHNA+SzirmXbih59arxXz/KXj8RqBuqbjHvA2Jhet38S3gK1GH2NNgUnAk rr35QHibbTJVwyu3U7QVt18Xs0lcyx8Fh18KNIo39saJ0/o8qMV1kM7KHKfK31S2KxNA 5eXyEMNDBUhDp/wpNLtK53XrO+h5fhJQKkqacK90yfgHGACHq8PF8tdAK3WKe1RKlVxX LLOFxv3OCxICObc0sxhEKgEfepKKstWbRmn5ijo/o8PzaoY9CixOF8AOXWykbl06yKbm nyxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452396; x=1797057196; 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=8JuYU4MEYDCRZjkSJ7brK8HwdzYzvtXEoJHK0t0Bqnw=; b=0hUuNeFYpDsxt94HuF/3LPZWUQwkIg5IKtL+8maVB1sOkB99+kCgxdih+MXKhm6V9x kIQsH3qz12fpUMQ9sQKU/Z3au3HMOvC5OwhIw/lHBk60V5rCI4MtassScEoq4H+mZh+f KLQF1NnvI8YxbwsJ/1fZYL69kiVhATnSxF5EQ046oR1cMGoWYdF4dle23BM5fFplX+Js 5a39YGgfGoTU/g3C259obWMYfSkJB7hj7az+fZJsOlHvdyTcHncskZztw9rnXvrSybnB YKC3ZpbCqa469iI2nAzAyyFMr24wzYY+7BCOAKBGzb0dM2qToIHvOAscp1yUghf4K8MC PXEg== X-Forwarded-Encrypted: i=1; AL+hErGkIKCyi1dNeJZHG5jHuAuzK4qWutye4LYmQnmXUTLbcy5ZZop+mo68+aU78whg5ZM+GwCjmVTr4BmI5gI=@vger.kernel.org X-Gm-Message-State: AB4q+uEURfluInOR4ozaeitvTlCeRgjJyqIgmBUbj1JskhQocrDH/F61 PyU1LrA4nXHHPgIVRTO75ZkYH/r7m6ImqPlG8GvC6/W5Wc37TNaYIiY9 X-Gm-Gg: AZFdTZcgIdY0pC5Rsc3DB0saZ4nfdipMCf8IOyMynHwtJsxTyw0cPA1VVhRgq72trUx d/Is9PYP30TS7DQMLlMDJv+SZXVTKKGVnTzzj93F5ImtckG8JGwgWIriYPEsb7s/vq1Sh9xTJKZ fS4dwIWY0xnuH7UlZWrSTQ8681/kY32G9YOzWm8gnODJaUOfgdCqsKH2k2bT6BTaKDbSPNZlzjL BTPdRCqCfNENbJ4RSSJbSu1JIGOuU7uT4UXB1HKwSgxVkFELfdmJqLdH1bTjMsmoQOsRRO6L7Tw sC6E/GiVlcryK9xCeOS8er45u8ahe8jEnT9OBNZSDCjTcx2yZQC8tGLEZV44CJ9pQb2RH+cZWMJ uzEwvuybGr0m8RS2HgjhBKdGBDuvSXnQ7mVTxD4CG+uc45eET4P3rtzFdaw7c3ljbPpzPQkrcCp Myj04laS/tiroVFrJJo4vwxHBZqt9IQg9WU997CR4vxJ30psmtLzwfRu2G1RvkHRSvKkXDlnUkW 1jBysJtAZmyaMWEaojBiCVjmBtJaiadysc3gDcbgZwre9TzZfSvVp8D7hAfe9mehIe42r0XfZS1 4TJIFUYq+wfRS24mxHrAXSrFi4yqyJpBo8OxVODmd+g4fWvcIUjlmm2doN40t7tWa1o= X-Received: by 2002:a05:7300:cf87:b0:385:4608:5679 with SMTP id 5a478bee46e88-3875217d82fmr3871804eec.40.1796452396295; Fri, 04 Dec 2026 22:33:16 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521bb842sm14612341eec.15.2026.12.04.22.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:33:15 -0800 (PST) From: Praneeth Balasubramanian To: Brian King , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Praneeth Balasubramanian , stable@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] scsi: ipr: Skip dump entries whose length is not a 4 byte multiple Date: Fri, 4 Dec 2026 22:32:24 -0800 Message-Id: <20261205063229.2518424-5-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261205063229.2518424-1-praneethb2002@gmail.com> References: <20261205063229.2518424-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 ipr_get_ioa_dump() takes each dump entry length from the adapter dump table and passes it to ipr_sdt_copy() without checking that it is a multiple of 4. ipr_sdt_copy() copies whole 32 bit words but advances page_offset, bytes_copied and the dump header length by the full byte count. When firmware supplies an unaligned length the trailing 1 to 3 bytes of the copy stay uninitialized and the next entry is written at a shifted offset. A later read of the dump sysfs attribute then copies those uninitialized kmalloc bytes to userspace. The dump is only readable by root and the values come from firmware, so the impact is limited. Skip such entries by clearing their valid flag, matching the existing handling of entries whose length exceeds the maximum dump size. 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 and checked against the source 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), clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no reproducer. I do not have this hardware. drivers/scsi/ipr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 1a5e362cccbd..71a70ce59bb2 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -3173,7 +3173,8 @@ static void ipr_get_ioa_dump(struct ipr_ioa_cfg *ioa_cfg, struct ipr_dump *dump) valid = 0; } if (valid) { - if (bytes_to_copy > max_dump_size) { + if (bytes_to_copy > max_dump_size || + bytes_to_copy & (sizeof(u32) - 1)) { sdt->entry[i].flags &= ~IPR_SDT_VALID_ENTRY; continue; } -- 2.25.1