[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <67fab0f1-e326-4ad8-9def-4d2bd5489b33@app.fastmail.com>
Date: Thu, 07 Dec 2023 08:13:22 +0100
From: "Arnd Bergmann" <arnd@...db.de>
To: "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
Cc: 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, "Gregory Price" <gregory.price@...verge.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 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
Powered by blists - more mailing lists