File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -2380,10 +2380,19 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
2380
2380
* TODO: provide forward progress for RECOVERY handler, so that
2381
2381
* unprivileged device can benefit from it
2382
2382
*/
2383
- if (info .flags & UBLK_F_UNPRIVILEGED_DEV )
2383
+ if (info .flags & UBLK_F_UNPRIVILEGED_DEV ) {
2384
2384
info .flags &= ~(UBLK_F_USER_RECOVERY_REISSUE |
2385
2385
UBLK_F_USER_RECOVERY );
2386
2386
2387
+ /*
2388
+ * For USER_COPY, we depends on userspace to fill request
2389
+ * buffer by pwrite() to ublk char device, which can't be
2390
+ * used for unprivileged device
2391
+ */
2392
+ if (info .flags & UBLK_F_USER_COPY )
2393
+ return - EINVAL ;
2394
+ }
2395
+
2387
2396
/* the created device is always owned by current user */
2388
2397
ublk_store_owner_uid_gid (& info .owner_uid , & info .owner_gid );
2389
2398
Original file line number Diff line number Diff line change 175
175
/* use ioctl encoding for uring command */
176
176
#define UBLK_F_CMD_IOCTL_ENCODE (1UL << 6)
177
177
178
- /* Copy between request and user buffer by pread()/pwrite() */
178
+ /*
179
+ * Copy between request and user buffer by pread()/pwrite()
180
+ *
181
+ * Not available for UBLK_F_UNPRIVILEGED_DEV, otherwise userspace may
182
+ * deceive us by not filling request buffer, then kernel uninitialized
183
+ * data may be leaked.
184
+ */
179
185
#define UBLK_F_USER_COPY (1UL << 7)
180
186
181
187
/*
You can’t perform that action at this time.
0 commit comments