History

Merge branch 'linus' into locking/kcsan, to pick up fixes

Ingo Molnar committed 6 years ago

Commit df108462 parents a4654e9 5ad0ec0906 files · +8764 −4406Browse files

Showing the changes to kernel (19 of 906 files). Show all

Unified · Split

19 files
  1. kernel/audit.c +21 −19
  2. kernel/auditfilter.c +39 −32
  3. kernel/cgroup/cgroup-v1.c +2 −1
  4. kernel/cgroup/cgroup.c +30 −13
  5. kernel/exit.c +2 −2
  6. kernel/fork.c +1 −1
  7. kernel/futex.c +55 −38
  8. kernel/pid.c +10 −0
  9. kernel/power/snapshot.c +1 −1
  10. kernel/sched/fair.c +2 −0
  11. kernel/signal.c +14 −9
  12. kernel/sys.c +2 −0
  13. kernel/trace/Kconfig +2 −2
  14. kernel/trace/blktrace.c +86 −31
  15. kernel/trace/ftrace.c +2 −0
  16. kernel/trace/synth_event_gen_test.c +22 −22
  17. kernel/trace/trace.c +2 −0
  18. kernel/trace/trace_events_hist.c +101 −11
  19. kernel/workqueue.c +8 −6
kernel/audit.c+21−19
@@ -1101,13 +1101,11 @@ static void audit_log_feature_change(int which, u32 old_feature, u32 new_feature · 1100 unmodified lines
11011101 audit_log_end(ab);
11021102 }
11031103
1104−static int audit_set_feature(struct sk_buff *skb)
1104+static int audit_set_feature(struct audit_features *uaf)
11051105 {
1106− struct audit_features *uaf;
11071106 int i;
11081107
11091108 BUILD_BUG_ON(AUDIT_LAST_FEATURE + 1 > ARRAY_SIZE(audit_feature_names));
1110− uaf = nlmsg_data(nlmsg_hdr(skb));
11111109
11121110 /* if there is ever a version 2 we should handle that here */
11131111
@@ -1175,6 +1173,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 61 unmodified lines
11751173 {
11761174 u32 seq;
11771175 void *data;
1176+ int data_len;
11781177 int err;
11791178 struct audit_buffer *ab;
11801179 u16 msg_type = nlh->nlmsg_type;
@@ -1188,6 +1187,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 7 unmodified lines
11881187
11891188 seq = nlh->nlmsg_seq;
11901189 data = nlmsg_data(nlh);
1190+ data_len = nlmsg_len(nlh);
11911191
11921192 switch (msg_type) {
11931193 case AUDIT_GET: {
@@ -1211,7 +1211,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 17 unmodified lines
12111211 struct audit_status s;
12121212 memset(&s, 0, sizeof(s));
12131213 /* guard against past and future API changes */
1214− memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
1214+ memcpy(&s, data, min_t(size_t, sizeof(s), data_len));
12151215 if (s.mask & AUDIT_STATUS_ENABLED) {
12161216 err = audit_set_enabled(s.enabled);
12171217 if (err < 0)
@@ -1315,7 +1315,9 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 97 unmodified lines
13151315 return err;
13161316 break;
13171317 case AUDIT_SET_FEATURE:
1318− err = audit_set_feature(skb);
1318+ if (data_len < sizeof(struct audit_features))
1319+ return -EINVAL;
1320+ err = audit_set_feature(data);
13191321 if (err)
13201322 return err;
13211323 break;
@@ -1327,6 +1329,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 5 unmodified lines
13271329
13281330 err = audit_filter(msg_type, AUDIT_FILTER_USER);
13291331 if (err == 1) { /* match or error */
1332+ char *str = data;
1333+
13301334 err = 0;
13311335 if (msg_type == AUDIT_USER_TTY) {
13321336 err = tty_audit_push();
@@ -1334,26 +1338,24 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 1 unmodified line
13341338 break;
13351339 }
13361340 audit_log_user_recv_msg(&ab, msg_type);
1337− if (msg_type != AUDIT_USER_TTY)
1341+ if (msg_type != AUDIT_USER_TTY) {
1342+ /* ensure NULL termination */
1343+ str[data_len - 1] = '\0';
13381344 audit_log_format(ab, " msg='%.*s'",
13391345 AUDIT_MESSAGE_TEXT_MAX,
1340− (char *)data);
1341− else {
1342− int size;
1343−
1346+ str);
1347+ } else {
13441348 audit_log_format(ab, " data=");
1345− size = nlmsg_len(nlh);
1346− if (size > 0 &&
1347− ((unsigned char *)data)[size - 1] == '\0')
1348− size--;
1349− audit_log_n_untrustedstring(ab, data, size);
1349+ if (data_len > 0 && str[data_len - 1] == '\0')
1350+ data_len--;
1351+ audit_log_n_untrustedstring(ab, str, data_len);
13501352 }
13511353 audit_log_end(ab);
13521354 }
13531355 break;
13541356 case AUDIT_ADD_RULE:
13551357 case AUDIT_DEL_RULE:
1356− if (nlmsg_len(nlh) < sizeof(struct audit_rule_data))
1358+ if (data_len < sizeof(struct audit_rule_data))
13571359 return -EINVAL;
13581360 if (audit_enabled == AUDIT_LOCKED) {
13591361 audit_log_common_recv_msg(audit_context(), &ab,
@@ -1365,7 +1367,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 5 unmodified lines
13651367 audit_log_end(ab);
13661368 return -EPERM;
13671369 }
1368− err = audit_rule_change(msg_type, seq, data, nlmsg_len(nlh));
1370+ err = audit_rule_change(msg_type, seq, data, data_len);
13691371 break;
13701372 case AUDIT_LIST_RULES:
13711373 err = audit_list_rules_send(skb, seq);
@@ -1380,7 +1382,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 8 unmodified lines
13801382 case AUDIT_MAKE_EQUIV: {
13811383 void *bufp = data;
13821384 u32 sizes[2];
1383− size_t msglen = nlmsg_len(nlh);
1385+ size_t msglen = data_len;
13841386 char *old, *new;
13851387
13861388 err = -EINVAL;
@@ -1456,7 +1458,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 69 unmodified lines
14561458
14571459 memset(&s, 0, sizeof(s));
14581460 /* guard against past and future API changes */
1459− memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
1461+ memcpy(&s, data, min_t(size_t, sizeof(s), data_len));
14601462 /* check if new data is valid */
14611463 if ((s.enabled != 0 && s.enabled != 1) ||
14621464 (s.log_passwd != 0 && s.log_passwd != 1))
kernel/auditfilter.c+39−32
@@ -456,6 +456,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, · 455 unmodified lines
456456 bufp = data->buf;
457457 for (i = 0; i < data->field_count; i++) {
458458 struct audit_field *f = &entry->rule.fields[i];
459+ u32 f_val;
459460
460461 err = -EINVAL;
461462
@@ -464,12 +465,12 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, · 2 unmodified lines
464465 goto exit_free;
465466
466467 f->type = data->fields[i];
467− f->val = data->values[i];
468+ f_val = data->values[i];
468469
469470 /* Support legacy tests for a valid loginuid */
470− if ((f->type == AUDIT_LOGINUID) && (f->val == AUDIT_UID_UNSET)) {
471+ if ((f->type == AUDIT_LOGINUID) && (f_val == AUDIT_UID_UNSET)) {
471472 f->type = AUDIT_LOGINUID_SET;
472− f->val = 0;
473+ f_val = 0;
473474 entry->rule.pflags |= AUDIT_LOGINUID_LEGACY;
474475 }
475476
@@ -485,7 +486,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, · 9 unmodified lines
485486 case AUDIT_SUID:
486487 case AUDIT_FSUID:
487488 case AUDIT_OBJ_UID:
488− f->uid = make_kuid(current_user_ns(), f->val);
489+ f->uid = make_kuid(current_user_ns(), f_val);
489490 if (!uid_valid(f->uid))
490491 goto exit_free;
491492 break;
@@ -494,11 +495,12 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, · 2 unmodified lines
494495 case AUDIT_SGID:
495496 case AUDIT_FSGID:
496497 case AUDIT_OBJ_GID:
497− f->gid = make_kgid(current_user_ns(), f->val);
498+ f->gid = make_kgid(current_user_ns(), f_val);
498499 if (!gid_valid(f->gid))
499500 goto exit_free;
500501 break;
501502 case AUDIT_ARCH:
503+ f->val = f_val;
502504 entry->rule.arch_f = f;
503505 break;
504506 case AUDIT_SUBJ_USER:
@@ -511,11 +513,13 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, · 6 unmodified lines
511513 case AUDIT_OBJ_TYPE:
512514 case AUDIT_OBJ_LEV_LOW:
513515 case AUDIT_OBJ_LEV_HIGH:
514− str = audit_unpack_string(&bufp, &remain, f->val);
515− if (IS_ERR(str))
516+ str = audit_unpack_string(&bufp, &remain, f_val);
517+ if (IS_ERR(str)) {
518+ err = PTR_ERR(str);
516519 goto exit_free;
517− entry->rule.buflen += f->val;
518−
520+ }
521+ entry->rule.buflen += f_val;
522+ f->lsm_str = str;
519523 err = security_audit_rule_init(f->type, f->op, str,
520524 (void **)&f->lsm_rule);
521525 /* Keep currently invalid fields around in case they
@@ -524,68 +528,71 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, · 2 unmodified lines
524528 pr_warn("audit rule for LSM \'%s\' is invalid\n",
525529 str);
526530 err = 0;
527− }
528− if (err) {
529− kfree(str);
531+ } else if (err)
530532 goto exit_free;
531− } else
532− f->lsm_str = str;
533533 break;
534534 case AUDIT_WATCH:
535− str = audit_unpack_string(&bufp, &remain, f->val);
536− if (IS_ERR(str))
535+ str = audit_unpack_string(&bufp, &remain, f_val);
536+ if (IS_ERR(str)) {
537+ err = PTR_ERR(str);
537538 goto exit_free;
538− entry->rule.buflen += f->val;
539−
540− err = audit_to_watch(&entry->rule, str, f->val, f->op);
539+ }
540+ err = audit_to_watch(&entry->rule, str, f_val, f->op);
541541 if (err) {
542542 kfree(str);
543543 goto exit_free;
544544 }
545+ entry->rule.buflen += f_val;
545546 break;
546547 case AUDIT_DIR:
547− str = audit_unpack_string(&bufp, &remain, f->val);
548− if (IS_ERR(str))
548+ str = audit_unpack_string(&bufp, &remain, f_val);
549+ if (IS_ERR(str)) {
550+ err = PTR_ERR(str);
549551 goto exit_free;
550− entry->rule.buflen += f->val;
551−
552+ }
552553 err = audit_make_tree(&entry->rule, str, f->op);
553554 kfree(str);
554555 if (err)
555556 goto exit_free;
557+ entry->rule.buflen += f_val;
556558 break;
557559 case AUDIT_INODE:
560+ f->val = f_val;
558561 err = audit_to_inode(&entry->rule, f);
559562 if (err)
560563 goto exit_free;
561564 break;
562565 case AUDIT_FILTERKEY:
563− if (entry->rule.filterkey || f->val > AUDIT_MAX_KEY_LEN)
566+ if (entry->rule.filterkey || f_val > AUDIT_MAX_KEY_LEN)
564567 goto exit_free;
565− str = audit_unpack_string(&bufp, &remain, f->val);
566− if (IS_ERR(str))
568+ str = audit_unpack_string(&bufp, &remain, f_val);
569+ if (IS_ERR(str)) {
570+ err = PTR_ERR(str);
567571 goto exit_free;
568− entry->rule.buflen += f->val;
572+ }
573+ entry->rule.buflen += f_val;
569574 entry->rule.filterkey = str;
570575 break;
571576 case AUDIT_EXE:
572− if (entry->rule.exe || f->val > PATH_MAX)
577+ if (entry->rule.exe || f_val > PATH_MAX)
573578 goto exit_free;
574− str = audit_unpack_string(&bufp, &remain, f->val);
579+ str = audit_unpack_string(&bufp, &remain, f_val);
575580 if (IS_ERR(str)) {
576581 err = PTR_ERR(str);
577582 goto exit_free;
578583 }
579− entry->rule.buflen += f->val;
580−
581− audit_mark = audit_alloc_mark(&entry->rule, str, f->val);
584+ audit_mark = audit_alloc_mark(&entry->rule, str, f_val);
582585 if (IS_ERR(audit_mark)) {
583586 kfree(str);
584587 err = PTR_ERR(audit_mark);
585588 goto exit_free;
586589 }
590+ entry->rule.buflen += f_val;
587591 entry->rule.exe = audit_mark;
588592 break;
593+ default:
594+ f->val = f_val;
595+ break;
589596 }
590597 }
591598
kernel/cgroup/cgroup-v1.c+2−1
@@ -471,6 +471,7 @@ static void *cgroup_pidlist_next(struct seq_file *s, void *v, loff_t *pos) · 470 unmodified lines
471471 */
472472 p++;
473473 if (p >= end) {
474+ (*pos)++;
474475 return NULL;
475476 } else {
476477 *pos = *p;
@@ -782,7 +783,7 @@ void cgroup1_release_agent(struct work_struct *work) · 305 unmodified lines
782783
783784 pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
784785 agentbuf = kstrdup(cgrp->root->release_agent_path, GFP_KERNEL);
785− if (!pathbuf || !agentbuf)
786+ if (!pathbuf || !agentbuf || !strlen(agentbuf))
786787 goto out;
787788
788789 spin_lock_irq(&css_set_lock);
kernel/cgroup/cgroup.c+30−13
@@ -3542,21 +3542,21 @@ static int cpu_stat_show(struct seq_file *seq, void *v) · 3541 unmodified lines
35423542 static int cgroup_io_pressure_show(struct seq_file *seq, void *v)
35433543 {
35443544 struct cgroup *cgrp = seq_css(seq)->cgroup;
3545− struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi;
3545+ struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi;
35463546
35473547 return psi_show(seq, psi, PSI_IO);
35483548 }
35493549 static int cgroup_memory_pressure_show(struct seq_file *seq, void *v)
35503550 {
35513551 struct cgroup *cgrp = seq_css(seq)->cgroup;
3552− struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi;
3552+ struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi;
35533553
35543554 return psi_show(seq, psi, PSI_MEM);
35553555 }
35563556 static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v)
35573557 {
35583558 struct cgroup *cgrp = seq_css(seq)->cgroup;
3559− struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi;
3559+ struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi;
35603560
35613561 return psi_show(seq, psi, PSI_CPU);
35623562 }
@@ -4400,12 +4400,16 @@ static void css_task_iter_advance_css_set(struct css_task_iter *it) · 837 unmodified lines
44004400 }
44014401 } while (!css_set_populated(cset) && list_empty(&cset->dying_tasks));
44024402
4403− if (!list_empty(&cset->tasks))
4403+ if (!list_empty(&cset->tasks)) {
44044404 it->task_pos = cset->tasks.next;
4405− else if (!list_empty(&cset->mg_tasks))
4405+ it->cur_tasks_head = &cset->tasks;
4406+ } else if (!list_empty(&cset->mg_tasks)) {
44064407 it->task_pos = cset->mg_tasks.next;
4407− else
4408+ it->cur_tasks_head = &cset->mg_tasks;
4409+ } else {
44084410 it->task_pos = cset->dying_tasks.next;
4411+ it->cur_tasks_head = &cset->dying_tasks;
4412+ }
44094413
44104414 it->tasks_head = &cset->tasks;
44114415 it->mg_tasks_head = &cset->mg_tasks;
@@ -4463,10 +4467,14 @@ repeat: · 51 unmodified lines
44634467 else
44644468 it->task_pos = it->task_pos->next;
44654469
4466− if (it->task_pos == it->tasks_head)
4470+ if (it->task_pos == it->tasks_head) {
44674471 it->task_pos = it->mg_tasks_head->next;
4468− if (it->task_pos == it->mg_tasks_head)
4472+ it->cur_tasks_head = it->mg_tasks_head;
4473+ }
4474+ if (it->task_pos == it->mg_tasks_head) {
44694475 it->task_pos = it->dying_tasks_head->next;
4476+ it->cur_tasks_head = it->dying_tasks_head;
4477+ }
44704478 if (it->task_pos == it->dying_tasks_head)
44714479 css_task_iter_advance_css_set(it);
44724480 } else {
@@ -4485,11 +4493,12 @@ repeat: · 12 unmodified lines
44854493 goto repeat;
44864494
44874495 /* and dying leaders w/o live member threads */
4488− if (!atomic_read(&task->signal->live))
4496+ if (it->cur_tasks_head == it->dying_tasks_head &&
4497+ !atomic_read(&task->signal->live))
44894498 goto repeat;
44904499 } else {
44914500 /* skip all dying ones */
4492− if (task->flags & PF_EXITING)
4501+ if (it->cur_tasks_head == it->dying_tasks_head)
44934502 goto repeat;
44944503 }
44954504 }
@@ -4595,6 +4604,9 @@ static void *cgroup_procs_next(struct seq_file *s, void *v, loff_t *pos) · 99 unmodified lines
45954604 struct kernfs_open_file *of = s->private;
45964605 struct css_task_iter *it = of->priv;
45974606
4607+ if (pos)
4608+ (*pos)++;
4609+
45984610 return css_task_iter_next(it);
45994611 }
46004612
@@ -4610,7 +4622,7 @@ static void *__cgroup_procs_start(struct seq_file *s, loff_t *pos, · 9 unmodified lines
46104622 * from position 0, so we can simply keep iterating on !0 *pos.
46114623 */
46124624 if (!it) {
4613− if (WARN_ON_ONCE((*pos)++))
4625+ if (WARN_ON_ONCE((*pos)))
46144626 return ERR_PTR(-EINVAL);
46154627
46164628 it = kzalloc(sizeof(*it), GFP_KERNEL);
@@ -4618,10 +4630,11 @@ static void *__cgroup_procs_start(struct seq_file *s, loff_t *pos, · 1 unmodified line
46184630 return ERR_PTR(-ENOMEM);
46194631 of->priv = it;
46204632 css_task_iter_start(&cgrp->self, iter_flags, it);
4621− } else if (!(*pos)++) {
4633+ } else if (!(*pos)) {
46224634 css_task_iter_end(it);
46234635 css_task_iter_start(&cgrp->self, iter_flags, it);
4624− }
4636+ } else
4637+ return it->cur_task;
46254638
46264639 return cgroup_procs_next(s, NULL, NULL);
46274640 }
@@ -6258,6 +6271,10 @@ void cgroup_sk_alloc(struct sock_cgroup_data *skcd) · 1630 unmodified lines
62586271 return;
62596272 }
62606273
6274+ /* Don't associate the sock with unrelated interrupted task's cgroup. */
6275+ if (in_interrupt())
6276+ return;
6277+
62616278 rcu_read_lock();
62626279
62636280 while (true) {
kernel/exit.c+2−2
@@ -619,8 +619,8 @@ static void forget_original_parent(struct task_struct *father, · 618 unmodified lines
619619 reaper = find_new_reaper(father, reaper);
620620 list_for_each_entry(p, &father->children, sibling) {
621621 for_each_thread(p, t) {
622− t->real_parent = reaper;
623− BUG_ON((!t->ptrace) != (t->parent == father));
622+ RCU_INIT_POINTER(t->real_parent, reaper);
623+ BUG_ON((!t->ptrace) != (rcu_access_pointer(t->parent) == father));
624624 if (likely(!t->ptrace))
625625 t->parent = t->real_parent;
626626 if (t->pdeath_signal)
kernel/fork.c+1−1
@@ -1508,7 +1508,7 @@ static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk) · 1507 unmodified lines
15081508 return 0;
15091509 }
15101510 sig = kmem_cache_alloc(sighand_cachep, GFP_KERNEL);
1511− rcu_assign_pointer(tsk->sighand, sig);
1511+ RCU_INIT_POINTER(tsk->sighand, sig);
15121512 if (!sig)
15131513 return -ENOMEM;
15141514
kernel/futex.c+55−38
@@ -385,9 +385,9 @@ static inline int hb_waiters_pending(struct futex_hash_bucket *hb) · 384 unmodified lines
385385 */
386386 static struct futex_hash_bucket *hash_futex(union futex_key *key)
387387 {
388− u32 hash = jhash2((u32*)&key->both.word,
389− (sizeof(key->both.word)+sizeof(key->both.ptr))/4,
388+ u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4,
390389 key->both.offset);
390+
391391 return &futex_queues[hash & (futex_hashsize - 1)];
392392 }
393393
@@ -429,7 +429,7 @@ static void get_futex_key_refs(union futex_key *key) · 35 unmodified lines
429429
430430 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
431431 case FUT_OFF_INODE:
432− ihold(key->shared.inode); /* implies smp_mb(); (B) */
432+ smp_mb(); /* explicit smp_mb(); (B) */
433433 break;
434434 case FUT_OFF_MMSHARED:
435435 futex_get_mm(key); /* implies smp_mb(); (B) */
@@ -463,7 +463,6 @@ static void drop_futex_key_refs(union futex_key *key) · 27 unmodified lines
463463
464464 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
465465 case FUT_OFF_INODE:
466− iput(key->shared.inode);
467466 break;
468467 case FUT_OFF_MMSHARED:
469468 mmdrop(key->private.mm);
@@ -505,6 +504,46 @@ futex_setup_timer(ktime_t *time, struct hrtimer_sleeper *timeout, · 35 unmodified lines
505504 return timeout;
506505 }
507506
507+/*
508+ * Generate a machine wide unique identifier for this inode.
509+ *
510+ * This relies on u64 not wrapping in the life-time of the machine; which with
511+ * 1ns resolution means almost 585 years.
512+ *
513+ * This further relies on the fact that a well formed program will not unmap
514+ * the file while it has a (shared) futex waiting on it. This mapping will have
515+ * a file reference which pins the mount and inode.
516+ *
517+ * If for some reason an inode gets evicted and read back in again, it will get
518+ * a new sequence number and will _NOT_ match, even though it is the exact same
519+ * file.
520+ *
521+ * It is important that match_futex() will never have a false-positive, esp.
522+ * for PI futexes that can mess up the state. The above argues that false-negatives
523+ * are only possible for malformed programs.
524+ */
525+static u64 get_inode_sequence_number(struct inode *inode)
526+{
527+ static atomic64_t i_seq;
528+ u64 old;
529+
530+ /* Does the inode already have a sequence number? */
531+ old = atomic64_read(&inode->i_sequence);
532+ if (likely(old))
533+ return old;
534+
535+ for (;;) {
536+ u64 new = atomic64_add_return(1, &i_seq);
537+ if (WARN_ON_ONCE(!new))
538+ continue;
539+
540+ old = atomic64_cmpxchg_relaxed(&inode->i_sequence, 0, new);
541+ if (old)
542+ return old;
543+ return new;
544+ }
545+}
546+
508547 /**
509548 * get_futex_key() - Get parameters which are the keys for a futex
510549 * @uaddr: virtual address of the futex
@@ -517,9 +556,15 @@ futex_setup_timer(ktime_t *time, struct hrtimer_sleeper *timeout, · 6 unmodified lines
517556 *
518557 * The key words are stored in @key on success.
519558 *
520− * For shared mappings, it's (page->index, file_inode(vma->vm_file),
521− * offset_within_page). For private mappings, it's (uaddr, current->mm).
522− * We can usually work out the index without swapping in the page.
559+ * For shared mappings (when @fshared), the key is:
560+ * ( inode->i_sequence, page->index, offset_within_page )
561+ * [ also see get_inode_sequence_number() ]
562+ *
563+ * For private mappings (or when !@fshared), the key is:
564+ * ( current->mm, address, 0 )
565+ *
566+ * This allows (cross process, where applicable) identification of the futex
567+ * without keeping the page pinned for the duration of the FUTEX_WAIT.
523568 *
524569 * lock_page() might sleep, the caller should not hold a spinlock.
525570 */
@@ -659,8 +704,6 @@ again: · 133 unmodified lines
659704 key->private.mm = mm;
660705 key->private.address = address;
661706
662− get_futex_key_refs(key); /* implies smp_mb(); (B) */
663−
664707 } else {
665708 struct inode *inode;
666709
@@ -692,40 +735,14 @@ again: · 25 unmodified lines
692735 goto again;
693736 }
694737
695− /*
696− * Take a reference unless it is about to be freed. Previously
697− * this reference was taken by ihold under the page lock
698− * pinning the inode in place so i_lock was unnecessary. The
699− * only way for this check to fail is if the inode was
700− * truncated in parallel which is almost certainly an
701− * application bug. In such a case, just retry.
702− *
703− * We are not calling into get_futex_key_refs() in file-backed
704− * cases, therefore a successful atomic_inc return below will
705− * guarantee that get_futex_key() will still imply smp_mb(); (B).
706− */
707− if (!atomic_inc_not_zero(&inode->i_count)) {
708− rcu_read_unlock();
709− put_page(page);
710−
711− goto again;
712− }
713−
714− /* Should be impossible but lets be paranoid for now */
715− if (WARN_ON_ONCE(inode->i_mapping != mapping)) {
716− err = -EFAULT;
717− rcu_read_unlock();
718− iput(inode);
719−
720− goto out;
721− }
722−
723738 key->both.offset |= FUT_OFF_INODE; /* inode-based key */
724− key->shared.inode = inode;
739+ key->shared.i_seq = get_inode_sequence_number(inode);
725740 key->shared.pgoff = basepage_index(tail);
726741 rcu_read_unlock();
727742 }
728743
744+ get_futex_key_refs(key); /* implies smp_mb(); (B) */
745+
729746 out:
730747 put_page(page);
731748 return err;
kernel/pid.c+10−0
@@ -247,6 +247,16 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, · 246 unmodified lines
247247 tmp = tmp->parent;
248248 }
249249
250+ /*
251+ * ENOMEM is not the most obvious choice especially for the case
252+ * where the child subreaper has already exited and the pid
253+ * namespace denies the creation of any new processes. But ENOMEM
254+ * is what we have exposed to userspace for a long time and it is
255+ * documented behavior for pid namespaces. So we can't easily
256+ * change it even if there were an error code better suited.
257+ */
258+ retval = -ENOMEM;
259+
250260 if (unlikely(is_child_reaper(pid))) {
251261 if (pid_ns_prepare_proc(ns))
252262 goto out_free;
kernel/power/snapshot.c+1−1
@@ -1681,7 +1681,7 @@ static unsigned long minimum_image_size(unsigned long saveable) · 1680 unmodified lines
16811681 * hibernation for allocations made while saving the image and for device
16821682 * drivers, in case they need to allocate memory from their hibernation
16831683 * callbacks (these two numbers are given by PAGES_FOR_IO (which is a rough
1684− * estimate) and reserverd_size divided by PAGE_SIZE (which is tunable through
1684+ * estimate) and reserved_size divided by PAGE_SIZE (which is tunable through
16851685 * /sys/power/reserved_size, respectively). To make this happen, we compute the
16861686 * total number of available page frames and allocate at least
16871687 *
kernel/sched/fair.c+2−0
@@ -8337,6 +8337,8 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd, · 8336 unmodified lines
83378337
83388338 sgs->group_capacity = group->sgc->capacity;
83398339
8340+ sgs->group_weight = group->group_weight;
8341+
83408342 sgs->group_type = group_classify(sd->imbalance_pct, group, sgs);
83418343
83428344 /*
kernel/signal.c+14−9
@@ -413,27 +413,32 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi · 412 unmodified lines
413413 {
414414 struct sigqueue *q = NULL;
415415 struct user_struct *user;
416+ int sigpending;
416417
417418 /*
418419 * Protect access to @t credentials. This can go away when all
419420 * callers hold rcu read lock.
421+ *
422+ * NOTE! A pending signal will hold on to the user refcount,
423+ * and we get/put the refcount only when the sigpending count
424+ * changes from/to zero.
420425 */
421426 rcu_read_lock();
422− user = get_uid(__task_cred(t)->user);
423− atomic_inc(&user->sigpending);
427+ user = __task_cred(t)->user;
428+ sigpending = atomic_inc_return(&user->sigpending);
429+ if (sigpending == 1)
430+ get_uid(user);
424431 rcu_read_unlock();
425432
426− if (override_rlimit ||
427− atomic_read(&user->sigpending) <=
428− task_rlimit(t, RLIMIT_SIGPENDING)) {
433+ if (override_rlimit || likely(sigpending <= task_rlimit(t, RLIMIT_SIGPENDING))) {
429434 q = kmem_cache_alloc(sigqueue_cachep, flags);
430435 } else {
431436 print_dropped_signal(sig);
432437 }
433438
434439 if (unlikely(q == NULL)) {
435− atomic_dec(&user->sigpending);
436− free_uid(user);
440+ if (atomic_dec_and_test(&user->sigpending))
441+ free_uid(user);
437442 } else {
438443 INIT_LIST_HEAD(&q->list);
439444 q->flags = 0;
@@ -447,8 +452,8 @@ static void __sigqueue_free(struct sigqueue *q) · 7 unmodified lines
447452 {
448453 if (q->flags & SIGQUEUE_PREALLOC)
449454 return;
450− atomic_dec(&q->user->sigpending);
451− free_uid(q->user);
455+ if (atomic_dec_and_test(&q->user->sigpending))
456+ free_uid(q->user);
452457 kmem_cache_free(sigqueue_cachep, q);
453458 }
454459
kernel/sys.c+2−0
@@ -47,6 +47,7 @@ · 46 unmodified lines
4747 #include <linux/syscalls.h>
4848 #include <linux/kprobes.h>
4949 #include <linux/user_namespace.h>
50+#include <linux/time_namespace.h>
5051 #include <linux/binfmts.h>
5152
5253 #include <linux/sched.h>
@@ -2546,6 +2547,7 @@ static int do_sysinfo(struct sysinfo *info) · 2493 unmodified lines
25462547 memset(info, 0, sizeof(struct sysinfo));
25472548
25482549 ktime_get_boottime_ts64(&tp);
2550+ timens_add_boottime(&tp);
25492551 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
25502552
25512553 get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT);
kernel/trace/Kconfig+2−2
@@ -143,8 +143,8 @@ if FTRACE · 142 unmodified lines
143143
144144 config BOOTTIME_TRACING
145145 bool "Boot-time Tracing support"
146− depends on BOOT_CONFIG && TRACING
147− default y
146+ depends on TRACING
147+ select BOOT_CONFIG
148148 help
149149 Enable developer to setup ftrace subsystem via supplemental
150150 kernel cmdline at boot time for debugging (tracing) driver
kernel/trace/blktrace.c+86−31
@@ -335,6 +335,7 @@ static void put_probe_ref(void) · 334 unmodified lines
335335
336336 static void blk_trace_cleanup(struct blk_trace *bt)
337337 {
338+ synchronize_rcu();
338339 blk_trace_free(bt);
339340 put_probe_ref();
340341 }
@@ -629,8 +630,10 @@ static int compat_blk_trace_setup(struct request_queue *q, char *name, · 288 unmodified lines
629630 static int __blk_trace_startstop(struct request_queue *q, int start)
630631 {
631632 int ret;
632− struct blk_trace *bt = q->blk_trace;
633+ struct blk_trace *bt;
633634
635+ bt = rcu_dereference_protected(q->blk_trace,
636+ lockdep_is_held(&q->blk_trace_mutex));
634637 if (bt == NULL)
635638 return -EINVAL;
636639
@@ -740,8 +743,8 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) · 103 unmodified lines
740743 void blk_trace_shutdown(struct request_queue *q)
741744 {
742745 mutex_lock(&q->blk_trace_mutex);
743−
744− if (q->blk_trace) {
746+ if (rcu_dereference_protected(q->blk_trace,
747+ lockdep_is_held(&q->blk_trace_mutex))) {
745748 __blk_trace_startstop(q, 0);
746749 __blk_trace_remove(q);
747750 }
@@ -752,8 +755,10 @@ void blk_trace_shutdown(struct request_queue *q) · 4 unmodified lines
752755 #ifdef CONFIG_BLK_CGROUP
753756 static u64 blk_trace_bio_get_cgid(struct request_queue *q, struct bio *bio)
754757 {
755− struct blk_trace *bt = q->blk_trace;
758+ struct blk_trace *bt;
756759
760+ /* We don't use the 'bt' value here except as an optimization... */
761+ bt = rcu_dereference_protected(q->blk_trace, 1);
757762 if (!bt || !(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP))
758763 return 0;
759764
@@ -796,10 +801,14 @@ blk_trace_request_get_cgid(struct request_queue *q, struct request *rq) · 36 unmodified lines
796801 static void blk_add_trace_rq(struct request *rq, int error,
797802 unsigned int nr_bytes, u32 what, u64 cgid)
798803 {
799− struct blk_trace *bt = rq->q->blk_trace;
804+ struct blk_trace *bt;
800805
801− if (likely(!bt))
806+ rcu_read_lock();
807+ bt = rcu_dereference(rq->q->blk_trace);
808+ if (likely(!bt)) {
809+ rcu_read_unlock();
802810 return;
811+ }
803812
804813 if (blk_rq_is_passthrough(rq))
805814 what |= BLK_TC_ACT(BLK_TC_PC);
@@ -808,6 +817,7 @@ static void blk_add_trace_rq(struct request *rq, int error, · 2 unmodified lines
808817
809818 __blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, req_op(rq),
810819 rq->cmd_flags, what, error, 0, NULL, cgid);
820+ rcu_read_unlock();
811821 }
812822
813823 static void blk_add_trace_rq_insert(void *ignore,
@@ -853,14 +863,19 @@ static void blk_add_trace_rq_complete(void *ignore, struct request *rq, · 39 unmodified lines
853863 static void blk_add_trace_bio(struct request_queue *q, struct bio *bio,
854864 u32 what, int error)
855865 {
856− struct blk_trace *bt = q->blk_trace;
866+ struct blk_trace *bt;
857867
858− if (likely(!bt))
868+ rcu_read_lock();
869+ bt = rcu_dereference(q->blk_trace);
870+ if (likely(!bt)) {
871+ rcu_read_unlock();
859872 return;
873+ }
860874
861875 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,
862876 bio_op(bio), bio->bi_opf, what, error, 0, NULL,
863877 blk_trace_bio_get_cgid(q, bio));
878+ rcu_read_unlock();
864879 }
865880
866881 static void blk_add_trace_bio_bounce(void *ignore,
@@ -905,11 +920,14 @@ static void blk_add_trace_getrq(void *ignore, · 38 unmodified lines
905920 if (bio)
906921 blk_add_trace_bio(q, bio, BLK_TA_GETRQ, 0);
907922 else {
908− struct blk_trace *bt = q->blk_trace;
923+ struct blk_trace *bt;
909924
925+ rcu_read_lock();
926+ bt = rcu_dereference(q->blk_trace);
910927 if (bt)
911928 __blk_add_trace(bt, 0, 0, rw, 0, BLK_TA_GETRQ, 0, 0,
912929 NULL, 0);
930+ rcu_read_unlock();
913931 }
914932 }
915933
@@ -921,27 +939,35 @@ static void blk_add_trace_sleeprq(void *ignore, · 5 unmodified lines
921939 if (bio)
922940 blk_add_trace_bio(q, bio, BLK_TA_SLEEPRQ, 0);
923941 else {
924− struct blk_trace *bt = q->blk_trace;
942+ struct blk_trace *bt;
925943
944+ rcu_read_lock();
945+ bt = rcu_dereference(q->blk_trace);
926946 if (bt)
927947 __blk_add_trace(bt, 0, 0, rw, 0, BLK_TA_SLEEPRQ,
928948 0, 0, NULL, 0);
949+ rcu_read_unlock();
929950 }
930951 }
931952
932953 static void blk_add_trace_plug(void *ignore, struct request_queue *q)
933954 {
934− struct blk_trace *bt = q->blk_trace;
955+ struct blk_trace *bt;
935956
957+ rcu_read_lock();
958+ bt = rcu_dereference(q->blk_trace);
936959 if (bt)
937960 __blk_add_trace(bt, 0, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, 0);
961+ rcu_read_unlock();
938962 }
939963
940964 static void blk_add_trace_unplug(void *ignore, struct request_queue *q,
941965 unsigned int depth, bool explicit)
942966 {
943− struct blk_trace *bt = q->blk_trace;
967+ struct blk_trace *bt;
944968
969+ rcu_read_lock();
970+ bt = rcu_dereference(q->blk_trace);
945971 if (bt) {
946972 __be64 rpdu = cpu_to_be64(depth);
947973 u32 what;
@@ -953,14 +979,17 @@ static void blk_add_trace_unplug(void *ignore, struct request_queue *q, · 5 unmodified lines
953979
954980 __blk_add_trace(bt, 0, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, 0);
955981 }
982+ rcu_read_unlock();
956983 }
957984
958985 static void blk_add_trace_split(void *ignore,
959986 struct request_queue *q, struct bio *bio,
960987 unsigned int pdu)
961988 {
962− struct blk_trace *bt = q->blk_trace;
989+ struct blk_trace *bt;
963990
991+ rcu_read_lock();
992+ bt = rcu_dereference(q->blk_trace);
964993 if (bt) {
965994 __be64 rpdu = cpu_to_be64(pdu);
966995
@@ -969,6 +998,7 @@ static void blk_add_trace_split(void *ignore, · 2 unmodified lines
969998 BLK_TA_SPLIT, bio->bi_status, sizeof(rpdu),
970999 &rpdu, blk_trace_bio_get_cgid(q, bio));
9711000 }
1001+ rcu_read_unlock();
9721002 }
9731003
9741004 /**
@@ -988,11 +1018,15 @@ static void blk_add_trace_bio_remap(void *ignore, · 13 unmodified lines
9881018 struct request_queue *q, struct bio *bio,
9891019 dev_t dev, sector_t from)
9901020 {
991− struct blk_trace *bt = q->blk_trace;
1021+ struct blk_trace *bt;
9921022 struct blk_io_trace_remap r;
9931023
994− if (likely(!bt))
1024+ rcu_read_lock();
1025+ bt = rcu_dereference(q->blk_trace);
1026+ if (likely(!bt)) {
1027+ rcu_read_unlock();
9951028 return;
1029+ }
9961030
9971031 r.device_from = cpu_to_be32(dev);
9981032 r.device_to = cpu_to_be32(bio_dev(bio));
@@ -1001,6 +1035,7 @@ static void blk_add_trace_bio_remap(void *ignore, · 2 unmodified lines
10011035 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,
10021036 bio_op(bio), bio->bi_opf, BLK_TA_REMAP, bio->bi_status,
10031037 sizeof(r), &r, blk_trace_bio_get_cgid(q, bio));
1038+ rcu_read_unlock();
10041039 }
10051040
10061041 /**
@@ -1021,11 +1056,15 @@ static void blk_add_trace_rq_remap(void *ignore, · 14 unmodified lines
10211056 struct request *rq, dev_t dev,
10221057 sector_t from)
10231058 {
1024− struct blk_trace *bt = q->blk_trace;
1059+ struct blk_trace *bt;
10251060 struct blk_io_trace_remap r;
10261061
1027− if (likely(!bt))
1062+ rcu_read_lock();
1063+ bt = rcu_dereference(q->blk_trace);
1064+ if (likely(!bt)) {
1065+ rcu_read_unlock();
10281066 return;
1067+ }
10291068
10301069 r.device_from = cpu_to_be32(dev);
10311070 r.device_to = cpu_to_be32(disk_devt(rq->rq_disk));
@@ -1034,6 +1073,7 @@ static void blk_add_trace_rq_remap(void *ignore, · 2 unmodified lines
10341073 __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq),
10351074 rq_data_dir(rq), 0, BLK_TA_REMAP, 0,
10361075 sizeof(r), &r, blk_trace_request_get_cgid(q, rq));
1076+ rcu_read_unlock();
10371077 }
10381078
10391079 /**
@@ -1051,14 +1091,19 @@ void blk_add_driver_data(struct request_queue *q, · 11 unmodified lines
10511091 struct request *rq,
10521092 void *data, size_t len)
10531093 {
1054− struct blk_trace *bt = q->blk_trace;
1094+ struct blk_trace *bt;
10551095
1056− if (likely(!bt))
1096+ rcu_read_lock();
1097+ bt = rcu_dereference(q->blk_trace);
1098+ if (likely(!bt)) {
1099+ rcu_read_unlock();
10571100 return;
1101+ }
10581102
10591103 __blk_add_trace(bt, blk_rq_trace_sector(rq), blk_rq_bytes(rq), 0, 0,
10601104 BLK_TA_DRV_DATA, 0, len, data,
10611105 blk_trace_request_get_cgid(q, rq));
1106+ rcu_read_unlock();
10621107 }
10631108 EXPORT_SYMBOL_GPL(blk_add_driver_data);
10641109
@@ -1597,6 +1642,7 @@ static int blk_trace_remove_queue(struct request_queue *q) · 532 unmodified lines
15971642 return -EINVAL;
15981643
15991644 put_probe_ref();
1645+ synchronize_rcu();
16001646 blk_trace_free(bt);
16011647 return 0;
16021648 }
@@ -1758,6 +1804,7 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev, · 155 unmodified lines
17581804 struct hd_struct *p = dev_to_part(dev);
17591805 struct request_queue *q;
17601806 struct block_device *bdev;
1807+ struct blk_trace *bt;
17611808 ssize_t ret = -ENXIO;
17621809
17631810 bdev = bdget(part_devt(p));
@@ -1770,21 +1817,23 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev, · 6 unmodified lines
17701817
17711818 mutex_lock(&q->blk_trace_mutex);
17721819
1820+ bt = rcu_dereference_protected(q->blk_trace,
1821+ lockdep_is_held(&q->blk_trace_mutex));
17731822 if (attr == &dev_attr_enable) {
1774− ret = sprintf(buf, "%u\n", !!q->blk_trace);
1823+ ret = sprintf(buf, "%u\n", !!bt);
17751824 goto out_unlock_bdev;
17761825 }
17771826
1778− if (q->blk_trace == NULL)
1827+ if (bt == NULL)
17791828 ret = sprintf(buf, "disabled\n");
17801829 else if (attr == &dev_attr_act_mask)
1781− ret = blk_trace_mask2str(buf, q->blk_trace->act_mask);
1830+ ret = blk_trace_mask2str(buf, bt->act_mask);
17821831 else if (attr == &dev_attr_pid)
1783− ret = sprintf(buf, "%u\n", q->blk_trace->pid);
1832+ ret = sprintf(buf, "%u\n", bt->pid);
17841833 else if (attr == &dev_attr_start_lba)
1785− ret = sprintf(buf, "%llu\n", q->blk_trace->start_lba);
1834+ ret = sprintf(buf, "%llu\n", bt->start_lba);
17861835 else if (attr == &dev_attr_end_lba)
1787− ret = sprintf(buf, "%llu\n", q->blk_trace->end_lba);
1836+ ret = sprintf(buf, "%llu\n", bt->end_lba);
17881837
17891838 out_unlock_bdev:
17901839 mutex_unlock(&q->blk_trace_mutex);
@@ -1801,6 +1850,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, · 10 unmodified lines
18011850 struct block_device *bdev;
18021851 struct request_queue *q;
18031852 struct hd_struct *p;
1853+ struct blk_trace *bt;
18041854 u64 value;
18051855 ssize_t ret = -EINVAL;
18061856
@@ -1831,8 +1881,10 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, · 24 unmodified lines
18311881
18321882 mutex_lock(&q->blk_trace_mutex);
18331883
1884+ bt = rcu_dereference_protected(q->blk_trace,
1885+ lockdep_is_held(&q->blk_trace_mutex));
18341886 if (attr == &dev_attr_enable) {
1835− if (!!value == !!q->blk_trace) {
1887+ if (!!value == !!bt) {
18361888 ret = 0;
18371889 goto out_unlock_bdev;
18381890 }
@@ -1844,18 +1896,21 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, · 5 unmodified lines
18441896 }
18451897
18461898 ret = 0;
1847− if (q->blk_trace == NULL)
1899+ if (bt == NULL) {
18481900 ret = blk_trace_setup_queue(q, bdev);
1901+ bt = rcu_dereference_protected(q->blk_trace,
1902+ lockdep_is_held(&q->blk_trace_mutex));
1903+ }
18491904
18501905 if (ret == 0) {
18511906 if (attr == &dev_attr_act_mask)
1852− q->blk_trace->act_mask = value;
1907+ bt->act_mask = value;
18531908 else if (attr == &dev_attr_pid)
1854− q->blk_trace->pid = value;
1909+ bt->pid = value;
18551910 else if (attr == &dev_attr_start_lba)
1856− q->blk_trace->start_lba = value;
1911+ bt->start_lba = value;
18571912 else if (attr == &dev_attr_end_lba)
1858− q->blk_trace->end_lba = value;
1913+ bt->end_lba = value;
18591914 }
18601915
18611916 out_unlock_bdev:
kernel/trace/ftrace.c+2−0
@@ -1547,6 +1547,8 @@ static struct dyn_ftrace *lookup_rec(unsigned long start, unsigned long end) · 1546 unmodified lines
15471547 rec = bsearch(&key, pg->records, pg->index,
15481548 sizeof(struct dyn_ftrace),
15491549 ftrace_cmp_recs);
1550+ if (rec)
1551+ break;
15501552 }
15511553 return rec;
15521554 }
kernel/trace/synth_event_gen_test.c+22−22
@@ -111,11 +111,11 @@ static int __init test_gen_synth_cmd(void) · 110 unmodified lines
111111 /* Create some bogus values just for testing */
112112
113113 vals[0] = 777; /* next_pid_field */
114− vals[1] = (u64)"hula hoops"; /* next_comm_field */
114+ vals[1] = (u64)(long)"hula hoops"; /* next_comm_field */
115115 vals[2] = 1000000; /* ts_ns */
116116 vals[3] = 1000; /* ts_ms */
117− vals[4] = smp_processor_id(); /* cpu */
118− vals[5] = (u64)"thneed"; /* my_string_field */
117+ vals[4] = raw_smp_processor_id(); /* cpu */
118+ vals[5] = (u64)(long)"thneed"; /* my_string_field */
119119 vals[6] = 598; /* my_int_field */
120120
121121 /* Now generate a gen_synth_test event */
@@ -218,11 +218,11 @@ static int __init test_empty_synth_event(void) · 96 unmodified lines
218218 /* Create some bogus values just for testing */
219219
220220 vals[0] = 777; /* next_pid_field */
221− vals[1] = (u64)"tiddlywinks"; /* next_comm_field */
221+ vals[1] = (u64)(long)"tiddlywinks"; /* next_comm_field */
222222 vals[2] = 1000000; /* ts_ns */
223223 vals[3] = 1000; /* ts_ms */
224− vals[4] = smp_processor_id(); /* cpu */
225− vals[5] = (u64)"thneed_2.0"; /* my_string_field */
224+ vals[4] = raw_smp_processor_id(); /* cpu */
225+ vals[5] = (u64)(long)"thneed_2.0"; /* my_string_field */
226226 vals[6] = 399; /* my_int_field */
227227
228228 /* Now trace an empty_synth_test event */
@@ -290,11 +290,11 @@ static int __init test_create_synth_event(void) · 61 unmodified lines
290290 /* Create some bogus values just for testing */
291291
292292 vals[0] = 777; /* next_pid_field */
293− vals[1] = (u64)"tiddlywinks"; /* next_comm_field */
293+ vals[1] = (u64)(long)"tiddlywinks"; /* next_comm_field */
294294 vals[2] = 1000000; /* ts_ns */
295295 vals[3] = 1000; /* ts_ms */
296− vals[4] = smp_processor_id(); /* cpu */
297− vals[5] = (u64)"thneed"; /* my_string_field */
296+ vals[4] = raw_smp_processor_id(); /* cpu */
297+ vals[5] = (u64)(long)"thneed"; /* my_string_field */
298298 vals[6] = 398; /* my_int_field */
299299
300300 /* Now generate a create_synth_test event */
@@ -330,7 +330,7 @@ static int __init test_add_next_synth_val(void) · 29 unmodified lines
330330 goto out;
331331
332332 /* next_comm_field */
333− ret = synth_event_add_next_val((u64)"slinky", &trace_state);
333+ ret = synth_event_add_next_val((u64)(long)"slinky", &trace_state);
334334 if (ret)
335335 goto out;
336336
@@ -345,12 +345,12 @@ static int __init test_add_next_synth_val(void) · 8 unmodified lines
345345 goto out;
346346
347347 /* cpu */
348− ret = synth_event_add_next_val(smp_processor_id(), &trace_state);
348+ ret = synth_event_add_next_val(raw_smp_processor_id(), &trace_state);
349349 if (ret)
350350 goto out;
351351
352352 /* my_string_field */
353− ret = synth_event_add_next_val((u64)"thneed_2.01", &trace_state);
353+ ret = synth_event_add_next_val((u64)(long)"thneed_2.01", &trace_state);
354354 if (ret)
355355 goto out;
356356
@@ -388,7 +388,7 @@ static int __init test_add_synth_val(void) · 31 unmodified lines
388388 if (ret)
389389 goto out;
390390
391− ret = synth_event_add_val("cpu", smp_processor_id(), &trace_state);
391+ ret = synth_event_add_val("cpu", raw_smp_processor_id(), &trace_state);
392392 if (ret)
393393 goto out;
394394
@@ -396,12 +396,12 @@ static int __init test_add_synth_val(void) · 1 unmodified line
396396 if (ret)
397397 goto out;
398398
399− ret = synth_event_add_val("next_comm_field", (u64)"silly putty",
399+ ret = synth_event_add_val("next_comm_field", (u64)(long)"silly putty",
400400 &trace_state);
401401 if (ret)
402402 goto out;
403403
404− ret = synth_event_add_val("my_string_field", (u64)"thneed_9",
404+ ret = synth_event_add_val("my_string_field", (u64)(long)"thneed_9",
405405 &trace_state);
406406 if (ret)
407407 goto out;
@@ -423,13 +423,13 @@ static int __init test_trace_synth_event(void) · 15 unmodified lines
423423
424424 /* Trace some bogus values just for testing */
425425 ret = synth_event_trace(create_synth_test, 7, /* number of values */
426− 444, /* next_pid_field */
427− (u64)"clackers", /* next_comm_field */
428− 1000000, /* ts_ns */
429− 1000, /* ts_ms */
430− smp_processor_id(), /* cpu */
431− (u64)"Thneed", /* my_string_field */
432− 999); /* my_int_field */
426+ (u64)444, /* next_pid_field */
427+ (u64)(long)"clackers", /* next_comm_field */
428+ (u64)1000000, /* ts_ns */
429+ (u64)1000, /* ts_ms */
430+ (u64)raw_smp_processor_id(), /* cpu */
431+ (u64)(long)"Thneed", /* my_string_field */
432+ (u64)999); /* my_int_field */
433433 return ret;
434434 }
435435
kernel/trace/trace.c+2−0
@@ -1837,6 +1837,7 @@ static __init int init_trace_selftests(void) · 1836 unmodified lines
18371837
18381838 pr_info("Running postponed tracer tests:\n");
18391839
1840+ tracing_selftest_running = true;
18401841 list_for_each_entry_safe(p, n, &postponed_selftests, list) {
18411842 /* This loop can take minutes when sanitizers are enabled, so
18421843 * lets make sure we allow RCU processing.
@@ -1859,6 +1860,7 @@ static __init int init_trace_selftests(void) · 16 unmodified lines
18591860 list_del(&p->list);
18601861 kfree(p);
18611862 }
1863+ tracing_selftest_running = false;
18621864
18631865 out:
18641866 mutex_unlock(&trace_types_lock);
kernel/trace/trace_events_hist.c+101−11
@@ -821,6 +821,29 @@ static const char *synth_field_fmt(char *type) · 820 unmodified lines
821821 return fmt;
822822 }
823823
824+static void print_synth_event_num_val(struct trace_seq *s,
825+ char *print_fmt, char *name,
826+ int size, u64 val, char *space)
827+{
828+ switch (size) {
829+ case 1:
830+ trace_seq_printf(s, print_fmt, name, (u8)val, space);
831+ break;
832+
833+ case 2:
834+ trace_seq_printf(s, print_fmt, name, (u16)val, space);
835+ break;
836+
837+ case 4:
838+ trace_seq_printf(s, print_fmt, name, (u32)val, space);
839+ break;
840+
841+ default:
842+ trace_seq_printf(s, print_fmt, name, val, space);
843+ break;
844+ }
845+}
846+
824847 static enum print_line_t print_synth_event(struct trace_iterator *iter,
825848 int flags,
826849 struct trace_event *event)
@@ -859,10 +882,13 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter, · 32 unmodified lines
859882 } else {
860883 struct trace_print_flags __flags[] = {
861884 __def_gfpflag_names, {-1, NULL} };
885+ char *space = (i == se->n_fields - 1 ? "" : " ");
862886
863− trace_seq_printf(s, print_fmt, se->fields[i]->name,
864− entry->fields[n_u64],
865− i == se->n_fields - 1 ? "" : " ");
887+ print_synth_event_num_val(s, print_fmt,
888+ se->fields[i]->name,
889+ se->fields[i]->size,
890+ entry->fields[n_u64],
891+ space);
866892
867893 if (strcmp(se->fields[i]->type, "gfp_t") == 0) {
868894 trace_seq_puts(s, " (");
@@ -1805,6 +1831,8 @@ __synth_event_trace_start(struct trace_event_file *file, · 936 unmodified lines
18051831 int entry_size, fields_size = 0;
18061832 int ret = 0;
18071833
1834+ memset(trace_state, '\0', sizeof(*trace_state));
1835+
18081836 /*
18091837 * Normal event tracing doesn't get called at all unless the
18101838 * ENABLED bit is set (which attaches the probe thus allowing
@@ -1885,6 +1913,11 @@ int synth_event_trace(struct trace_event_file *file, unsigned int n_vals, ...) · 74 unmodified lines
18851913 return ret;
18861914 }
18871915
1916+ if (n_vals != state.event->n_fields) {
1917+ ret = -EINVAL;
1918+ goto out;
1919+ }
1920+
18881921 va_start(args, n_vals);
18891922 for (i = 0, n_u64 = 0; i < state.event->n_fields; i++) {
18901923 u64 val;
@@ -1898,12 +1931,30 @@ int synth_event_trace(struct trace_event_file *file, unsigned int n_vals, ...) · 7 unmodified lines
18981931 strscpy(str_field, str_val, STR_VAR_LEN_MAX);
18991932 n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
19001933 } else {
1901− state.entry->fields[n_u64] = val;
1934+ struct synth_field *field = state.event->fields[i];
1935+
1936+ switch (field->size) {
1937+ case 1:
1938+ *(u8 *)&state.entry->fields[n_u64] = (u8)val;
1939+ break;
1940+
1941+ case 2:
1942+ *(u16 *)&state.entry->fields[n_u64] = (u16)val;
1943+ break;
1944+
1945+ case 4:
1946+ *(u32 *)&state.entry->fields[n_u64] = (u32)val;
1947+ break;
1948+
1949+ default:
1950+ state.entry->fields[n_u64] = val;
1951+ break;
1952+ }
19021953 n_u64++;
19031954 }
19041955 }
19051956 va_end(args);
1906−
1957+out:
19071958 __synth_event_trace_end(&state);
19081959
19091960 return ret;
@@ -1942,6 +1993,11 @@ int synth_event_trace_array(struct trace_event_file *file, u64 *vals, · 32 unmodified lines
19421993 return ret;
19431994 }
19441995
1996+ if (n_vals != state.event->n_fields) {
1997+ ret = -EINVAL;
1998+ goto out;
1999+ }
2000+
19452001 for (i = 0, n_u64 = 0; i < state.event->n_fields; i++) {
19462002 if (state.event->fields[i]->is_string) {
19472003 char *str_val = (char *)(long)vals[i];
@@ -1950,11 +2006,30 @@ int synth_event_trace_array(struct trace_event_file *file, u64 *vals, · 2 unmodified lines
19502006 strscpy(str_field, str_val, STR_VAR_LEN_MAX);
19512007 n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
19522008 } else {
1953− state.entry->fields[n_u64] = vals[i];
2009+ struct synth_field *field = state.event->fields[i];
2010+ u64 val = vals[i];
2011+
2012+ switch (field->size) {
2013+ case 1:
2014+ *(u8 *)&state.entry->fields[n_u64] = (u8)val;
2015+ break;
2016+
2017+ case 2:
2018+ *(u16 *)&state.entry->fields[n_u64] = (u16)val;
2019+ break;
2020+
2021+ case 4:
2022+ *(u32 *)&state.entry->fields[n_u64] = (u32)val;
2023+ break;
2024+
2025+ default:
2026+ state.entry->fields[n_u64] = val;
2027+ break;
2028+ }
19542029 n_u64++;
19552030 }
19562031 }
1957−
2032+out:
19582033 __synth_event_trace_end(&state);
19592034
19602035 return ret;
@@ -1997,8 +2072,6 @@ int synth_event_trace_start(struct trace_event_file *file, · 36 unmodified lines
19972072 if (!trace_state)
19982073 return -EINVAL;
19992074
2000− memset(trace_state, '\0', sizeof(*trace_state));
2001−
20022075 ret = __synth_event_trace_start(file, trace_state);
20032076 if (ret == -ENOENT)
20042077 ret = 0; /* just disabled, not really an error */
@@ -2069,8 +2142,25 @@ static int __synth_event_add_val(const char *field_name, u64 val, · 64 unmodified lines
20692142
20702143 str_field = (char *)&entry->fields[field->offset];
20712144 strscpy(str_field, str_val, STR_VAR_LEN_MAX);
2072− } else
2073− entry->fields[field->offset] = val;
2145+ } else {
2146+ switch (field->size) {
2147+ case 1:
2148+ *(u8 *)&trace_state->entry->fields[field->offset] = (u8)val;
2149+ break;
2150+
2151+ case 2:
2152+ *(u16 *)&trace_state->entry->fields[field->offset] = (u16)val;
2153+ break;
2154+
2155+ case 4:
2156+ *(u32 *)&trace_state->entry->fields[field->offset] = (u32)val;
2157+ break;
2158+
2159+ default:
2160+ trace_state->entry->fields[field->offset] = val;
2161+ break;
2162+ }
2163+ }
20742164 out:
20752165 return ret;
20762166 }
kernel/workqueue.c+8−6
@@ -1411,14 +1411,16 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, · 1410 unmodified lines
14111411 return;
14121412 rcu_read_lock();
14131413 retry:
1414− if (req_cpu == WORK_CPU_UNBOUND)
1415− cpu = wq_select_unbound_cpu(raw_smp_processor_id());
1416−
14171414 /* pwq which will be used unless @work is executing elsewhere */
1418− if (!(wq->flags & WQ_UNBOUND))
1419− pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
1420− else
1415+ if (wq->flags & WQ_UNBOUND) {
1416+ if (req_cpu == WORK_CPU_UNBOUND)
1417+ cpu = wq_select_unbound_cpu(raw_smp_processor_id());
14211418 pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu));
1419+ } else {
1420+ if (req_cpu == WORK_CPU_UNBOUND)
1421+ cpu = raw_smp_processor_id();
1422+ pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
1423+ }
14221424
14231425 /*
14241426 * If @work was previously on a different pool, it might still be

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t