lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100601024439.GA5134@cr0.nay.redhat.com>
Date:	Tue, 1 Jun 2010 10:44:39 +0800
From:	Américo Wang <xiyou.wangcong@...il.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Rusty Russell <rusty@...tcorp.com.au>,
	Brandon Philips <brandon@...p.org>,
	"Rafael J. Wysocki" <rjw@...k.pl>,
	LKML <linux-kernel@...r.kernel.org>,
	Jon Masters <jonathan@...masters.org>,
	Tejun Heo <htejun@...il.com>,
	Masami Hiramatsu <mhiramat@...hat.com>,
	Kay Sievers <kay.sievers@...y.org>
Subject: Re: [PATCH 1/2] Make the module 'usage' lists be two-way

On Mon, May 31, 2010 at 01:16:23PM -0700, Linus Torvalds wrote:
>
>From: Linus Torvalds <torvalds@...ux-foundation.org>
>Date: Mon, 31 May 2010 12:19:37 -0700
>Subject: [PATCH 1/2] Make the module 'usage' lists be two-way
>
>When adding a module that depends on another one, we used to create a
>one-way list of "modules_which_use_me", so that module unloading could
>see who needs a module.
>
>It's actually quite simple to make that list go both ways: so that we
>not only can see "who uses me", but also see a list of modules that are
>"used by me".
>
>In fact, we always wanted that list in "module_unload_free()": when we
>unload a module, we want to also release all the other modules that are
>used by that module.  But because we didn't have that list, we used to
>first iterate over all modules, and then iterate over each "used by me"
>list of that module.
>
>By making the list two-way, we simplify module_unload_free(), and it
>allows for some trivial fixes later too.
>
>Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>

Hi, Linus,

> 
> /* Clear the unload stuff of the module. */
> static void module_unload_free(struct module *mod)
> {
>-	struct module *i;
>+	struct module_use *use, *tmp;
> 
>-	list_for_each_entry(i, &modules, list) {
>-		struct module_use *use;
>-
>-		list_for_each_entry(use, &i->modules_which_use_me, list) {
>-			if (use->module_which_uses == mod) {
>-				DEBUGP("%s unusing %s\n", mod->name, i->name);
>-				module_put(i);
>-				list_del(&use->list);
>-				kfree(use);
>-				sysfs_remove_link(i->holders_dir, mod->name);
>-				/* There can be at most one match. */
>-				break;
>-			}
>-		}
>+	list_for_each_entry_safe(use, tmp, &mod->target_list, target_list) {
>+		struct module *i = use->target;
>+		DEBUGP("%s unusing %s\n", mod->name, i->name);
>+		module_put(i);
>+		list_del(&use->source_list);
>+		list_del(&use->target_list);
>+		kfree(use);
>+		sysfs_remove_link(i->holders_dir, mod->name);


I think it's nice to have a remove_module_usage() here, since we already
have add_module_usage().

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ