In the Linux kernel, the following vulnerability has been resolved:
drm/mediatek: Init ddp_comp
with devm_kcalloc()
In the case where conn_routes
is true we allocate an extra slot in
the ddp_comp
array but mtk_drm_crtc_create() never seemed to
initialize it in the test case I ran. For me, this caused a later
crash when we looped through the array in mtk_drm_crtc_mode_valid().
This showed up for me when I booted with slub_debug=FZPUA
which
poisons the memory initially. Without slub_debug
I couldn’t
reproduce, presumably because the later code handles the value being
NULL and in most cases (not guaranteed in all cases) the memory the
allocator returned started out as 0.
It really doesn’t hurt to initialize the array with devm_kcalloc()
since the array is small and the overhead of initting a handful of
elements to 0 is small. In general initting memory to zero is a safer
practice and usually it’s suggested to only use the non-initting alloc
functions if you really need to.
Let’s switch the function to use an allocation function that zeros the
memory. For me, this avoids the crash.
[
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "01389b324c97",
"lessThan": "cf69d0af7db9",
"versionType": "git"
},
{
"status": "affected",
"version": "01389b324c97",
"lessThan": "9fe2cc3fa44f",
"versionType": "git"
},
{
"status": "affected",
"version": "01389b324c97",
"lessThan": "01a2c5123e27",
"versionType": "git"
}
],
"programFiles": [
"drivers/gpu/drm/mediatek/mtk_drm_crtc.c"
],
"defaultStatus": "unaffected"
},
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "6.7"
},
{
"status": "unaffected",
"version": "0",
"lessThan": "6.7",
"versionType": "custom"
},
{
"status": "unaffected",
"version": "6.8.12",
"versionType": "custom",
"lessThanOrEqual": "6.8.*"
},
{
"status": "unaffected",
"version": "6.9.3",
"versionType": "custom",
"lessThanOrEqual": "6.9.*"
},
{
"status": "unaffected",
"version": "6.10",
"versionType": "original_commit_for_fix",
"lessThanOrEqual": "*"
}
],
"programFiles": [
"drivers/gpu/drm/mediatek/mtk_drm_crtc.c"
],
"defaultStatus": "affected"
}
]