sys: util: FspEaBufferAndNamesValid

This commit is contained in:
Bill Zissimopoulos 2019-03-16 13:58:09 -07:00
parent 91568edc45
commit 9e5d75fadc
No known key found for this signature in database
GPG Key ID: 3D4F95D52C7B3EA3
4 changed files with 44 additions and 22 deletions

View File

@ -314,8 +314,7 @@ static NTSTATUS FspFsvolCreateNoLock(
return STATUS_ACCESS_DENIED; return STATUS_ACCESS_DENIED;
/* is the EA buffer valid? */ /* is the EA buffer valid? */
Irp->IoStatus.Information = 0; Result = FspEaBufferAndNamesValid(EaBuffer, EaLength, (PULONG)&Irp->IoStatus.Information);
Result = IoCheckEaBufferValidity(EaBuffer, EaLength, (PULONG)&Irp->IoStatus.Information);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
} }

View File

@ -515,6 +515,10 @@ NTSTATUS FspCcFlushCache(PSECTION_OBJECT_POINTERS SectionObjectPointer,
NTSTATUS FspQuerySecurityDescriptorInfo(SECURITY_INFORMATION SecurityInformation, NTSTATUS FspQuerySecurityDescriptorInfo(SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR SecurityDescriptor, PULONG PLength, PSECURITY_DESCRIPTOR SecurityDescriptor, PULONG PLength,
PSECURITY_DESCRIPTOR ObjectsSecurityDescriptor); PSECURITY_DESCRIPTOR ObjectsSecurityDescriptor);
NTSTATUS FspEaBufferAndNamesValid(
PFILE_FULL_EA_INFORMATION Buffer,
ULONG Length,
PULONG PErrorOffset);
NTSTATUS FspNotifyInitializeSync(PNOTIFY_SYNC *NotifySync); NTSTATUS FspNotifyInitializeSync(PNOTIFY_SYNC *NotifySync);
NTSTATUS FspNotifyFullChangeDirectory( NTSTATUS FspNotifyFullChangeDirectory(
PNOTIFY_SYNC NotifySync, PNOTIFY_SYNC NotifySync,

View File

@ -506,31 +506,12 @@ static NTSTATUS FspFsvolSetEa(
Result = FspBufferUserBuffer(Irp, Length, IoReadAccess); Result = FspBufferUserBuffer(Irp, Length, IoReadAccess);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
Buffer = Irp->AssociatedIrp.SystemBuffer; Buffer = Irp->AssociatedIrp.SystemBuffer;
Irp->IoStatus.Information = 0; Result = FspEaBufferAndNamesValid(Buffer, Length, (PULONG)&Irp->IoStatus.Information);
Result = IoCheckEaBufferValidity(Buffer, Length,
(PULONG)&Irp->IoStatus.Information);
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
return Result; return Result;
for (PFILE_FULL_EA_INFORMATION Ea = Buffer, EaEnd = (PVOID)((PUINT8)Ea + Length);
EaEnd > Ea; Ea = FSP_NEXT_EA(Ea, EaEnd))
{
STRING Name;
Name.Length = Name.MaximumLength = Ea->EaNameLength;
Name.Buffer = Ea->EaName;
if (!FspEaNameIsValid(&Name))
{
Result = STATUS_INVALID_EA_NAME;
Irp->IoStatus.Information = (ULONG)((PUINT8)Ea - (PUINT8)Buffer);
return Result;
}
}
FspFileNodeAcquireExclusive(FileNode, Full); FspFileNodeAcquireExclusive(FileNode, Full);
Result = FspIopCreateRequestEx(Irp, 0, Length, FspFsvolSetEaRequestFini, Result = FspIopCreateRequestEx(Irp, 0, Length, FspFsvolSetEaRequestFini,

View File

@ -49,6 +49,10 @@ NTSTATUS FspCcFlushCache(PSECTION_OBJECT_POINTERS SectionObjectPointer,
NTSTATUS FspQuerySecurityDescriptorInfo(SECURITY_INFORMATION SecurityInformation, NTSTATUS FspQuerySecurityDescriptorInfo(SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR SecurityDescriptor, PULONG PLength, PSECURITY_DESCRIPTOR SecurityDescriptor, PULONG PLength,
PSECURITY_DESCRIPTOR ObjectsSecurityDescriptor); PSECURITY_DESCRIPTOR ObjectsSecurityDescriptor);
NTSTATUS FspEaBufferAndNamesValid(
PFILE_FULL_EA_INFORMATION Buffer,
ULONG Length,
PULONG PErrorOffset);
NTSTATUS FspNotifyInitializeSync(PNOTIFY_SYNC *NotifySync); NTSTATUS FspNotifyInitializeSync(PNOTIFY_SYNC *NotifySync);
NTSTATUS FspNotifyFullChangeDirectory( NTSTATUS FspNotifyFullChangeDirectory(
PNOTIFY_SYNC NotifySync, PNOTIFY_SYNC NotifySync,
@ -129,6 +133,7 @@ NTSTATUS FspIrpHookNext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context);
#pragma alloc_text(PAGE, FspCcMdlWriteComplete) #pragma alloc_text(PAGE, FspCcMdlWriteComplete)
#pragma alloc_text(PAGE, FspCcFlushCache) #pragma alloc_text(PAGE, FspCcFlushCache)
#pragma alloc_text(PAGE, FspQuerySecurityDescriptorInfo) #pragma alloc_text(PAGE, FspQuerySecurityDescriptorInfo)
#pragma alloc_text(PAGE, FspEaBufferAndNamesValid)
#pragma alloc_text(PAGE, FspNotifyInitializeSync) #pragma alloc_text(PAGE, FspNotifyInitializeSync)
#pragma alloc_text(PAGE, FspNotifyFullChangeDirectory) #pragma alloc_text(PAGE, FspNotifyFullChangeDirectory)
#pragma alloc_text(PAGE, FspNotifyFullReportChange) #pragma alloc_text(PAGE, FspNotifyFullReportChange)
@ -578,6 +583,39 @@ NTSTATUS FspQuerySecurityDescriptorInfo(SECURITY_INFORMATION SecurityInformation
return STATUS_BUFFER_TOO_SMALL == Result ? STATUS_BUFFER_OVERFLOW : Result; return STATUS_BUFFER_TOO_SMALL == Result ? STATUS_BUFFER_OVERFLOW : Result;
} }
NTSTATUS FspEaBufferAndNamesValid(
PFILE_FULL_EA_INFORMATION Buffer,
ULONG Length,
PULONG PErrorOffset)
{
PAGED_CODE();
NTSTATUS Result;
*PErrorOffset = 0;
Result = IoCheckEaBufferValidity(Buffer, Length, PErrorOffset);
if (!NT_SUCCESS(Result))
return Result;
for (PFILE_FULL_EA_INFORMATION Ea = Buffer, EaEnd = (PVOID)((PUINT8)Ea + Length);
EaEnd > Ea; Ea = FSP_NEXT_EA(Ea, EaEnd))
{
STRING Name;
Name.Length = Name.MaximumLength = Ea->EaNameLength;
Name.Buffer = Ea->EaName;
if (!FspEaNameIsValid(&Name))
{
*PErrorOffset = (ULONG)((PUINT8)Ea - (PUINT8)Buffer);
return STATUS_INVALID_EA_NAME;
}
}
return STATUS_SUCCESS;
}
NTSTATUS FspNotifyInitializeSync(PNOTIFY_SYNC *NotifySync) NTSTATUS FspNotifyInitializeSync(PNOTIFY_SYNC *NotifySync)
{ {
PAGED_CODE(); PAGED_CODE();