[Cbe-oss-dev] PATCH 19/21] powerpc: Merge creation of signal frame (#2)

Christoph Hellwig hch at lst.de
Mon Jun 4 18:01:26 EST 2007


On Mon, Jun 04, 2007 at 05:22:48PM +1000, Benjamin Herrenschmidt wrote:
> +/*
> + * Allocate space for the signal frame
> + */
> +void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
> +			   size_t frame_size)

little style nitpick: no whitespace after the *, please.

> +{
> +        unsigned long oldsp, newsp;
> +
> +        /* Default to using normal stack */
> +        oldsp = regs->gpr[1];
> +
> +	/* Check for alt stack */
> +	if ((ka->sa.sa_flags & SA_ONSTACK) &&
> +	    current->sas_ss_size && !on_sig_stack(oldsp))
> +		oldsp = (current->sas_ss_sp + current->sas_ss_size);
> +
> +	/* Get aligned frame */
> +	newsp = (oldsp - frame_size) & ~0xFUL;
> +
> +	/* Check access */
> +	if (!access_ok(VERIFY_WRITE, (void __user *)newsp, oldsp - newsp))
> +		return NULL;
> +
> +        return (void __user *)newsp;
> +}

The body also has some odd whitespace problems.  I'd also make
newsp a void __user variable to only do the cast once.  In the end the
function should looks something like:

void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
		size_t frame_size)
{
	unsigned long oldsp;
	void __user *newsp;

	/* Check for alt stack */
	if ((ka->sa.sa_flags & SA_ONSTACK) &&
	    current->sas_ss_size && !on_sig_stack(oldsp))
		oldsp = (current->sas_ss_sp + current->sas_ss_size);
	else
		oldsp = regs->gpr[1];

	/* Get aligned frame */
	newsp = (void __user *)((oldsp - frame_size) & ~0xFUL);

	/* Check access */
	if (!access_ok(VERIFY_WRITE, newsp, oldsp - newsp))
		return NULL;

	return newsp;
}




More information about the cbe-oss-dev mailing list