Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1964928imm; Thu, 24 May 2018 03:42:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqNegWOHnrG1wsi70sWJeUm34NIRLUUTejZM7EWUqtQHd9jRhXvM2c5qQPNrnaLMioVbhUO X-Received: by 2002:a65:484c:: with SMTP id i12-v6mr5428043pgs.162.1527158547994; Thu, 24 May 2018 03:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158547; cv=none; d=google.com; s=arc-20160816; b=TR6UsVz8vsVdE/snxoqwF/ivrKFCJUlFqjgQzYAxZJX56ilQllzTgFh1kWmQLVJUZZ kT4uqNG7KASm05s1KhBWfft6KtVKuvEN7fnNDiXm76pCvAYRZYANmzc4xcda3P5i24UC r35aKkZjOyeAZFuMPw0aUMMXdVwTI4fBcz8B5iE6qr8eWkJRZ5MhISWaw2F5S1ttgaMq u6m6hYxJYHUePK7pQ227ITL72FwzFlTFxQlxts8tknKuiSpkZIRKn4qNpJ+boxhnDIRr Tlu0hy7qTJRopha0iWzl0g9RKATvD0RAGFl+Q8BUCSGgjjcv9JYIYnWSTVsMZ5bhjj7y hF2g== 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=Xa6McjbQb/txnn2w9R4AqDCofaonF9Lj0YhS4NElCa0=; b=TUopnOwWhzv+4NHL8Ug5LYSrJmuUsJJu+niRNUEEuPeYB6+tNBHvxwqa6Gkp368ZDv i3ZX/nCCWbzRUfN05yRdjHC8EEBRymVx0KA2p7wg9TKyKvAw6jdBBif2fhXvqkdEteNX YxEGmxNXTGd5PO5WosdHIv0Ouhbq5pVtvqfiI5spY9Wox7NeBbHDgPQDtv5uQ7Uh8NX/ KWdcOIbhyK5FnQmulLjjcDzm/1cEeK57I4GvRRMtCNFq3qk91GhsfU+BwN3tQtTbY7a2 8XYZGB6borhYGTndOuolRyLZ7lLchjf84I+fXPDplLIeBwzRH3JFict1KMLazwytHPy3 UBlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GFBQF8pN; 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 67-v6si20802815pla.475.2018.05.24.03.42.13; Thu, 24 May 2018 03:42:27 -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=GFBQF8pN; 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 S1030673AbeEXJ6q (ORCPT + 99 others); Thu, 24 May 2018 05:58:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:38786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030612AbeEXJ6l (ORCPT ); Thu, 24 May 2018 05:58:41 -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 3CF1D20893; Thu, 24 May 2018 09:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155920; bh=lHIGi0VRbsbpF3TyA2B60J/h95JW4M9n0b3hkJ+Abuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GFBQF8pNKKXlqMvQ1cK0kNFQH/WtymIyZRaP89C0CsX0sDnwBl9WKzU/DN80uyJ58 Bd0qBVzTCq1AtOGLA5jyfEp1bxH1533+irQywhwaTHuJMKHLpNn7cw63sECdOY+dXw ihH/xhWlXJARGRjzowqCHe+p7Y/veqQdD8RmN0nU= 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.14 152/165] serial: samsung: Fix out-of-bounds access through serial port index Date: Thu, 24 May 2018 11:39:18 +0200 Message-Id: <20180524093628.224421697@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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.14-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 @@ -1821,6 +1821,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);