History

kmsan: disable strscpy() optimization under KMSAN

Disable the efficient 8-byte reading under KMSAN to avoid false positives.

Alexander Potapenko committed 4 years ago

Commit 2de6f3b1 parent 8ed691b1 file · +8 −0Browse files

Showing the changes to lib/string.c (1 of 1 file). Show all

Unified · Split

lib/string.c+8−0
@@ -197,6 +197,14 @@ ssize_t strscpy(char *dest, const char *src, size_t count) · 196 unmodified lines
197 max = 0;197 max = 0;
198#endif198#endif
199 199
200 /*
201 * read_word_at_a_time() below may read uninitialized bytes after the
202 * trailing zero and use them in comparisons. Disable this optimization
203 * under KMSAN to prevent false positive reports.
204 */
205 if (IS_ENABLED(CONFIG_KMSAN))
206 max = 0;
207
200 while (max >= sizeof(unsigned long)) {208 while (max >= sizeof(unsigned long)) {
201 unsigned long c, data;209 unsigned long c, data;
202 210