Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1619178ybv; Fri, 21 Feb 2020 00:24:33 -0800 (PST) X-Google-Smtp-Source: APXvYqz9LWVz+hDAavaPQ04Af31gN1zYPEYOeOY1W/6B2ynjAzPFBcrkYd1TWFn35dbUWQC6zDsm X-Received: by 2002:aca:f517:: with SMTP id t23mr984824oih.160.1582273473294; Fri, 21 Feb 2020 00:24:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273473; cv=none; d=google.com; s=arc-20160816; b=o1p61JuYu9HTr1pfuwA6xun0m52kXqcptRYPVQLh+ybgxkWAcXjUu7FpuPFKdTKvZZ wSG21uyGb3/S4ESr2sv0j6Z5tsimRY6HZXOh65dhSFDw7ZpFRrg79Mu/sJBcBNAGZAOZ Kzr16yrvMN1HAilpwIHnrJwCZrW7PK/JpNTx1gaV0wXXnAE0/EejkXayUrIcNPfJSqqc IJ2zDjxiLjD7kPLajUjfvjItvR9J7dGdtafhDwWQintTM8/HES0FEsb9UZ1C5m+DAYJ8 N0ZKC21/gDBJeUq6bRIIcBeUHw5Q8cg0f6+GFxcNMTwcYTDR9tsAPy0rfCNLq19mcpcV ExbA== 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=iCuPULROYglAiLyeppJVUb1Nx7nj6CThYyCnA0jMtus=; b=Zwm1dylGlO4kAw8DZk/z2El/5oK9Q/vaMVVnfR+xkI1X9g/MpLeIiuBVRFWxeNNhu/ pzaJ68th+E0qmyOI2ZUOQIePFRYD7JwTZGcCGlG0TENrQmAdFiosdVdQ1wahw8bLeBjg fUxfahlW+dlLKBV6xVFUTQKPw61BaSnTn90ls2T8OXlnJb+ZTQDDsT4ydWEl9XmVlKGt +ng3lij9LTnmlaKQ1ZEg70GXfJU0A3zbSbMgE/QSiVdtNR+ergFNZDFf7tCUzD+QA6D1 HaUIS+rEJi+DKlojDvEnd7+CDJh+r/2jZTmh7pFpXw5z/cqPj/urbIs8+K6PWoYdcTTR gjBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XklDQV6U; 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 t137si507512oif.61.2020.02.21.00.24.21; Fri, 21 Feb 2020 00:24:33 -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=XklDQV6U; 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 S2388348AbgBUIWk (ORCPT + 99 others); Fri, 21 Feb 2020 03:22:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:34270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388334AbgBUIWh (ORCPT ); Fri, 21 Feb 2020 03:22:37 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 B92772467D; Fri, 21 Feb 2020 08:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273357; bh=2+cmvOTfjefLg7z9K6NEbzvp0YsZpeIAhXSEBWBCpx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XklDQV6UFWI9aAd33JBIUkpF9ii30QEJHAIZNAU/vqk3IeVv6GyJRWHx1y7BXUDLL 9CP6ovsM/D4P2MUw1nnNx/Ar6ik1QMescLnBIJd/r+y1wsl5GBqJjU8nSjuZSRDLoI m+kF0qSCqInAbyieQqYA8Kzq3BgHUHgjdj53WsQg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 141/191] cmd64x: potential buffer overflow in cmd64x_program_timings() Date: Fri, 21 Feb 2020 08:41:54 +0100 Message-Id: <20200221072307.595664535@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Dan Carpenter [ Upstream commit 117fcc3053606d8db5cef8821dca15022ae578bb ] The "drive->dn" value is a u8 and it is controlled by root only, but it could be out of bounds here so let's check. Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/ide/cmd64x.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index b127ed60c7336..9dde8390da09b 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c @@ -65,6 +65,9 @@ static void cmd64x_program_timings(ide_drive_t *drive, u8 mode) struct ide_timing t; u8 arttim = 0; + if (drive->dn >= ARRAY_SIZE(drwtim_regs)) + return; + ide_timing_compute(drive, mode, &t, T, 0); /* -- 2.20.1