Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e2aec87 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'generic-string-functions'

This makes <asm/word-at-a-time.h> actually live up to its promise of
allowing architectures to help tune the string functions that do their
work a word at a time.

David had already taken the x86 strncpy_from_user() function, modified
it to work on sparc, and then done the extra work to make it generically
useful.  This then expands on that work by making x86 use that generic
version, completing the circle.

But more importantly, it fixes up the word-at-a-time interfaces so that
it's now easy to also support things like strnlen_user(), and pretty
much most random string functions.

David reports that it all works fine on sparc, and Jonas Bonn reported
that an earlier version of this worked on OpenRISC too.  It's pretty
easy for architectures to add support for this and just replace their
private versions with the generic code.

* generic-string-functions:
  sparc: use the new generic strnlen_user() function
  x86: use the new generic strnlen_user() function
  lib: add generic strnlen_user() function
  word-at-a-time: make the interfaces truly generic
  x86: use generic strncpy_from_user routine
parents ae32adc1 2c66f623
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -66,3 +66,4 @@ generic-y += topology.h
generic-y += types.h
generic-y += ucontext.h
generic-y += user.h
generic-y += word-at-a-time.h
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ config SPARC
	select GENERIC_CMOS_UPDATE
	select GENERIC_CLOCKEVENTS
	select GENERIC_STRNCPY_FROM_USER
	select GENERIC_STRNLEN_USER

config SPARC32
	def_bool !64BIT
+1 −0
Original line number Diff line number Diff line
@@ -21,3 +21,4 @@ generic-y += div64.h
generic-y += local64.h
generic-y += irq_regs.h
generic-y += local.h
generic-y += word-at-a-time.h
+4 −18
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#ifndef __ASSEMBLY__

#include <asm/processor.h>

#define ARCH_HAS_SORT_EXTABLE
#define ARCH_HAS_SEARCH_EXTABLE

@@ -304,24 +306,8 @@ static inline unsigned long clear_user(void __user *addr, unsigned long n)
		return n;
}

extern long __strlen_user(const char __user *);
extern long __strnlen_user(const char __user *, long len);

static inline long strlen_user(const char __user *str)
{
	if (!access_ok(VERIFY_READ, str, 0))
		return 0;
	else
		return __strlen_user(str);
}

static inline long strnlen_user(const char __user *str, long len)
{
	if (!access_ok(VERIFY_READ, str, 0))
		return 0;
	else
		return __strnlen_user(str, len);
}
extern __must_check long strlen_user(const char __user *str);
extern __must_check long strnlen_user(const char __user *str, long n);

#endif  /* __ASSEMBLY__ */

+4 −4
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@

#ifndef __ASSEMBLY__

#include <asm/processor.h>

/*
 * Sparc64 is segmented, though more like the M68K than the I386.
 * We use the secondary ASI to address user memory, which references a
@@ -257,11 +259,9 @@ extern unsigned long __must_check __clear_user(void __user *, unsigned long);

#define clear_user __clear_user

extern long __strlen_user(const char __user *);
extern long __strnlen_user(const char __user *, long len);
extern __must_check long strlen_user(const char __user *str);
extern __must_check long strnlen_user(const char __user *str, long n);

#define strlen_user __strlen_user
#define strnlen_user __strnlen_user
#define __copy_to_user_inatomic ___copy_to_user
#define __copy_from_user_inatomic ___copy_from_user

Loading