@@ -1076,45 +1076,6 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
1076
1076
return copy_to_user (param , & lp , sizeof (* param )) ? - EFAULT : 0 ;
1077
1077
}
1078
1078
1079
- /*
1080
- * Copy the kernel size attribute structure (which might be larger
1081
- * than what user-space knows about) to user-space.
1082
- *
1083
- * Note that all cases are valid: user-space buffer can be larger or
1084
- * smaller than the kernel-space buffer. The usual case is that both
1085
- * have the same size.
1086
- */
1087
- static int
1088
- sched_attr_copy_to_user (struct sched_attr __user * uattr ,
1089
- struct sched_attr * kattr ,
1090
- unsigned int usize )
1091
- {
1092
- unsigned int ksize = sizeof (* kattr );
1093
-
1094
- if (!access_ok (uattr , usize ))
1095
- return - EFAULT ;
1096
-
1097
- /*
1098
- * sched_getattr() ABI forwards and backwards compatibility:
1099
- *
1100
- * If usize == ksize then we just copy everything to user-space and all is good.
1101
- *
1102
- * If usize < ksize then we only copy as much as user-space has space for,
1103
- * this keeps ABI compatibility as well. We skip the rest.
1104
- *
1105
- * If usize > ksize then user-space is using a newer version of the ABI,
1106
- * which part the kernel doesn't know about. Just ignore it - tooling can
1107
- * detect the kernel's knowledge of attributes from the attr->size value
1108
- * which is set to ksize in this case.
1109
- */
1110
- kattr -> size = min (usize , ksize );
1111
-
1112
- if (copy_to_user (uattr , kattr , kattr -> size ))
1113
- return - EFAULT ;
1114
-
1115
- return 0 ;
1116
- }
1117
-
1118
1079
/**
1119
1080
* sys_sched_getattr - similar to sched_getparam, but with sched_attr
1120
1081
* @pid: the pid in question.
@@ -1159,7 +1120,8 @@ SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr,
1159
1120
#endif
1160
1121
}
1161
1122
1162
- return sched_attr_copy_to_user (uattr , & kattr , usize );
1123
+ kattr .size = min (usize , sizeof (kattr ));
1124
+ return copy_struct_to_user (uattr , usize , & kattr , sizeof (kattr ), NULL );
1163
1125
}
1164
1126
1165
1127
#ifdef CONFIG_SMP
0 commit comments