commit d7c715292147f2403ef60b04759e19c674ffe366
Author: Vincent Chuang <Vincent.Chuang@mediatek.com>
Date:   Fri Apr 21 15:45:38 2023 +0800

    core: thread: Add support for canary value randomization [1/1]

    PD#RSP-6589

    Currently hardcoded magic number is used as thread stack canary,
    an attacker with full control over the overflow can embed the
    hardcoded canary value on the right location to bypass the overflow
    detection.

    To add extra layer of security, redefine the canary value as variable,
    such that the canary can be initialized during runtime.

    The canaries are initialized with static values from thread_init_canaries()
    during the early boot stage. The plat_get_random_stack_canaries() is
    refactored to support arbitrary-length random numbers, and a new function
    called thread_update_canaries() is created to fetch the random values and
    update the thread canaries. For CFG_NS_VIRTUALIZATION=y, the updated
    function is disabled.

    Change-Id: I806740c3908215e5c5d2bb9505143433e348fd5b
    Signed-off-by: Vincent Chuang <Vincent.Chuang@mediatek.com>
    Signed-off-by: Randy Hsu <Randy-CY.Hsu@mediatek.com>
    Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
    Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

Change-Id: Icf4d43b5f6f70287ef7f89325ac3bf8a35cf7165
36 files changed