mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
sys: IRP_MJ_CREATE
This commit is contained in:
parent
a0e90dc6fb
commit
0e170901c8
@ -73,7 +73,7 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
PSECURITY_DESCRIPTOR SecurityDescriptor = AccessState->SecurityDescriptor;
|
PSECURITY_DESCRIPTOR SecurityDescriptor = AccessState->SecurityDescriptor;
|
||||||
ULONG SecurityDescriptorSize = 0;
|
ULONG SecurityDescriptorSize = 0;
|
||||||
LARGE_INTEGER AllocationSize = Irp->Overlay.AllocationSize;
|
LARGE_INTEGER AllocationSize = Irp->Overlay.AllocationSize;
|
||||||
ACCESS_MASK DesiredAccess = IrpSp->Parameters.Create.SecurityContext->DesiredAccess;
|
ACCESS_MASK DesiredAccess = AccessState->OriginalDesiredAccess;
|
||||||
USHORT ShareAccess = IrpSp->Parameters.Create.ShareAccess;
|
USHORT ShareAccess = IrpSp->Parameters.Create.ShareAccess;
|
||||||
PFILE_FULL_EA_INFORMATION EaBuffer = Irp->AssociatedIrp.SystemBuffer;
|
PFILE_FULL_EA_INFORMATION EaBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||||
//ULONG EaLength = IrpSp->Parameters.Create.EaLength;
|
//ULONG EaLength = IrpSp->Parameters.Create.EaLength;
|
||||||
@ -344,7 +344,23 @@ VOID FspFsvolCreateComplete(
|
|||||||
{
|
{
|
||||||
FSP_ENTER_IOC(PAGED_CODE());
|
FSP_ENTER_IOC(PAGED_CODE());
|
||||||
|
|
||||||
|
PDEVICE_OBJECT DeviceObject = IrpSp->DeviceObject;
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension =
|
||||||
|
FspFsvrtDeviceExtension(FsvolDeviceExtension->FsvrtDeviceObject);
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
|
PACCESS_STATE AccessState = IrpSp->Parameters.Create.SecurityContext->AccessState;
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor =
|
||||||
|
(PVOID)(Response->Buffer + Response->Rsp.Create.SecurityDescriptor);
|
||||||
|
ULONG SecurityDescriptorSize = Response->Rsp.Create.SecurityDescriptorSize;
|
||||||
|
ACCESS_MASK DesiredAccess = AccessState->OriginalDesiredAccess;
|
||||||
|
USHORT ShareAccess = IrpSp->Parameters.Create.ShareAccess;
|
||||||
|
ULONG Flags = IrpSp->Flags;
|
||||||
|
KPROCESSOR_MODE RequestorMode =
|
||||||
|
FlagOn(Flags, SL_FORCE_ACCESS_CHECK) ? UserMode : Irp->RequestorMode;
|
||||||
|
FSP_FILE_CONTEXT *FsContext = FileObject->FsContext;
|
||||||
|
ACCESS_MASK GrantedAccess;
|
||||||
|
BOOLEAN Inserted = FALSE;
|
||||||
|
|
||||||
/* did the user-mode file system sent us a failure code? */
|
/* did the user-mode file system sent us a failure code? */
|
||||||
if (!NT_SUCCESS(Response->IoStatus.Status))
|
if (!NT_SUCCESS(Response->IoStatus.Status))
|
||||||
@ -356,35 +372,21 @@ VOID FspFsvolCreateComplete(
|
|||||||
FSP_RETURN();
|
FSP_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
PDEVICE_OBJECT DeviceObject = IrpSp->DeviceObject;
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
|
||||||
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension =
|
|
||||||
FspFsvrtDeviceExtension(FsvolDeviceExtension->FsvrtDeviceObject);
|
|
||||||
|
|
||||||
/* are we doing access checks? */
|
/* are we doing access checks? */
|
||||||
if (FsvrtDeviceExtension->VolumeParams.NoSystemAccessCheck &&
|
if (FsvrtDeviceExtension->VolumeParams.NoSystemAccessCheck &&
|
||||||
0 != Response->Rsp.Create.SecurityDescriptorSize)
|
0 != SecurityDescriptorSize)
|
||||||
{
|
{
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor =
|
if ((PUINT8)SecurityDescriptor + SecurityDescriptorSize > (PUINT8)Response + Response->Size ||
|
||||||
(PVOID)(Response->Buffer + Response->Rsp.Create.SecurityDescriptor);
|
!FspValidRelativeSecurityDescriptor(SecurityDescriptor, SecurityDescriptorSize, 0))
|
||||||
if ((PUINT8)SecurityDescriptor + Response->Rsp.Create.SecurityDescriptorSize >
|
|
||||||
(PUINT8)Response + Response->Size ||
|
|
||||||
!FspValidRelativeSecurityDescriptor(
|
|
||||||
SecurityDescriptor, Response->Rsp.Create.SecurityDescriptorSize, 0))
|
|
||||||
{
|
{
|
||||||
FspFsvolCreateClose(Irp, Response);
|
FspFsvolCreateClose(Irp, Response);
|
||||||
FSP_RETURN(Result = STATUS_ACCESS_DENIED);
|
FSP_RETURN(Result = STATUS_ACCESS_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG Flags = IrpSp->Flags;
|
|
||||||
KPROCESSOR_MODE RequestorMode =
|
|
||||||
FlagOn(Flags, SL_FORCE_ACCESS_CHECK) ? UserMode : Irp->RequestorMode;
|
|
||||||
PACCESS_STATE AccessState = IrpSp->Parameters.Create.SecurityContext->AccessState;
|
|
||||||
ACCESS_MASK GrantedAccess;
|
|
||||||
if (!SeAccessCheck(SecurityDescriptor,
|
if (!SeAccessCheck(SecurityDescriptor,
|
||||||
&AccessState->SubjectSecurityContext,
|
&AccessState->SubjectSecurityContext,
|
||||||
FALSE,
|
FALSE,
|
||||||
AccessState->OriginalDesiredAccess,
|
DesiredAccess,
|
||||||
AccessState->PreviouslyGrantedAccess,
|
AccessState->PreviouslyGrantedAccess,
|
||||||
0,
|
0,
|
||||||
IoGetFileObjectGenericMapping(),
|
IoGetFileObjectGenericMapping(),
|
||||||
@ -398,30 +400,48 @@ VOID FspFsvolCreateComplete(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* record the user-mode file system contexts */
|
/* record the user-mode file system contexts */
|
||||||
FSP_FILE_CONTEXT *FsContext = FileObject->FsContext;
|
|
||||||
FsContext->UserContext = Response->Rsp.Create.UserContext;
|
FsContext->UserContext = Response->Rsp.Create.UserContext;
|
||||||
FileObject->FsContext2 = (PVOID)(UINT_PTR)Response->Rsp.Create.UserContext2;
|
FileObject->FsContext2 = (PVOID)(UINT_PTR)Response->Rsp.Create.UserContext2;
|
||||||
|
|
||||||
/* insert the new FsContext into our generic table */
|
/* following must be performed under the fsvol lock */
|
||||||
BOOLEAN Inserted;
|
|
||||||
ExAcquireResourceExclusiveLite(&FsvolDeviceExtension->Base.Resource, TRUE);
|
ExAcquireResourceExclusiveLite(&FsvolDeviceExtension->Base.Resource, TRUE);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
/* insert the new FsContext into our generic table */
|
||||||
|
Result = STATUS_SUCCESS;
|
||||||
FsContext = FspFsvolDeviceInsertContext(DeviceObject,
|
FsContext = FspFsvolDeviceInsertContext(DeviceObject,
|
||||||
FsContext->UserContext, FsContext, &Inserted);
|
FsContext->UserContext, FsContext, &Inserted);
|
||||||
if (0 != FsContext)
|
if (0 == FsContext)
|
||||||
|
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* do the share access checks */
|
||||||
|
if (Inserted)
|
||||||
|
{
|
||||||
|
IoSetShareAccess(DesiredAccess, ShareAccess, FileObject,
|
||||||
|
&FsContext->ShareAccess);
|
||||||
FspFileContextOpen(FsContext);
|
FspFileContextOpen(FsContext);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = IoCheckShareAccess(DesiredAccess, ShareAccess, FileObject,
|
||||||
|
&FsContext->ShareAccess, TRUE);
|
||||||
|
if (NT_SUCCESS(Result))
|
||||||
|
FspFileContextOpen(FsContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ExReleaseResourceLite(&FsvolDeviceExtension->Base.Resource);
|
ExReleaseResourceLite(&FsvolDeviceExtension->Base.Resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* did we fail to insert? */
|
/* did we fail to insert? */
|
||||||
if (0 == FsContext)
|
if (!NT_SUCCESS(Result))
|
||||||
{
|
{
|
||||||
|
ASSERT(!Inserted);
|
||||||
FspFsvolCreateClose(Irp, Response);
|
FspFsvolCreateClose(Irp, Response);
|
||||||
FSP_RETURN(Result = STATUS_INSUFFICIENT_RESOURCES);
|
FSP_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does an FsContext with the same UserContext already exist? */
|
/* does an FsContext with the same UserContext already exist? */
|
||||||
@ -431,6 +451,7 @@ VOID FspFsvolCreateComplete(
|
|||||||
FileObject->FsContext = FsContext;
|
FileObject->FsContext = FsContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SUCCESS! */
|
||||||
Irp->IoStatus.Information = Response->IoStatus.Information;
|
Irp->IoStatus.Information = Response->IoStatus.Information;
|
||||||
Result = Response->IoStatus.Status;
|
Result = Response->IoStatus.Status;
|
||||||
|
|
||||||
|
@ -364,6 +364,8 @@ typedef struct
|
|||||||
FSRTL_ADVANCED_FCB_HEADER Header;
|
FSRTL_ADVANCED_FCB_HEADER Header;
|
||||||
FSP_FILE_CONTEXT_NONPAGED *NonPaged;
|
FSP_FILE_CONTEXT_NONPAGED *NonPaged;
|
||||||
LONG OpenCount;
|
LONG OpenCount;
|
||||||
|
SHARE_ACCESS ShareAccess;
|
||||||
|
/* protected by containing fsvol lock */
|
||||||
UINT64 UserContext;
|
UINT64 UserContext;
|
||||||
UNICODE_STRING FileName;
|
UNICODE_STRING FileName;
|
||||||
WCHAR FileNameBuf[];
|
WCHAR FileNameBuf[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user