netdev->dev_addr should only be modified via helpers, but someone may be casting off the const. Add a runtime check to catch abuses.
Showing the changes to include (1 of 3 files). Show all
Unified · Split
| @@ -1942,6 +1942,8 @@ enum netdev_ml_priv_type { · 1941 unmodified lines | |||
| 1942 | * @unlink_list: As netif_addr_lock() can be called recursively, | 1942 | * @unlink_list: As netif_addr_lock() can be called recursively, |
| 1943 | * keep a list of interfaces to be deleted. | 1943 | * keep a list of interfaces to be deleted. |
| 1944 | * | 1944 | * |
| 1945 | * @dev_addr_shadow: Copy of @dev_addr to catch direct writes. | ||
| 1946 | * | ||
| 1945 | * FIXME: cleanup struct net_device such that network protocol info | 1947 | * FIXME: cleanup struct net_device such that network protocol info |
| 1946 | * moves out. | 1948 | * moves out. |
| 1947 | */ | 1949 | */ |
| @@ -2268,6 +2270,8 @@ struct net_device { · 320 unmodified lines | |||
| 2268 | 2270 | ||
| 2269 | /* protected by rtnl_lock */ | 2271 | /* protected by rtnl_lock */ |
| 2270 | struct bpf_xdp_entity xdp_state[__MAX_XDP_MODE]; | 2272 | struct bpf_xdp_entity xdp_state[__MAX_XDP_MODE]; |
| 2273 | |||
| 2274 | u8 dev_addr_shadow[MAX_ADDR_LEN]; | ||
| 2271 | }; | 2275 | }; |
| 2272 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 2276 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
| 2273 | 2277 | ||
| @@ -4288,6 +4292,7 @@ int dev_addr_del(struct net_device *dev, const unsigned char *addr, · 2014 unmodified lines | |||
| 4288 | unsigned char addr_type); | 4292 | unsigned char addr_type); |
| 4289 | void dev_addr_flush(struct net_device *dev); | 4293 | void dev_addr_flush(struct net_device *dev); |
| 4290 | int dev_addr_init(struct net_device *dev); | 4294 | int dev_addr_init(struct net_device *dev); |
| 4295 | void dev_addr_check(struct net_device *dev); | ||
| 4291 | 4296 | ||
| 4292 | /* Functions used for unicast addresses handling */ | 4297 | /* Functions used for unicast addresses handling */ |
| 4293 | int dev_uc_add(struct net_device *dev, const unsigned char *addr); | 4298 | int dev_uc_add(struct net_device *dev, const unsigned char *addr); |