Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106146832
D15887.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D15887.diff
View Options
Index: head/sys/compat/linux/linux_misc.c
===================================================================
--- head/sys/compat/linux/linux_misc.c
+++ head/sys/compat/linux/linux_misc.c
@@ -1867,7 +1867,9 @@
/* NOTREACHED */
}
-#define _LINUX_CAPABILITY_VERSION 0x19980330
+#define _LINUX_CAPABILITY_VERSION_1 0x19980330
+#define _LINUX_CAPABILITY_VERSION_2 0x20071026
+#define _LINUX_CAPABILITY_VERSION_3 0x20080522
struct l_user_cap_header {
l_int version;
@@ -1881,27 +1883,35 @@
};
int
-linux_capget(struct thread *td, struct linux_capget_args *args)
+linux_capget(struct thread *td, struct linux_capget_args *uap)
{
struct l_user_cap_header luch;
- struct l_user_cap_data lucd;
- int error;
+ struct l_user_cap_data lucd[2];
+ int error, u32s;
- if (args->hdrp == NULL)
+ if (uap->hdrp == NULL)
return (EFAULT);
- error = copyin(args->hdrp, &luch, sizeof(luch));
+ error = copyin(uap->hdrp, &luch, sizeof(luch));
if (error != 0)
return (error);
- if (luch.version != _LINUX_CAPABILITY_VERSION) {
+ switch (luch.version) {
+ case _LINUX_CAPABILITY_VERSION_1:
+ u32s = 1;
+ break;
+ case _LINUX_CAPABILITY_VERSION_2:
+ case _LINUX_CAPABILITY_VERSION_3:
+ u32s = 2;
+ break;
+ default:
#ifdef DEBUG
if (ldebug(capget))
printf(LMSG("invalid capget capability version 0x%x"),
luch.version);
#endif
- luch.version = _LINUX_CAPABILITY_VERSION;
- error = copyout(&luch, args->hdrp, sizeof(luch));
+ luch.version = _LINUX_CAPABILITY_VERSION_1;
+ error = copyout(&luch, uap->hdrp, sizeof(luch));
if (error)
return (error);
return (EINVAL);
@@ -1910,42 +1920,50 @@
if (luch.pid)
return (EPERM);
- if (args->datap) {
+ if (uap->datap) {
/*
* The current implementation doesn't support setting
* a capability (it's essentially a stub) so indicate
* that no capabilities are currently set or available
* to request.
*/
- bzero (&lucd, sizeof(lucd));
- error = copyout(&lucd, args->datap, sizeof(lucd));
+ memset(&lucd, 0, u32s * sizeof(lucd[0]));
+ error = copyout(&lucd, uap->datap, u32s * sizeof(lucd[0]));
}
return (error);
}
int
-linux_capset(struct thread *td, struct linux_capset_args *args)
+linux_capset(struct thread *td, struct linux_capset_args *uap)
{
struct l_user_cap_header luch;
- struct l_user_cap_data lucd;
- int error;
+ struct l_user_cap_data lucd[2];
+ int error, i, u32s;
- if (args->hdrp == NULL || args->datap == NULL)
+ if (uap->hdrp == NULL || uap->datap == NULL)
return (EFAULT);
- error = copyin(args->hdrp, &luch, sizeof(luch));
+ error = copyin(uap->hdrp, &luch, sizeof(luch));
if (error != 0)
return (error);
- if (luch.version != _LINUX_CAPABILITY_VERSION) {
+ switch (luch.version) {
+ case _LINUX_CAPABILITY_VERSION_1:
+ u32s = 1;
+ break;
+ case _LINUX_CAPABILITY_VERSION_2:
+ case _LINUX_CAPABILITY_VERSION_3:
+ u32s = 2;
+ break;
+ default:
#ifdef DEBUG
if (ldebug(capset))
printf(LMSG("invalid capset capability version 0x%x"),
luch.version);
#endif
- luch.version = _LINUX_CAPABILITY_VERSION;
- error = copyout(&luch, args->hdrp, sizeof(luch));
+ luch.version = _LINUX_CAPABILITY_VERSION_1;
+ error = copyout(&luch, uap->hdrp, sizeof(luch));
if (error)
return (error);
return (EINVAL);
@@ -1954,18 +1972,21 @@
if (luch.pid)
return (EPERM);
- error = copyin(args->datap, &lucd, sizeof(lucd));
+ error = copyin(uap->datap, &lucd, u32s * sizeof(lucd[0]));
if (error != 0)
return (error);
/* We currently don't support setting any capabilities. */
- if (lucd.effective || lucd.permitted || lucd.inheritable) {
- linux_msg(td,
- "capset effective=0x%x, permitted=0x%x, "
- "inheritable=0x%x is not implemented",
- (int)lucd.effective, (int)lucd.permitted,
- (int)lucd.inheritable);
- return (EPERM);
+ for (i = 0; i < u32s; i++) {
+ if (lucd[i].effective || lucd[i].permitted ||
+ lucd[i].inheritable) {
+ linux_msg(td,
+ "capset[%d] effective=0x%x, permitted=0x%x, "
+ "inheritable=0x%x is not implemented", i,
+ (int)lucd[i].effective, (int)lucd[i].permitted,
+ (int)lucd[i].inheritable);
+ return (EPERM);
+ }
}
return (0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 4:16 AM (11 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15611091
Default Alt Text
D15887.diff (4 KB)
Attached To
Mode
D15887: linuxulator: handle V3 capget/capset
Attached
Detach File
Event Timeline
Log In to Comment