aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/compat.c')
-rw-r--r--kernel/compat.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/kernel/compat.c b/kernel/compat.c
index 6952dd057300..cebb4c28c039 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -1016,3 +1016,69 @@ asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
1016 return sys_migrate_pages(pid, nr_bits + 1, old, new); 1016 return sys_migrate_pages(pid, nr_bits + 1, old, new);
1017} 1017}
1018#endif 1018#endif
1019
1020struct compat_sysinfo {
1021 s32 uptime;
1022 u32 loads[3];
1023 u32 totalram;
1024 u32 freeram;
1025 u32 sharedram;
1026 u32 bufferram;
1027 u32 totalswap;
1028 u32 freeswap;
1029 u16 procs;
1030 u16 pad;
1031 u32 totalhigh;
1032 u32 freehigh;
1033 u32 mem_unit;
1034 char _f[20-2*sizeof(u32)-sizeof(int)];
1035};
1036
1037asmlinkage long
1038compat_sys_sysinfo(struct compat_sysinfo __user *info)
1039{
1040 struct sysinfo s;
1041
1042 do_sysinfo(&s);
1043
1044 /* Check to see if any memory value is too large for 32-bit and scale
1045 * down if needed
1046 */
1047 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
1048 int bitcount = 0;
1049
1050 while (s.mem_unit < PAGE_SIZE) {
1051 s.mem_unit <<= 1;
1052 bitcount++;
1053 }
1054
1055 s.totalram >>= bitcount;
1056 s.freeram >>= bitcount;
1057 s.sharedram >>= bitcount;
1058 s.bufferram >>= bitcount;
1059 s.totalswap >>= bitcount;
1060 s.freeswap >>= bitcount;
1061 s.totalhigh >>= bitcount;
1062 s.freehigh >>= bitcount;
1063 }
1064
1065 if (!access_ok(VERIFY_WRITE, info, sizeof(struct compat_sysinfo)) ||
1066 __put_user (s.uptime, &info->uptime) ||
1067 __put_user (s.loads[0], &info->loads[0]) ||
1068 __put_user (s.loads[1], &info->loads[1]) ||
1069 __put_user (s.loads[2], &info->loads[2]) ||
1070 __put_user (s.totalram, &info->totalram) ||
1071 __put_user (s.freeram, &info->freeram) ||
1072 __put_user (s.sharedram, &info->sharedram) ||
1073 __put_user (s.bufferram, &info->bufferram) ||
1074 __put_user (s.totalswap, &info->totalswap) ||
1075 __put_user (s.freeswap, &info->freeswap) ||
1076 __put_user (s.procs, &info->procs) ||
1077 __put_user (s.totalhigh, &info->totalhigh) ||
1078 __put_user (s.freehigh, &info->freehigh) ||
1079 __put_user (s.mem_unit, &info->mem_unit))
1080 return -EFAULT;
1081
1082 return 0;
1083}
1084