Commit 30c14e40 authored by Jes Sorensen's avatar Jes Sorensen Committed by Linus Torvalds

[PATCH] avoid unaligned access when accessing poll stack

Commit 70674f95:

  [PATCH] Optimize select/poll by putting small data sets on the stack

resulted in the poll stack being 4-byte aligned on 64-bit architectures,
causing misaligned accesses to elements in the array.

This patch fixes it by declaring the stack in terms of 'long' instead
of 'char'.

Force alignment of poll and select stacks to long to avoid unaligned
access on 64 bit architectures.
Signed-off-by: default avatarJes Sorensen <jes@sgi.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d21c356b
...@@ -314,7 +314,7 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, ...@@ -314,7 +314,7 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
int ret, size, max_fdset; int ret, size, max_fdset;
struct fdtable *fdt; struct fdtable *fdt;
/* Allocate small arguments on the stack to save memory and be faster */ /* Allocate small arguments on the stack to save memory and be faster */
char stack_fds[SELECT_STACK_ALLOC]; long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
ret = -EINVAL; ret = -EINVAL;
if (n < 0) if (n < 0)
...@@ -639,8 +639,10 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout) ...@@ -639,8 +639,10 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout)
struct poll_list *walk; struct poll_list *walk;
struct fdtable *fdt; struct fdtable *fdt;
int max_fdset; int max_fdset;
/* Allocate small arguments on the stack to save memory and be faster */ /* Allocate small arguments on the stack to save memory and be
char stack_pps[POLL_STACK_ALLOC]; faster - use long to make sure the buffer is aligned properly
on 64 bit archs to avoid unaligned access */
long stack_pps[POLL_STACK_ALLOC/sizeof(long)];
struct poll_list *stack_pp = NULL; struct poll_list *stack_pp = NULL;
/* Do a sanity check on nfds ... */ /* Do a sanity check on nfds ... */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment