sfc: make function tables const
Subsystems (2)
PATCH 1/1 sfc: make function tables const
The phy, mac, and board information structures should be const. Since tables contain function pointer this improves security (at least theoretically).
Compile tested only.
--- drivers/net/sfc/efx.c | 6 +++--- drivers/net/sfc/falcon.c | 4 ++-- drivers/net/sfc/falcon_xmac.c | 2 +- drivers/net/sfc/mac.h | 4 ++-- drivers/net/sfc/mcdi_mac.c | 2 +- drivers/net/sfc/mcdi_phy.c | 2 +- drivers/net/sfc/net_driver.h | 6 +++--- drivers/net/sfc/nic.h | 6 +++--- drivers/net/sfc/phy.h | 8 ++++---- drivers/net/sfc/qt202x_phy.c | 2 +- drivers/net/sfc/siena.c | 2 +- drivers/net/sfc/tenxpress.c | 2 +- drivers/net/sfc/txc43128_phy.c | 2 +- 13 files changed, 24 insertions(+), 24 deletions(-)
drivers/net/sfc/efx.c +3 -3
@@ -2245,7 +2245,7 @@ static bool efx_port_dummy_op_poll(strucreturn false; } -static struct efx_phy_operations efx_dummy_phy_operations = { +static const struct efx_phy_operations efx_dummy_phy_operations = { .init = efx_port_dummy_op_int, .reconfigure = efx_port_dummy_op_int, .poll = efx_port_dummy_op_poll,
@@ -2261,7 +2261,7 @@ static struct efx_phy_operations efx_dum/* This zeroes out and then fills in the invariants in a struct * efx_nic (including all sub-structures). */ -static int efx_init_struct (struct efx_nic *efx,struct efx_nic_type *type, +static int efx_init_struct (struct efx_nic *efx,const struct efx_nic_type *type,struct pci_dev *pci_dev,struct net_device *net_dev) {int i;
@@ -2451,7 +2451,7 @@ static int efx_pci_probe_main(struct efxstatic int __devinit efx_pci_probe (struct pci_dev *pci_dev,const struct pci_device_id *entry) { -struct efx_nic_type *type = (struct efx_nic_type *) entry->driver_data; +const struct efx_nic_type *type = (const struct efx_nic_type *) entry->driver_data;struct net_device *net_dev;struct efx_nic *efx;int i, rc;
drivers/net/sfc/mcdi_phy.c +1 -1
@@ -739,7 +739,7 @@ static const char *efx_mcdi_phy_test_namreturn NULL ; } -struct efx_phy_operations efx_mcdi_phy_ops = { +const struct efx_phy_operations efx_mcdi_phy_ops = { .probe = efx_mcdi_phy_probe, .init = efx_port_dummy_op_int, .reconfigure = efx_mcdi_phy_reconfigure,
drivers/net/sfc/net_driver.h +3 -3
@@ -773,10 +773,10 @@ struct efx_nic {struct efx_buffer stats_buffer; -struct efx_mac_operations *mac_op; +const struct efx_mac_operations *mac_op;unsigned int phy_type; -struct efx_phy_operations *phy_op; +const struct efx_phy_operations *phy_op;void *phy_data;struct mdio_if_info mdio;unsigned int mdio_bus;
@@ -897,7 +897,7 @@ struct efx_nic_type {void (*resume_wol)(struct efx_nic *efx);int (*test_registers)(struct efx_nic *efx);int (*test_nvram)(struct efx_nic *efx); -struct efx_mac_operations *default_mac_ops; +const struct efx_mac_operations *default_mac_ops;int revision;unsigned int mem_map_size;
drivers/net/sfc/phy.h +4 -4
@@ -13,14 +13,14 @@/**************************************************************************** * 10Xpress (SFX7101) PHY */ -extern struct efx_phy_operations falcon_sfx7101_phy_ops; +extern const struct efx_phy_operations falcon_sfx7101_phy_ops;extern void tenxpress_set_id_led (struct efx_nic *efx,enum efx_led_mode mode);/**************************************************************************** * AMCC/Quake QT202x PHYs */ -extern struct efx_phy_operations falcon_qt202x_phy_ops; +extern const struct efx_phy_operations falcon_qt202x_phy_ops;/* These PHYs provide various H/W control states for LEDs */ #define QUAKE_LED_LINK_INVAL (0)
@@ -39,7 +39,7 @@ extern void falcon_qt202x_set_led(struct/**************************************************************************** * Transwitch CX4 retimer */ -extern struct efx_phy_operations falcon_txc_phy_ops; +extern const struct efx_phy_operations falcon_txc_phy_ops;#define TXC_GPIO_DIR_INPUT 0#define TXC_GPIO_DIR_OUTPUT 1
@@ -50,7 +50,7 @@ extern void falcon_txc_set_gpio_val(stru/**************************************************************************** * Siena managed PHYs */ -extern struct efx_phy_operations efx_mcdi_phy_ops; +extern const struct efx_phy_operations efx_mcdi_phy_ops; extern int efx_mcdi_mdio_read(struct efx_nic *efx, unsigned int bus, unsigned int prtad, unsigned int devad,
drivers/net/sfc/qt202x_phy.c +1 -1
@@ -449,7 +449,7 @@ static void qt202x_phy_remove(struct efx efx->phy_data =NULL ; } -struct efx_phy_operations falcon_qt202x_phy_ops = { +const struct efx_phy_operations falcon_qt202x_phy_ops = { .probe = qt202x_phy_probe, .init = qt202x_phy_init, .reconfigure = qt202x_phy_reconfigure,
drivers/net/sfc/tenxpress.c +1 -1
@@ -478,7 +478,7 @@ static void sfx7101_set_npage_adv(struct advertising & ADVERTISED_10000baseT_Full); } -struct efx_phy_operations falcon_sfx7101_phy_ops = { +const struct efx_phy_operations falcon_sfx7101_phy_ops = { .probe = tenxpress_phy_probe, .init = tenxpress_phy_init, .reconfigure = tenxpress_phy_reconfigure,
drivers/net/sfc/txc43128_phy.c +1 -1
@@ -545,7 +545,7 @@ static void txc43128_get_settings(structmdio45_ethtool_gset (&efx->mdio, ecmd); } -struct efx_phy_operations falcon_txc_phy_ops = { +const struct efx_phy_operations falcon_txc_phy_ops = { .probe = txc43128_phy_probe, .init = txc43128_phy_init, .reconfigure = txc43128_phy_reconfigure,
drivers/net/sfc/falcon_xmac.c +1 -1
@@ -362,7 +362,7 @@ void falcon_poll_xmac(struct efx_nic *effalcon_ack_status_intr (efx); } -struct efx_mac_operations falcon_xmac_operations = { +const struct efx_mac_operations falcon_xmac_operations = { .reconfigure = falcon_reconfigure_xmac, .update_stats = falcon_update_stats_xmac, .check_fault = falcon_xmac_check_fault,
drivers/net/sfc/mac.h +2 -2
@@ -13,8 +13,8 @@#include "net_driver.h" -extern struct efx_mac_operations falcon_xmac_operations; -extern struct efx_mac_operations efx_mcdi_mac_operations; +extern const struct efx_mac_operations falcon_xmac_operations; +extern const struct efx_mac_operations efx_mcdi_mac_operations;extern int efx_mcdi_mac_stats (struct efx_nic *efx,dma_addr_t dma_addr,u32 dma_len,int enable,int clear);
drivers/net/sfc/mcdi_mac.c +1 -1
@@ -138,7 +138,7 @@ static bool efx_mcdi_mac_check_fault(str } -struct efx_mac_operations efx_mcdi_mac_operations = { +const struct efx_mac_operations efx_mcdi_mac_operations = { .reconfigure = efx_mcdi_mac_reconfigure, .update_stats = efx_port_dummy_op_void, .check_fault = efx_mcdi_mac_check_fault,
drivers/net/sfc/falcon.c +2 -2
@@ -1703,7 +1703,7 @@ static int falcon_set_wol(struct efx_nic************************************************************************** */ -struct efx_nic_type falcon_a1_nic_type = { +const struct efx_nic_type falcon_a1_nic_type = { .probe = falcon_probe_nic, .remove = falcon_remove_nic, .init = falcon_init_nic,
@@ -1744,7 +1744,7 @@ struct efx_nic_type falcon_a1_nic_type = .reset_world_flags = ETH_RESET_IRQ, }; -struct efx_nic_type falcon_b0_nic_type = { +const struct efx_nic_type falcon_b0_nic_type = { .probe = falcon_probe_nic, .remove = falcon_remove_nic, .init = falcon_init_nic,
drivers/net/sfc/nic.h +3 -3
@@ -150,9 +150,9 @@ struct siena_nic_data {int wol_filter_id; }; -extern struct efx_nic_type falcon_a1_nic_type; -extern struct efx_nic_type falcon_b0_nic_type; -extern struct efx_nic_type siena_a0_nic_type; +extern const struct efx_nic_type falcon_a1_nic_type; +extern const struct efx_nic_type falcon_b0_nic_type; +extern const struct efx_nic_type siena_a0_nic_type;/************************************************************************** *
drivers/net/sfc/siena.c +1 -1
@@ -581,7 +581,7 @@ static void siena_init_wol(struct efx_ni************************************************************************** */ -struct efx_nic_type siena_a0_nic_type = { +const struct efx_nic_type siena_a0_nic_type = { .probe = siena_probe_nic, .remove = siena_remove_nic, .init = siena_init_nic,
Quoted 1 line · Stephen Hemminger
The phy, mac, and board information structures should be const.
efx_nic_type actually holds information and function pointers about different generations of the controller, not different boards.
Quoted 6 lines
Since tables contain function pointer this improves security (at least theoretically).
Compile tested only.
Signed-off-by Stephen Hemminger <[email protected]>
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
From: Ben Hutchings <[email protected]>
Date: Thu, 14 Apr 2011 17:37:18 +0100
Quoted 6 lines · Stephen Hemminger
Quoted 1 line
The phy, mac, and board information structures should be const.
efx_nic_typeactually holds information and function pointers about different generations of the controller, not different boards.
Quoted 7 lines
Quoted 6 lines
Since tables contain function pointer this improves security (at least theoretically).
Compile tested only.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Ben Hutchings <[email protected]>
Applied.