Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2689562imj; Mon, 11 Feb 2019 07:04:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IZhRUdIU1nJ89/EsV3anXu/52HbZzzk7bBJK0pIp61uqJS9sO+y0YvUz+3ktHubVSWEcbbs X-Received: by 2002:a63:105a:: with SMTP id 26mr12639760pgq.184.1549897462096; Mon, 11 Feb 2019 07:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897462; cv=none; d=google.com; s=arc-20160816; b=jNQPt2Jwk0FhqlVr7cya0v4/QZ1s4kfrJfCTxOEVYX69no7MjQ/LPizTnn83sqQ1sy IzkaY1jszipak/BVKi6ux0fsDsJJ1GvhBYLOn1LiMd1S02VlXB9UHf7dIqoSqzmzt3Xz EcQL3u7QAnlnxrz6kbhcyfwhU5W0vFcCtk+FemqKrh8T2NOOAwDWV349Qxui+KvzNW2a 3BzgK3I8ofY8UiftCY91EEXeoIONo/21AHtqhxiNLsUbY4DMYaVLdMDLgkLVgHbGspej 8nLyuOiujiyJdK3pBBTwpr4Kxt9Mp1oQ+t4ZMSAu7Dbgb9PHX/zm7eFTOuMBJm6hIfb/ MHyg== 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=HNgOLAGcm/c/0LDrQMVnauUnVzxSlNYTTRzDz1zShtU=; b=coqV4dSyLgselloC67D99rarKjK2DjdfrH3nYhCbDmwPVHN1eGmKUg1kn7Jt1PGgqS l51cPzQ/onh2UvSvNesAcoh8kTNyM7GAG21XUVUzxvRjWO8/o1YwxobL5/XVGQxTJzGm zOgCQiFeU0Y5HR391U4LnrGmyyBiHiycSbQeBeU5fxau/PpaX/I899dFG1Bb3DubA0xy F4rJ9EmJERpV8eCkBegSpqq0/UbAA7Y0O3WxUg2aEsZzbHdxkrpLeCai8q+ekAQezJ6n 0P4ru4+SU7dpBf89GpdaVgDsbstzR9nfaynZpiWCjfA8vI+Q+uSrNMmOhE4bmVSmPNqC M7AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RkanaOrj; 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 j1si2450312pll.219.2019.02.11.07.04.04; Mon, 11 Feb 2019 07:04:22 -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=RkanaOrj; 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 S2390411AbfBKPC1 (ORCPT + 99 others); Mon, 11 Feb 2019 10:02:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:50596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390405AbfBKPCY (ORCPT ); Mon, 11 Feb 2019 10:02:24 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 1A860222AB; Mon, 11 Feb 2019 15:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897343; bh=V958nLWppYx+37qg+PqLz2JfypNUSeHxylTcn2/MPr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RkanaOrjSuBugxEks5rknjM4+Oc8hLm8oKuBNQfE/qTJvP2Eh2HWeQhZZmWogDX5J BdRV1A8dFeIzWjUfgjzV0RPRRKTBdJhLEvV7MmKYnPwTkufL9ve909dSFGPrTFCrq0 fs1UjgDy5RsnvZa13QP2/eoI26O63Eq/8TLQZOG4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" Subject: [PATCH 4.14 170/205] skge: potential memory corruption in skge_get_regs() Date: Mon, 11 Feb 2019 15:19:28 +0100 Message-Id: <20190211141839.479602359@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 294c149a209c6196c2de85f512b52ef50f519949 ] The "p" buffer is 0x4000 bytes long. B3_RI_WTO_R1 is 0x190. The value of "regs->len" is in the 1-0x4000 range. The bug here is that "regs->len - B3_RI_WTO_R1" can be a negative value which would lead to memory corruption and an abrupt crash. Fixes: c3f8be961808 ("[PATCH] skge: expand ethtool debug register dump") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/skge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/marvell/skge.c +++ b/drivers/net/ethernet/marvell/skge.c @@ -152,8 +152,10 @@ static void skge_get_regs(struct net_dev memset(p, 0, regs->len); memcpy_fromio(p, io, B3_RAM_ADDR); - memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, - regs->len - B3_RI_WTO_R1); + if (regs->len > B3_RI_WTO_R1) { + memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, + regs->len - B3_RI_WTO_R1); + } } /* Wake on Lan only supported on Yukon chips with rev 1 or above */