• Beau Belgrave's avatar
    tracing/user_events: Fix non-spaced field matching · bd125a08
    Beau Belgrave authored
    When the ABI was updated to prevent same name w/different args, it
    missed an important corner case when fields don't end with a space.
    Typically, space is used for fields to help separate them, like
    "u8 field1; u8 field2". If no spaces are used, like
    "u8 field1;u8 field2", then the parsing works for the first time.
    However, the match check fails on a subsequent register, leading to
    confusion.
    
    This is because the match check uses argv_split() and assumes that all
    fields will be split upon the space. When spaces are used, we get back
    { "u8", "field1;" }, without spaces we get back { "u8", "field1;u8" }.
    This causes a mismatch, and the user program gets back -EADDRINUSE.
    
    Add a method to detect this case before calling argv_split(). If found
    force a space after the field separator character ';'. This ensures all
    cases work properly for matching.
    
    With this fix, the following are all treated as matching:
    u8 field1;u8 field2
    u8 field1; u8 field2
    u8 field1;\tu8 field2
    u8 field1;\nu8 field2
    
    Link: https://lore.kernel.org/linux-trace-kernel/20240423162338.292-2-beaub@linux.microsoft.com
    
    Fixes: ba470eeb ("tracing/user_events: Prevent same name but different args event")
    Signed-off-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
    Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
    bd125a08
trace_events_user.c 67.1 KB