Skip to contentSkip to conversation

+ use-list_head-in-binfmt-handling-fix.patch added to -mm tree

PATCH New [email protected] 2 participants 2 messages Jul 25, 2007

Subsystems (3)
lore
Share & tools
lore

[email protected]

author tree notice
#0 lore raw

The patch titled
use-list_head-in-binfmt-handling fix
has been added to the -mm tree. Its filename is
use-list_head-in-binfmt-handling-fix.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this

------------------------------------------------------
Subject: use-list_head-in-binfmt-handling fix
From: Andrew Morton <[email protected]>

arch/sparc64/kernel/binfmt_aout32.c:41: warning: missing braces around initializer arch/sparc64/kernel/binfmt_aout32.c:41: warning: (near initialization for `aout32_format.lh') arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:43: warning: initialization makes pointer from integer without a cast

please grep for more missed instances?

Cc Alexey Dobriyan <[email protected]>

---

 arch/sparc64/kernel/binfmt_aout32.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/sparc64/kernel/binfmt_aout32.c renamed from arch/sparc64/kernel/binfmt_aout32.c~use-list_head-in-binfmt-handling-fix +6 -2
diff -puN arch/sparc64/kernel/binfmt_aout32.c~use-list_head-in-binfmt-handling-fix arch/sparc64/kernel/binfmt_aout32.c
@@ -38,8 +38,12 @@ static int load_aout32_library(struct fi
 static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file);
 
 static struct linux_binfmt aout32_format = {
-	NULL, THIS_MODULE, load_aout32_binary, load_aout32_library, aout32_core_dump,
-	PAGE_SIZE
+	.lh	=	LIST_HEAD_INIT(aout32_format.lh),
+	.module =	THIS_MODULE,
+	.load_binary =	load_aout32_binary,
+	.load_shlib =	load_aout32_library,
+	.core_dump =	aout32_core_dump,
+	.min_coredump =	PAGE_SIZE,
 };
 
 static void set_brk(unsigned long start, unsigned long end)

_

Patches currently in -mm which might be from [email protected] are

origin.patch
rtc-stk17ta8-update-for-sysfs-api-change.patch x86_powernow_k8_acpi-must-depend-on-acpi.patch revert-x86-serial-convert-legacy-com-ports-to-platform-devices.patch ufs-printk-warning-fix.patch
i2c-ds1682-warning-fix.patch
edac-is-bust-on-mips.patch kdebugh-forward-declare-struct-struct-notifier_block.patch slow-down-printk-during-boot.patch
slow-down-printk-during-boot-fix-2.patch
git-acpi.patch
git-acpi-build-fix.patch
acpi-add-reboot-mechanism-fix.patch working-3d-dri-intel-agpko-resume-for-i815-chip.patch revert-gregkh-driver-block-device.patch
dma-arch-fix.patch
ia64-rename-partial_page.patch
adbhid-produce-all-capslock-key-events-fix.patch m68k-mac-make-mac_hid_mouse_emulate_buttons.patch
iforce-warning-fix.patch
git-kvm.patch
libata-arm-ioh-needs-iomaph.patch libata-add-irq_flags-to-struct-pata_platform_info-fix.patch ata-add-the-sw-ncq-support-to-sata_nv-for-mcp51-mcp55-mcp61-fix.patch fix-ide-ide-add-ide-set-pio-take3.patch ide-bodge-things-around-to-make-arm-work.patch
mmc-build-fix.patch
git-mtd.patch
git-mtd-fix-printk-warning-in-jffs2_block_check_erase.patch mtdoops-printk-warning-fixes.patch
ax88796-printk-fixes.patch
e1000new-build-fix.patch
e1000new-build-fix-2.patch
ip_auto_config-fix-fix.patch
git-ocfs2.patch serial-8250-handle-saving-the-clear-on-read-bits-from-the-lsr-fix.patch add-blacklisting-capability-to-serial_pci-to-avoid-misdetection-fix.patch revert-gregkh-pci-pci_bridge-device.patch i386-add-support-for-picopower-irq-router.patch try-parent-numa_node-at-first-before-using-default-v2-fix.patch pci-remove-irritating-try-pci=assign-busses-warning.patch aacraid-rename-check_reset.patch
git-scsi-rc-fixes.patch
git-scsi-target-fixup.patch
git-block-fixup.patch
git-block-fixup-2.patch
git-block-fix-headers_check.patch
git-block-whoops.patch
more-request_queue_t-removal.patch
git-unionfs.patch
merge-the-sonics-silicon-backplane-subsystem-fix.patch
git-watchdog.patch
x86_64-clean-up-apicid_to_node-declaration.patch x86_64-dynticks-disable-hpet_id_legsup-hpets.patch mmconfig-validate-against-acpi-motherboard-resources.patch git-newsetup-fixup.patch
git-kgdb-fixup.patch
git-kgdb-arm-fix.patch
git-kgdb-mips-fix.patch vmscan-give-referenced-active-and-unmapped-pages-a-second-trip-around-the-lru.patch sparsemem-record-when-a-section-has-a-valid-mem_map-fix.patch readahead-combine-file_ra_stateprev_index-prev_offset-into-prev_pos-fix.patch readahead-combine-file_ra_stateprev_index-prev_offset-into-prev_pos-fix-2.patch fs-introduce-write_begin-write_end-and-perform_write-aops.patch bias-the-location-of-pages-freed-for-min_free_kbytes-in-the-same-max_order_nr_pages-blocks.patch maps2-move-the-page-walker-code-to-lib.patch maps2-add-proc-pid-pagemap-interface.patch maps2-make-proc-pid-smaps-optional-under-config_embeddedpatch-fix.patch slub-slab-validation-move-tracking-information-alloc-outside-of-melstuff.patch hugetlbfs-read-support-fix.patch security-convert-lsm-into-a-static-interface-fix.patch security-convert-lsm-into-a-static-interface-fix-2.patch security-convert-lsm-into-a-static-interface-fix-unionfs.patch file-capabilities-clear-caps-cleanup-fix.patch capabilityh-remove-include-of-currenth.patch cache-pipe-buf-page-address-for-non-highmem-arch.patch use-list_head-in-binfmt-handling-fix.patch softlockup-add-a-proc-tuning-parameter-fix.patch force-erroneous-inclusions-of-compiler-h-files-to-be-errors-fix.patch driver-for-the-atmel-on-chip-ssc-on-at32ap-and-at91-fix.patch add-kernel-notifierc-fix.patch
fs-9p-convc-error-path-fix.patch
loop-use-unlocked_ioctl.patch do_sys_poll-simplify-playing-with-on-stack-data-fix.patch pcmcia-compactflash-driver-for-pa-semi-electra-boards.patch allow-individual-core-dump-methods-to-be-unlimited-when-sending-to-a-pipe-fix.patch allow-individual-core-dump-methods-to-be-unlimited-when-sending-to-a-pipe-fix-2-fix.patch ip2main-warning-fix.patch writeback-fix-time-ordering-of-the-per-superblock-dirty-inode-lists.patch writeback-fix-time-ordering-of-the-per-superblock-dirty-inode-lists-2.patch writeback-fix-time-ordering-of-the-per-superblock-dirty-inode-lists-3.patch writeback-fix-time-ordering-of-the-per-superblock-dirty-inode-lists-4.patch writeback-fix-comment-use-helper-function.patch writeback-fix-time-ordering-of-the-per-superblock-dirty-inode-lists-5.patch writeback-fix-time-ordering-of-the-per-superblock-dirty-inode-lists-6.patch writeback-fix-time-ordering-of-the-per-superblock-dirty-inode-lists-7.patch revert-faster-ext2_clear_inode.patch
ecryptfs-printk-warning-fixes.patch intel-iommu-pci-generic-helper-function.patch intel-iommu-iova-allocation-and-management-routines.patch intel-iommu-intel-iommu-driver.patch
intel-iommu-iommu-floppy-workaround.patch
64-bit-i_version-afs-fixes.patch
revoke-wire-up-i386-system-calls.patch
revoke-vs-git-block.patch
add-containerstats-v3-fix.patch pid-namespaces-dynamic-kmem-cache-allocator-for-pid-namespaces-fix.patch pid-namespaces-define-is_global_init-and-is_container_init-fix.patch fs-superc-use-list_for_each_entry-instead-of-list_for_each-fix.patch reiser4.patch
git-block-vs-reiser4.patch
page-owner-tracking-leak-detector.patch
check_dirty_inode_list.patch
alloc_pages-debug.patch
w1-build-fix.patch

#1 lore raw

PATCH v2 1/2 Use list_head in binfmt handling

Quoted 13 lines · On Tue, Jul 24, 2007 at 10:16:44PM -0700, [email protected] wrote:

arch/sparc64/kernel/binfmt_aout32.c:41: warning: missing braces around initializer arch/sparc64/kernel/binfmt_aout32.c:41: warning: (near initialization for `aout32_format.lh') arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:41: warning: initialization from incompatible pointer type arch/sparc64/kernel/binfmt_aout32.c:43: warning: initialization makes pointer from integer without a cast

arch/sparc64/kernel/binfmt_aout32.c renamed from arch/sparc64/kernel/binfmt_aout32.c~use-list_head-in-binfmt-handling-fix +0 -0
@@ -38,8 +38,12 @@ static int load_aout32_library(struct fi
 static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file);
 

arch/sparc64/kernel/binfmt_aout32.c static int load_aout32_library(struct fi · line 47

Quoted 10 lines
arch/sparc64/kernel/binfmt_aout32.c renamed from arch/sparc64/kernel/binfmt_aout32.c~use-list_head-in-binfmt-handling-fix +6 -2
 static struct linux_binfmt aout32_format = {
-	NULL, THIS_MODULE, load_aout32_binary, load_aout32_library, aout32_core_dump,
-	PAGE_SIZE
+	.lh	=	LIST_HEAD_INIT(aout32_format.lh),
+	.module =	THIS_MODULE,
+	.load_binary =	load_aout32_binary,
+	.load_shlib =	load_aout32_library,
+	.core_dump =	aout32_core_dump,
+	.min_coredump =	PAGE_SIZE,
 };

Doh! Thanks, Andrew.

list_head initialization is unneeded, because register_binfmt() will reinitialize it anyway.

Here is final version which was test-compiled on sparc64 and on mips (after irixelf.c BROKEN removal):

[PATCH 1/2] Use list_head in binfmt handling

Switch single-linked binfmt formats list to usual list_head's. This leads to one-liners in register_binfmt() and unregister_binfmt(). The downside is one pointer more in struct linux_binfmt. This is not a problem, since the set of registered binfmts on typical box is very small -- (ELF + something distro enabled for you).

Test-booted, played with executable .txt files, modprobe/rmmod binfmt_misc.

---

 arch/mips/kernel/irixelf.c          |    7 +++++--
 arch/sparc64/kernel/binfmt_aout32.c |    7 +++++--
 fs/exec.c                           |   34 ++++++----------------------------
 include/linux/binfmts.h             |    2 +-
 4 files changed, 17 insertions(+), 33 deletions(-)
arch/mips/kernel/irixelf.c +5 -2
@@ -47,8 +47,11 @@ static int irix_core_dump(long signr, struct pt_regs * regs,
                           struct file *file);
 
 static struct linux_binfmt irix_format = {
-	NULL, THIS_MODULE, load_irix_binary, load_irix_library,
-	irix_core_dump, PAGE_SIZE
+	.module		= THIS_MODULE,
+	.load_binary	= load_irix_binary,
+	.load_shlib	= load_irix_library,
+	.core_dump	= irix_core_dump,
+	.min_coredump	= PAGE_SIZE,
 };
 
 /* Debugging routines. */
arch/sparc64/kernel/binfmt_aout32.c +5 -2
@@ -38,8 +38,11 @@ static int load_aout32_library(struct file*);
 static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file);
 
 static struct linux_binfmt aout32_format = {
-	NULL, THIS_MODULE, load_aout32_binary, load_aout32_library, aout32_core_dump,
-	PAGE_SIZE
+	.module		= THIS_MODULE,
+	.load_binary	= load_aout32_binary,
+	.load_shlib	= load_aout32_library,
+	.core_dump	= aout32_core_dump,
+	.min_coredump	= PAGE_SIZE,
 };
 
 static void set_brk(unsigned long start, unsigned long end)
fs/exec.c +6 -28
@@ -67,27 +67,15 @@ int suid_dumpable = 0;
 EXPORT_SYMBOL(suid_dumpable);
 /* The maximal length of core_pattern is also specified in sysctl.c */
 
-static struct linux_binfmt *formats;
+static LIST_HEAD(formats);
 static DEFINE_RWLOCK(binfmt_lock);
 
 int register_binfmt(struct linux_binfmt * fmt)
 {
-	struct linux_binfmt ** tmp = &formats;
-
 	if (!fmt)
 		return -EINVAL;
-	if (fmt->next)
-		return -EBUSY;
 	write_lock(&binfmt_lock);
-	while (*tmp) {
-		if (fmt == *tmp) {
-			write_unlock(&binfmt_lock);
-			return -EBUSY;
-		}
-		tmp = &(*tmp)->next;
-	}
-	fmt->next = formats;
-	formats = fmt;
+	list_add(&fmt->lh, &formats);
 	write_unlock(&binfmt_lock);
 	return 0;	
 }
@@ -96,20 +84,10 @@ EXPORT_SYMBOL(register_binfmt);
 
 int unregister_binfmt(struct linux_binfmt * fmt)
 {
-	struct linux_binfmt ** tmp = &formats;
-
 	write_lock(&binfmt_lock);
-	while (*tmp) {
-		if (fmt == *tmp) {
-			*tmp = fmt->next;
-			fmt->next = NULL;
-			write_unlock(&binfmt_lock);
-			return 0;
-		}
-		tmp = &(*tmp)->next;
-	}
+	list_del(&fmt->lh);
 	write_unlock(&binfmt_lock);
-	return -EINVAL;
+	return 0;
 }
 
 EXPORT_SYMBOL(unregister_binfmt);
@@ -156,7 +134,7 @@ asmlinkage long sys_uselib(const char __user * library)
 		struct linux_binfmt * fmt;
 
 		read_lock(&binfmt_lock);
-		for (fmt = formats ; fmt ; fmt = fmt->next) {
+		list_for_each_entry(fmt, &formats, lh) {
 			if (!fmt->load_shlib)
 				continue;
 			if (!try_module_get(fmt->module))
@@ -1290,7 +1268,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
 	retval = -ENOENT;
 	for (try=0; try<2; try++) {
 		read_lock(&binfmt_lock);
-		for (fmt = formats ; fmt ; fmt = fmt->next) {
+		list_for_each_entry(fmt, &formats, lh) {
 			int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary;
 			if (!fn)
 				continue;
include/linux/binfmts.h +1 -1
@@ -63,7 +63,7 @@ struct linux_binprm{
  * linux accepts.
  */
 struct linux_binfmt {
-	struct linux_binfmt * next;
+	struct list_head lh;
 	struct module *module;
 	int (*load_binary)(struct linux_binprm *, struct  pt_regs * regs);
 	int (*load_shlib)(struct file *);