Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] ntdll: Zero-initialize the syscall_frame used for starting threads on ARM/ARM64
@ 2022-03-04 16:15 Martin Storsjö
  2022-03-04 16:17 ` Martin Storsjö
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Storsjö @ 2022-03-04 16:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Martin Storsjö

This fixes an inconsistency since
fed7e7a78b4bea183d0cbb107953e275f17baa4f (ntdll: Simulate a syscall
return when starting a thread); in that commit, on i386 and
x86_64, the syscall_frame used for starting the thread was
zeroed with a memset, while it wasn't on arm and arm64.

This had a noticable effect on float maths, where the
uninitialized frame->restore_flags field could have the
CONTEXT_FLOATING_POINT bit set. (call_init_thunk only ORs in
CONTEXT_INTEGER into the restore_flags field, on all architectures).
If that bit was set, it would restore uninitialized data into the
fpscr register, possibly setting the FPU in a nondefault rounding
mode.

Signed-off-by: Martin Storsjö <martin@martin.st>
---
 dlls/ntdll/unix/signal_arm.c   | 1 +
 dlls/ntdll/unix/signal_arm64.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c
index a1bcb0ddd32..1fea76f6563 100644
--- a/dlls/ntdll/unix/signal_arm.c
+++ b/dlls/ntdll/unix/signal_arm.c
@@ -1105,6 +1105,7 @@ void DECLSPEC_HIDDEN call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, B
     ctx = (CONTEXT *)((ULONG_PTR)context.Sp & ~15) - 1;
     *ctx = context;
     ctx->ContextFlags = CONTEXT_FULL;
+    memset( frame, 0, sizeof(*frame) );
     NtSetContextThread( GetCurrentThread(), ctx );
 
     frame->sp = (DWORD)ctx;
diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c
index 94f280e218a..1df97f16f13 100644
--- a/dlls/ntdll/unix/signal_arm64.c
+++ b/dlls/ntdll/unix/signal_arm64.c
@@ -1202,6 +1202,7 @@ void DECLSPEC_HIDDEN call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, B
     ctx = (CONTEXT *)((ULONG_PTR)context.Sp & ~15) - 1;
     *ctx = context;
     ctx->ContextFlags = CONTEXT_FULL;
+    memset( frame, 0, sizeof(*frame) );
     NtSetContextThread( GetCurrentThread(), ctx );
 
     frame->sp    = (ULONG64)ctx;
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH] ntdll: Zero-initialize the syscall_frame used for starting threads on ARM/ARM64
  2022-03-04 16:15 [FFmpeg-devel] [PATCH] ntdll: Zero-initialize the syscall_frame used for starting threads on ARM/ARM64 Martin Storsjö
@ 2022-03-04 16:17 ` Martin Storsjö
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Storsjö @ 2022-03-04 16:17 UTC (permalink / raw)
  To: ffmpeg-devel

On Fri, 4 Mar 2022, Martin Storsjö wrote:

Sorry, I sent this to the entirely wrong mailing list...

// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-04 16:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 16:15 [FFmpeg-devel] [PATCH] ntdll: Zero-initialize the syscall_frame used for starting threads on ARM/ARM64 Martin Storsjö
2022-03-04 16:17 ` Martin Storsjö

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git