Commit c19ac326 authored by Sam Ravnborg's avatar Sam Ravnborg Committed by David S. Miller

sparc64: clean up compat_sigset_t.seta handling

Use compat_sigset_t rather than opencode the array
Drop "switch (_NSIG_WORDS)" as we know this is always 1
Introduce BUILD_BUG_ON() to catch if this changes

As a side-effect of this fix following sparse warnings:
signal32.c:220:60: warning: invalid access past the end of 'seta' (12 8)
signal32.c:220:42: warning: invalid access past the end of 'seta' (8 8)
signal32.c:219:60: warning: invalid access past the end of 'seta' (20 8)
signal32.c:219:42: warning: invalid access past the end of 'seta' (16 8)
signal32.c:218:60: warning: invalid access past the end of 'seta' (28 8)
signal32.c:218:42: warning: invalid access past the end of 'seta' (24 8)
signal32.c:309:68: warning: invalid access past the end of 'seta' (12 8)
signal32.c:309:46: warning: invalid access past the end of 'seta' (8 8)
signal32.c:308:68: warning: invalid access past the end of 'seta' (20 8)
signal32.c:308:46: warning: invalid access past the end of 'seta' (16 8)
signal32.c:307:68: warning: invalid access past the end of 'seta' (28 8)
signal32.c:307:46: warning: invalid access past the end of 'seta' (24 8)

They all pointed to code that was never executed - so no bugs fixed.
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent abaff455
...@@ -146,7 +146,7 @@ void do_sigreturn32(struct pt_regs *regs) ...@@ -146,7 +146,7 @@ void do_sigreturn32(struct pt_regs *regs)
unsigned int psr; unsigned int psr;
unsigned pc, npc; unsigned pc, npc;
sigset_t set; sigset_t set;
unsigned seta[_COMPAT_NSIG_WORDS]; compat_sigset_t seta;
int err, i; int err, i;
/* Always make any pending restarted system calls return -EINTR */ /* Always make any pending restarted system calls return -EINTR */
...@@ -210,17 +210,13 @@ void do_sigreturn32(struct pt_regs *regs) ...@@ -210,17 +210,13 @@ void do_sigreturn32(struct pt_regs *regs)
if (restore_rwin_state(compat_ptr(rwin_save))) if (restore_rwin_state(compat_ptr(rwin_save)))
goto segv; goto segv;
} }
err |= __get_user(seta[0], &sf->info.si_mask); err |= __get_user(seta.sig[0], &sf->info.si_mask);
err |= copy_from_user(seta+1, &sf->extramask, err |= copy_from_user(&seta.sig[1], &sf->extramask,
(_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
if (err) if (err)
goto segv; goto segv;
switch (_NSIG_WORDS) {
case 4: set.sig[3] = seta[6] + (((long)seta[7]) << 32); set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
case 3: set.sig[2] = seta[4] + (((long)seta[5]) << 32);
case 2: set.sig[1] = seta[2] + (((long)seta[3]) << 32);
case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32);
}
set_current_blocked(&set); set_current_blocked(&set);
return; return;
...@@ -304,12 +300,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) ...@@ -304,12 +300,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
goto segv; goto segv;
} }
switch (_NSIG_WORDS) { set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32);
case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32);
case 2: set.sig[1] = seta.sig[2] + (((long)seta.sig[3]) << 32);
case 1: set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
}
set_current_blocked(&set); set_current_blocked(&set);
return; return;
segv: segv:
...@@ -418,7 +409,7 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs, ...@@ -418,7 +409,7 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs,
void __user *tail; void __user *tail;
int sigframe_size; int sigframe_size;
u32 psr; u32 psr;
unsigned int seta[_COMPAT_NSIG_WORDS]; compat_sigset_t seta;
/* 1. Make sure everything is clean */ /* 1. Make sure everything is clean */
synchronize_user_stack(); synchronize_user_stack();
...@@ -482,18 +473,14 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs, ...@@ -482,18 +473,14 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs,
err |= __put_user(0, &sf->rwin_save); err |= __put_user(0, &sf->rwin_save);
} }
switch (_NSIG_WORDS) { /* If these change we need to know - assignments to seta relies on these sizes */
case 4: seta[7] = (oldset->sig[3] >> 32); BUILD_BUG_ON(_NSIG_WORDS != 1);
seta[6] = oldset->sig[3]; BUILD_BUG_ON(_COMPAT_NSIG_WORDS != 2);
case 3: seta[5] = (oldset->sig[2] >> 32); seta.sig[1] = (oldset->sig[0] >> 32);
seta[4] = oldset->sig[2]; seta.sig[0] = oldset->sig[0];
case 2: seta[3] = (oldset->sig[1] >> 32);
seta[2] = oldset->sig[1]; err |= __put_user(seta.sig[0], &sf->info.si_mask);
case 1: seta[1] = (oldset->sig[0] >> 32); err |= __copy_to_user(sf->extramask, &seta.sig[1],
seta[0] = oldset->sig[0];
}
err |= __put_user(seta[0], &sf->info.si_mask);
err |= __copy_to_user(sf->extramask, seta + 1,
(_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
if (!wsaved) { if (!wsaved) {
...@@ -623,16 +610,8 @@ static int setup_rt_frame32(struct ksignal *ksig, struct pt_regs *regs, ...@@ -623,16 +610,8 @@ static int setup_rt_frame32(struct ksignal *ksig, struct pt_regs *regs,
/* Setup sigaltstack */ /* Setup sigaltstack */
err |= __compat_save_altstack(&sf->stack, regs->u_regs[UREG_FP]); err |= __compat_save_altstack(&sf->stack, regs->u_regs[UREG_FP]);
switch (_NSIG_WORDS) { seta.sig[1] = (oldset->sig[0] >> 32);
case 4: seta.sig[7] = (oldset->sig[3] >> 32); seta.sig[0] = oldset->sig[0];
seta.sig[6] = oldset->sig[3];
case 3: seta.sig[5] = (oldset->sig[2] >> 32);
seta.sig[4] = oldset->sig[2];
case 2: seta.sig[3] = (oldset->sig[1] >> 32);
seta.sig[2] = oldset->sig[1];
case 1: seta.sig[1] = (oldset->sig[0] >> 32);
seta.sig[0] = oldset->sig[0];
}
err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t)); err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
if (!wsaved) { if (!wsaved) {
......
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