Merge branch 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm...
[platform/kernel/linux-starfive.git] / fs / proc / base.c
index 30c9fce..b1d94d1 100644 (file)
@@ -1581,6 +1581,7 @@ static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
        noffsets = 0;
        for (pos = kbuf; pos; pos = next_line) {
                struct proc_timens_offset *off = &offsets[noffsets];
+               char clock[10];
                int err;
 
                /* Find the end of line and ensure we don't look past it */
@@ -1592,10 +1593,21 @@ static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
                                next_line = NULL;
                }
 
-               err = sscanf(pos, "%u %lld %lu", &off->clockid,
+               err = sscanf(pos, "%9s %lld %lu", clock,
                                &off->val.tv_sec, &off->val.tv_nsec);
                if (err != 3 || off->val.tv_nsec >= NSEC_PER_SEC)
                        goto out;
+
+               clock[sizeof(clock) - 1] = 0;
+               if (strcmp(clock, "monotonic") == 0 ||
+                   strcmp(clock, __stringify(CLOCK_MONOTONIC)) == 0)
+                       off->clockid = CLOCK_MONOTONIC;
+               else if (strcmp(clock, "boottime") == 0 ||
+                        strcmp(clock, __stringify(CLOCK_BOOTTIME)) == 0)
+                       off->clockid = CLOCK_BOOTTIME;
+               else
+                       goto out;
+
                noffsets++;
                if (noffsets == ARRAY_SIZE(offsets)) {
                        if (next_line)