From 90c133c67c74d0e8f6b78899e9fca3d502b1039e Mon Sep 17 00:00:00 2001 From: Subash Abhinov Kasiviswanathan Date: Mon, 5 Dec 2016 12:26:41 -0700 Subject: [PATCH] net: rmnet_data: Disable generic receive offload by default Generic receive offload is enabled by default on a net_device whenever it is registered. In case of rmnet_data, a physical device could theoretically pass cloned frames and rmnet_data would pass on these cloned frames to GRO framework. This would cause memory corruption or crashes since GRO modifies the skb shared info which is shared across clones. While cloned frames are usually not sent to rmnet_data, this configuration actually requires userspace intervention. If userspace does not makes appropriate calls to kernel, we will run into crashes. Handle this scenario by disabling GRO by default. Userspace will need to explicitly enable GRO if required to do so. CRs-Fixed: 1097389 Change-Id: I40d5ce940f4722b128c0138c07232c33d0b74e14 Signed-off-by: Subash Abhinov Kasiviswanathan --- net/rmnet_data/rmnet_data_vnd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/rmnet_data/rmnet_data_vnd.c b/net/rmnet_data/rmnet_data_vnd.c index 2999e2c15fdb..2819da9ae3f2 100644 --- a/net/rmnet_data/rmnet_data_vnd.c +++ b/net/rmnet_data/rmnet_data_vnd.c @@ -504,6 +504,18 @@ static void rmnet_vnd_setup(struct net_device *dev) INIT_LIST_HEAD(&dev_conf->flow_head); } +/** + * rmnet_vnd_setup() - net_device initialization helper function + * @dev: Virtual network device + * + * Called during device initialization. Disables GRO. + */ +static void rmnet_vnd_disable_offload(struct net_device *dev) +{ + dev->wanted_features &= ~NETIF_F_GRO; + __netdev_update_features(dev); +} + /* ***************** Exposed API ******************************************** */ /** @@ -616,6 +628,8 @@ int rmnet_vnd_create_dev(int id, struct net_device **new_device, *new_device = dev; } + rmnet_vnd_disable_offload(dev); + LOGM("Registered device %s", dev->name); return rc; }