ARM: VDSO: put RO and RO after init objects into proper sections
PATCH v3 1/1 ARM: VDSO: put RO and RO after init objects into proper sections
vdso_data_mapping is never modified, so mark it as const.
vdso_total_pages, vdso_data_page, vdso_text_mapping and cntvct_ok are initialized by vdso_init(), thereafter are read only.
The fact that they are read only after init makes them candidates for __ro_after_init declarations.
---
Since v2:
- include <linux/cache.h> explicitly for __ro_after_init
Since v1:
- use __ro_after_init instead of __read_mostly
- apply __ro_after_init for vdso_total_pages and cntvct_ok as well
arch/arm/kernel/vdso.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm/kernel/vdso.c +6 -5
@@ -17,6 +17,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/cache.h> #include <linux/elf.h> #include <linux/err.h> #include <linux/kernel.h>
@@ -39,7 +40,7 @@static struct page **vdso_text_pagelist;/* Total number of pages needed for the data and text portions of the VDSO. */ -unsigned int vdso_total_pages__read_mostly ; +unsigned int vdso_total_pages__ro_after_init ;/* * The VDSO data page.
@@ -47,13 +48,13 @@ unsigned int vdso_total_pages __read_mostly; static union vdso_data_store vdso_data_store __page_aligned_data;static struct vdso_data *vdso_data = &vdso_data_store.data; -static struct page *vdso_data_page; -static struct vm_special_mapping vdso_data_mapping = { +static struct page *vdso_data_page__ro_after_init ; +static const struct vm_special_mapping vdso_data_mapping = { .name ="[vvar]" , .pages = &vdso_data_page, }; -static struct vm_special_mapping vdso_text_mapping = { +static struct vm_special_mapping vdso_text_mapping__ro_after_init = { .name ="[vdso]" , };
@@ -67,7 +68,7 @@ struct elfinfo {/* Cached result of boot-time check for whether the arch timer exists, * and if so, whether the virtual counter is useable. */ -static bool cntvct_ok__read_mostly ; +static bool cntvct_ok__ro_after_init ;static bool __init cntvct_functional (void ) {
Signature · 1 line
2.8.1
Quoted 9 lines · Jisheng Zhang
vdso_data_mappingis never modified, so mark it as const.
vdso_total_pages,vdso_data_page,vdso_text_mappingandcntvct_okare initialized byvdso_init(), thereafter are read only.The fact that they are read only after init makes them candidates for
__ro_after_initdeclarations.Signed-off-by Jisheng Zhang <[email protected]>
Looks great; thanks for keeping __ro_after_init in mind. :)
-Kees
Quoted 62 lines
---
Since v2:
- include <linux/cache.h> explicitly for__ro_after_initSince v1:
- use__ro_after_initinstead of__read_mostly
- apply__ro_after_initforvdso_total_pagesandcntvct_okas wellarch/arm/kernel/vdso.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)arch/arm/kernel/vdso.c +6
-6@@ -17,6 +17,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/cache.h> #include <linux/elf.h> #include <linux/err.h> #include <linux/kernel.h> @@ -39,7 +40,7 @@static struct page **vdso_text_pagelist;/* Total number of pages needed for the data and text portions of the VDSO. */ -unsigned int vdso_total_pages__read_mostly ; +unsigned int vdso_total_pages__ro_after_init ;/* * The VDSO data page. @@ -47,13 +48,13 @@ unsigned int vdso_total_pages __read_mostly; static union vdso_data_store vdso_data_store __page_aligned_data;static struct vdso_data *vdso_data = &vdso_data_store.data; -static struct page *vdso_data_page; -static struct vm_special_mapping vdso_data_mapping = { +static struct page *vdso_data_page__ro_after_init ; +static const struct vm_special_mapping vdso_data_mapping = { .name ="[vvar]" , .pages = &vdso_data_page, }; -static struct vm_special_mapping vdso_text_mapping = { +static struct vm_special_mapping vdso_text_mapping__ro_after_init = { .name ="[vdso]" , };@@ -67,7 +68,7 @@ struct elfinfo {/* Cached result of boot-time check for whether the arch timer exists, * and if so, whether the virtual counter is useable. */ -static bool cntvct_ok__read_mostly ; +static bool cntvct_ok__ro_after_init ;static bool __init cntvct_functional (void ) { --2.8.1
Signature · 2 lines
Kees Cook Nexus Security
Nathan Lynch
Acked-byQuoted 6 lines · Kees Cook
Quoted 5 lines · Jisheng Zhang
vdso_data_mappingis never modified, so mark it as const.
vdso_total_pages,vdso_data_page,vdso_text_mappingandcntvct_okare initialized byvdso_init(), thereafter are read only.
Quoted 8 lines
Quoted 4 lines
The fact that they are read only after init makes them candidates for
__ro_after_initdeclarations.Signed-off-by Jisheng Zhang <[email protected]>Looks great; thanks for keeping
__ro_after_initin mind. :)Reviewed-by Kees Cook <[email protected]>
Looks fine and nothing goes wrong with my vdso tests. Please send it through Russell.