public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] (re)register_binfmt returns with -EBUSY
@ 2007-04-02 12:54 kalash nainwal
  2007-04-03  0:40 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: kalash nainwal @ 2007-04-02 12:54 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

When a binary format is unregistered and re-registered,
register_binfmt fails with -EBUSY. The reason is that
unregister_binfmt does not set fmt->next to NULL, and seeing
(fmt->next != NULL), register_binfmt fails with -EBUSY.

One can find his way around by explicitly setting fmt->next to NULL
after unregistering, but that is kind of unclean (one should better be
using only the interfaces, and not the interal members, isn't it?)

Attached one-liner can fix it (for 2.6.20).

Regards,
-Kalash


Signed-off-by: Kalash Nainwal <kalash.nainwal@gmail.com>

[-- Attachment #2: lnx_binfmt.patch --]
[-- Type: application/octet-stream, Size: 330 bytes --]

--- linux-2.6.20/fs/exec.c	2007-02-05 00:14:54.000000000 +0530
+++ linux-2.6.20_modified/fs/exec.c	2007-04-02 17:56:56.369105272 +0530
@@ -100,6 +100,7 @@ int unregister_binfmt(struct linux_binfm
 	while (*tmp) {
 		if (fmt == *tmp) {
 			*tmp = fmt->next;
+			fmt->next = NULL;
 			write_unlock(&binfmt_lock);
 			return 0;
 		}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] (re)register_binfmt returns with -EBUSY
  2007-04-02 12:54 [PATCH] (re)register_binfmt returns with -EBUSY kalash nainwal
@ 2007-04-03  0:40 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2007-04-03  0:40 UTC (permalink / raw)
  To: kalash nainwal; +Cc: linux-kernel

On Mon, 2 Apr 2007 18:24:15 +0530
"kalash nainwal" <kalash.nainwal@gmail.com> wrote:

> When a binary format is unregistered and re-registered,
> register_binfmt fails with -EBUSY. The reason is that
> unregister_binfmt does not set fmt->next to NULL, and seeing
> (fmt->next != NULL), register_binfmt fails with -EBUSY.
> 
> One can find his way around by explicitly setting fmt->next to NULL
> after unregistering, but that is kind of unclean (one should better be
> using only the interfaces, and not the interal members, isn't it?)
> 
> Attached one-liner can fix it (for 2.6.20).

Yes, that'll fix it.

But I wonder why register_binfmt() even checks that the to-be-registered
linux_binfmt has a non-null fmt->next?  Presumably that's there to catch
erroneous re-registration of an already-registered format.

All very odd.  It looks like that code should be converted to list_heads
anyway...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-04-03  0:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-02 12:54 [PATCH] (re)register_binfmt returns with -EBUSY kalash nainwal
2007-04-03  0:40 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox