Date: Thu, 12 Apr 2012 19:10:10 +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-mSOJ8_odgJoEO=GjhDB2rDX0T58O925P9KR_azhmfDwvUbg@mail.gmail.com> In-Reply-To: <CAE-mSOJUD4%2BiGXDhDPi%2Bvt4JjbPUa5A0sPN5CtqiCnA3kbv9Hg@mail.gmail.com> References: <201204121449.q3CEnP8L033082@svn.freebsd.org> <CAE-mSOJUD4%2BiGXDhDPi%2Bvt4JjbPUa5A0sPN5CtqiCnA3kbv9Hg@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
On 12 April 2012 19:06, Sergey Kandaurov <pluknet@freebsd.org> wrote: > 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: >> If a linker file contains at least one module, but all of the modules >> fail to load (the MOD_LOAD event fails) during a kldload(2), unload the >> linker file and fail the kldload(2) with ENOEXEC. >> >> Reported by: gcooper >> MFC after: 1 week >> >> Modified: >> head/sys/kern/kern_linker.c >> >> Modified: head/sys/kern/kern_linker.c >> ============================================================================== >> --- head/sys/kern/kern_linker.c Thu Apr 12 14:06:05 2012 (r234185) >> +++ head/sys/kern/kern_linker.c Thu Apr 12 14:49:25 2012 (r234186) >> @@ -380,7 +380,7 @@ linker_load_file(const char *filename, l >> { >> linker_class_t lc; >> linker_file_t lf; >> - int foundfile, error; >> + int foundfile, error, modules; >> >> /* Refuse to load modules if securelevel raised */ >> if (prison0.pr_securelevel > 0) >> @@ -419,11 +419,22 @@ linker_load_file(const char *filename, l >> linker_file_unload(lf, LINKER_UNLOAD_FORCE); >> return (error); >> } >> + modules = !TAILQ_EMPTY(&lf->modules); >> KLD_UNLOCK(); >> linker_file_register_sysctls(lf); >> linker_file_sysinit(lf); >> KLD_LOCK(); >> lf->flags |= LINKER_FILE_LINKED; >> + >> + /* >> + * If all of the modules in this file failed >> + * to load, unload the file and return an >> + * error of ENOEXEC. >> + */ >> + if (modules && TAILQ_EMPTY(&lf->modules)) { >> + linker_file_unload(lf, LINKER_UNLOAD_FORCE); >> + return (ENOEXEC); >> + } >> *result = lf; >> return (0); >> } >> @@ -627,7 +638,7 @@ linker_file_unload(linker_file_t file, i >> >> /* >> * Inform any modules associated with this file that they are >> - * being be unloaded. >> + * being unloaded. >> */ >> MOD_XLOCK; >> for (mod = TAILQ_FIRST(&file->modules); mod; mod = next) { > > Thanks. I have had exactly this change in my local tree, > but I didn't commit it for some reasons I don't recall... Doh, I have had something different.. Sorry. -- wbr, pluknethelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAE-mSOJ8_odgJoEO=GjhDB2rDX0T58O925P9KR_azhmfDwvUbg>
