Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2535803imu; Thu, 29 Nov 2018 06:32:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/XhE9p6CzL1npc3iEbXnIDHLPMIBev1uvFzHvC9laWXzQOj6KoKy/p4XqQyxNDHdc/troVV X-Received: by 2002:a62:160d:: with SMTP id 13mr1578523pfw.203.1543501975217; Thu, 29 Nov 2018 06:32:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501975; cv=none; d=google.com; s=arc-20160816; b=nQfXl+hc8Z7idblnVWX9+yK5p3OGeVlhMM9bljC4UIeTcUBPtUZI5GzqOldmBmUT9C pi0ehUUIGAdcV3FMz2TVcWrcf6zNC6x4USerUmnsrB2wEDesmjzjgTU209O4gzz8b+N1 oeLQShjf29+90M9+BZmcE+foCjPerV0AeCFClqJA2X5IK5aNyzEZoNGhLYI0g4BolZUB Nyh60rc+aajwHR7/HybvZCl+HylpZ8snC8Yhx/kYQP0MnrAoH8dxIY/Z8VyXFkT5NVzh oOLPXyXZEruNzSMafgx0C1DXLwFZ+KSNdTZOpg5M1T3RZf/MVz6KwlN8nkPQSuJM2URP h0sQ== 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=fo365Ty5SAQBEhJ12KuQhOsxUDQFWhhLmkTxUlZy7xU=; b=lpvzaOEM+W7maZvMAi3TdC5g7aZqEbu0s+DmKf10sQO/6rQjpg+eZqc/NabCmJ2vWw V9OJeA1syG6p1CztKII9h91K/bDHV2r5FrnB8k/zSqWLgD1yxfupGowhFvIZRFLj6z5c kDMSR8DSZJGozfKT0BvjUHmhZJ/LgPUJzYMdU8WaciHxH4DGOFrtt70S3/gx7TeRYO7V QYNlISvbeJu/DkmbLC+avAKUodOkkcK/cigienshD9UStiHQhl5ym6fDw5I+lwJnCUhO gQnTsvfTnXp30ItxP+iLY8C4eYLBj2QCZuWbhC7KOLJXa4KZfAhh1+n2bb+yzHgOt26Y DUjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bQMtJacR; 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 69si1744830pgd.290.2018.11.29.06.32.27; Thu, 29 Nov 2018 06:32:55 -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=bQMtJacR; 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 S2388718AbeK3Bft (ORCPT + 99 others); Thu, 29 Nov 2018 20:35:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:37824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbeK3Bfs (ORCPT ); Thu, 29 Nov 2018 20:35:48 -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 DAB742145D; Thu, 29 Nov 2018 14:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501815; bh=TSwb8zSIliG8pquJ1Dd+e9phszGWfwYwsbHJ7oEF+Mk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bQMtJacRAGTWXUKb/B6sQnMsUW8VD7pVoCAhy0ajV+anxoAU0WYzJpRllWy5nYIEM kfeERBLV9mXojp7lStPW/gbKjPtSnQggPD+KgruHS4yAW4HOjt9SBTcE+yVK4+nmgf Napcpow04Wxjabel00+yvl//2ZqGBKauNDjqAZ5c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Kleine-Budde Subject: [PATCH 4.19 051/110] 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:22 +0100 Message-Id: <20181129135923.326981375@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129135921.231283053@linuxfoundation.org> References: <20181129135921.231283053@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.19-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 @@ -481,7 +481,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