[RFC] x86/pci: Mark pci_root_ops as const
pci_root_ops is only written to from within intel_mid_pci_init. This is linked in only when CONFIG_X86_INTEL_MID is set. If not for this, pci_root_ops could be marked as const. Fix this by replacing pci_root_ops usage with pci_root_ops_ptr. If CONFIG_X86_INTEL_MID is set, pci_root_ops_ptr will be set to intel_mid_pci_ops inside intel_mid_pci_init. Introduce pci_acpi_set_ops for intel_mid_pci_init to set acpi_pci_root_ops.pci_ops. This also means that intel_mid_pci_ops cannot be freed after init, hence remove __initconst. Signed-off-by: Zubin Mithra --- arch/x86/include/asm/pci_x86.h | 4 +++- arch/x86/pci/acpi.c| 5 + arch/x86/pci/common.c | 5 +++-- arch/x86/pci/intel_mid_pci.c | 5 +++-- drivers/pci/access.c | 4 ++-- drivers/pci/probe.c| 4 ++-- include/linux/pci-acpi.h | 2 +- include/linux/pci.h| 11 ++- 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index 959d618dbb17..1e82ddaeb52f 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h @@ -58,7 +58,8 @@ void pcibios_set_cache_line_size(void); /* pci-pc.c */ extern int pcibios_last_bus; -extern struct pci_ops pci_root_ops; +extern const struct pci_ops pci_root_ops; +extern const struct pci_ops *pci_root_ops_ptr; void pcibios_scan_specific_bus(int busn); @@ -122,6 +123,7 @@ extern void __init dmi_check_skip_isa_align(void); /* some common used subsys_initcalls */ extern int __init pci_acpi_init(void); +extern void __init pci_acpi_set_ops(const struct pci_ops *ops); extern void __init pcibios_irq_init(void); extern int __init pcibios_init(void); extern int pci_legacy_init(void); diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 948656069cdd..63ebac5fa212 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -397,6 +397,11 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) return 0; } +void __init pci_acpi_set_ops(const struct pci_ops *ops) +{ + acpi_pci_root_ops.pci_ops = ops; +} + int __init pci_acpi_init(void) { struct pci_dev *dev = NULL; diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index d4ec117c1142..747a8e9fd430 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -67,10 +67,11 @@ static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int siz devfn, where, size, value); } -struct pci_ops pci_root_ops = { +const struct pci_ops pci_root_ops = { .read = pci_read, .write = pci_write, }; +const struct pci_ops *pci_root_ops_ptr = _root_ops; /* * This interrupt-safe spinlock protects all accesses to PCI configuration @@ -467,7 +468,7 @@ void pcibios_scan_root(int busnum) sd->node = x86_pci_root_bus_node(busnum); x86_pci_root_bus_resources(busnum, ); printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); - bus = pci_scan_root_bus(NULL, busnum, _root_ops, sd, ); + bus = pci_scan_root_bus(NULL, busnum, pci_root_ops_ptr, sd, ); if (!bus) { pci_free_resource_list(); kfree(sd); diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c index 43867bc85368..b79c469afd57 100644 --- a/arch/x86/pci/intel_mid_pci.c +++ b/arch/x86/pci/intel_mid_pci.c @@ -280,7 +280,7 @@ static void intel_mid_pci_irq_disable(struct pci_dev *dev) } } -static const struct pci_ops intel_mid_pci_ops __initconst = { +static const struct pci_ops intel_mid_pci_ops = { .read = pci_read, .write = pci_write, }; @@ -297,7 +297,8 @@ int __init intel_mid_pci_init(void) pci_mmcfg_late_init(); pcibios_enable_irq = intel_mid_pci_irq_enable; pcibios_disable_irq = intel_mid_pci_irq_disable; - pci_root_ops = intel_mid_pci_ops; + pci_root_ops_ptr = _mid_pci_ops; + pci_acpi_set_ops(_mid_pci_ops); pci_soc_mode = 1; /* Continue with standard init */ acpi_noirq_set(); diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 544922f097c0..ca9d3cbc5541 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -180,9 +180,9 @@ EXPORT_SYMBOL_GPL(pci_generic_config_write32); * * Return previous raw operations */ -struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops) +const struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, const struct pci_ops *ops) { - struct pci_ops *old_ops; + const struct pci_ops *old_ops; unsigned long flags; raw_spin_lock_irqsave(_lock, flags); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b1c05b5054a0..c66c84ef070a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2915,7 +2915,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) } struct pci_bus *pci_create_root_bus(struct device *pa
[RFC] x86/pci: Mark pci_root_ops as const
pci_root_ops is only written to from within intel_mid_pci_init. This is linked in only when CONFIG_X86_INTEL_MID is set. If not for this, pci_root_ops could be marked as const. Fix this by replacing pci_root_ops usage with pci_root_ops_ptr. If CONFIG_X86_INTEL_MID is set, pci_root_ops_ptr will be set to intel_mid_pci_ops inside intel_mid_pci_init. Introduce pci_acpi_set_ops for intel_mid_pci_init to set acpi_pci_root_ops.pci_ops. This also means that intel_mid_pci_ops cannot be freed after init, hence remove __initconst. Signed-off-by: Zubin Mithra --- arch/x86/include/asm/pci_x86.h | 4 +++- arch/x86/pci/acpi.c| 5 + arch/x86/pci/common.c | 5 +++-- arch/x86/pci/intel_mid_pci.c | 5 +++-- drivers/pci/access.c | 4 ++-- drivers/pci/probe.c| 4 ++-- include/linux/pci-acpi.h | 2 +- include/linux/pci.h| 11 ++- 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index 959d618dbb17..1e82ddaeb52f 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h @@ -58,7 +58,8 @@ void pcibios_set_cache_line_size(void); /* pci-pc.c */ extern int pcibios_last_bus; -extern struct pci_ops pci_root_ops; +extern const struct pci_ops pci_root_ops; +extern const struct pci_ops *pci_root_ops_ptr; void pcibios_scan_specific_bus(int busn); @@ -122,6 +123,7 @@ extern void __init dmi_check_skip_isa_align(void); /* some common used subsys_initcalls */ extern int __init pci_acpi_init(void); +extern void __init pci_acpi_set_ops(const struct pci_ops *ops); extern void __init pcibios_irq_init(void); extern int __init pcibios_init(void); extern int pci_legacy_init(void); diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 948656069cdd..63ebac5fa212 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -397,6 +397,11 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) return 0; } +void __init pci_acpi_set_ops(const struct pci_ops *ops) +{ + acpi_pci_root_ops.pci_ops = ops; +} + int __init pci_acpi_init(void) { struct pci_dev *dev = NULL; diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index d4ec117c1142..747a8e9fd430 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -67,10 +67,11 @@ static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int siz devfn, where, size, value); } -struct pci_ops pci_root_ops = { +const struct pci_ops pci_root_ops = { .read = pci_read, .write = pci_write, }; +const struct pci_ops *pci_root_ops_ptr = _root_ops; /* * This interrupt-safe spinlock protects all accesses to PCI configuration @@ -467,7 +468,7 @@ void pcibios_scan_root(int busnum) sd->node = x86_pci_root_bus_node(busnum); x86_pci_root_bus_resources(busnum, ); printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); - bus = pci_scan_root_bus(NULL, busnum, _root_ops, sd, ); + bus = pci_scan_root_bus(NULL, busnum, pci_root_ops_ptr, sd, ); if (!bus) { pci_free_resource_list(); kfree(sd); diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c index 43867bc85368..b79c469afd57 100644 --- a/arch/x86/pci/intel_mid_pci.c +++ b/arch/x86/pci/intel_mid_pci.c @@ -280,7 +280,7 @@ static void intel_mid_pci_irq_disable(struct pci_dev *dev) } } -static const struct pci_ops intel_mid_pci_ops __initconst = { +static const struct pci_ops intel_mid_pci_ops = { .read = pci_read, .write = pci_write, }; @@ -297,7 +297,8 @@ int __init intel_mid_pci_init(void) pci_mmcfg_late_init(); pcibios_enable_irq = intel_mid_pci_irq_enable; pcibios_disable_irq = intel_mid_pci_irq_disable; - pci_root_ops = intel_mid_pci_ops; + pci_root_ops_ptr = _mid_pci_ops; + pci_acpi_set_ops(_mid_pci_ops); pci_soc_mode = 1; /* Continue with standard init */ acpi_noirq_set(); diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 544922f097c0..ca9d3cbc5541 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -180,9 +180,9 @@ EXPORT_SYMBOL_GPL(pci_generic_config_write32); * * Return previous raw operations */ -struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops) +const struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, const struct pci_ops *ops) { - struct pci_ops *old_ops; + const struct pci_ops *old_ops; unsigned long flags; raw_spin_lock_irqsave(_lock, flags); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b1c05b5054a0..c66c84ef070a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2915,7 +2915,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) } struct pci_bus *pci_create_root_bus(struct device *pa
[PATCH] x86/pci: Annotate 'pci_root_ops' with __ro_after_init
When CONFIG_X86_INTEL_MID is set pci_root_ops is written to inside intel_mid_pci_init(which is marked __init) and not modified after. This makes pci_root_ops a suitable candidate for annotating as __ro_after_init. Signed-off-by: Zubin Mithra --- arch/x86/pci/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index d4ec117c1142..204ee80cfa63 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -67,7 +67,7 @@ static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int siz devfn, where, size, value); } -struct pci_ops pci_root_ops = { +struct pci_ops pci_root_ops __ro_after_init = { .read = pci_read, .write = pci_write, }; -- 2.19.1.930.g4563a0d9d0-goog
[PATCH] x86/pci: Annotate 'pci_root_ops' with __ro_after_init
When CONFIG_X86_INTEL_MID is set pci_root_ops is written to inside intel_mid_pci_init(which is marked __init) and not modified after. This makes pci_root_ops a suitable candidate for annotating as __ro_after_init. Signed-off-by: Zubin Mithra --- arch/x86/pci/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index d4ec117c1142..204ee80cfa63 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -67,7 +67,7 @@ static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int siz devfn, where, size, value); } -struct pci_ops pci_root_ops = { +struct pci_ops pci_root_ops __ro_after_init = { .read = pci_read, .write = pci_write, }; -- 2.19.1.930.g4563a0d9d0-goog
[PATCH] apparmor: Fix uninitialized value in aa_split_fqname
Syzkaller reported a OOB-read with the stacktrace below. This occurs inside __aa_lookupn_ns as `n` is not initialized. `n` is obtained from aa_splitn_fqname. In cases where `name` is invalid, aa_splitn_fqname returns without initializing `ns_name` and `ns_len`. Fix this by always initializing `ns_name` and `ns_len`. __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1c4/0x2b4 lib/dump_stack.c:113 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430 memcmp+0xe3/0x160 lib/string.c:861 strnstr+0x4b/0x70 lib/string.c:934 __aa_lookupn_ns+0xc1/0x570 security/apparmor/policy_ns.c:209 aa_lookupn_ns+0x88/0x1e0 security/apparmor/policy_ns.c:240 aa_fqlookupn_profile+0x1b9/0x1010 security/apparmor/policy.c:468 fqlookupn_profile+0x80/0xc0 security/apparmor/label.c:1844 aa_label_strn_parse+0xa3a/0x1230 security/apparmor/label.c:1908 aa_label_parse+0x42/0x50 security/apparmor/label.c:1943 aa_change_profile+0x513/0x3510 security/apparmor/domain.c:1362 apparmor_setprocattr+0xaa4/0x1150 security/apparmor/lsm.c:658 security_setprocattr+0x66/0xc0 security/security.c:1298 proc_pid_attr_write+0x301/0x540 fs/proc/base.c:2555 __vfs_write+0x119/0x9f0 fs/read_write.c:485 vfs_write+0x1fc/0x560 fs/read_write.c:549 ksys_write+0x101/0x260 fs/read_write.c:598 __do_sys_write fs/read_write.c:610 [inline] __se_sys_write fs/read_write.c:607 [inline] __x64_sys_write+0x73/0xb0 fs/read_write.c:607 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Fixes: 3b0aaf5866bf ("apparmor: add lib fn to find the "split" for fqnames") Reported-by: syzbot+61e4b490d9d2da591...@syzkaller.appspotmail.com Signed-off-by: Zubin Mithra --- security/apparmor/lib.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c index 974affe50531..76491e7f4177 100644 --- a/security/apparmor/lib.c +++ b/security/apparmor/lib.c @@ -90,10 +90,12 @@ const char *aa_splitn_fqname(const char *fqname, size_t n, const char **ns_name, const char *end = fqname + n; const char *name = skipn_spaces(fqname, n); - if (!name) - return NULL; *ns_name = NULL; *ns_len = 0; + + if (!name) + return NULL; + if (name[0] == ':') { char *split = strnchr([1], end - [1], ':'); *ns_name = skipn_spaces([1], end - [1]); -- 2.19.0.605.g01d371f741-goog
[PATCH] apparmor: Fix uninitialized value in aa_split_fqname
Syzkaller reported a OOB-read with the stacktrace below. This occurs inside __aa_lookupn_ns as `n` is not initialized. `n` is obtained from aa_splitn_fqname. In cases where `name` is invalid, aa_splitn_fqname returns without initializing `ns_name` and `ns_len`. Fix this by always initializing `ns_name` and `ns_len`. __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1c4/0x2b4 lib/dump_stack.c:113 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430 memcmp+0xe3/0x160 lib/string.c:861 strnstr+0x4b/0x70 lib/string.c:934 __aa_lookupn_ns+0xc1/0x570 security/apparmor/policy_ns.c:209 aa_lookupn_ns+0x88/0x1e0 security/apparmor/policy_ns.c:240 aa_fqlookupn_profile+0x1b9/0x1010 security/apparmor/policy.c:468 fqlookupn_profile+0x80/0xc0 security/apparmor/label.c:1844 aa_label_strn_parse+0xa3a/0x1230 security/apparmor/label.c:1908 aa_label_parse+0x42/0x50 security/apparmor/label.c:1943 aa_change_profile+0x513/0x3510 security/apparmor/domain.c:1362 apparmor_setprocattr+0xaa4/0x1150 security/apparmor/lsm.c:658 security_setprocattr+0x66/0xc0 security/security.c:1298 proc_pid_attr_write+0x301/0x540 fs/proc/base.c:2555 __vfs_write+0x119/0x9f0 fs/read_write.c:485 vfs_write+0x1fc/0x560 fs/read_write.c:549 ksys_write+0x101/0x260 fs/read_write.c:598 __do_sys_write fs/read_write.c:610 [inline] __se_sys_write fs/read_write.c:607 [inline] __x64_sys_write+0x73/0xb0 fs/read_write.c:607 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Fixes: 3b0aaf5866bf ("apparmor: add lib fn to find the "split" for fqnames") Reported-by: syzbot+61e4b490d9d2da591...@syzkaller.appspotmail.com Signed-off-by: Zubin Mithra --- security/apparmor/lib.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c index 974affe50531..76491e7f4177 100644 --- a/security/apparmor/lib.c +++ b/security/apparmor/lib.c @@ -90,10 +90,12 @@ const char *aa_splitn_fqname(const char *fqname, size_t n, const char **ns_name, const char *end = fqname + n; const char *name = skipn_spaces(fqname, n); - if (!name) - return NULL; *ns_name = NULL; *ns_len = 0; + + if (!name) + return NULL; + if (name[0] == ':') { char *split = strnchr([1], end - [1], ':'); *ns_name = skipn_spaces([1], end - [1]); -- 2.19.0.605.g01d371f741-goog
[tip:perf/core] perf/x86/intel/pt: Annotate 'pt_cap_group' with __ro_after_init
Commit-ID: 49e73246cbe6fe0df9cae2db87f31cdc3a0b2b61 Gitweb: https://git.kernel.org/tip/49e73246cbe6fe0df9cae2db87f31cdc3a0b2b61 Author: Zubin Mithra AuthorDate: Wed, 12 Sep 2018 09:45:10 -0700 Committer: Ingo Molnar CommitDate: Wed, 12 Sep 2018 21:16:16 +0200 perf/x86/intel/pt: Annotate 'pt_cap_group' with __ro_after_init 'pt_cap_group' is written to in pt_pmu_hw_init() and not modified after. This makes it a suitable candidate for annotating as __ro_after_init. Signed-off-by: Zubin Mithra Reviewed-by: Guenter Roeck Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: keesc...@chromium.org Link: http://lkml.kernel.org/r/20180912164510.23444-1-...@chromium.org Signed-off-by: Ingo Molnar --- arch/x86/events/intel/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 8d016ce5b80d..3a0aa83cbd07 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -95,7 +95,7 @@ static ssize_t pt_cap_show(struct device *cdev, return snprintf(buf, PAGE_SIZE, "%x\n", pt_cap_get(cap)); } -static struct attribute_group pt_cap_group = { +static struct attribute_group pt_cap_group __ro_after_init = { .name = "caps", };
[tip:perf/core] perf/x86/intel/pt: Annotate 'pt_cap_group' with __ro_after_init
Commit-ID: 49e73246cbe6fe0df9cae2db87f31cdc3a0b2b61 Gitweb: https://git.kernel.org/tip/49e73246cbe6fe0df9cae2db87f31cdc3a0b2b61 Author: Zubin Mithra AuthorDate: Wed, 12 Sep 2018 09:45:10 -0700 Committer: Ingo Molnar CommitDate: Wed, 12 Sep 2018 21:16:16 +0200 perf/x86/intel/pt: Annotate 'pt_cap_group' with __ro_after_init 'pt_cap_group' is written to in pt_pmu_hw_init() and not modified after. This makes it a suitable candidate for annotating as __ro_after_init. Signed-off-by: Zubin Mithra Reviewed-by: Guenter Roeck Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: keesc...@chromium.org Link: http://lkml.kernel.org/r/20180912164510.23444-1-...@chromium.org Signed-off-by: Ingo Molnar --- arch/x86/events/intel/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 8d016ce5b80d..3a0aa83cbd07 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -95,7 +95,7 @@ static ssize_t pt_cap_show(struct device *cdev, return snprintf(buf, PAGE_SIZE, "%x\n", pt_cap_get(cap)); } -static struct attribute_group pt_cap_group = { +static struct attribute_group pt_cap_group __ro_after_init = { .name = "caps", };
[PATCH] perf/pt: Annotate pt_cap_group with __ro_after_init
pt_cap_group is written to in pt_pmu_hw_init and not modified after. This makes it a suitable candidate for annotating as __ro_after_init. Signed-off-by: Zubin Mithra --- arch/x86/events/intel/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 8d016ce5b80d..3a0aa83cbd07 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -95,7 +95,7 @@ static ssize_t pt_cap_show(struct device *cdev, return snprintf(buf, PAGE_SIZE, "%x\n", pt_cap_get(cap)); } -static struct attribute_group pt_cap_group = { +static struct attribute_group pt_cap_group __ro_after_init = { .name = "caps", }; -- 2.18.0.597.ga71716f1ad-goog
[PATCH] perf/pt: Annotate pt_cap_group with __ro_after_init
pt_cap_group is written to in pt_pmu_hw_init and not modified after. This makes it a suitable candidate for annotating as __ro_after_init. Signed-off-by: Zubin Mithra --- arch/x86/events/intel/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 8d016ce5b80d..3a0aa83cbd07 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -95,7 +95,7 @@ static ssize_t pt_cap_show(struct device *cdev, return snprintf(buf, PAGE_SIZE, "%x\n", pt_cap_get(cap)); } -static struct attribute_group pt_cap_group = { +static struct attribute_group pt_cap_group __ro_after_init = { .name = "caps", }; -- 2.18.0.597.ga71716f1ad-goog
[tip:perf/core] perf/x86: Add __ro_after_init annotations
Commit-ID: 2766d2ee960c52adc415931130dd6910158dd04d Gitweb: https://git.kernel.org/tip/2766d2ee960c52adc415931130dd6910158dd04d Author: Zubin Mithra AuthorDate: Fri, 10 Aug 2018 08:43:14 -0700 Committer: Ingo Molnar CommitDate: Mon, 10 Sep 2018 14:55:36 +0200 perf/x86: Add __ro_after_init annotations x86_pmu_{format,events,attr,caps}_group is written to in init_hw_perf_events and not modified after. This makes them suitable candidates for annotating as __ro_after_init. Signed-off-by: Zubin Mithra Reviewed-by: Kees Cook Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: a...@kernel.org Cc: alexander.shish...@linux.intel.com Cc: gro...@chromium.org Link: http://lkml.kernel.org/r/20180810154314.96710-1-...@chromium.org Signed-off-by: Ingo Molnar --- arch/x86/events/core.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index dfb2f7c0d019..7a6fb9b2bec5 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1584,7 +1584,7 @@ static void __init pmu_check_apic(void) } -static struct attribute_group x86_pmu_format_group = { +static struct attribute_group x86_pmu_format_group __ro_after_init = { .name = "format", .attrs = NULL, }; @@ -1715,7 +1715,7 @@ static struct attribute *events_attr[] = { NULL, }; -static struct attribute_group x86_pmu_events_group = { +static struct attribute_group x86_pmu_events_group __ro_after_init = { .name = "events", .attrs = events_attr, }; @@ -2230,7 +2230,7 @@ static struct attribute *x86_pmu_attrs[] = { NULL, }; -static struct attribute_group x86_pmu_attr_group = { +static struct attribute_group x86_pmu_attr_group __ro_after_init = { .attrs = x86_pmu_attrs, }; @@ -2248,7 +2248,7 @@ static struct attribute *x86_pmu_caps_attrs[] = { NULL }; -static struct attribute_group x86_pmu_caps_group = { +static struct attribute_group x86_pmu_caps_group __ro_after_init = { .name = "caps", .attrs = x86_pmu_caps_attrs, };
[tip:perf/core] perf/x86: Add __ro_after_init annotations
Commit-ID: 2766d2ee960c52adc415931130dd6910158dd04d Gitweb: https://git.kernel.org/tip/2766d2ee960c52adc415931130dd6910158dd04d Author: Zubin Mithra AuthorDate: Fri, 10 Aug 2018 08:43:14 -0700 Committer: Ingo Molnar CommitDate: Mon, 10 Sep 2018 14:55:36 +0200 perf/x86: Add __ro_after_init annotations x86_pmu_{format,events,attr,caps}_group is written to in init_hw_perf_events and not modified after. This makes them suitable candidates for annotating as __ro_after_init. Signed-off-by: Zubin Mithra Reviewed-by: Kees Cook Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: a...@kernel.org Cc: alexander.shish...@linux.intel.com Cc: gro...@chromium.org Link: http://lkml.kernel.org/r/20180810154314.96710-1-...@chromium.org Signed-off-by: Ingo Molnar --- arch/x86/events/core.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index dfb2f7c0d019..7a6fb9b2bec5 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1584,7 +1584,7 @@ static void __init pmu_check_apic(void) } -static struct attribute_group x86_pmu_format_group = { +static struct attribute_group x86_pmu_format_group __ro_after_init = { .name = "format", .attrs = NULL, }; @@ -1715,7 +1715,7 @@ static struct attribute *events_attr[] = { NULL, }; -static struct attribute_group x86_pmu_events_group = { +static struct attribute_group x86_pmu_events_group __ro_after_init = { .name = "events", .attrs = events_attr, }; @@ -2230,7 +2230,7 @@ static struct attribute *x86_pmu_attrs[] = { NULL, }; -static struct attribute_group x86_pmu_attr_group = { +static struct attribute_group x86_pmu_attr_group __ro_after_init = { .attrs = x86_pmu_attrs, }; @@ -2248,7 +2248,7 @@ static struct attribute *x86_pmu_caps_attrs[] = { NULL }; -static struct attribute_group x86_pmu_caps_group = { +static struct attribute_group x86_pmu_caps_group __ro_after_init = { .name = "caps", .attrs = x86_pmu_caps_attrs, };
[PATCH] perf/x86: Add __ro_after_init annotations
x86_pmu_{format,events,attr,caps}_group is written to in init_hw_perf_events and not modified after. This makes them suitable candidates for annotating as __ro_after_init. Signed-off-by: Zubin Mithra --- arch/x86/events/core.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 5f4829f10129..88e5f67f5d4c 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1584,7 +1584,7 @@ static void __init pmu_check_apic(void) } -static struct attribute_group x86_pmu_format_group = { +static struct attribute_group x86_pmu_format_group __ro_after_init = { .name = "format", .attrs = NULL, }; @@ -1715,7 +1715,7 @@ static struct attribute *events_attr[] = { NULL, }; -static struct attribute_group x86_pmu_events_group = { +static struct attribute_group x86_pmu_events_group __ro_after_init = { .name = "events", .attrs = events_attr, }; @@ -2230,7 +2230,7 @@ static struct attribute *x86_pmu_attrs[] = { NULL, }; -static struct attribute_group x86_pmu_attr_group = { +static struct attribute_group x86_pmu_attr_group __ro_after_init = { .attrs = x86_pmu_attrs, }; @@ -2248,7 +2248,7 @@ static struct attribute *x86_pmu_caps_attrs[] = { NULL }; -static struct attribute_group x86_pmu_caps_group = { +static struct attribute_group x86_pmu_caps_group __ro_after_init = { .name = "caps", .attrs = x86_pmu_caps_attrs, }; -- 2.18.0.597.ga71716f1ad-goog
[PATCH] perf/x86: Add __ro_after_init annotations
x86_pmu_{format,events,attr,caps}_group is written to in init_hw_perf_events and not modified after. This makes them suitable candidates for annotating as __ro_after_init. Signed-off-by: Zubin Mithra --- arch/x86/events/core.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 5f4829f10129..88e5f67f5d4c 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1584,7 +1584,7 @@ static void __init pmu_check_apic(void) } -static struct attribute_group x86_pmu_format_group = { +static struct attribute_group x86_pmu_format_group __ro_after_init = { .name = "format", .attrs = NULL, }; @@ -1715,7 +1715,7 @@ static struct attribute *events_attr[] = { NULL, }; -static struct attribute_group x86_pmu_events_group = { +static struct attribute_group x86_pmu_events_group __ro_after_init = { .name = "events", .attrs = events_attr, }; @@ -2230,7 +2230,7 @@ static struct attribute *x86_pmu_attrs[] = { NULL, }; -static struct attribute_group x86_pmu_attr_group = { +static struct attribute_group x86_pmu_attr_group __ro_after_init = { .attrs = x86_pmu_attrs, }; @@ -2248,7 +2248,7 @@ static struct attribute *x86_pmu_caps_attrs[] = { NULL }; -static struct attribute_group x86_pmu_caps_group = { +static struct attribute_group x86_pmu_caps_group __ro_after_init = { .name = "caps", .attrs = x86_pmu_caps_attrs, }; -- 2.18.0.597.ga71716f1ad-goog
[PATCH v2] tracefs: Annotate tracefs_ops with __ro_after_init
tracefs_ops is initialized inside tracefs_create_instance_dir and not modified after. tracefs_create_instance_dir allows for initialization only once, and is called from create_trace_instances(marked __init), which is called from tracer_init_tracefs(marked __init). Also, mark tracefs_create_instance_dir as __init. Signed-off-by: Zubin Mithra --- fs/tracefs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index bea8ad876bf9..7098c49f3693 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = { static struct tracefs_dir_ops { int (*mkdir)(const char *name); int (*rmdir)(const char *name); -} tracefs_ops; +} tracefs_ops __ro_after_init; static char *get_dname(struct dentry *dentry) { @@ -478,7 +478,8 @@ struct dentry *tracefs_create_dir(const char *name, struct dentry *parent) * * Returns the dentry of the instances directory. */ -struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *parent, +__init struct dentry *tracefs_create_instance_dir(const char *name, + struct dentry *parent, int (*mkdir)(const char *name), int (*rmdir)(const char *name)) { -- 2.18.0.233.g985f88cf7e-goog
[PATCH v2] tracefs: Annotate tracefs_ops with __ro_after_init
tracefs_ops is initialized inside tracefs_create_instance_dir and not modified after. tracefs_create_instance_dir allows for initialization only once, and is called from create_trace_instances(marked __init), which is called from tracer_init_tracefs(marked __init). Also, mark tracefs_create_instance_dir as __init. Signed-off-by: Zubin Mithra --- fs/tracefs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index bea8ad876bf9..7098c49f3693 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = { static struct tracefs_dir_ops { int (*mkdir)(const char *name); int (*rmdir)(const char *name); -} tracefs_ops; +} tracefs_ops __ro_after_init; static char *get_dname(struct dentry *dentry) { @@ -478,7 +478,8 @@ struct dentry *tracefs_create_dir(const char *name, struct dentry *parent) * * Returns the dentry of the instances directory. */ -struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *parent, +__init struct dentry *tracefs_create_instance_dir(const char *name, + struct dentry *parent, int (*mkdir)(const char *name), int (*rmdir)(const char *name)) { -- 2.18.0.233.g985f88cf7e-goog
[PATCH] tracefs: Annotate tracefs_ops with __ro_after_init
tracefs_ops is initialized inside tracefs_create_instance_dir and not modified after. tracefs_create_instance_dir allows for initialization only once, and is called from create_trace_instances(marked __init), which is called from tracer_init_tracefs(marked __init). Signed-off-by: Zubin Mithra Reviewed-by: Kees Cook --- fs/tracefs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index bea8ad876bf9..20e965873f27 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = { static struct tracefs_dir_ops { int (*mkdir)(const char *name); int (*rmdir)(const char *name); -} tracefs_ops; +} tracefs_ops __ro_after_init; static char *get_dname(struct dentry *dentry) { -- 2.18.0.233.g985f88cf7e-goog
[PATCH] tracefs: Annotate tracefs_ops with __ro_after_init
tracefs_ops is initialized inside tracefs_create_instance_dir and not modified after. tracefs_create_instance_dir allows for initialization only once, and is called from create_trace_instances(marked __init), which is called from tracer_init_tracefs(marked __init). Signed-off-by: Zubin Mithra Reviewed-by: Kees Cook --- fs/tracefs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index bea8ad876bf9..20e965873f27 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = { static struct tracefs_dir_ops { int (*mkdir)(const char *name); int (*rmdir)(const char *name); -} tracefs_ops; +} tracefs_ops __ro_after_init; static char *get_dname(struct dentry *dentry) { -- 2.18.0.233.g985f88cf7e-goog