Skip to content

Commit

Permalink
virtio: console: Disable lseek(2) for port file operations
Browse files Browse the repository at this point in the history
The ports are char devices; do not have seeking capabilities.  Calling
nonseekable_open() from the fops_open() call and setting the llseek fops
pointer to no_llseek ensures an lseek() call from userspace returns
-ESPIPE.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
CC: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Amit Shah authored and Rusty Russell committed Oct 21, 2010
1 parent a461e11 commit 299fb61
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ static int port_fops_open(struct inode *inode, struct file *filp)
reclaim_consumed_buffers(port);
spin_unlock_irq(&port->outvq_lock);

nonseekable_open(inode, filp);

/* Notify host of port being opened */
send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);

Expand Down Expand Up @@ -840,6 +842,7 @@ static const struct file_operations port_fops = {
.poll = port_fops_poll,
.release = port_fops_release,
.fasync = port_fops_fasync,
.llseek = no_llseek,
};

/*
Expand Down

0 comments on commit 299fb61

Please sign in to comment.