Skip to content

Commit e0cd920

Browse files
committed
Merge branch 'uaccess.access_ok' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull uaccess/access_ok updates from Al Viro: "Removals of trivially pointless access_ok() calls. Note: the fiemap stuff was removed from the series, since they are duplicates with part of ext4 series carried in Ted's tree" * 'uaccess.access_ok' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: vmci_host: get rid of pointless access_ok() hfi1: get rid of pointless access_ok() usb: get rid of pointless access_ok() calls lpfc_debugfs: get rid of pointless access_ok() efi_test: get rid of pointless access_ok() drm_read(): get rid of pointless access_ok() via-pmu: don't bother with access_ok() drivers/crypto/ccp/sev-dev.c: get rid of pointless access_ok() omapfb: get rid of pointless access_ok() calls amifb: get rid of pointless access_ok() calls drivers/fpga/dfl-afu-dma-region.c: get rid of pointless access_ok() drivers/fpga/dfl-fme-pr.c: get rid of pointless access_ok() cm4000_cs.c cmm_ioctl(): get rid of pointless access_ok() nvram: drop useless access_ok() n_hdlc_tty_read(): remove pointless access_ok() tomoyo_write_control(): get rid of pointless access_ok() btrfs_ioctl_send(): don't bother with access_ok() fat_dir_ioctl(): hadn't needed that access_ok() for more than a decade... dlmfs_file_write(): get rid of pointless access_ok()
2 parents 4b01285 + 87c233b commit e0cd920

File tree

21 files changed

+3
-123
lines changed

21 files changed

+3
-123
lines changed

drivers/char/nvram.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ static ssize_t nvram_misc_read(struct file *file, char __user *buf,
232232
ssize_t ret;
233233

234234

235-
if (!access_ok(buf, count))
236-
return -EFAULT;
237235
if (*ppos >= nvram_size)
238236
return 0;
239237

@@ -264,8 +262,6 @@ static ssize_t nvram_misc_write(struct file *file, const char __user *buf,
264262
char *tmp;
265263
ssize_t ret;
266264

267-
if (!access_ok(buf, count))
268-
return -EFAULT;
269265
if (*ppos >= nvram_size)
270266
return 0;
271267

drivers/char/pcmcia/cm4000_cs.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,6 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
14041404
unsigned int iobase = dev->p_dev->resource[0]->start;
14051405
struct inode *inode = file_inode(filp);
14061406
struct pcmcia_device *link;
1407-
int size;
14081407
int rc;
14091408
void __user *argp = (void __user *)arg;
14101409
#ifdef CM4000_DEBUG
@@ -1441,19 +1440,6 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
14411440
DEBUGP(4, dev, "iocnr mismatch\n");
14421441
goto out;
14431442
}
1444-
size = _IOC_SIZE(cmd);
1445-
rc = -EFAULT;
1446-
DEBUGP(4, dev, "iocdir=%.4x iocr=%.4x iocw=%.4x iocsize=%d cmd=%.4x\n",
1447-
_IOC_DIR(cmd), _IOC_READ, _IOC_WRITE, size, cmd);
1448-
1449-
if (_IOC_DIR(cmd) & _IOC_READ) {
1450-
if (!access_ok(argp, size))
1451-
goto out;
1452-
}
1453-
if (_IOC_DIR(cmd) & _IOC_WRITE) {
1454-
if (!access_ok(argp, size))
1455-
goto out;
1456-
}
14571443
rc = 0;
14581444

14591445
switch (cmd) {

drivers/crypto/ccp/sev-dev.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
394394
goto cmd;
395395

396396
/* allocate a physically contiguous buffer to store the CSR blob */
397-
if (!access_ok(input.address, input.length) ||
398-
input.length > SEV_FW_BLOB_MAX_SIZE) {
397+
if (input.length > SEV_FW_BLOB_MAX_SIZE) {
399398
ret = -EFAULT;
400399
goto e_free;
401400
}
@@ -632,12 +631,6 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
632631
if (copy_from_user(&input, (void __user *)argp->data, sizeof(input)))
633632
return -EFAULT;
634633

635-
/* Check if we have write access to the userspace buffer */
636-
if (input.address &&
637-
input.length &&
638-
!access_ok(input.address, input.length))
639-
return -EFAULT;
640-
641634
data = kzalloc(sizeof(*data), GFP_KERNEL);
642635
if (!data)
643636
return -ENOMEM;
@@ -753,15 +746,13 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
753746
goto cmd;
754747

755748
/* Allocate a physically contiguous buffer to store the PDH blob. */
756-
if ((input.pdh_cert_len > SEV_FW_BLOB_MAX_SIZE) ||
757-
!access_ok(input.pdh_cert_address, input.pdh_cert_len)) {
749+
if (input.pdh_cert_len > SEV_FW_BLOB_MAX_SIZE) {
758750
ret = -EFAULT;
759751
goto e_free;
760752
}
761753

762754
/* Allocate a physically contiguous buffer to store the cert chain blob. */
763-
if ((input.cert_chain_len > SEV_FW_BLOB_MAX_SIZE) ||
764-
!access_ok(input.cert_chain_address, input.cert_chain_len)) {
755+
if (input.cert_chain_len > SEV_FW_BLOB_MAX_SIZE) {
765756
ret = -EFAULT;
766757
goto e_free;
767758
}

drivers/firmware/efi/test/efi_test.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
7070
return 0;
7171
}
7272

73-
if (!access_ok(src, 1))
74-
return -EFAULT;
75-
7673
buf = memdup_user(src, len);
7774
if (IS_ERR(buf)) {
7875
*dst = NULL;
@@ -91,9 +88,6 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
9188
static inline int
9289
get_ucs2_strsize_from_user(efi_char16_t __user *src, size_t *len)
9390
{
94-
if (!access_ok(src, 1))
95-
return -EFAULT;
96-
9791
*len = user_ucs2_strsize(src);
9892
if (*len == 0)
9993
return -EFAULT;
@@ -118,9 +112,6 @@ copy_ucs2_from_user(efi_char16_t **dst, efi_char16_t __user *src)
118112
{
119113
size_t len;
120114

121-
if (!access_ok(src, 1))
122-
return -EFAULT;
123-
124115
len = user_ucs2_strsize(src);
125116
if (len == 0)
126117
return -EFAULT;
@@ -142,9 +133,6 @@ copy_ucs2_to_user_len(efi_char16_t __user *dst, efi_char16_t *src, size_t len)
142133
if (!src)
143134
return 0;
144135

145-
if (!access_ok(dst, 1))
146-
return -EFAULT;
147-
148136
return copy_to_user(dst, src, len);
149137
}
150138

drivers/fpga/dfl-afu-dma-region.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,6 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
324324
if (user_addr + length < user_addr)
325325
return -EINVAL;
326326

327-
if (!access_ok((void __user *)(unsigned long)user_addr,
328-
length))
329-
return -EINVAL;
330-
331327
region = kzalloc(sizeof(*region), GFP_KERNEL);
332328
if (!region)
333329
return -ENOMEM;

drivers/fpga/dfl-fme-pr.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ static int fme_pr(struct platform_device *pdev, unsigned long arg)
9797
return -EINVAL;
9898
}
9999

100-
if (!access_ok((void __user *)(unsigned long)port_pr.buffer_address,
101-
port_pr.buffer_size))
102-
return -EFAULT;
103-
104100
/*
105101
* align PR buffer per PR bandwidth, as HW ignores the extra padding
106102
* data automatically.

drivers/gpu/drm/drm_file.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,6 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
569569
struct drm_device *dev = file_priv->minor->dev;
570570
ssize_t ret;
571571

572-
if (!access_ok(buffer, count))
573-
return -EFAULT;
574-
575572
ret = mutex_lock_interruptible(&file_priv->event_read_lock);
576573
if (ret)
577574
return ret;

drivers/infiniband/hw/hfi1/user_exp_rcv.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ static int pin_rcv_pages(struct hfi1_filedata *fd, struct tid_user_buf *tidbuf)
206206
return -EINVAL;
207207
}
208208

209-
/* Verify that access is OK for the user buffer */
210-
if (!access_ok((void __user *)vaddr,
211-
npages * PAGE_SIZE)) {
212-
dd_dev_err(dd, "Fail vaddr %p, %u pages, !access_ok\n",
213-
(void *)vaddr, npages);
214-
return -EFAULT;
215-
}
216209
/* Allocate the array of struct page pointers needed for pinning */
217210
pages = kcalloc(npages, sizeof(*pages), GFP_KERNEL);
218211
if (!pages)

drivers/macintosh/via-pmu.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,8 +2184,6 @@ pmu_read(struct file *file, char __user *buf,
21842184

21852185
if (count < 1 || !pp)
21862186
return -EINVAL;
2187-
if (!access_ok(buf, count))
2188-
return -EFAULT;
21892187

21902188
spin_lock_irqsave(&pp->lock, flags);
21912189
add_wait_queue(&pp->wait, &wait);

drivers/misc/vmw_vmci/vmci_host.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ static int vmci_host_setup_notify(struct vmci_ctx *context,
233233
* about the size.
234234
*/
235235
BUILD_BUG_ON(sizeof(bool) != sizeof(u8));
236-
if (!access_ok((void __user *)uva, sizeof(u8)))
237-
return VMCI_ERROR_GENERIC;
238236

239237
/*
240238
* Lock physical page backing a given user VA.

0 commit comments

Comments
 (0)