Skip to content

Commit c3f9b9f

Browse files
committed
Merge tag 'ceph-for-6.3-rc1' of https://github.com/ceph/ceph-client
Pull ceph fixes from Ilya Dryomov: "Two small fixes from Xiubo and myself, marked for stable" * tag 'ceph-for-6.3-rc1' of https://github.com/ceph/ceph-client: rbd: avoid use-after-free in do_rbd_add() when rbd_dev_create() fails ceph: update the time stamps and try to drop the suid/sgid
2 parents 04a357b + f7c4d9b commit c3f9b9f

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

drivers/block/rbd.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5291,8 +5291,7 @@ static void rbd_dev_release(struct device *dev)
52915291
module_put(THIS_MODULE);
52925292
}
52935293

5294-
static struct rbd_device *__rbd_dev_create(struct rbd_client *rbdc,
5295-
struct rbd_spec *spec)
5294+
static struct rbd_device *__rbd_dev_create(struct rbd_spec *spec)
52965295
{
52975296
struct rbd_device *rbd_dev;
52985297

@@ -5337,9 +5336,6 @@ static struct rbd_device *__rbd_dev_create(struct rbd_client *rbdc,
53375336
rbd_dev->dev.parent = &rbd_root_dev;
53385337
device_initialize(&rbd_dev->dev);
53395338

5340-
rbd_dev->rbd_client = rbdc;
5341-
rbd_dev->spec = spec;
5342-
53435339
return rbd_dev;
53445340
}
53455341

@@ -5352,12 +5348,10 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
53525348
{
53535349
struct rbd_device *rbd_dev;
53545350

5355-
rbd_dev = __rbd_dev_create(rbdc, spec);
5351+
rbd_dev = __rbd_dev_create(spec);
53565352
if (!rbd_dev)
53575353
return NULL;
53585354

5359-
rbd_dev->opts = opts;
5360-
53615355
/* get an id and fill in device name */
53625356
rbd_dev->dev_id = ida_simple_get(&rbd_dev_id_ida, 0,
53635357
minor_to_rbd_dev_id(1 << MINORBITS),
@@ -5374,6 +5368,10 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
53745368
/* we have a ref from do_rbd_add() */
53755369
__module_get(THIS_MODULE);
53765370

5371+
rbd_dev->rbd_client = rbdc;
5372+
rbd_dev->spec = spec;
5373+
rbd_dev->opts = opts;
5374+
53775375
dout("%s rbd_dev %p dev_id %d\n", __func__, rbd_dev, rbd_dev->dev_id);
53785376
return rbd_dev;
53795377

@@ -6735,7 +6733,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)
67356733
goto out_err;
67366734
}
67376735

6738-
parent = __rbd_dev_create(rbd_dev->rbd_client, rbd_dev->parent_spec);
6736+
parent = __rbd_dev_create(rbd_dev->parent_spec);
67396737
if (!parent) {
67406738
ret = -ENOMEM;
67416739
goto out_err;
@@ -6745,8 +6743,8 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)
67456743
* Images related by parent/child relationships always share
67466744
* rbd_client and spec/parent_spec, so bump their refcounts.
67476745
*/
6748-
__rbd_get_client(rbd_dev->rbd_client);
6749-
rbd_spec_get(rbd_dev->parent_spec);
6746+
parent->rbd_client = __rbd_get_client(rbd_dev->rbd_client);
6747+
parent->spec = rbd_spec_get(rbd_dev->parent_spec);
67506748

67516749
__set_bit(RBD_DEV_FLAG_READONLY, &parent->flags);
67526750

fs/ceph/file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,9 @@ static long ceph_fallocate(struct file *file, int mode,
20982098
loff_t endoff = 0;
20992099
loff_t size;
21002100

2101+
dout("%s %p %llx.%llx mode %x, offset %llu length %llu\n", __func__,
2102+
inode, ceph_vinop(inode), mode, offset, length);
2103+
21012104
if (mode != (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
21022105
return -EOPNOTSUPP;
21032106

@@ -2132,6 +2135,10 @@ static long ceph_fallocate(struct file *file, int mode,
21322135
if (ret < 0)
21332136
goto unlock;
21342137

2138+
ret = file_modified(file);
2139+
if (ret)
2140+
goto put_caps;
2141+
21352142
filemap_invalidate_lock(inode->i_mapping);
21362143
ceph_fscache_invalidate(inode, false);
21372144
ceph_zero_pagecache_range(inode, offset, length);
@@ -2147,6 +2154,7 @@ static long ceph_fallocate(struct file *file, int mode,
21472154
}
21482155
filemap_invalidate_unlock(inode->i_mapping);
21492156

2157+
put_caps:
21502158
ceph_put_cap_refs(ci, got);
21512159
unlock:
21522160
inode_unlock(inode);

0 commit comments

Comments
 (0)