Skip to content

Commit 3bad2f1

Browse files
committed
Merge branch 'work.misc-set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc user access cleanups from Al Viro: "The first pile is assorted getting rid of cargo-culted access_ok(), cargo-culted set_fs() and field-by-field copyouts. The same description applies to a lot of stuff in other branches - this is just the stuff that didn't fit into a more specific topical branch" * 'work.misc-set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: Switch flock copyin/copyout primitives to copy_{from,to}_user() fs/fcntl: return -ESRCH in f_setown when pid/pgid can't be found fs/fcntl: f_setown, avoid undefined behaviour fs/fcntl: f_setown, allow returning error lpfc debugfs: get rid of pointless access_ok() adb: get rid of pointless access_ok() isdn: get rid of pointless access_ok() compat statfs: switch to copy_to_user() fs/locks: don't mess with the address limit in compat_fcntl64 nfsd_readlink(): switch to vfs_get_link() drbd: ->sendpage() never needed set_fs() fs/locks: pass kernel struct flock to fcntl_getlk/setlk fs: locks: Fix some troubles at kernel-doc comments
2 parents b4b8cbf + 8c6657c commit 3bad2f1

12 files changed

Lines changed: 220 additions & 271 deletions

File tree

‎drivers/block/drbd/drbd_main.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,6 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa
15511551
int offset, size_t size, unsigned msg_flags)
15521552
{
15531553
struct socket *socket = peer_device->connection->data.socket;
1554-
mm_segment_t oldfs = get_fs();
15551554
int len = size;
15561555
int err = -EIO;
15571556

@@ -1566,7 +1565,6 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa
15661565

15671566
msg_flags |= MSG_NOSIGNAL;
15681567
drbd_update_congested(peer_device->connection);
1569-
set_fs(KERNEL_DS);
15701568
do {
15711569
int sent;
15721570

@@ -1586,7 +1584,6 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa
15861584
len -= sent;
15871585
offset += sent;
15881586
} while (len > 0 /* THINK && device->cstate >= C_CONNECTED*/);
1589-
set_fs(oldfs);
15901587
clear_bit(NET_CONGESTED, &peer_device->connection->flags);
15911588

15921589
if (len == 0) {

‎drivers/isdn/i4l/isdn_common.c‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
13041304
if (arg) {
13051305
ulong __user *p = argp;
13061306
int i;
1307-
if (!access_ok(VERIFY_WRITE, p,
1308-
sizeof(ulong) * ISDN_MAX_CHANNELS * 2))
1309-
return -EFAULT;
13101307
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
13111308
put_user(dev->ibytes[i], p++);
13121309
put_user(dev->obytes[i], p++);
@@ -1540,11 +1537,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
15401537
char __user *p = argp;
15411538
int i;
15421539

1543-
if (!access_ok(VERIFY_WRITE, argp,
1544-
(ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN)
1545-
* ISDN_MAX_CHANNELS))
1546-
return -EFAULT;
1547-
15481540
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
15491541
if (copy_to_user(p, dev->mdm.info[i].emu.profile,
15501542
ISDN_MODEM_NUMREG))
@@ -1567,11 +1559,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
15671559
char __user *p = argp;
15681560
int i;
15691561

1570-
if (!access_ok(VERIFY_READ, argp,
1571-
(ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN)
1572-
* ISDN_MAX_CHANNELS))
1573-
return -EFAULT;
1574-
15751562
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
15761563
if (copy_from_user(dev->mdm.info[i].emu.profile, p,
15771564
ISDN_MODEM_NUMREG))
@@ -1617,8 +1604,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
16171604
int j = 0;
16181605

16191606
while (1) {
1620-
if (!access_ok(VERIFY_READ, p, 1))
1621-
return -EFAULT;
16221607
get_user(bname[j], p++);
16231608
switch (bname[j]) {
16241609
case '\0':
@@ -1685,9 +1670,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
16851670
drvidx = 0;
16861671
if (drvidx == -1)
16871672
return -ENODEV;
1688-
if (!access_ok(VERIFY_WRITE, argp,
1689-
sizeof(isdn_ioctl_struct)))
1690-
return -EFAULT;
16911673
c.driver = drvidx;
16921674
c.command = ISDN_CMD_IOCTL;
16931675
c.arg = cmd;

‎drivers/isdn/i4l/isdn_ppp.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,6 @@ isdn_ppp_read(int min, struct file *file, char __user *buf, int count)
795795
if (!(is->state & IPPP_OPEN))
796796
return 0;
797797

798-
if (!access_ok(VERIFY_WRITE, buf, count))
799-
return -EFAULT;
800-
801798
spin_lock_irqsave(&is->buflock, flags);
802799
b = is->first->next;
803800
save_buf = b->buf;
@@ -2014,9 +2011,6 @@ isdn_ppp_dev_ioctl_stats(int slot, struct ifreq *ifr, struct net_device *dev)
20142011
struct ppp_stats t;
20152012
isdn_net_local *lp = netdev_priv(dev);
20162013

2017-
if (!access_ok(VERIFY_WRITE, res, sizeof(struct ppp_stats)))
2018-
return -EFAULT;
2019-
20202014
/* build a temporary stat struct and copy it to user space */
20212015

20222016
memset(&t, 0, sizeof(struct ppp_stats));

‎drivers/isdn/isdnloop/isdnloop.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,6 @@ isdnloop_command(isdn_ctrl *c, isdnloop_card *card)
11421142
case ISDNLOOP_IOCTL_DEBUGVAR:
11431143
return (ulong) card;
11441144
case ISDNLOOP_IOCTL_STARTUP:
1145-
if (!access_ok(VERIFY_READ, (void *) a, sizeof(isdnloop_sdef)))
1146-
return -EFAULT;
11471145
return isdnloop_start(card, (isdnloop_sdef *) a);
11481146
break;
11491147
case ISDNLOOP_IOCTL_ADDCARD:

‎drivers/macintosh/adb.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,6 @@ static ssize_t adb_read(struct file *file, char __user *buf,
723723
return -EINVAL;
724724
if (count > sizeof(req->reply))
725725
count = sizeof(req->reply);
726-
if (!access_ok(VERIFY_WRITE, buf, count))
727-
return -EFAULT;
728726

729727
req = NULL;
730728
spin_lock_irqsave(&state->lock, flags);
@@ -781,8 +779,6 @@ static ssize_t adb_write(struct file *file, const char __user *buf,
781779
return -EINVAL;
782780
if (adb_controller == NULL)
783781
return -ENXIO;
784-
if (!access_ok(VERIFY_READ, buf, count))
785-
return -EFAULT;
786782

787783
req = kmalloc(sizeof(struct adb_request),
788784
GFP_KERNEL);

‎drivers/scsi/lpfc/lpfc_debugfs.c‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,10 +1949,6 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
19491949
if (nbytes > 64)
19501950
nbytes = 64;
19511951

1952-
/* Protect copy from user */
1953-
if (!access_ok(VERIFY_READ, buf, nbytes))
1954-
return -EFAULT;
1955-
19561952
memset(mybuf, 0, sizeof(mybuf));
19571953

19581954
if (copy_from_user(mybuf, buf, nbytes))
@@ -2037,10 +2033,6 @@ lpfc_debugfs_nvmektime_write(struct file *file, const char __user *buf,
20372033
if (nbytes > 64)
20382034
nbytes = 64;
20392035

2040-
/* Protect copy from user */
2041-
if (!access_ok(VERIFY_READ, buf, nbytes))
2042-
return -EFAULT;
2043-
20442036
memset(mybuf, 0, sizeof(mybuf));
20452037

20462038
if (copy_from_user(mybuf, buf, nbytes))
@@ -2169,10 +2161,6 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
21692161
if (nbytes > 64)
21702162
nbytes = 64;
21712163

2172-
/* Protect copy from user */
2173-
if (!access_ok(VERIFY_READ, buf, nbytes))
2174-
return -EFAULT;
2175-
21762164
memset(mybuf, 0, sizeof(mybuf));
21772165

21782166
if (copy_from_user(mybuf, buf, nbytes))
@@ -2280,10 +2268,6 @@ lpfc_debugfs_cpucheck_write(struct file *file, const char __user *buf,
22802268
if (nbytes > 64)
22812269
nbytes = 64;
22822270

2283-
/* Protect copy from user */
2284-
if (!access_ok(VERIFY_READ, buf, nbytes))
2285-
return -EFAULT;
2286-
22872271
memset(mybuf, 0, sizeof(mybuf));
22882272

22892273
if (copy_from_user(mybuf, buf, nbytes))
@@ -2354,10 +2338,6 @@ static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes,
23542338
int i;
23552339
size_t bsize;
23562340

2357-
/* Protect copy from user */
2358-
if (!access_ok(VERIFY_READ, buf, nbytes))
2359-
return -EFAULT;
2360-
23612341
memset(mybuf, 0, sizeof(mybuf));
23622342
memset(idiag_cmd, 0, sizeof(*idiag_cmd));
23632343
bsize = min(nbytes, (sizeof(mybuf)-1));

0 commit comments

Comments
 (0)