Skip to content

Commit

Permalink
Correct path-remaining with Reparse Points
Browse files Browse the repository at this point in the history
When returning STATUS_REPARSE we are to calculate
how much of the path remains unused, and did so using
strlen(). This will break with non-ASCII characters
(umlauts etc). Now we use RtlUTF8ToUnicodeN() to
get the number of characters remaining (instead of bytes).

Also started work allowing fastio_query_open() to assign
vp, but currently not active.

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
  • Loading branch information
lundman committed Feb 19, 2024
1 parent 400fc2e commit f886377
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/os/windows/zfs/sys/zfs_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ extern NTSTATUS file_ea_information(PDEVICE_OBJECT, PIRP, PIO_STACK_LOCATION,
extern NTSTATUS file_alignment_information(PDEVICE_OBJECT, PIRP,
PIO_STACK_LOCATION, FILE_ALIGNMENT_INFORMATION *);
extern void file_network_open_information_impl(PDEVICE_OBJECT, PFILE_OBJECT,
FILE_NETWORK_OPEN_INFORMATION *, PIO_STATUS_BLOCK);
struct vnode *, FILE_NETWORK_OPEN_INFORMATION *, PIO_STATUS_BLOCK);
extern NTSTATUS file_network_open_information(PDEVICE_OBJECT, PIRP,
PIO_STACK_LOCATION, FILE_NETWORK_OPEN_INFORMATION *);
extern NTSTATUS file_standard_link_information(PDEVICE_OBJECT, PIRP,
Expand Down
24 changes: 13 additions & 11 deletions module/os/windows/zfs/zfs_vnops_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,11 +1138,16 @@ zfs_vnop_lookup_impl(PIRP Irp, PIO_STACK_LOCATION IrpSp, mount_t *zmo,
* Should include the leading "/", when finalname
* here would be "lower".
*/
rpb->Reserved = strlen(finalname) * sizeof (WCHAR);
if (rpb->Reserved != 0)
rpb->Reserved += sizeof (WCHAR); // the slash
ULONG len = 0;
if (finalname && *finalname) {
RtlUTF8ToUnicodeN(NULL, 0, &len,
finalname, strlen(finalname));
len += sizeof (WCHAR);
}
rpb->Reserved = len;

dprintf("%s: returning REPARSE\n", __func__);
dprintf("%s: returning REPARSE (remainder %d)\n",
__func__, rpb->Reserved);
Irp->IoStatus.Information = rpb->ReparseTag;
Irp->Tail.Overlay.AuxiliaryBuffer = (void *)rpb;

Expand Down Expand Up @@ -7994,7 +7999,8 @@ fastio_query_network_open_info(PFILE_OBJECT FileObject,
return (FALSE);
}

file_network_open_information_impl(DeviceObject, FileObject, fnoi,
file_network_open_information_impl(DeviceObject, FileObject, vp,
fnoi,
IoStatus);

ExReleaseResourceLite(vp->FileHeader.Resource);
Expand Down Expand Up @@ -8197,13 +8203,9 @@ fastio_query_open(PIRP Irp,
/* call sets the IoStatus */
dprintf("%s: open OK stat()ing.\n", __func__);

// if (IrpSp->FileObject->FsContext == NULL)
// zfs_couplefileobject(dvp, vp,
// IrpSp->FileObject->FsContext, 0ULL, &zccb,
// NULL, 0, NULL);

file_network_open_information_impl(DeviceObject,
IrpSp->FileObject, NetworkInformation,
IrpSp->FileObject, vp ? vp : dvp,
NetworkInformation,
&Irp->IoStatus);
if (vp)
VN_RELE(vp);
Expand Down
10 changes: 6 additions & 4 deletions module/os/windows/zfs/zfs_vnops_windows_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,9 @@ zfs_send_notify_stream(zfsvfs_t *zfsvfs, char *name, int nameoffset,
if (name == NULL)
return;

if (nameoffset > strlen(name))
return;

AsciiStringToUnicodeString(name, &ustr);

dprintf("%s: '%wZ' part '%S' %lu %u\n", __func__, &ustr,
Expand Down Expand Up @@ -4596,12 +4599,11 @@ file_alignment_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,

void
file_network_open_information_impl(PDEVICE_OBJECT DeviceObject,
PFILE_OBJECT FileObject, FILE_NETWORK_OPEN_INFORMATION *netopen,
PFILE_OBJECT FileObject, vnode_t *vp,
FILE_NETWORK_OPEN_INFORMATION *netopen,
PIO_STATUS_BLOCK IoStatus)
{
dprintf(" %s\n", __func__);
struct vnode *vp = FileObject->FsContext;
zfs_ccb_t *zccb = FileObject->FsContext2;
znode_t *zp = VTOZ(vp);
mount_t *zmo = DeviceObject->DeviceExtension;
zfsvfs_t *zfsvfs = vfs_fsprivate(zmo);
Expand Down Expand Up @@ -4662,7 +4664,7 @@ file_network_open_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,

// This function relies on VN_HOLD in dispatcher.
file_network_open_information_impl(DeviceObject, IrpSp->FileObject,
netopen, &Irp->IoStatus);
IrpSp->FileObject->FsContext, netopen, &Irp->IoStatus);

return (Irp->IoStatus.Status);
}
Expand Down

0 comments on commit f886377

Please sign in to comment.