From: Al Viro <viro@ZenIV.linux.org.uk>
To: Greentime Hu <green.hu@gmail.com>
Cc: greentime@andestech.com, linux-kernel@vger.kernel.org,
arnd@arndb.de, linux-arch@vger.kernel.org, tglx@linutronix.de,
jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org,
netdev@vger.kernel.org, Vincent Chen <vincentc@andestech.com>
Subject: Re: [PATCH 18/31] nds32: Library functions
Date: Thu, 9 Nov 2017 00:40:20 +0000 [thread overview]
Message-ID: <20171109004020.GX21978@ZenIV.linux.org.uk> (raw)
In-Reply-To: <ea57a25c0aceab45d36951fed44cfbecfe1540b8.1510118606.git.green.hu@gmail.com>
On Wed, Nov 08, 2017 at 01:55:06PM +0800, Greentime Hu wrote:
> +#define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size))
> +
> +#define access_ok(type, addr, size) \
> + __range_ok((unsigned long)addr, (unsigned long)size)
> +#define __get_user_x(__r2,__p,__e,__s,__i...) \
> + __asm__ __volatile__ ( \
> + __asmeq("%0", "$r0") __asmeq("%1", "$r2") \
> + "bal __get_user_" #__s \
... which does not check access_ok() or do any visible equivalents; OK...
> +#define get_user(x,p) \
> + ({ \
> + const register typeof(*(p)) __user *__p asm("$r0") = (p);\
> + register unsigned long __r2 asm("$r2"); \
> + register int __e asm("$r0"); \
> + switch (sizeof(*(__p))) { \
> + case 1: \
> + __get_user_x(__r2, __p, __e, 1, "$lp"); \
... and neither does this, which is almost certainly *not* OK.
> +#define put_user(x,p) \
Same here, AFAICS.
> +extern unsigned long __arch_copy_from_user(void *to, const void __user * from,
> + unsigned long n);
> +static inline unsigned long raw_copy_from_user(void *to,
> + const void __user * from,
> + unsigned long n)
> +{
> + return __arch_copy_from_user(to, from, n);
> +}
Er... Why not call your __arch_... raw_... and be done with that?
> +#define INLINE_COPY_FROM_USER
> +#define INLINE_COPY_TO_USER
Are those actually worth bothering? IOW, have you compared behaviour
with and without them?
> +ENTRY(__arch_copy_to_user)
> + push $r0
> + push $r2
> + beqz $r2, ctu_exit
> + srli $p0, $r2, #2 ! $p0 = number of word to clear
> + andi $r2, $r2, #3 ! Bytes less than a word to copy
> + beqz $p0, byte_ctu ! Only less than a word to copy
> +word_ctu:
> + lmw.bim $p1, [$r1], $p1 ! Load the next word
> +USER( smw.bim,$p1, [$r0], $p1) ! Store the next word
Umm... It's that happy with unaligned loads and stores? Your memcpy seems
to be trying to avoid those...
> +9001:
> + pop $p1 ! Original $r2, n
> + pop $p0 ! Original $r0, void *to
> + sub $r1, $r0, $p0 ! Bytes copied
> + sub $r2, $p1, $r1 ! Bytes left to copy
> + push $lp
> + move $r0, $p0
> + bal memzero ! Clean up the memory
Just what memory are you zeroing here? The one you had been
unable to store into in the first place?
> +ENTRY(__arch_copy_from_user)
> +9001:
> + pop $p1 ! Original $r2, n
> + pop $p0 ! Original $r0, void *to
> + sub $r1, $r1, $p0 ! Bytes copied
> + sub $r2, $p1, $r1 ! Bytes left to copy
> + push $lp
> + bal memzero ! Clean up the memory
Ditto, only this one is even worse - instead of just oopsing on
you, it will quietly destroy data past the area you've copied
into. raw_copy_..._user() MUST NOT ZERO ANYTHING. Ever.
next prev parent reply other threads:[~2017-11-09 0:40 UTC|newest]
Thread overview: 177+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 5:54 [PATCH 00/31] Andes(nds32) Linux Kernel Port Greentime Hu
2017-11-08 5:54 ` [PATCH 01/31] nds32: Assembly macros and definitions Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 02/31] nds32: Kernel booting and initialization Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 13:38 ` Rob Herring
2017-11-09 9:49 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 03/31] nds32: Support early_printk Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 9:47 ` Tobias Klauser
2017-11-09 7:19 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 04/31] nds32: Exception handling Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 8:23 ` Arnd Bergmann
[not found] ` <E26F4CF8B7DDDB4383A6C2D78D5C3CD56B4974CE@ATCPCS16.andestech.com>
2017-11-13 10:54 ` Fwd: FW: " Vincent Chen
2017-11-08 5:54 ` [PATCH 05/31] nds32: MMU definitions Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 8:36 ` Arnd Bergmann
2017-11-08 8:36 ` Arnd Bergmann
2017-11-08 8:46 ` Greentime Hu
2017-11-08 8:46 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 06/31] nds32: MMU initialization Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 07/31] nds32: MMU fault handling and page table management Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 08/31] nds32: Cache and TLB routines Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 8:45 ` Arnd Bergmann
2017-11-08 9:01 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 09/31] nds32: Process management Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 10/31] nds32: IRQ handling Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 8:49 ` Arnd Bergmann
2017-11-08 9:06 ` Greentime Hu
2017-11-08 5:54 ` [PATCH 11/31] nds32: Atomic operations Greentime Hu
2017-11-08 5:54 ` Greentime Hu
2017-11-08 8:54 ` Arnd Bergmann
2017-11-08 8:54 ` Arnd Bergmann
2017-11-08 9:32 ` vincentc
2017-11-20 14:29 ` Will Deacon
2017-11-22 3:02 ` Vincent Chen
2017-11-22 3:02 ` Vincent Chen
2017-11-08 5:55 ` [PATCH 12/31] nds32: Device specific operations Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:04 ` Arnd Bergmann
2017-11-09 7:04 ` Greentime Hu
2017-11-10 16:07 ` Greentime Hu
2017-11-10 16:14 ` Arnd Bergmann
2017-11-22 10:02 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 13/31] nds32: DMA mapping API Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:09 ` Arnd Bergmann
2017-11-08 9:09 ` Arnd Bergmann
2017-11-09 7:12 ` Greentime Hu
2017-11-09 10:14 ` Arnd Bergmann
2017-11-09 10:14 ` Arnd Bergmann
2017-11-10 8:13 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 14/31] nds32: ELF definitions Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 15/31] nds32: System calls handling Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:30 ` Arnd Bergmann
2017-11-08 9:30 ` Arnd Bergmann
[not found] ` <E26F4CF8B7DDDB4383A6C2D78D5C3CD56B497241@ATCPCS16.andestech.com>
2017-11-13 2:51 ` Fwd: FW: " Vincent Chen
2017-11-13 11:42 ` Arnd Bergmann
2017-11-22 3:13 ` Vincent Chen
2017-11-08 5:55 ` [PATCH 16/31] nds32: VDSO support Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:37 ` Arnd Bergmann
2017-11-08 20:00 ` Deepa Dinamani
2017-11-08 20:06 ` Arnd Bergmann
2017-11-08 20:06 ` Arnd Bergmann
2017-11-08 20:14 ` Deepa Dinamani
2017-11-08 5:55 ` [PATCH 17/31] nds32: Signal handling support Greentime Hu
2017-11-09 1:26 ` Al Viro
[not found] ` <E26F4CF8B7DDDB4383A6C2D78D5C3CD56B497460@ATCPCS16.andestech.com>
2017-11-13 2:34 ` Fwd: FW: " Vincent Chen
2017-11-08 5:55 ` [PATCH 18/31] nds32: Library functions Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:45 ` Arnd Bergmann
2017-11-09 0:40 ` Al Viro [this message]
[not found] ` <E26F4CF8B7DDDB4383A6C2D78D5C3CD56B497559@ATCPCS16.andestech.com>
2017-11-14 4:47 ` Fwd: FW: " Vincent Chen
2017-11-14 4:47 ` Vincent Chen
2017-11-18 2:44 ` Al Viro
2017-11-08 5:55 ` [PATCH 19/31] nds32: Debugging support Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 20/31] nds32: L2 cache support Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:48 ` Arnd Bergmann
2017-11-08 9:48 ` Arnd Bergmann
2017-11-09 7:24 ` Greentime Hu
2017-11-09 7:24 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 21/31] nds32: Loadable modules Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 22/31] nds32: Generic timers support Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 23/31] nds32: Device tree support Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:53 ` Arnd Bergmann
2017-11-08 9:53 ` Arnd Bergmann
2017-11-09 7:48 ` Greentime Hu
2017-11-09 7:48 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 24/31] nds32: Miscellaneous header files Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 9:57 ` Arnd Bergmann
2017-11-08 9:57 ` Arnd Bergmann
2017-11-08 5:55 ` [PATCH 25/31] nds32: defconfig Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 10:03 ` Arnd Bergmann
2017-11-08 10:03 ` Arnd Bergmann
2017-11-09 8:00 ` Greentime Hu
2017-11-09 8:00 ` Greentime Hu
2017-11-09 10:20 ` Arnd Bergmann
2017-11-09 10:20 ` Arnd Bergmann
2017-11-10 8:16 ` Greentime Hu
2017-11-10 8:16 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 26/31] nds32: Build infrastructure Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 10:16 ` Arnd Bergmann
2017-11-09 9:02 ` Greentime Hu
2017-11-09 10:33 ` Arnd Bergmann
2017-11-09 10:33 ` Arnd Bergmann
2017-11-10 8:26 ` Greentime Hu
2017-11-10 8:26 ` Greentime Hu
2017-11-17 12:39 ` Greentime Hu
2017-11-17 12:50 ` Arnd Bergmann
2017-11-17 12:50 ` Arnd Bergmann
2017-11-17 13:50 ` Greentime Hu
2017-11-17 13:50 ` Greentime Hu
2017-11-13 10:45 ` Geert Uytterhoeven
2017-11-13 10:45 ` Geert Uytterhoeven
2017-11-16 10:03 ` Greentime Hu
2017-11-16 10:25 ` Arnd Bergmann
2017-11-17 13:53 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 27/31] dt-bindings: interrupt-controller: Andestech Internal Vector Interrupt Controller Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 13:25 ` Rob Herring
2017-11-08 13:25 ` Rob Herring
2017-11-09 9:43 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 28/31] irqchip: Andestech Internal Vector Interrupt Controller driver Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 14:24 ` Marc Zyngier
2017-11-08 14:24 ` Marc Zyngier
2017-11-09 10:10 ` Greentime Hu
2017-11-09 10:10 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 29/31] MAINTAINERS: Add nds32 Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 13:31 ` Rob Herring
2017-11-09 9:46 ` Greentime Hu
2017-11-09 9:46 ` Greentime Hu
2017-11-09 10:36 ` Arnd Bergmann
2017-11-14 15:39 ` Joe Perches
2017-11-14 15:39 ` Joe Perches
2017-11-16 12:22 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 30/31] dt-bindings: nds32 CPU Bindings Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 13:18 ` Rob Herring
2017-11-09 9:39 ` Greentime Hu
2017-11-09 9:39 ` Greentime Hu
[not found] ` <CAEbi=3e-hRbej7EZ68-J1YPNfdxu7O_BAZ1rvZvAhhYzAT09-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-09 13:57 ` Rob Herring
2017-11-09 13:57 ` Rob Herring
2017-11-10 6:22 ` Greentime Hu
2017-11-10 6:22 ` Greentime Hu
2017-11-10 8:25 ` Arnd Bergmann
[not found] ` <CAK8P3a1k_zNN6FTRNm5kfun8Nb+3ZLtmCLjHOVZUFB10TqQBFQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-10 8:43 ` Greentime Hu
2017-11-10 8:43 ` Greentime Hu
2017-11-08 5:55 ` [PATCH 31/31] net: faraday add nds32 support Greentime Hu
2017-11-08 5:55 ` Greentime Hu
2017-11-08 8:32 ` [PATCH 00/31] Andes(nds32) Linux Kernel Port David Howells
2017-11-08 8:41 ` Greentime Hu
2017-11-08 8:41 ` Greentime Hu
2017-11-08 10:18 ` Arnd Bergmann
2017-11-08 10:18 ` Arnd Bergmann
2017-11-09 9:26 ` Greentime Hu
2017-11-08 10:26 ` Arnd Bergmann
2017-11-08 10:26 ` Arnd Bergmann
2017-11-09 9:33 ` Greentime Hu
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=20171109004020.GX21978@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=arnd@arndb.de \
--cc=green.hu@gmail.com \
--cc=greentime@andestech.com \
--cc=jason@lakedaemon.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=tglx@linutronix.de \
--cc=vincentc@andestech.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).