Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2529485imu; Thu, 29 Nov 2018 06:27:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/XjjDmkEGBqfm1QuRMgBYT8rJ6CdXPygiCYSoVplowypqEeGaC2YyoxUpHgDzRU8MyZXGUO X-Received: by 2002:a63:f515:: with SMTP id w21mr1433438pgh.220.1543501678353; Thu, 29 Nov 2018 06:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501678; cv=none; d=google.com; s=arc-20160816; b=0w6OdrY3QQdj5g+RninrRAG6twVEsjT2SDqFeF61gXDybOvCQdjR9SA9EAPnyA6PES POZjZgr33aBaktJTzbUQ+bZq/EykO11CNFQHZlYOg4KjMI6u/X34LWPMlt8HxXeh6SYq y6e7t1879W2DT8QtTtNPUAPatPUF5Qg6yTosfsN07oBY9V1m8IapbPNdDuDlZKqoj/kP v5G0LlgkiJzG2+cQV/KhYaedUr10XTFC1NuafF2bsSpJff7aV1ngeeftekEyrBWLXKIj Fl1HAbeslYuZeRqX+q0OtLiklv+vGZ465IYQpsaWH/TtZ8IxoXa4kN5TtLxuwXF3d7DZ qwBg== 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=AtFUFMszpkSaWBGqUW8P/pl2lDOoh7Z7OyvfvPegV8I=; b=SymO5JRfUNtfqySdVLoAgrye7NjQdPgu4/gUzZKOh4jFkuI5gvIcOPjvVShiXjceVV U28jZmj1Hpv9njZ2501vT8PGolrkjPFpiDHRo7iZJgRq/DiVdhbnmg9+F/FkQlfSKaXN VTVEN4ZmFavDGmirnu8SvOIoRScdp9ahB9xy147+2rrsCtjorcCwGlwUzONsfR9fW1i+ Cx3OLCdXNzfhZq3NaP3rUD4n9am8byZjTg6nKc5Jt/WwztrVnywcyOxvgYEv5WJzVjMU RWPfI81cSlXB/FAmeW9+w5Js+BM7thTOd5aa/mjLgNs/6SxmosqdfQ//rmPEyZUBmvdd Wf2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g2aQXQ5+; 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 205si2167417pfa.199.2018.11.29.06.27.42; Thu, 29 Nov 2018 06:27:58 -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=g2aQXQ5+; 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 S1733119AbeK3BbW (ORCPT + 99 others); Thu, 29 Nov 2018 20:31:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:58870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731628AbeK3BbV (ORCPT ); Thu, 29 Nov 2018 20:31:21 -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 673252133F; Thu, 29 Nov 2018 14:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501549; bh=RPblNFY2qCdYDMrUeWLcczh9DYrdJok0ptvumGJ7H/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2aQXQ5+wSARpRK4kIqJ8LTQvsVeByNPqM5sbIJbPDfAJ9NIVpIPJj9Dd8AzsX2ev BnNr9oSQeQEg3XHwHpFvuU0XrwIkn+ucEtDK+WAnyGgyEzdK0mzaIYd+xRsqV5Y+rZ rylg7pVrfwTUSwMVpNRiA4pQTJ9hE0K2/YY59or8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Hartkopp , Marc Kleine-Budde Subject: [PATCH 4.14 042/100] can: raw: check for CAN FD capable netdev in raw_sendmsg() Date: Thu, 29 Nov 2018 15:12:12 +0100 Message-Id: <20181129140102.440259394@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: Oliver Hartkopp commit a43608fa77213ad5ac5f75994254b9f65d57cfa0 upstream. When the socket is CAN FD enabled it can handle CAN FD frame transmissions. Add an additional check in raw_sendmsg() as a CAN2.0 CAN driver (non CAN FD) should never see a CAN FD frame. Due to the commonly used can_dropped_invalid_skb() function the CAN 2.0 driver would drop that CAN FD frame anyway - but with this patch the user gets a proper -EINVAL return code. Signed-off-by: Oliver Hartkopp Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- net/can/raw.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/net/can/raw.c +++ b/net/can/raw.c @@ -745,18 +745,19 @@ static int raw_sendmsg(struct socket *so } else ifindex = ro->ifindex; - if (ro->fd_frames) { + dev = dev_get_by_index(sock_net(sk), ifindex); + if (!dev) + return -ENXIO; + + err = -EINVAL; + if (ro->fd_frames && dev->mtu == CANFD_MTU) { if (unlikely(size != CANFD_MTU && size != CAN_MTU)) - return -EINVAL; + goto put_dev; } else { if (unlikely(size != CAN_MTU)) - return -EINVAL; + goto put_dev; } - dev = dev_get_by_index(sock_net(sk), ifindex); - if (!dev) - return -ENXIO; - skb = sock_alloc_send_skb(sk, size + sizeof(struct can_skb_priv), msg->msg_flags & MSG_DONTWAIT, &err); if (!skb)