Skip to content

Commit

Permalink
maccess,probe_kernel: Make write/read src const void *
Browse files Browse the repository at this point in the history
The functions probe_kernel_write() and probe_kernel_read() do not modify
the src pointer. Allow const pointers to be passed in without the need
of a typecast.

Acked-by: Mike Frysinger <[email protected]>
Acked-by: Heiko Carstens <[email protected]>
Acked-by: Martin Schwidefsky <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
  • Loading branch information
Steven Rostedt authored and rostedt committed May 25, 2011
1 parent 6e9101a commit f29c504
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions arch/blackfin/mm/maccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static int validate_memory_access_address(unsigned long addr, int size)
return bfin_mem_access_type(addr, size);
}

long probe_kernel_read(void *dst, void *src, size_t size)
long probe_kernel_read(void *dst, const void *src, size_t size)
{
unsigned long lsrc = (unsigned long)src;
int mem_type;
Expand Down Expand Up @@ -55,7 +55,7 @@ long probe_kernel_read(void *dst, void *src, size_t size)
return -EFAULT;
}

long probe_kernel_write(void *dst, void *src, size_t size)
long probe_kernel_write(void *dst, const void *src, size_t size)
{
unsigned long ldst = (unsigned long)dst;
int mem_type;
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/mm/maccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* using the stura instruction.
* Returns the number of bytes copied or -EFAULT.
*/
static long probe_kernel_write_odd(void *dst, void *src, size_t size)
static long probe_kernel_write_odd(void *dst, const void *src, size_t size)
{
unsigned long count, aligned;
int offset, mask;
Expand All @@ -45,7 +45,7 @@ static long probe_kernel_write_odd(void *dst, void *src, size_t size)
return rc ? rc : count;
}

long probe_kernel_write(void *dst, void *src, size_t size)
long probe_kernel_write(void *dst, const void *src, size_t size)
{
long copied = 0;

Expand Down
8 changes: 4 additions & 4 deletions include/linux/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ static inline unsigned long __copy_from_user_nocache(void *to,
* Safely read from address @src to the buffer at @dst. If a kernel fault
* happens, handle that and return -EFAULT.
*/
extern long probe_kernel_read(void *dst, void *src, size_t size);
extern long __probe_kernel_read(void *dst, void *src, size_t size);
extern long probe_kernel_read(void *dst, const void *src, size_t size);
extern long __probe_kernel_read(void *dst, const void *src, size_t size);

/*
* probe_kernel_write(): safely attempt to write to a location
Expand All @@ -105,7 +105,7 @@ extern long __probe_kernel_read(void *dst, void *src, size_t size);
* Safely write to address @dst from the buffer at @src. If a kernel fault
* happens, handle that and return -EFAULT.
*/
extern long notrace probe_kernel_write(void *dst, void *src, size_t size);
extern long notrace __probe_kernel_write(void *dst, void *src, size_t size);
extern long notrace probe_kernel_write(void *dst, const void *src, size_t size);
extern long notrace __probe_kernel_write(void *dst, const void *src, size_t size);

#endif /* __LINUX_UACCESS_H__ */
8 changes: 4 additions & 4 deletions mm/maccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* happens, handle that and return -EFAULT.
*/

long __weak probe_kernel_read(void *dst, void *src, size_t size)
long __weak probe_kernel_read(void *dst, const void *src, size_t size)
__attribute__((alias("__probe_kernel_read")));

long __probe_kernel_read(void *dst, void *src, size_t size)
long __probe_kernel_read(void *dst, const void *src, size_t size)
{
long ret;
mm_segment_t old_fs = get_fs();
Expand All @@ -43,10 +43,10 @@ EXPORT_SYMBOL_GPL(probe_kernel_read);
* Safely write to address @dst from the buffer at @src. If a kernel fault
* happens, handle that and return -EFAULT.
*/
long __weak probe_kernel_write(void *dst, void *src, size_t size)
long __weak probe_kernel_write(void *dst, const void *src, size_t size)
__attribute__((alias("__probe_kernel_write")));

long __probe_kernel_write(void *dst, void *src, size_t size)
long __probe_kernel_write(void *dst, const void *src, size_t size)
{
long ret;
mm_segment_t old_fs = get_fs();
Expand Down

0 comments on commit f29c504

Please sign in to comment.