From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752040AbcHLSGS (ORCPT ); Fri, 12 Aug 2016 14:06:18 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36380 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbcHLSGR (ORCPT ); Fri, 12 Aug 2016 14:06:17 -0400 MIME-Version: 1.0 In-Reply-To: <1470989538-2953-1-git-send-email-jszhang@marvell.com> References: <1470989538-2953-1-git-send-email-jszhang@marvell.com> From: Kees Cook Date: Fri, 12 Aug 2016 11:06:14 -0700 X-Google-Sender-Auth: vJh4AtQleJKQGsuvf7nMSRrsdEs Message-ID: Subject: Re: [PATCH v3] ARM: VDSO: put RO and RO after init objects into proper sections To: Jisheng Zhang Cc: Russell King , Nathan Lynch , Arnd Bergmann , "linux-arm-kernel@lists.infradead.org" , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 12, 2016 at 1:12 AM, Jisheng Zhang 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 Looks great; thanks for keeping __ro_after_init in mind. :) Reviewed-by: Kees Cook -Kees > --- > > Since v2: > - include 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 . > */ > > +#include > #include > #include > #include > @@ -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