From owner-freebsd-bugs Mon Mar 3 16:00:06 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id QAA07586 for bugs-outgoing; Mon, 3 Mar 1997 16:00:06 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id QAA07556; Mon, 3 Mar 1997 16:00:03 -0800 (PST) Resent-Date: Mon, 3 Mar 1997 16:00:03 -0800 (PST) Resent-Message-Id: <199703040000.QAA07556@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, mks@msc.edu Received: from salo.msci.magic.net (salo.msci.magic.net [137.66.176.16]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id PAA07227 for ; Mon, 3 Mar 1997 15:53:47 -0800 (PST) Received: (from mks@localhost) by salo.msci.magic.net (8.7.5/8.7.3) id RAA00607; Mon, 3 Mar 1997 17:53:14 -0600 (CST) Message-Id: <199703032353.RAA00607@salo.msci.magic.net> Date: Mon, 3 Mar 1997 17:53:14 -0600 (CST) From: mks@msc.edu Reply-To: mks@msc.edu To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/2864: Using modload with -p option Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 2864 >Category: bin >Synopsis: Using modload with -p option broken >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 3 16:00:01 PST 1997 >Last-Modified: >Originator: Mike Spengler >Organization: Minnesota Supercomputer Center, Inc. >Release: FreeBSD 2.1-STABLE i386 >Environment: >Description: There are two problems when using modload -p : 1. If the -u option is also specified, the loaded output file is never deleted; 2. The /dev/lkm device isn't closed before calling the post-install program, thus modload still holds the exclusive lock on /dev/lkm. If the post-install program then tries to use modstat (to figure out name of loaded module) it will hang on its open(/dev/lkm) and thus the modload itself will hang waiting for the install program to complete. >How-To-Repeat: o create the following shell script (call it mod_loaded) #!/bin/sh # PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH MODID=$1 MOD=`modstat -i ${MODID} | awk ' $2 == modid { print $NF; exit; }' modid=${MODID}` echo "module loaded was ${MOD}" exit 0 o pick your favorite loadable module (mymod) and, modload -u -e -o /tmp/mymod -p mod_loaded mymod.o o this should hang the modload and its invocation of mod_loaded and will also not delete /tmp/mymod. >Fix: --- modload.c.orig Tue May 30 01:09:20 1995 +++ modload.c Mon Mar 3 17:03:40 1997 @@ -358,6 +358,12 @@ fileopen &= ~PART_RESRV; /* loaded */ if(!quiet) printf("Module loaded as ID %d\n", resrv.slot); + if(dounlink) { + if(unlink(out)) { + err(17, "unlink(%s)", out); + } + } + if (post) { struct lmc_stat sbuf; char id[16], type[16], offset[16]; @@ -370,14 +376,12 @@ sprintf(offset, "%d", sbuf.offset); /* XXX the modload docs say that drivers can install bdevsw & cdevsw, but the interface only supports one at a time. sigh. */ + + /* Free resources before calling post-install program */ + cleanup(); + execl(post, post, id, type, offset, 0); err(16, "can't exec '%s'", post); - } - - if(dounlink) { - if(unlink(out)) { - err(17, "unlink(%s)", out); - } } return 0; >Audit-Trail: >Unformatted: