Compare
eadfe727dd800fc5fca33e45dbfd392ade5bbbd6..3c44cbcec5eb370713bbd2c315ed7c34d8ccec2b
drm/amdgpu: keep the eviction fence until the last handle is closed
amdgpu_gem_object_close() detaches the user queue eviction fence from
the BO before it checks bo_va->ref_count, so closing any handle of a BO
removes the fence, even when the file still has another handle to the
BO and the bo_va with its GPU mappings stays. The BO can then be evicted
without suspending the user queues of the file, which keep accessing it
through mappings that are only marked for update.
Seen on navi31 with a SDMA user queue: a BO opened twice in the same
file (GEM_FLINK + GEM_OPEN) loses its eviction fence when the second
handle is closed (traced attach/detach of the fence):
attach bo=ffff8c78a6c84c00
GEM_CLOSE handle=7
detach bo=ffff8c78a6c84c00
while handle 6 and the mapping are still in use.
Only detach the fence when the last reference to the bo_va goes away,
matching amdgpu_gem_object_open(), which attaches it only when the
bo_va is created. With this the fence stays until the file is closed.
Fixes: 31f7efcdca4d ("drm/amdgpu: enable eviction fence")
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8387982f03d4026b7dc11b0b5e3118298eee4d6a)
Cc: stable@vger.kernel.org
Jesse Zhang <Jesse.Zhang@amd.com> · 2026-10-12 04:24 UTC · committed by Alex Deucher
42 files changed,
+168
−365
- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c
- drivers/gpu/drm/amd/display/dc/link/link_dpms.c
- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
- fs/9p/v9fs.h
- fs/9p/vfs_super.c
- fs/afs/internal.h
- fs/afs/super.c
- fs/autofs/waitq.c
- fs/ext4/ext4.h
- fs/ext4/extents-test.c
- fs/ext4/extents.c
- fs/ext4/extents_status.c
- fs/ext4/extents_status.h
- fs/ext4/super.c
- fs/namei.c
- fs/namespace.c
- fs/notify/mark.c
- fs/ntfs3/dir.c
- fs/ntfs3/ntfs_fs.h
- fs/ntfs3/super.c
- fs/ocfs2/dlm/dlmcommon.h
- fs/ocfs2/dlm/dlmdebug.c
- fs/ocfs2/dlm/dlmrecovery.c
- fs/overlayfs/params.c
- fs/pipe.c
- fs/tracefs/event_inode.c
- fs/unicode/utf8-core.c
- include/linux/fsnotify_backend.h
- include/linux/sched/signal.h
- include/linux/unicode.h
- ipc/namespace.c
- kernel/exit.c
- kernel/fork.c
- kernel/pid_namespace.c
- kernel/watch_queue.c
- samples/pidfd/Makefile
- tools/testing/selftests/filesystems/umount_propagation/locked_mount_test.c
modified drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
| @@ -1431,6 +1431,7 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser) | |||
| 1431 | 1431 | int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |
| 1432 | 1432 | { | |
| 1433 | 1433 | struct amdgpu_device *adev = drm_to_adev(dev); | |
| 1434 | + | struct amdgpu_bo_list_entry *e; | |
| 1434 | 1435 | struct amdgpu_cs_parser parser; | |
| 1435 | 1436 | int r; | |
| 1436 | 1437 | ||
| @@ -1465,25 +1466,31 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
| 1465 | 1466 | ||
| 1466 | 1467 | r = amdgpu_cs_patch_jobs(&parser); | |
| 1467 | 1468 | if (r) | |
| 1468 | - | goto error_fini; | |
| 1469 | + | goto error_free_user_pages; | |
| 1469 | 1470 | ||
| 1470 | 1471 | r = amdgpu_cs_vm_handling(&parser); | |
| 1471 | 1472 | if (r) | |
| 1472 | - | goto error_fini; | |
| 1473 | + | goto error_free_user_pages; | |
| 1473 | 1474 | ||
| 1474 | 1475 | r = amdgpu_cs_sync_rings(&parser); | |
| 1475 | 1476 | if (r) | |
| 1476 | - | goto error_fini; | |
| 1477 | + | goto error_free_user_pages; | |
| 1477 | 1478 | ||
| 1478 | 1479 | trace_amdgpu_cs_ibs(&parser); | |
| 1479 | 1480 | ||
| 1480 | 1481 | r = amdgpu_cs_submit(&parser, data); | |
| 1481 | 1482 | if (r) | |
| 1482 | - | goto error_fini; | |
| 1483 | + | goto error_free_user_pages; | |
| 1483 | 1484 | ||
| 1484 | 1485 | amdgpu_cs_parser_fini(&parser); | |
| 1485 | 1486 | return 0; | |
| 1486 | 1487 | ||
| 1488 | + | error_free_user_pages: | |
| 1489 | + | /* amdgpu_cs_submit() only drops the ranges once it got that far. */ | |
| 1490 | + | amdgpu_bo_list_for_each_userptr_entry(e, parser.bo_list) { | |
| 1491 | + | amdgpu_hmm_range_free(e->range); | |
| 1492 | + | e->range = NULL; | |
| 1493 | + | } | |
| 1487 | 1494 | error_fini: | |
| 1488 | 1495 | amdgpu_cs_parser_fini(&parser); | |
| 1489 | 1496 | return r; | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
| @@ -1266,7 +1266,6 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, | |||
| 1266 | 1266 | { | |
| 1267 | 1267 | struct amdgpu_device *adev = f->f_inode->i_private; | |
| 1268 | 1268 | int r; | |
| 1269 | - | ssize_t result = 0; | |
| 1270 | 1269 | uint32_t offset, se, sh, cu, wave, simd, thread, bank, *data; | |
| 1271 | 1270 | ||
| 1272 | 1271 | if (size > 4096 || size & 3 || *pos & 3) | |
| @@ -1310,25 +1309,11 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, | |||
| 1310 | 1309 | mutex_unlock(&adev->grbm_idx_mutex); | |
| 1311 | 1310 | ||
| 1312 | 1311 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| 1312 | + | amdgpu_virt_disable_access_debugfs(adev); | |
| 1313 | 1313 | ||
| 1314 | - | while (size) { | |
| 1315 | - | uint32_t value; | |
| 1316 | - | ||
| 1317 | - | value = data[result >> 2]; | |
| 1318 | - | r = put_user(value, (uint32_t *)buf); | |
| 1319 | - | if (r) { | |
| 1320 | - | amdgpu_virt_disable_access_debugfs(adev); | |
| 1321 | - | goto err; | |
| 1322 | - | } | |
| 1323 | - | ||
| 1324 | - | result += 4; | |
| 1325 | - | buf += 4; | |
| 1326 | - | size -= 4; | |
| 1327 | - | } | |
| 1328 | - | ||
| 1314 | + | r = copy_to_user(buf, data, size) ? -EFAULT : size; | |
| 1329 | 1315 | kfree(data); | |
| 1330 | - | amdgpu_virt_disable_access_debugfs(adev); | |
| 1331 | - | return result; | |
| 1316 | + | return r; | |
| 1332 | 1317 | ||
| 1333 | 1318 | err: | |
| 1334 | 1319 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
| @@ -337,11 +337,14 @@ static void amdgpu_gem_object_close(struct drm_gem_object *obj, | |||
| 337 | 337 | goto out_unlock; | |
| 338 | 338 | } | |
| 339 | 339 | ||
| 340 | + | bo_va = amdgpu_vm_bo_find(vm, bo); | |
| 341 | + | /* the fence is attached once per bo_va, so keep it for other handles */ | |
| 342 | + | if (bo_va && --bo_va->ref_count) | |
| 343 | + | goto out_unlock; | |
| 344 | + | ||
| 340 | 345 | if (!amdgpu_vm_is_bo_always_valid(vm, bo)) | |
| 341 | 346 | amdgpu_evf_mgr_detach_fence(&fpriv->evf_mgr, bo); | |
| 342 | - | ||
| 343 | - | bo_va = amdgpu_vm_bo_find(vm, bo); | |
| 344 | - | if (!bo_va || --bo_va->ref_count) | |
| 347 | + | if (!bo_va) | |
| 345 | 348 | goto out_unlock; | |
| 346 | 349 | ||
| 347 | 350 | amdgpu_vm_bo_del(adev, bo_va); | |
| @@ -567,8 +570,10 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, | |||
| 567 | 570 | ||
| 568 | 571 | if (args->flags & AMDGPU_GEM_USERPTR_VALIDATE) { | |
| 569 | 572 | range = amdgpu_hmm_range_alloc(NULL); | |
| 570 | - | if (unlikely(!range)) | |
| 571 | - | return -ENOMEM; | |
| 573 | + | if (unlikely(!range)) { | |
| 574 | + | r = -ENOMEM; | |
| 575 | + | goto release_object; | |
| 576 | + | } | |
| 572 | 577 | r = amdgpu_ttm_tt_get_user_pages(bo, range); | |
| 573 | 578 | if (r) { | |
| 574 | 579 | amdgpu_hmm_range_free(range); | |
| @@ -1236,7 +1241,7 @@ int amdgpu_gem_list_handles_ioctl(struct drm_device *dev, void *data, | |||
| 1236 | 1241 | bo_entry->alloc_flags = bo->flags & AMDGPU_GEM_CREATE_SETTABLE_MASK; | |
| 1237 | 1242 | bo_entry->preferred_domains = bo->preferred_domains; | |
| 1238 | 1243 | bo_entry->gem_handle = id; | |
| 1239 | - | bo_entry->alignment = bo->tbo.page_alignment; | |
| 1244 | + | bo_entry->alignment = (u64)bo->tbo.page_alignment << PAGE_SHIFT; | |
| 1240 | 1245 | ||
| 1241 | 1246 | if (bo->tbo.base.import_attach) | |
| 1242 | 1247 | bo_entry->flags |= AMDGPU_GEM_LIST_HANDLES_FLAG_IS_IMPORT; | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
| @@ -2065,14 +2065,15 @@ static int amdgpu_ttm_buffer_entity_init(struct amdgpu_gtt_mgr *mgr, | |||
| 2065 | 2065 | int i, r, num_pages; | |
| 2066 | 2066 | const u64 GTT_MAX_PAGES = (AMDGPU_GTT_MAX_TRANSFER_SIZE >> PAGE_SHIFT); | |
| 2067 | 2067 | ||
| 2068 | + | if (ARRAY_SIZE(entity->gart_window_offs) < num_gart_windows) | |
| 2069 | + | return -EINVAL; | |
| 2070 | + | ||
| 2068 | 2071 | r = drm_sched_entity_init(&entity->base, prio, scheds, num_schedulers, NULL); | |
| 2069 | 2072 | if (r) | |
| 2070 | 2073 | return r; | |
| 2071 | 2074 | ||
| 2072 | 2075 | mutex_init(&entity->lock); | |
| 2073 | 2076 | ||
| 2074 | - | if (ARRAY_SIZE(entity->gart_window_offs) < num_gart_windows) | |
| 2075 | - | return -EINVAL; | |
| 2076 | 2077 | if (num_gart_windows == 0) | |
| 2077 | 2078 | return 0; | |
| 2078 | 2079 | ||
| @@ -2080,6 +2081,7 @@ static int amdgpu_ttm_buffer_entity_init(struct amdgpu_gtt_mgr *mgr, | |||
| 2080 | 2081 | r = amdgpu_gtt_mgr_alloc_entries(mgr, &entity->gart_node, num_pages, | |
| 2081 | 2082 | DRM_MM_INSERT_BEST); | |
| 2082 | 2083 | if (r) { | |
| 2084 | + | mutex_destroy(&entity->lock); | |
| 2083 | 2085 | drm_sched_entity_destroy(&entity->base); | |
| 2084 | 2086 | return r; | |
| 2085 | 2087 | } | |
| @@ -2097,6 +2099,7 @@ static void amdgpu_ttm_buffer_entity_fini(struct amdgpu_gtt_mgr *mgr, | |||
| 2097 | 2099 | struct amdgpu_ttm_buffer_entity *entity) | |
| 2098 | 2100 | { | |
| 2099 | 2101 | amdgpu_gtt_mgr_free_entries(mgr, &entity->gart_node); | |
| 2102 | + | mutex_destroy(&entity->lock); | |
| 2100 | 2103 | drm_sched_entity_destroy(&entity->base); | |
| 2101 | 2104 | } | |
| 2102 | 2105 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
| @@ -980,19 +980,21 @@ amdgpu_userq_bo_validate(struct amdgpu_device *adev, struct drm_exec *exec, | |||
| 980 | 980 | { | |
| 981 | 981 | struct ttm_operation_ctx ctx = { false, false }; | |
| 982 | 982 | struct amdgpu_bo_va *bo_va; | |
| 983 | - | struct amdgpu_bo *bo; | |
| 983 | + | struct amdgpu_bo *bo, *tmp; | |
| 984 | 984 | int ret; | |
| 985 | 985 | ||
| 986 | 986 | spin_lock(&vm->individual_lock); | |
| 987 | - | while (!list_empty(&vm->always_valid.evicted)) { | |
| 988 | - | bo_va = list_first_entry(&vm->always_valid.evicted, | |
| 987 | + | while (!list_empty(&vm->individual.evicted)) { | |
| 988 | + | bo_va = list_first_entry(&vm->individual.evicted, | |
| 989 | 989 | struct amdgpu_bo_va, | |
| 990 | 990 | base.vm_status); | |
| 991 | + | bo = bo_va->base.bo; | |
| 992 | + | tmp = amdgpu_bo_ref(bo); | |
| 991 | 993 | spin_unlock(&vm->individual_lock); | |
| 992 | 994 | ||
| 993 | - | bo = bo_va->base.bo; | |
| 994 | 995 | ret = drm_exec_prepare_obj(exec, &bo->tbo.base, | |
| 995 | 996 | TTM_NUM_MOVE_FENCES + 1); | |
| 997 | + | amdgpu_bo_unref(&tmp); | |
| 996 | 998 | if (unlikely(ret)) | |
| 997 | 999 | return ret; | |
| 998 | 1000 | ||
modified drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c
| @@ -288,7 +288,7 @@ static int uvd_v3_1_fw_validate(struct amdgpu_device *adev) | |||
| 288 | 288 | int i; | |
| 289 | 289 | uint32_t keysel = adev->uvd.keyselect; | |
| 290 | 290 | ||
| 291 | - | if (RREG32(mmUVD_FW_START) & UVD_FW_STATUS__PASS_MASK) { | |
| 291 | + | if (RREG32(mmUVD_FW_START)) { | |
| 292 | 292 | dev_dbg(adev->dev, "UVD keyselect already set: 0x%x (on CPU: 0x%x)\n", | |
| 293 | 293 | RREG32(mmUVD_FW_START), adev->uvd.keyselect); | |
| 294 | 294 | return 0; | |
modified drivers/gpu/drm/amd/display/dc/link/link_dpms.c
| @@ -2306,9 +2306,14 @@ static bool allocate_usb4_bandwidth_for_stream(struct dc_stream_state *stream, i | |||
| 2306 | 2306 | { | |
| 2307 | 2307 | ASSERT(stream->sink); | |
| 2308 | 2308 | ||
| 2309 | - | struct dc_link *link = stream->sink->link; | |
| 2309 | + | struct dc_link *link; | |
| 2310 | 2310 | int req_bw = stream_bw; | |
| 2311 | 2311 | ||
| 2312 | + | if (!stream->sink) | |
| 2313 | + | return false; | |
| 2314 | + | ||
| 2315 | + | link = stream->sink->link; | |
| 2316 | + | ||
| 2312 | 2317 | DC_LOGGER_INIT(link->ctx->logger); | |
| 2313 | 2318 | ||
| 2314 | 2319 | if (!link->dpia_bw_alloc_config.bw_alloc_enabled) | |
| @@ -2355,9 +2360,13 @@ static bool allocate_usb4_bandwidth(struct dc_stream_state *stream) | |||
| 2355 | 2360 | ASSERT(stream->sink); | |
| 2356 | 2361 | ||
| 2357 | 2362 | bool ret; | |
| 2363 | + | int bw; | |
| 2358 | 2364 | ||
| 2359 | - | int bw = dc_bandwidth_in_kbps_from_timing(&stream->timing, | |
| 2360 | - | dc_link_get_highest_encoding_format(stream->sink->link)); | |
| 2365 | + | if (!stream->sink) | |
| 2366 | + | return false; | |
| 2367 | + | ||
| 2368 | + | bw = dc_bandwidth_in_kbps_from_timing(&stream->timing, | |
| 2369 | + | dc_link_get_highest_encoding_format(stream->sink->link)); | |
| 2361 | 2370 | ||
| 2362 | 2371 | ret = allocate_usb4_bandwidth_for_stream(stream, bw); | |
| 2363 | 2372 | ||
| @@ -2419,7 +2428,8 @@ enum dc_status link_set_dpms_off(struct pipe_ctx *pipe_ctx) | |||
| 2419 | 2428 | update_psp_stream_config(pipe_ctx, true); | |
| 2420 | 2429 | dc->hwss.blank_stream(pipe_ctx); | |
| 2421 | 2430 | ||
| 2422 | - | if (pipe_ctx->link_config.dp_tunnel_settings.should_use_dp_bw_allocation) | |
| 2431 | + | if (pipe_ctx->link_config.dp_tunnel_settings.should_use_dp_bw_allocation && | |
| 2432 | + | stream->sink) | |
| 2423 | 2433 | deallocate_usb4_bandwidth(stream); | |
| 2424 | 2434 | ||
| 2425 | 2435 | if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) | |
modified drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
| @@ -89,6 +89,7 @@ static const struct smu_feature_bits smu_v14_0_2_dpm_features = { | |||
| 89 | 89 | #define PP_OD_FEATURE_FAN_TARGET_TEMPERATURE 9 | |
| 90 | 90 | #define PP_OD_FEATURE_FAN_MINIMUM_PWM 10 | |
| 91 | 91 | #define PP_OD_FEATURE_FAN_ZERO_RPM_ENABLE 11 | |
| 92 | + | #define PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP 12 | |
| 92 | 93 | ||
| 93 | 94 | static struct cmn2asic_msg_mapping smu_v14_0_2_message_map[SMU_MSG_MAX_COUNT] = { | |
| 94 | 95 | MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1), | |
| @@ -1020,6 +1021,10 @@ static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu, | |||
| 1020 | 1021 | od_min_setting = overdrive_lowerlimits->FanZeroRpmEnable; | |
| 1021 | 1022 | od_max_setting = overdrive_upperlimits->FanZeroRpmEnable; | |
| 1022 | 1023 | break; | |
| 1024 | + | case PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP: | |
| 1025 | + | od_min_setting = pptable->SkuTable.MsgLimits.FanStopTempMin; | |
| 1026 | + | od_max_setting = pptable->SkuTable.MsgLimits.FanStopTempMax; | |
| 1027 | + | break; | |
| 1023 | 1028 | default: | |
| 1024 | 1029 | od_min_setting = od_max_setting = INT_MAX; | |
| 1025 | 1030 | break; | |
| @@ -1244,6 +1249,24 @@ static int smu_v14_0_2_emit_clk_levels(struct smu_context *smu, | |||
| 1244 | 1249 | min_value, max_value); | |
| 1245 | 1250 | break; | |
| 1246 | 1251 | ||
| 1252 | + | case SMU_OD_FAN_ZERO_RPM_STOP_TEMP: | |
| 1253 | + | if (!smu_v14_0_2_is_od_feature_supported(smu, | |
| 1254 | + | PP_OD_FEATURE_ZERO_FAN_BIT)) | |
| 1255 | + | break; | |
| 1256 | + | ||
| 1257 | + | size += sysfs_emit_at(buf, size, "FAN_ZERO_RPM_STOP_TEMPERATURE:\n"); | |
| 1258 | + | size += sysfs_emit_at(buf, size, "%d\n", | |
| 1259 | + | (int)od_table->OverDriveTable.FanZeroRpmStopTemp); | |
| 1260 | + | ||
| 1261 | + | size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE"); | |
| 1262 | + | smu_v14_0_2_get_od_setting_limits(smu, | |
| 1263 | + | PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP, | |
| 1264 | + | &min_value, | |
| 1265 | + | &max_value); | |
| 1266 | + | size += sysfs_emit_at(buf, size, "ZERO_RPM_STOP_TEMPERATURE: %u %u\n", | |
| 1267 | + | min_value, max_value); | |
| 1268 | + | break; | |
| 1269 | + | ||
| 1247 | 1270 | case SMU_OD_RANGE: | |
| 1248 | 1271 | if (!smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_GFXCLK_BIT) && | |
| 1249 | 1272 | !smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_UCLK_BIT) && | |
| @@ -2311,7 +2334,9 @@ static void smu_v14_0_2_set_supported_od_feature_mask(struct smu_context *smu) | |||
| 2311 | 2334 | OD_OPS_SUPPORT_FAN_MINIMUM_PWM_RETRIEVE | | |
| 2312 | 2335 | OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET | | |
| 2313 | 2336 | OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_RETRIEVE | | |
| 2314 | - | OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET; | |
| 2337 | + | OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET | | |
| 2338 | + | OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_RETRIEVE | | |
| 2339 | + | OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_SET; | |
| 2315 | 2340 | } | |
| 2316 | 2341 | ||
| 2317 | 2342 | static int smu_v14_0_2_get_overdrive_table(struct smu_context *smu, | |
| @@ -2392,6 +2417,8 @@ static int smu_v14_0_2_set_default_od_settings(struct smu_context *smu) | |||
| 2392 | 2417 | user_od_table_bak.OverDriveTable.FanMinimumPwm; | |
| 2393 | 2418 | user_od_table->OverDriveTable.FanZeroRpmEnable = | |
| 2394 | 2419 | user_od_table_bak.OverDriveTable.FanZeroRpmEnable; | |
| 2420 | + | user_od_table->OverDriveTable.FanZeroRpmStopTemp = | |
| 2421 | + | user_od_table_bak.OverDriveTable.FanZeroRpmStopTemp; | |
| 2395 | 2422 | } | |
| 2396 | 2423 | ||
| 2397 | 2424 | smu_v14_0_2_set_supported_od_feature_mask(smu); | |
| @@ -2446,6 +2473,11 @@ static int smu_v14_0_2_od_restore_table_single(struct smu_context *smu, long inp | |||
| 2446 | 2473 | boot_overdrive_table->OverDriveTable.FanZeroRpmEnable; | |
| 2447 | 2474 | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2448 | 2475 | break; | |
| 2476 | + | case PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP: | |
| 2477 | + | od_table->OverDriveTable.FanZeroRpmStopTemp = | |
| 2478 | + | boot_overdrive_table->OverDriveTable.FanZeroRpmStopTemp; | |
| 2479 | + | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2480 | + | break; | |
| 2449 | 2481 | case PP_OD_EDIT_ACOUSTIC_LIMIT: | |
| 2450 | 2482 | od_table->OverDriveTable.AcousticLimitRpmThreshold = | |
| 2451 | 2483 | boot_overdrive_table->OverDriveTable.AcousticLimitRpmThreshold; | |
| @@ -2752,6 +2784,27 @@ static int smu_v14_0_2_od_edit_dpm_table(struct smu_context *smu, | |||
| 2752 | 2784 | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2753 | 2785 | break; | |
| 2754 | 2786 | ||
| 2787 | + | case PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP: | |
| 2788 | + | if (!smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_ZERO_FAN_BIT)) { | |
| 2789 | + | dev_warn(adev->dev, "Zero RPM setting not supported!\n"); | |
| 2790 | + | return -ENOTSUPP; | |
| 2791 | + | } | |
| 2792 | + | ||
| 2793 | + | smu_v14_0_2_get_od_setting_limits(smu, | |
| 2794 | + | PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP, | |
| 2795 | + | &minimum, | |
| 2796 | + | &maximum); | |
| 2797 | + | if (input[0] < minimum || | |
| 2798 | + | input[0] > maximum) { | |
| 2799 | + | dev_info(adev->dev, "zero RPM stop temperature setting(%ld) must be within [%d, %d]!\n", | |
| 2800 | + | input[0], minimum, maximum); | |
| 2801 | + | return -EINVAL; | |
| 2802 | + | } | |
| 2803 | + | ||
| 2804 | + | od_table->OverDriveTable.FanZeroRpmStopTemp = input[0]; | |
| 2805 | + | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2806 | + | break; | |
| 2807 | + | ||
| 2755 | 2808 | case PP_OD_RESTORE_DEFAULT_TABLE: | |
| 2756 | 2809 | if (size == 1) { | |
| 2757 | 2810 | ret = smu_v14_0_2_od_restore_table_single(smu, input[0]); | |
modified fs/9p/v9fs.h
| @@ -137,7 +137,6 @@ struct v9fs_session_info { | |||
| 137 | 137 | struct list_head slist; /* list of sessions registered with v9fs */ | |
| 138 | 138 | struct rw_semaphore rename_sem; | |
| 139 | 139 | long session_lock_timeout; /* retry interval for blocking locks */ | |
| 140 | - | struct rcu_head rcu; /* v9fs_vfs_get_link_dotl() reads ->cache in rcu pathwalk */ | |
| 141 | 140 | }; | |
| 142 | 141 | ||
| 143 | 142 | #define NDENTRY_TIMEOUT_NEVER (-1U) | |
modified fs/9p/vfs_super.c
| @@ -173,8 +173,8 @@ static void v9fs_kill_super(struct super_block *s) | |||
| 173 | 173 | ||
| 174 | 174 | v9fs_session_cancel(v9ses); | |
| 175 | 175 | v9fs_session_close(v9ses); | |
| 176 | - | /* v9fs_vfs_get_link_dotl() may still read ->cache in rcu pathwalk */ | |
| 177 | - | kfree_rcu(v9ses, rcu); | |
| 176 | + | kfree(v9ses); | |
| 177 | + | s->s_fs_info = NULL; | |
| 178 | 178 | p9_debug(P9_DEBUG_VFS, "exiting kill_super\n"); | |
| 179 | 179 | } | |
| 180 | 180 | ||
modified fs/afs/internal.h
| @@ -251,8 +251,6 @@ struct afs_super_info { | |||
| 251 | 251 | struct afs_volume *volume; /* volume record */ | |
| 252 | 252 | enum afs_flock_mode flock_mode:8; /* File locking emulation mode */ | |
| 253 | 253 | bool dyn_root; /* True if dynamic root */ | |
| 254 | - | /* afs_atcell_get_link() reads ->net_ns in rcu pathwalk */ | |
| 255 | - | struct rcu_head rcu; | |
| 256 | 254 | }; | |
| 257 | 255 | ||
| 258 | 256 | static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) | |
modified fs/afs/super.c
| @@ -523,7 +523,7 @@ static void afs_destroy_sbi(struct afs_super_info *as) | |||
| 523 | 523 | afs_put_volume(as->volume, afs_volume_trace_put_destroy_sbi); | |
| 524 | 524 | afs_unuse_cell(as->cell, afs_cell_trace_unuse_sbi); | |
| 525 | 525 | put_net(as->net_ns); | |
| 526 | - | kfree_rcu(as, rcu); | |
| 526 | + | kfree(as); | |
| 527 | 527 | } | |
| 528 | 528 | } | |
| 529 | 529 | ||
modified fs/autofs/waitq.c
| @@ -12,13 +12,15 @@ | |||
| 12 | 12 | */ | |
| 13 | 13 | static autofs_wqt_t autofs_next_wait_queue = 1; | |
| 14 | 14 | ||
| 15 | - | static void autofs_catatonic_mode_locked(struct autofs_sb_info *sbi) | |
| 15 | + | void autofs_catatonic_mode(struct autofs_sb_info *sbi) | |
| 16 | 16 | { | |
| 17 | 17 | struct autofs_wait_queue *wq, *nwq; | |
| 18 | 18 | ||
| 19 | - | lockdep_assert_held(&sbi->wq_mutex); | |
| 20 | - | if (sbi->flags & AUTOFS_SBI_CATATONIC) | |
| 19 | + | mutex_lock(&sbi->wq_mutex); | |
| 20 | + | if (sbi->flags & AUTOFS_SBI_CATATONIC) { | |
| 21 | + | mutex_unlock(&sbi->wq_mutex); | |
| 21 | 22 | return; | |
| 23 | + | } | |
| 22 | 24 | ||
| 23 | 25 | pr_debug("entering catatonic mode\n"); | |
| 24 | 26 | ||
| @@ -38,21 +40,6 @@ static void autofs_catatonic_mode_locked(struct autofs_sb_info *sbi) | |||
| 38 | 40 | fput(sbi->pipe); /* Close the pipe */ | |
| 39 | 41 | sbi->pipe = NULL; | |
| 40 | 42 | sbi->pipefd = -1; | |
| 41 | - | } | |
| 42 | - | ||
| 43 | - | void autofs_catatonic_mode(struct autofs_sb_info *sbi) | |
| 44 | - | { | |
| 45 | - | mutex_lock(&sbi->wq_mutex); | |
| 46 | - | autofs_catatonic_mode_locked(sbi); | |
| 47 | - | mutex_unlock(&sbi->wq_mutex); | |
| 48 | - | } | |
| 49 | - | ||
| 50 | - | static void autofs_catatonic_mode_for_pipe(struct autofs_sb_info *sbi, | |
| 51 | - | struct file *pipe) | |
| 52 | - | { | |
| 53 | - | mutex_lock(&sbi->wq_mutex); | |
| 54 | - | if (sbi->pipe == pipe) | |
| 55 | - | autofs_catatonic_mode_locked(sbi); | |
| 56 | 43 | mutex_unlock(&sbi->wq_mutex); | |
| 57 | 44 | } | |
| 58 | 45 | ||
| @@ -183,7 +170,7 @@ static void autofs_notify_daemon(struct autofs_sb_info *sbi, | |||
| 183 | 170 | autofs_wait_release(sbi, wq->wait_queue_token, ret); | |
| 184 | 171 | break; | |
| 185 | 172 | default: | |
| 186 | - | autofs_catatonic_mode_for_pipe(sbi, pipe); | |
| 173 | + | autofs_catatonic_mode(sbi); | |
| 187 | 174 | break; | |
| 188 | 175 | } | |
| 189 | 176 | fput(pipe); | |
modified fs/ext4/ext4.h
| @@ -1774,8 +1774,6 @@ struct ext4_sb_info { | |||
| 1774 | 1774 | struct list_head s_es_list; /* List of inodes with reclaimable extents */ | |
| 1775 | 1775 | long s_es_nr_inode; | |
| 1776 | 1776 | struct ext4_es_stats s_es_stats; | |
| 1777 | - | /* ext4_get_link() reads the sbi in rcu pathwalk */ | |
| 1778 | - | struct rcu_head s_rcu; | |
| 1779 | 1777 | struct mb_cache *s_ea_block_cache; | |
| 1780 | 1778 | struct mb_cache *s_ea_inode_cache; | |
| 1781 | 1779 | ||
modified fs/ext4/extents-test.c
| @@ -151,7 +151,6 @@ static void extents_kunit_exit(struct kunit *test) | |||
| 151 | 151 | ||
| 152 | 152 | sbi = k_ctx.k_ei->vfs_inode.i_sb->s_fs_info; | |
| 153 | 153 | ext4_es_unregister_shrinker(sbi); | |
| 154 | - | ext4_es_destroy_stats(sbi); | |
| 155 | 154 | deactivate_super(sbi->s_sb); | |
| 156 | 155 | kfree(sbi); | |
| 157 | 156 | kfree(k_ctx.k_ei); | |
| @@ -341,7 +340,6 @@ out: | |||
| 341 | 340 | k_ctx.k_data = NULL; | |
| 342 | 341 | ||
| 343 | 342 | ext4_es_unregister_shrinker(sbi); | |
| 344 | - | ext4_es_destroy_stats(sbi); | |
| 345 | 343 | out_deactivate: | |
| 346 | 344 | deactivate_locked_super(sb); | |
| 347 | 345 | kfree(sbi); | |
modified fs/ext4/extents.c
| @@ -6409,7 +6409,6 @@ EXPORT_SYMBOL_FOR_EXT4_TEST(__ext4_ext_dirty); | |||
| 6409 | 6409 | EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_zeroout); | |
| 6410 | 6410 | EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_register_shrinker); | |
| 6411 | 6411 | EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_unregister_shrinker); | |
| 6412 | - | EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_destroy_stats); | |
| 6413 | 6412 | EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_create_blocks); | |
| 6414 | 6413 | EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_init_tree); | |
| 6415 | 6414 | EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_lookup_extent); | |
modified fs/ext4/extents_status.c
| @@ -1881,17 +1881,12 @@ err1: | |||
| 1881 | 1881 | } | |
| 1882 | 1882 | ||
| 1883 | 1883 | void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi) | |
| 1884 | - | { | |
| 1885 | - | shrinker_free(sbi->s_es_shrinker); | |
| 1886 | - | } | |
| 1887 | - | ||
| 1888 | - | /* ext4_get_link() bumps the hit and miss counters in rcu pathwalk */ | |
| 1889 | - | void ext4_es_destroy_stats(struct ext4_sb_info *sbi) | |
| 1890 | 1884 | { | |
| 1891 | 1885 | percpu_counter_destroy(&sbi->s_es_stats.es_stats_cache_hits); | |
| 1892 | 1886 | percpu_counter_destroy(&sbi->s_es_stats.es_stats_cache_misses); | |
| 1893 | 1887 | percpu_counter_destroy(&sbi->s_es_stats.es_stats_all_cnt); | |
| 1894 | 1888 | percpu_counter_destroy(&sbi->s_es_stats.es_stats_shk_cnt); | |
| 1889 | + | shrinker_free(sbi->s_es_shrinker); | |
| 1895 | 1890 | } | |
| 1896 | 1891 | ||
| 1897 | 1892 | /* | |
modified fs/ext4/extents_status.h
| @@ -238,7 +238,6 @@ static inline void ext4_es_store_pblock_status(struct extent_status *es, | |||
| 238 | 238 | ||
| 239 | 239 | extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi); | |
| 240 | 240 | extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi); | |
| 241 | - | extern void ext4_es_destroy_stats(struct ext4_sb_info *sbi); | |
| 242 | 241 | ||
| 243 | 242 | extern int ext4_seq_es_shrinker_info_show(struct seq_file *seq, void *v); | |
| 244 | 243 | ||
modified fs/ext4/super.c
| @@ -1279,14 +1279,6 @@ static void ext4_flex_groups_free(struct ext4_sb_info *sbi) | |||
| 1279 | 1279 | } | |
| 1280 | 1280 | } | |
| 1281 | 1281 | ||
| 1282 | - | static void ext4_put_sbi_rcu(struct rcu_head *head) | |
| 1283 | - | { | |
| 1284 | - | struct ext4_sb_info *sbi = container_of(head, struct ext4_sb_info, s_rcu); | |
| 1285 | - | ||
| 1286 | - | ext4_es_destroy_stats(sbi); | |
| 1287 | - | kfree(sbi); | |
| 1288 | - | } | |
| 1289 | - | ||
| 1290 | 1282 | static void ext4_put_super(struct super_block *sb) | |
| 1291 | 1283 | { | |
| 1292 | 1284 | struct ext4_sb_info *sbi = EXT4_SB(sb); | |
| @@ -1382,6 +1374,7 @@ static void ext4_put_super(struct super_block *sb) | |||
| 1382 | 1374 | ext4_stop_mmpd(sbi); | |
| 1383 | 1375 | ||
| 1384 | 1376 | brelse(sbi->s_sbh); | |
| 1377 | + | sb->s_fs_info = NULL; | |
| 1385 | 1378 | /* | |
| 1386 | 1379 | * Now that we are completely done shutting down the | |
| 1387 | 1380 | * superblock, we need to actually destroy the kobject. | |
| @@ -1394,8 +1387,7 @@ static void ext4_put_super(struct super_block *sb) | |||
| 1394 | 1387 | #if IS_ENABLED(CONFIG_UNICODE) | |
| 1395 | 1388 | utf8_unload(sb->s_encoding); | |
| 1396 | 1389 | #endif | |
| 1397 | - | /* ext4_get_link() reads the sbi and the counters in rcu pathwalk */ | |
| 1398 | - | call_rcu(&sbi->s_rcu, ext4_put_sbi_rcu); | |
| 1390 | + | kfree(sbi); | |
| 1399 | 1391 | } | |
| 1400 | 1392 | ||
| 1401 | 1393 | static struct kmem_cache *ext4_inode_cachep; | |
| @@ -5814,7 +5806,6 @@ failed_mount3a: | |||
| 5814 | 5806 | /* Drain deferred EA inode iputs from journal replay */ | |
| 5815 | 5807 | flush_delayed_work(&sbi->s_ea_inode_work); | |
| 5816 | 5808 | ext4_es_unregister_shrinker(sbi); | |
| 5817 | - | ext4_es_destroy_stats(sbi); | |
| 5818 | 5809 | failed_mount3: | |
| 5819 | 5810 | /* flush s_sb_upd_work before sbi destroy */ | |
| 5820 | 5811 | flush_work(&sbi->s_sb_upd_work); | |
modified fs/namei.c
| @@ -4750,7 +4750,8 @@ static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag) | |||
| 4750 | 4750 | return dentry; | |
| 4751 | 4751 | ||
| 4752 | 4752 | if (open_flag & O_CREAT) { | |
| 4753 | - | if (d_is_negative(dentry)) { | |
| 4753 | + | /* Discard negative dentries. Need inode_lock to do the create */ | |
| 4754 | + | if (!dentry->d_inode) { | |
| 4754 | 4755 | if (!(nd->flags & LOOKUP_RCU)) | |
| 4755 | 4756 | dput(dentry); | |
| 4756 | 4757 | dentry = NULL; | |
modified fs/namespace.c
| @@ -297,11 +297,7 @@ int mnt_get_count(struct mount *mnt) | |||
| 297 | 297 | /* puts first, so a put counted here has its get counted below */ | |
| 298 | 298 | for_each_possible_cpu(cpu) | |
| 299 | 299 | puts += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_puts; | |
| 300 | - | /* | |
| 301 | - | * Pairs with the smp_wmb() in mntput_no_expire() and with the | |
| 302 | - | * smp_mb() in __legitimize_mnt(). | |
| 303 | - | */ | |
| 304 | - | smp_mb(); | |
| 300 | + | smp_mb(); /* pairs with the smp_wmb() in mntput_no_expire() */ | |
| 305 | 301 | for_each_possible_cpu(cpu) | |
| 306 | 302 | gets += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_gets; | |
| 307 | 303 | ||
| @@ -786,7 +782,7 @@ int __legitimize_mnt(struct vfsmount *bastard, unsigned seq) | |||
| 786 | 782 | return 0; | |
| 787 | 783 | mnt = real_mount(bastard); | |
| 788 | 784 | mnt_inc_count(mnt); | |
| 789 | - | smp_mb(); /* pairs with the smp_mb() in mnt_get_count() */ | |
| 785 | + | smp_mb(); /* see mntput_no_expire_slowpath() and do_umount() */ | |
| 790 | 786 | if (likely(!read_seqretry(&mount_lock, seq))) | |
| 791 | 787 | return 0; | |
| 792 | 788 | lock_mount_hash(); | |
| @@ -1423,6 +1419,11 @@ static void noinline mntput_no_expire_slowpath(struct mount *mnt) | |||
| 1423 | 1419 | ||
| 1424 | 1420 | VFS_BUG_ON(mnt->mnt_ns); | |
| 1425 | 1421 | lock_mount_hash(); | |
| 1422 | + | /* | |
| 1423 | + | * make sure that if __legitimize_mnt() has not seen us grab | |
| 1424 | + | * mount_lock, we'll see their refcount increment here. | |
| 1425 | + | */ | |
| 1426 | + | smp_mb(); | |
| 1426 | 1427 | mnt_dec_count(mnt); | |
| 1427 | 1428 | count = mnt_get_count(mnt); | |
| 1428 | 1429 | if (count != 0) { | |
| @@ -2005,6 +2006,7 @@ static int do_umount(struct mount *mnt, int flags) | |||
| 2005 | 2006 | umount_tree(mnt, UMOUNT_PROPAGATE); | |
| 2006 | 2007 | retval = 0; | |
| 2007 | 2008 | } else { | |
| 2009 | + | smp_mb(); // paired with __legitimize_mnt() | |
| 2008 | 2010 | shrink_submounts(mnt); | |
| 2009 | 2011 | retval = -EBUSY; | |
| 2010 | 2012 | if (!propagate_mount_busy(mnt, 2)) { | |
| @@ -2252,11 +2254,6 @@ struct mount *copy_tree(struct mount *src_root, struct dentry *dentry, | |||
| 2252 | 2254 | } | |
| 2253 | 2255 | if (!(flag & CL_COPY_MNT_NS_FILE) && | |
| 2254 | 2256 | is_mnt_ns_file(src_mnt->mnt.mnt_root)) { | |
| 2255 | - | if (src_mnt->mnt.mnt_flags & MNT_LOCKED) { | |
| 2256 | - | /* Both a mount namespace file and locked. */ | |
| 2257 | - | dst_mnt = ERR_PTR(-EPERM); | |
| 2258 | - | goto out; | |
| 2259 | - | } | |
| 2260 | 2257 | src_mnt = skip_mnt_tree(src_mnt); | |
| 2261 | 2258 | continue; | |
| 2262 | 2259 | } | |
| @@ -3652,9 +3649,8 @@ static bool mount_is_ancestor(const struct mount *p1, const struct mount *p2) | |||
| 3652 | 3649 | * @mnt_to: mount under which to mount | |
| 3653 | 3650 | * @mp: mountpoint of @mnt_to | |
| 3654 | 3651 | * | |
| 3655 | - | * - Make sure that @mnt_from can take over the lock of @mnt_to. A | |
| 3656 | - | * mount of a mount namespace file is left out of a copy of the tree | |
| 3657 | - | * and can't. | |
| 3652 | + | * - Make sure that the caller can unmount the topmost mount ensuring | |
| 3653 | + | * that the caller could reveal the underlying mountpoint. | |
| 3658 | 3654 | * - Ensure that nothing has been mounted on top of @mnt_from before we | |
| 3659 | 3655 | * grabbed @namespace_sem to avoid creating pointless shadow mounts. | |
| 3660 | 3656 | * - Prevent mounting beneath a mount if the propagation relationship | |
| @@ -3670,15 +3666,6 @@ static int can_move_mount_beneath(const struct mount *mnt_from, | |||
| 3670 | 3666 | { | |
| 3671 | 3667 | struct mount *parent_mnt_to = mnt_to->mnt_parent; | |
| 3672 | 3668 | ||
| 3673 | - | /* | |
| 3674 | - | * @mnt_from takes over the lock of @mnt_to. copy_tree() leaves a | |
| 3675 | - | * mount of a mount namespace file out of every copy made without | |
| 3676 | - | * CL_COPY_MNT_NS_FILE, together with what is mounted on it, so it | |
| 3677 | - | * can't keep anything hidden. | |
| 3678 | - | */ | |
| 3679 | - | if (IS_MNT_LOCKED(mnt_to) && is_mnt_ns_file(mnt_from->mnt.mnt_root)) | |
| 3680 | - | return -EINVAL; | |
| 3681 | - | ||
| 3682 | 3669 | /* Avoid creating shadow mounts during mount propagation. */ | |
| 3683 | 3670 | if (mnt_from->overmount) | |
| 3684 | 3671 | return -EINVAL; | |
modified fs/notify/mark.c
| @@ -929,11 +929,6 @@ restart: | |||
| 929 | 929 | goto restart; | |
| 930 | 930 | } | |
| 931 | 931 | ||
| 932 | - | if (conn->flags & FSNOTIFY_CONN_FLAG_DESTROYING) { | |
| 933 | - | err = -ENOENT; | |
| 934 | - | goto out_err; | |
| 935 | - | } | |
| 936 | - | ||
| 937 | 932 | /* is mark the first mark? */ | |
| 938 | 933 | if (hlist_empty(&conn->list)) { | |
| 939 | 934 | hlist_add_head_rcu(&mark->obj_list, &conn->list); | |
| @@ -1121,12 +1116,6 @@ void fsnotify_destroy_marks(fsnotify_connp_t *connp) | |||
| 1121 | 1116 | conn = fsnotify_grab_connector(connp); | |
| 1122 | 1117 | if (!conn) | |
| 1123 | 1118 | return; | |
| 1124 | - | /* | |
| 1125 | - | * New marks could be inserted before our cursor and survive the final | |
| 1126 | - | * detachment of the connector from the object. Prevent additions to | |
| 1127 | - | * this connector before dropping its lock. | |
| 1128 | - | */ | |
| 1129 | - | conn->flags |= FSNOTIFY_CONN_FLAG_DESTROYING; | |
| 1130 | 1119 | /* | |
| 1131 | 1120 | * We have to be careful since we can race with e.g. | |
| 1132 | 1121 | * fsnotify_clear_marks_by_group() and once we drop the conn->lock, the | |
modified fs/ntfs3/dir.c
| @@ -186,20 +186,11 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len, | |||
| 186 | 186 | { | |
| 187 | 187 | int ret, slen, i; | |
| 188 | 188 | const u8 *end; | |
| 189 | - | struct ntfs_mount_options *opts; | |
| 190 | - | struct nls_table *nls; | |
| 191 | - | bool ads; | |
| 189 | + | struct nls_table *nls = sbi->options->nls; | |
| 192 | 190 | u16 *uname = uni->name; | |
| 193 | 191 | ||
| 194 | 192 | static_assert(sizeof(wchar_t) == sizeof(u16)); | |
| 195 | 193 | ||
| 196 | - | /* ntfs_fs_reconfigure() may replace the options, but not ->nls */ | |
| 197 | - | rcu_read_lock(); | |
| 198 | - | opts = READ_ONCE(sbi->options); | |
| 199 | - | nls = opts->nls; | |
| 200 | - | ads = opts->ads; | |
| 201 | - | rcu_read_unlock(); | |
| 202 | - | ||
| 203 | 194 | if (!nls) { | |
| 204 | 195 | /* utf8 -> utf16 */ | |
| 205 | 196 | ret = _utf8s_to_utf16s(name, name_len, endian, uname, max_ulen); | |
| @@ -239,7 +230,7 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len, | |||
| 239 | 230 | ||
| 240 | 231 | uni->len = ret; | |
| 241 | 232 | uni->ads_len = 0; | |
| 242 | - | if (ret > 0 && ads) { | |
| 233 | + | if (ret > 0 && sbi->options->ads) { | |
| 243 | 234 | uname = uni->name; | |
| 244 | 235 | /* Find delimiter in range [1 : ret-2). */ | |
| 245 | 236 | for (i = 1; i + 1 < ret; i++) { | |
modified fs/ntfs3/ntfs_fs.h
| @@ -91,8 +91,6 @@ enum utf16_endian; | |||
| 91 | 91 | struct ntfs_mount_options { | |
| 92 | 92 | char *nls_name; | |
| 93 | 93 | struct nls_table *nls; | |
| 94 | - | /* ->d_hash() and ->d_compare() read the options in rcu pathwalk */ | |
| 95 | - | struct rcu_head rcu; | |
| 96 | 94 | ||
| 97 | 95 | kuid_t fs_uid; | |
| 98 | 96 | kgid_t fs_gid; | |
| @@ -213,7 +211,6 @@ struct ntfs_index { | |||
| 213 | 211 | /* Ntfs file system in-core superblock data. */ | |
| 214 | 212 | struct ntfs_sb_info { | |
| 215 | 213 | struct super_block *sb; | |
| 216 | - | struct rcu_head rcu; | |
| 217 | 214 | ||
| 218 | 215 | u32 discard_granularity; | |
| 219 | 216 | u64 discard_granularity_mask_inv; // ~(discard_granularity_mask_inv-1) | |
modified fs/ntfs3/super.c
| @@ -196,7 +196,7 @@ void *ntfs_set_shared(void *ptr, u32 bytes) | |||
| 196 | 196 | void *ret = NULL; | |
| 197 | 197 | int i, j = -1; | |
| 198 | 198 | ||
| 199 | - | spin_lock_bh(&s_shared_lock); | |
| 199 | + | spin_lock(&s_shared_lock); | |
| 200 | 200 | for (i = 0; i < ARRAY_SIZE(s_shared); i++) { | |
| 201 | 201 | if (!s_shared[i].cnt) { | |
| 202 | 202 | j = i; | |
| @@ -214,7 +214,7 @@ void *ntfs_set_shared(void *ptr, u32 bytes) | |||
| 214 | 214 | s_shared[j].cnt = 1; | |
| 215 | 215 | ret = ptr; | |
| 216 | 216 | } | |
| 217 | - | spin_unlock_bh(&s_shared_lock); | |
| 217 | + | spin_unlock(&s_shared_lock); | |
| 218 | 218 | ||
| 219 | 219 | return ret; | |
| 220 | 220 | } | |
| @@ -231,7 +231,7 @@ void *ntfs_put_shared(void *ptr) | |||
| 231 | 231 | void *ret = ptr; | |
| 232 | 232 | int i; | |
| 233 | 233 | ||
| 234 | - | spin_lock_bh(&s_shared_lock); | |
| 234 | + | spin_lock(&s_shared_lock); | |
| 235 | 235 | for (i = 0; i < ARRAY_SIZE(s_shared); i++) { | |
| 236 | 236 | if (s_shared[i].cnt && s_shared[i].ptr == ptr) { | |
| 237 | 237 | if (--s_shared[i].cnt) | |
| @@ -239,7 +239,7 @@ void *ntfs_put_shared(void *ptr) | |||
| 239 | 239 | break; | |
| 240 | 240 | } | |
| 241 | 241 | } | |
| 242 | - | spin_unlock_bh(&s_shared_lock); | |
| 242 | + | spin_unlock(&s_shared_lock); | |
| 243 | 243 | ||
| 244 | 244 | return ret; | |
| 245 | 245 | } | |
| @@ -251,11 +251,6 @@ static inline void put_mount_options(struct ntfs_mount_options *options) | |||
| 251 | 251 | kfree(options); | |
| 252 | 252 | } | |
| 253 | 253 | ||
| 254 | - | static void put_mount_options_rcu(struct rcu_head *head) | |
| 255 | - | { | |
| 256 | - | put_mount_options(container_of(head, struct ntfs_mount_options, rcu)); | |
| 257 | - | } | |
| 258 | - | ||
| 259 | 254 | enum Opt { | |
| 260 | 255 | Opt_uid, | |
| 261 | 256 | Opt_gid, | |
| @@ -449,7 +444,6 @@ static int ntfs_fs_reconfigure(struct fs_context *fc) | |||
| 449 | 444 | struct super_block *sb = fc->root->d_sb; | |
| 450 | 445 | struct ntfs_sb_info *sbi = sb->s_fs_info; | |
| 451 | 446 | struct ntfs_mount_options *new_opts = fc->fs_private; | |
| 452 | - | struct ntfs_mount_options *old_opts; | |
| 453 | 447 | int ro_rw; | |
| 454 | 448 | ||
| 455 | 449 | ro_rw = sb_rdonly(sb) && !(fc->sb_flags & SB_RDONLY); | |
| @@ -479,15 +473,7 @@ static int ntfs_fs_reconfigure(struct fs_context *fc) | |||
| 479 | 473 | } | |
| 480 | 474 | ||
| 481 | 475 | sync_filesystem(sb); | |
| 482 | - | old_opts = sbi->options; | |
| 483 | - | /* pairs with the READ_ONCE() in ntfs_nls_to_utf16() */ | |
| 484 | - | smp_store_release(&sbi->options, new_opts); | |
| 485 | - | fc->fs_private = NULL; | |
| 486 | - | /* | |
| 487 | - | * ntfs_d_hash() and ntfs_d_compare() of a pathwalk in rcu mode may | |
| 488 | - | * still read the old options through the sbi. | |
| 489 | - | */ | |
| 490 | - | call_rcu(&old_opts->rcu, put_mount_options_rcu); | |
| 476 | + | swap(sbi->options, fc->fs_private); | |
| 491 | 477 | ||
| 492 | 478 | return 0; | |
| 493 | 479 | } | |
| @@ -722,8 +708,6 @@ static noinline void ntfs3_put_sbi(struct ntfs_sb_info *sbi) | |||
| 722 | 708 | ||
| 723 | 709 | static void ntfs3_free_sbi(struct ntfs_sb_info *sbi) | |
| 724 | 710 | { | |
| 725 | - | if (sbi->options) | |
| 726 | - | put_mount_options(sbi->options); | |
| 727 | 711 | kfree(sbi->new_rec); | |
| 728 | 712 | kvfree(ntfs_put_shared(sbi->upcase)); | |
| 729 | 713 | kvfree(sbi->def_table); | |
| @@ -735,11 +719,6 @@ static void ntfs3_free_sbi(struct ntfs_sb_info *sbi) | |||
| 735 | 719 | kfree(sbi); | |
| 736 | 720 | } | |
| 737 | 721 | ||
| 738 | - | static void ntfs3_free_sbi_rcu(struct rcu_head *head) | |
| 739 | - | { | |
| 740 | - | ntfs3_free_sbi(container_of(head, struct ntfs_sb_info, rcu)); | |
| 741 | - | } | |
| 742 | - | ||
| 743 | 722 | static void ntfs_put_super(struct super_block *sb) | |
| 744 | 723 | { | |
| 745 | 724 | struct ntfs_sb_info *sbi = sb->s_fs_info; | |
| @@ -749,11 +728,11 @@ static void ntfs_put_super(struct super_block *sb) | |||
| 749 | 728 | /* Mark rw ntfs as clear, if possible. */ | |
| 750 | 729 | ntfs_set_state(sbi, NTFS_DIRTY_CLEAR); | |
| 751 | 730 | ||
| 752 | - | /* | |
| 753 | - | * The mount options stay until the sbi is freed: ->d_hash() and | |
| 754 | - | * ->d_compare() of a pathwalk in rcu mode read the nls table through | |
| 755 | - | * them. | |
| 756 | - | */ | |
| 731 | + | if (sbi->options) { | |
| 732 | + | put_mount_options(sbi->options); | |
| 733 | + | sbi->options = NULL; | |
| 734 | + | } | |
| 735 | + | ||
| 757 | 736 | ntfs3_put_sbi(sbi); | |
| 758 | 737 | } | |
| 759 | 738 | ||
| @@ -1960,11 +1939,9 @@ static void ntfs3_kill_sb(struct super_block *sb) | |||
| 1960 | 1939 | ||
| 1961 | 1940 | kill_block_super(sb); | |
| 1962 | 1941 | ||
| 1963 | - | /* | |
| 1964 | - | * A pathwalk in rcu mode may still be in ->d_hash() or ->d_compare() | |
| 1965 | - | * and read the upcase table and the nls table through the sbi. | |
| 1966 | - | */ | |
| 1967 | - | call_rcu(&sbi->rcu, ntfs3_free_sbi_rcu); | |
| 1942 | + | if (sbi->options) | |
| 1943 | + | put_mount_options(sbi->options); | |
| 1944 | + | ntfs3_free_sbi(sbi); | |
| 1968 | 1945 | } | |
| 1969 | 1946 | ||
| 1970 | 1947 | // clang-format off | |
modified fs/ocfs2/dlm/dlmcommon.h
| @@ -435,8 +435,6 @@ enum { | |||
| 435 | 435 | DLM_DEREF_LOCKRES_DONE = 522, | |
| 436 | 436 | }; | |
| 437 | 437 | ||
| 438 | - | extern spinlock_t dlm_reco_state_lock; | |
| 439 | - | ||
| 440 | 438 | struct dlm_reco_node_data | |
| 441 | 439 | { | |
| 442 | 440 | int state; | |
modified fs/ocfs2/dlm/dlmdebug.c
| @@ -736,11 +736,8 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) | |||
| 736 | 736 | buf + out, len - out); | |
| 737 | 737 | out += scnprintf(buf + out, len - out, "\n"); | |
| 738 | 738 | ||
| 739 | - | spin_unlock(&dlm->spinlock); | |
| 740 | - | ||
| 741 | 739 | /* Recovery Node State: */ | |
| 742 | 740 | out += scnprintf(buf + out, len - out, "Recovery Node State:\n"); | |
| 743 | - | spin_lock(&dlm_reco_state_lock); | |
| 744 | 741 | list_for_each_entry(node, &dlm->reco.node_data, list) { | |
| 745 | 742 | switch (node->state) { | |
| 746 | 743 | case DLM_RECO_NODE_DATA_INIT: | |
| @@ -772,7 +769,7 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) | |||
| 772 | 769 | node->node_num, state); | |
| 773 | 770 | } | |
| 774 | 771 | ||
| 775 | - | spin_unlock(&dlm_reco_state_lock); | |
| 772 | + | spin_unlock(&dlm->spinlock); | |
| 776 | 773 | ||
| 777 | 774 | return out; | |
| 778 | 775 | } | |
modified fs/ocfs2/dlm/dlmrecovery.c
| @@ -80,7 +80,7 @@ static int dlm_lockres_master_requery(struct dlm_ctxt *dlm, | |||
| 80 | 80 | ||
| 81 | 81 | static u64 dlm_get_next_mig_cookie(void); | |
| 82 | 82 | ||
| 83 | - | DEFINE_SPINLOCK(dlm_reco_state_lock); | |
| 83 | + | static DEFINE_SPINLOCK(dlm_reco_state_lock); | |
| 84 | 84 | static DEFINE_SPINLOCK(dlm_mig_cookie_lock); | |
| 85 | 85 | static u64 dlm_mig_cookie = 1; | |
| 86 | 86 | ||
modified fs/overlayfs/params.c
| @@ -216,9 +216,6 @@ static ssize_t ovl_parse_param_split_lowerdirs(char *str) | |||
| 216 | 216 | if (*s == '\\') { | |
| 217 | 217 | /* keep esc chars in split lowerdir */ | |
| 218 | 218 | *d++ = *s++; | |
| 219 | - | /* A trailing backslash escapes nothing. */ | |
| 220 | - | if (!*s) | |
| 221 | - | return -EINVAL; | |
| 222 | 219 | } else if (*s == ':') { | |
| 223 | 220 | bool next_colon = (*(s + 1) == ':'); | |
| 224 | 221 | ||
modified fs/pipe.c
| @@ -838,11 +838,9 @@ pipe_fasync(int fd, struct file *filp, int on) | |||
| 838 | 838 | if (filp->f_mode & FMODE_READ) | |
| 839 | 839 | retval = fasync_helper(fd, filp, on, &pipe->fasync_readers); | |
| 840 | 840 | if ((filp->f_mode & FMODE_WRITE) && retval >= 0) { | |
| 841 | - | int read_ret = retval; | |
| 842 | - | ||
| 843 | 841 | retval = fasync_helper(fd, filp, on, &pipe->fasync_writers); | |
| 844 | - | /* Undo only a reader entry added by this call. */ | |
| 845 | - | if (retval < 0 && read_ret > 0) | |
| 842 | + | if (retval < 0 && (filp->f_mode & FMODE_READ)) | |
| 843 | + | /* this can happen only if on == T */ | |
| 846 | 844 | fasync_helper(-1, filp, 0, &pipe->fasync_readers); | |
| 847 | 845 | } | |
| 848 | 846 | mutex_unlock(&pipe->mutex); | |
modified fs/tracefs/event_inode.c
| @@ -91,14 +91,6 @@ static void free_ei_rcu(struct rcu_head *rcu) | |||
| 91 | 91 | } | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | - | /* read under eventfs_srcu and, by tracefs_d_revalidate(), in rcu pathwalk */ | |
| 95 | - | static void free_ei_srcu(struct rcu_head *rcu) | |
| 96 | - | { | |
| 97 | - | struct eventfs_inode *ei = container_of(rcu, struct eventfs_inode, rcu); | |
| 98 | - | ||
| 99 | - | call_rcu(&ei->rcu, free_ei_rcu); | |
| 100 | - | } | |
| 101 | - | ||
| 102 | 94 | /* | |
| 103 | 95 | * eventfs_inode reference count management. | |
| 104 | 96 | * | |
| @@ -120,7 +112,7 @@ static void release_ei(struct kref *ref) | |||
| 120 | 112 | entry->release(entry->name, ei->data); | |
| 121 | 113 | } | |
| 122 | 114 | ||
| 123 | - | call_srcu(&eventfs_srcu, &ei->rcu, free_ei_srcu); | |
| 115 | + | call_srcu(&eventfs_srcu, &ei->rcu, free_ei_rcu); | |
| 124 | 116 | } | |
| 125 | 117 | ||
| 126 | 118 | static inline void put_ei(struct eventfs_inode *ei) | |
modified fs/unicode/utf8-core.c
| @@ -3,7 +3,6 @@ | |||
| 3 | 3 | #include <linux/kernel.h> | |
| 4 | 4 | #include <linux/string.h> | |
| 5 | 5 | #include <linux/slab.h> | |
| 6 | - | #include <linux/rcupdate.h> | |
| 7 | 6 | #include <linux/parser.h> | |
| 8 | 7 | #include <linux/errno.h> | |
| 9 | 8 | #include <linux/stringhash.h> | |
| @@ -184,24 +183,12 @@ out_free_um: | |||
| 184 | 183 | } | |
| 185 | 184 | EXPORT_SYMBOL(utf8_load); | |
| 186 | 185 | ||
| 187 | - | static void utf8_unload_rcu(struct rcu_head *head) | |
| 188 | - | { | |
| 189 | - | struct unicode_map *um = container_of(head, struct unicode_map, rcu); | |
| 190 | - | ||
| 191 | - | symbol_put(utf8_data_table); | |
| 192 | - | kfree(um); | |
| 193 | - | } | |
| 194 | - | ||
| 195 | - | /* | |
| 196 | - | * A pathwalk in rcu mode may still be in ->d_hash() or ->d_compare() of a | |
| 197 | - | * filesystem that is being torn down and read the map through its | |
| 198 | - | * superblock, so the map and the tables it points to have to outlive the | |
| 199 | - | * grace period. | |
| 200 | - | */ | |
| 201 | 186 | void utf8_unload(struct unicode_map *um) | |
| 202 | 187 | { | |
| 203 | - | if (um) | |
| 204 | - | call_rcu(&um->rcu, utf8_unload_rcu); | |
| 188 | + | if (um) { | |
| 189 | + | symbol_put(utf8_data_table); | |
| 190 | + | kfree(um); | |
| 191 | + | } | |
| 205 | 192 | } | |
| 206 | 193 | EXPORT_SYMBOL(utf8_unload); | |
| 207 | 194 | ||
modified include/linux/fsnotify_backend.h
| @@ -566,7 +566,6 @@ struct fsnotify_mark_connector { | |||
| 566 | 566 | unsigned char prio; /* Highest priority group */ | |
| 567 | 567 | #define FSNOTIFY_CONN_FLAG_IS_WATCHED 0x01 | |
| 568 | 568 | #define FSNOTIFY_CONN_FLAG_HAS_IREF 0x02 | |
| 569 | - | #define FSNOTIFY_CONN_FLAG_DESTROYING 0x04 | |
| 570 | 569 | unsigned short flags; /* flags [lock] */ | |
| 571 | 570 | union { | |
| 572 | 571 | /* Object pointer [lock] */ | |
modified include/linux/sched/signal.h
| @@ -130,8 +130,8 @@ struct signal_struct { | |||
| 130 | 130 | * process will inherit a flag if they should look for a | |
| 131 | 131 | * child_subreaper process at exit. | |
| 132 | 132 | */ | |
| 133 | - | bool is_child_subreaper; | |
| 134 | - | bool has_child_subreaper; | |
| 133 | + | unsigned int is_child_subreaper:1; | |
| 134 | + | unsigned int has_child_subreaper:1; | |
| 135 | 135 | unsigned int autoreap:1; | |
| 136 | 136 | ||
| 137 | 137 | #ifdef CONFIG_POSIX_TIMERS | |
modified include/linux/unicode.h
| @@ -53,7 +53,6 @@ struct unicode_map { | |||
| 53 | 53 | unsigned int version; | |
| 54 | 54 | const struct utf8data *ntab[UTF8_NMAX]; | |
| 55 | 55 | const struct utf8data_table *tables; | |
| 56 | - | struct rcu_head rcu; | |
| 57 | 56 | }; | |
| 58 | 57 | ||
| 59 | 58 | int utf8_validate(const struct unicode_map *um, const struct qstr *str); | |
modified ipc/namespace.c
| @@ -96,7 +96,7 @@ fail_ipc: | |||
| 96 | 96 | fail_mq_sysctls: | |
| 97 | 97 | retire_mq_sysctls(ns); | |
| 98 | 98 | fail_mq_mount: | |
| 99 | - | kern_unmount(ns->mq_mnt); | |
| 99 | + | mntput(ns->mq_mnt); | |
| 100 | 100 | fail_put: | |
| 101 | 101 | put_user_ns(ns->user_ns); | |
| 102 | 102 | ns_common_free(ns); | |
modified kernel/exit.c
| @@ -1729,7 +1729,7 @@ static long do_wait(struct wait_opts *wo) | |||
| 1729 | 1729 | add_wait_queue(¤t->signal->wait_chldexit, &wo->child_wait); | |
| 1730 | 1730 | ||
| 1731 | 1731 | do { | |
| 1732 | - | set_current_state(TASK_INTERRUPTIBLE | TASK_FREEZABLE); | |
| 1732 | + | set_current_state(TASK_INTERRUPTIBLE); | |
| 1733 | 1733 | retval = __do_wait(wo); | |
| 1734 | 1734 | if (retval != -ERESTARTSYS) | |
| 1735 | 1735 | break; | |
modified kernel/fork.c
| @@ -1619,13 +1619,7 @@ static int copy_exec_state(u64 clone_flags, struct task_struct *tsk) | |||
| 1619 | 1619 | return task_exec_state_copy(tsk); | |
| 1620 | 1620 | } | |
| 1621 | 1621 | ||
| 1622 | - | enum copy_fs_flags_t { | |
| 1623 | - | COPY_FS_UMH = (1 << 0), | |
| 1624 | - | COPY_FS_IDLE = (1 << 1), | |
| 1625 | - | }; | |
| 1626 | - | ||
| 1627 | - | static int copy_fs(u64 clone_flags, struct task_struct *tsk, | |
| 1628 | - | enum copy_fs_flags_t flags) | |
| 1622 | + | static int copy_fs(u64 clone_flags, struct task_struct *tsk, bool umh) | |
| 1629 | 1623 | { | |
| 1630 | 1624 | struct fs_struct *fs; | |
| 1631 | 1625 | ||
| @@ -1635,20 +1629,19 @@ static int copy_fs(u64 clone_flags, struct task_struct *tsk, | |||
| 1635 | 1629 | * filesystem state, or be started from a non-initial mount | |
| 1636 | 1630 | * namespace. | |
| 1637 | 1631 | */ | |
| 1638 | - | if (flags & COPY_FS_UMH) { | |
| 1632 | + | if (umh) { | |
| 1639 | 1633 | if (clone_flags & (CLONE_NEWNS | CLONE_FS)) | |
| 1640 | 1634 | return -EINVAL; | |
| 1641 | 1635 | if (current->nsproxy->mnt_ns != &init_mnt_ns) | |
| 1642 | 1636 | return -EINVAL; | |
| 1643 | 1637 | fs = userspace_init_fs; | |
| 1644 | - | } else if (flags & COPY_FS_IDLE) { | |
| 1645 | - | fs = &init_fs; | |
| 1646 | 1638 | } else { | |
| 1647 | 1639 | fs = current->fs; | |
| 1648 | 1640 | VFS_WARN_ON_ONCE(current->fs != current->real_fs); | |
| 1649 | 1641 | } | |
| 1650 | 1642 | ||
| 1651 | 1643 | if (clone_flags & CLONE_FS) { | |
| 1644 | + | /* tsk->fs is already what we want */ | |
| 1652 | 1645 | read_seqlock_excl(&fs->seq); | |
| 1653 | 1646 | /* "users" and "in_exec" locked for check_unsafe_exec() */ | |
| 1654 | 1647 | if (fs->in_exec) { | |
| @@ -1657,7 +1650,6 @@ static int copy_fs(u64 clone_flags, struct task_struct *tsk, | |||
| 1657 | 1650 | } | |
| 1658 | 1651 | fs->users++; | |
| 1659 | 1652 | read_sequnlock_excl(&fs->seq); | |
| 1660 | - | tsk->real_fs = tsk->fs = fs; | |
| 1661 | 1653 | return 0; | |
| 1662 | 1654 | } | |
| 1663 | 1655 | tsk->real_fs = tsk->fs = copy_fs_struct(fs); | |
| @@ -2307,9 +2299,7 @@ __latent_entropy struct task_struct *copy_process( | |||
| 2307 | 2299 | retval = copy_files(clone_flags, p, args->no_files); | |
| 2308 | 2300 | if (retval) | |
| 2309 | 2301 | goto bad_fork_cleanup_semundo; | |
| 2310 | - | retval = copy_fs(clone_flags, p, | |
| 2311 | - | (args->umh ? COPY_FS_UMH : 0) | | |
| 2312 | - | (args->idle ? COPY_FS_IDLE : 0)); | |
| 2302 | + | retval = copy_fs(clone_flags, p, args->umh); | |
| 2313 | 2303 | if (retval) | |
| 2314 | 2304 | goto bad_fork_cleanup_files; | |
| 2315 | 2305 | retval = copy_sighand(clone_flags, p); | |
| @@ -2681,7 +2671,7 @@ struct task_struct * __init fork_idle(int cpu) | |||
| 2681 | 2671 | { | |
| 2682 | 2672 | struct task_struct *task; | |
| 2683 | 2673 | struct kernel_clone_args args = { | |
| 2684 | - | .flags = CLONE_VM | CLONE_FS, | |
| 2674 | + | .flags = CLONE_VM, | |
| 2685 | 2675 | .fn = &idle_dummy, | |
| 2686 | 2676 | .fn_arg = NULL, | |
| 2687 | 2677 | .kthread = 1, | |
modified kernel/pid_namespace.c
| @@ -268,7 +268,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) | |||
| 268 | 268 | * free_pid() will awaken this task. | |
| 269 | 269 | */ | |
| 270 | 270 | for (;;) { | |
| 271 | - | set_current_state(TASK_IDLE | TASK_FREEZABLE); | |
| 271 | + | set_current_state(TASK_INTERRUPTIBLE); | |
| 272 | 272 | if (pid_ns->pid_allocated == init_pids) | |
| 273 | 273 | break; | |
| 274 | 274 | schedule(); | |
modified kernel/watch_queue.c
| @@ -101,7 +101,7 @@ static bool post_one_notification(struct watch_queue *wqueue, | |||
| 101 | 101 | struct pipe_inode_info *pipe = wqueue->pipe; | |
| 102 | 102 | struct pipe_buffer *buf; | |
| 103 | 103 | struct page *page; | |
| 104 | - | unsigned int head, tail, note, offset, len, nr_notes; | |
| 104 | + | unsigned int head, tail, note, offset, len; | |
| 105 | 105 | bool done = false; | |
| 106 | 106 | ||
| 107 | 107 | spin_lock_irq(&pipe->rd_wait.lock); | |
| @@ -111,10 +111,8 @@ static bool post_one_notification(struct watch_queue *wqueue, | |||
| 111 | 111 | if (pipe_full(head, tail, pipe->ring_size)) | |
| 112 | 112 | goto lost; | |
| 113 | 113 | ||
| 114 | - | /* Pairs with the smp_store_release() in watch_queue_set_size(). */ | |
| 115 | - | nr_notes = smp_load_acquire(&wqueue->nr_notes); | |
| 116 | - | note = find_first_bit(wqueue->notes_bitmap, nr_notes); | |
| 117 | - | if (note >= nr_notes) | |
| 114 | + | note = find_first_bit(wqueue->notes_bitmap, wqueue->nr_notes); | |
| 115 | + | if (note >= wqueue->nr_notes) | |
| 118 | 116 | goto lost; | |
| 119 | 117 | ||
| 120 | 118 | page = wqueue->notes[note / WATCH_QUEUE_NOTES_PER_PAGE]; | |
| @@ -299,8 +297,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes) | |||
| 299 | 297 | wqueue->notes = pages; | |
| 300 | 298 | wqueue->notes_bitmap = bitmap; | |
| 301 | 299 | wqueue->nr_pages = nr_pages; | |
| 302 | - | /* Pairs with the smp_load_acquire() in post_one_notification(). */ | |
| 303 | - | smp_store_release(&wqueue->nr_notes, nr_notes); | |
| 300 | + | wqueue->nr_notes = nr_notes; | |
| 304 | 301 | return 0; | |
| 305 | 302 | ||
| 306 | 303 | error_p: | |
modified samples/pidfd/Makefile
| @@ -1,4 +1,4 @@ | |||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0 | |
| 2 | - | userprogs-always-y += pidfd-metadata | |
| 2 | + | usertprogs-always-y += pidfd-metadata | |
| 3 | 3 | ||
| 4 | 4 | userccflags += -I usr/include | |
modified tools/testing/selftests/filesystems/umount_propagation/locked_mount_test.c
| @@ -9,8 +9,6 @@ | |||
| 9 | 9 | #include <errno.h> | |
| 10 | 10 | #include <fcntl.h> | |
| 11 | 11 | #include <sched.h> | |
| 12 | - | #include <stdbool.h> | |
| 13 | - | #include <signal.h> | |
| 14 | 12 | #include <stdio.h> | |
| 15 | 13 | #include <stdlib.h> | |
| 16 | 14 | #include <string.h> | |
| @@ -29,12 +27,6 @@ | |||
| 29 | 27 | #ifndef MOVE_MOUNT_BENEATH | |
| 30 | 28 | #define MOVE_MOUNT_BENEATH 0x00000200 | |
| 31 | 29 | #endif | |
| 32 | - | #ifndef OPEN_TREE_CLONE | |
| 33 | - | #define OPEN_TREE_CLONE 1 | |
| 34 | - | #endif | |
| 35 | - | #ifndef OPEN_TREE_CLOEXEC | |
| 36 | - | #define OPEN_TREE_CLOEXEC O_CLOEXEC | |
| 37 | - | #endif | |
| 38 | 30 | ||
| 39 | 31 | #define DIR_LEN 64 | |
| 40 | 32 | #define PATH_LEN 192 | |
| @@ -128,35 +120,6 @@ static bool covered(const char *path) | |||
| 128 | 120 | return fd < 0; | |
| 129 | 121 | } | |
| 130 | 122 | ||
| 131 | - | /* What @path reads, "" if it can't be read. */ | |
| 132 | - | static int read_word(const char *path, char *buf, size_t len) | |
| 133 | - | { | |
| 134 | - | ssize_t n = 0; | |
| 135 | - | int fd; | |
| 136 | - | ||
| 137 | - | fd = open(path, O_RDONLY | O_CLOEXEC); | |
| 138 | - | if (fd >= 0) { | |
| 139 | - | n = read(fd, buf, len - 1); | |
| 140 | - | close(fd); | |
| 141 | - | } | |
| 142 | - | buf[n > 0 ? n : 0] = 0; | |
| 143 | - | return fd < 0 ? -1 : 0; | |
| 144 | - | } | |
| 145 | - | ||
| 146 | - | /* Put a clone of the mount at @src beneath the top mount at @where. */ | |
| 147 | - | static int move_beneath(const char *src, const char *where) | |
| 148 | - | { | |
| 149 | - | int fd, ret; | |
| 150 | - | ||
| 151 | - | fd = syscall(__NR_open_tree, AT_FDCWD, src, OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC); | |
| 152 | - | if (fd < 0) | |
| 153 | - | return -1; | |
| 154 | - | ret = syscall(__NR_move_mount, fd, "", AT_FDCWD, where, | |
| 155 | - | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_BENEATH); | |
| 156 | - | close(fd); | |
| 157 | - | return ret; | |
| 158 | - | } | |
| 159 | - | ||
| 160 | 123 | FIXTURE(locked_mount) { | |
| 161 | 124 | char base[DIR_LEN]; | |
| 162 | 125 | bool tracing; /* debugfs with the tracefs automount is there */ | |
| @@ -466,89 +429,4 @@ TEST_F(locked_mount, propagated_copy_keeps_the_cover_locked) | |||
| 466 | 429 | EXPECT_EQ(ret, CHILD_OK); | |
| 467 | 430 | } | |
| 468 | 431 | ||
| 469 | - | /* | |
| 470 | - | * A mount of a mount namespace file is left out of the copy that | |
| 471 | - | * unshare(CLONE_NEWNS) makes, together with everything mounted on it, so | |
| 472 | - | * it can't take over the lock of a cover it is moved beneath. The child | |
| 473 | - | * tries just that with the namespace file of a grandchild and gets EINVAL. | |
| 474 | - | * A bind of an ordinary file takes the lock over, and the file is still | |
| 475 | - | * covered in the next copy of the mount namespace. | |
| 476 | - | */ | |
| 477 | - | static int ns_file_child(const char *base) | |
| 478 | - | { | |
| 479 | - | char secret[PATH_LEN], mine[PATH_LEN], nsfile[PATH_LEN], buf[32]; | |
| 480 | - | int ret = CHILD_OK, pfd[2]; | |
| 481 | - | pid_t pid; | |
| 482 | - | ||
| 483 | - | snprintf(secret, sizeof(secret), "%s/P/secret", base); | |
| 484 | - | snprintf(mine, sizeof(mine), "%s/mine", base); | |
| 485 | - | ||
| 486 | - | if (enter_userns() || pipe(pfd)) | |
| 487 | - | return CHILD_SETUP; | |
| 488 | - | /* the cover is locked */ | |
| 489 | - | if (!umount2(secret, 0) || errno != EINVAL) | |
| 490 | - | return CHILD_STEP1; | |
| 491 | - | ||
| 492 | - | /* a mount namespace newer than our own, so that a bind of it is allowed */ | |
| 493 | - | pid = fork(); | |
| 494 | - | if (pid < 0) | |
| 495 | - | return CHILD_SETUP; | |
| 496 | - | if (pid == 0) { | |
| 497 | - | if (unshare(CLONE_NEWNS) || send_byte(pfd[1])) | |
| 498 | - | _exit(1); | |
| 499 | - | pause(); | |
| 500 | - | _exit(0); | |
| 501 | - | } | |
| 502 | - | if (wait_byte(pfd[0])) | |
| 503 | - | return CHILD_SETUP; | |
| 504 | - | snprintf(nsfile, sizeof(nsfile), "/proc/%d/ns/mnt", pid); | |
| 505 | - | if (!move_beneath(nsfile, secret) || errno != EINVAL) | |
| 506 | - | ret = CHILD_STEP2; | |
| 507 | - | kill(pid, SIGKILL); | |
| 508 | - | waitpid(pid, NULL, 0); | |
| 509 | - | if (ret) | |
| 510 | - | return ret; | |
| 511 | - | ||
| 512 | - | /* an ordinary file beneath the cover takes the lock over */ | |
| 513 | - | if (move_beneath(mine, secret)) | |
| 514 | - | return CHILD_STEP3; | |
| 515 | - | if (umount2(secret, 0)) | |
| 516 | - | return CHILD_STEP3; | |
| 517 | - | if (!umount2(secret, 0) || errno != EINVAL) | |
| 518 | - | return CHILD_STEP3; | |
| 519 | - | /* and it is in the next copy of the namespace */ | |
| 520 | - | if (unshare(CLONE_NEWNS)) | |
| 521 | - | return CHILD_SETUP; | |
| 522 | - | if (read_word(secret, buf, sizeof(buf)) || strcmp(buf, "mine")) | |
| 523 | - | return CHILD_STEP4; | |
| 524 | - | return CHILD_OK; | |
| 525 | - | } | |
| 526 | - | ||
| 527 | - | TEST_F(locked_mount, mount_namespace_file_cant_take_the_lock) | |
| 528 | - | { | |
| 529 | - | char p[PATH_LEN], q[PATH_LEN]; | |
| 530 | - | pid_t pid; | |
| 531 | - | int ret; | |
| 532 | - | ||
| 533 | - | snprintf(p, sizeof(p), "%s/P", self->base); | |
| 534 | - | ASSERT_EQ(mkdir(p, 0755), 0); | |
| 535 | - | ASSERT_EQ(mount("tmpfs", p, "tmpfs", 0, "mode=0755"), 0); | |
| 536 | - | snprintf(p, sizeof(p), "%s/P/secret", self->base); | |
| 537 | - | ASSERT_EQ(create_file(p, "covered-by-root\n"), 0); | |
| 538 | - | snprintf(q, sizeof(q), "%s/P/empty", self->base); | |
| 539 | - | ASSERT_EQ(create_file(q, ""), 0); | |
| 540 | - | /* the cover: an empty file over the secret */ | |
| 541 | - | ASSERT_EQ(mount(q, p, NULL, MS_BIND, NULL), 0); | |
| 542 | - | snprintf(q, sizeof(q), "%s/mine", self->base); | |
| 543 | - | ASSERT_EQ(create_file(q, "mine"), 0); | |
| 544 | - | ||
| 545 | - | pid = fork(); | |
| 546 | - | ASSERT_GE(pid, 0); | |
| 547 | - | if (pid == 0) | |
| 548 | - | _exit(ns_file_child(self->base)); | |
| 549 | - | ret = wait_child(pid); | |
| 550 | - | TH_LOG("child exit code %d", ret); | |
| 551 | - | EXPECT_EQ(ret, CHILD_OK); | |
| 552 | - | } | |
| 553 | - | ||
| 554 | 432 | TEST_HARNESS_MAIN | |