diff options
author | Jes Sorensen <jes@sgi.com> | 2006-03-31 11:18:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-31 15:30:48 -0500 |
commit | 30c14e40ed85469f166b5effdab6705c73c5cd5e (patch) | |
tree | 31154f46c2c2acd0499b9ab8c849f009ac342641 /fs | |
parent | d21c356b08820e60501ce7a42107a7f05863d91d (diff) |
[PATCH] avoid unaligned access when accessing poll stack
Commit 70674f95c0a2ea694d5c39f4e514f538a09be36f:
[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: Jes Sorensen <jes@sgi.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/select.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/select.c b/fs/select.c index b3a3a1326af6..071660fa7b01 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -314,7 +314,7 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | |||
314 | int ret, size, max_fdset; | 314 | int ret, size, max_fdset; |
315 | struct fdtable *fdt; | 315 | struct fdtable *fdt; |
316 | /* Allocate small arguments on the stack to save memory and be faster */ | 316 | /* Allocate small arguments on the stack to save memory and be faster */ |
317 | char stack_fds[SELECT_STACK_ALLOC]; | 317 | long stack_fds[SELECT_STACK_ALLOC/sizeof(long)]; |
318 | 318 | ||
319 | ret = -EINVAL; | 319 | ret = -EINVAL; |
320 | if (n < 0) | 320 | if (n < 0) |
@@ -639,8 +639,10 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout) | |||
639 | struct poll_list *walk; | 639 | struct poll_list *walk; |
640 | struct fdtable *fdt; | 640 | struct fdtable *fdt; |
641 | int max_fdset; | 641 | int max_fdset; |
642 | /* Allocate small arguments on the stack to save memory and be faster */ | 642 | /* Allocate small arguments on the stack to save memory and be |
643 | char stack_pps[POLL_STACK_ALLOC]; | 643 | faster - use long to make sure the buffer is aligned properly |
644 | on 64 bit archs to avoid unaligned access */ | ||
645 | long stack_pps[POLL_STACK_ALLOC/sizeof(long)]; | ||
644 | struct poll_list *stack_pp = NULL; | 646 | struct poll_list *stack_pp = NULL; |
645 | 647 | ||
646 | /* Do a sanity check on nfds ... */ | 648 | /* Do a sanity check on nfds ... */ |