PCI: endpoint: Make pci_epf_ops in pci_epf_driver const
Subsystems (4)
PATCH 1/5 PCI: endpoint: Make pci_epf_ops in pci_epf_driver const
The pci_epf_ops struct contains a set of callbacks that are used by the pci_epf_driver. The ops struct is never modified by the epf core itself.
Marking the ops pointer const allows epf drivers to declare their pci_epf_ops struct to be const. This allows the struct to be placed in the read-only section. Which for example brings some security benefits as the callbacks can not be overwritten.
--- include/linux/pci-epf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pci-epf.h +1 -1
@@ -98,7 +98,7 @@ struct pci_epf_driver {void (*remove)(struct pci_epf *epf);struct device_driver driver; -struct pci_epf_ops *ops; +const struct pci_epf_ops *ops;struct module *owner;struct list_head epf_group;const struct pci_epf_device_id *id_table;
Signature · 1 line
2.39.2
PATCH 2/5 PCI: endpoint: pci-epf-mhi: Constify pci_epf_ops and pci_epf_event_ops
Both the pci_epf_ops and pci_epf_evnt_ops structs for the PCI endpoint mhi driver are never modified. Mark them as const so they can be placed in the read-only section.
--- drivers/pci/endpoint/functions/pci-epf-mhi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/endpoint/functions/pci-epf-mhi.c +2 -2
@@ -389,7 +389,7 @@ static void pci_epf_mhi_unbind(struct pci_epf *epf)pci_epc_clear_bar (epc, epf->func_no, epf->vfunc_no, epf_bar); } -static struct pci_epc_event_ops pci_epf_mhi_event_ops = { +static const struct pci_epc_event_ops pci_epf_mhi_event_ops = { .core_init = pci_epf_mhi_core_init, .link_up = pci_epf_mhi_link_up, .link_down = pci_epf_mhi_link_down,
@@ -428,7 +428,7 @@ static const struct pci_epf_device_id pci_epf_mhi_ids[] = { {}, }; -static struct pci_epf_ops pci_epf_mhi_ops = { +static const struct pci_epf_ops pci_epf_mhi_ops = { .unbind = pci_epf_mhi_unbind, .bind = pci_epf_mhi_bind, };
Signature · 1 line
2.39.2
Re: [PATCH 2/5] PCI: endpoint: pci-epf-mhi: Constify pci_epf_ops and pci_epf_event_ops
Quoted 5 lines · Lars-Peter Clausen
Both the
pci_epf_opsandpci_epf_evnt_opsstructs for the PCI endpoint mhi driver are never modified. Mark them as const so they can be placed in the read-only section.Signed-off-by Lars-Peter Clausen <[email protected]>
- Mani
Quoted 29 lines
--- drivers/pci/endpoint/functions/pci-epf-mhi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/endpoint/functions/pci-epf-mhi.c +2
-2@@ -389,7 +389,7 @@ static void pci_epf_mhi_unbind(struct pci_epf *epf)pci_epc_clear_bar (epc, epf->func_no, epf->vfunc_no, epf_bar); } -static struct pci_epc_event_ops pci_epf_mhi_event_ops = { +static const struct pci_epc_event_ops pci_epf_mhi_event_ops = { .core_init = pci_epf_mhi_core_init, .link_up = pci_epf_mhi_link_up, .link_down = pci_epf_mhi_link_down,@@ -428,7 +428,7 @@ static const struct pci_epf_device_id pci_epf_mhi_ids[] = { {}, }; -static struct pci_epf_ops pci_epf_mhi_ops = { +static const struct pci_epf_ops pci_epf_mhi_ops = { .unbind = pci_epf_mhi_unbind, .bind = pci_epf_mhi_bind, };Signature · 1 line
2.39.2
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH 3/5 PCI: endpoint: pci-epf-ntb: Constify pci_epf_ops
In reply to Lars-Peter ClausenThe pci_epf_ops struct for the PCI endpoint ntb driver is never modified. Mark it as const so it can be placed in the read-only section.
--- drivers/pci/endpoint/functions/pci-epf-ntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-ntb.c +1 -1
@@ -2099,7 +2099,7 @@ static int epf_ntb_probe(struct pci_epf *epf,return 0 ; } -static struct pci_epf_ops epf_ntb_ops = { +static const struct pci_epf_ops epf_ntb_ops = { .bind = epf_ntb_bind, .unbind = epf_ntb_unbind, .add_cfs = epf_ntb_add_cfs,
Signature · 1 line
2.39.2
Re: [PATCH 3/5] PCI: endpoint: pci-epf-ntb: Constify pci_epf_ops
Quoted 4 lines · Lars-Peter Clausen
The
pci_epf_opsstruct for the PCI endpoint ntb driver is never modified. Mark it as const so it can be placed in the read-only section.Signed-off-by Lars-Peter Clausen <[email protected]>
- Mani
Quoted 20 lines
--- drivers/pci/endpoint/functions/pci-epf-ntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/endpoint/functions/pci-epf-ntb.c +1
-1@@ -2099,7 +2099,7 @@ static int epf_ntb_probe(struct pci_epf *epf,return 0 ; } -static struct pci_epf_ops epf_ntb_ops = { +static const struct pci_epf_ops epf_ntb_ops = { .bind = epf_ntb_bind, .unbind = epf_ntb_unbind, .add_cfs = epf_ntb_add_cfs,Signature · 1 line
2.39.2
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH 4/5 PCI: endpoint: pci-epf-vntb: Constify pci_epf_ops
In reply to Lars-Peter ClausenThe pci_epf_ops struct for the PCI endpoint vntb driver is never modified. Mark it as const so it can be placed in the read-only section.
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
@@ -1387,7 +1387,7 @@ static void epf_ntb_unbind(struct pci_epf *epf) }// EPF driver probe -static struct pci_epf_ops epf_ntb_ops = { +static const struct pci_epf_ops epf_ntb_ops = { .bind = epf_ntb_bind, .unbind = epf_ntb_unbind, .add_cfs = epf_ntb_add_cfs,
Signature · 1 line
2.39.2
Re: [PATCH 4/5] PCI: endpoint: pci-epf-vntb: Constify pci_epf_ops
Quoted 4 lines · Lars-Peter Clausen
The
pci_epf_opsstruct for the PCI endpoint vntb driver is never modified. Mark it as const so it can be placed in the read-only section.Signed-off-by Lars-Peter Clausen <[email protected]>
- Mani
Quoted 20 lines
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/endpoint/functions/pci-epf-vntb.c +1
-1@@ -1387,7 +1387,7 @@ static void epf_ntb_unbind(struct pci_epf *epf) }// EPF driver probe -static struct pci_epf_ops epf_ntb_ops = { +static const struct pci_epf_ops epf_ntb_ops = { .bind = epf_ntb_bind, .unbind = epf_ntb_unbind, .add_cfs = epf_ntb_add_cfs,Signature · 1 line
2.39.2
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH 5/5 PCI: endpoint: pci-epf-test: Constify pci_epf_ops
In reply to Lars-Peter ClausenThe pci_epf_ops struct for the PCI endpoint test driver is never modified. Mark it as const so it can be placed in the read-only section.
--- drivers/pci/endpoint/functions/pci-epf-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-test.c +1 -1
@@ -973,7 +973,7 @@ static int pci_epf_test_probe(struct pci_epf *epf,return 0 ; } -static struct pci_epf_ops ops = { +static const struct pci_epf_ops ops = { .unbind = pci_epf_test_unbind, .bind = pci_epf_test_bind, };
Signature · 1 line
2.39.2
Re: [PATCH 5/5] PCI: endpoint: pci-epf-test: Constify pci_epf_ops
Quoted 4 lines · Lars-Peter Clausen
The
pci_epf_opsstruct for the PCI endpoint test driver is never modified. Mark it as const so it can be placed in the read-only section.Signed-off-by Lars-Peter Clausen <[email protected]>
- Mani
Quoted 20 lines
--- drivers/pci/endpoint/functions/pci-epf-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/endpoint/functions/pci-epf-test.c +1
-1@@ -973,7 +973,7 @@ static int pci_epf_test_probe(struct pci_epf *epf,return 0 ; } -static struct pci_epf_ops ops = { +static const struct pci_epf_ops ops = { .unbind = pci_epf_test_unbind, .bind = pci_epf_test_bind, };Signature · 1 line
2.39.2
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 9 lines · Lars-Peter Clausen
The
pci_epf_opsstruct contains a set of callbacks that are used by thepci_epf_driver. The ops struct is never modified by the epf core itself.Marking the ops pointer const allows epf drivers to declare their
pci_epf_opsstruct to be const. This allows the struct to be placed in the read-only section. Which for example brings some security benefits as the callbacks can not be overwritten.Signed-off-by Lars-Peter Clausen <[email protected]>
- Mani
Quoted 20 lines
--- include/linux/pci-epf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/pci-epf.h +1
-1@@ -98,7 +98,7 @@ struct pci_epf_driver {void (*remove)(struct pci_epf *epf);struct device_driver driver; -struct pci_epf_ops *ops; +const struct pci_epf_ops *ops;struct module *owner;struct list_head epf_group;const struct pci_epf_device_id *id_table;Signature · 1 line
2.39.2
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Krzysztof Wilczyński
AppliedHello,
Quoted 7 lines
The
pci_epf_opsstruct contains a set of callbacks that are used by thepci_epf_driver. The ops struct is never modified by the epf core itself.Marking the ops pointer const allows epf drivers to declare their
pci_epf_opsstruct to be const. This allows the struct to be placed in the read-only section. Which for example brings some security benefits as the callbacks can not be overwritten.
Applied to endpoint, thank you!
[01/05] PCI: endpoint: Make struct pci_epf_ops in pci_epf_driver const
https://git.kernel.org/pci/pci/c/86362293044b [02/05] PCI: endpoint: pci-epf-mhi: Make structs pci_epf_ops and pci_epf_event_ops const https://git.kernel.org/pci/pci/c/150d04ddf386 [03/05] PCI: endpoint: pci-epf-ntb: Make struct pci_epf_ops const https://git.kernel.org/pci/pci/c/54f22c9758dc [04/05] PCI: endpoint: pci-epf-vntb: Make struct pci_epf_ops const https://git.kernel.org/pci/pci/c/c21b53deda09 [05/05] PCI: endpoint: pci-epf-test: Make struct pci_epf_ops const https://git.kernel.org/pci/pci/c/6f517e044096 Krzysztof