History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

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")

Jakub Kicinski committed 4 years ago

Commit aaa25a22 parents 9e7b78d d8152cf227 files · +1756 −925Browse files

Showing the changes to kernel (9 of 227 files). Show all

Unified · Split

9 files
  1. kernel/cgroup/cgroup-v1.c +4 −2
  2. kernel/cgroup/cgroup.c +14 −0
  3. kernel/cgroup/cpuset.c +7 −5
  4. kernel/cred.c +2 −7
  5. kernel/fork.c +20 −10
  6. kernel/locking/lockdep.c +2 −2
  7. kernel/sched/core.c +21 −13
  8. kernel/sys.c +14 −6
  9. kernel/ucount.c +2 −1
kernel/cgroup/cgroup-v1.c+4−2
@@ -546,6 +546,7 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of, · 545 unmodified lines
546 char *buf, size_t nbytes, loff_t off)546 char *buf, size_t nbytes, loff_t off)
547{547{
548 struct cgroup *cgrp;548 struct cgroup *cgrp;
549 struct cgroup_file_ctx *ctx;
549 550
550 BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);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 * Release agent gets called with all capabilities,554 * Release agent gets called with all capabilities,
554 * require capabilities to set release agent.555 * require capabilities to set release agent.
555 */556 */
556 if ((of->file->f_cred->user_ns != &init_user_ns) ||557 ctx = of->priv;
557 !capable(CAP_SYS_ADMIN))558 if ((ctx->ns->user_ns != &init_user_ns) ||
559 !file_ns_capable(of->file, &init_user_ns, CAP_SYS_ADMIN))
558 return -EPERM;560 return -EPERM;
559 561
560 cgrp = cgroup_kn_lock_live(of->kn, false);562 cgrp = cgroup_kn_lock_live(of->kn, false);
kernel/cgroup/cgroup.c+14−0
@@ -6166,6 +6166,20 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs) · 6165 unmodified lines
6166 if (ret)6166 if (ret)
6167 goto err;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 ret = cgroup_attach_permissions(cset->dfl_cgrp, dst_cgrp, sb,6183 ret = cgroup_attach_permissions(cset->dfl_cgrp, dst_cgrp, sb,
6170 !(kargs->flags & CLONE_THREAD),6184 !(kargs->flags & CLONE_THREAD),
6171 current->nsproxy->cgroup_ns);6185 current->nsproxy->cgroup_ns);
kernel/cgroup/cpuset.c+7−5
@@ -2289,6 +2289,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) · 2288 unmodified lines
2289 cgroup_taskset_first(tset, &css);2289 cgroup_taskset_first(tset, &css);
2290 cs = css_cs(css);2290 cs = css_cs(css);
2291 2291
2292 cpus_read_lock();
2292 percpu_down_write(&cpuset_rwsem);2293 percpu_down_write(&cpuset_rwsem);
2293 2294
2294 guarantee_online_mems(cs, &cpuset_attach_nodemask_to);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 wake_up(&cpuset_attach_wq);2343 wake_up(&cpuset_attach_wq);
2343 2344
2344 percpu_up_write(&cpuset_rwsem);2345 percpu_up_write(&cpuset_rwsem);
2346 cpus_read_unlock();
2345}2347}
2346 2348
2347/* The various types of files and directories in a cpuset file system */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 return cs;3524 return cs;
3523}3525}
3524 3526
3525/**3527/*
3526 * cpuset_node_allowed - Can we allocate on a memory node?3528 * __cpuset_node_allowed - Can we allocate on a memory node?
3527 * @node: is this an allowed node?3529 * @node: is this an allowed node?
3528 * @gfp_mask: memory allocation flags3530 * @gfp_mask: memory allocation flags
3529 *3531 *
@@ -3694,8 +3696,8 @@ void cpuset_print_current_mems_allowed(void) · 164 unmodified lines
3694 3696
3695int cpuset_memory_pressure_enabled __read_mostly;3697int cpuset_memory_pressure_enabled __read_mostly;
3696 3698
3697/**3699/*
3698 * cpuset_memory_pressure_bump - keep stats of per-cpuset reclaims.3700 * __cpuset_memory_pressure_bump - keep stats of per-cpuset reclaims.
3699 *3701 *
3700 * Keep a running average of the rate of synchronous (direct)3702 * Keep a running average of the rate of synchronous (direct)
3701 * page reclaim efforts initiated by tasks in each cpuset.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 * "memory_pressure". Value displayed is an integer3712 * "memory_pressure". Value displayed is an integer
3711 * representing the recent rate of entry into the synchronous3713 * representing the recent rate of entry into the synchronous
3712 * (direct) page reclaim by any task attached to the cpuset.3714 * (direct) page reclaim by any task attached to the cpuset.
3713 **/3715 */
3714 3716
3715void __cpuset_memory_pressure_bump(void)3717void __cpuset_memory_pressure_bump(void)
3716{3718{
kernel/cred.c+2−7
@@ -665,21 +665,16 @@ EXPORT_SYMBOL(cred_fscmp); · 664 unmodified lines
665 665
666int set_cred_ucounts(struct cred *new)666int set_cred_ucounts(struct cred *new)
667{667{
668 struct task_struct *task = current;
669 const struct cred *old = task->real_cred;
670 struct ucounts *new_ucounts, *old_ucounts = new->ucounts;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 * This optimization is needed because alloc_ucounts() uses locks671 * This optimization is needed because alloc_ucounts() uses locks
677 * for table lookups.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 return 0;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 return -EAGAIN;678 return -EAGAIN;
684 679
685 new->ucounts = new_ucounts;680 new->ucounts = new_ucounts;
kernel/fork.c+20−10
@@ -2021,18 +2021,18 @@ static __latent_entropy struct task_struct *copy_process( · 2020 unmodified lines
2021#ifdef CONFIG_PROVE_LOCKING2021#ifdef CONFIG_PROVE_LOCKING
2022 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);2022 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
2023#endif2023#endif
2024 retval = copy_creds(p, clone_flags);
2025 if (retval < 0)
2026 goto bad_fork_free;
2027
2024 retval = -EAGAIN;2028 retval = -EAGAIN;
2025 if (is_ucounts_overlimit(task_ucounts(p), UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC))) {2029 if (is_ucounts_overlimit(task_ucounts(p), UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC))) {
2026 if (p->real_cred->user != INIT_USER &&2030 if (p->real_cred->user != INIT_USER &&
2027 !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))2031 !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
2028 goto bad_fork_free;2032 goto bad_fork_cleanup_count;
2029 }2033 }
2030 current->flags &= ~PF_NPROC_EXCEEDED;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 * If multiple threads are within copy_process(), then this check2037 * If multiple threads are within copy_process(), then this check
2038 * triggers too late. This doesn't hurt, the check is only there2038 * 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 if (retval)2266 if (retval)
2267 goto bad_fork_put_pidfd;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 * From this point on we must avoid any synchronous user-space2281 * From this point on we must avoid any synchronous user-space
2271 * communication until we take the tasklist-lock. In particular, we do2282 * 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 goto bad_fork_cancel_cgroup;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 init_task_pid_links(p);2337 init_task_pid_links(p);
2331 if (likely(p->pid)) {2338 if (likely(p->pid)) {
2332 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);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 syscall_tracepoint_update(p);2382 syscall_tracepoint_update(p);
2376 write_unlock_irq(&tasklist_lock);2383 write_unlock_irq(&tasklist_lock);
2377 2384
2385 if (pidfile)
2386 fd_install(pidfd, pidfile);
2387
2378 proc_fork_connector(p);2388 proc_fork_connector(p);
2379 sched_post_fork(p, args);2389 sched_post_fork(p);
2380 cgroup_post_fork(p, args);2390 cgroup_post_fork(p, args);
2381 perf_event_fork(p);2391 perf_event_fork(p);
2382 2392
kernel/locking/lockdep.c+2−2
@@ -3462,7 +3462,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i) · 3461 unmodified lines
3462 u16 chain_hlock = chain_hlocks[chain->base + i];3462 u16 chain_hlock = chain_hlocks[chain->base + i];
3463 unsigned int class_idx = chain_hlock_class_idx(chain_hlock);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 hlock_id = chain_hlocks[chain->base + i];3530 hlock_id = chain_hlocks[chain->base + i];
3531 chain_key = print_chain_key_iteration(hlock_id, chain_key);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 printk("\n");3534 printk("\n");
3535 }3535 }
3536}3536}
kernel/sched/core.c+21−13
@@ -1214,9 +1214,8 @@ int tg_nop(struct task_group *tg, void *data) · 1213 unmodified lines
1214}1214}
1215#endif1215#endif
1216 1216
1217static void set_load_weight(struct task_struct *p)1217static void set_load_weight(struct task_struct *p, bool update_load)
1218{1218{
1219 bool update_load = !(READ_ONCE(p->__state) & TASK_NEW);
1220 int prio = p->static_prio - MAX_RT_PRIO;1219 int prio = p->static_prio - MAX_RT_PRIO;
1221 struct load_weight *load = &p->se.load;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 p->static_prio = NICE_TO_PRIO(0);4406 p->static_prio = NICE_TO_PRIO(0);
4408 4407
4409 p->prio = p->normal_prio = p->static_prio;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 * We don't need the reset flag anymore after the fork. It has4412 * 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 init_entity_runnable_average(&p->se);4425 init_entity_runnable_average(&p->se);
4427 4426
4427
4428#ifdef CONFIG_SCHED_INFO4428#ifdef CONFIG_SCHED_INFO
4429 if (likely(sched_info_on()))4429 if (likely(sched_info_on()))
4430 memset(&p->sched_info, 0, sizeof(p->sched_info));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 return 0;4440 return 0;
4441}4441}
4442 4442
4443void sched_post_fork(struct task_struct *p, struct kernel_clone_args *kargs)4443void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs)
4444{4444{
4445 unsigned long flags;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 raw_spin_lock_irqsave(&p->pi_lock, flags);4451 raw_spin_lock_irqsave(&p->pi_lock, flags);
4451#ifdef CONFIG_CGROUP_SCHED4452#ifdef CONFIG_CGROUP_SCHED
4452 tg = container_of(kargs->cset->subsys[cpu_cgrp_id],4453 if (1) {
4453 struct task_group, css);4454 struct task_group *tg;
4454 p->sched_task_group = autogroup_task_group(p, 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#endif4460#endif
4456 rseq_migrate(p);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 if (p->sched_class->task_fork)4467 if (p->sched_class->task_fork)
4463 p->sched_class->task_fork(p);4468 p->sched_class->task_fork(p);
4464 raw_spin_unlock_irqrestore(&p->pi_lock, flags);4469 raw_spin_unlock_irqrestore(&p->pi_lock, flags);
4470}
4465 4471
4472void sched_post_fork(struct task_struct *p)
4473{
4466 uclamp_post_fork(p);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 put_prev_task(rq, p);6930 put_prev_task(rq, p);
6923 6931
6924 p->static_prio = NICE_TO_PRIO(nice);6932 p->static_prio = NICE_TO_PRIO(nice);
6925 set_load_weight(p);6933 set_load_weight(p, true);
6926 old_prio = p->prio;6934 old_prio = p->prio;
6927 p->prio = effective_prio(p);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 p->rt_priority = attr->sched_priority;7222 p->rt_priority = attr->sched_priority;
7215 p->normal_prio = normal_prio(p);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#endif9454#endif
9447 }9455 }
9448 9456
9449 set_load_weight(&init_task);9457 set_load_weight(&init_task, false);
9450 9458
9451 /*9459 /*
9452 * The boot idle thread does lazy MMU switching as well:9460 * The boot idle thread does lazy MMU switching as well:
kernel/sys.c+14−6
@@ -472,6 +472,16 @@ static int set_user(struct cred *new) · 471 unmodified lines
472 if (!new_user)472 if (!new_user)
473 return -EAGAIN;473 return -EAGAIN;
474 474
475 free_uid(new->user);
476 new->user = new_user;
477 return 0;
478}
479
480static void flag_nproc_exceeded(struct cred *new)
481{
482 if (new->ucounts == current_ucounts())
483 return;
484
475 /*485 /*
476 * We don't fail in case of NPROC limit excess here because too many486 * We don't fail in case of NPROC limit excess here because too many
477 * poorly written programs don't check set*uid() return code, assuming487 * 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 * failure to the execve() stage.490 * failure to the execve() stage.
481 */491 */
482 if (is_ucounts_overlimit(new->ucounts, UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC)) &&492 if (is_ucounts_overlimit(new->ucounts, UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC)) &&
483 new_user != INIT_USER &&493 new->user != INIT_USER)
484 !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
485 current->flags |= PF_NPROC_EXCEEDED;494 current->flags |= PF_NPROC_EXCEEDED;
486 else495 else
487 current->flags &= ~PF_NPROC_EXCEEDED;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 if (retval < 0)568 if (retval < 0)
564 goto error;569 goto error;
565 570
571 flag_nproc_exceeded(new);
566 return commit_creds(new);572 return commit_creds(new);
567 573
568error:574error:
@@ -625,6 +631,7 @@ long __sys_setuid(uid_t uid) · 56 unmodified lines
625 if (retval < 0)631 if (retval < 0)
626 goto error;632 goto error;
627 633
634 flag_nproc_exceeded(new);
628 return commit_creds(new);635 return commit_creds(new);
629 636
630error:637error:
@@ -704,6 +711,7 @@ long __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid) · 73 unmodified lines
704 if (retval < 0)711 if (retval < 0)
705 goto error;712 goto error;
706 713
714 flag_nproc_exceeded(new);
707 return commit_creds(new);715 return commit_creds(new);
708 716
709error:717error:
kernel/ucount.c+2−1
@@ -350,7 +350,8 @@ bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsign · 349 unmodified lines
350 if (rlimit > LONG_MAX)350 if (rlimit > LONG_MAX)
351 max = LONG_MAX;351 max = LONG_MAX;
352 for (iter = ucounts; iter; iter = iter->ns->ucounts) {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 return true;355 return true;
355 max = READ_ONCE(iter->ns->ucount_max[type]);356 max = READ_ONCE(iter->ns->ucount_max[type]);
356 }357 }