tools/testing/selftests/net/mptcp/mptcp_join.sh 34aa6e3bccd8 ("selftests: mptcp: add ip mptcp wrappers") 857898eb4b28 ("selftests: mptcp: add missing join check") 6ef84b1517e0 ("selftests: mptcp: more robust signal race test") https://lore.kernel.org/all/20220221131842.468893-1-broonie@kernel.org/ drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c fb7e76ea3f3b6 ("net/mlx5e: TC, Skip redundant ct clear actions") c63741b426e11 ("net/mlx5e: Fix MPLSoUDP encap to use MPLS action information") 09bf97923224f ("net/mlx5e: TC, Move pedit_headers_action to parse_attr") 84ba8062e383 ("net/mlx5e: Test CT and SAMPLE on flow attr") efe6f961cd2e ("net/mlx5e: CT, Don't set flow flag CT for ct clear flow") 3b49a7edec1d ("net/mlx5e: TC, Reject rules with multiple CT actions")
Showing the changes to kernel (9 of 227 files). Show all
Unified · Split
| @@ -546,6 +546,7 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of, · 545 unmodified lines | ||
| 546 | 546 | char *buf, size_t nbytes, loff_t off) |
| 547 | 547 | { |
| 548 | 548 | struct cgroup *cgrp; |
| 549 | + struct cgroup_file_ctx *ctx; | |
| 549 | 550 | |
| 550 | 551 | BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); |
| 551 | 552 | |
| @@ -553,8 +554,9 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of, · 1 unmodified line | ||
| 553 | 554 | * Release agent gets called with all capabilities, |
| 554 | 555 | * require capabilities to set release agent. |
| 555 | 556 | */ |
| 556 | − if ((of->file->f_cred->user_ns != &init_user_ns) || | |
| 557 | − !capable(CAP_SYS_ADMIN)) | |
| 557 | + ctx = of->priv; | |
| 558 | + if ((ctx->ns->user_ns != &init_user_ns) || | |
| 559 | + !file_ns_capable(of->file, &init_user_ns, CAP_SYS_ADMIN)) | |
| 558 | 560 | return -EPERM; |
| 559 | 561 | |
| 560 | 562 | cgrp = cgroup_kn_lock_live(of->kn, false); |
| @@ -6166,6 +6166,20 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs) · 6165 unmodified lines | ||
| 6166 | 6166 | if (ret) |
| 6167 | 6167 | goto err; |
| 6168 | 6168 | |
| 6169 | + /* | |
| 6170 | + * Spawning a task directly into a cgroup works by passing a file | |
| 6171 | + * descriptor to the target cgroup directory. This can even be an O_PATH | |
| 6172 | + * file descriptor. But it can never be a cgroup.procs file descriptor. | |
| 6173 | + * This was done on purpose so spawning into a cgroup could be | |
| 6174 | + * conceptualized as an atomic | |
| 6175 | + * | |
| 6176 | + * fd = openat(dfd_cgroup, "cgroup.procs", ...); | |
| 6177 | + * write(fd, <child-pid>, ...); | |
| 6178 | + * | |
| 6179 | + * sequence, i.e. it's a shorthand for the caller opening and writing | |
| 6180 | + * cgroup.procs of the cgroup indicated by @dfd_cgroup. This allows us | |
| 6181 | + * to always use the caller's credentials. | |
| 6182 | + */ | |
| 6169 | 6183 | ret = cgroup_attach_permissions(cset->dfl_cgrp, dst_cgrp, sb, |
| 6170 | 6184 | !(kargs->flags & CLONE_THREAD), |
| 6171 | 6185 | current->nsproxy->cgroup_ns); |
| @@ -2289,6 +2289,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) · 2288 unmodified lines | ||
| 2289 | 2289 | cgroup_taskset_first(tset, &css); |
| 2290 | 2290 | cs = css_cs(css); |
| 2291 | 2291 | |
| 2292 | + cpus_read_lock(); | |
| 2292 | 2293 | percpu_down_write(&cpuset_rwsem); |
| 2293 | 2294 | |
| 2294 | 2295 | guarantee_online_mems(cs, &cpuset_attach_nodemask_to); |
| @@ -2342,6 +2343,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) · 47 unmodified lines | ||
| 2342 | 2343 | wake_up(&cpuset_attach_wq); |
| 2343 | 2344 | |
| 2344 | 2345 | percpu_up_write(&cpuset_rwsem); |
| 2346 | + cpus_read_unlock(); | |
| 2345 | 2347 | } |
| 2346 | 2348 | |
| 2347 | 2349 | /* The various types of files and directories in a cpuset file system */ |
| @@ -3522,8 +3524,8 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs) · 1174 unmodified lines | ||
| 3522 | 3524 | return cs; |
| 3523 | 3525 | } |
| 3524 | 3526 | |
| 3525 | −/** | |
| 3526 | − * cpuset_node_allowed - Can we allocate on a memory node? | |
| 3527 | +/* | |
| 3528 | + * __cpuset_node_allowed - Can we allocate on a memory node? | |
| 3527 | 3529 | * @node: is this an allowed node? |
| 3528 | 3530 | * @gfp_mask: memory allocation flags |
| 3529 | 3531 | * |
| @@ -3694,8 +3696,8 @@ void cpuset_print_current_mems_allowed(void) · 164 unmodified lines | ||
| 3694 | 3696 | |
| 3695 | 3697 | int cpuset_memory_pressure_enabled __read_mostly; |
| 3696 | 3698 | |
| 3697 | −/** | |
| 3698 | − * cpuset_memory_pressure_bump - keep stats of per-cpuset reclaims. | |
| 3699 | +/* | |
| 3700 | + * __cpuset_memory_pressure_bump - keep stats of per-cpuset reclaims. | |
| 3699 | 3701 | * |
| 3700 | 3702 | * Keep a running average of the rate of synchronous (direct) |
| 3701 | 3703 | * page reclaim efforts initiated by tasks in each cpuset. |
| @@ -3710,7 +3712,7 @@ int cpuset_memory_pressure_enabled __read_mostly; · 8 unmodified lines | ||
| 3710 | 3712 | * "memory_pressure". Value displayed is an integer |
| 3711 | 3713 | * representing the recent rate of entry into the synchronous |
| 3712 | 3714 | * (direct) page reclaim by any task attached to the cpuset. |
| 3713 | − **/ | |
| 3715 | + */ | |
| 3714 | 3716 | |
| 3715 | 3717 | void __cpuset_memory_pressure_bump(void) |
| 3716 | 3718 | { |
| @@ -665,21 +665,16 @@ EXPORT_SYMBOL(cred_fscmp); · 664 unmodified lines | ||
| 665 | 665 | |
| 666 | 666 | int set_cred_ucounts(struct cred *new) |
| 667 | 667 | { |
| 668 | − struct task_struct *task = current; | |
| 669 | − const struct cred *old = task->real_cred; | |
| 670 | 668 | struct ucounts *new_ucounts, *old_ucounts = new->ucounts; |
| 671 | 669 | |
| 672 | − if (new->user == old->user && new->user_ns == old->user_ns) | |
| 673 | − return 0; | |
| 674 | − | |
| 675 | 670 | /* |
| 676 | 671 | * This optimization is needed because alloc_ucounts() uses locks |
| 677 | 672 | * for table lookups. |
| 678 | 673 | */ |
| 679 | − if (old_ucounts->ns == new->user_ns && uid_eq(old_ucounts->uid, new->euid)) | |
| 674 | + if (old_ucounts->ns == new->user_ns && uid_eq(old_ucounts->uid, new->uid)) | |
| 680 | 675 | return 0; |
| 681 | 676 | |
| 682 | − if (!(new_ucounts = alloc_ucounts(new->user_ns, new->euid))) | |
| 677 | + if (!(new_ucounts = alloc_ucounts(new->user_ns, new->uid))) | |
| 683 | 678 | return -EAGAIN; |
| 684 | 679 | |
| 685 | 680 | new->ucounts = new_ucounts; |
| @@ -2021,18 +2021,18 @@ static __latent_entropy struct task_struct *copy_process( · 2020 unmodified lines | ||
| 2021 | 2021 | #ifdef CONFIG_PROVE_LOCKING |
| 2022 | 2022 | DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled); |
| 2023 | 2023 | #endif |
| 2024 | + retval = copy_creds(p, clone_flags); | |
| 2025 | + if (retval < 0) | |
| 2026 | + goto bad_fork_free; | |
| 2027 | + | |
| 2024 | 2028 | retval = -EAGAIN; |
| 2025 | 2029 | if (is_ucounts_overlimit(task_ucounts(p), UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC))) { |
| 2026 | 2030 | if (p->real_cred->user != INIT_USER && |
| 2027 | 2031 | !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) |
| 2028 | − goto bad_fork_free; | |
| 2032 | + goto bad_fork_cleanup_count; | |
| 2029 | 2033 | } |
| 2030 | 2034 | current->flags &= ~PF_NPROC_EXCEEDED; |
| 2031 | 2035 | |
| 2032 | − retval = copy_creds(p, clone_flags); | |
| 2033 | − if (retval < 0) | |
| 2034 | − goto bad_fork_free; | |
| 2035 | − | |
| 2036 | 2036 | /* |
| 2037 | 2037 | * If multiple threads are within copy_process(), then this check |
| 2038 | 2038 | * triggers too late. This doesn't hurt, the check is only there |
| @@ -2266,6 +2266,17 @@ static __latent_entropy struct task_struct *copy_process( · 227 unmodified lines | ||
| 2266 | 2266 | if (retval) |
| 2267 | 2267 | goto bad_fork_put_pidfd; |
| 2268 | 2268 | |
| 2269 | + /* | |
| 2270 | + * Now that the cgroups are pinned, re-clone the parent cgroup and put | |
| 2271 | + * the new task on the correct runqueue. All this *before* the task | |
| 2272 | + * becomes visible. | |
| 2273 | + * | |
| 2274 | + * This isn't part of ->can_fork() because while the re-cloning is | |
| 2275 | + * cgroup specific, it unconditionally needs to place the task on a | |
| 2276 | + * runqueue. | |
| 2277 | + */ | |
| 2278 | + sched_cgroup_fork(p, args); | |
| 2279 | + | |
| 2269 | 2280 | /* |
| 2270 | 2281 | * From this point on we must avoid any synchronous user-space |
| 2271 | 2282 | * communication until we take the tasklist-lock. In particular, we do |
| @@ -2323,10 +2334,6 @@ static __latent_entropy struct task_struct *copy_process( · 51 unmodified lines | ||
| 2323 | 2334 | goto bad_fork_cancel_cgroup; |
| 2324 | 2335 | } |
| 2325 | 2336 | |
| 2326 | − /* past the last point of failure */ | |
| 2327 | − if (pidfile) | |
| 2328 | − fd_install(pidfd, pidfile); | |
| 2329 | − | |
| 2330 | 2337 | init_task_pid_links(p); |
| 2331 | 2338 | if (likely(p->pid)) { |
| 2332 | 2339 | ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace); |
| @@ -2375,8 +2382,11 @@ static __latent_entropy struct task_struct *copy_process( · 42 unmodified lines | ||
| 2375 | 2382 | syscall_tracepoint_update(p); |
| 2376 | 2383 | write_unlock_irq(&tasklist_lock); |
| 2377 | 2384 | |
| 2385 | + if (pidfile) | |
| 2386 | + fd_install(pidfd, pidfile); | |
| 2387 | + | |
| 2378 | 2388 | proc_fork_connector(p); |
| 2379 | − sched_post_fork(p, args); | |
| 2389 | + sched_post_fork(p); | |
| 2380 | 2390 | cgroup_post_fork(p, args); |
| 2381 | 2391 | perf_event_fork(p); |
| 2382 | 2392 | |
| @@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i) · 3461 unmodified lines | ||
| 3462 | 3462 | u16 chain_hlock = chain_hlocks[chain->base + i]; |
| 3463 | 3463 | unsigned int class_idx = chain_hlock_class_idx(chain_hlock); |
| 3464 | 3464 | |
| 3465 | − return lock_classes + class_idx - 1; | |
| 3465 | + return lock_classes + class_idx; | |
| 3466 | 3466 | } |
| 3467 | 3467 | |
| 3468 | 3468 | /* |
| @@ -3530,7 +3530,7 @@ static void print_chain_keys_chain(struct lock_chain *chain) · 61 unmodified lines | ||
| 3530 | 3530 | hlock_id = chain_hlocks[chain->base + i]; |
| 3531 | 3531 | chain_key = print_chain_key_iteration(hlock_id, chain_key); |
| 3532 | 3532 | |
| 3533 | − print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id) - 1); | |
| 3533 | + print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id)); | |
| 3534 | 3534 | printk("\n"); |
| 3535 | 3535 | } |
| 3536 | 3536 | } |
| @@ -1214,9 +1214,8 @@ int tg_nop(struct task_group *tg, void *data) · 1213 unmodified lines | ||
| 1214 | 1214 | } |
| 1215 | 1215 | #endif |
| 1216 | 1216 | |
| 1217 | −static void set_load_weight(struct task_struct *p) | |
| 1217 | +static void set_load_weight(struct task_struct *p, bool update_load) | |
| 1218 | 1218 | { |
| 1219 | − bool update_load = !(READ_ONCE(p->__state) & TASK_NEW); | |
| 1220 | 1219 | int prio = p->static_prio - MAX_RT_PRIO; |
| 1221 | 1220 | struct load_weight *load = &p->se.load; |
| 1222 | 1221 | |
| @@ -4407,7 +4406,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) · 3184 unmodified lines | ||
| 4407 | 4406 | p->static_prio = NICE_TO_PRIO(0); |
| 4408 | 4407 | |
| 4409 | 4408 | p->prio = p->normal_prio = p->static_prio; |
| 4410 | − set_load_weight(p); | |
| 4409 | + set_load_weight(p, false); | |
| 4411 | 4410 | |
| 4412 | 4411 | /* |
| 4413 | 4412 | * We don't need the reset flag anymore after the fork. It has |
| @@ -4425,6 +4424,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) · 11 unmodified lines | ||
| 4425 | 4424 | |
| 4426 | 4425 | init_entity_runnable_average(&p->se); |
| 4427 | 4426 | |
| 4427 | + | |
| 4428 | 4428 | #ifdef CONFIG_SCHED_INFO |
| 4429 | 4429 | if (likely(sched_info_on())) |
| 4430 | 4430 | memset(&p->sched_info, 0, sizeof(p->sched_info)); |
| @@ -4440,18 +4440,23 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) · 9 unmodified lines | ||
| 4440 | 4440 | return 0; |
| 4441 | 4441 | } |
| 4442 | 4442 | |
| 4443 | −void sched_post_fork(struct task_struct *p, struct kernel_clone_args *kargs) | |
| 4443 | +void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs) | |
| 4444 | 4444 | { |
| 4445 | 4445 | unsigned long flags; |
| 4446 | −#ifdef CONFIG_CGROUP_SCHED | |
| 4447 | − struct task_group *tg; | |
| 4448 | −#endif | |
| 4449 | 4446 | |
| 4447 | + /* | |
| 4448 | + * Because we're not yet on the pid-hash, p->pi_lock isn't strictly | |
| 4449 | + * required yet, but lockdep gets upset if rules are violated. | |
| 4450 | + */ | |
| 4450 | 4451 | raw_spin_lock_irqsave(&p->pi_lock, flags); |
| 4451 | 4452 | #ifdef CONFIG_CGROUP_SCHED |
| 4452 | − tg = container_of(kargs->cset->subsys[cpu_cgrp_id], | |
| 4453 | − struct task_group, css); | |
| 4454 | − p->sched_task_group = autogroup_task_group(p, tg); | |
| 4453 | + if (1) { | |
| 4454 | + struct task_group *tg; | |
| 4455 | + tg = container_of(kargs->cset->subsys[cpu_cgrp_id], | |
| 4456 | + struct task_group, css); | |
| 4457 | + tg = autogroup_task_group(p, tg); | |
| 4458 | + p->sched_task_group = tg; | |
| 4459 | + } | |
| 4455 | 4460 | #endif |
| 4456 | 4461 | rseq_migrate(p); |
| 4457 | 4462 | /* |
| @@ -4462,7 +4467,10 @@ void sched_post_fork(struct task_struct *p, struct kernel_clone_args *kargs) · 4 unmodified lines | ||
| 4462 | 4467 | if (p->sched_class->task_fork) |
| 4463 | 4468 | p->sched_class->task_fork(p); |
| 4464 | 4469 | raw_spin_unlock_irqrestore(&p->pi_lock, flags); |
| 4470 | +} | |
| 4465 | 4471 | |
| 4472 | +void sched_post_fork(struct task_struct *p) | |
| 4473 | +{ | |
| 4466 | 4474 | uclamp_post_fork(p); |
| 4467 | 4475 | } |
| 4468 | 4476 | |
| @@ -6922,7 +6930,7 @@ void set_user_nice(struct task_struct *p, long nice) · 2453 unmodified lines | ||
| 6922 | 6930 | put_prev_task(rq, p); |
| 6923 | 6931 | |
| 6924 | 6932 | p->static_prio = NICE_TO_PRIO(nice); |
| 6925 | − set_load_weight(p); | |
| 6933 | + set_load_weight(p, true); | |
| 6926 | 6934 | old_prio = p->prio; |
| 6927 | 6935 | p->prio = effective_prio(p); |
| 6928 | 6936 | |
| @@ -7213,7 +7221,7 @@ static void __setscheduler_params(struct task_struct *p, · 284 unmodified lines | ||
| 7213 | 7221 | */ |
| 7214 | 7222 | p->rt_priority = attr->sched_priority; |
| 7215 | 7223 | p->normal_prio = normal_prio(p); |
| 7216 | − set_load_weight(p); | |
| 7224 | + set_load_weight(p, true); | |
| 7217 | 7225 | } |
| 7218 | 7226 | |
| 7219 | 7227 | /* |
| @@ -9446,7 +9454,7 @@ void __init sched_init(void) · 2226 unmodified lines | ||
| 9446 | 9454 | #endif |
| 9447 | 9455 | } |
| 9448 | 9456 | |
| 9449 | − set_load_weight(&init_task); | |
| 9457 | + set_load_weight(&init_task, false); | |
| 9450 | 9458 | |
| 9451 | 9459 | /* |
| 9452 | 9460 | * The boot idle thread does lazy MMU switching as well: |
| @@ -472,6 +472,16 @@ static int set_user(struct cred *new) · 471 unmodified lines | ||
| 472 | 472 | if (!new_user) |
| 473 | 473 | return -EAGAIN; |
| 474 | 474 | |
| 475 | + free_uid(new->user); | |
| 476 | + new->user = new_user; | |
| 477 | + return 0; | |
| 478 | +} | |
| 479 | + | |
| 480 | +static void flag_nproc_exceeded(struct cred *new) | |
| 481 | +{ | |
| 482 | + if (new->ucounts == current_ucounts()) | |
| 483 | + return; | |
| 484 | + | |
| 475 | 485 | /* |
| 476 | 486 | * We don't fail in case of NPROC limit excess here because too many |
| 477 | 487 | * poorly written programs don't check set*uid() return code, assuming |
| @@ -480,15 +490,10 @@ static int set_user(struct cred *new) · 2 unmodified lines | ||
| 480 | 490 | * failure to the execve() stage. |
| 481 | 491 | */ |
| 482 | 492 | if (is_ucounts_overlimit(new->ucounts, UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC)) && |
| 483 | − new_user != INIT_USER && | |
| 484 | − !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) | |
| 493 | + new->user != INIT_USER) | |
| 485 | 494 | current->flags |= PF_NPROC_EXCEEDED; |
| 486 | 495 | else |
| 487 | 496 | current->flags &= ~PF_NPROC_EXCEEDED; |
| 488 | − | |
| 489 | − free_uid(new->user); | |
| 490 | − new->user = new_user; | |
| 491 | − return 0; | |
| 492 | 497 | } |
| 493 | 498 | |
| 494 | 499 | /* |
| @@ -563,6 +568,7 @@ long __sys_setreuid(uid_t ruid, uid_t euid) · 68 unmodified lines | ||
| 563 | 568 | if (retval < 0) |
| 564 | 569 | goto error; |
| 565 | 570 | |
| 571 | + flag_nproc_exceeded(new); | |
| 566 | 572 | return commit_creds(new); |
| 567 | 573 | |
| 568 | 574 | error: |
| @@ -625,6 +631,7 @@ long __sys_setuid(uid_t uid) · 56 unmodified lines | ||
| 625 | 631 | if (retval < 0) |
| 626 | 632 | goto error; |
| 627 | 633 | |
| 634 | + flag_nproc_exceeded(new); | |
| 628 | 635 | return commit_creds(new); |
| 629 | 636 | |
| 630 | 637 | error: |
| @@ -704,6 +711,7 @@ long __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid) · 73 unmodified lines | ||
| 704 | 711 | if (retval < 0) |
| 705 | 712 | goto error; |
| 706 | 713 | |
| 714 | + flag_nproc_exceeded(new); | |
| 707 | 715 | return commit_creds(new); |
| 708 | 716 | |
| 709 | 717 | error: |
| @@ -350,7 +350,8 @@ bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsign · 349 unmodified lines | ||
| 350 | 350 | if (rlimit > LONG_MAX) |
| 351 | 351 | max = LONG_MAX; |
| 352 | 352 | for (iter = ucounts; iter; iter = iter->ns->ucounts) { |
| 353 | − if (get_ucounts_value(iter, type) > max) | |
| 353 | + long val = get_ucounts_value(iter, type); | |
| 354 | + if (val < 0 || val > max) | |
| 354 | 355 | return true; |
| 355 | 356 | max = READ_ONCE(iter->ns->ucount_max[type]); |
| 356 | 357 | } |