From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Xie He <xie.he.0141@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 10/18] drivers/net/wan/lapbether: Fixed the value of hard_header_len
Date: Tue, 14 Jul 2020 10:39:06 -0400 [thread overview]
Message-ID: <20200714143914.4035489-10-sashal@kernel.org> (raw)
In-Reply-To: <20200714143914.4035489-1-sashal@kernel.org>
From: Xie He <xie.he.0141@gmail.com>
[ Upstream commit 9dc829a135fb5927f1519de11286e2bbb79f5b66 ]
When this driver transmits data,
first this driver will remove a pseudo header of 1 byte,
then the lapb module will prepend the LAPB header of 2 or 3 bytes,
then this driver will prepend a length field of 2 bytes,
then the underlying Ethernet device will prepend its own header.
So, the header length required should be:
-1 + 3 + 2 + "the header length needed by the underlying device".
This patch fixes kernel panic when this driver is used with AF_PACKET
SOCK_DGRAM sockets.
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/wan/lapbether.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 0f1217b506ad2..5a6f27298b90f 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -303,7 +303,6 @@ static void lapbeth_setup(struct net_device *dev)
dev->netdev_ops = &lapbeth_netdev_ops;
dev->needs_free_netdev = true;
dev->type = ARPHRD_X25;
- dev->hard_header_len = 3;
dev->mtu = 1000;
dev->addr_len = 0;
}
@@ -324,6 +323,14 @@ static int lapbeth_new_device(struct net_device *dev)
if (!ndev)
goto out;
+ /* When transmitting data:
+ * first this driver removes a pseudo header of 1 byte,
+ * then the lapb module prepends an LAPB header of at most 3 bytes,
+ * then this driver prepends a length field of 2 bytes,
+ * then the underlying Ethernet device prepends its own header.
+ */
+ ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len;
+
lapbeth = netdev_priv(ndev);
lapbeth->axdev = ndev;
--
2.25.1
next prev parent reply other threads:[~2020-07-14 14:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-14 14:38 [PATCH AUTOSEL 5.4 01/18] gpio: arizona: handle pm_runtime_get_sync failure case Sasha Levin
2020-07-14 14:38 ` [PATCH AUTOSEL 5.4 02/18] gpio: arizona: put pm_runtime in case of failure Sasha Levin
2020-07-14 14:38 ` [PATCH AUTOSEL 5.4 03/18] KVM: s390: reduce number of IO pins to 1 Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 04/18] pinctrl: amd: fix npins for uart0 in kerncz_groups Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 05/18] mac80211: allow rx of mesh eapol frames with default rx key Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 06/18] scsi: scsi_transport_spi: Fix function pointer check Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 07/18] xtensa: fix __sync_fetch_and_{and,or}_4 declarations Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 08/18] xtensa: update *pos in cpuinfo_op.next Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 09/18] scsi: mpt3sas: Fix unlock imbalance Sasha Levin
2020-07-14 14:39 ` Sasha Levin [this message]
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 11/18] ALSA: hda/hdmi: fix failures at PCM open on Intel ICL and later Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 12/18] net: usb: qmi_wwan: add support for Quectel EG95 LTE modem Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 13/18] net: sky2: initialize return of gm_phy_read Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 14/18] drm/nouveau/i2c/g94-: increase NV_PMGR_DP_AUXCTL_TRANSACTREQ timeout Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 15/18] scsi: mpt3sas: Fix error returns in BRM_status_show Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 16/18] scsi: dh: Add Fujitsu device to devinfo and dh lists Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 17/18] dm: use bio_uninit instead of bio_disassociate_blkg Sasha Levin
2020-07-14 14:39 ` [PATCH AUTOSEL 5.4 18/18] drivers/firmware/psci: Fix memory leakage in alloc_init_cpu_groups() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200714143914.4035489-10-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=xie.he.0141@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).