PERFORCE change 112535 for review
John Baldwin
jhb at freebsd.org
Tue Jan 9 13:12:28 PST 2007
On Tuesday 09 January 2007 15:33, Divacky Roman wrote:
> On Tue, Jan 09, 2007 at 01:17:06PM -0500, John Baldwin wrote:
> > > > > @@ -237,12 +237,10 @@
> > > > >
> > > > > pr = td->td_ucred->cr_prison;
> > > > > if (pr != NULL) {
> > > > > - mtx_lock(&pr->pr_mtx);
> > > > > if (pr->pr_linux != NULL) {
> > > > > lpr = (struct linux_prison *)pr->pr_linux;
> > > > > use26 = lpr->pr_use_linux26;
> > > > > }
> > > > > - mtx_unlock(&pr->pr_mtx);
> > > > > } else
> > > > > use26 = linux_use_linux26;
> > > > >
> > > > >
> > > >
> > > > Hmm, what is use26 set to if pr != NULL but pr->pr_linux == NULL?
> > >
> > > to the default value of 0
> >
> > Shouldn't it be set to linux_use_26 in that case?
>
> as I understand the code such condition should not happen under
> normal condition and is a sign of something bad's going on.
No, it is quite normal. By default linux processes in a jail use the base
system's settings. When you go to change a setting via sysctl inside a jail,
then that jail grows its own linux prison "on demand" to hold those settings
and not change the settings in the base system. The case you are ignoring
here is that the sysadmin has set the Linux OS version for the base system to
be "2.6.12". By default all jails should be inheriting that. In fact,
linux_get_osname() will return "2.6.12", so glibc inside the jail will think
it is on a 2.6.x system, as will 'uname'. However, the linux compat layer
will incorrectly think it isn't and apps will probably break.
Look at linux_get_osname()'s logic for example:
void
linux_get_osname(struct thread *td, char *dst)
{
register struct prison *pr;
register struct linux_prison *lpr;
pr = td->td_ucred->cr_prison;
if (pr != NULL) {
mtx_lock(&pr->pr_mtx);
if (pr->pr_linux != NULL) {
lpr = (struct linux_prison *)pr->pr_linux;
if (lpr->pr_osname[0]) {
bcopy(lpr->pr_osname, dst, LINUX_MAX_UTSNAME);
mtx_unlock(&pr->pr_mtx);
return;
}
}
mtx_unlock(&pr->pr_mtx);
}
mtx_lock(&osname_lock);
bcopy(linux_osname, dst, LINUX_MAX_UTSNAME);
mtx_unlock(&osname_lock);
}
--
John Baldwin
More information about the p4-projects
mailing list