aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_ioctl.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2002-08-17 02:36:16 +0000
committerRobert Watson <rwatson@FreeBSD.org>2002-08-17 02:36:16 +0000
commitd49fa1ca6ed75bd712b6eecb7383e9abe8b96943 (patch)
treefe31f7ea9a8713005d8ba378b027671dbea5c058 /sys/compat/linux/linux_ioctl.c
parentc068736a6139e9a60b6b4747f762a572e1b002f4 (diff)
downloadsrc-d49fa1ca6ed75bd712b6eecb7383e9abe8b96943.tar.gz
src-d49fa1ca6ed75bd712b6eecb7383e9abe8b96943.zip
In continuation of early fileop credential changes, modify fo_ioctl() to
accept an 'active_cred' argument reflecting the credential of the thread initiating the ioctl operation. - Change fo_ioctl() to accept active_cred; change consumers of the fo_ioctl() interface to generally pass active_cred from td->td_ucred. - In fifofs, initialize filetmp.f_cred to ap->a_cred so that the invocations of soo_ioctl() are provided access to the calling f_cred. Pass ap->a_td->td_ucred as the active_cred, but note that this is required because we don't yet distinguish file_cred and active_cred in invoking VOP's. - Update kqueue_ioctl() for its new argument. - Update pipe_ioctl() for its new argument, pass active_cred rather than td_ucred to MAC for authorization. - Update soo_ioctl() for its new argument. - Update vn_ioctl() for its new argument, use active_cred rather than td->td_ucred to authorize VOP_IOCTL() and the associated VOP_GETATTR(). Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
Notes
Notes: svn path=/head/; revision=102003
Diffstat (limited to 'sys/compat/linux/linux_ioctl.c')
-rw-r--r--sys/compat/linux/linux_ioctl.c54
1 files changed, 36 insertions, 18 deletions
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 77e294280622..05fc0bddd3b8 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -113,7 +113,8 @@ linux_ioctl_disk(struct thread *td, struct linux_ioctl_args *args)
return (error);
switch (args->cmd & 0xffff) {
case LINUX_BLKGETSIZE:
- error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, td);
+ error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, td->td_ucred,
+ td);
fdrop(fp, td);
if (error)
return (error);
@@ -560,7 +561,8 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
switch (args->cmd & 0xffff) {
case LINUX_TCGETS:
- error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td);
+ error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td->td_ucred,
+ td);
if (error)
break;
bsd_to_linux_termios(&bios, &lios);
@@ -572,7 +574,8 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
if (error)
break;
linux_to_bsd_termios(&lios, &bios);
- error = (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td));
+ error = (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td->td_ucred,
+ td));
break;
case LINUX_TCSETSW:
@@ -580,7 +583,8 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
if (error)
break;
linux_to_bsd_termios(&lios, &bios);
- error = (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td));
+ error = (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td->td_ucred,
+ td));
break;
case LINUX_TCSETSF:
@@ -588,11 +592,13 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
if (error)
break;
linux_to_bsd_termios(&lios, &bios);
- error = (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td));
+ error = (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td->td_ucred,
+ td));
break;
case LINUX_TCGETA:
- error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td);
+ error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td->td_ucred,
+ td);
if (error)
break;
bsd_to_linux_termio(&bios, &lio);
@@ -604,7 +610,8 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
if (error)
break;
linux_to_bsd_termio(&lio, &bios);
- error = (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td));
+ error = (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td->td_ucred,
+ td));
break;
case LINUX_TCSETAW:
@@ -612,7 +619,8 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
if (error)
break;
linux_to_bsd_termio(&lio, &bios);
- error = (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td));
+ error = (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td->td_ucred,
+ td));
break;
case LINUX_TCSETAF:
@@ -620,7 +628,8 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
if (error)
break;
linux_to_bsd_termio(&lio, &bios);
- error = (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td));
+ error = (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td->td_ucred,
+ td));
break;
/* LINUX_TCSBRK */
@@ -637,7 +646,8 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
case LINUX_TCION: {
int c;
struct write_args wr;
- error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td);
+ error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios,
+ td->td_ucred, td);
if (error)
break;
fdrop(fp, td);
@@ -799,14 +809,16 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
fdrop(fp, td);
return (EINVAL);
}
- error = (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, td));
+ error = (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, td->td_ucred,
+ td));
break;
}
case LINUX_TIOCGETD: {
int linux_line;
int bsd_line = TTYDISC;
- error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, td);
+ error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line,
+ td->td_ucred, td);
if (error)
return (error);
switch (bsd_line) {
@@ -1275,7 +1287,8 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args)
case LINUX_CDROMREADTOCHDR: {
struct ioc_toc_header th;
struct linux_cdrom_tochdr lth;
- error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, td);
+ error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th,
+ td->td_ucred, td);
if (!error) {
lth.cdth_trk0 = th.starting_track;
lth.cdth_trk1 = th.ending_track;
@@ -1290,7 +1303,8 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args)
struct ioc_read_toc_single_entry irtse;
irtse.address_format = ltep->cdte_format;
irtse.track = ltep->cdte_track;
- error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, td);
+ error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse,
+ td->td_ucred, td);
if (!error) {
lte = *ltep;
lte.cdte_ctrl = irtse.entry.control;
@@ -1331,7 +1345,8 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args)
bsdsc.track = 0;
bsdsc.data_len = sizeof(struct cd_sub_channel_info);
bsdsc.data = bsdinfo;
- error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, td);
+ error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc,
+ td->td_ucred, td);
if (error)
break;
error = copyin((caddr_t)args->arg, &sc,
@@ -1397,7 +1412,8 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args)
error = linux_to_bsd_dvd_struct(&lds, &bds);
if (error)
break;
- error = fo_ioctl(fp, DVDIOCREADSTRUCTURE, (caddr_t)&bds, td);
+ error = fo_ioctl(fp, DVDIOCREADSTRUCTURE, (caddr_t)&bds,
+ td->td_ucred, td);
if (error)
break;
error = bsd_to_linux_dvd_struct(&bds, &lds);
@@ -1422,7 +1438,8 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args)
error = linux_to_bsd_dvd_authinfo(&lda, &bcode, &bda);
if (error)
break;
- error = fo_ioctl(fp, bcode, (caddr_t)&bda, td);
+ error = fo_ioctl(fp, bcode, (caddr_t)&bda, td->td_ucred,
+ td);
if (error) {
if (lda.type == LINUX_DVD_HOST_SEND_KEY2) {
lda.type = LINUX_DVD_AUTH_FAILURE;
@@ -1759,7 +1776,8 @@ linux_ioctl_console(struct thread *td, struct linux_ioctl_args *args)
fdrop(fp, td);
return (EINVAL);
}
- error = (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, td));
+ error = (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode,
+ td->td_ucred, td));
break;
}