On 28/09/2015 11:01, sginsberg(a)svn.reactos.org wrote:
> Author: sginsberg
> Date: Mon Sep 28 09:01:11 2015
> New Revision: 69393
>
> URL: http://svn.reactos.org/svn/reactos?rev=69393&view=rev
> Log:
> [NTOS] Fix the Ob wait system calls to only catch the exceptions that are expected to be raised by the Ke wait functions (and not potentially silently catching *any* exception and corrupting everything in the process). Also fixup some code logic. SEH Mega Fixup 1/???
>
> Modified:
> trunk/reactos/ntoskrnl/ob/obwait.c
>
> Modified: trunk/reactos/ntoskrnl/ob/obwait.c
> URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obwait.c?rev=6…
> ==============================================================================
> --- trunk/reactos/ntoskrnl/ob/obwait.c [iso-8859-1] (original)
> +++ trunk/reactos/ntoskrnl/ob/obwait.c [iso-8859-1] Mon Sep 28 09:01:11 2015
> @@ -49,12 +49,12 @@
> IN BOOLEAN Alertable,
> IN PLARGE_INTEGER TimeOut OPTIONAL)
> {
> - PKWAIT_BLOCK WaitBlockArray = NULL;
> + PKWAIT_BLOCK WaitBlockArray;
> HANDLE Handles[MAXIMUM_WAIT_OBJECTS], KernelHandle;
> PVOID Objects[MAXIMUM_WAIT_OBJECTS];
> PVOID WaitObjects[MAXIMUM_WAIT_OBJECTS];
> - ULONG i = 0, ReferencedObjects = 0, j;
> - KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
> + ULONG i, ReferencedObjects, j;
> + KPROCESSOR_MODE PreviousMode;
> LARGE_INTEGER SafeTimeOut;
> BOOLEAN LockInUse;
> PHANDLE_TABLE_ENTRY HandleEntry;
> @@ -65,31 +65,26 @@
> NTSTATUS Status;
> PAGED_CODE();
>
> - /* Enter a critical region since we'll play with handles */
> - LockInUse = TRUE;
> - KeEnterCriticalRegion();
> -
> /* Check for valid Object Count */
> if ((ObjectCount > MAXIMUM_WAIT_OBJECTS) || !(ObjectCount))
> {
> /* Fail */
> - Status = STATUS_INVALID_PARAMETER_1;
> - goto Quickie;
> + return STATUS_INVALID_PARAMETER_1;
> }
>
> /* Check for valid Wait Type */
> if ((WaitType != WaitAll) && (WaitType != WaitAny))
> {
> /* Fail */
> - Status = STATUS_INVALID_PARAMETER_3;
> - goto Quickie;
> - }
> -
> - /* Enter SEH */
> - _SEH2_TRY
> - {
> - /* Check if the call came from user mode */
> - if (PreviousMode != KernelMode)
> + return STATUS_INVALID_PARAMETER_3;
> + }
> +
> + /* Enter SEH for user mode */
> + PreviousMode = ExGetPreviousMode();
> + if (PreviousMode != KernelMode)
> + {
> + /* Enter SEH */
> + _SEH2_TRY
No, this is plain wrong.
This is not because you're in kernel mode that the world is marvelous
and callers trustable.
A caller can pass you buggy address and you HAVE to wrap the
RtlCopyMemory in SEH to make sure that if a buggy address is passed, the
whole system isn't brought down (that's the whole purpose of the copy
after all!).
In case you have a doubt, just put some random:
Status = ZwWaitForMultipleObjects(2, (void **)0x42424242, WaitAll,
FALSE, NULL);
In a kernel component. In w2k3, you'll get Status = STATUS_ACCESS_VIOLATION
In ReactOS, with your changes: BSOD.
Please before doing random changes that you believe are right: do testing.
Alex already told you that.
Cheers,
--
Pierre Schweitzer <pierre at reactos.org>
System & Network Administrator
Senior Kernel Developer
ReactOS Deutschland e.V.
Hello,
Let me invite you to the monthly status meeting taking place last
Thursday of a month, 24th of September, 19:00 UTC, as usual.
IRC service will only be started shortly before the meeting. Your
participation passwords and server address will be emailed to you
shortly before the meeting starts, and they are going to be different
once again as they are not stored in any database. Hopefully it's not
much of inconvenience.
Please send agenda proposals to me before the meeting.
Regards,
Aleksey Bragin
ion(a)svn.reactos.org wrote:
> - Add correct MS-PL (Public) License. Not added to build/used, but I
> need some of the headers/data structures in here.
> - Source:
https://github.com/Microsoft/Windows-driver-samples/blob/master/filesys/cdfs
Yay! No more messing around with DDK licenses!
Someone should take the other samples there and replace our DDK-inspired
components (e.g. classpnp and disk) by these ones licensed under MS-PL.
Cheers,
Colin
hbelusca(a)svn.reactos.org wrote:
> +// FIXME! FIXME! Do it in a portable way!!
> typedef unsigned char BYTE;
> typedef unsigned short WORD;
> typedef unsigned long DWORD;
Try using our include/host/typedefs.h, which provides the most popular
Windows type definitions in a portable way.
- Colin
cwittich(a)svn.reactos.org wrote:
> Modified: trunk/reactos/base/applications/cmdutils/mode/mode.c
What is that tool for anyway?
Windows has a 16-bit "mode.com" for compatibility and I believe the
actual "mode" command is built-in into cmd.exe these days.
Cheers,
Colin