In the Linux kernel, the following vulnerability has been resolved:
staging: media: atomisp: Fix stack buffer overflow in gmingetvar_int()
When gmingetconfigvar() calls efi.getvariable() and the EFI variable is larger than the expected buffer size, two behaviors combine to create a stack buffer overflow:
gmingetconfigvar() does not return the proper error code when efi.getvariable() fails. It returns the stale 'ret' value from earlier operations instead of indicating the EFI failure.
When efi.getvariable() returns EFIBUFFERTOOSMALL, it updates *outlen to the required buffer size but writes no data to the output buffer. However, due to bug #1, gmingetvarint() believes the call succeeded.
The caller gmingetvarint() then performs: - Allocates val[CFGVARNAMEMAX + 1] (65 bytes) on stack - Calls gmingetconfigvar(dev, isgmin, var, val, &len) with len=64 - If EFI variable is >64 bytes, efi.getvariable() sets len=requiredsize - Due to bug #1, thinks call succeeded with len=required_size - Executes val[len] = 0, writing past end of 65-byte stack buffer
This creates a stack buffer overflow when EFI variables are larger than 64 bytes. Since EFI variables can be controlled by firmware or system configuration, this could potentially be exploited for code execution.
Fix the bug by returning proper error codes from gmingetconfig_var() based on EFI status instead of stale 'ret' value.
The gmingetvar_int() function is called during device initialization for camera sensor configuration on Intel Bay Trail and Cherry Trail platforms using the atomisp camera stack.