rpms/kernel/F-9 linux-2.6-dev-zero-avoid-oom-lockup.patch, NONE, 1.1.2.1 linux-2.6-parport-quickfix-the-proc-registration-bug.patch, NONE, 1.1.2.1 kernel.spec, 1.891.2.54, 1.891.2.55

Chuck Ebbert cebbert at fedoraproject.org
Tue Jun 16 18:11:12 UTC 2009


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/F-9
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv22127

Modified Files:
      Tag: private-fedora-9-2_6_27-branch
	kernel.spec 
Added Files:
      Tag: private-fedora-9-2_6_27-branch
	linux-2.6-dev-zero-avoid-oom-lockup.patch 
	linux-2.6-parport-quickfix-the-proc-registration-bug.patch 
Log Message:
Avoid lockup on OOM with /dev/zero
Stop spewing useless warning on parport sysctl registration

linux-2.6-dev-zero-avoid-oom-lockup.patch:

--- NEW FILE linux-2.6-dev-zero-avoid-oom-lockup.patch ---
From: Salman Qazi <sqazi at google.com>
Date: Thu, 4 Jun 2009 22:20:39 +0000 (-0700)
Subject: drivers/char/mem.c: avoid OOM lockup during large reads from /dev/zero
X-Git-Tag: v2.6.30~31
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=730c586ad5228c339949b2eb4e72b80ae167abc4

drivers/char/mem.c: avoid OOM lockup during large reads from /dev/zero

While running 20 parallel instances of dd as follows:

  #!/bin/bash
  for i in `seq 1 20`; do
           dd if=/dev/zero of=/export/hda3/dd_$i bs=1073741824 count=1 &
  done
  wait

on a 16G machine, we noticed that rather than just killing the processes,
the entire kernel went down.  Stracing dd reveals that it first does an
mmap2, which makes 1GB worth of zero page mappings.  Then it performs a
read on those pages from /dev/zero, and finally it performs a write.

The machine died during the reads.  Looking at the code, it was noticed
that /dev/zero's read operation had been changed by
557ed1fa2620dc119adb86b34c614e152a629a80 ("remove ZERO_PAGE") from giving
zero page mappings to actually zeroing the page.

The zeroing of the pages causes physical pages to be allocated to the
process.  But, when the process exhausts all the memory that it can, the
kernel cannot kill it, as it is still in the kernel mode allocating more
memory.  Consequently, the kernel eventually crashes.

To fix this, I propose that when a fatal signal is pending during
/dev/zero read operation, we simply return and let the user process die.

Signed-off-by: Salman Qazi <sqazi at google.com>
Cc: Nick Piggin <nickpiggin at yahoo.com.au>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
[ Modified error return and comment trivially.  - Linus]
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 8f05c38..65e12bc 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -694,6 +694,9 @@ static ssize_t read_zero(struct file * file, char __user * buf,
 		written += chunk - unwritten;
 		if (unwritten)
 			break;
+		/* Consider changing this to just 'signal_pending()' with lots of testing */
+		if (fatal_signal_pending(current))
+			return written ? written : -EINTR;
 		buf += chunk;
 		count -= chunk;
 		cond_resched();

linux-2.6-parport-quickfix-the-proc-registration-bug.patch:

--- NEW FILE linux-2.6-parport-quickfix-the-proc-registration-bug.patch ---
From: Alan Cox <alan at etchedpixels.co.uk>
Date: Tue, 2 Jun 2009 15:58:10 +0000 (+0100)
Subject: parport: quickfix the proc registration bug
X-Git-Tag: v2.6.30-rc8~2
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=05ad709d04799125ed85dd816fdb558258102172

parport: quickfix the proc registration bug

Ideally we should have a directory of drivers and a link to the 'active'
driver. For now just show the first device which is effectively the existing
semantics without a warning.

This is an update on the original buggy patch that I then forgot to
resubmit. Confusingly it was proposed by Red Hat, written by Etched Pixels
fixed and submitted by Intel ...

Resolves-Bug: http://bugzilla.kernel.org/show_bug.cgi?id=9749
Signed-off-by: Alan Cox <alan at linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 0ebca45..dffa5d4 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -614,7 +614,10 @@ parport_register_device(struct parport *port, const char *name,
 	 * pardevice fields. -arca
 	 */
 	port->ops->init_state(tmp, tmp->state);
-	parport_device_proc_register(tmp);
+	if (!test_and_set_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags)) {
+		port->proc_device = tmp;
+		parport_device_proc_register(tmp);
+	}
 	return tmp;
 
  out_free_all:
@@ -646,10 +649,14 @@ void parport_unregister_device(struct pardevice *dev)
 	}
 #endif
 
-	parport_device_proc_unregister(dev);
-
 	port = dev->port->physport;
 
+	if (port->proc_device == dev) {
+		port->proc_device = NULL;
+		clear_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags);
+		parport_device_proc_unregister(dev);
+	}
+
 	if (port->cad == dev) {
 		printk(KERN_DEBUG "%s: %s forgot to release port\n",
 		       port->name, dev->name);
diff --git a/include/linux/parport.h b/include/linux/parport.h
index e1f83c5..38a423e 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -324,6 +324,10 @@ struct parport {
 	int spintime;
 	atomic_t ref_count;
 
+	unsigned long devflags;
+#define PARPORT_DEVPROC_REGISTERED	0
+	struct pardevice *proc_device;	/* Currently register proc device */
+
 	struct list_head full_list;
 	struct parport *slaves[3];
 };


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-9/kernel.spec,v
retrieving revision 1.891.2.54
retrieving revision 1.891.2.55
diff -u -p -r1.891.2.54 -r1.891.2.55
--- kernel.spec	15 Jun 2009 01:16:35 -0000	1.891.2.54
+++ kernel.spec	16 Jun 2009 18:10:40 -0000	1.891.2.55
@@ -753,6 +753,9 @@ Patch3110: linux-2.6-dmi-autoload.patch
 Patch4000: kvm-vmx-don-t-allow-uninhibited-access-to-efer-on-i386.patch
 Patch4010: kvm-make-efer-reads-safe-when-efer-does-not-exist.patch
 
+Patch11000: linux-2.6-parport-quickfix-the-proc-registration-bug.patch
+Patch11010: linux-2.6-dev-zero-avoid-oom-lockup.patch
+
 %endif
 
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
@@ -1353,6 +1356,11 @@ ApplyPatch linux-2.6-merge-efifb-imacfb.
 ApplyPatch kvm-vmx-don-t-allow-uninhibited-access-to-efer-on-i386.patch
 ApplyPatch kvm-make-efer-reads-safe-when-efer-does-not-exist.patch
 
+# finally fix the proc registration bug (F11#503773 and others)
+ApplyPatch linux-2.6-parport-quickfix-the-proc-registration-bug.patch
+
+ApplyPatch linux-2.6-dev-zero-avoid-oom-lockup.patch
+
 # END OF PATCH APPLICATIONS
 
 %endif
@@ -1956,6 +1964,10 @@ fi
 %kernel_variant_files -a /%{image_install_path}/xen*-%{KVERREL}.xen -e /etc/ld.so.conf.d/kernelcap-%{KVERREL}.xen.conf %{with_xen} xen
 
 %changelog
+* Tue Jun 16 2009 Chuck Ebbert <cebbert at redhat.com> 2.6.27.25-78.2.55
+- Avoid lockup on OOM with /dev/zero
+- Stop spewing useless warning on parport sysctl registration
+
 * Sun Jun 14 2009 Chuck Ebbert <cebbert at redhat.com>  2.6.27.25-78.2.54
 - Linux 2.6.27.25
 - Dropped patches, merged in .25




More information about the fedora-extras-commits mailing list