Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jun 2006 10:02:25 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Roman Divacky <rdivacky@freebsd.org>
Cc:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   Re: PERFORCE change 99406 for review
Message-ID:  <200606191002.26358.jhb@freebsd.org>
In-Reply-To: <200606170857.k5H8vYVk017130@repoman.freebsd.org>
References:  <200606170857.k5H8vYVk017130@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 17 June 2006 04:57, Roman Divacky wrote:
> http://perforce.freebsd.org/chv.cgi?CH=3D99406
>=20
> Change 99406 by rdivacky@rdivacky_witten on 2006/06/17 08:56:59
>=20
> 	Change the emulpath sysctl to be per-prison.
>=20
> =3D=3D=3D=3D //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/l=
inux_mib.c#3 (text+ko) =3D=3D=3D=3D
>=20
> @@ -90,7 +90,7 @@
>  static int
>  linux_sysctl_linux_emul_path(SYSCTL_HANDLER_ARGS)
>  {
> -           char emul_path[LINUX_NAME_MAX];
> +           static char emul_path[LINUX_NAME_MAX];
>  	   int error;
>  	   Elf32_Brandinfo **brandinfo;
> =20
> @@ -99,10 +99,39 @@
>  	   if (error || req->newptr =3D=3D NULL)
>  	      	return (error);
>  	   error =3D linux_set_emul_path(req->td, emul_path);
> -	   for (brandinfo =3D &linux_brandlist[0]; *brandinfo !=3D NULL;
> -		 ++brandinfo)
> -	      	if (elf32_insert_brand_entry(*brandinfo) < 0)
> -		   error =3D EINVAL;	  =20
> +	   {
> +	        static Elf32_Brandinfo linux_brand =3D {
> +		   ELFOSABI_LINUX,
> +		   EM_386,
> +		   "Linux",
> +		   emul_path,
> +		   "/lib/ld-linux.so.1",
> +		   &elf_linux_sysvec,
> +		   NULL,
> +		   BI_CAN_EXEC_DYN,
> +		};
> +	        static Elf32_Brandinfo linux_glibc2brand =3D {
> +		   ELFOSABI_LINUX,
> +		   EM_386,
> +		   "Linux",
> +		   emul_path,
> +		   "/lib/ld-linux.so.2",
> +		   &elf_linux_sysvec,
> +		   NULL,
> +		   BI_CAN_EXEC_DYN,
> +		};
> +	=09
> +	        Elf32_Brandinfo *local_linux_brandlist[] =3D {
> +		   &linux_brand,
> +		   &linux_glibc2brand,
> +		   NULL
> +		};
> +
> +   	   	for (brandinfo =3D &local_linux_brandlist[0]; *brandinfo !=3D NU=
LL;
> +		 	++brandinfo)
> +	      		if (elf32_insert_brand_entry(*brandinfo) < 0)
> +		   		error =3D EINVAL;	  =20
> +	   }
>  	   return (error);
>  }

I don't think this is going to work because the brand lists aren't
per-prison, they are one shared list.  That is, once you create a
jail and try to change the path, the insert's will add new entries
to the end of the list, but an earlier entry for another jail
might handle the binary instead.  Also, elf32_insert_brand_entry()
saves the pointer you pass to it, and your pointers are for variables
that are on the stack which will become garbage when this function
returns.

=2D-=20
John Baldwin <jhb@FreeBSD.org> =A0<>< =A0http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org



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