Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3671142ima; Mon, 4 Feb 2019 03:10:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN4EplplgvlXhYY6FndTEO1uSPTehSW2ZZqPHE2rTY1yoxEc6nBmIKNAN1icQnqYfhHtmNzk X-Received: by 2002:a62:7e13:: with SMTP id z19mr50472345pfc.94.1549278645688; Mon, 04 Feb 2019 03:10:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549278645; cv=none; d=google.com; s=arc-20160816; b=lOk7EZ5w+aSWReMNo8OdyDhe4bV2odu/GSSZApbB11iL9TWHCWTJ5Ey3mou4zZlW3e s6VyWxcDcCnMhVpjaXqzEuMrKGwSmAyEHfn7y8k/YtvzA0iJH3Op3pDM7oS4kd6u6sCf w0I27zX+f49KWf7x/PfqkbN1jgE9tQ9TcH0q0WY/HYg6iaxrgIo1YarPE3qH6JPcZQKo E01egiiGMhp57jbYUXKFW2SG1/udBPVHRpBzjKAQGd61uQtgejM6voumd+5MUBCMUvxz C9nzyeZ6rWb72GxfQtDQPaB9y8Dl9oTDhxk7PJCCn9p39ObR+XlgHhd6M0mUXzGSu/1T 5EYA== 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=VkDGjhNMEJ6UpmXYrZeJuL+0npLDoqDTNbtC9jh/pMo=; b=lRYg8WFM2SUcDog43oQoLb3PxLaW9SsOQc534rFUNjx/jd4LHJp5pEYHgBjUPRRpGv jLNmygVTsgdZEJFIH1w+ZkVu+daZo4tpRh3KYW0A5bUHlDCB0y5NAEnhi2sOQCSV4KSk 2aCPlUEFl/I3H01D5eN35HlWQWZ4Qsc/ASoLZ+Mr9KOGaard6/dCmaWQ3O0pOjCM3DNP eUjLvPwQPJHXR78GHfsXsd3n1mqW1EjXP8Qci/MrkQNaalA0xDsh1QnUMxxvrJLpPmfE qsofE1amvHB6DDHB9augCEKLRY6hQjobi6tQy8TCNmHmOLRenuyRJ68w1fOs1gnps3+4 k6Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MHXs3Fnf; 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 i3si3201178pgq.217.2019.02.04.03.10.28; Mon, 04 Feb 2019 03:10:45 -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=MHXs3Fnf; 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 S1729345AbfBDKlE (ORCPT + 99 others); Mon, 4 Feb 2019 05:41:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:39020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729241AbfBDKlB (ORCPT ); Mon, 4 Feb 2019 05:41:01 -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 62C24217F9; Mon, 4 Feb 2019 10:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549276859; bh=HsKOtZk31acJrDF//CkFWjJZ3aAdDsJ8SboyL0Yo02E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHXs3FnfSqVQrMI4Hj7NAeEWWHPZtl6FRlQ99E3h4b4VPPzghCD39TxOBGaPd4A1O llQ1wUogIPi+dsKtdGUMRBYL4s8sKS5tP9wwiO59R8u13Uf/Ly5lMXqmFRPRGY+l4h DHPoWqi19nXcvA3xgVxp7UwOWJhp6evI7c0zt/Io= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manfred Schlaegl , Marc Kleine-Budde Subject: [PATCH 4.4 21/65] can: dev: __can_get_echo_skb(): fix bogous check for non-existing skb by removing it Date: Mon, 4 Feb 2019 11:36:14 +0100 Message-Id: <20190204103614.168183423@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103610.583715954@linuxfoundation.org> References: <20190204103610.583715954@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Manfred Schlaegl commit 7b12c8189a3dc50638e7d53714c88007268d47ef upstream. This patch revert commit 7da11ba5c506 ("can: dev: __can_get_echo_skb(): print error message, if trying to echo non existing skb") After introduction of this change we encountered following new error message on various i.MX plattforms (flexcan): | flexcan 53fc8000.can can0: __can_get_echo_skb: BUG! Trying to echo non | existing skb: can_priv::echo_skb[0] The introduction of the message was a mistake because priv->echo_skb[idx] = NULL is a perfectly valid in following case: If CAN_RAW_LOOPBACK is disabled (setsockopt) in applications, the pkt_type of the tx skb's given to can_put_echo_skb is set to PACKET_LOOPBACK. In this case can_put_echo_skb will not set priv->echo_skb[idx]. It is therefore kept NULL. As additional argument for revert: The order of check and usage of idx was changed. idx is used to access an array element before checking it's boundaries. Signed-off-by: Manfred Schlaegl Fixes: 7da11ba5c506 ("can: dev: __can_get_echo_skb(): print error message, if trying to echo non existing skb") Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/dev.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -426,8 +426,6 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb); struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) { struct can_priv *priv = netdev_priv(dev); - struct sk_buff *skb = priv->echo_skb[idx]; - struct canfd_frame *cf; 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", @@ -435,20 +433,21 @@ struct sk_buff *__can_get_echo_skb(struc return NULL; } - if (!skb) { - netdev_err(dev, "%s: BUG! Trying to echo non existing skb: can_priv::echo_skb[%u]\n", - __func__, idx); - return NULL; - } + if (priv->echo_skb[idx]) { + /* Using "struct canfd_frame::len" for the frame + * length is supported on both CAN and CANFD frames. + */ + struct sk_buff *skb = priv->echo_skb[idx]; + struct canfd_frame *cf = (struct canfd_frame *)skb->data; + u8 len = cf->len; - /* Using "struct canfd_frame::len" for the frame - * length is supported on both CAN and CANFD frames. - */ - cf = (struct canfd_frame *)skb->data; - *len_ptr = cf->len; - priv->echo_skb[idx] = NULL; + *len_ptr = len; + priv->echo_skb[idx] = NULL; + + return skb; + } - return skb; + return NULL; } /*