From: Nicholas Piggin <npiggin@gmail•com>
To: Christophe Leroy <christophe.leroy@c-s•fr>,
linuxppc-dev@lists•ozlabs.org
Subject: Re: [PATCH 1/4] powerpc/64s: implement probe_kernel_read/write without touching AMR
Date: Fri, 03 Apr 2020 18:59:58 +1000 [thread overview]
Message-ID: <1585904337.b41amzn27o.astroid@bobo.none> (raw)
In-Reply-To: <d619b378-3a88-f941-b2d5-42b79574e2ab@c-s.fr>
Christophe Leroy's on March 27, 2020 5:13 pm:
>
>
> Le 27/03/2020 à 08:02, Nicholas Piggin a écrit :
>> There is no need to allow user accesses when probing kernel addresses.
>>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail•com>
>> ---
>> arch/powerpc/include/asm/uaccess.h | 25 ++++++++++-----
>> arch/powerpc/lib/Makefile | 2 +-
>> arch/powerpc/lib/uaccess.c | 50 ++++++++++++++++++++++++++++++
>> 3 files changed, 68 insertions(+), 9 deletions(-)
>> create mode 100644 arch/powerpc/lib/uaccess.c
>>
>
> [...]
>
>> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
>> index b8de3be10eb4..a15060b5008e 100644
>> --- a/arch/powerpc/lib/Makefile
>> +++ b/arch/powerpc/lib/Makefile
>> @@ -36,7 +36,7 @@ extra-$(CONFIG_PPC64) += crtsavres.o
>> endif
>>
>> obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o copypage_power7.o \
>> - memcpy_power7.o
>> + memcpy_power7.o uaccess.o
>
> Why only book3s/64 ? It applies to the 8xx and book3s/32 as well, I
> think it should just be for all powerpc.
Okay I can do that.
>>
>> obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
>> memcpy_64.o memcpy_mcsafe_64.o
>> diff --git a/arch/powerpc/lib/uaccess.c b/arch/powerpc/lib/uaccess.c
>> new file mode 100644
>> index 000000000000..0057ab52d6fe
>> --- /dev/null
>> +++ b/arch/powerpc/lib/uaccess.c
>> @@ -0,0 +1,50 @@
>> +#include <linux/mm.h>
>> +#include <linux/uaccess.h>
>> +
>> +static __always_inline long
>> +probe_read_common(void *dst, const void __user *src, size_t size)
>> +{
>> + long ret;
>> +
>> + pagefault_disable();
>> + ret = raw_copy_from_user_allowed(dst, src, size);
>> + pagefault_enable();
>> +
>> + return ret ? -EFAULT : 0;
>> +}
>> +
>> +static __always_inline long
>> +probe_write_common(void __user *dst, const void *src, size_t size)
>> +{
>> + long ret;
>> +
>> + pagefault_disable();
>> + ret = raw_copy_to_user_allowed(dst, src, size);
>> + pagefault_enable();
>> +
>> + return ret ? -EFAULT : 0;
>> +}
>> +
>> +long probe_kernel_read(void *dst, const void *src, size_t size)
>> +{
>> + long ret;
>> + mm_segment_t old_fs = get_fs();
>> +
>> + set_fs(KERNEL_DS);
>> + ret = probe_read_common(dst, (__force const void __user *)src, size);
>
> I think you should squash probe_read_common() here, having it separated
> is a lot of lines for no added value. It also may make people believe it
> overwrites the generic probe_read_common()
Yeah I'll see how that looks.
Thanks,
Nick
prev parent reply other threads:[~2020-04-03 9:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 7:02 [PATCH 1/4] powerpc/64s: implement probe_kernel_read/write without touching AMR Nicholas Piggin
2020-03-27 7:02 ` [PATCH 2/4] powerpc/64s: use mmu_has_feature in set_kuap() and get_kuap() Nicholas Piggin
2020-03-27 7:02 ` [PATCH 3/4] powerpc/uaccess: evaluate macro arguments once, before user access is allowed Nicholas Piggin
2020-03-27 7:21 ` Christophe Leroy
2020-04-03 8:58 ` Nicholas Piggin
2020-03-27 7:02 ` [PATCH 4/4] powerpc/uaccess: add more __builtin_expect annotations Nicholas Piggin
2020-03-27 7:13 ` [PATCH 1/4] powerpc/64s: implement probe_kernel_read/write without touching AMR Christophe Leroy
2020-04-03 8:59 ` Nicholas Piggin [this message]
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=1585904337.b41amzn27o.astroid@bobo.none \
--to=npiggin@gmail$(echo .)com \
--cc=christophe.leroy@c-s$(echo .)fr \
--cc=linuxppc-dev@lists$(echo .)ozlabs.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