Whamcloud - gitweb
LU-12165 quota: fix to use correct fsname array size 08/34608/2
authorWang Shilong <wshilong@ddn.com>
Sat, 6 Apr 2019 13:23:23 +0000 (21:23 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 13 Apr 2019 04:49:22 +0000 (04:49 +0000)
Max fsname is allowed to be LUSTRE_MAXFSNAME, plus '\0',
we expected arrary size should be LUSTRE_MAXFSNAME + 1.

Otherwise, we will hit following crash easily.

[864870.292204] [<ffffffff9230e84e>] dump_stack+0x19/0x1b
[864870.293186] [<ffffffff92308b50>] panic+0xe8/0x21f
[864870.294104] [<ffffffffc0f3f805>] ? qsd_enabled_seq_write+0x205/0x210 [lquota]
[864870.295418] [<ffffffff91c91b8b>] __stack_chk_fail+0x1b/0x20
[864870.296437] [<ffffffffc0f3f805>] qsd_enabled_seq_write+0x205/0x210 [lquota]
[864870.297760] [<ffffffff91e1e418>] ? __sb_start_write+0x58/0x110
[864870.298894] [<ffffffff91e91050>] proc_reg_write+0x40/0x80
[864870.299883] [<ffffffff91e1b490>] vfs_write+0xc0/0x1f0
[864870.300765] [<ffffffff91e1c2bf>] SyS_write+0x7f/0xf0
[864870.301711] [<ffffffff92320795>] system_call_fastpath+0x1c/0x21

Test-parameters: trivial
Change-Id: I33dd331a83ddac0e0c36a82480e7e90ad0ed2c2a
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/34608
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
lustre/quota/qsd_lib.c

index 294538b..6aaed49 100644 (file)
@@ -155,7 +155,7 @@ static ssize_t qsd_enabled_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct qsd_instance *qsd = m->private;
-       char fsname[LUSTRE_MAXFSNAME];
+       char fsname[LUSTRE_MAXFSNAME + 1];
        int enabled = 0;
        char valstr[5];
        int pool, rc;