mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-04 12:52:15 +00:00
Emulate the FIODGNAME ioctl in our 32-bit emulator.
It's quite strange that nobody reported this issue before. It turns out functions like ttyname(), ptsname() and fdevname() don't work in compat32. This means it't not even possible to run applications like script(1) inside a 32-bit FreeBSD jail. Fix this by converting 32-bit fiodgname_arg structures to their 64-bit equivalent. Reported by: kris Tested by: kris
This commit is contained in:
parent
50959dc8d4
commit
7eac36ed3c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190529
@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/cdio.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/filio.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioccom.h>
|
||||
#include <sys/mdioctl.h>
|
||||
@ -178,6 +179,22 @@ freebsd32_ioctl_ioc_read_toc(struct thread *td,
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
freebsd32_ioctl_fiodgname(struct thread *td,
|
||||
struct freebsd32_ioctl_args *uap, struct file *fp)
|
||||
{
|
||||
struct fiodgname_arg fgn;
|
||||
struct fiodgname_arg32 fgn32;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(uap->data, &fgn32, sizeof fgn32)) != 0)
|
||||
return (error);
|
||||
CP(fgn32, fgn, len);
|
||||
PTRIN_CP(fgn32, fgn, buf);
|
||||
error = fo_ioctl(fp, FIODGNAME, (caddr_t)&fgn, td->td_ucred, td);
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap)
|
||||
@ -210,6 +227,9 @@ freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap)
|
||||
case CDIOREADTOCHEADER_32:
|
||||
return freebsd32_ioctl_ioc_toc_header(td, uap, fp);
|
||||
|
||||
case FIODGNAME_32:
|
||||
return freebsd32_ioctl_fiodgname(td, uap, fp);
|
||||
|
||||
default:
|
||||
fdrop(fp, td);
|
||||
ap.fd = uap->fd;
|
||||
|
@ -62,11 +62,17 @@ struct md_ioctl32 {
|
||||
int md_pad[MDNPAD32]; /* padding for future ideas */
|
||||
};
|
||||
|
||||
struct fiodgname_arg32 {
|
||||
int len;
|
||||
caddr_t32 buf;
|
||||
};
|
||||
|
||||
#define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32)
|
||||
#define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32)
|
||||
#define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4)
|
||||
#define MDIOCDETACH_32 _IOC(IOC_INOUT, 'm', 1, sizeof(struct md_ioctl32) + 4)
|
||||
#define MDIOCQUERY_32 _IOC(IOC_INOUT, 'm', 2, sizeof(struct md_ioctl32) + 4)
|
||||
#define MDIOCLIST_32 _IOC(IOC_INOUT, 'm', 3, sizeof(struct md_ioctl32) + 4)
|
||||
#define FIODGNAME_32 _IOW('f', 120, struct fiodgname_arg32)
|
||||
|
||||
#endif /* _COMPAT_FREEBSD32_IOCTL_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user