Jonas Bonn | 25 May 08:24
Picon

[PATCH 1/1] openrisc: use generic strncpy_from_user


As per commits 2922585b93294d47172a765115e0dbc1bfe1be19
("lib: Sparc's strncpy_from_user is generic enough, move under lib/"),
92ae03f2ef99fbc23bfa9080d6b58f25227bd7ef ("x86: merge 32/64-bit versions
of 'strncpy_from_user()' and speed it up"), and corresponding
discussion on linux-arch.

Signed-off-by: Jonas Bonn <jonas <at> southpole.se>
---

Hi Linus,

Here's a single patch update to the OpenRISC arch to use the new
strncpy_from_user implementation.  Hope it's ok to send it as a
single patch and not as a pull request; let me know otherwise.

Thanks,
Jonas

 arch/openrisc/Kconfig               |    1 +
 arch/openrisc/include/asm/uaccess.h |   10 ++-----
 arch/openrisc/lib/string.S          |   52 -----------------------------------
 3 files changed, 4 insertions(+), 59 deletions(-)

diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index da4ccd1..ee4d124 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -19,6 +19,7 @@ config OPENRISC
 	select GENERIC_CPU_DEVICES
(Continue reading)

David Miller | 24 May 22:26
Favicon

[PATCH 2/3 v2] kernel: Move REPEAT_BYTE definition into linux/kernel.h


And make sure that everything using it explicitly includes
that header file.

Signed-off-by: David S. Miller <davem <at> davemloft.net>
---
 arch/sparc/lib/usercopy.c             |    3 +--
 arch/x86/include/asm/word-at-a-time.h |    4 ++--
 fs/namei.c                            |    1 +
 include/linux/kernel.h                |    2 ++
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/lib/usercopy.c b/arch/sparc/lib/usercopy.c
index f61ed82..0b12e91 100644
--- a/arch/sparc/lib/usercopy.c
+++ b/arch/sparc/lib/usercopy.c
@@ -1,5 +1,6 @@
 #include <linux/module.h>
 #include <linux/uaccess.h>
+#include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/bug.h>

@@ -11,8 +12,6 @@ void copy_from_user_overflow(void)
 }
 EXPORT_SYMBOL(copy_from_user_overflow);

-#define REPEAT_BYTE(x)	((~0ul / 0xff) * (x))
-
 static inline long find_zero(unsigned long mask)
(Continue reading)

David Miller | 24 May 05:34
Favicon

[PATCH 3/3] lib: Sparc's strncpy_from_user is generic enough, move under lib/


To use this, an architecture simply needs to:

1) Provide a user_addr_max() implementation via asm/uaccess.h

2) Add "select GENERIC_STRNCPY_FROM_USER" to their arch Kcnfig

3) Remove the existing strncpy_from_user() implementation and symbol
   exports their architecture had.

Signed-off-by: David S. Miller <davem <at> davemloft.net>
---
 arch/sparc/Kconfig        |    1 +
 arch/sparc/lib/usercopy.c |  138 --------------------------------------------
 lib/Kconfig               |    3 +
 lib/Makefile              |    2 +
 lib/strncpy_from_user.c   |  140 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 146 insertions(+), 138 deletions(-)
 create mode 100644 lib/strncpy_from_user.c

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 051af37..2247423 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -32,6 +32,7 @@ config SPARC
 	select HAVE_NMI_WATCHDOG if SPARC64
 	select HAVE_BPF_JIT
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_STRNCPY_FROM_USER

(Continue reading)

David Miller | 24 May 05:34
Favicon

[PATCH 1/3] sparc: Increase portability of strncpy_from_user() implementation.


Hide details of maximum user address calculation in a new
asm/uaccess.h interface named user_addr_max().

Provide little-endian implementation in find_zero(), which should work
but can probably be improved.

Guard alignment check using CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.

Signed-off-by: David S. Miller <davem <at> davemloft.net>
---
 arch/sparc/include/asm/uaccess.h |    3 +++
 arch/sparc/lib/usercopy.c        |   28 ++++++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
index 42a28cf..20c2acb 100644
--- a/arch/sparc/include/asm/uaccess.h
+++ b/arch/sparc/include/asm/uaccess.h
@@ -6,6 +6,9 @@
 #include <asm/uaccess_32.h>
 #endif

+#define user_addr_max() \
+	(segment_eq(get_fs(), USER_DS) ? STACK_TOP : ~0UL)
+
 extern long strncpy_from_user(char *dest, const char __user *src, long count);

 #endif
diff --git a/arch/sparc/lib/usercopy.c b/arch/sparc/lib/usercopy.c
(Continue reading)

David Miller | 24 May 05:34
Favicon

[PATCH 2/3] kernel: Move REPEAT_BYTE definition into linux/kernel.h


And make sure that everything using it explicitly includes
that header file.

Signed-off-by: David S. Miller <davem <at> davemloft.net>
---
 arch/sparc/lib/usercopy.c             |    3 +--
 arch/x86/include/asm/word-at-a-time.h |    4 ++--
 fs/namei.c                            |    1 +
 include/linux/kernel.h                |    2 ++
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/lib/usercopy.c b/arch/sparc/lib/usercopy.c
index 9ba59ef..3d3bef9 100644
--- a/arch/sparc/lib/usercopy.c
+++ b/arch/sparc/lib/usercopy.c
@@ -1,5 +1,6 @@
 #include <linux/module.h>
 #include <linux/uaccess.h>
+#include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/bug.h>

@@ -11,8 +12,6 @@ void copy_from_user_overflow(void)
 }
 EXPORT_SYMBOL(copy_from_user_overflow);

-#define REPEAT_BYTE(x)	((~0ul / 0xff) * (x))
-
 static inline long find_zero(unsigned long mask)
(Continue reading)

David Miller | 24 May 05:34
Favicon

[PATCH 0/3] Make sparc's strncpy_from_user() generic.


Ok, this is against my current sparc GIT tree at:

	git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git

After these changes it should definitely be usable by any
architecture.

If there are no major objections I can push this out to my sparc tree
and ask Linus to pull all of this work in.

Afterwards we can tweak it to use the x86 word-at-a-time tricks if we
want.

Thanks.
Al Viro | 22 May 06:35
Picon
Favicon

[git pull] signals, the first series

	This is just the first part of the queue (about a half of it);
assorted fixes all over the place in signals' handling.  This one ends
with all sigsuspend() implementations switched to generic one
(->saved_sigmask-based), a bunch of assorted old buglets fixed and most
of the missing bits of NOTIFY_RESUME hookup in place (two more sit in
arm and um trees resp. and there's a couple of broken ones that need
obvious fixes - parisc and avr32 check TIF_NOTIFY_RESUME only on one of
two codepaths; that'll go in the next series).  Please, pull from
git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal.git for-linus

Shortlog:
Al Viro (35):
      new helper: sigsuspend()
      parisc: resetting ->restart_block.fn needs to be done on rt_sigreturn()
      c6x: ->restart_block.fn needs to be reset on rt_sigreturn
      hexagon: ->restart_block.fn needs to be reset on rt_sigreturn
      microblaze: ->restart_block.fn needs to be reset on rt_sigreturn
      score: ->restart_block.fn needs to be reset on rt_sigreturn
      xtensa: ->restart_block.fn needs to be reset on rt_sigreturn
      avr32: ->restart_block.fn needs to be reset on rt_sigreturn
      xtensa: switch to generic rt_sigsuspend(2)
      sh: switch to saved_sigmask-based sigsuspend()/rt_sigsuspend()
      h8300: don't change blocked signals' mask if setting frame up fails
      h8300: switch to saved_sigmask-based sigsuspend/rt_sigsuspend
      cris: SA_ONESHOT handling is done by get_signal_to_deliver()
      microblaze: bury sys_rt_sigsuspend_wrapper in nommu case too
      avr32: need to clear RESTORE_SIGMASK on successful signal delivery
      blackfin: don't open-code force_sigsegv()
      cris: don't open-code force_sigsegv()
      score: don't open-code force_sigsegv()
(Continue reading)

Linus Torvalds | 21 May 18:50
Gravatar

Arch maintainers Ahoy! (was Re: x86: faster strncpy_from_user())

Ok, several weeks ago I sent out an email about the x86
strncpy_from_user() patch I did, and cc'd linux-arch because the
second stage might well affect other architectures.

Nobody reacted to it, and today that second stage was merged into
mainline, so I thought I'd re-do the notice. The relevant part of the
original explanation is appended, but I'll explain once more..

On x86, we *used* to be very lazy about strncpy_from_user(), and not
actually do the full proper error handling: the code was (for
historical reasons) using inline asms where it was very inconvenient
to actually check the proper end of the address space. And nobody had
really ever bothered to fix it up. As a result, the main user
(getname()) had its own special magic workarounds for this.

Until 3.4. We now do strncpy_from_user() properly, with all the
appropriate error cases of hitting the end of the user address space
etc handled.

And now that the 3.5 merge window is open, some of the first merging I
did was my own branches that had been pending. Including the one that
removes all the hackery from getname(), and expects
strncpy_from_user() to just work right.

If any architecture copied the lazy x86 strncpy_from_user(), they
really do need to fix themselves now. You can actually take the new
all-C x86 implementation, and just strip away the word-at-a-time
optimizations, and it should be pretty generic (if perhaps not
optimal).

(Continue reading)

免交40万留学保证金,打造平民化的出国留学服务,爱尔兰名校等您来深造

您还在为家庭不够富裕,而不能让品学兼优的孩子出国深造而苦恼吗?
您还在为国内教育资源分配严重不均,而不能让自己的孩子获得理想的教育环境而发愁吗?

免交40万留学保证金,打造平民化的出国留学服务!
让工薪家庭孩子也可以一圆出国留学梦!

爱尔兰名校等您来深造!
想了解详情的请联系QQ: 2636882155   或者立即回复邮箱: 2636882155 <at> qq.com
想了解详情的请联系QQ: 2636882155   或者立即回复邮箱: 2636882155 <at> qq.com
想了解详情的请联系QQ: 2636882155   或者立即回复邮箱: 2636882155 <at> qq.com
 
 
现诚招全国各地出国留学顾问。
零风险!高回报!共享朝阳般的教育产业大蛋糕!
请联系QQ: 2636882155
请联系QQ: 2636882155
请联系QQ: 2636882155
Mr. Peter Wong | 21 May 00:20
Favicon

Re:

Good-Day Friend,

I Mr. Peter Wong, I Need Your Assistance

Al Viro | 19 May 23:09
Picon
Favicon

hexagon: signal bugs

	1) spot the braino:
void do_trap0(struct pt_regs *regs)
...
        unsigned long syscallret = 0;
	...
                if ((unsigned long) regs->syscall_nr >= __NR_syscalls) {
                        regs->r00 = -1;
                } else {
                        syscall = (syscall_fn)
                                  (sys_call_table[regs->syscall_nr]);
                        syscallret = syscall(regs->r00, regs->r01,
                                   regs->r02, regs->r03,
                                   regs->r04, regs->r05);
                }

                if (regs->syscall_nr != __NR_rt_sigreturn)
                        regs->r00 = syscallret;
IOW, the last if () should've been inside the "syscall_nr is not too high"
branch of the if () just above...

	2) you do _not_ want syscall restarts to happen on sigreturn().
Whatever adjustment needed to be done had already been done back before
we'd saved the registers into sigcontext.  So doing
        regs->syscall_nr = __NR_rt_sigreturn;
in sys_rt_sigreturn() is exactly the wrong thing - for syscall restart
purposes you want it to look like a non-syscall (i.e. it should be
regs->syscall_nr = -1 to make your check in handle_signal() work).
Incidentally, I would suggest just having that thing return regs->r00;
then you can avoid all special-casing for "do we want to put the
return value of sys_...() into regs->r00?" in do_trap0().
(Continue reading)


Gmane