mm/memory.c: fix race when faulting a device private page
[linux-2.6-block.git] / lib / string.c
index 6f334420f68718f3d25bf470f0feb0842229b38b..3371d26a0e390cd6c3650be0d59b2e78d0b452b3 100644 (file)
@@ -197,6 +197,14 @@ ssize_t strscpy(char *dest, const char *src, size_t count)
                max = 0;
 #endif
 
+       /*
+        * read_word_at_a_time() below may read uninitialized bytes after the
+        * trailing zero and use them in comparisons. Disable this optimization
+        * under KMSAN to prevent false positive reports.
+        */
+       if (IS_ENABLED(CONFIG_KMSAN))
+               max = 0;
+
        while (max >= sizeof(unsigned long)) {
                unsigned long c, data;