• A
    net: ipa: memory region array is variable size · bcacae2f
    Alex Elder 提交于
    stable inclusion
    from stable-5.10.42
    commit ee67cbc13fc5c512b9211314466e814f071884e2
    bugzilla: 55093
    CVE: NA
    
    --------------------------------
    
    [ Upstream commit 440c3247 ]
    
    IPA configuration data includes an array of memory region
    descriptors.  That was a fixed-size array at one time, but
    at some point we started defining it such that it was only
    as big as required for a given platform.  The actual number
    of entries in the array is recorded in the configuration data
    along with the array.
    
    A loop in ipa_mem_config() still assumes the array has entries
    for all defined memory region IDs.  As a result, this loop can
    go past the end of the actual array and attempt to write
    "canary" values based on nonsensical data.
    
    Fix this, by stashing the number of entries in the array, and
    using that rather than IPA_MEM_COUNT in the initialization loop
    found in ipa_mem_config().
    
    The only remaining use of IPA_MEM_COUNT is in a validation check
    to ensure configuration data doesn't have too many entries.
    That's fine for now.
    
    Fixes: 3128aae8 ("net: ipa: redefine struct ipa_mem_data")
    Signed-off-by: NAlex Elder <elder@linaro.org>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NChen Jun <chenjun102@huawei.com>
    Acked-by: NWeilong Chen <chenweilong@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    bcacae2f
ipa_mem.c 13.7 KB