Skip to content

Commit 740c452

Browse files
committed
idpf: fix null-ptr-deref in idpf_features_check
jira LE-3467 Rebuild_History Non-Buildable kernel-4.18.0-553.58.1.el8_10 commit-author Pavan Kumar Linga <pavan.kumar.linga@intel.com> commit 2dabe34 idpf_features_check is used to validate the TX packet. skb header length is compared with the hardware supported value received from the device control plane. The value is stored in the adapter structure and to access it, vport pointer is used. During reset all the vports are released and the vport pointer that the netdev private structure points to is NULL. To avoid null-ptr-deref, store the max header length value in netdev private structure. This also helps to cache the value and avoid accessing adapter pointer in hot path. BUG: kernel NULL pointer dereference, address: 0000000000000068 ... RIP: 0010:idpf_features_check+0x6d/0xe0 [idpf] Call Trace: <TASK> ? __die+0x23/0x70 ? page_fault_oops+0x154/0x520 ? exc_page_fault+0x76/0x190 ? asm_exc_page_fault+0x26/0x30 ? idpf_features_check+0x6d/0xe0 [idpf] netif_skb_features+0x88/0x310 validate_xmit_skb+0x2a/0x2b0 validate_xmit_skb_list+0x4c/0x70 sch_direct_xmit+0x19d/0x3a0 __dev_queue_xmit+0xb74/0xe70 ... Fixes: a251eee ("idpf: add SRIOV support and other ndo_ops") Reviewed-by: Madhu Chititm <madhu.chittim@intel.com> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Samuel Salin <Samuel.salin@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> (cherry picked from commit 2dabe34) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent cb28197 commit 740c452

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ enum idpf_vport_state {
144144
* @vport_id: Vport identifier
145145
* @link_speed_mbps: Link speed in mbps
146146
* @vport_idx: Relative vport index
147+
* @max_tx_hdr_size: Max header length hardware can support
147148
* @state: See enum idpf_vport_state
148149
* @netstats: Packet and byte stats
149150
* @stats_lock: Lock to protect stats update
@@ -154,6 +155,7 @@ struct idpf_netdev_priv {
154155
u32 vport_id;
155156
u32 link_speed_mbps;
156157
u16 vport_idx;
158+
u16 max_tx_hdr_size;
157159
enum idpf_vport_state state;
158160
struct rtnl_link_stats64 netstats;
159161
spinlock_t stats_lock;

drivers/net/ethernet/intel/idpf/idpf_lib.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
738738
np->vport = vport;
739739
np->vport_idx = vport->idx;
740740
np->vport_id = vport->vport_id;
741+
np->max_tx_hdr_size = idpf_get_max_tx_hdr_size(adapter);
741742
vport->netdev = netdev;
742743

743744
return idpf_init_mac_addr(vport, netdev);
@@ -755,6 +756,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
755756
np->adapter = adapter;
756757
np->vport_idx = vport->idx;
757758
np->vport_id = vport->vport_id;
759+
np->max_tx_hdr_size = idpf_get_max_tx_hdr_size(adapter);
758760

759761
spin_lock_init(&np->stats_lock);
760762

@@ -2244,8 +2246,8 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb,
22442246
struct net_device *netdev,
22452247
netdev_features_t features)
22462248
{
2247-
struct idpf_vport *vport = idpf_netdev_to_vport(netdev);
2248-
struct idpf_adapter *adapter = vport->adapter;
2249+
struct idpf_netdev_priv *np = netdev_priv(netdev);
2250+
u16 max_tx_hdr_size = np->max_tx_hdr_size;
22492251
size_t len;
22502252

22512253
/* No point in doing any of this if neither checksum nor GSO are
@@ -2268,7 +2270,7 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb,
22682270
goto unsupported;
22692271

22702272
len = skb_network_header_len(skb);
2271-
if (unlikely(len > idpf_get_max_tx_hdr_size(adapter)))
2273+
if (unlikely(len > max_tx_hdr_size))
22722274
goto unsupported;
22732275

22742276
if (!skb->encapsulation)
@@ -2281,7 +2283,7 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb,
22812283

22822284
/* IPLEN can support at most 127 dwords */
22832285
len = skb_inner_network_header_len(skb);
2284-
if (unlikely(len > idpf_get_max_tx_hdr_size(adapter)))
2286+
if (unlikely(len > max_tx_hdr_size))
22852287
goto unsupported;
22862288

22872289
/* No need to validate L4LEN as TCP is the only protocol with a

0 commit comments

Comments
 (0)