From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7947436A342; Wed, 20 May 2026 16:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296093; cv=none; b=sBkWTXEPQ5sVzU9p04TAkQUQynmdptUK/c801L5WA94ZGMrlSoHpXfR92TM2xQFlfH6Y8pX2ILydICQw2a2BRR5UjLiSTQ2LF4sKyDz68nZGqF5pHtzzdTRntppGPTRHXzA856JNCYAn7x2pzeXpGb18heRMlg0cz7BcJ5bge9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296093; c=relaxed/simple; bh=VHiXBxqxOYsXiPFVDzDCroSZennb+/FQ4h7penOHwjI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HTnRjsMbmdWFEhteZqP3BWF9zpbMdEuljBbgnd2sAwDLzhXazSkHgaaF82Ih4713nImMSk73K8UWrLKsBKgHlizPuaYpJCnVE4It3yrLr7TnE8MKcEuIi0mC9iGhlNoI4HlXiHholSo9x8P/ZWghBz1F15A0xYW1XE+cttN9INY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uoTMExnz; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uoTMExnz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96AC01F000E9; Wed, 20 May 2026 16:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779296092; bh=hDDgWFbCeICNW8Fwdt/XYN/bGK3W7j6PXTuqntr+Eds=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uoTMExnzSaDpOWMR3xgLDJJg1Xe8c2wjmo+84iC5i94V87Z5jyn+P6pWZkOQFFuUb m/F8Os/PL8bRj4S1YaLLkvaZ7R9UXsAUK7bQbbvFBKgFYeAmckDymrGPPPKxQFTAMd wGZzkwKVYZTD1+Fdd4HQP1poJMEfcXXi6+kdYTLI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Randy Dunlap , Sasha Levin Subject: [PATCH 7.0 0668/1146] tty: hvc_iucv: fix off-by-one in number of supported devices Date: Wed, 20 May 2026 18:15:18 +0200 Message-ID: <20260520162203.305800921@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162148.390695140@linuxfoundation.org> References: <20260520162148.390695140@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Randy Dunlap [ Upstream commit f2a880e802ad12d1e38039d1334fb1475d0f5241 ] MAX_HVC_IUCV_LINES == HVC_ALLOC_TTY_ADAPTERS == 8. This is the number of entries in: static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES]; Sometimes hvc_iucv_table[] is limited by: (a) if (num > hvc_iucv_devices) // for error detection or (b) for (i = 0; i < hvc_iucv_devices; i++) // in 2 places (so these 2 don't agree; second one appears to be correct to me.) hvc_iucv_devices can be 0..8. This is a counter. (c) if (hvc_iucv_devices > MAX_HVC_IUCV_LINES) If hvc_iucv_devices == 8, (a) allows the code to access hvc_iucv_table[8]. Oops. Fixes: 44a01d5ba8a4 ("[S390] s390/hvc_console: z/VM IUCV hypervisor console support") Signed-off-by: Randy Dunlap Link: https://patch.msgid.link/20260130072939.1535869-1-rdunlap@infradead.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/hvc/hvc_iucv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c index 1dcdb9e99bd8a..37db8a3e5158e 100644 --- a/drivers/tty/hvc/hvc_iucv.c +++ b/drivers/tty/hvc/hvc_iucv.c @@ -130,7 +130,7 @@ static struct iucv_handler hvc_iucv_handler = { */ static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) { - if (num > hvc_iucv_devices) + if (num >= hvc_iucv_devices) return NULL; return hvc_iucv_table[num]; } -- 2.53.0