diff options
-rw-r--r-- | include/linux/kernel.h | 2 | ||||
-rw-r--r-- | kernel/compat.c | 65 | ||||
-rw-r--r-- | kernel/timer.c | 70 |
3 files changed, 69 insertions, 68 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 2dac79c39199..6d1844f393c0 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -798,6 +798,4 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
798 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 798 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
799 | #endif | 799 | #endif |
800 | 800 | ||
801 | extern int do_sysinfo(struct sysinfo *info); | ||
802 | |||
803 | #endif | 801 | #endif |
diff --git a/kernel/compat.c b/kernel/compat.c index 19971d8c7299..1e8f1455117a 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
@@ -1138,71 +1138,6 @@ asmlinkage long compat_sys_migrate_pages(compat_pid_t pid, | |||
1138 | } | 1138 | } |
1139 | #endif | 1139 | #endif |
1140 | 1140 | ||
1141 | struct compat_sysinfo { | ||
1142 | s32 uptime; | ||
1143 | u32 loads[3]; | ||
1144 | u32 totalram; | ||
1145 | u32 freeram; | ||
1146 | u32 sharedram; | ||
1147 | u32 bufferram; | ||
1148 | u32 totalswap; | ||
1149 | u32 freeswap; | ||
1150 | u16 procs; | ||
1151 | u16 pad; | ||
1152 | u32 totalhigh; | ||
1153 | u32 freehigh; | ||
1154 | u32 mem_unit; | ||
1155 | char _f[20-2*sizeof(u32)-sizeof(int)]; | ||
1156 | }; | ||
1157 | |||
1158 | asmlinkage long | ||
1159 | compat_sys_sysinfo(struct compat_sysinfo __user *info) | ||
1160 | { | ||
1161 | struct sysinfo s; | ||
1162 | |||
1163 | do_sysinfo(&s); | ||
1164 | |||
1165 | /* Check to see if any memory value is too large for 32-bit and scale | ||
1166 | * down if needed | ||
1167 | */ | ||
1168 | if ((s.totalram >> 32) || (s.totalswap >> 32)) { | ||
1169 | int bitcount = 0; | ||
1170 | |||
1171 | while (s.mem_unit < PAGE_SIZE) { | ||
1172 | s.mem_unit <<= 1; | ||
1173 | bitcount++; | ||
1174 | } | ||
1175 | |||
1176 | s.totalram >>= bitcount; | ||
1177 | s.freeram >>= bitcount; | ||
1178 | s.sharedram >>= bitcount; | ||
1179 | s.bufferram >>= bitcount; | ||
1180 | s.totalswap >>= bitcount; | ||
1181 | s.freeswap >>= bitcount; | ||
1182 | s.totalhigh >>= bitcount; | ||
1183 | s.freehigh >>= bitcount; | ||
1184 | } | ||
1185 | |||
1186 | if (!access_ok(VERIFY_WRITE, info, sizeof(struct compat_sysinfo)) || | ||
1187 | __put_user (s.uptime, &info->uptime) || | ||
1188 | __put_user (s.loads[0], &info->loads[0]) || | ||
1189 | __put_user (s.loads[1], &info->loads[1]) || | ||
1190 | __put_user (s.loads[2], &info->loads[2]) || | ||
1191 | __put_user (s.totalram, &info->totalram) || | ||
1192 | __put_user (s.freeram, &info->freeram) || | ||
1193 | __put_user (s.sharedram, &info->sharedram) || | ||
1194 | __put_user (s.bufferram, &info->bufferram) || | ||
1195 | __put_user (s.totalswap, &info->totalswap) || | ||
1196 | __put_user (s.freeswap, &info->freeswap) || | ||
1197 | __put_user (s.procs, &info->procs) || | ||
1198 | __put_user (s.totalhigh, &info->totalhigh) || | ||
1199 | __put_user (s.freehigh, &info->freehigh) || | ||
1200 | __put_user (s.mem_unit, &info->mem_unit)) | ||
1201 | return -EFAULT; | ||
1202 | |||
1203 | return 0; | ||
1204 | } | ||
1205 | |||
1206 | COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval, | 1141 | COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval, |
1207 | compat_pid_t, pid, | 1142 | compat_pid_t, pid, |
1208 | struct compat_timespec __user *, interval) | 1143 | struct compat_timespec __user *, interval) |
diff --git a/kernel/timer.c b/kernel/timer.c index dbf7a78a1ef1..06b3245624e2 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/sched.h> | 41 | #include <linux/sched.h> |
42 | #include <linux/sched/sysctl.h> | 42 | #include <linux/sched/sysctl.h> |
43 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
44 | #include <linux/compat.h> | ||
44 | 45 | ||
45 | #include <asm/uaccess.h> | 46 | #include <asm/uaccess.h> |
46 | #include <asm/unistd.h> | 47 | #include <asm/unistd.h> |
@@ -1567,7 +1568,7 @@ SYSCALL_DEFINE0(gettid) | |||
1567 | * do_sysinfo - fill in sysinfo struct | 1568 | * do_sysinfo - fill in sysinfo struct |
1568 | * @info: pointer to buffer to fill | 1569 | * @info: pointer to buffer to fill |
1569 | */ | 1570 | */ |
1570 | int do_sysinfo(struct sysinfo *info) | 1571 | static int do_sysinfo(struct sysinfo *info) |
1571 | { | 1572 | { |
1572 | unsigned long mem_total, sav_total; | 1573 | unsigned long mem_total, sav_total; |
1573 | unsigned int mem_unit, bitcount; | 1574 | unsigned int mem_unit, bitcount; |
@@ -1642,6 +1643,73 @@ SYSCALL_DEFINE1(sysinfo, struct sysinfo __user *, info) | |||
1642 | return 0; | 1643 | return 0; |
1643 | } | 1644 | } |
1644 | 1645 | ||
1646 | #ifdef CONFIG_COMPAT | ||
1647 | struct compat_sysinfo { | ||
1648 | s32 uptime; | ||
1649 | u32 loads[3]; | ||
1650 | u32 totalram; | ||
1651 | u32 freeram; | ||
1652 | u32 sharedram; | ||
1653 | u32 bufferram; | ||
1654 | u32 totalswap; | ||
1655 | u32 freeswap; | ||
1656 | u16 procs; | ||
1657 | u16 pad; | ||
1658 | u32 totalhigh; | ||
1659 | u32 freehigh; | ||
1660 | u32 mem_unit; | ||
1661 | char _f[20-2*sizeof(u32)-sizeof(int)]; | ||
1662 | }; | ||
1663 | |||
1664 | asmlinkage long | ||
1665 | compat_sys_sysinfo(struct compat_sysinfo __user *info) | ||
1666 | { | ||
1667 | struct sysinfo s; | ||
1668 | |||
1669 | do_sysinfo(&s); | ||
1670 | |||
1671 | /* Check to see if any memory value is too large for 32-bit and scale | ||
1672 | * down if needed | ||
1673 | */ | ||
1674 | if ((s.totalram >> 32) || (s.totalswap >> 32)) { | ||
1675 | int bitcount = 0; | ||
1676 | |||
1677 | while (s.mem_unit < PAGE_SIZE) { | ||
1678 | s.mem_unit <<= 1; | ||
1679 | bitcount++; | ||
1680 | } | ||
1681 | |||
1682 | s.totalram >>= bitcount; | ||
1683 | s.freeram >>= bitcount; | ||
1684 | s.sharedram >>= bitcount; | ||
1685 | s.bufferram >>= bitcount; | ||
1686 | s.totalswap >>= bitcount; | ||
1687 | s.freeswap >>= bitcount; | ||
1688 | s.totalhigh >>= bitcount; | ||
1689 | s.freehigh >>= bitcount; | ||
1690 | } | ||
1691 | |||
1692 | if (!access_ok(VERIFY_WRITE, info, sizeof(struct compat_sysinfo)) || | ||
1693 | __put_user (s.uptime, &info->uptime) || | ||
1694 | __put_user (s.loads[0], &info->loads[0]) || | ||
1695 | __put_user (s.loads[1], &info->loads[1]) || | ||
1696 | __put_user (s.loads[2], &info->loads[2]) || | ||
1697 | __put_user (s.totalram, &info->totalram) || | ||
1698 | __put_user (s.freeram, &info->freeram) || | ||
1699 | __put_user (s.sharedram, &info->sharedram) || | ||
1700 | __put_user (s.bufferram, &info->bufferram) || | ||
1701 | __put_user (s.totalswap, &info->totalswap) || | ||
1702 | __put_user (s.freeswap, &info->freeswap) || | ||
1703 | __put_user (s.procs, &info->procs) || | ||
1704 | __put_user (s.totalhigh, &info->totalhigh) || | ||
1705 | __put_user (s.freehigh, &info->freehigh) || | ||
1706 | __put_user (s.mem_unit, &info->mem_unit)) | ||
1707 | return -EFAULT; | ||
1708 | |||
1709 | return 0; | ||
1710 | } | ||
1711 | #endif /* CONFIG_COMPAT */ | ||
1712 | |||
1645 | static int __cpuinit init_timers_cpu(int cpu) | 1713 | static int __cpuinit init_timers_cpu(int cpu) |
1646 | { | 1714 | { |
1647 | int j; | 1715 | int j; |