From: Dominik Brodowski <linux@dominikbrodowski.net>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>,
huawei.libin@huawei.com, cj.chengjian@huawei.com,
xiexiuqi@huawei.com, mark.rutland@arm.com, hch@infradead.org,
wcohen@redhat.com, linux-kernel@vger.kernel.org,
mtk.manpages@gmail.com, wezhang@redhat.com,
gregkh@linuxfoundation.org, Will Deacon <will@kernel.org>
Subject: Re: [RESEND PATCH] sys_personality: Add optional arch hook arch_check_personality
Date: Mon, 8 Jun 2020 16:58:42 +0200 [thread overview]
Message-ID: <20200608145842.GA716055@light.dominikbrodowski.net> (raw)
In-Reply-To: <20200608094640.GA13596@gaia>
On Mon, Jun 08, 2020 at 10:46:41AM +0100, Catalin Marinas wrote:
> On Mon, Jun 08, 2020 at 10:49:25AM +0800, Wang ShaoBo wrote:
> > Currently arm64 personality syscall uses wrapper __arm64_sys_personality
> > to redirect to __arm64_sys_arm64_personality, it's easily confused,
> > Whereas using an normal hook arch_check_personality() can reject
> > additional settings like this for special case of different architectures.
> >
> > This makes code clean and easier for subsequent modification.
>
> Do you plan to add more stuff here? Curious what triggered this patch.
>
> > diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
> > index d5ffaaab31a7..5c01816d7a77 100644
> > --- a/arch/arm64/kernel/sys.c
> > +++ b/arch/arm64/kernel/sys.c
> > @@ -28,12 +28,13 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
> > return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
> > }
> >
> > -SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
> > +int arch_check_personality(unsigned int personality)
> > {
> > if (personality(personality) == PER_LINUX32 &&
> > !system_supports_32bit_el0())
> > return -EINVAL;
> > - return ksys_personality(personality);
> > +
> > + return 0;
> > }
>
> We use the ksys_* pattern in other places as well, so this wouldn't be
> something new.
>
> > diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> > index 1815065d52f3..3dbbad498027 100644
> > --- a/include/linux/syscalls.h
> > +++ b/include/linux/syscalls.h
> > @@ -1393,16 +1393,6 @@ static inline long ksys_truncate(const char __user *pathname, loff_t length)
> > return do_sys_truncate(pathname, length);
> > }
> >
> > -static inline unsigned int ksys_personality(unsigned int personality)
> > -{
> > - unsigned int old = current->personality;
> > -
> > - if (personality != 0xffffffff)
> > - set_personality(personality);
> > -
> > - return old;
> > -}
> > -
> > /* for __ARCH_WANT_SYS_IPC */
> > long ksys_semtimedop(int semid, struct sembuf __user *tsops,
> > unsigned int nsops,
> > diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
> > index 33f07c5f2515..f3682f4bf205 100644
> > --- a/kernel/exec_domain.c
> > +++ b/kernel/exec_domain.c
> > @@ -35,9 +35,21 @@ static int __init proc_execdomains_init(void)
> > module_init(proc_execdomains_init);
> > #endif
> >
> > +int __weak arch_check_personality(unsigned int personality)
> > +{
> > + return 0;
> > +}
> > +
> > SYSCALL_DEFINE1(personality, unsigned int, personality)
> > {
> > - unsigned int old = current->personality;
> > + int err;
> > + unsigned int old;
> > +
> > + err = arch_check_personality(personality);
> > + if (err)
> > + return err;
> > +
> > + old = current->personality;
>
> I'm surprised that the generic sys_personality() doesn't call
> ksys_personality() directly but rather duplicates the code.
It was the other way round, and the duplication is based on a
suggestion by Christoph Hellwig IIRC,
https://lore.kernel.org/lkml/20180514120756.GA11638@infradead.org/
Thanks,
Dominik
next prev parent reply other threads:[~2020-06-08 14:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-08 2:49 [RESEND PATCH] sys_personality: Add optional arch hook arch_check_personality Wang ShaoBo
2020-06-08 7:50 ` kernel test robot
2020-06-08 9:46 ` Catalin Marinas
2020-06-08 13:16 ` Wangshaobo (bobo)
2020-06-08 14:58 ` Dominik Brodowski [this message]
2020-06-09 7:25 ` kernel test robot
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=20200608145842.GA716055@light.dominikbrodowski.net \
--to=linux@dominikbrodowski.net \
--cc=bobo.shaobowang@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=cj.chengjian@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=huawei.libin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mtk.manpages@gmail.com \
--cc=wcohen@redhat.com \
--cc=wezhang@redhat.com \
--cc=will@kernel.org \
--cc=xiexiuqi@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).