public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium•org>
To: Christophe Leroy <christophe.leroy@csgroup•eu>
Cc: "luto@kernel•org" <luto@kernel•org>,
	"linux-sh@vger•kernel.org" <linux-sh@vger•kernel.org>,
	"peterz@infradead•org" <peterz@infradead•org>,
	"dave.hansen@linux•intel.com" <dave.hansen@linux•intel.com>,
	"linux-mips@vger•kernel.org" <linux-mips@vger•kernel.org>,
	"linux-mm@kvack•org" <linux-mm@kvack•org>,
	"hpa@zytor•com" <hpa@zytor•com>,
	"sparclinux@vger•kernel.org" <sparclinux@vger•kernel.org>,
	"linux-s390@vger•kernel.org" <linux-s390@vger•kernel.org>,
	"x86@kernel•org" <x86@kernel•org>,
	"linux-csky@vger•kernel.org" <linux-csky@vger•kernel.org>,
	"mingo@redhat•com" <mingo@redhat•com>,
	"linux-snps-arc@lists•infradead.org"
	<linux-snps-arc@lists•infradead.org>,
	"Liam.Howlett@oracle•com" <Liam.Howlett@oracle•com>,
	"broonie@kernel•org" <broonie@kernel•org>,
	"bp@alien8•de" <bp@alien8•de>,
	"loongarch@lists•linux.dev" <loongarch@lists•linux.dev>,
	"tglx@linutronix•de" <tglx@linutronix•de>,
	"linux-arm-kernel@lists•infradead.org"
	<linux-arm-kernel@lists•infradead.org>,
	"debug@rivosinc•com" <debug @rivosinc.com>,
	"linux-parisc@vger•kernel.org" <linux-parisc@vger•kernel.org>,
	"linux-kernel@vger•kernel.org" <linux-kernel@vger•kernel.org>,
	"linux-alpha@vger•kernel.org" <linux-alpha@vger•kernel.org>,
	"akpm@linux-foundation•org" <akpm@linux-foundation•org>,
	Rick Edgecombe <rick.p.edgecombe@intel•com>,
	"linuxppc-dev@lists•ozlabs.org" <linuxppc-dev@lists•ozlabs.org>,
	"kirill.shutemov@linux•intel.com"
	<kirill.shutemov@linux•intel.com>
Subject: Re: [PATCH v2 5/9] mm: Initialize struct vm_unmapped_area_info
Date: Tue, 27 Feb 2024 10:07:26 -0800	[thread overview]
Message-ID: <202402271004.7145FDB53F@keescook> (raw)
In-Reply-To: <94a2b919-e03b-4ade-b13e-7774849dc02b@csgroup.eu>

On Tue, Feb 27, 2024 at 07:02:59AM +0000, Christophe Leroy wrote:
> 
> 
> Le 26/02/2024 à 20:09, Rick Edgecombe a écrit :
> > Future changes will need to add a field to struct vm_unmapped_area_info.
> > This would cause trouble for any archs that don't initialize the
> > struct. Currently every user sets each field, so if new fields are
> > added, the core code parsing the struct will see garbage in the new
> > field.
> > 
> > It could be possible to initialize the new field for each arch to 0, but
> > instead simply inialize the field with a C99 struct inializing syntax.
> 
> Why doing a full init of the struct when all fields are re-written a few 
> lines after ?

It's a nice change for robustness and makes future changes easier. It's
not actually wasteful since the compiler will throw away all redundant
stores.

> If I take the exemple of powerpc function slice_find_area_bottomup():
> 
> 	struct vm_unmapped_area_info info;
> 
> 	info.flags = 0;
> 	info.length = len;
> 	info.align_mask = PAGE_MASK & ((1ul << pshift) - 1);
> 	info.align_offset = 0;

But one cleanup that is possible from explicitly zero-initializing the
whole structure would be dropping all the individual "= 0" assignments.
:)

-- 
Kees Cook

  parent reply	other threads:[~2024-02-27 18:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240226190951.3240433-1-rick.p.edgecombe@intel.com>
2024-02-26 19:09 ` [PATCH v2 5/9] mm: Initialize struct vm_unmapped_area_info Rick Edgecombe
2024-02-27  7:02   ` Christophe Leroy
2024-02-27 15:00     ` Edgecombe, Rick P
2024-02-27 18:07     ` Kees Cook [this message]
2024-02-27 18:16       ` Christophe Leroy
2024-02-27 20:25         ` Edgecombe, Rick P
2024-02-28 13:22           ` Christophe Leroy
2024-02-28 17:01             ` Edgecombe, Rick P
2024-02-28 23:10               ` Christophe Leroy
2024-02-28 17:21             ` Kees Cook
2024-03-02  0:47               ` Edgecombe, Rick P
2024-03-02  1:51                 ` Kees Cook
2024-03-04 18:00                   ` Christophe Leroy
2024-03-04 18:03                     ` Edgecombe, Rick P
2024-02-28 11:51   ` Kirill A. Shutemov
     [not found]   ` <20240302001714.674091-1-rick.p.edgecombe@intel.com>
2024-03-02  0:17     ` [RFC v2.1 07/12] powerpc: Use initializer for " Rick Edgecombe
2024-03-05  0:51       ` Michael Ellerman
2024-03-05 14:50         ` Edgecombe, Rick P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202402271004.7145FDB53F@keescook \
    --to=keescook@chromium$(echo .)org \
    --cc=Liam.Howlett@oracle$(echo .)com \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=bp@alien8$(echo .)de \
    --cc=broonie@kernel$(echo .)org \
    --cc=christophe.leroy@csgroup$(echo .)eu \
    --cc=dave.hansen@linux$(echo .)intel.com \
    --cc=debug@rivosinc$(echo .)com \
    --cc=hpa@zytor$(echo .)com \
    --cc=kirill.shutemov@linux$(echo .)intel.com \
    --cc=linux-alpha@vger$(echo .)kernel.org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-csky@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-mips@vger$(echo .)kernel.org \
    --cc=linux-mm@kvack$(echo .)org \
    --cc=linux-parisc@vger$(echo .)kernel.org \
    --cc=linux-s390@vger$(echo .)kernel.org \
    --cc=linux-sh@vger$(echo .)kernel.org \
    --cc=linux-snps-arc@lists$(echo .)infradead.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=loongarch@lists$(echo .)linux.dev \
    --cc=luto@kernel$(echo .)org \
    --cc=mingo@redhat$(echo .)com \
    --cc=peterz@infradead$(echo .)org \
    --cc=rick.p.edgecombe@intel$(echo .)com \
    --cc=sparclinux@vger$(echo .)kernel.org \
    --cc=tglx@linutronix$(echo .)de \
    --cc=x86@kernel$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox