Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2499077imm; Mon, 28 May 2018 09:13:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoyQEDISGW4655zH/gKdJM4jH+k9yCnp9kXXtH3n/d9qnct9ZGx793u648InKR3jTnkdE7B X-Received: by 2002:a62:c898:: with SMTP id i24-v6mr14173891pfk.35.1527524017318; Mon, 28 May 2018 09:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524017; cv=none; d=google.com; s=arc-20160816; b=AVw/G6oe7eI3kmoKh6NHoI1TxP9x4A4/rRvAmURw0Qg9/Ts1bD5AmqtOJ5fUSMEQ8O Ky8PGvk1JYhB/smOM7JBxG4JVg0PUNOrHF9wkFnsrovAb8+nXTsUuxJHDb/2bEUgitjM L6A+3TiRIGUmnxwPKFdCKfHXNOV3uynQbYSS/Wmg4ZSjvh2/8M4EkionIbXsVszxrfHQ MG6gvEoj0kzQhXZFl6CpIBz7Fbgre4S9L/8IKZo4dS1hqxFeJmxW9bkKXAznVSgwOKEv 9QKp7+bo2aC9HJqpoCcZzC6878sxIBJXENGGtAZID4xdvI+/2bsZ3fcHdoAjrWwH6Ydq waCw== 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=EGMnNn0/qVVCWNUFVXv377xT80I4cZQRC90mrSu3aAI=; b=p/mySCk4vY9z9Xf7OQUq82CpRSoT65fex7unqVSzJOs3qkwnG75HptwLSAc4+u93P/ qG3lz1COe7AiwqeufiGpVWjUy/jsgG26Zbf5EIQG706zOEyzedrRVdCCvdGrJb95GtIR HaAAKTwgbEu/PNLqcLP9wSk4eeeDWypF9Ng7amsZzijblnUkYBhjbfNBVcJ0zWuoN3j3 v1GDqwKJZipq0b2RfBzhczv/+GuSYghEjcMu/xa4ExpkTzaqa9OVDwYEkRCLWQOQKXiW 42pjG+uJzztUSUkLye5k/mZ0zdqQtFCAAPUw+YVaCvGVKvrJQ7Sy7G9GikLxLyZUtj1E 6RYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QXsLLIFx; 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 b8-v6si32498713pls.261.2018.05.28.09.13.22; Mon, 28 May 2018 09:13:37 -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=QXsLLIFx; 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 S936509AbeE1KN0 (ORCPT + 99 others); Mon, 28 May 2018 06:13:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:33078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965345AbeE1KNM (ORCPT ); Mon, 28 May 2018 06:13:12 -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 A83282086D; Mon, 28 May 2018 10:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502392; bh=NT8r+qs/CHlIrZzhxuxgKjParUHxdpve05zIzysPdjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QXsLLIFxdQ3Cr4inl2u7MIQRxbsSiPy/UMa3OSFcS03NXQzSDJ0WVS0u+sFfd5h3D t7pGir4usmalYjY6PUMSTZxJM1FKClQeGOws6Qf7qnBk2fBQaPL5upGmFM+Pe0hyES +tf1gm4gfmH0bYJDYDE4VeLRl7nuftPZh//PPa9g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Sasha Levin Subject: [PATCH 3.18 168/185] serial: samsung: Fix out-of-bounds access through serial port index Date: Mon, 28 May 2018 12:03:29 +0200 Message-Id: <20180528100113.127942563@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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 @@ -1288,6 +1288,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);