• M
    gpiolib: Fix possible use after free on label · 3555de57
    Muchun Song 提交于
    [ Upstream commit 18534df419041e6c1f4b41af56ee7d41f757815c ]
    
    gpiod_request_commit() copies the pointer to the label passed as
    an argument only to be used later. But there's a chance the caller
    could immediately free the passed string(e.g., local variable).
    This could trigger a use after free when we use gpio label(e.g.,
    gpiochip_unlock_as_irq(), gpiochip_is_requested()).
    
    To be on the safe side: duplicate the string with kstrdup_const()
    so that if an unaware user passes an address to a stack-allocated
    buffer, we won't get the arbitrary label.
    
    Also fix gpiod_set_consumer_name().
    Signed-off-by: NMuchun Song <smuchun@gmail.com>
    Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    3555de57
consumer.h 15.1 KB