Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2527930imu; Thu, 29 Nov 2018 06:26:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/UfYf6Q59f7rjKvNb13eX0bzbtSfDPHIyJaI+w7CRYcLXTP60qUrMGJzsJDsEK+sfOgoLVL X-Received: by 2002:a17:902:724a:: with SMTP id c10mr1710201pll.51.1543501601548; Thu, 29 Nov 2018 06:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501601; cv=none; d=google.com; s=arc-20160816; b=iexsKjxEK1PvclmdG9kWVo32n/beGq9cSRmw7qcayFYCUaNBzySyC+RMewqOfmP82l p3MlwTW6QZPZIqUipWyuNq7S5gV2Gx5+miPHEWUMH45c+DzNJiHFGIAc/H+9qHKRAC8Z MZo++pxlxGgvv0Z5TADHCCrCXCRqgCr1SQuvCZEmiiAiVImlapwOcjtmlqOAtO+8ihxa Jrcdg3xylRNMJEdiwCyVfL9o+nI+m/9UbSAzdTE1ipjCCyi5YYOhqhZU+QiCZ/aBXD7i /zR2imchGEPsBM0Zfok7VNIBsJL2mcSrOQ04MzAfVS1In4NgLsUhBpC5MUm9xDdnaHGS Du+g== 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=xF1rVb3UlJ1M2ziOplkAsiI0/9zii5Zlt6iGBeKbl7E=; b=yKHuqvYTasB2ocWM9Iul121wN3rWHN3apd7DR2UU2WtjcMGb43pZAgd6QikR37IXNx u4UZTOVSBh5SHqPc0IgosxxGwV4xPkr3YDYOTYhC/IGViz1+D04P2uIvzVL2DHTRFH7h aVQKhiK5rTXp3NvDjNDTntogxEMHqf7D3xBgQ7HtaJmnR9sZq0yJbfI+Ws4xvoQSpjWt 8gvgS7VN/VfgeK+GX53odRwC7Vz6J6d9DfeEBkvAwHzvWbeNBOAZu73LDSY9EuT1h2XA ptq9sOOKxtdqHJG+tvfyV+ykds9tGoldO7ttd2NNjgQPtprhxSP0RoxDblk/USyB7xWz sIGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a7MZnnNu; 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 l186si2036231pga.498.2018.11.29.06.26.26; Thu, 29 Nov 2018 06:26:41 -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=a7MZnnNu; 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 S1733052AbeK3BbK (ORCPT + 99 others); Thu, 29 Nov 2018 20:31:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:58576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731628AbeK3BbJ (ORCPT ); Thu, 29 Nov 2018 20:31:09 -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 4E81021104; Thu, 29 Nov 2018 14:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501537; bh=hKtQfeVLBTfeBGmip7Y6RpRdZKYow4E7aS/o1XJAcM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7MZnnNuywT3Mr/jS1WzzyLPE/VajhvE30POtWGkCGgTLuHoyvv2E5l57c7PnrX/U hE5yq7bClLrywQDug/qQsY0e2yDqKiw1MUKlWtxP3rAEUkqeu5reWSSMQHYBvF4TEt CaEWzdrZUeaxeO0XgcFbDQWGX9gbtvu/MACN4ueY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Kleine-Budde Subject: [PATCH 4.14 038/100] can: dev: __can_get_echo_skb(): Dont crash the kernel if can_priv::echo_skb is accessed out of bounds Date: Thu, 29 Nov 2018 15:12:08 +0100 Message-Id: <20181129140102.078315742@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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: Marc Kleine-Budde commit e7a6994d043a1e31d5b17706a22ce33d2a3e4cdc upstream. If the "struct can_priv::echo_skb" is accessed out of bounds would lead to a kernel crash. Better print a sensible warning message instead and try to recover. Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/dev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -480,7 +480,11 @@ struct sk_buff *__can_get_echo_skb(struc { struct can_priv *priv = netdev_priv(dev); - BUG_ON(idx >= priv->echo_skb_max); + if (idx >= priv->echo_skb_max) { + netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n", + __func__, idx, priv->echo_skb_max); + return NULL; + } if (priv->echo_skb[idx]) { /* Using "struct canfd_frame::len" for the frame