No conflicts.
Showing the changes to kernel (6 of 342 files). Show all
Unified · Split
| @@ -718,7 +718,7 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, · 717 unmodified lines | ||
| 718 | 718 | { |
| 719 | 719 | int rc = 0; |
| 720 | 720 | struct sk_buff *skb; |
| 721 | − static unsigned int failed = 0; | |
| 721 | + unsigned int failed = 0; | |
| 722 | 722 | |
| 723 | 723 | /* NOTE: kauditd_thread takes care of all our locking, we just use |
| 724 | 724 | * the netlink info passed to us (e.g. sk and portid) */ |
| @@ -735,32 +735,30 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, · 10 unmodified lines | ||
| 735 | 735 | continue; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | +retry: | |
| 738 | 739 | /* grab an extra skb reference in case of error */ |
| 739 | 740 | skb_get(skb); |
| 740 | 741 | rc = netlink_unicast(sk, skb, portid, 0); |
| 741 | 742 | if (rc < 0) { |
| 742 | − /* fatal failure for our queue flush attempt? */ | |
| 743 | + /* send failed - try a few times unless fatal error */ | |
| 743 | 744 | if (++failed >= retry_limit || |
| 744 | 745 | rc == -ECONNREFUSED || rc == -EPERM) { |
| 745 | − /* yes - error processing for the queue */ | |
| 746 | 746 | sk = NULL; |
| 747 | 747 | if (err_hook) |
| 748 | 748 | (*err_hook)(skb); |
| 749 | − if (!skb_hook) | |
| 750 | − goto out; | |
| 751 | − /* keep processing with the skb_hook */ | |
| 749 | + if (rc == -EAGAIN) | |
| 750 | + rc = 0; | |
| 751 | + /* continue to drain the queue */ | |
| 752 | 752 | continue; |
| 753 | 753 | } else |
| 754 | − /* no - requeue to preserve ordering */ | |
| 755 | − skb_queue_head(queue, skb); | |
| 754 | + goto retry; | |
| 756 | 755 | } else { |
| 757 | − /* it worked - drop the extra reference and continue */ | |
| 756 | + /* skb sent - drop the extra reference and continue */ | |
| 758 | 757 | consume_skb(skb); |
| 759 | 758 | failed = 0; |
| 760 | 759 | } |
| 761 | 760 | } |
| 762 | 761 | |
| 763 | −out: | |
| 764 | 762 | return (rc >= 0 ? 0 : rc); |
| 765 | 763 | } |
| 766 | 764 | |
| @@ -1609,7 +1607,8 @@ static int __net_init audit_net_init(struct net *net) · 842 unmodified lines | ||
| 1609 | 1607 | audit_panic("cannot initialize netlink socket in namespace"); |
| 1610 | 1608 | return -ENOMEM; |
| 1611 | 1609 | } |
| 1612 | − aunet->sk->sk_sndtimeo = MAX_SCHEDULE_TIMEOUT; | |
| 1610 | + /* limit the timeout in case auditd is blocked/stopped */ | |
| 1611 | + aunet->sk->sk_sndtimeo = HZ / 10; | |
| 1613 | 1612 | |
| 1614 | 1613 | return 0; |
| 1615 | 1614 | } |
| @@ -1368,22 +1368,28 @@ static void __reg_bound_offset(struct bpf_reg_state *reg) · 1367 unmodified lines | ||
| 1368 | 1368 | reg->var_off = tnum_or(tnum_clear_subreg(var64_off), var32_off); |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | +static bool __reg32_bound_s64(s32 a) | |
| 1372 | +{ | |
| 1373 | + return a >= 0 && a <= S32_MAX; | |
| 1374 | +} | |
| 1375 | + | |
| 1371 | 1376 | static void __reg_assign_32_into_64(struct bpf_reg_state *reg) |
| 1372 | 1377 | { |
| 1373 | 1378 | reg->umin_value = reg->u32_min_value; |
| 1374 | 1379 | reg->umax_value = reg->u32_max_value; |
| 1375 | − /* Attempt to pull 32-bit signed bounds into 64-bit bounds | |
| 1376 | − * but must be positive otherwise set to worse case bounds | |
| 1377 | − * and refine later from tnum. | |
| 1380 | + | |
| 1381 | + /* Attempt to pull 32-bit signed bounds into 64-bit bounds but must | |
| 1382 | + * be positive otherwise set to worse case bounds and refine later | |
| 1383 | + * from tnum. | |
| 1378 | 1384 | */ |
| 1379 | − if (reg->s32_min_value >= 0 && reg->s32_max_value >= 0) | |
| 1380 | − reg->smax_value = reg->s32_max_value; | |
| 1381 | − else | |
| 1382 | − reg->smax_value = U32_MAX; | |
| 1383 | − if (reg->s32_min_value >= 0) | |
| 1385 | + if (__reg32_bound_s64(reg->s32_min_value) && | |
| 1386 | + __reg32_bound_s64(reg->s32_max_value)) { | |
| 1384 | 1387 | reg->smin_value = reg->s32_min_value; |
| 1385 | − else | |
| 1388 | + reg->smax_value = reg->s32_max_value; | |
| 1389 | + } else { | |
| 1386 | 1390 | reg->smin_value = 0; |
| 1391 | + reg->smax_value = U32_MAX; | |
| 1392 | + } | |
| 1387 | 1393 | } |
| 1388 | 1394 | |
| 1389 | 1395 | static void __reg_combine_32_into_64(struct bpf_reg_state *reg) |
| @@ -2381,8 +2387,6 @@ static int backtrack_insn(struct bpf_verifier_env *env, int idx, · 991 unmodified lines | ||
| 2381 | 2387 | */ |
| 2382 | 2388 | if (insn->src_reg != BPF_REG_FP) |
| 2383 | 2389 | return 0; |
| 2384 | − if (BPF_SIZE(insn->code) != BPF_DW) | |
| 2385 | − return 0; | |
| 2386 | 2390 | |
| 2387 | 2391 | /* dreg = *(u64 *)[fp - off] was a fill from the stack. |
| 2388 | 2392 | * that [fp - off] slot contains scalar that needs to be |
| @@ -2405,8 +2409,6 @@ static int backtrack_insn(struct bpf_verifier_env *env, int idx, · 16 unmodified lines | ||
| 2405 | 2409 | /* scalars can only be spilled into stack */ |
| 2406 | 2410 | if (insn->dst_reg != BPF_REG_FP) |
| 2407 | 2411 | return 0; |
| 2408 | − if (BPF_SIZE(insn->code) != BPF_DW) | |
| 2409 | − return 0; | |
| 2410 | 2412 | spi = (-insn->off - 1) / BPF_REG_SIZE; |
| 2411 | 2413 | if (spi >= 64) { |
| 2412 | 2414 | verbose(env, "BUG spi %d\n", spi); |
| @@ -4553,9 +4555,16 @@ static int check_atomic(struct bpf_verifier_env *env, int insn_idx, struct bpf_i · 2140 unmodified lines | ||
| 4553 | 4555 | |
| 4554 | 4556 | if (insn->imm == BPF_CMPXCHG) { |
| 4555 | 4557 | /* Check comparison of R0 with memory location */ |
| 4556 | − err = check_reg_arg(env, BPF_REG_0, SRC_OP); | |
| 4558 | + const u32 aux_reg = BPF_REG_0; | |
| 4559 | + | |
| 4560 | + err = check_reg_arg(env, aux_reg, SRC_OP); | |
| 4557 | 4561 | if (err) |
| 4558 | 4562 | return err; |
| 4563 | + | |
| 4564 | + if (is_pointer_value(env, aux_reg)) { | |
| 4565 | + verbose(env, "R%d leaks addr into mem\n", aux_reg); | |
| 4566 | + return -EACCES; | |
| 4567 | + } | |
| 4559 | 4568 | } |
| 4560 | 4569 | |
| 4561 | 4570 | if (is_pointer_value(env, insn->src_reg)) { |
| @@ -4590,13 +4599,19 @@ static int check_atomic(struct bpf_verifier_env *env, int insn_idx, struct bpf_i · 28 unmodified lines | ||
| 4590 | 4599 | load_reg = -1; |
| 4591 | 4600 | } |
| 4592 | 4601 | |
| 4593 | − /* check whether we can read the memory */ | |
| 4602 | + /* Check whether we can read the memory, with second call for fetch | |
| 4603 | + * case to simulate the register fill. | |
| 4604 | + */ | |
| 4594 | 4605 | err = check_mem_access(env, insn_idx, insn->dst_reg, insn->off, |
| 4595 | − BPF_SIZE(insn->code), BPF_READ, load_reg, true); | |
| 4606 | + BPF_SIZE(insn->code), BPF_READ, -1, true); | |
| 4607 | + if (!err && load_reg >= 0) | |
| 4608 | + err = check_mem_access(env, insn_idx, insn->dst_reg, insn->off, | |
| 4609 | + BPF_SIZE(insn->code), BPF_READ, load_reg, | |
| 4610 | + true); | |
| 4596 | 4611 | if (err) |
| 4597 | 4612 | return err; |
| 4598 | 4613 | |
| 4599 | − /* check whether we can write into the same memory */ | |
| 4614 | + /* Check whether we can write into the same memory. */ | |
| 4600 | 4615 | err = check_mem_access(env, insn_idx, insn->dst_reg, insn->off, |
| 4601 | 4616 | BPF_SIZE(insn->code), BPF_WRITE, -1, true); |
| 4602 | 4617 | if (err) |
| @@ -8364,6 +8379,10 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn) · 3761 unmodified lines | ||
| 8364 | 8379 | insn->dst_reg); |
| 8365 | 8380 | } |
| 8366 | 8381 | zext_32_to_64(dst_reg); |
| 8382 | + | |
| 8383 | + __update_reg_bounds(dst_reg); | |
| 8384 | + __reg_deduce_bounds(dst_reg); | |
| 8385 | + __reg_bound_offset(dst_reg); | |
| 8367 | 8386 | } |
| 8368 | 8387 | } else { |
| 8369 | 8388 | /* case: R = imm |
| @@ -238,6 +238,13 @@ void __wake_up_sync(struct wait_queue_head *wq_head, unsigned int mode) · 237 unmodified lines | ||
| 238 | 238 | } |
| 239 | 239 | EXPORT_SYMBOL_GPL(__wake_up_sync); /* For internal use only */ |
| 240 | 240 | |
| 241 | +void __wake_up_pollfree(struct wait_queue_head *wq_head) | |
| 242 | +{ | |
| 243 | + __wake_up(wq_head, TASK_NORMAL, 0, poll_to_key(EPOLLHUP | POLLFREE)); | |
| 244 | + /* POLLFREE must have cleared the queue. */ | |
| 245 | + WARN_ON_ONCE(waitqueue_active(wq_head)); | |
| 246 | +} | |
| 247 | + | |
| 241 | 248 | /* |
| 242 | 249 | * Note: we use "set_current_state()" _after_ the wait-queue add, |
| 243 | 250 | * because we need a memory barrier there on SMP, so that any |
| @@ -2054,26 +2054,28 @@ unsigned long msleep_interruptible(unsigned int msecs) · 2053 unmodified lines | ||
| 2054 | 2054 | EXPORT_SYMBOL(msleep_interruptible); |
| 2055 | 2055 | |
| 2056 | 2056 | /** |
| 2057 | − * usleep_range - Sleep for an approximate time | |
| 2058 | − * @min: Minimum time in usecs to sleep | |
| 2059 | − * @max: Maximum time in usecs to sleep | |
| 2057 | + * usleep_range_state - Sleep for an approximate time in a given state | |
| 2058 | + * @min: Minimum time in usecs to sleep | |
| 2059 | + * @max: Maximum time in usecs to sleep | |
| 2060 | + * @state: State of the current task that will be while sleeping | |
| 2060 | 2061 | * |
| 2061 | 2062 | * In non-atomic context where the exact wakeup time is flexible, use |
| 2062 | − * usleep_range() instead of udelay(). The sleep improves responsiveness | |
| 2063 | + * usleep_range_state() instead of udelay(). The sleep improves responsiveness | |
| 2063 | 2064 | * by avoiding the CPU-hogging busy-wait of udelay(), and the range reduces |
| 2064 | 2065 | * power usage by allowing hrtimers to take advantage of an already- |
| 2065 | 2066 | * scheduled interrupt instead of scheduling a new one just for this sleep. |
| 2066 | 2067 | */ |
| 2067 | −void __sched usleep_range(unsigned long min, unsigned long max) | |
| 2068 | +void __sched usleep_range_state(unsigned long min, unsigned long max, | |
| 2069 | + unsigned int state) | |
| 2068 | 2070 | { |
| 2069 | 2071 | ktime_t exp = ktime_add_us(ktime_get(), min); |
| 2070 | 2072 | u64 delta = (u64)(max - min) * NSEC_PER_USEC; |
| 2071 | 2073 | |
| 2072 | 2074 | for (;;) { |
| 2073 | − __set_current_state(TASK_UNINTERRUPTIBLE); | |
| 2075 | + __set_current_state(state); | |
| 2074 | 2076 | /* Do not return before the requested sleep time has elapsed */ |
| 2075 | 2077 | if (!schedule_hrtimeout_range(&exp, delta, HRTIMER_MODE_ABS)) |
| 2076 | 2078 | break; |
| 2077 | 2079 | } |
| 2078 | 2080 | } |
| 2079 | −EXPORT_SYMBOL(usleep_range); | |
| 2081 | +EXPORT_SYMBOL(usleep_range_state); | |
| @@ -5217,6 +5217,7 @@ int unregister_ftrace_direct(unsigned long ip, unsigned long addr) · 5216 unmodified lines | ||
| 5217 | 5217 | { |
| 5218 | 5218 | struct ftrace_direct_func *direct; |
| 5219 | 5219 | struct ftrace_func_entry *entry; |
| 5220 | + struct ftrace_hash *hash; | |
| 5220 | 5221 | int ret = -ENODEV; |
| 5221 | 5222 | |
| 5222 | 5223 | mutex_lock(&direct_mutex); |
| @@ -5225,7 +5226,8 @@ int unregister_ftrace_direct(unsigned long ip, unsigned long addr) · 2 unmodified lines | ||
| 5225 | 5226 | if (!entry) |
| 5226 | 5227 | goto out_unlock; |
| 5227 | 5228 | |
| 5228 | − if (direct_functions->count == 1) | |
| 5229 | + hash = direct_ops.func_hash->filter_hash; | |
| 5230 | + if (hash->count == 1) | |
| 5229 | 5231 | unregister_ftrace_function(&direct_ops); |
| 5230 | 5232 | |
| 5231 | 5233 | ret = ftrace_set_filter_ip(&direct_ops, ip, 1, 0); |
| @@ -5540,6 +5542,10 @@ int unregister_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr) · 308 unmodified lines | ||
| 5540 | 5542 | err = unregister_ftrace_function(ops); |
| 5541 | 5543 | remove_direct_functions_hash(hash, addr); |
| 5542 | 5544 | mutex_unlock(&direct_mutex); |
| 5545 | + | |
| 5546 | + /* cleanup for possible another register call */ | |
| 5547 | + ops->func = NULL; | |
| 5548 | + ops->trampoline = 0; | |
| 5543 | 5549 | return err; |
| 5544 | 5550 | } |
| 5545 | 5551 | EXPORT_SYMBOL_GPL(unregister_ftrace_direct_multi); |
| @@ -1237,9 +1237,8 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 1236 unmodified lines | ||
| 1237 | 1237 | argv + consumed, &consumed, |
| 1238 | 1238 | &field_version); |
| 1239 | 1239 | if (IS_ERR(field)) { |
| 1240 | − argv_free(argv); | |
| 1241 | 1240 | ret = PTR_ERR(field); |
| 1242 | − goto err; | |
| 1241 | + goto err_free_arg; | |
| 1243 | 1242 | } |
| 1244 | 1243 | |
| 1245 | 1244 | /* |
| @@ -1262,18 +1261,19 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 16 unmodified lines | ||
| 1262 | 1261 | if (cmd_version > 1 && n_fields_this_loop >= 1) { |
| 1263 | 1262 | synth_err(SYNTH_ERR_INVALID_CMD, errpos(field_str)); |
| 1264 | 1263 | ret = -EINVAL; |
| 1265 | − goto err; | |
| 1264 | + goto err_free_arg; | |
| 1266 | 1265 | } |
| 1267 | 1266 | |
| 1268 | 1267 | fields[n_fields++] = field; |
| 1269 | 1268 | if (n_fields == SYNTH_FIELDS_MAX) { |
| 1270 | 1269 | synth_err(SYNTH_ERR_TOO_MANY_FIELDS, 0); |
| 1271 | 1270 | ret = -EINVAL; |
| 1272 | − goto err; | |
| 1271 | + goto err_free_arg; | |
| 1273 | 1272 | } |
| 1274 | 1273 | |
| 1275 | 1274 | n_fields_this_loop++; |
| 1276 | 1275 | } |
| 1276 | + argv_free(argv); | |
| 1277 | 1277 | |
| 1278 | 1278 | if (consumed < argc) { |
| 1279 | 1279 | synth_err(SYNTH_ERR_INVALID_CMD, 0); |
| @@ -1281,7 +1281,6 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 1 unmodified line | ||
| 1281 | 1281 | goto err; |
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | − argv_free(argv); | |
| 1285 | 1284 | } |
| 1286 | 1285 | |
| 1287 | 1286 | if (n_fields == 0) { |
| @@ -1307,6 +1306,8 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 19 unmodified lines | ||
| 1307 | 1306 | kfree(saved_fields); |
| 1308 | 1307 | |
| 1309 | 1308 | return ret; |
| 1309 | + err_free_arg: | |
| 1310 | + argv_free(argv); | |
| 1310 | 1311 | err: |
| 1311 | 1312 | for (i = 0; i < n_fields; i++) |
| 1312 | 1313 | free_synth_field(fields[i]); |