Whamcloud - gitweb
LU-13039 quota: Ensure local buffer is null terminated 99/36899/3
authorShaun Tancheff <stancheff@cray.com>
Sat, 30 Nov 2019 18:14:56 +0000 (12:14 -0600)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Jan 2020 04:04:42 +0000 (04:04 +0000)
Found via KASAN, copy_from_user may not set null
terminator.

Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Change-Id: I20de911c2b2d50a1715a27e3edfe65442eaa2be6
Reviewed-on: https://review.whamcloud.com/36899
Reviewed-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-by: Sergey Cheremencev <c17829@cray.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/quota/qsd_lib.c

index da1c7c8..c535f90 100644 (file)
@@ -168,6 +168,7 @@ static ssize_t qsd_enabled_seq_write(struct file *file,
        if (copy_from_user(valstr, buffer, count))
                GOTO(out, count = -EFAULT);
 
        if (copy_from_user(valstr, buffer, count))
                GOTO(out, count = -EFAULT);
 
+       valstr[sizeof(valstr) - 1] = 0;
        if (strchr(valstr, 'u'))
                enabled |= BIT(USRQUOTA);
        if (strchr(valstr, 'g'))
        if (strchr(valstr, 'u'))
                enabled |= BIT(USRQUOTA);
        if (strchr(valstr, 'g'))