dev_addr: add a modification check
netdev->dev_addr should only be modified via helpers, but someone may be casting off the const. Add a runtime check to catch abuses. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5f0b692384
commit
d07b26f5bb
3 changed files with 25 additions and 0 deletions
|
|
@ -1942,6 +1942,8 @@ enum netdev_ml_priv_type {
|
|||
* @unlink_list: As netif_addr_lock() can be called recursively,
|
||||
* keep a list of interfaces to be deleted.
|
||||
*
|
||||
* @dev_addr_shadow: Copy of @dev_addr to catch direct writes.
|
||||
*
|
||||
* FIXME: cleanup struct net_device such that network protocol info
|
||||
* moves out.
|
||||
*/
|
||||
|
|
@ -2268,6 +2270,8 @@ struct net_device {
|
|||
|
||||
/* protected by rtnl_lock */
|
||||
struct bpf_xdp_entity xdp_state[__MAX_XDP_MODE];
|
||||
|
||||
u8 dev_addr_shadow[MAX_ADDR_LEN];
|
||||
};
|
||||
#define to_net_dev(d) container_of(d, struct net_device, dev)
|
||||
|
||||
|
|
@ -4288,6 +4292,7 @@ int dev_addr_del(struct net_device *dev, const unsigned char *addr,
|
|||
unsigned char addr_type);
|
||||
void dev_addr_flush(struct net_device *dev);
|
||||
int dev_addr_init(struct net_device *dev);
|
||||
void dev_addr_check(struct net_device *dev);
|
||||
|
||||
/* Functions used for unicast addresses handling */
|
||||
int dev_uc_add(struct net_device *dev, const unsigned char *addr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue