Date: Thu, 12 Apr 2012 19:06:56 +0400 From: Sergey Kandaurov <pluknet@freebsd.org> To: John Baldwin <jhb@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234186 - head/sys/kern Message-ID: <CAE-mSOJUD4%2BiGXDhDPi%2Bvt4JjbPUa5A0sPN5CtqiCnA3kbv9Hg@mail.gmail.com> In-Reply-To: <201204121449.q3CEnP8L033082@svn.freebsd.org> References: <201204121449.q3CEnP8L033082@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 12 April 2012 18:49, John Baldwin <jhb@freebsd.org> wrote: > Author: jhb > Date: Thu Apr 12 14:49:25 2012 > New Revision: 234186 > URL: http://svn.freebsd.org/changeset/base/234186 > > Log: > =A0If a linker file contains at least one module, but all of the modules > =A0fail to load (the MOD_LOAD event fails) during a kldload(2), unload th= e > =A0linker file and fail the kldload(2) with ENOEXEC. > > =A0Reported by: =A0gcooper > =A0MFC after: =A0 =A01 week > > Modified: > =A0head/sys/kern/kern_linker.c > > Modified: head/sys/kern/kern_linker.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/kern/kern_linker.c Thu Apr 12 14:06:05 2012 =A0 =A0 =A0 =A0(= r234185) > +++ head/sys/kern/kern_linker.c Thu Apr 12 14:49:25 2012 =A0 =A0 =A0 =A0(= r234186) > @@ -380,7 +380,7 @@ linker_load_file(const char *filename, l > =A0{ > =A0 =A0 =A0 =A0linker_class_t lc; > =A0 =A0 =A0 =A0linker_file_t lf; > - =A0 =A0 =A0 int foundfile, error; > + =A0 =A0 =A0 int foundfile, error, modules; > > =A0 =A0 =A0 =A0/* Refuse to load modules if securelevel raised */ > =A0 =A0 =A0 =A0if (prison0.pr_securelevel > 0) > @@ -419,11 +419,22 @@ linker_load_file(const char *filename, l > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0linker_fil= e_unload(lf, LINKER_UNLOAD_FORCE); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (er= ror); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 modules =3D !TAILQ_EMPTY(&l= f->modules); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0KLD_UNLOCK(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0linker_file_register_sysct= ls(lf); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0linker_file_sysinit(lf); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0KLD_LOCK(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0lf->flags |=3D LINKER_FILE= _LINKED; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* If all of the modules = in this file failed > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* to load, unload the fi= le and return an > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* error of ENOEXEC. > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (modules && TAILQ_EMPTY(= &lf->modules)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 linker_file= _unload(lf, LINKER_UNLOAD_FORCE); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (ENO= EXEC); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*result =3D lf; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (0); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > @@ -627,7 +638,7 @@ linker_file_unload(linker_file_t file, i > > =A0 =A0 =A0 =A0/* > =A0 =A0 =A0 =A0 * Inform any modules associated with this file that they = are > - =A0 =A0 =A0 =A0* being be unloaded. > + =A0 =A0 =A0 =A0* being unloaded. > =A0 =A0 =A0 =A0 */ > =A0 =A0 =A0 =A0MOD_XLOCK; > =A0 =A0 =A0 =A0for (mod =3D TAILQ_FIRST(&file->modules); mod; mod =3D nex= t) { Thanks. I have had exactly this change in my local tree, but I didn't commit it for some reasons I don't recall... --=20 wbr, pluknet
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAE-mSOJUD4%2BiGXDhDPi%2Bvt4JjbPUa5A0sPN5CtqiCnA3kbv9Hg>