* [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
@ 2014-12-05 8:03 Tristan Lelong
2014-12-05 8:28 ` Joe Perches
2014-12-05 21:27 ` Greg KH
0 siblings, 2 replies; 9+ messages in thread
From: Tristan Lelong @ 2014-12-05 8:03 UTC (permalink / raw)
To: oleg.drokin, andreas.dilger, gregkh, askb23, john.hammond,
gdonald, anhlq2110, fabio.falzoi84, oort10, agimenez, rupran,
surya.seetharaman9, Julia.Lawall, joe, a.terekhov, liang.zhen,
vthakkar1994, amk, srikrishanmalik, rd, bergwolf, dan.carpenter,
paul.gortmaker, tapaswenipathak, email, uja.ornl, brilliantov,
dmitry.eremin
Cc: HPDD-discuss, devel, linux-kernel, Tristan Lelong
This patch fix a sparse warning in lustre sources
warning: incorrect type in argument 1 (different address spaces)
expected void [noderef] <asn:1>*to
got char *<noident>
This is done by adding the missing __user attribute on userland pointers inside
the LPROC_SEQ_FOPS-like macros:
- LPROC_SEQ_FOPS
- LPROC_SEQ_FOPS_RW_TYPE
- LPROC_SEQ_FOPS_WR_ONLY
- LDLM_POOL_PROC_WRITER
The patch also updates all the functions that are used by this macro:
- lprocfs_wr_*
- *_seq_write
as well as some helpers used by the previously modified functions (otherwise
fixing the sparse warning add some new ones):
- lprocfs_write_frac_helper
- lprocfs_write_helper
- lprocfs_write_u64_helper
The patch also fixes one __user pointer direct dereference by strncmp
in function fld_proc_hash_seq_write by adding the proper copy_from_user.
Signed-off-by: Tristan Lelong <tristan@lelong.xyz>
---
drivers/staging/lustre/lustre/fld/lproc_fld.c | 14 ++++--
.../staging/lustre/lustre/include/lprocfs_status.h | 44 +++++++++--------
drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 5 +-
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 4 +-
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 7 +--
drivers/staging/lustre/lustre/lov/lproc_lov.c | 20 +++++---
drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 7 +--
.../lustre/lustre/obdclass/linux/linux-module.c | 5 +-
.../lustre/lustre/obdclass/lprocfs_status.c | 2 +-
drivers/staging/lustre/lustre/osc/lproc_osc.c | 57 +++++++++++++---------
.../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 25 +++++-----
11 files changed, 114 insertions(+), 76 deletions(-)
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index 95e7de1..9f1db6c 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -87,13 +87,21 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
}
static ssize_t
-fld_proc_hash_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+fld_proc_hash_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct lu_client_fld *fld;
struct lu_fld_hash *hash = NULL;
+ char name[80];
int i;
+ if (count > 80)
+ return -ENAMETOOLONG;
+
+ if (copy_from_user(name, buffer, count) != 0)
+ return -EFAULT;
+
fld = ((struct seq_file *)file->private_data)->private;
LASSERT(fld != NULL);
@@ -101,7 +109,7 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer,
if (count != strlen(fld_hash[i].fh_name))
continue;
- if (!strncmp(fld_hash[i].fh_name, buffer, count)) {
+ if (!strncmp(fld_hash[i].fh_name, name, count)) {
hash = &fld_hash[i];
break;
}
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index cfe503b..8a25cf6 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -627,16 +627,16 @@ struct adaptive_timeout;
extern int lprocfs_at_hist_helper(struct seq_file *m,
struct adaptive_timeout *at);
extern int lprocfs_rd_timeouts(struct seq_file *m, void *data);
-extern int lprocfs_wr_timeouts(struct file *file, const char *buffer,
+extern int lprocfs_wr_timeouts(struct file *file, const char __user *buffer,
unsigned long count, void *data);
-extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
+extern int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
-extern int lprocfs_wr_ping(struct file *file, const char *buffer,
+extern int lprocfs_wr_ping(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
-extern int lprocfs_wr_import(struct file *file, const char *buffer,
+extern int lprocfs_wr_import(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
extern int lprocfs_rd_pinger_recov(struct seq_file *m, void *n);
-extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
+extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
/* Statfs helpers */
@@ -650,8 +650,8 @@ extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
int *val);
extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
-extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
- __u64 *val);
+extern int lprocfs_write_u64_helper(const char __user *buffer,
+ unsigned long count, __u64 *val);
extern int lprocfs_write_frac_u64_helper(const char *buffer,
unsigned long count,
__u64 *val, int mult);
@@ -716,7 +716,8 @@ static struct file_operations name##_fops = { \
return lprocfs_rd_##type(m, m->private); \
} \
static ssize_t name##_##type##_seq_write(struct file *file, \
- const char *buffer, size_t count, loff_t *off) \
+ const char __user *buffer, size_t count, \
+ loff_t *off) \
{ \
struct seq_file *seq = file->private_data; \
return lprocfs_wr_##type(file, buffer, \
@@ -726,7 +727,8 @@ static struct file_operations name##_fops = { \
#define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
static ssize_t name##_##type##_write(struct file *file, \
- const char *buffer, size_t count, loff_t *off) \
+ const char __user *buffer, size_t count, \
+ loff_t *off) \
{ \
return lprocfs_wr_##type(file, buffer, count, off); \
} \
@@ -939,20 +941,24 @@ static inline int lprocfs_at_hist_helper(struct seq_file *m,
static inline int lprocfs_rd_timeouts(struct seq_file *m, void *data)
{ return 0; }
static inline int lprocfs_wr_timeouts(struct file *file,
- const char *buffer,
- unsigned long count, void *data)
+ const char __user *buffer,
+ unsigned long count, void *data)
{ return 0; }
-static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static inline int lprocfs_wr_evict_client(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{ return 0; }
-static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static inline int lprocfs_wr_ping(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{ return 0; }
-static inline int lprocfs_wr_import(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static inline int lprocfs_wr_import(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{ return 0; }
-static inline int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static inline int lprocfs_wr_pinger_recov(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{ return 0; }
/* Statfs helpers */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index 6c6c57c..20e64cd 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -249,8 +249,9 @@ typedef enum ldlm_policy_res ldlm_policy_res_t;
struct __##var##__dummy_read {; } /* semicolon catcher */
#define LDLM_POOL_PROC_WRITER(var, type) \
- static int lprocfs_wr_##var(struct file *file, const char *buffer, \
- unsigned long count, void *data) \
+ static int lprocfs_wr_##var(struct file *file, \
+ const char __user *buffer, \
+ unsigned long count, void *data) \
{ \
struct ldlm_pool *pl = data; \
type tmp; \
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index 4c838f6..142b3dd 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -697,8 +697,8 @@ LPROC_SEQ_FOPS_RO(lprocfs_grant_plan);
LDLM_POOL_PROC_READER_SEQ_SHOW(recalc_period, int);
LDLM_POOL_PROC_WRITER(recalc_period, int);
static ssize_t lprocfs_recalc_period_seq_write(struct file *file,
- const char *buf, size_t len,
- loff_t *off)
+ const char __user *buf,
+ size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 1f150e4..c6f62a9 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -72,7 +72,7 @@ extern unsigned int ldlm_cancel_unused_locks_before_replay;
unsigned int ldlm_dump_granted_max = 256;
#if defined(CONFIG_PROC_FS)
-static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer,
+static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
@@ -287,8 +287,9 @@ static int lprocfs_elc_seq_show(struct seq_file *m, void *v)
return lprocfs_rd_uint(m, &supp);
}
-static ssize_t lprocfs_elc_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t lprocfs_elc_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
unsigned int supp = -1;
diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c
index c993f25..c99f2f4 100644
--- a/drivers/staging/lustre/lustre/lov/lproc_lov.c
+++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c
@@ -51,8 +51,9 @@ static int lov_stripesize_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%llu\n", desc->ld_default_stripe_size);
}
-static ssize_t lov_stripesize_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t lov_stripesize_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc;
@@ -81,8 +82,9 @@ static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%llu\n", desc->ld_default_stripe_offset);
}
-static ssize_t lov_stripeoffset_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t lov_stripeoffset_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc;
@@ -110,8 +112,9 @@ static int lov_stripetype_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%u\n", desc->ld_pattern);
}
-static ssize_t lov_stripetype_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t lov_stripetype_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc;
@@ -140,8 +143,9 @@ static int lov_stripecount_seq_show(struct seq_file *m, void *v)
(__s16)(desc->ld_default_stripe_count + 1) - 1);
}
-static ssize_t lov_stripecount_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t lov_stripecount_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc;
diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
index 16341c8..c420219 100644
--- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
+++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
@@ -52,7 +52,7 @@ static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
}
static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
- const char *buffer,
+ const char __user *buffer,
size_t count,
loff_t *off)
{
@@ -82,8 +82,9 @@ static int mdc_kuc_open(struct inode *inode, struct file *file)
}
/* temporary for testing */
-static ssize_t mdc_kuc_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t mdc_kuc_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *obd =
((struct seq_file *)file->private_data)->private;
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 66ceab2..b5007b8 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -272,8 +272,9 @@ static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%s\n", obd_jobid_var);
}
-static ssize_t obd_proc_jobid_var_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
return -EINVAL;
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 3b7dfc3..f78a241 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1849,7 +1849,7 @@ int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult)
}
EXPORT_SYMBOL(lprocfs_seq_read_frac_helper);
-int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
+int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count,
__u64 *val)
{
return lprocfs_write_frac_u64_helper(buffer, count, val, 1);
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index 9f719bc..8e22e45 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -53,8 +53,9 @@ static int osc_active_seq_show(struct seq_file *m, void *v)
return rc;
}
-static ssize_t osc_active_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_active_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -88,7 +89,8 @@ static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
}
static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
- const char *buffer, size_t count, loff_t *off)
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &dev->u.cli;
@@ -130,8 +132,9 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
return lprocfs_seq_read_frac_helper(m, val, mult);
}
-static ssize_t osc_max_dirty_mb_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &dev->u.cli;
@@ -233,8 +236,9 @@ static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
return rc;
}
-static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &obd->u.cli;
@@ -290,7 +294,8 @@ static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
}
static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
- const char *buffer, size_t count, loff_t *off)
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -322,8 +327,9 @@ static int osc_checksum_seq_show(struct seq_file *m, void *v)
obd->u.cli.cl_checksum ? 1 : 0);
}
-static ssize_t osc_checksum_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_checksum_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -362,7 +368,8 @@ static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
return 0;
}
-static ssize_t osc_checksum_type_seq_write(struct file *file, const char *buffer,
+static ssize_t osc_checksum_type_seq_write(struct file *file,
+ const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
@@ -401,8 +408,9 @@ static int osc_resend_count_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
}
-static ssize_t osc_resend_count_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_resend_count_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int val, rc;
@@ -428,8 +436,9 @@ static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%u\n", od->od_contention_time);
}
-static ssize_t osc_contention_seconds_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_contention_seconds_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct osc_device *od = obd2osc_dev(obd);
@@ -447,8 +456,9 @@ static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
return seq_printf(m, "%u\n", od->od_lockless_truncate);
}
-static ssize_t osc_lockless_truncate_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+static ssize_t osc_lockless_truncate_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct osc_device *od = obd2osc_dev(obd);
@@ -472,7 +482,8 @@ static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
}
static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
- const char *buffer, size_t count, loff_t *off)
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &dev->u.cli;
@@ -664,8 +675,9 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
}
#undef pct
-static ssize_t osc_rpc_stats_seq_write(struct file *file, const char *buf,
- size_t len, loff_t *off)
+static ssize_t osc_rpc_stats_seq_write(struct file *file,
+ const char __user *buf,
+ size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
struct obd_device *dev = seq->private;
@@ -702,8 +714,9 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v)
return 0;
}
-static ssize_t osc_stats_seq_write(struct file *file, const char *buf,
- size_t len, loff_t *off)
+static ssize_t osc_stats_seq_write(struct file *file,
+ const char __user *buf,
+ size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
struct obd_device *dev = seq->private;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 4011e00..7b22afd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -284,8 +284,9 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n)
}
static ssize_t
-ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
int bufpages;
@@ -329,8 +330,9 @@ ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n)
}
static ssize_t
-ptlrpc_lprocfs_threads_min_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+ptlrpc_lprocfs_threads_min_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
int val;
@@ -381,8 +383,9 @@ ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n)
}
static ssize_t
-ptlrpc_lprocfs_threads_max_seq_write(struct file *file, const char *buffer,
- size_t count, loff_t *off)
+ptlrpc_lprocfs_threads_max_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
int val;
@@ -1025,7 +1028,7 @@ static int ptlrpc_lprocfs_hp_ratio_seq_show(struct seq_file *m, void *v)
}
static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file,
- const char *buffer,
+ const char __user *buffer,
size_t count,
loff_t *off)
{
@@ -1175,7 +1178,7 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
#define BUFLEN (UUID_MAX + 5)
-int lprocfs_wr_evict_client(struct file *file, const char *buffer,
+int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
@@ -1223,7 +1226,7 @@ EXPORT_SYMBOL(lprocfs_wr_evict_client);
#undef BUFLEN
-int lprocfs_wr_ping(struct file *file, const char *buffer,
+int lprocfs_wr_ping(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
@@ -1251,7 +1254,7 @@ EXPORT_SYMBOL(lprocfs_wr_ping);
* The connection UUID is a node's primary NID. For example,
* "echo connection=192.168.0.1@tcp0::instance > .../import".
*/
-int lprocfs_wr_import(struct file *file, const char *buffer,
+int lprocfs_wr_import(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
@@ -1329,7 +1332,7 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
}
EXPORT_SYMBOL(lprocfs_rd_pinger_recov);
-int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
+int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
--
2.1.1
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-05 8:03 [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros Tristan Lelong
@ 2014-12-05 8:28 ` Joe Perches
2014-12-05 8:37 ` Tristan Lelong
2014-12-05 21:27 ` Greg KH
1 sibling, 1 reply; 9+ messages in thread
From: Joe Perches @ 2014-12-05 8:28 UTC (permalink / raw)
To: Tristan Lelong
Cc: oleg.drokin, andreas.dilger, gregkh, askb23, john.hammond,
gdonald, anhlq2110, fabio.falzoi84, oort10, agimenez, rupran,
surya.seetharaman9, Julia.Lawall, a.terekhov, liang.zhen,
vthakkar1994, amk, srikrishanmalik, rd, bergwolf, dan.carpenter,
paul.gortmaker, tapaswenipathak, email, uja.ornl, brilliantov,
dmitry.eremin, HPDD-discuss, devel, linux-kernel
On Fri, 2014-12-05 at 00:03 -0800, Tristan Lelong wrote:
> This patch fix a sparse warning in lustre sources
>
> warning: incorrect type in argument 1 (different address spaces)
> expected void [noderef] <asn:1>*to
> got char *<noident>
[]
> diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
[]
> @@ -87,13 +87,21 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
> }
>
> static ssize_t
> -fld_proc_hash_seq_write(struct file *file, const char *buffer,
> - size_t count, loff_t *off)
> +fld_proc_hash_seq_write(struct file *file,
> + const char __user *buffer,
> + size_t count, loff_t *off)
> {
> struct lu_client_fld *fld;
> struct lu_fld_hash *hash = NULL;
> + char name[80];
> int i;
>
> + if (count > 80)
> + return -ENAMETOOLONG;
> +
> + if (copy_from_user(name, buffer, count) != 0)
> + return -EFAULT;
> +
> fld = ((struct seq_file *)file->private_data)->private;
> LASSERT(fld != NULL);
>
Why 80? Is there no #define for this length?
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-05 8:28 ` Joe Perches
@ 2014-12-05 8:37 ` Tristan Lelong
2014-12-05 8:44 ` Joe Perches
0 siblings, 1 reply; 9+ messages in thread
From: Tristan Lelong @ 2014-12-05 8:37 UTC (permalink / raw)
To: Joe Perches
Cc: oleg.drokin, andreas.dilger, gregkh, askb23, john.hammond,
gdonald, anhlq2110, fabio.falzoi84, oort10, agimenez, rupran,
surya.seetharaman9, Julia.Lawall, a.terekhov, liang.zhen,
vthakkar1994, amk, srikrishanmalik, rd, bergwolf, dan.carpenter,
paul.gortmaker, tapaswenipathak, email, uja.ornl, brilliantov,
dmitry.eremin, HPDD-discuss, devel, linux-kernel
On Fri, Dec 05, 2014 at 12:28:11AM -0800, Joe Perches wrote:
> On Fri, 2014-12-05 at 00:03 -0800, Tristan Lelong wrote:
> > This patch fix a sparse warning in lustre sources
> >
> > warning: incorrect type in argument 1 (different address spaces)
> > expected void [noderef] <asn:1>*to
> > got char *<noident>
> []
> > diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
> []
> > @@ -87,13 +87,21 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
> > }
> >
> > static ssize_t
> > -fld_proc_hash_seq_write(struct file *file, const char *buffer,
> > - size_t count, loff_t *off)
> > +fld_proc_hash_seq_write(struct file *file,
> > + const char __user *buffer,
> > + size_t count, loff_t *off)
> > {
> > struct lu_client_fld *fld;
> > struct lu_fld_hash *hash = NULL;
> > + char name[80];
> > int i;
> >
> > + if (count > 80)
> > + return -ENAMETOOLONG;
> > +
> > + if (copy_from_user(name, buffer, count) != 0)
> > + return -EFAULT;
> > +
> > fld = ((struct seq_file *)file->private_data)->private;
> > LASSERT(fld != NULL);
> >
>
> Why 80? Is there no #define for this length?
>
No, there is no define.
I thought about adding one, but several other files and structure members in the lustre sources are using this specific value, and it seemed like a modification to do in another patch.
Let me know if you feel I should do it in a patch serie.
Regards
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-05 8:37 ` Tristan Lelong
@ 2014-12-05 8:44 ` Joe Perches
2014-12-05 22:35 ` Tristan Lelong
0 siblings, 1 reply; 9+ messages in thread
From: Joe Perches @ 2014-12-05 8:44 UTC (permalink / raw)
To: Tristan Lelong
Cc: oleg.drokin, andreas.dilger, gregkh, askb23, john.hammond,
gdonald, anhlq2110, fabio.falzoi84, oort10, agimenez, rupran,
surya.seetharaman9, Julia.Lawall, a.terekhov, liang.zhen,
vthakkar1994, amk, srikrishanmalik, rd, bergwolf, dan.carpenter,
paul.gortmaker, tapaswenipathak, email, uja.ornl, brilliantov,
dmitry.eremin, HPDD-discuss, devel, linux-kernel
On Fri, 2014-12-05 at 00:37 -0800, Tristan Lelong wrote:
> On Fri, Dec 05, 2014 at 12:28:11AM -0800, Joe Perches wrote:
> > On Fri, 2014-12-05 at 00:03 -0800, Tristan Lelong wrote:
[]
> > > diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
[]
> > > + char name[80];
[]
> > Why 80? Is there no #define for this length?
> >
> No, there is no define.
>
> I thought about adding one, but several other files and structure
> members in the lustre sources are using this specific value, and it
> seemed like a modification to do in another patch.
>
> Let me know if you feel I should do it in a patch serie.
No worries if it's not a new number.
It'd be nice if you would submit a new
patch with a #define and a conversion
to use the #define one day.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-05 8:44 ` Joe Perches
@ 2014-12-05 22:35 ` Tristan Lelong
0 siblings, 0 replies; 9+ messages in thread
From: Tristan Lelong @ 2014-12-05 22:35 UTC (permalink / raw)
To: Joe Perches
Cc: oleg.drokin, andreas.dilger, gregkh, askb23, john.hammond,
gdonald, anhlq2110, fabio.falzoi84, oort10, agimenez, rupran,
surya.seetharaman9, Julia.Lawall, a.terekhov, liang.zhen,
vthakkar1994, amk, srikrishanmalik, rd, bergwolf, dan.carpenter,
paul.gortmaker, tapaswenipathak, email, uja.ornl, brilliantov,
dmitry.eremin, HPDD-discuss, devel, linux-kernel
On Fri, Dec 05, 2014 at 12:44:07AM -0800, Joe Perches wrote:
> On Fri, 2014-12-05 at 00:37 -0800, Tristan Lelong wrote:
> > On Fri, Dec 05, 2014 at 12:28:11AM -0800, Joe Perches wrote:
> > > On Fri, 2014-12-05 at 00:03 -0800, Tristan Lelong wrote:
> []
> > > > diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
> []
> > > > + char name[80];
> []
> > > Why 80? Is there no #define for this length?
> > >
> > No, there is no define.
> >
> > I thought about adding one, but several other files and structure
> > members in the lustre sources are using this specific value, and it
> > seemed like a modification to do in another patch.
> >
> > Let me know if you feel I should do it in a patch serie.
>
> No worries if it's not a new number.
>
> It'd be nice if you would submit a new
> patch with a #define and a conversion
> to use the #define one day.
>
>
No worries, I'll be happy to submit a patch to fix this soon.
Thanks
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-05 8:03 [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros Tristan Lelong
2014-12-05 8:28 ` Joe Perches
@ 2014-12-05 21:27 ` Greg KH
2014-12-05 22:41 ` Tristan Lelong
1 sibling, 1 reply; 9+ messages in thread
From: Greg KH @ 2014-12-05 21:27 UTC (permalink / raw)
To: Tristan Lelong
Cc: oleg.drokin, andreas.dilger, askb23, john.hammond, gdonald,
anhlq2110, fabio.falzoi84, oort10, agimenez, rupran,
surya.seetharaman9, Julia.Lawall, joe, a.terekhov, liang.zhen,
vthakkar1994, amk, srikrishanmalik, rd, bergwolf, dan.carpenter,
paul.gortmaker, tapaswenipathak, email, uja.ornl, brilliantov,
dmitry.eremin, HPDD-discuss, devel, linux-kernel
On Fri, Dec 05, 2014 at 12:03:47AM -0800, Tristan Lelong wrote:
> This patch fix a sparse warning in lustre sources
>
> warning: incorrect type in argument 1 (different address spaces)
> expected void [noderef] <asn:1>*to
> got char *<noident>
>
> This is done by adding the missing __user attribute on userland pointers inside
> the LPROC_SEQ_FOPS-like macros:
> - LPROC_SEQ_FOPS
> - LPROC_SEQ_FOPS_RW_TYPE
> - LPROC_SEQ_FOPS_WR_ONLY
> - LDLM_POOL_PROC_WRITER
>
> The patch also updates all the functions that are used by this macro:
> - lprocfs_wr_*
> - *_seq_write
>
> as well as some helpers used by the previously modified functions (otherwise
> fixing the sparse warning add some new ones):
> - lprocfs_write_frac_helper
> - lprocfs_write_helper
> - lprocfs_write_u64_helper
>
> The patch also fixes one __user pointer direct dereference by strncmp
> in function fld_proc_hash_seq_write by adding the proper copy_from_user.
>
> Signed-off-by: Tristan Lelong <tristan@lelong.xyz>
> ---
> drivers/staging/lustre/lustre/fld/lproc_fld.c | 14 ++++--
> .../staging/lustre/lustre/include/lprocfs_status.h | 44 +++++++++--------
> drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 5 +-
> drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 4 +-
> drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 7 +--
> drivers/staging/lustre/lustre/lov/lproc_lov.c | 20 +++++---
> drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 7 +--
> .../lustre/lustre/obdclass/linux/linux-module.c | 5 +-
> .../lustre/lustre/obdclass/lprocfs_status.c | 2 +-
> drivers/staging/lustre/lustre/osc/lproc_osc.c | 57 +++++++++++++---------
> .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 25 +++++-----
> 11 files changed, 114 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
> index 95e7de1..9f1db6c 100644
> --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
> +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
> @@ -87,13 +87,21 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
> }
>
> static ssize_t
> -fld_proc_hash_seq_write(struct file *file, const char *buffer,
> - size_t count, loff_t *off)
> +fld_proc_hash_seq_write(struct file *file,
> + const char __user *buffer,
> + size_t count, loff_t *off)
> {
> struct lu_client_fld *fld;
> struct lu_fld_hash *hash = NULL;
> + char name[80];
> int i;
>
> + if (count > 80)
> + return -ENAMETOOLONG;
> +
> + if (copy_from_user(name, buffer, count) != 0)
> + return -EFAULT;
How was this code ever working before?
And I know Joe asked, but how do you know that 80 is ok? And why on the
stack?
Shouldn't you just compare count to strlen(fld_hash[i].fh_name)? like you
do later on?
> +
> fld = ((struct seq_file *)file->private_data)->private;
> LASSERT(fld != NULL);
>
> @@ -101,7 +109,7 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer,
> if (count != strlen(fld_hash[i].fh_name))
> continue;
>
> - if (!strncmp(fld_hash[i].fh_name, buffer, count)) {
> + if (!strncmp(fld_hash[i].fh_name, name, count)) {
So right now the code is just accessing user memory directly?
Seriously? Ugh.
Anyway, I don't like large stack variables like this, can you make it
dynamic instead?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-05 21:27 ` Greg KH
@ 2014-12-05 22:41 ` Tristan Lelong
2014-12-06 17:05 ` Dilger, Andreas
0 siblings, 1 reply; 9+ messages in thread
From: Tristan Lelong @ 2014-12-05 22:41 UTC (permalink / raw)
To: Greg KH
Cc: oleg.drokin, andreas.dilger, askb23, john.hammond, gdonald,
anhlq2110, fabio.falzoi84, oort10, agimenez, rupran,
surya.seetharaman9, Julia.Lawall, joe, a.terekhov, liang.zhen,
vthakkar1994, amk, srikrishanmalik, rd, bergwolf, dan.carpenter,
paul.gortmaker, tapaswenipathak, email, uja.ornl, brilliantov,
dmitry.eremin, HPDD-discuss, devel, linux-kernel
On Fri, Dec 05, 2014 at 01:27:23PM -0800, Greg KH wrote:
> On Fri, Dec 05, 2014 at 12:03:47AM -0800, Tristan Lelong wrote:
> > static ssize_t
> > -fld_proc_hash_seq_write(struct file *file, const char *buffer,
> > - size_t count, loff_t *off)
> > +fld_proc_hash_seq_write(struct file *file,
> > + const char __user *buffer,
> > + size_t count, loff_t *off)
> > {
> > struct lu_client_fld *fld;
> > struct lu_fld_hash *hash = NULL;
> > + char name[80];
> > int i;
> >
> > + if (count > 80)
> > + return -ENAMETOOLONG;
> > +
> > + if (copy_from_user(name, buffer, count) != 0)
> > + return -EFAULT;
>
> How was this code ever working before?
I have no idea, and was actually surprised that this was there.
>
> And I know Joe asked, but how do you know that 80 is ok? And why on the
> stack?
80 is the sizeof(struct lu_fld_hash.fh_name) and there is no define for that.
A few other structure members are using this 80 value internally, and as I told
Joe, I will analyze if they are all related and submit a patch to use a define instead.
>
> Shouldn't you just compare count to strlen(fld_hash[i].fh_name)? like you
> do later on?
>
This is actually done in the for loop already. I first compare with the maximum size,
then the loop use the strlen of each entries in the table, and finally does the strncmp.
>
> Anyway, I don't like large stack variables like this, can you make it
> dynamic instead?
>
I can definitely do this with a kmalloc, I'll submit a v2 tonight.
Thanks
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-05 22:41 ` Tristan Lelong
@ 2014-12-06 17:05 ` Dilger, Andreas
2014-12-06 22:34 ` Tristan Lelong
0 siblings, 1 reply; 9+ messages in thread
From: Dilger, Andreas @ 2014-12-06 17:05 UTC (permalink / raw)
To: Tristan Lelong, Greg KH
Cc: Drokin, Oleg, askb23, Hammond, John, gdonald, anhlq2110,
fabio.falzoi84, oort10, agimenez, rupran, surya.seetharaman9,
Julia.Lawall, joe, a.terekhov, vthakkar1994, amk,
srikrishanmalik, rd, bergwolf, dan.carpenter, Gortmaker,
Paul (Wind River),
tapaswenipathak, email, uja.ornl, brilliantov, Eremin, Dmitry,
HPDD-discuss@lists.01.org, devel, linux-kernel
On 2014/12/05, 3:41 PM, "Tristan Lelong" <tristan@lelong.xyz> wrote:
>On Fri, Dec 05, 2014 at 01:27:23PM -0800, Greg KH wrote:
>> On Fri, Dec 05, 2014 at 12:03:47AM -0800, Tristan Lelong wrote:
>> > static ssize_t
>> > -fld_proc_hash_seq_write(struct file *file, const char *buffer,
>> > - size_t count, loff_t *off)
>> > +fld_proc_hash_seq_write(struct file *file,
>> > + const char __user *buffer,
>> > + size_t count, loff_t *off)
>> > {
>> > struct lu_client_fld *fld;
>> > struct lu_fld_hash *hash = NULL;
>> > + char name[80];
>> > int i;
>> >
>> > + if (count > 80)
>> > + return -ENAMETOOLONG;
>> > +
>> > + if (copy_from_user(name, buffer, count) != 0)
>> > + return -EFAULT;
>>
>> How was this code ever working before?
>
>I have no idea, and was actually surprised that this was there.
>
>>
>> And I know Joe asked, but how do you know that 80 is ok? And why on the
>> stack?
>
>80 is the sizeof(struct lu_fld_hash.fh_name) and there is no define for
>that. A few other structure members are using this 80 value internally,
>and as I told Joe, I will analyze if they are all related and submit a
>patch to use a define instead.
Sorry, but I don't see where you get 80 from? fh_name is declared as a
"const char *", and initialized in the declaration of fld_hash[]. I'd
thought to reply that sizeof(fh_name) would even be better than a #define,
but sizeof(const char *) doesn't actually make sense.
The longest declared fh_name is 4 characters, but I'm not sure of an easy
way to determine this at compile time. I guess one option is to change
the declaration of struct lu_fld_hash to use "const char fh_name[4];" and
then use sizeof(fh_name), but I don't know if that is better than just
declaring a small buffer (8 chars) for this usage. IMHO that is small
enough to fit on the stack, since it is at the top of a very short
callchain (userspace->sys_write->vfs_write->fld_proc_hash_seq_write())
that just saves the value so the chance of stack overflow is basically nil.
>>
>> Shouldn't you just compare count to strlen(fld_hash[i].fh_name)? like
>>you
>> do later on?
>>
>
>This is actually done in the for loop already. I first compare with the
>maximum size, then the loop use the strlen of each entries in the table,
>and finally does the strncmp.
>
>>
>> Anyway, I don't like large stack variables like this, can you make it
>> dynamic instead?
>>
>
>I can definitely do this with a kmalloc, I'll submit a v2 tonight.
>
>Thanks
>
Cheers, Andreas
--
Andreas Dilger
Lustre Software Architect
Intel High Performance Data Division
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros
2014-12-06 17:05 ` Dilger, Andreas
@ 2014-12-06 22:34 ` Tristan Lelong
0 siblings, 0 replies; 9+ messages in thread
From: Tristan Lelong @ 2014-12-06 22:34 UTC (permalink / raw)
To: Dilger, Andreas
Cc: Greg KH, Drokin, Oleg, askb23, Hammond, John, gdonald, anhlq2110,
fabio.falzoi84, oort10, agimenez, rupran, surya.seetharaman9,
Julia.Lawall, joe, a.terekhov, vthakkar1994, amk,
srikrishanmalik, rd, bergwolf, dan.carpenter, Gortmaker,
Paul (Wind River),
tapaswenipathak, email, uja.ornl, brilliantov, Eremin, Dmitry,
HPDD-discuss@lists.01.org, devel, linux-kernel
Andreas,
On Sat, Dec 06, 2014 at 05:05:14PM +0000, Dilger, Andreas wrote:
> On 2014/12/05, 3:41 PM, "Tristan Lelong" <tristan@lelong.xyz> wrote:
>
>
> Sorry, but I don't see where you get 80 from? fh_name is declared as a
> "const char *", and initialized in the declaration of fld_hash[]. I'd
> thought to reply that sizeof(fh_name) would even be better than a #define,
> but sizeof(const char *) doesn't actually make sense.
>
You are right, I got confused with the names trying to follow the declaration of the variable.
> The longest declared fh_name is 4 characters, but I'm not sure of an easy
> way to determine this at compile time. I guess one option is to change
> the declaration of struct lu_fld_hash to use "const char fh_name[4];" and
> then use sizeof(fh_name), but I don't know if that is better than just
> declaring a small buffer (8 chars) for this usage. IMHO that is small
> enough to fit on the stack, since it is at the top of a very short
> callchain (userspace->sys_write->vfs_write->fld_proc_hash_seq_write())
> that just saves the value so the chance of stack overflow is basically nil.
>
I can implement any of those 2 options. If somebody as a strong preference, let me know,
otherwise I'll follow Andreas idea and will redo the patch with a stack name variable of size 8.
>
> Cheers, Andreas
> --
> Andreas Dilger
>
> Lustre Software Architect
> Intel High Performance Data Division
>
>
Thanks for your comment and help.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-12-06 22:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-05 8:03 [PATCH] staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros Tristan Lelong
2014-12-05 8:28 ` Joe Perches
2014-12-05 8:37 ` Tristan Lelong
2014-12-05 8:44 ` Joe Perches
2014-12-05 22:35 ` Tristan Lelong
2014-12-05 21:27 ` Greg KH
2014-12-05 22:41 ` Tristan Lelong
2014-12-06 17:05 ` Dilger, Andreas
2014-12-06 22:34 ` Tristan Lelong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome