lkml.org 
[lkml]   [2022]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v5 26/44] kmsan: disable strscpy() optimization under KMSAN
    From
    Disable the efficient 8-byte reading under KMSAN to avoid false positives.

    Signed-off-by: Alexander Potapenko <glider@google.com>

    ---

    Link: https://linux-review.googlesource.com/id/Iffd8336965e88fce915db2e6a9d6524422975f69
    ---
    lib/string.c | 8 ++++++++
    1 file changed, 8 insertions(+)

    diff --git a/lib/string.c b/lib/string.c
    index 6f334420f6871..3371d26a0e390 100644
    --- a/lib/string.c
    +++ b/lib/string.c
    @@ -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;

    --
    2.37.2.672.g94769d06f0-goog
    \
     
     \ /
      Last update: 2022-08-26 17:14    [W:4.090 / U:0.284 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site