Skip to contentSkip to conversation

(re)register_binfmt returns with -EBUSY

PATCH In review kalash nainwal 2 participants 2 messages Apr 2, 2007 – Apr 3, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 (re)register_binfmt returns with -EBUSY

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

fs/exec.c +1 -0
@@ -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;
 		}
#1 lore raw
Quoted 10 lines · On Mon, 2 Apr 2007 18:24:15 +0530 "kalash nainwal" <[email protected]>…

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...