From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386AbdAQRmw (ORCPT ); Tue, 17 Jan 2017 12:42:52 -0500 Received: from mail-it0-f45.google.com ([209.85.214.45]:36826 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751204AbdAQRmu (ORCPT ); Tue, 17 Jan 2017 12:42:50 -0500 MIME-Version: 1.0 In-Reply-To: <1484397114-7705-1-git-send-email-bhumirks@gmail.com> References: <1484397114-7705-1-git-send-email-bhumirks@gmail.com> From: Kees Cook Date: Tue, 17 Jan 2017 09:33:28 -0800 X-Google-Sender-Auth: T9gyM0Pe_EfsN412j9LjMV_I2jk Message-ID: Subject: Re: [PATCH] sparc32: mm: srmmu: add __ro_after_init to sparc32_cachetlb_ops structures To: Bhumika Goyal Cc: Julia Lawall , "David S. Miller" , sparclinux , 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 Sat, Jan 14, 2017 at 4:31 AM, Bhumika Goyal wrote: > The objects viking_ops, viking_sun4d_smp_ops and smp_cachetlb_ops of > type sparc32_cachetlb_ops are not modified anywhere after getting modified > in the init functions. Inside init their reference is also stored in a > pointer of type const struct sparc32_cachetlb_ops *. So these structures > are never modified after init, therefore add __ro_after to the declaration > of these structures. > > Signed-off-by: Bhumika Goyal Reviewed-by: Kees Cook Yay more ro_after_init! :) -Kees > --- > Instead of using __ro_after_init for the viking_* structures, should I > use const by making two copies of these structures with different field values? > > arch/sparc/mm/srmmu.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c > index c7f2a52..def82f6 100644 > --- a/arch/sparc/mm/srmmu.c > +++ b/arch/sparc/mm/srmmu.c > @@ -1444,7 +1444,7 @@ static void poke_viking(void) > srmmu_set_mmureg(mreg); > } > > -static struct sparc32_cachetlb_ops viking_ops = { > +static struct sparc32_cachetlb_ops viking_ops __ro_after_init = { > .cache_all = viking_flush_cache_all, > .cache_mm = viking_flush_cache_mm, > .cache_page = viking_flush_cache_page, > @@ -1475,7 +1475,7 @@ static void poke_viking(void) > * flushes going at once will require SMP locking anyways so there's > * no real value in trying any harder than this. > */ > -static struct sparc32_cachetlb_ops viking_sun4d_smp_ops = { > +static struct sparc32_cachetlb_ops viking_sun4d_smp_ops __ro_after_init = { > .cache_all = viking_flush_cache_all, > .cache_mm = viking_flush_cache_mm, > .cache_page = viking_flush_cache_page, > @@ -1759,7 +1759,7 @@ static void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr) > local_ops->sig_insns(mm, insn_addr); > } > > -static struct sparc32_cachetlb_ops smp_cachetlb_ops = { > +static struct sparc32_cachetlb_ops smp_cachetlb_ops __ro_after_init = { > .cache_all = smp_flush_cache_all, > .cache_mm = smp_flush_cache_mm, > .cache_page = smp_flush_cache_page, > -- > 1.9.1 > -- Kees Cook Nexus Security From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kees Cook Date: Tue, 17 Jan 2017 17:33:28 +0000 Subject: Re: [PATCH] sparc32: mm: srmmu: add __ro_after_init to sparc32_cachetlb_ops structures Message-Id: List-Id: References: <1484397114-7705-1-git-send-email-bhumirks@gmail.com> In-Reply-To: <1484397114-7705-1-git-send-email-bhumirks@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Bhumika Goyal Cc: Julia Lawall , "David S. Miller" , sparclinux , LKML On Sat, Jan 14, 2017 at 4:31 AM, Bhumika Goyal wrote: > The objects viking_ops, viking_sun4d_smp_ops and smp_cachetlb_ops of > type sparc32_cachetlb_ops are not modified anywhere after getting modified > in the init functions. Inside init their reference is also stored in a > pointer of type const struct sparc32_cachetlb_ops *. So these structures > are never modified after init, therefore add __ro_after to the declaration > of these structures. > > Signed-off-by: Bhumika Goyal Reviewed-by: Kees Cook Yay more ro_after_init! :) -Kees > --- > Instead of using __ro_after_init for the viking_* structures, should I > use const by making two copies of these structures with different field values? > > arch/sparc/mm/srmmu.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c > index c7f2a52..def82f6 100644 > --- a/arch/sparc/mm/srmmu.c > +++ b/arch/sparc/mm/srmmu.c > @@ -1444,7 +1444,7 @@ static void poke_viking(void) > srmmu_set_mmureg(mreg); > } > > -static struct sparc32_cachetlb_ops viking_ops = { > +static struct sparc32_cachetlb_ops viking_ops __ro_after_init = { > .cache_all = viking_flush_cache_all, > .cache_mm = viking_flush_cache_mm, > .cache_page = viking_flush_cache_page, > @@ -1475,7 +1475,7 @@ static void poke_viking(void) > * flushes going at once will require SMP locking anyways so there's > * no real value in trying any harder than this. > */ > -static struct sparc32_cachetlb_ops viking_sun4d_smp_ops = { > +static struct sparc32_cachetlb_ops viking_sun4d_smp_ops __ro_after_init = { > .cache_all = viking_flush_cache_all, > .cache_mm = viking_flush_cache_mm, > .cache_page = viking_flush_cache_page, > @@ -1759,7 +1759,7 @@ static void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr) > local_ops->sig_insns(mm, insn_addr); > } > > -static struct sparc32_cachetlb_ops smp_cachetlb_ops = { > +static struct sparc32_cachetlb_ops smp_cachetlb_ops __ro_after_init = { > .cache_all = smp_flush_cache_all, > .cache_mm = smp_flush_cache_mm, > .cache_page = smp_flush_cache_page, > -- > 1.9.1 > -- Kees Cook Nexus Security