Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Oct 2002 22:40:11 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Daniel Eischen <eischen@vigrid.com>
Cc:        current@FreeBSD.ORG
Subject:   Re: Longer term fix for sigreturn ABI breaking
Message-ID:  <20021002222754.W518-100000@gamplex.bde.org>
In-Reply-To: <3D98BF1A.4A58EE74@vigrid.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 30 Sep 2002, Daniel Eischen wrote:

> At the end is a potentially longer term fix for the ABI
> breakage that was introduced when the i386 mcontext_t
> was changed/enlarged.
>
> Someone other than I (Bruce?) should vet this.  It should
> solve the libc_r binary compatibility problem, but it may
> not fix everything.  Applications that copy ucontext_t's
> around (without changing corrupting the mc_fpformat field)
> will still break, but there may not be many (if any) of
> those.
> ...
> Index: i386/i386/machdep.c
> ===================================================================
> RCS file: /opt/d/CVS/src/sys/i386/i386/machdep.c,v
> retrieving revision 1.539
> diff -u -r1.539 machdep.c
> --- i386/i386/machdep.c	30 Sep 2002 07:02:22 -0000	1.539
> +++ i386/i386/machdep.c	30 Sep 2002 20:42:30 -0000
> ...
> @@ -754,9 +754,15 @@
>  			return (EINVAL);
>  		}
>
> -		ret = set_fpcontext(td, &ucp->uc_mcontext);
> -		if (ret != 0)
> -			return (ret);
> +		/*
> +		 * Intentionally ignore the error to keep binary
> +		 * compatibility with applications that fiddle with
> +		 * the FPU save area in the context.  The kernel
> +		 * now saves the FPU state in the context, but it
> +		 * gets corrupted by those applications that try
> +		 * to work around the kernel NOT saving it.
> +		 */
> +		(void)set_fpcontext(td, &ucp->uc_mcontext);
>  		bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs));
>  	}
>
> ...

I think this is a bit too simple.  If set_fpcontext() fails then the
interrupted code may resume with a garbage FP context (most likely
whatever is in the PCB).  Snipped parts of the patch back out the
temporary hack of forcing of the state to the PCB in sendsig(), so
the resumed FP context is quite like likely to be garbage.

I think not using the parts of the state that is corrupted by
applications would work better (basically the same as the temporary
hack, except it would waste time instead of space).  The space
wastage would be approximately 28 * 4 bytes.  This would be wasted
forever or until the struct is versioned better.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021002222754.W518-100000>