mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-30 16:51:41 +00:00
Update userref handling after discussion with submitter of previous
patch. lf can't be dereferenced after the unload attempt, in case it was freed. Instead, decrement first and back it out if the unload failed. This should be relatively immune to races caused by the user since the userref count will be zero for the duration of the actual unloading and will stop further kldunload attempts. Submitted by: Ustimenko Semen <semen@iclub.nsu.ru>
This commit is contained in:
parent
2c9b3ec2ff
commit
461b36ab54
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43084
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: kern_linker.c,v 1.20 1999/01/19 16:26:32 peter Exp $
|
||||
* $Id: kern_linker.c,v 1.21 1999/01/19 22:26:46 peter Exp $
|
||||
*/
|
||||
|
||||
#include "opt_ddb.h"
|
||||
@ -680,14 +680,14 @@ kldunload(struct proc* p, struct kldunload_args* uap)
|
||||
if (lf) {
|
||||
KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs));
|
||||
if (lf->userrefs == 0) {
|
||||
printf("linkerunload: attempt to unload file which was not loaded by user\n");
|
||||
printf("linkerunload: attempt to unload file that was loaded by the kernel\n");
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
lf->userrefs--;
|
||||
error = linker_file_unload(lf);
|
||||
if (error)
|
||||
goto out;
|
||||
lf->userrefs--;
|
||||
lf->userrefs++;
|
||||
} else
|
||||
error = ENOENT;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user