diff options
author | Ricardo M. Correia <[email protected]> | 2009-03-12 21:23:34 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2009-03-12 15:47:50 -0700 |
commit | a0b5ae8acaaf63fa2378a6d062e66fdf99387625 (patch) | |
tree | 998eb5f4711122c5d67d07547ec45181e7beae53 /module/spl | |
parent | 6c33eb816268ef3fef9bb8ca9079bb46aad26605 (diff) |
Fix off-by-1 truncation of hw_serial when converting from integer to string, when writing to /proc/sys/kernel/spl/spl_hostid.
Fixes hostid mismatch which leads to assertion failure when the hostid/hw_serial is a 10-character decimal number:
$ zpool status
pool: lustre
state: ONLINE
lt-zpool: zpool_main.c:3176: status_callback: Assertion `reason == ZPOOL_STATUS_OK' failed.
zsh: 5262 abort zpool status
Diffstat (limited to 'module/spl')
-rw-r--r-- | module/spl/spl-proc.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c index d0ce23194..294948d81 100644 --- a/module/spl/spl-proc.c +++ b/module/spl/spl-proc.c @@ -457,23 +457,24 @@ proc_dohostid(struct ctl_table *table, int write, struct file *filp, int len, rc = 0; int32_t val; char *end, str[32]; - ENTRY; + ENTRY; if (write) { - /* We can't use proc_doulongvec_minmax() in the write - * case hear because hostid while a hex value has no - * leading 0x which confuses the helper function. */ + /* We can't use proc_doulongvec_minmax() in the write + * case hear because hostid while a hex value has no + * leading 0x which confuses the helper function. */ rc = proc_copyin_string(str, sizeof(str), buffer, *lenp); if (rc < 0) RETURN(rc); val = simple_strtol(str, &end, 16); - if (str == end) - RETURN(-EINVAL); + if (str == end) + RETURN(-EINVAL); - spl_hostid = (long)val; - (void)snprintf(hw_serial, HW_HOSTID_LEN-1, "%u", - (val >= 0) ? val : -val); + spl_hostid = (long) val; + (void) snprintf(hw_serial, HW_HOSTID_LEN, "%u", + (val >= 0) ? val : -val); + hw_serial[HW_HOSTID_LEN - 1] = '\0'; *ppos += *lenp; } else { len = snprintf(str, sizeof(str), "%lx", spl_hostid); |