-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heap corruption with format conversion #715
Comments
@eero-t thanks report. will check it. |
fixes intel#715 the swizzleSurface function will call GmmLib::GmmResourceInfoCommon::CpuBlt and CpuSwizzleBlt, in this function _mm_storeu_si128 will write some invalid memory it is not rootcause, jus a finding. should not merged until real rootcause is found Signed-off-by: XinfengZhang <[email protected]>
Why, were you unable to reproduce the issue? (As can be seen from the backtrace, it's some kind of issue in SIMD optimized CpuBlt() implementation, either off-by-one, or invalid handling of the unaligned part of the blit. #732 seems to replace that with pixel-by-pixel variant, so it shouldn't have the issue that's in the optimized routine.) |
What's the status of this bug? The indicated use-case doesn't crash anymore after #757 fix, but I'm still seeing larger number of Valgrind warnings (although libdrm/gmmlib/media-driver were compiled with valgrind headers present). |
@eero-t , almost all of the violation is because of gpu memory allocation, when we map the buffer, valgrind could not get the real size of the buffer. |
Of course it can. You just add Valgrind annotation define for it, like e.g. libdrm does: Besides annotating allocations, you obviously need to annotate also frees, and tell Valgrind something about the memory area types, like is done in the linked libdrm example. If driver uses those mappings as a memory pool instead of direct allocations, Valgrind has annotation support for that too, to make memory access checks more accurate with them: https://valgrind.org/docs/manual/mc-manual.html#mc-manual.mempools |
@eero-t , thanks, to add these annotation, we should include valgrind header file and detect valgrind installation. right? |
Adding valgrind headers to the system before build is a user responsibility (on Debian derived distros, this would mean doing just "sudo apt install valgrind-dev"). Media driver needs to:
Examples for all of these can be found from libdrm. As I mentioned in #784 (which I think should be re-opened until it's actually fixed), driver already has some annotations, but either:
[1] Valgrind already catches syscalls like mmap() and other libraries (like libc & libdrm) already annotate their alloc functions, but Valgrind doesn't know about results of direct i915 ioctls done by media driver (or gmmlib?) until they're properly annotated. |
With drm-tip kernel and media stack built from git commit from few days ago, format conversion crashes.
Setup:
Use-case:
ffmpeg -y -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i 1280x720p_29.97_10mb_h264_cabac.264 -vf 'hwdownload,format=uyvy422' -c:v rawvideo -f rawvideo /dev/null
Crashes to:
Depending on input video, libc doesn't always catch the heap corruption like above, and FFmpeg segfaults instead.
Valgrind shows huge number of invalid memory accesses ending with heap corruption in media driver / libgmm:
The text was updated successfully, but these errors were encountered: