From: LABBE Corentin Date: Thu, 4 Sep 2014 13:24:57 +0000 (+0200) Subject: staging: lustre: Annotate user buffer with __user X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=5a08f0672b29659c5dcdbbe7fa136ab810292259;p=openwrt%2Fstaging%2Fblogic.git staging: lustre: Annotate user buffer with __user Fix the warning reported by sparse on drivers/staging/lustre/lnet/lnet/router_proc.c warning: incorrect type in argument 4 (different address spaces) The correction is to annotate all user buffer variable by __user Signed-off-by: LABBE Corentin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 30098f39181f..aa9222cbc7cc 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -265,9 +265,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, /* other external symbols that tracefile provides: */ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, - const char *usr_buffer, int usr_buffer_nob); -int cfs_trace_copyout_string(char *usr_buffer, int usr_buffer_nob, - const char *knl_buffer, char *append); + const char __user *usr_buffer, int usr_buffer_nob); +int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, + const char *knl_buffer, char *append); #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log" diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 166c1e647e2b..6e8f7e2bbcfc 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -90,9 +90,10 @@ enum { #define LNET_PROC_VERSION(v) ((unsigned int)((v) & LNET_PROC_VER_MASK)) -static int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, - size_t *lenp, int (*handler)(void *data, int write, - loff_t pos, void *buffer, int len)) +static int proc_call_handler(void *data, int write, loff_t *ppos, + void __user *buffer, size_t *lenp, + int (*handler)(void *data, int write, + loff_t pos, void __user *buffer, int len)) { int rc = handler(data, write, *ppos, buffer, *lenp); @@ -109,7 +110,7 @@ static int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, } static int __proc_lnet_stats(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { int rc; lnet_counters_t *ctrs; @@ -592,7 +593,7 @@ int proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer, } static int __proc_lnet_buffers(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { char *s; char *tmpstr; @@ -815,7 +816,7 @@ static struct lnet_portal_rotors portal_rotors[] = { extern int portal_rotor; static int __proc_lnet_portal_rotor(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { const int buf_len = 128; char *buf; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index 13a9266acfa0..bbe2c68c18a6 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -98,9 +98,10 @@ enum { PSDEV_LNET_FAIL_VAL, /* userdata for fail loc */ }; -static int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, - size_t *lenp, int (*handler)(void *data, int write, - loff_t pos, void *buffer, int len)) +static int proc_call_handler(void *data, int write, loff_t *ppos, + void __user *buffer, size_t *lenp, + int (*handler)(void *data, int write, + loff_t pos, void __user *buffer, int len)) { int rc = handler(data, write, *ppos, buffer, *lenp); @@ -117,7 +118,7 @@ static int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, } static int __proc_dobitmasks(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { const int tmpstrlen = 512; char *tmpstr; @@ -168,7 +169,7 @@ static int min_watchdog_ratelimit = 0; /* disable ratelimiting */ static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */ static int __proc_dump_kernel(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { if (!write) return 0; @@ -184,7 +185,7 @@ static int proc_dump_kernel(struct ctl_table *table, int write, } static int __proc_daemon_file(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { if (!write) { int len = strlen(cfs_tracefile); @@ -207,7 +208,7 @@ static int proc_daemon_file(struct ctl_table *table, int write, } static int __proc_debug_mb(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { if (!write) { char tmpstr[32]; @@ -344,7 +345,7 @@ int proc_fail_loc(struct ctl_table *table, int write, void __user *buffer, } static int __proc_cpt_table(void *data, int write, - loff_t pos, void *buffer, int nob) + loff_t pos, void __user *buffer, int nob) { char *buf = NULL; int len = 4096; diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 0569bf8c75f3..7e3f6a45da00 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -755,7 +755,7 @@ void cfs_trace_flush_pages(void) } int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, - const char *usr_buffer, int usr_buffer_nob) + const char __user *usr_buffer, int usr_buffer_nob) { int nob; @@ -763,7 +763,7 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, return -EOVERFLOW; if (copy_from_user((void *)knl_buffer, - (void *)usr_buffer, usr_buffer_nob)) + usr_buffer, usr_buffer_nob)) return -EFAULT; nob = strnlen(knl_buffer, usr_buffer_nob); @@ -782,7 +782,7 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, } EXPORT_SYMBOL(cfs_trace_copyin_string); -int cfs_trace_copyout_string(char *usr_buffer, int usr_buffer_nob, +int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, const char *knl_buffer, char *append) { /* NB if 'append' != NULL, it's a single character to append to the @@ -824,7 +824,7 @@ void cfs_trace_free_string_buffer(char *str, int nob) kfree(str); } -int cfs_trace_dump_debug_buffer_usrstr(void *usr_str, int usr_str_nob) +int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob) { char *str; int rc; @@ -886,7 +886,7 @@ int cfs_trace_daemon_command(char *str) return rc; } -int cfs_trace_daemon_command_usrstr(void *usr_str, int usr_str_nob) +int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob) { char *str; int rc; @@ -939,7 +939,7 @@ int cfs_trace_set_debug_mb(int mb) return 0; } -int cfs_trace_set_debug_mb_usrstr(void *usr_str, int usr_str_nob) +int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob) { char str[32]; int rc; diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.h b/drivers/staging/lustre/lustre/libcfs/tracefile.h index 8df4af36c91d..0601476e1dc3 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.h +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.h @@ -68,16 +68,16 @@ void cfs_tracefile_exit(void); int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, - const char *usr_buffer, int usr_buffer_nob); -int cfs_trace_copyout_string(char *usr_buffer, int usr_buffer_nob, + const char __user *usr_buffer, int usr_buffer_nob); +int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, const char *knl_str, char *append); int cfs_trace_allocate_string_buffer(char **str, int nob); void cfs_trace_free_string_buffer(char *str, int nob); -int cfs_trace_dump_debug_buffer_usrstr(void *usr_str, int usr_str_nob); +int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob); int cfs_trace_daemon_command(char *str); -int cfs_trace_daemon_command_usrstr(void *usr_str, int usr_str_nob); +int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob); int cfs_trace_set_debug_mb(int mb); -int cfs_trace_set_debug_mb_usrstr(void *usr_str, int usr_str_nob); +int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob); int cfs_trace_get_debug_mb(void); extern void libcfs_debug_dumplog_internal(void *arg);