mirror of
https://github.com/torvalds/linux.git
synced 2026-10-23 15:32:04 +02:00
PCI/proc: Use get_user()/put_user() for config space reads and writes
proc_bus_pci_read() and proc_bus_pci_write() check the user buffer with access_ok() and then copy config space one byte, word or dword at a time with __put_user() and __get_user(). Each of those accesses enables and disables user access on its own, so the up-front check saves nothing. Use put_user() and get_user(). This deliberately changes nothing else: the return values were ignored before and still are, and the access_ok() stays, since it is the only error these functions report for a bad buffer. This is part of getting rid of __get_user() and __put_user() entirely. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8d1cec6c76
commit
198db29840
|
|
@ -67,7 +67,7 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
|
|||
if ((pos & 1) && cnt) {
|
||||
unsigned char val;
|
||||
pci_user_read_config_byte(dev, pos, &val);
|
||||
__put_user(val, buf);
|
||||
put_user(val, buf);
|
||||
buf++;
|
||||
pos++;
|
||||
cnt--;
|
||||
|
|
@ -76,7 +76,7 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
|
|||
if ((pos & 3) && cnt > 2) {
|
||||
unsigned short val;
|
||||
pci_user_read_config_word(dev, pos, &val);
|
||||
__put_user(cpu_to_le16(val), (__le16 __user *) buf);
|
||||
put_user(cpu_to_le16(val), (__le16 __user *) buf);
|
||||
buf += 2;
|
||||
pos += 2;
|
||||
cnt -= 2;
|
||||
|
|
@ -85,7 +85,7 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
|
|||
while (cnt >= 4) {
|
||||
unsigned int val;
|
||||
pci_user_read_config_dword(dev, pos, &val);
|
||||
__put_user(cpu_to_le32(val), (__le32 __user *) buf);
|
||||
put_user(cpu_to_le32(val), (__le32 __user *) buf);
|
||||
buf += 4;
|
||||
pos += 4;
|
||||
cnt -= 4;
|
||||
|
|
@ -95,7 +95,7 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
|
|||
if (cnt >= 2) {
|
||||
unsigned short val;
|
||||
pci_user_read_config_word(dev, pos, &val);
|
||||
__put_user(cpu_to_le16(val), (__le16 __user *) buf);
|
||||
put_user(cpu_to_le16(val), (__le16 __user *) buf);
|
||||
buf += 2;
|
||||
pos += 2;
|
||||
cnt -= 2;
|
||||
|
|
@ -104,7 +104,7 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
|
|||
if (cnt) {
|
||||
unsigned char val;
|
||||
pci_user_read_config_byte(dev, pos, &val);
|
||||
__put_user(val, buf);
|
||||
put_user(val, buf);
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
|
|||
|
||||
if ((pos & 1) && cnt) {
|
||||
unsigned char val;
|
||||
__get_user(val, buf);
|
||||
get_user(val, buf);
|
||||
pci_user_write_config_byte(dev, pos, val);
|
||||
buf++;
|
||||
pos++;
|
||||
|
|
@ -160,7 +160,7 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
|
|||
|
||||
if ((pos & 3) && cnt > 2) {
|
||||
__le16 val;
|
||||
__get_user(val, (__le16 __user *) buf);
|
||||
get_user(val, (__le16 __user *) buf);
|
||||
pci_user_write_config_word(dev, pos, le16_to_cpu(val));
|
||||
buf += 2;
|
||||
pos += 2;
|
||||
|
|
@ -169,7 +169,7 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
|
|||
|
||||
while (cnt >= 4) {
|
||||
__le32 val;
|
||||
__get_user(val, (__le32 __user *) buf);
|
||||
get_user(val, (__le32 __user *) buf);
|
||||
pci_user_write_config_dword(dev, pos, le32_to_cpu(val));
|
||||
buf += 4;
|
||||
pos += 4;
|
||||
|
|
@ -178,7 +178,7 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
|
|||
|
||||
if (cnt >= 2) {
|
||||
__le16 val;
|
||||
__get_user(val, (__le16 __user *) buf);
|
||||
get_user(val, (__le16 __user *) buf);
|
||||
pci_user_write_config_word(dev, pos, le16_to_cpu(val));
|
||||
buf += 2;
|
||||
pos += 2;
|
||||
|
|
@ -187,7 +187,7 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
|
|||
|
||||
if (cnt) {
|
||||
unsigned char val;
|
||||
__get_user(val, buf);
|
||||
get_user(val, buf);
|
||||
pci_user_write_config_byte(dev, pos, val);
|
||||
pos++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user