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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 21 Mar 2014 14:20:11 +0000
From:	Matt Sickler <Matt.Sickler@...tronics.com>
To:	"hjk@...sjkoch.de" <hjk@...sjkoch.de>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH]: UIO read(2)/write(2) overrides

Tiny patch to let uio-based drivers override the read(2), write(2), and poll(2) syscalls.
The rationale is that some uio-based drivers might want the mmap(2) functionality
of UIO, but have no need for the IRQ semantics of read(2) and write(2).

Signed-Off-by: Matt Sickler <Matt.Sickler@...tronics.com>
---
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index a673e5b..da1bfc8 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -505,6 +505,9 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
    struct uio_listener *listener = filep->private_data;
    struct uio_device *idev = listener->dev;

+   if (idev->info->poll)
+       return idev->info->poll(filep, wait);
+
    if (!idev->info->irq)
        return -EIO;

@@ -523,6 +526,9 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
    ssize_t retval;
    s32 event_count;

+   if (idev->info->read)
+       return idev->info->read(filep, buf, count, ppos);
+
    if (!idev->info->irq)
        return -EIO;

@@ -571,6 +577,9 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
    ssize_t retval;
    s32 irq_on;

+   if (idev->info->write)
+       return idev->info->write(filep, buf, count, ppos);
+
    if (!idev->info->irq)
        return -EIO;

diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 1ad4724..f15ace1 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -16,6 +16,7 @@

 #include <linux/fs.h>
 #include <linux/interrupt.h>
+#include <linux/poll.h>

 struct module;
 struct uio_map;
@@ -95,6 +96,11 @@ struct uio_info {
    int (*open)(struct uio_info *info, struct inode *inode);
    int (*release)(struct uio_info *info, struct inode *inode);
    int (*irqcontrol)(struct uio_info *info, s32 irq_on);
+   unsigned int (*poll)(struct file *filep, poll_table *wait);
+   ssize_t (*read)(struct file *filep, char __user *buf,
+                   size_t count, loff_t *ppos);
+   ssize_t (*write)(struct file *filep, const char __user *buf,
+                    size_t count, loff_t *ppos);
 };

 extern int __must_check

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists