Skip to content

Commit ce5155c

Browse files
author
Al Viro
committed
compat sysinfo(2): don't bother with field-by-field copyout
Signed-off-by: Al Viro <[email protected]>
1 parent 8f3d9f3 commit ce5155c

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

kernel/sys.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,7 @@ struct compat_sysinfo {
26342634
COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)
26352635
{
26362636
struct sysinfo s;
2637+
struct compat_sysinfo s_32;
26372638

26382639
do_sysinfo(&s);
26392640

@@ -2658,23 +2659,23 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)
26582659
s.freehigh >>= bitcount;
26592660
}
26602661

2661-
if (!access_ok(info, sizeof(struct compat_sysinfo)) ||
2662-
__put_user(s.uptime, &info->uptime) ||
2663-
__put_user(s.loads[0], &info->loads[0]) ||
2664-
__put_user(s.loads[1], &info->loads[1]) ||
2665-
__put_user(s.loads[2], &info->loads[2]) ||
2666-
__put_user(s.totalram, &info->totalram) ||
2667-
__put_user(s.freeram, &info->freeram) ||
2668-
__put_user(s.sharedram, &info->sharedram) ||
2669-
__put_user(s.bufferram, &info->bufferram) ||
2670-
__put_user(s.totalswap, &info->totalswap) ||
2671-
__put_user(s.freeswap, &info->freeswap) ||
2672-
__put_user(s.procs, &info->procs) ||
2673-
__put_user(s.totalhigh, &info->totalhigh) ||
2674-
__put_user(s.freehigh, &info->freehigh) ||
2675-
__put_user(s.mem_unit, &info->mem_unit))
2662+
memset(&s_32, 0, sizeof(s_32));
2663+
s_32.uptime = s.uptime;
2664+
s_32.loads[0] = s.loads[0];
2665+
s_32.loads[1] = s.loads[1];
2666+
s_32.loads[2] = s.loads[2];
2667+
s_32.totalram = s.totalram;
2668+
s_32.freeram = s.freeram;
2669+
s_32.sharedram = s.sharedram;
2670+
s_32.bufferram = s.bufferram;
2671+
s_32.totalswap = s.totalswap;
2672+
s_32.freeswap = s.freeswap;
2673+
s_32.procs = s.procs;
2674+
s_32.totalhigh = s.totalhigh;
2675+
s_32.freehigh = s.freehigh;
2676+
s_32.mem_unit = s.mem_unit;
2677+
if (copy_to_user(info, &s_32, sizeof(s_32)))
26762678
return -EFAULT;
2677-
26782679
return 0;
26792680
}
26802681
#endif /* CONFIG_COMPAT */

0 commit comments

Comments
 (0)