Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2749536imj; Mon, 11 Feb 2019 07:56:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IYkeTuUydw8Mo37FtAqS6q74xdlf8qK7jt6niw7ZgeBQFgpbVqK/x+2UzL0xaOdH0lfT4tW X-Received: by 2002:a63:2784:: with SMTP id n126mr34696668pgn.48.1549900589507; Mon, 11 Feb 2019 07:56:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900589; cv=none; d=google.com; s=arc-20160816; b=qXgssQvleSb4r5Z+JBkmwOAgPb1TCUM60e4MTkPPr0RDP4bldLUUnhxu5Vwf/1yy1M 2Vx1VqmwiwTS8kMzzCEyU9Len6wjcPK6JKdmakSxRASfT4oDE7zkm37FbsFKyFwl8tvN aJel+tG20+9NDDiqnR9UUZ0rPGnxB1+UD0tvFw2ZEgbD4QjTUEiTUGy2yiWtc2b+PAa8 CphNZ/WcR+B8TRBcjUV6pjqGZxKk6cs/hFVMv7FhpPBxDgfIY7UtX5dE0iA6EfjzYRi+ WRP34IUg0IZQ6nbZvJlzcBStYn7CDm9nTxIjbmrXiO11eSZCfcS4EtJqAEIfWeszmjER bUQw== 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=/OtmUZTUOvXGQ7GjUX/x3TdMw0z2PEClBEPm0CduC7o=; b=Qegb81bdFtETL3U3I16I3P6ZW7mLaPGz9sNWd+JMPlOu4j+gw7207TNI9avDU/31Oj y8hdGkK/gwdk44z2hZExgDlH12qEcZj61kErsFQaw/exndx0Mg8Igs2yla63rFFfy4mg HacmnVGgfUyNllEv1Y8m5ZvSE53QMbvwpOtpMmbUX7gYu6x7b2I8a2czN0oA9l/VR0FL V6239qYvwrNkFHqQ5R2ZwhRIol44qAcojyLrUUpqw/A+jYcWRy/EM67csMuixPdLSnTh ONSrr/TPM29bgSeFHPrMCnooFskJyM/ebtrQoVorZRucK7AY+GqEvsD719TFswkR+3Uk KTqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tlvfRipr; 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 b8si9383068pgw.561.2019.02.11.07.56.13; Mon, 11 Feb 2019 07:56:29 -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=tlvfRipr; 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 S1731176AbfBKOgD (ORCPT + 99 others); Mon, 11 Feb 2019 09:36:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:44868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731138AbfBKOgA (ORCPT ); Mon, 11 Feb 2019 09:36:00 -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 425D32080F; Mon, 11 Feb 2019 14:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895759; bh=E1EYjcnK2uMgsfARZYoFDX7xe70HqrWuT3x9RaOwRZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tlvfRiprk8sw+OQwi2oQFTsm9QAgN83VPAJ2U43PcE46Y+hksTBp4ipeQUyx1vu+P 8GpEhTRmMFIaUZ8/2p1r4opYAGPDHqiJyFT1TQKvecGFMQTVYF1zm2FvYV/A9/zD7A baWJHaD8zc1x0i7xK358fOJfP1ywo3CF3hWM4yN4= 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.20 306/352] skge: potential memory corruption in skge_get_regs() Date: Mon, 11 Feb 2019 15:18:53 +0100 Message-Id: <20190211141906.338421225@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 */