Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1931749ybv; Fri, 14 Feb 2020 08:26:24 -0800 (PST) X-Google-Smtp-Source: APXvYqzn/h6GHD0hn/93Z9tMaV0zo3PC7TC6YWuhxrMhmu0cWziK4lOQc3ytQZ+I5DKw943JOqQx X-Received: by 2002:aca:a857:: with SMTP id r84mr2334421oie.41.1581697583945; Fri, 14 Feb 2020 08:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697583; cv=none; d=google.com; s=arc-20160816; b=HM4qrxWZ1lJF4bwS9Cmj6n0wJlQdeQB5DwH6ol42Tw8GlvmlWa/U2CIsowiHIH+Z3A U+ZtKRrt8GiBtCv03fWdzdBGNoZ9npsdAv1jva8FBEB2EGj0vVcAhhvCwRypYf/2/E0F auicigQJTftva7XTtelR0dS99MObvNZnCqmGvbBgRmTJCQWiWuDt8/IYAXkmfrvmnVEJ /3RKlteYbjQTuSn09D5F4APxL2zES3FYTL0hhGk/jkaWNOV+//KysZIQ68WLtHPEbVyK eRQ4v5XjEvaHFkl5d6ihkp7oCp4d3iR5jv4pObCz3vdnxkFLAgyOpS4gYB1yb2LIBqOI 2ZLA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iCuPULROYglAiLyeppJVUb1Nx7nj6CThYyCnA0jMtus=; b=ahZikJUoOkZiK3rT+wRPM2FpZEJ2y0j4XEnjtIbLW9besdYjCFL7K1N6GIsnzReReW 7uBU8T5Lu75mCMDqgW6/i8A5ddwX1f/g4icMw9Dmxk9gb9W8bjLLKOPzybDHyJ39tVgJ HCImXD52Bz8Mz3InPrCVkF6b4QyzWmsX93O9Xv1J4zF8lVYMIooFOXreODWpruNqzZFT 5J/0juZI92A/dvalf9DwShBYiAeEzJ2MuCUKD2CRa+r2Hvu+MEB2nx9jto1RYQKfUd6Z xoMArLkM22WDIwZix8VRAVGEmwJLM4XARbATvklZylfOni2rP5bBOEvI4SiqXwBhx/LV xRow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=emecN0pS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h18si2855626otr.265.2020.02.14.08.26.12; Fri, 14 Feb 2020 08:26:23 -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=emecN0pS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406199AbgBNQZp (ORCPT + 99 others); Fri, 14 Feb 2020 11:25:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:60060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405685AbgBNQXh (ORCPT ); Fri, 14 Feb 2020 11:23:37 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C80424772; Fri, 14 Feb 2020 16:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697417; bh=2+cmvOTfjefLg7z9K6NEbzvp0YsZpeIAhXSEBWBCpx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=emecN0pSriW2P3YGZ3ddns5SGhjR+RO9UrfUWV08Iiqy+hdzzfg6f+AMWN55aDw6O AtBRQTI7/I3fU+C/r6/28iNn8xkMnuy9aNptBHGhty/6Pkg2RIpQtcSoTdfz4fs+DW NkfwB2B+VupVf9V2jynJWe/Z6TwkT/gYPU/eitXo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , "David S . Miller" , Sasha Levin , linux-ide@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 107/141] cmd64x: potential buffer overflow in cmd64x_program_timings() Date: Fri, 14 Feb 2020 11:20:47 -0500 Message-Id: <20200214162122.19794-107-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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