Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1914904imm; Thu, 24 May 2018 02:51:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo5+m/NUGqyI2tt3pyq51zq2ZdYMIZoG7QTEGUJHysy+UwYfG1NHA/tOs5jSBA1tV5WTGos X-Received: by 2002:a62:449c:: with SMTP id m28-v6mr6513360pfi.145.1527155515893; Thu, 24 May 2018 02:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155515; cv=none; d=google.com; s=arc-20160816; b=JStWRER7h/W6mPz9+PNMYu0s3riLMzfW24ydJZzXVlUTXaYPtWQXIr6BrtdnDT4BMn fkr+BuhLx4JuHTJzXJYLKKjLWMw2OeEkKy7G75tTh3Jbt3y8/gSDxjdlAqATzEV7knGh 6eOroPE8TJ/XtdX0BM3vo0N1Rb3llO9CuCIPNGuby0QckwCqshE7I+3EL/QbGD55xEkd ahMy/CmbvxrYYGkGAnqqPe0ZjBdz+oUUSarvUrH+LyAsou4yra8NamKaNA0HY/5Lwain 9jesQhBztZ4kQ/pxTF7n9iMg17ORuisEXlHapx7KnhwUaP3a2k24ilaB7T9raSOvUaJH G1aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=YjqrNFeq2vlHkHOLKAKudokGT22WAHrMLbUwwzu12rA=; b=etokUZe7i6eI0KsolbhNwFUbKgrR1SfJdqL7b8DXJAXwY6rplrYItETzlRsXGn/Mx4 Anp2pfgijubOgcJ20WkWfITTDqSQyK3uOeLQKkDO+WdfHvvBrbI4fIYwOXFUMV1vGIjU wxbXKQdlzWBLTgagTpSWQ3rsk/NaveQ8fNFwxutl8IgREPyTqSUJW2xGzlxRHmDLJT4Z 29J/tY3BPS4WsQVZy7KyQGaVr/mnpANufYAuCwXvAQfsXWJlhiAD8OceVxGbpgqkmTh5 4/ifGod6JP6Ce2kqarM8btg84UCdTdmGlfxF+B8UvEsm9b0RrYP+0rCN0hjMMUa1QVoi xpoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jyVgl2xu; 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 e184-v6si16712915pgc.475.2018.05.24.02.51.41; Thu, 24 May 2018 02:51:55 -0700 (PDT) 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=jyVgl2xu; 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 S967634AbeEXJuv (ORCPT + 99 others); Thu, 24 May 2018 05:50:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:42996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967238AbeEXJuq (ORCPT ); Thu, 24 May 2018 05:50:46 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 663DC208A0; Thu, 24 May 2018 09:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155445; bh=fBJGZvwO9LaZkFpJV/uVlguCzJkEjOwucpeawnp20w0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jyVgl2xuGonKweeIThHj5yn5uyiAxZIKUNsZH5gjsDiE6g9uPo2WKy36CEFn1k12t aE/kVafwlC+miUVt92HLrOvOjGD0BTgrFCM3kuSo+2Kf5e6o+mwqVjfdy2E9FdCFJR ns8solRqy5BY5buE1ud0/RfHPVEbmZnI4ieMhFLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Sasha Levin Subject: [PATCH 4.9 88/96] serial: samsung: Fix out-of-bounds access through serial port index Date: Thu, 24 May 2018 11:39:11 +0200 Message-Id: <20180524093610.647235627@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Geert Uytterhoeven [ Upstream commit 49ee23b71877831ac087d6083f6f397dc19c9664 ] The s3c24xx_serial_ports[] array is indexed using a value derived from the "serialN" alias in DT, or from an incrementing probe index, which may lead to an out-of-bounds access. Fix this by adding a range check. Note that the array size is defined by a Kconfig symbol (CONFIG_SERIAL_SAMSUNG_UARTS), so this can even be triggered using a legitimate DTB or legitimate board code. Fixes: 13a9f6c64fdc55eb ("serial: samsung: Consider DT alias when probing ports") Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/samsung.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1813,6 +1813,10 @@ static int s3c24xx_serial_probe(struct p dbg("s3c24xx_serial_probe(%p) %d\n", pdev, index); + if (index >= ARRAY_SIZE(s3c24xx_serial_ports)) { + dev_err(&pdev->dev, "serial%d out of range\n", index); + return -EINVAL; + } ourport = &s3c24xx_serial_ports[index]; ourport->drv_data = s3c24xx_get_driver_data(pdev);