| .. | .. |
|---|
| 285 | 285 | ino_t ino; |
|---|
| 286 | 286 | |
|---|
| 287 | 287 | if (!(sb->s_flags & SB_KERNMOUNT)) { |
|---|
| 288 | | - raw_spin_lock(&sbinfo->stat_lock); |
|---|
| 288 | + spin_lock(&sbinfo->stat_lock); |
|---|
| 289 | 289 | if (sbinfo->max_inodes) { |
|---|
| 290 | 290 | if (!sbinfo->free_inodes) { |
|---|
| 291 | | - raw_spin_unlock(&sbinfo->stat_lock); |
|---|
| 291 | + spin_unlock(&sbinfo->stat_lock); |
|---|
| 292 | 292 | return -ENOSPC; |
|---|
| 293 | 293 | } |
|---|
| 294 | 294 | sbinfo->free_inodes--; |
|---|
| .. | .. |
|---|
| 311 | 311 | } |
|---|
| 312 | 312 | *inop = ino; |
|---|
| 313 | 313 | } |
|---|
| 314 | | - raw_spin_unlock(&sbinfo->stat_lock); |
|---|
| 314 | + spin_unlock(&sbinfo->stat_lock); |
|---|
| 315 | 315 | } else if (inop) { |
|---|
| 316 | 316 | /* |
|---|
| 317 | 317 | * __shmem_file_setup, one of our callers, is lock-free: it |
|---|
| .. | .. |
|---|
| 326 | 326 | * to worry about things like glibc compatibility. |
|---|
| 327 | 327 | */ |
|---|
| 328 | 328 | ino_t *next_ino; |
|---|
| 329 | | - |
|---|
| 330 | 329 | next_ino = per_cpu_ptr(sbinfo->ino_batch, get_cpu()); |
|---|
| 331 | 330 | ino = *next_ino; |
|---|
| 332 | 331 | if (unlikely(ino % SHMEM_INO_BATCH == 0)) { |
|---|
| 333 | | - raw_spin_lock(&sbinfo->stat_lock); |
|---|
| 332 | + spin_lock(&sbinfo->stat_lock); |
|---|
| 334 | 333 | ino = sbinfo->next_ino; |
|---|
| 335 | 334 | sbinfo->next_ino += SHMEM_INO_BATCH; |
|---|
| 336 | | - raw_spin_unlock(&sbinfo->stat_lock); |
|---|
| 335 | + spin_unlock(&sbinfo->stat_lock); |
|---|
| 337 | 336 | if (unlikely(is_zero_ino(ino))) |
|---|
| 338 | 337 | ino++; |
|---|
| 339 | 338 | } |
|---|
| .. | .. |
|---|
| 349 | 348 | { |
|---|
| 350 | 349 | struct shmem_sb_info *sbinfo = SHMEM_SB(sb); |
|---|
| 351 | 350 | if (sbinfo->max_inodes) { |
|---|
| 352 | | - raw_spin_lock(&sbinfo->stat_lock); |
|---|
| 351 | + spin_lock(&sbinfo->stat_lock); |
|---|
| 353 | 352 | sbinfo->free_inodes++; |
|---|
| 354 | | - raw_spin_unlock(&sbinfo->stat_lock); |
|---|
| 353 | + spin_unlock(&sbinfo->stat_lock); |
|---|
| 355 | 354 | } |
|---|
| 356 | 355 | } |
|---|
| 357 | 356 | |
|---|
| .. | .. |
|---|
| 1493 | 1492 | { |
|---|
| 1494 | 1493 | struct mempolicy *mpol = NULL; |
|---|
| 1495 | 1494 | if (sbinfo->mpol) { |
|---|
| 1496 | | - raw_spin_lock(&sbinfo->stat_lock); /* prevent replace/use races */ |
|---|
| 1495 | + spin_lock(&sbinfo->stat_lock); /* prevent replace/use races */ |
|---|
| 1497 | 1496 | mpol = sbinfo->mpol; |
|---|
| 1498 | 1497 | mpol_get(mpol); |
|---|
| 1499 | | - raw_spin_unlock(&sbinfo->stat_lock); |
|---|
| 1498 | + spin_unlock(&sbinfo->stat_lock); |
|---|
| 1500 | 1499 | } |
|---|
| 1501 | 1500 | return mpol; |
|---|
| 1502 | 1501 | } |
|---|
| .. | .. |
|---|
| 3425 | 3424 | unsigned long long size; |
|---|
| 3426 | 3425 | char *rest; |
|---|
| 3427 | 3426 | int opt; |
|---|
| 3427 | + kuid_t kuid; |
|---|
| 3428 | + kgid_t kgid; |
|---|
| 3428 | 3429 | |
|---|
| 3429 | 3430 | opt = fs_parse(fc, shmem_fs_parameters, param, &result); |
|---|
| 3430 | 3431 | if (opt < 0) |
|---|
| .. | .. |
|---|
| 3460 | 3461 | ctx->mode = result.uint_32 & 07777; |
|---|
| 3461 | 3462 | break; |
|---|
| 3462 | 3463 | case Opt_uid: |
|---|
| 3463 | | - ctx->uid = make_kuid(current_user_ns(), result.uint_32); |
|---|
| 3464 | | - if (!uid_valid(ctx->uid)) |
|---|
| 3464 | + kuid = make_kuid(current_user_ns(), result.uint_32); |
|---|
| 3465 | + if (!uid_valid(kuid)) |
|---|
| 3465 | 3466 | goto bad_value; |
|---|
| 3467 | + |
|---|
| 3468 | + /* |
|---|
| 3469 | + * The requested uid must be representable in the |
|---|
| 3470 | + * filesystem's idmapping. |
|---|
| 3471 | + */ |
|---|
| 3472 | + if (!kuid_has_mapping(fc->user_ns, kuid)) |
|---|
| 3473 | + goto bad_value; |
|---|
| 3474 | + |
|---|
| 3475 | + ctx->uid = kuid; |
|---|
| 3466 | 3476 | break; |
|---|
| 3467 | 3477 | case Opt_gid: |
|---|
| 3468 | | - ctx->gid = make_kgid(current_user_ns(), result.uint_32); |
|---|
| 3469 | | - if (!gid_valid(ctx->gid)) |
|---|
| 3478 | + kgid = make_kgid(current_user_ns(), result.uint_32); |
|---|
| 3479 | + if (!gid_valid(kgid)) |
|---|
| 3470 | 3480 | goto bad_value; |
|---|
| 3481 | + |
|---|
| 3482 | + /* |
|---|
| 3483 | + * The requested gid must be representable in the |
|---|
| 3484 | + * filesystem's idmapping. |
|---|
| 3485 | + */ |
|---|
| 3486 | + if (!kgid_has_mapping(fc->user_ns, kgid)) |
|---|
| 3487 | + goto bad_value; |
|---|
| 3488 | + |
|---|
| 3489 | + ctx->gid = kgid; |
|---|
| 3471 | 3490 | break; |
|---|
| 3472 | 3491 | case Opt_huge: |
|---|
| 3473 | 3492 | ctx->huge = result.uint_32; |
|---|
| .. | .. |
|---|
| 3563 | 3582 | struct shmem_options *ctx = fc->fs_private; |
|---|
| 3564 | 3583 | struct shmem_sb_info *sbinfo = SHMEM_SB(fc->root->d_sb); |
|---|
| 3565 | 3584 | unsigned long inodes; |
|---|
| 3566 | | - struct mempolicy *mpol = NULL; |
|---|
| 3567 | 3585 | const char *err; |
|---|
| 3568 | 3586 | |
|---|
| 3569 | | - raw_spin_lock(&sbinfo->stat_lock); |
|---|
| 3587 | + spin_lock(&sbinfo->stat_lock); |
|---|
| 3570 | 3588 | inodes = sbinfo->max_inodes - sbinfo->free_inodes; |
|---|
| 3571 | 3589 | if ((ctx->seen & SHMEM_SEEN_BLOCKS) && ctx->blocks) { |
|---|
| 3572 | 3590 | if (!sbinfo->max_blocks) { |
|---|
| .. | .. |
|---|
| 3611 | 3629 | * Preserve previous mempolicy unless mpol remount option was specified. |
|---|
| 3612 | 3630 | */ |
|---|
| 3613 | 3631 | if (ctx->mpol) { |
|---|
| 3614 | | - mpol = sbinfo->mpol; |
|---|
| 3632 | + mpol_put(sbinfo->mpol); |
|---|
| 3615 | 3633 | sbinfo->mpol = ctx->mpol; /* transfers initial ref */ |
|---|
| 3616 | 3634 | ctx->mpol = NULL; |
|---|
| 3617 | 3635 | } |
|---|
| 3618 | | - raw_spin_unlock(&sbinfo->stat_lock); |
|---|
| 3619 | | - mpol_put(mpol); |
|---|
| 3636 | + spin_unlock(&sbinfo->stat_lock); |
|---|
| 3620 | 3637 | return 0; |
|---|
| 3621 | 3638 | out: |
|---|
| 3622 | | - raw_spin_unlock(&sbinfo->stat_lock); |
|---|
| 3639 | + spin_unlock(&sbinfo->stat_lock); |
|---|
| 3623 | 3640 | return invalfc(fc, "%s", err); |
|---|
| 3624 | 3641 | } |
|---|
| 3625 | 3642 | |
|---|
| .. | .. |
|---|
| 3736 | 3753 | sbinfo->mpol = ctx->mpol; |
|---|
| 3737 | 3754 | ctx->mpol = NULL; |
|---|
| 3738 | 3755 | |
|---|
| 3739 | | - raw_spin_lock_init(&sbinfo->stat_lock); |
|---|
| 3756 | + spin_lock_init(&sbinfo->stat_lock); |
|---|
| 3740 | 3757 | if (percpu_counter_init(&sbinfo->used_blocks, 0, GFP_KERNEL)) |
|---|
| 3741 | 3758 | goto failed; |
|---|
| 3742 | 3759 | spin_lock_init(&sbinfo->shrinklist_lock); |
|---|
| .. | .. |
|---|
| 4103 | 4120 | .name = "tmpfs", |
|---|
| 4104 | 4121 | .init_fs_context = ramfs_init_fs_context, |
|---|
| 4105 | 4122 | .parameters = ramfs_fs_parameters, |
|---|
| 4106 | | - .kill_sb = kill_litter_super, |
|---|
| 4123 | + .kill_sb = ramfs_kill_sb, |
|---|
| 4107 | 4124 | .fs_flags = FS_USERNS_MOUNT, |
|---|
| 4108 | 4125 | }; |
|---|
| 4109 | 4126 | |
|---|