Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1929783imm; Thu, 24 May 2018 03:06:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpIqIoX0NKRYWMTaVMF6ihjKc8mSwk+HHy3g8VViBsSPbNZ/VdvESrDgdrSFTquT1xVW2qL X-Received: by 2002:a17:902:680c:: with SMTP id h12-v6mr6810872plk.113.1527156398726; Thu, 24 May 2018 03:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156398; cv=none; d=google.com; s=arc-20160816; b=JCyN+NSR0SmXxJ0LTgnBnyIxov7KWKMxSKBdF+WXwtJIb5PfEfMXO7eE9xwdZ1i5iK J9FcC9ykzh73+epGmANrMthvg7cBeiGG265pueMnCvVImi97P1xgoH5tPWb/Xludy7qZ 35TSIPRuwLHhdwHnPNnmM7I5hLvj64Zzs+TSj77ntSPgDV84Q+S0sPz0BdTdNV1iUr81 qhf6UH92wEm3AMkRqowlXwmsy6Gpu/wk+vADECmFDAIh7tlkRcdc2EkQPgbw/37873IT kJfuUQnhEh8Ge0FAGI3gqVxeXr+sX0Q106G4YfACJ/Y2tueAc1+VLX/wH1ZKnv5pY9XB ruTA== 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=XxkLbR1DNO51YvZdbv4FQj2109y6aMvB94tzeRKSsIg=; b=XDgBkyqiJX14euq9AlofR4f1LtWw0/CoekdNrrzJNvMzJuicxE+Flya97mez8dKvVg IZDh92mJ6WE/l8ZJztu8tffPGlrr3dsFIr0KBUg+G/W5tMno6+jllsVCEU2MLZq2yBDd YWSK1Rq5BoaTAD2DRXGPGoq7AC15waLV1SHNlAxBROv1DaUoqpehgRnGNjaRyVOOiXbA 5Xq1UcCSRVRLunusZePCJyXrHW7aQv2V5NHBFo4qOMGEe+8HjmFwTkQv8S2mc8Y2a/EC ULnQuLEcM17veBTQ6FWQt+scbkL/kPdhyBhwCdMok/nJHK1SzU9trPMMBNoy+xxhkxyN KFZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IA4lGUO8; 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 a69-v6si21024013pli.391.2018.05.24.03.06.24; Thu, 24 May 2018 03:06:38 -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=IA4lGUO8; 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 S1031613AbeEXKFg (ORCPT + 99 others); Thu, 24 May 2018 06:05:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:54652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031130AbeEXKFa (ORCPT ); Thu, 24 May 2018 06:05:30 -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 1C0BE20899; Thu, 24 May 2018 10:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156329; bh=boSCQJYDpgkVevjA3ecVenKEISxpauMA8KWqlToLv7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IA4lGUO8gBPADRkeYX9GaJunmRCJYpsPDA0y+k5f1uvqqEkhU+G6hgeKC1YSF2p1S Uz+CYInL2ivWuApMs8FX9PeSjp/grfdb96nBtkcy6DX2jRgQFfZMh8BBxWUnzxcrwx k4a2MZPx1mtP3prIp6DIjT2XzFC6CWag//Hhkt+c= 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.16 148/161] serial: samsung: Fix out-of-bounds access through serial port index Date: Thu, 24 May 2018 11:39:33 +0200 Message-Id: <20180524093036.055303902@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@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.16-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 @@ -1818,6 +1818,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);