Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1461005 > unrolled thread

[PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections

Started byJisheng Zhang <jszhang@marvell.com>
First post2016-08-12 10:30 +0200
Last post2016-08-12 20:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections Jisheng Zhang <jszhang@marvell.com> - 2016-08-12 10:30 +0200
    Re: [PATCH v3] ARM: VDSO: put RO and RO after init objects into  proper sections Kees Cook <keescook@chromium.org> - 2016-08-12 20:10 +0200
      Re: [PATCH v3] ARM: VDSO: put RO and RO after init objects into  proper sections Nathan Lynch <Nathan_Lynch@mentor.com> - 2016-08-12 20:50 +0200

#1461005 — [PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections

FromJisheng Zhang <jszhang@marvell.com>
Date2016-08-12 10:30 +0200
Subject[PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections
Message-ID<s5g0O-7Fi-25@gated-at.bofh.it>
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.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
---

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(-)

diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index 994e971..bbbffe94 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -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

[toc] | [next] | [standalone]


#1461358 — Re: [PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections

FromKees Cook <keescook@chromium.org>
Date2016-08-12 20:10 +0200
SubjectRe: [PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections
Message-ID<s5p45-59c-3@gated-at.bofh.it>
In reply to#1461005
On Fri, Aug 12, 2016 at 1:12 AM, Jisheng Zhang <jszhang@marvell.com> wrote:
> 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.
>
> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>

Looks great; thanks for keeping __ro_after_init in mind. :)

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>
> 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(-)
>
> diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
> index 994e971..bbbffe94 100644
> --- a/arch/arm/kernel/vdso.c
> +++ b/arch/arm/kernel/vdso.c
> @@ -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
>



-- 
Kees Cook
Nexus Security

[toc] | [prev] | [next] | [standalone]


#1461398 — Re: [PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections

FromNathan Lynch <Nathan_Lynch@mentor.com>
Date2016-08-12 20:50 +0200
SubjectRe: [PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections
Message-ID<s5pGO-5nO-63@gated-at.bofh.it>
In reply to#1461358
On 08/12/2016 01:06 PM, Kees Cook wrote:
> On Fri, Aug 12, 2016 at 1:12 AM, Jisheng Zhang <jszhang@marvell.com> wrote:
>> 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.
>>
>> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> 
> Looks great; thanks for keeping __ro_after_init in mind. :)
> 
> Reviewed-by: Kees Cook <keescook@chromium.org>

Looks fine and nothing goes wrong with my vdso tests.  Please send it
through Russell.

Acked-by: Nathan Lynch <nathan_lynch@mentor.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web