Commit graph

32 commits

Author SHA1 Message Date
Jérôme Gardou 2ae9feb59f [NTOS] Properly implement and use FsRtlAcquireFileForModWriteEx 2022-11-02 19:41:04 +01:00
George Bișoc abe89d7cde
[NTOS:FSRTL] Assign the buffer length to ThisBufferLength field
This fixes an issue where ReactOS would assert on QuotaUsage == 0 as the process was still taking up quotas during a quota block de-reference with root cause of ThisBufferLength member field being 0 which made process quota charging/returning flow unbalanced.
In addition to that, on FsRtlCancelNotify routine API all we must ensure that if PsChargePoolQuota or ExAllocatePoolWithTag function fails we have to handle the raised exceptions accordingly and return the charged quota back (if we actually charged quotas that is). With said, wrap that part of code with SEH.

=== DOCUMENTATION REMARKS ===
The cause of the assert is due to the fact ThisBufferLength was being handled wrongly ever since, until this commit. When FsRtl of the Executive has to filter reported changes (with logic algorithm implemented in FsRtlNotifyFilterReportChange function), the said function will charge the quota of a given process
with an amount that is represented as the buffer length whose size is expressed in bytes. This length buffer is preserved in a local variable called NumberOfBytes, which is initialized from BufferLength member field of notification structure or from the length from stack parameters pointed from an IRP.

As it currently stands, the code is implemented in such a way that FsRtlNotifyFilterReportChange will charge quotas to a process but it doesn't assign the buffer length to ThisBufferLength. On the first glimpse ThisBufferLength and BufferLength are very similar members that serve exact same purpose but in reality there's a subtle distinction between the two.

BufferLength is a member whose length size is given by FSDs (filesystem drivers) during a notification dispatching. Whenever FsRtl receives the notification structure packed with data from the filesystem, the length pointed by BufferLength gets passed to ThisBufferLength and from now on the kernel has to use this member for the whole time of its task to accomplish
whatever request it's been given by the filesystem. In other words, BufferLength is strictly used only to pass length size data to the kernel by initializing ThisBufferLength based on that length and unequivocally the kernel uses this member field. What we're doing is that ThisBufferLength never receives the length from BufferLength therefore whenever FsRtl component
has to return quotas back it'll return an amount of 0 (which means no amount to return) and that's a bug in the kernel.
2022-01-11 10:11:08 +01:00
George Bișoc 3bc2d590a1
[NTOSKRNL] Regroup the pool allocation tags in one dedicated place
We have a special file, tag.h, which serves as a place to store whatever kernel pool allocation tag yet we still have some tags sparse over the kernel code... So just re-group them in one unique place.
2021-12-27 18:57:03 +01:00
Jérôme Gardou 46af941c4c [NTOS:FSRTL] Check return status of FsRtl locking functions
CORE-17637
2021-06-28 10:20:57 +02:00
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
Jérôme Gardou bde2ee571a [NTOS:FSRTL] Properly leave FsRtl when returning STATUS_CANT_WAIT 2021-02-03 09:41:23 +01:00
Jérôme Gardou bd0445dbf2 [NTOS/FSRTL] Implement FsRtlAcquireToCreateMappedSection using filter callbacks 2020-12-22 11:37:53 +01:00
Jérôme Gardou 3d4cf8d2d8 [NTOS/FSRTL] Fix MCB tests
- Fix behaviour when adding or removing entries in the middle of an existing run
 - Do not touch output parameters when failing, caller might rely on this.
2020-12-08 11:48:00 +01:00
Jérôme Gardou 0db79d4aa9 [NTOSKRNL:FSRTL] Fix memory corruption when pruning tunnel cache 2020-12-04 16:08:14 +01:00
Victor Perevertkin 5c7ce4475e
[REACTOS] Cleanup INIT and some PAGE section allocations
- Change INIT_FUNCTION and INIT_SECTION to CODE_SEG("INIT") and DATA_SEG("INIT") respectively
- Remove INIT_FUNCTION from function prototypes
- Remove alloc_text pragma calls as they are not needed anymore
2020-11-02 21:45:31 +03:00
Hermès Bélusca-Maïto 3b2f158593
[NTOS][CLASS2][FFS][WIN32SS] Fix some pool tags so that they correctly appear in pool dump lists.
Reminder: in the code they are defined using reverse byte order
(Windows/ReactOS are little-endian OSes).
2019-11-01 19:12:27 +01:00
Bișoc George 42ce8519b6 [FASTFAT][FLTMGR][NTOS] Do not explicitly call ObfDereferenceObject() (#1636)
"Most code should not directly call the platform-specific ObfDereferenceObject() function but use the ObDereferenceObject() macro instead."

CORE-16081
2019-06-22 16:20:58 +02:00
Hervé Poussineau 4d1a8f8f54 [NTOS:FSRTL] Use _SEH2_AbnormalTermination() instead of _abnormal_termination()
We're already using SEH2 macros, so also use SEH2 functions
2019-04-07 19:28:18 +02:00
Bartosz Brachaczek d256ff6006
[NTOSKRNL] Do not try to access OldBackTracking[-1]
It can be triggered by the existing "F<", "FILE.TXT" case in the tests.

CORE-15902
2019-04-01 08:28:00 +02:00
Bartosz Brachaczek 695e00fbbd
[NTOSKRNL] Unify buffer size calculation in FsRtlIs{Name,Dbcs}InExpression
It better captures the intent now in FsRtlIsNameInExpressionPrivate and
fixes a slight overallotion by 4 bytes in FsRtlIsDbcsInExpression.

While at it, use the ANSI_DOS_DOT macro in the Dbcs version.

CORE-15902
2019-04-01 08:27:59 +02:00
Bartosz Brachaczek e9b438bfaa
[NTOSKRNL] Addendum to 21d2c70: properly start DOS_START loop
Fixes last failing test.

CORE-15902
2019-03-31 19:35:25 +02:00
Bartosz Brachaczek 8bc9935fcb
[NTOSKRNL] Properly copy backtracking buffer content on realloc
CORE-15902
2019-03-31 11:44:01 +02:00
Bartosz Brachaczek 21d2c70bb4
[NTOSKRNL] Properly compare position to name length in FsRtlIsNameInExpressionPrivate
CORE-15902
2019-03-31 11:44:00 +02:00
Bartosz Brachaczek 5d5e9c8486
[NTOSKRNL] Don't overflow backtrack stack buffer
CORE-15902
2019-03-31 11:44:00 +02:00
Bartosz Brachaczek b1ae592e7f
[NTOSKRNL] Don't oversize buffer for backtracking in FsRtlIsNameInExpressionPrivate
CORE-15902
2019-03-31 11:44:00 +02:00
Timo Kreuzer 71fefa32db
[NDK][NTOS] Add global definition of INIT_FUNCTION/INIT_SECTION (#779)
* Add an NDK header to define INIT_FUNCTION/INIT_SECTION globally
* Use _declspec(allocate(x)) and _declspec(code_seg(x)) on MSVC versions that support it
* Use INIT_FUNCTION on functions only and INIT_SECTION on data only (required by MSVC)
* Place INIT_FUNCTION before the return type (required by MSVC)
* Make sure declarations and implementations share the same modifiers (required by MSVC)
* Add a global linker option to suppress warnings about defined but unused INIT section
* Merge INIT section into .text in freeldr
2018-12-30 12:19:11 +01:00
Pierre Schweitzer 5c10b02957
[NTOSKRNL] Add the OLE flag where appropriate in FsRtlLegalAnsiCharacterArray
This brings in the ability to check NTFS streams names (OLE | NTFS).
This fixes failing tests from previous commit.
2018-08-25 14:26:49 +02:00
Pierre Schweitzer 65f9783808
[NTOSKRNL] Properly initialize the IO_STATUS_BLOCK 2018-08-17 19:13:13 +02:00
Pierre Schweitzer 7eca874824
[NTOSKRNL] Fix FsRtlStackOverflow work item free.
Oneliner of the day... This typo just prevented the
whole feature to work properly. Because any allocated
work item would miserably fail to be freed.

This will obviously help real world FSD relying on
StackOverflow worker from FsRtl to work better!

CORE-14611
2018-05-10 10:49:17 +02:00
Pierre Schweitzer 2abb99faa9
[NTOSKRNL] In FsRtlAddToTunnelCache() allocate memory from PagedPool when required.
Also, if allocating from lookaside list, reattempt a cold allocation.
2018-01-20 21:21:00 +01:00
Ivan Labutin 0d01b00871 [NTOS:FSRTL] Fixed incorrect comparison 2017-12-20 06:56:09 +01:00
Ivan Labutin d6792047f3 [NTOS][NDK][RTL] A bunch of 'wrong size' fixes 2017-12-20 06:56:09 +01:00
Pierre Schweitzer 2284a457a3
[NTOSKRNL] Fix MSVC build: don't attempt to return in a void function 2017-11-18 18:38:36 +01:00
Pierre Schweitzer d3d5853956
[NTOSKRNL] Implement FsRtlCheckOplock(), FsRtlCurrentBatchOplock(), FsRtlInitializeOplock(), FsRtlOplockFsctrl(), FsRtlOplockIsFastIoPossible(), FsRtlUninitializeOplock().
But also, implement FsRtlNotifyCompletion(), FsRtlCompletionRoutinePriv(), FsRtlRemoveAndCompleteWaitIrp(), FsRtlCancelWaitIrp(), FsRtlWaitOnIrp(), FsRtlOplockBreakNotify(), FsRtlRemoveAndCompleteIrp(), FsRtlCancelOplockIIIrp(), FsRtlAcknowledgeOplockBreak(), FsRtlOpBatchBreakClosePending(), FsRtlAllocateOplock(), FsRtlCancelExclusiveIrp(), FsRtlRequestExclusiveOplock(), FsRtlRequestOplockII(), FsRtlOplockCleanup(), FsRtlOplockBreakToNone(), FsRtlOplockBreakToII().
In short... Implement oplocks support in ReactOS.
2017-11-18 18:23:57 +01:00
Timo Kreuzer 959d9c6201 [NTOSKRNL] Fix out-of-bounds access (CID-1401083) and potencial memory leak in FsRtlIsNameInExpressionPrivate 2017-10-26 20:52:27 +02:00
Timo Kreuzer 561f18afea [NTOSKRNL] Fix our-of-bounds access and memory leak (CID-1401178, 1401177) in FsRtlIsDbcsInExpression 2017-10-26 20:52:27 +02:00
Colin Finck c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00