From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BFB8FDDB1; Thu, 13 Jun 2024 11:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718278615; cv=none; b=ClCbiZMHPWUQHXztXOO0MOlaX/dCPH40NbTghmzGdKYnE2Iw2+Hlzkt4Fq2efcwdCHqLzl39sggXFb6x2jc5U4zk4kipMoMmTPNjDAjlKaPsQM5K1/ayJOIAZsXXRvsJ6jA97/m1DLu99ohBACrFZBMVHUmIrI0v/hhjZGBpoTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718278615; c=relaxed/simple; bh=I4SQRDGVqZCVAf1cwVEVTPZhJ4g2NpVHEBCiccAQQf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O8jmsjK5DoKc/W4h6iEkzvhzoYvkLrVjkNX8CuGsFNg6AncMjSAejBL26DtDDz4TXOxy2KNlY2e8mpaBRzJxSMK1do2ZyI/1UVTd/YgUzz09K146lXqCJ867ozvzzuHW8ZIMMAPpZZZ/gf5f/2jXGlNv2PoOIgOazv5NEqPhgp4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iqQo6juH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="iqQo6juH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2789C2BBFC; Thu, 13 Jun 2024 11:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718278615; bh=I4SQRDGVqZCVAf1cwVEVTPZhJ4g2NpVHEBCiccAQQf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqQo6juHuNF1+jAUHUUVjMrv7r+sI9jqx3aBy/rrHFUpUV6m8emvear4/nE5Dc0iY yyRxLm+a3puwUQQXOxPIgaeRlBnPimdCkExc2BjPDXBRzvhJbTZz/Kd3+sVenS4sEq rtep5MS1n654AxkRmtdRKyu+1lgJWhBONHU64cps= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Samuel Thibault Subject: [PATCH 4.19 002/213] speakup: Fix sizeof() vs ARRAY_SIZE() bug Date: Thu, 13 Jun 2024 13:30:50 +0200 Message-ID: <20240613113228.067029714@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613113227.969123070@linuxfoundation.org> References: <20240613113227.969123070@linuxfoundation.org> User-Agent: quilt/0.67 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 008ab3c53bc4f0b2f20013c8f6c204a3203d0b8b upstream. The "buf" pointer is an array of u16 values. This code should be using ARRAY_SIZE() (which is 256) instead of sizeof() (which is 512), otherwise it can the still got out of bounds. Fixes: c8d2f34ea96e ("speakup: Avoid crash on very long word") Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter Reviewed-by: Samuel Thibault Link: https://lore.kernel.org/r/d16f67d2-fd0a-4d45-adac-75ddd11001aa@moroto.mountain Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c @@ -577,7 +577,7 @@ static u_long get_word(struct vc_data *v } attr_ch = get_char(vc, (u_short *)tmp_pos, &spk_attr); buf[cnt++] = attr_ch; - while (tmpx < vc->vc_cols - 1 && cnt < sizeof(buf) - 1) { + while (tmpx < vc->vc_cols - 1 && cnt < ARRAY_SIZE(buf) - 1) { tmp_pos += 2; tmpx++; ch = get_char(vc, (u_short *)tmp_pos, &temp);