Pull up following revision(s) (requested by reinoud in ticket #1438):

sys/compat/netbsd32/netbsd32.h: revision 1.140
	sys/compat/netbsd32/netbsd32_fs.c: revision 1.95
	sys/fs/udf/udf_subr.c: revision 1.169

Fix endian issue with UDF extended attribute handling

Implement support for mounting UDF in compat32
Fixes PR#56801
This commit is contained in:
martin 2022-04-24 16:39:00 +00:00
parent 32bbb15705
commit aefc4e8caa
3 changed files with 92 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32.h,v 1.123.4.1 2019/11/19 13:36:25 martin Exp $ */
/* $NetBSD: netbsd32.h,v 1.123.4.2 2022/04/24 16:39:00 martin Exp $ */
/*
* Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@ -1095,6 +1095,25 @@ struct netbsd32_msdosfs_args {
int gmtoff; /* v3: offset from UTC in seconds */
};
/* from <udf/udf_mount.h> */
struct netbsd32_udf_args {
uint32_t version; /* version of this structure */
netbsd32_charp fspec; /* mount specifier */
int32_t sessionnr; /* session specifier, rel of abs */
uint32_t udfmflags; /* mount options */
int32_t gmtoff; /* offset from UTC in seconds */
uid_t anon_uid; /* mapping of anonymous files uid */
gid_t anon_gid; /* mapping of anonymous files gid */
uid_t nobody_uid; /* nobody:nobody will map to -1:-1 */
gid_t nobody_gid; /* nobody:nobody will map to -1:-1 */
uint32_t sector_size; /* for mounting dumps/files */
/* extendable */
uint8_t reserved[32];
};
/* from <miscfs/genfs/layer.h> */
struct netbsd32_layer_args {
netbsd32_charp target; /* Target of loopback */

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_fs.c,v 1.82.4.1 2019/10/16 17:29:49 martin Exp $ */
/* $NetBSD: netbsd32_fs.c,v 1.82.4.2 2022/04/24 16:39:00 martin Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.1 2019/10/16 17:29:49 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.2 2022/04/24 16:39:00 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.1 2019/10/16 17:29:49 martin
#include <fs/tmpfs/tmpfs_args.h>
#include <fs/msdosfs/bpb.h>
#include <fs/msdosfs/msdosfsmount.h>
#include <fs/udf/udf_mount.h>
#include <ufs/ufs/ufsmount.h>
#include <miscfs/nullfs/null.h>
@ -794,6 +795,7 @@ netbsd32___mount50(struct lwp *l, const struct netbsd32___mount50_args *uap,
struct netbsd32_iso_args iso_args;
struct netbsd32_nfs_args nfs_args;
struct netbsd32_msdosfs_args msdosfs_args;
struct netbsd32_udf_args udf_args;
struct netbsd32_tmpfs_args tmpfs_args;
struct netbsd32_null_args null_args;
} fs_args32;
@ -803,6 +805,7 @@ netbsd32___mount50(struct lwp *l, const struct netbsd32___mount50_args *uap,
struct iso_args iso_args;
struct nfs_args nfs_args;
struct msdosfs_args msdosfs_args;
struct udf_args udf_args;
struct tmpfs_args tmpfs_args;
struct null_args null_args;
} fs_args;
@ -928,6 +931,40 @@ netbsd32___mount50(struct lwp *l, const struct netbsd32___mount50_args *uap,
data_seg = UIO_SYSSPACE;
data = &fs_args.msdosfs_args;
data_len = sizeof(fs_args.msdosfs_args);
} else if (strcmp(mtype, MOUNT_UDF) == 0) {
if (data_len != 0 && data_len < sizeof(fs_args32.udf_args))
return EINVAL;
if ((flags & MNT_GETARGS) == 0) {
error = copyin(data, &fs_args32.udf_args,
sizeof(fs_args32.udf_args));
if (error)
return error;
fs_args.udf_args.version =
fs_args32.udf_args.version;
fs_args.udf_args.fspec =
NETBSD32PTR64(fs_args32.udf_args.fspec);
fs_args.udf_args.sessionnr =
fs_args32.udf_args.sessionnr;
fs_args.udf_args.udfmflags =
fs_args32.udf_args.udfmflags;
fs_args.udf_args.gmtoff =
fs_args32.udf_args.gmtoff;
fs_args.udf_args.anon_uid =
fs_args32.udf_args.anon_uid;
fs_args.udf_args.anon_gid =
fs_args32.udf_args.anon_gid;
fs_args.udf_args.nobody_uid =
fs_args32.udf_args.nobody_uid;
fs_args.udf_args.nobody_gid =
fs_args32.udf_args.nobody_gid;
fs_args.udf_args.sector_size =
fs_args32.udf_args.sector_size;
memset(fs_args.udf_args.reserved, 0,
sizeof(fs_args.udf_args.reserved));
}
data_seg = UIO_SYSSPACE;
data = &fs_args.udf_args;
data_len = sizeof(fs_args.udf_args);
} else if (strcmp(mtype, MOUNT_NFS) == 0) {
if (data_len < sizeof(fs_args32.nfs_args))
return EINVAL;
@ -1031,6 +1068,35 @@ netbsd32___mount50(struct lwp *l, const struct netbsd32___mount50_args *uap,
error = copyout(&fs_args32.iso_args, udata,
sizeof(fs_args32.iso_args));
*retval = sizeof(fs_args32.iso_args);
} else if (strcmp(mtype, MOUNT_UDF) == 0) {
if (data_len != 0 &&
data_len != sizeof(fs_args.udf_args))
return EINVAL;
fs_args32.udf_args.version =
fs_args.udf_args.version;
NETBSD32PTR32(fs_args32.udf_args.fspec,
fs_args.udf_args.fspec);
fs_args32.udf_args.sessionnr =
fs_args.udf_args.sessionnr;
fs_args32.udf_args.udfmflags =
fs_args.udf_args.udfmflags;
fs_args32.udf_args.gmtoff =
fs_args.udf_args.gmtoff;
fs_args32.udf_args.anon_uid =
fs_args.udf_args.anon_uid;
fs_args32.udf_args.anon_gid =
fs_args.udf_args.anon_gid;
fs_args32.udf_args.nobody_uid =
fs_args.udf_args.nobody_uid;
fs_args32.udf_args.nobody_gid =
fs_args.udf_args.nobody_gid;
fs_args32.udf_args.sector_size =
fs_args.udf_args.sector_size;
memset(fs_args32.udf_args.reserved, 0,
sizeof(fs_args32.udf_args.reserved));
error = copyout(&fs_args32.udf_args, udata,
sizeof(fs_args32.udf_args));
*retval = sizeof(fs_args32.udf_args);
} else if (strcmp(mtype, MOUNT_NFS) == 0) {
if (data_len != sizeof(fs_args.nfs_args))
return EINVAL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: udf_subr.c,v 1.146.2.2 2022/03/13 09:48:32 martin Exp $ */
/* $NetBSD: udf_subr.c,v 1.146.2.3 2022/04/24 16:39:00 martin Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.146.2.2 2022/03/13 09:48:32 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.146.2.3 2022/04/24 16:39:00 martin Exp $");
#endif /* not lint */
@ -2439,11 +2439,11 @@ udf_extattr_search_intern(struct udf_node *node,
if ((a_l == 0) || (a_l > l_ea))
return EINVAL;
if (attrhdr->type != sattr)
if (udf_rw32(attrhdr->type) != sattr)
goto next_attribute;
/* we might have found it! */
if (attrhdr->type < 2048) { /* Ecma-167 attribute */
if (udf_rw32(attrhdr->type) < 2048) { /* Ecma-167 attribute */
*offsetp = offset;
*lengthp = a_l;
return 0; /* success */