[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZXHdhVeel1dOxlYJ@memverge.com>
Date: Thu, 7 Dec 2023 09:58:13 -0500
From: Gregory Price <gregory.price@...verge.com>
To: Arnd Bergmann <arnd@...db.de>
Cc: Gregory Price <gourry.memverge@...il.com>, linux-mm@...ck.org,
jgroves@...ron.com, ravis.opensrc@...ron.com,
sthanneeru@...ron.com, emirakhur@...ron.com, Hasan.Maruf@....com,
linux-doc@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-api@...r.kernel.org, Linux-Arch <linux-arch@...r.kernel.org>,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andy Lutomirski <luto@...nel.org>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, Michal Hocko <mhocko@...nel.org>,
Tejun Heo <tj@...nel.org>, ying.huang@...el.com,
Jonathan Corbet <corbet@....net>, rakie.kim@...com,
hyeongtak.ji@...com, honggyu.kim@...com, vtavarespetr@...ron.com,
Peter Zijlstra <peterz@...radead.org>,
Frank van der Linden <fvdl@...gle.com>
Subject: Re: [RFC PATCH 07/11] mm/mempolicy: add userland mempolicy arg
structure
On Thu, Dec 07, 2023 at 08:13:22AM +0100, Arnd Bergmann wrote:
> On Thu, Dec 7, 2023, at 01:27, Gregory Price wrote:
> > This patch adds the new user-api argument structure intended for
> > set_mempolicy2 and mbind2.
> >
> > struct mpol_args {
> > /* Basic mempolicy settings */
> > unsigned short mode;
> > unsigned short mode_flags;
> > unsigned long *pol_nodes;
> > unsigned long pol_maxnodes;
> >
> > /* get_mempolicy2: policy information (e.g. next interleave node) */
> > int policy_node;
> >
> > /* get_mempolicy2: memory range policy */
> > unsigned long addr;
> > int addr_node;
> >
> > /* all operations: policy home node */
> > unsigned long home_node;
> >
> > /* mbind2: address ranges to apply the policy */
> > const struct iovec __user *vec;
> > size_t vlen;
> > };
>
> This is not a great structure layout for a system call ABI,
> mostly because it requires adding a compat syscall handler
> to be usable from 32-bit tasks. It would be nice if this
> could be rewritten in a way that uses only fixed-length
> members (__u16, __u32, __aligned_u64), though that does
> require the use of u64_to_user_ptr() to replace the pointers
> and the reverse in userspace.
>
> Aside from this, you should avoid holes in the data structure.
> On 64-bit architectures, the layout above has holes after
> policy_node and after addr_node.
>
> Arnd
doh, clearly i didn't stop to think about alignment. Good eye.
I'll redo this with __u/s members and fix the holes.
Didn't stop to think about compat pointers. I don't think the
u64_to_user_ptr pattern is offensive, so i'll make that change.
At least I don't see what the other options are beyond compat.
Thanks
~Gregory
Powered by blists - more mailing lists