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]
Date:	Thu, 14 Jun 2012 12:55:48 +0000
From:	"Liu, Jinsong" <jinsong.liu@...el.com>
To:	Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
CC:	"xen-devel@...ts.xensource.com" <xen-devel@...ts.xensource.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] xen/mce: add .poll method for mcelog device driver

>> 
>> So another bug which is that mcelog is spinning at 100% CPU (and
>> only under Xen). 
>> 
>> It seems to be doing:
>> 
>> ppoll([{fd=4, events=POLLIN}, {fd=3, events=POLLIN}], 2, NULL, [], 8)
>> = 1 ([{fd=3, revents=POLLIN}]) read(3, "", 2816)
>> = 0
>> ppoll([{fd=4, events=POLLIN}, {fd=3, events=POLLIN}], 2, NULL, [], 8)
>> = 1 ([{fd=3, revents=POLLIN}]) read(3, "", 2816)
>> 
>> constantly.
> 
> I will debug it. I have try at my platform, but fail to reproduce it.
> (You still use the config you send me last time, right?) Would you
> tell me your step? 
> 
> Thanks,
> Jinsong

Have a look at it, it caused by NULL .poll method.
Attached is the patch to fix this bug, but I cannot reproduce the bug at my platform, so would you please help me to test it at your side?

Thanks,
Jinsong

=============
>From fb664590ce4198539d96b6bc245c5d70cc079129 Mon Sep 17 00:00:00 2001
From: Liu, Jinsong <jinsong.liu@...el.com>
Date: Fri, 15 Jun 2012 04:16:52 +0800
Subject: [PATCH] xen/mce: add .poll method for mcelog device driver

If a driver leaves its poll method NULL, the device is assumed to
be both readable and writable without blocking.

This patch add .poll method to xen mcelog device driver, so that
when mcelog use system calls like ppoll or select, it would be
blocked when no data available, and avoid spinning at CPU.

Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
Signed-off-by: Liu, Jinsong <jinsong.liu@...el.com>
---
 drivers/xen/mcelog.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/xen/mcelog.c b/drivers/xen/mcelog.c
index 804aa3c..c0b39c9 100644
--- a/drivers/xen/mcelog.c
+++ b/drivers/xen/mcelog.c
@@ -41,6 +41,7 @@
 #include <linux/miscdevice.h>
 #include <linux/uaccess.h>
 #include <linux/capability.h>
+#include <linux/poll.h>
 
 #include <xen/interface/xen.h>
 #include <xen/events.h>
@@ -135,6 +136,14 @@ out:
 	return err ? err : buf - ubuf;
 }
 
+static unsigned int xen_mce_chrdev_poll(struct file *file, poll_table *wait)
+{
+	if (xen_mcelog.next)
+		return POLLIN | POLLRDNORM;
+
+	return 0;
+}
+
 static long xen_mce_chrdev_ioctl(struct file *f, unsigned int cmd,
 				unsigned long arg)
 {
@@ -166,6 +175,7 @@ static const struct file_operations xen_mce_chrdev_ops = {
 	.open			= xen_mce_chrdev_open,
 	.release		= xen_mce_chrdev_release,
 	.read			= xen_mce_chrdev_read,
+	.poll			= xen_mce_chrdev_poll,
 	.unlocked_ioctl		= xen_mce_chrdev_ioctl,
 	.llseek			= no_llseek,
 };
-- 
1.7.1

Download attachment "0001-xen-mce-add-.poll-method-for-mcelog-device-driver.patch" of type "application/octet-stream" (1677 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ