Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2959278imu; Mon, 19 Nov 2018 08:38:23 -0800 (PST) X-Google-Smtp-Source: AJdET5dWEARjLuEt2yknbEregXTsSAjz1jJHu/Z27pjAQ6TiMP/A79at3WOq4eOhWX9d8/kIcLXf X-Received: by 2002:a63:5c22:: with SMTP id q34mr20551833pgb.417.1542645503519; Mon, 19 Nov 2018 08:38:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645503; cv=none; d=google.com; s=arc-20160816; b=CN9o7DxjaXEb33Rya4nZ7BRB2q3/ykQjwDZcNqaQWnkPuhNIzjh/whmfIvmchMAfgA X4JXLnyXkgepQYFZ4FkDj2LiPo4s/4TVtp0+El5AN1JwOgzcShkEktWtItrfaTYNll7F C2X6azUauNe7O3s7khP62ju5xzn3fFGFklbn58/lqsOeS9tlG9Q6bUHT8AwVLfOJs3AZ z2821JIEsA8iNDSK7MyZmhxjhPzyfaW2XeZyWKlio72TOrbCtVoA6HWjevkdcpfebbtU nRXzdvmkIiLDneLKLkyVcddSQjhr8G1UKVqxaJay++b4EtXWihKtNBWkz0lIdfUOMjtT g/CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=obT2I8GH42fy6dSdWJ9PbFv32gKXr1Hip0lagCRIH64=; b=UAfwiimuc5XYQV+AgvuZv03Hvpp8l/erTAlF+/2eFptZdGdgyZIzXrerFvqRjtSanD js3u8JdkJdqiGcIPB4liGS//rUjh+t89uCBF/LC0+F2tn620GeZQSsebSPwzlvR1UuUA AcqR7hFusSPG0tYc7y6k8QDu6kDIZmFUMalpSyGpITob6dlQZDK6j57G1CzUkU4oks4p CXKr8d49jZG4BG2SkT7R9ZuWeCFojbmwV7GdVlzsgfuFmOHL4r/fqqiUFtF4/1/n8r9C Dua5/t+oOgyHmdoTuxGmApPhV8m91zYR4RdMw+4XgVTQHM472IR40oIU1u7N/3v6/HSr 5ryg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c8ksvzKg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si12885491pfo.90.2018.11.19.08.38.09; Mon, 19 Nov 2018 08:38:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c8ksvzKg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731637AbeKTC72 (ORCPT + 99 others); Mon, 19 Nov 2018 21:59:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:58938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730350AbeKTC72 (ORCPT ); Mon, 19 Nov 2018 21:59:28 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF72220C01; Mon, 19 Nov 2018 16:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645320; bh=sGUH1TyEtOhx69kdLWfx+TJvxzRyoV34xtrpcnSOh/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c8ksvzKgZw12NB2ouDH3WzmZ7CanKkR9nsGQ4rSl8Vp0RFrJD1qNwn+uZD7jFQxDD Q5WcoVR16WvLA7K+H3Sa9rCwM59JhTPDZW6wJUu+44HV5X3eIdXlPPfl6UbODghvoT 5JxYI3MnUNPpHDQBItPkNjOapoPihf2hnj9OfqyA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "H. Peter Anvin (Intel)" , "Cc: Johan Hovold" , Jiri Slaby , Al Viro , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Gleixner , Kate Stewart , Philippe Ombredanne , Eugene Syromiatnikov , Alan Cox Subject: [PATCH 4.19 120/205] termios, tty/tty_baudrate.c: fix buffer overrun Date: Mon, 19 Nov 2018 17:27:07 +0100 Message-Id: <20181119162635.927742775@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: H. Peter Anvin commit 991a25194097006ec1e0d2e0814ff920e59e3465 upstream. On architectures with CBAUDEX == 0 (Alpha and PowerPC), the code in tty_baudrate.c does not do any limit checking on the tty_baudrate[] array, and in fact a buffer overrun is possible on both architectures. Add a limit check to prevent that situation. This will be followed by a much bigger cleanup/simplification patch. Signed-off-by: H. Peter Anvin (Intel) Requested-by: Cc: Johan Hovold Cc: Jiri Slaby Cc: Al Viro Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Thomas Gleixner Cc: Kate Stewart Cc: Philippe Ombredanne Cc: Eugene Syromiatnikov Cc: Alan Cox Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_baudrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/tty/tty_baudrate.c +++ b/drivers/tty/tty_baudrate.c @@ -77,7 +77,7 @@ speed_t tty_termios_baud_rate(struct kte else cbaud += 15; } - return baud_table[cbaud]; + return cbaud >= n_baud_table ? 0 : baud_table[cbaud]; } EXPORT_SYMBOL(tty_termios_baud_rate); @@ -113,7 +113,7 @@ speed_t tty_termios_input_baud_rate(stru else cbaud += 15; } - return baud_table[cbaud]; + return cbaud >= n_baud_table ? 0 : baud_table[cbaud]; #else /* IBSHIFT */ return tty_termios_baud_rate(termios); #endif /* IBSHIFT */