Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 17081
b: refs/heads/master
c: 5a57be8
h: refs/heads/master
i:
  17079: 762e77b
v: v3
  • Loading branch information
Jens Axboe committed Jan 9, 2006
1 parent b999070 commit 94597b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0ea60b5ad8c3630e8f44c443f173d841be7fc701
refs/heads/master: 5a57be8d100c67a033ec78f00d5a0cd387da72e9
13 changes: 9 additions & 4 deletions trunk/block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,21 @@ static int verify_command(struct file *file, unsigned char *cmd)
safe_for_write(GPCMD_SET_STREAMING),
};
unsigned char type = cmd_type[cmd[0]];
int has_write_perm = 0;

/* Anybody who can open the device can do a read-safe command */
if (type & CMD_READ_SAFE)
return 0;

/*
* file can be NULL from ioctl_by_bdev()...
*/
if (file)
has_write_perm = file->f_mode & FMODE_WRITE;

/* Write-safe commands just require a writable open.. */
if (type & CMD_WRITE_SAFE) {
if (file->f_mode & FMODE_WRITE)
return 0;
}
if ((type & CMD_WRITE_SAFE) && has_write_perm)
return 0;

/* And root can do any command.. */
if (capable(CAP_SYS_RAWIO))
Expand Down

0 comments on commit 94597b8

Please sign in to comment.