Linux 7.3.1
Greg Kroah-Hartman
maintainerMakefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 7 PATCHLEVEL = 3 -SUBLEVEL = 0 +SUBLEVEL = 1 EXTRAVERSION = NAME = Baby Opossum Posse
crypto/asymmetric_keys/restrict.c +6 -2
@@ -243,10 +243,14 @@ static int key_or_keyring_common(struct key *dest_keyring,if (IS_ERR (key)) key =NULL ; }else if (trusted->type == &key_type_asymmetric) { +const struct asymmetric_key_ids *kids;const struct asymmetric_key_id **signer_ids; - signer_ids = (const struct asymmetric_key_id **) -asymmetric_key_ids (trusted)->id; + kids =asymmetric_key_ids (trusted); +if (!kids) +return -ENOKEY ; + + signer_ids = (const struct asymmetric_key_id **)kids->id;/* * The auth_ids come from the candidate key (the
fs/coredump.c +10 -8
@@ -508,7 +508,9 @@ static int zap_threads(struct task_struct *tsk,int nr = -EAGAIN ;spin_lock_irq (&tsk->sighand->siglock); -if (!(signal->flags &SIGNAL_GROUP_EXIT ) && !signal->group_exec_task) { +/* A freeze requested before the dump would be lost with TIF_SIGPENDING. */ +if (!(signal->flags &SIGNAL_GROUP_EXIT ) && !signal->group_exec_task && + !freezing (tsk) && !(tsk->jobctl &JOBCTL_TRAP_FREEZE )) {/* Allow SIGKILL, see prepare_signal() */ signal->core_state = core_state; nr =zap_process (signal, exit_code);
@@ -562,6 +564,8 @@ static void coredump_finish(bool core_dumped) current->signal->core_state =NULL ;spin_unlock_irq (¤t->sighand->siglock); +/* A released thread may exit and be freed before it is woken. */ +guard (rcu)();while ((curr = next) !=NULL ) { next = curr->next; task = curr->task;
@@ -570,6 +574,7 @@ static void coredump_finish(bool core_dumped)* ->task == NULL before we read ->next. */ smp_mb (); +/* Any wakeup now lets the thread exit, rcu keeps it alive. */ curr->task =NULL ;wake_up_process (task); }
@@ -577,13 +582,8 @@ static void coredump_finish(bool core_dumped)static bool dump_interrupted (void ) { -/* -* SIGKILL or freezing() interrupt the coredumping. Perhaps we -* can do try_to_freeze() and check __fatal_signal_pending(), -* but then we need to teach dump_write() to restart and clear -* TIF_SIGPENDING. -*/ -return fatal_signal_pending (current) ||freezing (current); +/* Only SIGKILL and the freezers set it after zap_threads(). */ +return task_sigpending (current); }static void wait_for_dump_helpers (struct file *file)
@@ -1191,6 +1191,8 @@ void vfs_coredump(const kernel_siginfo_t *siginfo)if (coredump_wait (siginfo->si_signo, &core_state) <0 )return ; +/* Task work must not cut the dump short, see signal_pending(). */ +guard (no_notify_signal)(); scoped_with_creds(cred) do_coredump(&cn, &cprm, &argv, &argc, binfmt);coredump_cleanup (&cn, &cprm);
include/linux/io_uring_types.h +2 -0
@@ -521,6 +521,8 @@ struct io_ring_ctx {struct callback_head poll_wq_task_work;struct list_head defer_list;unsigned nr_drained; +/* drain request dispatched from ->defer_list, until it completes */ +struct io_kiocb *drain_req;/* protected by ->completion_lock */ unsigned nr_req_allocated;
include/linux/key-type.h +1 -0
@@ -161,6 +161,7 @@ struct key_type { const void *in, const void *in2);/* internal fields */ +atomic64_t index_id;/* Opaque keyring index ID */ struct list_head link;/* link in types list */ struct lock_class_key lock_class;/* key->sem lock class */ } __randomize_layout;
include/linux/key.h +5 -0
@@ -107,6 +107,7 @@ struct keyring_name;struct key_tag {struct rcu_head rcu; +atomic64_t index_id;/* Opaque keyring index ID */ refcount_t usage;bool removed;/* T when subject removed */ };
@@ -129,6 +130,8 @@ struct keyring_index_key {struct key_type *type;struct key_tag *domain_tag;/* Domain of operation */ const char *description; +u64 type_id;/* Cached index IDs */ +u64 domain_id; };union key_payload {
@@ -251,6 +254,8 @@ struct key {struct key_type *type;/* type of key */ struct key_tag *domain_tag;/* Domain of operation */ char *description; +u64 type_id; +u64 domain_id; }; };
include/linux/sched.h +1 -1
@@ -1817,7 +1817,7 @@ extern struct pid __rcu *cad_pid;* I am cleaning dirty pages from some other bdi. */ #define PF_KTHREAD 0x00200000/* I am a kernel thread */ #define PF_RANDOMIZE 0x00400000/* Randomize virtual address space */ -#define PF__HOLE__00800000 0x00800000 +#define PF_NO_NOTIFY_SIGNAL 0x00800000/* see no_notify_signal_save() */ #define PF__HOLE__01000000 0x01000000#define PF__HOLE__02000000 0x02000000#define PF_NO_SETAFFINITY 0x04000000/* Userland is not allowed to meddle with cpus_mask */
include/linux/sched/signal.h +25 -2
@@ -2,6 +2,7 @@#ifndef _LINUX_SCHED_SIGNAL_H#define _LINUX_SCHED_SIGNAL_H +#include <linux/cleanup.h> #include <linux/rculist.h> #include <linux/signal.h> #include <linux/sched.h>
@@ -384,14 +385,36 @@ static inline int task_sigpending(struct task_struct *p)return unlikely (test_tsk_thread_flag (p,TIF_SIGPENDING )); } +/* Prevent TIF_NOTIFY_SIGNAL from interrupting this task. */ +static inline unsigned int no_notify_signal_save (void ) +{ +unsigned int flags = current->flags; + + current->flags |=PF_NO_NOTIFY_SIGNAL ; +return flags; +} + +/* Restore the previous PF_NO_NOTIFY_SIGNAL state. */ +static inline void no_notify_signal_restore (unsigned int flags) +{ +current_restore_flags (flags,PF_NO_NOTIFY_SIGNAL ); +} + +DEFINE_LOCK_GUARD_0 (no_notify_signal, + _T->flags =no_notify_signal_save (), +no_notify_signal_restore (_T->flags), + unsigned int flags) +static inline int signal_pending (struct task_struct *p) {/* * TIF_NOTIFY_SIGNAL isn't really a signal, but it requires the same * behavior in terms of ensuring that we break out of wait loops -* so that notify signal callbacks can be processed. +* so that notify signal callbacks can be processed. Not for a task +* that asked not to be interrupted by it, see no_notify_signal_save(). */ -if (unlikely (test_tsk_thread_flag (p,TIF_NOTIFY_SIGNAL ))) +if (unlikely (test_tsk_thread_flag (p,TIF_NOTIFY_SIGNAL )) && +likely (!(READ_ONCE (p->flags) &PF_NO_NOTIFY_SIGNAL )))return 1 ;return task_sigpending (p); }
io_uring/io-wq.c +2 -0
@@ -1324,6 +1324,8 @@ static bool io_task_work_match(struct callback_head *cb, void *data)void io_wq_exit_start (struct io_wq *wq) {set_bit (IO_WQ_BIT_EXIT , &wq->state); +/* Pairs with task_work_add() in io_queue_worker_create(). */ +smp_mb__after_atomic (); }static void io_wq_cancel_tw_create (struct io_wq *wq)
io_uring/io_uring.c +39 -3
84 lines not on this page · raw message
io_uring/net.c +2 -0
@@ -1178,6 +1178,8 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg *sel =io_buffer_select (req, &len, sr->buf_group, issue_flags);if (!sel->addr)return -ENOBUFS ; +/* ring provided buffers can be up to 4G, keep len an int */ + len =min_t (size_t, len,MAX_RW_COUNT ); sr->buf = sel->addr; sr->len = len; map_ubuf:
io_uring/poll.c +13 -4
@@ -241,12 +241,14 @@ static inline void io_poll_execute(struct io_kiocb *req, int res,*/ static int io_poll_check_events (struct io_kiocb *req,io_tw_token_t tw) { +bool again;int v;if (unlikely (tw.cancel))return -ECANCELED ; do { + again = false; v = atomic_read(&req->poll_refs); if (unlikely(v != 1)) {
@@ -310,9 +312,15 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw) }else {int ret; -/* multiple refs and HUP, ensure we loop once more */ -if ((req->cqe.res & (POLLHUP |POLLRDHUP )) && v !=1 ) - v--; +/* +* Multiple refs and HUP, ensure we loop once more. Drop +* down to one ref now, so the next pass ends unless a +* wake up came in. +*/ +if ((req->cqe.res & (POLLHUP |POLLRDHUP )) && v !=1 ) { +atomic_sub (v -1 , &req->poll_refs); + again = true; + } ret =io_poll_issue (req, tw);if (ret ==IOU_COMPLETE )
@@ -330,7 +338,8 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)* Release all references, retry if someone tried to restart * task_work while we were executing it. */ - }while (atomic_sub_return (v, &req->poll_refs) &IO_POLL_REF_MASK ); + v &=IO_POLL_REF_MASK ; + }while (again ||atomic_cmpxchg (&req->poll_refs, v,0 ) != v);io_napi_add (req);return IOU_POLL_NO_ACTION ;
io_uring/wait.c +13 -3
@@ -3,6 +3,7 @@* Waiting for completion events */ #include <linux/kernel.h> +#include <linux/sched/rt.h> #include <linux/sched/signal.h> #include <linux/io_uring.h> #include <linux/time_namespace.h>
@@ -112,23 +113,32 @@ static enum hrtimer_restart io_cqring_min_timer_wakeup(struct hrtimer *timer)return io_cqring_timer_wakeup (timer); } +/* Same policy as for hrtimer sleepers, see __hrtimer_setup_sleeper(). */ +static enum hrtimer_mode io_cqring_timer_mode (void ) +{ +if (IS_ENABLED (CONFIG_PREEMPT_RT ) &&rt_or_dl_task_policy (current)) +return HRTIMER_MODE_ABS_HARD ; +return HRTIMER_MODE_ABS ; +} +static int io_cqring_schedule_timeout (struct io_wait_queue *iowq,clockid_t clock_id,ktime_t start_time) { +enum hrtimer_mode mode =io_cqring_timer_mode ();ktime_t timeout;if (iowq->min_timeout) { timeout =ktime_add_ns (iowq->min_timeout, start_time);hrtimer_setup_on_stack (&iowq->t, io_cqring_min_timer_wakeup, clock_id, -HRTIMER_MODE_ABS ); + mode); }else { timeout = iowq->timeout;hrtimer_setup_on_stack (&iowq->t, io_cqring_timer_wakeup, clock_id, -HRTIMER_MODE_ABS ); + mode); }hrtimer_set_expires_range_ns (&iowq->t, timeout,0 ); -hrtimer_start_expires (&iowq->t,HRTIMER_MODE_ABS ); +hrtimer_start_expires (&iowq->t, mode);if (!READ_ONCE (iowq->hit_timeout))schedule ();
io_uring/waitid.c +5 -2
@@ -154,9 +154,12 @@ static bool __io_waitid_cancel(struct io_kiocb *req, bool copy_si)/* * Mark us canceled regardless of ownership. This will prevent a -* potential retry from a spurious wakeup. +* potential retry from a spurious wakeup. Only the first cancel +* attempt should take a reference for the ownership handoff. */ -atomic_or (IO_WAITID_CANCEL_FLAG , &iw->refs); +if (atomic_fetch_or (IO_WAITID_CANCEL_FLAG , &iw->refs) & +IO_WAITID_CANCEL_FLAG ) +return false;/* claim ownership */ if (atomic_fetch_inc (&iw->refs) &IO_WAITID_REF_MASK )
kernel/exit.c +3 -2
@@ -978,10 +978,11 @@ void __noreturn do_exit(long code)exit_sem (tsk);exit_shm (tsk); -exit_files (tsk); -exit_fs (tsk); +/* Hang the tty up before the last close of it can clear the session. */ if (group_dead)disassociate_ctty (1 ); +exit_files (tsk); +exit_fs (tsk);exit_nsproxy_namespaces (tsk);exit_task_work (tsk);exit_thread (tsk);
kernel/fork.c +6 -3
@@ -1685,6 +1685,7 @@ static int copy_files(u64 clone_flags, struct task_struct *tsk,if (clone_flags &CLONE_FILES ) {atomic_inc (&oldf->count); + tsk->files = oldf;return 0 ; }
@@ -2208,6 +2209,8 @@ __latent_entropy struct task_struct *copy_process(INIT_LIST_HEAD (&p->sibling);rcu_copy_process (p); p->vfork_done =NULL ; +/* Set by copy_files(), exit_files() on the error path skips NULL. */ + p->files =NULL ;spin_lock_init (&p->alloc_lock);init_sigpending (&p->pending);
@@ -2311,7 +2314,7 @@ __latent_entropy struct task_struct *copy_process( (args->umh ?COPY_FS_UMH :0 ) | (args->idle ? COPY_FS_IDLE : 0));if (retval) - goto bad_fork_cleanup_files; + goto bad_fork_cleanup_semundo; retval =copy_sighand (clone_flags, p);if (retval) goto bad_fork_cleanup_fs;
@@ -2625,8 +2628,6 @@ __latent_entropy struct task_struct *copy_process(__cleanup_sighand (p->sighand); bad_fork_cleanup_fs:exit_fs (p);/* blocking */ -bad_fork_cleanup_files: -exit_files (p);/* blocking */ bad_fork_cleanup_semundo:exit_sem (p); bad_fork_cleanup_security:
@@ -2637,6 +2638,8 @@ __latent_entropy struct task_struct *copy_process(perf_event_free_task (p); bad_fork_sched_cancel_fork:sched_cancel_fork (p); +/* ->release() of a file may need scx_fork_rwsem for write. */ +exit_files (p);/* blocking */ bad_fork_cleanup_policy:lockdep_free_task (p);#ifdef CONFIG_NUMA
kernel/irq/proc.c +17 -7
@@ -462,7 +462,7 @@ int __weak arch_show_interrupts(struct seq_file *p, int prec)static DEFINE_RAW_SPINLOCK (irq_proc_constraints_lock);static struct irq_proc_constraints { -bool print_header; +loff_t first_pos;unsigned int num_prec;unsigned int chip_width; } irq_proc_constraints__read_mostly = {
@@ -543,14 +543,13 @@ static int irq_seq_show(struct seq_file *p, void *v)struct irqaction *action;/* Print header for the first interrupt? */ -if (constr->print_header) { +if (p->index == constr->first_pos) {unsigned int cpu;seq_printf (p,"%*s" , constr->num_prec +8 ,"" );for_each_online_cpu (cpu)seq_printf (p,"CPU%-8d" , cpu);seq_putc (p,'\n' ); - constr->print_header = false; }if (desc ==ARCH_PROC_IRQDESC )
@@ -635,14 +634,25 @@ static void *irq_seq_next_desc(loff_t *pos)static void *irq_seq_start (struct seq_file *f,loff_t *pos) { -if (!*pos) { -struct irq_proc_constraints *constr = f->private; +struct irq_proc_constraints *constr = f->private; +bool first = !*pos; +void *ret; +if (first) { constr->num_prec =READ_ONCE (irq_proc_constraints.num_prec); constr->chip_width =READ_ONCE (irq_proc_constraints.chip_width); - constr->print_header = true; } -return irq_seq_next_desc (pos); + + ret =irq_seq_next_desc (pos); + +/* +* Record position of the first output record so that irq_seq_show() +* knows where to write the header. +*/ +if (first) + constr->first_pos = *pos; + +return ret; }static void *irq_seq_next (struct seq_file *f,void *v,loff_t *pos)
kernel/pid_namespace.c +2 -1
@@ -238,9 +238,10 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)* kernel_wait4() will also block until our children traced from the * parent namespace are detached and become EXIT_DEAD. */ +/* Task work must not busy-loop the reaper, see signal_pending(). */ +guard (no_notify_signal)();do {clear_thread_flag (TIF_SIGPENDING ); -clear_thread_flag (TIF_NOTIFY_SIGNAL ); rc =kernel_wait4 (-1 ,NULL , __WALL,NULL ); }while (rc != -ECHILD );
kernel/ptrace.c +6 -0
@@ -1227,6 +1227,12 @@ int ptrace_request(struct task_struct *child, long request,case PTRACE_SETSIGMASK : {sigset_t new_set; +/* A user worker only ever takes SIGKILL and SIGSTOP. */ +if (child->flags &PF_USER_WORKER ) { + ret = -EPERM ; +break ; + } +if (addr !=sizeof (sigset_t)) { ret = -EINVAL ;break ;
kernel/signal.c +4 -0
@@ -3170,6 +3170,10 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)sigset_t retarget;struct task_struct *t; +/* Nobody dequeues them in a dying group, see get_signal(). */ +if (tsk->signal->flags &SIGNAL_GROUP_EXIT ) +return ; +sigandsets (&retarget, &tsk->signal->shared_pending.signal, which);if (sigisemptyset (&retarget))return ;
kernel/trace/ftrace.c +2 -2
@@ -4426,9 +4426,9 @@ subsys_initcall(ftrace_check_for_weak_functions);static int print_rec (struct seq_file *m,unsigned long ip) { -unsigned long offset; +unsigned long offset =0 ;char str[KSYM_SYMBOL_LEN ]; -char *modname; +char *modname =NULL ;const char *ret; ret =kallsyms_lookup (ip,NULL , &offset, &modname, str);
kernel/trace/trace.c +18 -3
@@ -3614,6 +3614,7 @@ static int tracing_single_release_tr(struct inode *inode, struct file *file)return single_release (inode, file); } +static bool __update_last_data_if_empty (struct trace_array *tr);static bool update_last_data_if_empty (struct trace_array *tr);static int tracing_open (struct inode *inode,struct file *file)
@@ -4708,7 +4709,7 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,int tracer_init (struct tracer *t,struct trace_array *tr) {tracing_reset_online_cpus (&tr->array_buffer); -update_last_data_if_empty (tr); +__update_last_data_if_empty (tr);return t->init (tr); }
@@ -5387,8 +5388,10 @@ static int tracing_wait_pipe(struct file *filp)return 1 ; } -static bool update_last_data_if_empty (struct trace_array *tr) +static bool __update_last_data_if_empty (struct trace_array *tr) { +lockdep_assert_held (&trace_types_lock); +if (!(tr->flags &TRACE_ARRAY_FL_LAST_BOOT ))return false;
@@ -5403,6 +5406,16 @@ static bool update_last_data_if_empty(struct trace_array *tr)return true; } +static bool update_last_data_if_empty (struct trace_array *tr) +{ +/* Avoid the lock on the read path unless this is a last boot buffer */ +if (!(tr->flags &TRACE_ARRAY_FL_LAST_BOOT )) +return false; + +guard (mutex)(&trace_types_lock); +return __update_last_data_if_empty (tr); +} +/* * Consumer reader. */
@@ -6495,7 +6508,7 @@ int tracing_set_clock(struct trace_array *tr, const char *clockstr)ring_buffer_set_clock (tr->snapshot_buffer.buffer, trace_clocks[i].func);tracing_reset_online_cpus (&tr->snapshot_buffer);#endif -update_last_data_if_empty (tr); +__update_last_data_if_empty (tr);if (tr->scratch && !(tr->flags &TRACE_ARRAY_FL_LAST_BOOT )) {struct trace_scratch *tscratch = tr->scratch;
@@ -9263,6 +9276,8 @@ static void trace_module_record(struct module *mod, bool add)struct trace_array *tr;unsigned long flags; +guard (mutex)(&trace_types_lock); +list_for_each_entry (tr, &ftrace_trace_arrays, list) { flags = tr->flags & (TRACE_ARRAY_FL_BOOT |TRACE_ARRAY_FL_LAST_BOOT );/* Update any persistent trace array that has already been started */
kernel/trace/trace_events_filter.c +6 -0
@@ -595,6 +595,12 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, top--;/* #12 */ } } +/* Only the inner loop can complete a non-empty expression. */ +if (N ) { + ret = -EINVAL ; +parse_error (pe,FILT_ERR_INVALID_FILTER , ptr - str); + goto out_free; + } out:if (top != op_stack) {/* Too many '(' */
kernel/trace/trace_events_hist.c +17 -19
@@ -466,7 +466,7 @@ static u64 hist_field_unary_minus(struct hist_field *hist_field, { \type *addr = (type *)(event + hist_field->field->offset); \ \ -return (u64 )(unsigned long )*addr; \ +return (u64)*addr; \ }DEFINE_HIST_FIELD_FN (s64);
@@ -549,7 +549,7 @@ struct field_var { };struct field_var_hist { -struct hist_trigger_data *hist_data; +struct trace_event_file *file;char *cmd; };
@@ -1754,6 +1754,9 @@ static bool expr_field_str(struct hist_field *field, struct seq_buf *s)seq_buf_printf (s,".%s" , flags_str); } +if (field->buckets) +seq_buf_printf (s,"=%lu" , field->buckets); +return !seq_buf_has_overflowed (s); }
@@ -3119,8 +3122,8 @@ create_field_var_hist(struct hist_trigger_data *target_hist_data,return ERR_PTR (-ENOMEM ); } -/* Save the compatible histogram information */ - var_hist->hist_data = hist_data; +/* Needed to remove the histogram when the target goes away */ + var_hist->file = file;/* Create the new histogram with our variable */ ret = event_hist_trigger_parse(&trigger_hist_cmd, file,
@@ -3135,20 +3138,18 @@ create_field_var_hist(struct hist_trigger_data *target_hist_data,kfree (cmd); + n = target_hist_data->n_field_var_hists; + target_hist_data->field_var_hists[n] = var_hist; + target_hist_data->n_field_var_hists++; +/* If we can't find the variable, something went wrong */ event_var =find_synthetic_field_var (target_hist_data, subsys_name, event_name, field_name);if (IS_ERR_OR_NULL (event_var)) { -kfree (var_hist->cmd); -kfree (var_hist);hist_err (tr,HIST_ERR_SYNTH_VAR_NOT_FOUND ,errpos (field_name));return ERR_PTR (-EINVAL ); } - n = target_hist_data->n_field_var_hists; - target_hist_data->field_var_hists[n] = var_hist; - target_hist_data->n_field_var_hists++; -return event_var; }
@@ -6351,7 +6352,7 @@ static void unregister_field_var_hists(struct hist_trigger_data *hist_data)int ret;for (i =0 ; i < hist_data->n_field_var_hists; i++) { - file = hist_data->field_var_hists[i]->hist_data->event_file; + file = hist_data->field_var_hists[i]->file; cmd = hist_data->field_var_hists[i]->cmd; ret =event_hist_trigger_parse (&trigger_hist_cmd, file,"!hist" ,"hist" , cmd);
@@ -6801,7 +6802,6 @@ static void hist_unreg_all(struct trace_event_file *file)struct event_trigger_data *test, *n;struct hist_trigger_data *hist_data;struct synth_event *se; -const char *se_name;lockdep_assert_held (&event_mutex);
@@ -6814,8 +6814,7 @@ static void hist_unreg_all(struct trace_event_file *file)list_del_rcu (&test->list);trace_event_trigger_enable_disable (file,0 ); - se_name =trace_event_name (file->event_call); - se =find_synth_event (se_name); + se =find_synth_event_call (file->event_call);if (se) se->ref--;
@@ -6839,7 +6838,6 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,struct hist_trigger_data *hist_data;char *param, *filter, *p, *start;struct synth_event *se; -const char *se_name;bool remove;int ret =0 ;
@@ -6933,8 +6931,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, }event_trigger_unregister (cmd_ops, file, glob+1 , trigger_data); - se_name =trace_event_name (file->event_call); - se =find_synth_event (se_name); + se =find_synth_event_call (file->event_call);if (se) se->ref--; ret =0 ;
@@ -6969,8 +6966,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,if (ret) goto out_unreg; - se_name =trace_event_name (file->event_call); - se =find_synth_event (se_name); + se =find_synth_event_call (file->event_call);if (se) se->ref++; out:
@@ -6987,6 +6983,8 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,trigger_data_free (trigger_data); +unregister_field_var_hists (hist_data); +destroy_hist_data (hist_data); goto out; }
kernel/trace/trace_events_synth.c +10 -0
@@ -914,6 +914,16 @@ struct synth_event *find_synth_event(const char *name)return NULL ; } +struct synth_event *find_synth_event_call (struct trace_event_call *call) +{ +struct synth_event *se; +const char *name; + + name =trace_event_name (call); + se =find_synth_event (name); +return se && &se->call == call ? se :NULL ; +} +static struct trace_event_fields synth_event_fields_array[] = { { .type =TRACE_FUNCTION_TYPE , .define_fields = synth_event_define_fields },
kernel/trace/trace_synth.h +1 -0
@@ -37,5 +37,6 @@ struct synth_event { };extern struct synth_event *find_synth_event (const char *name); +extern struct synth_event *find_synth_event_call (struct trace_event_call *call);#endif /* __TRACE_SYNTH_H */
kernel/trace/trace_syscalls.c +1 -1
@@ -683,7 +683,7 @@ static int syscall_copy_user_array(char *buf, const char __user *ptr,for (int i =0 ; i < args->uargs; i++, buf +=SYSCALL_FAULT_ARG_SZ ) { ptr = (char __user *)args->ptr_array[i]; - ret =__copy_from_user (buf, ptr, size); + ret =copy_from_user (buf, ptr, size); args->read[i] = ret ?-1 : size; }return 0 ;
mm/damon/core.c +16 -6
@@ -1136,15 +1136,18 @@ static void damos_commit_quota_goal_union( } } -static void damos_commit_quota_goal ( +static int damos_commit_quota_goal (struct damos_quota_goal *dst,struct damos_quota_goal *src) { +if (!src->target_value) +return -EINVAL ; dst->metric = src->metric; dst->target_value = src->target_value;if (dst->metric ==DAMOS_QUOTA_USER_INPUT ) dst->current_value = src->current_value;/* keep last_psi_total as is, since it will be updated in next cycle */ damos_commit_quota_goal_union (dst, src); +return 0 ; }/**
@@ -1162,14 +1165,17 @@ static void damos_commit_quota_goal(int damos_commit_quota_goals (struct damos_quota *dst,struct damos_quota *src) {struct damos_quota_goal *dst_goal, *next, *src_goal, *new_goal; -int i =0 , j =0 ; +int i =0 , j =0 , err;damos_for_each_quota_goal_safe (dst_goal, next, dst) { src_goal =damos_nth_quota_goal (i++, src); -if (src_goal) -damos_commit_quota_goal (dst_goal, src_goal); -else +if (src_goal) { + err =damos_commit_quota_goal (dst_goal, src_goal); +if (err) +return err; + }else {damos_destroy_quota_goal (dst_goal); + } }damos_for_each_quota_goal_safe (src_goal, next, src) {if (j++ < i)
@@ -1178,7 +1184,11 @@ int damos_commit_quota_goals(struct damos_quota *dst, struct damos_quota *src) src_goal->metric, src_goal->target_value);if (!new_goal)return -ENOMEM ; -damos_commit_quota_goal (new_goal, src_goal); + err =damos_commit_quota_goal (new_goal, src_goal); +if (err) { +damos_free_quota_goal (new_goal); +return err; + }damos_add_quota_goal (dst, new_goal); }return 0 ;
net/bluetooth/l2cap_core.c +6 -1
@@ -622,6 +622,10 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)BT_DBG ("conn %p, psm 0x%2.2x, dcid 0x%4.4x" , conn,__le16_to_cpu (chan->psm), chan->dcid); +/* Caller must ensure l2cap_chan is linked to l2cap_conn only once */ +if (WARN_ON_ONCE (chan->conn ||test_bit (FLAG_DEL , &chan->flags))) +return ; + conn->disc_reason =HCI_ERROR_REMOTE_USER_TERM ; chan->conn =l2cap_conn_get (conn);
@@ -7416,7 +7420,8 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, } } -if (cid &&__l2cap_get_chan_by_dcid (conn, cid)) { +if ((cid &&__l2cap_get_chan_by_dcid (conn, cid)) || chan->conn || +test_bit (FLAG_DEL , &chan->flags)) {hci_conn_drop (hcon); err = -EBUSY ; goto chan_unlock;
net/bluetooth/l2cap_sock.c +2 -0
@@ -109,6 +109,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr_unsized *addr, ireturn -EINVAL ; } +l2cap_chan_lock (chan);lock_sock (sk);if (sk->sk_state !=BT_OPEN ) {
@@ -174,6 +175,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr_unsized *addr, i done:release_sock (sk); +l2cap_chan_unlock (chan);return err; }
security/keys/key.c +10 -3
@@ -588,11 +588,18 @@ int key_reject_and_link(struct key *key, ret = -EBUSY ;if (keyring) { -if (keyring->restrict_link) -return -EPERM ; - link_ret =__key_link_lock (keyring, &key->index_key);if (link_ret ==0 ) { +/* +* Check the restriction under the keyring semaphore. +* keyring_restrict() installs it while holding the +* semaphore, so testing it beforehand races with a +* concurrent restriction install. +*/ +if (keyring->restrict_link) { +__key_link_end (keyring, &key->index_key, edit); +return -EPERM ; + } link_ret =__key_link_begin (keyring, &key->index_key, &edit);if (link_ret <0 )__key_link_end (keyring, &key->index_key, edit);
security/keys/keyctl.c +8 -7
@@ -677,12 +677,14 @@ long keyctl_describe_key(key_serial_t keyid,/* calculate how much information we're going to return */ ret = -ENOMEM ; +down_read (&key->sem); infobuf =kasprintf (GFP_KERNEL ,"%s;%d;%d;%08x;" , key->type->name,from_kuid_munged (current_user_ns (), key->uid),from_kgid_munged (current_user_ns (), key->gid), key->perm); +up_read (&key->sem);if (!infobuf) goto error2; infolen =strlen (infobuf);
@@ -806,8 +808,12 @@ static long __keyctl_read_key(struct key *key, char *buffer, size_t buflen)down_read (&key->sem); ret =key_validate (key); -if (ret ==0 ) - ret = key->type->read (key, buffer, buflen); +if (ret ==0 ) { +if (key->type->read) + ret = key->type->read (key, buffer, buflen); +else + ret = -EOPNOTSUPP ; + }up_read (&key->sem);return ret; }
@@ -861,11 +867,6 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)/* the key is probably readable - now try to read it */ can_read_key: -if (!key->type->read) { - ret = -EOPNOTSUPP ; - goto key_put_out; - } -if (!buffer || !buflen) {/* Get the key length from the read method */ ret =__keyctl_read_key (key,NULL ,0 );
security/keys/keyring.c +81 -71
232 lines not on this page · raw message
security/keys/process_keys.c +2 -3
@@ -556,9 +556,8 @@ key_ref_t search_process_keyrings_rcu(struct keyring_search_context *ctx) ) {const struct cred *cred = ctx->cred; -if (key_validate (cred->request_key_auth) ==0 ) { - rka = ctx->cred->request_key_auth->payload.data[0 ]; - + rka =dereference_key_rcu (cred->request_key_auth); +if (rka &&key_validate (cred->request_key_auth) ==0 ) {//// was search_process_keyrings() [ie. recursive] ctx->cred = rka->cred; key_ref =search_cred_keyrings_rcu (ctx);
security/keys/trusted-keys/trusted_tpm1.c +3 -1
@@ -923,8 +923,10 @@ static int trusted_tpm_unseal(struct trusted_key_payload *p, char *datablob) ret =tpm2_unseal_trusted (chip, p, options); else ret =key_unseal (p, options); -if (ret <0 ) +if (ret <0 ) {pr_info ("key_unseal failed (%d)\n" , ret); + goto out; + }if (options->pcrlock) { ret =pcrlock (options->pcrlock);
security/keys/trusted-keys/trusted_tpm2.c +1 -1
@@ -115,7 +115,7 @@ static int tpm2_key_decode(struct trusted_key_payload *payload,if (ctx.priv_len + ctx.pub_len >MAX_BLOB_SIZE )return -EINVAL ; - blob =kmalloc (ctx.priv_len + ctx.pub_len +4 ,GFP_KERNEL ); + blob =kmalloc (ctx.priv_len + ctx.pub_len,GFP_KERNEL );if (!blob)return -ENOMEM ;
tools/dma/Makefile +2 -2
@@ -38,8 +38,8 @@ prepare: $(OUTPUT)include/linux/map_benchmark.h FORCE: DMA_MAP_BENCHMARK = dma_map_benchmark -$(DMA_MAP_BENCHMARK): prepare FORCE - $(CC) $(CFLAGS) $(DMA_MAP_BENCHMARK).c -o $(DMA_MAP_BENCHMARK) +$(OUTPUT)$(DMA_MAP_BENCHMARK): prepare FORCE + $(CC) $(CFLAGS) $(DMA_MAP_BENCHMARK).c -o $@ clean: rm -f $(ALL_PROGRAMS)
tools/testing/selftests/ftrace/test.d/filter/event-filter-incomplete.tc new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: event filter - reject incomplete logical expressions +# requires: events/sched/sched_switch/filter +# flags: instance + +filter=events/sched/sched_switch/filter + +for base in \ + 'common_pid == 1' \ + 'common_pid == 1 || common_pid == 2' \ + 'common_pid == 1 && common_pid == 2' \ + '!(common_pid == 1 || common_pid == 2)' +do + printf '%s' "$base" > "$filter" + for tail in '&&' '||' '&& !' '|| !' '&& !! ' '|| !! '; do + if printf '%s' "$base $tail" > "$filter" 2>/dev/null; then + echo "Accepted incomplete filter: $base $tail" + exit_fail + fi + done +done + +echo 0 > "$filter"
Greg Kroah-Hartman
maintainerI'm announcing the release of the 7.3.1 kernel.
All users of the 7.3 kernel series must upgrade.
The updated 7.3.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-7.3.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary
thanks,
greg k-h
------------
Makefile | 2 crypto/asymmetric_keys/restrict.c | 8 fs/coredump.c | 18 - include/linux/io_uring_types.h | 2 include/linux/key-type.h | 1 include/linux/key.h | 5 include/linux/sched.h | 2 include/linux/sched/signal.h | 27 + io_uring/io-wq.c | 2 io_uring/io_uring.c | 42 ++ io_uring/net.c | 2 io_uring/poll.c | 17 - io_uring/wait.c | 16 - io_uring/waitid.c | 7 kernel/exit.c | 5 kernel/fork.c | 9 kernel/irq/proc.c | 24 + kernel/pid_namespace.c | 3 kernel/ptrace.c | 6 kernel/signal.c | 4 kernel/trace/ftrace.c | 4 kernel/trace/trace.c | 21 + kernel/trace/trace_events_filter.c | 6 kernel/trace/trace_events_hist.c | 36 +- kernel/trace/trace_events_synth.c | 10 kernel/trace/trace_synth.h | 1 kernel/trace/trace_syscalls.c | 2 mm/damon/core.c | 22 + net/bluetooth/l2cap_core.c | 7 net/bluetooth/l2cap_sock.c | 2 security/keys/key.c | 13 security/keys/keyctl.c | 15 security/keys/keyring.c | 152 +++++----- security/keys/process_keys.c | 5 security/keys/trusted-keys/trusted_tpm1.c | 4 security/keys/trusted-keys/trusted_tpm2.c | 2 tools/dma/Makefile | 4 tools/testing/selftests/ftrace/test.d/filter/event-filter-incomplete.tc | 24 + 38 files changed, 373 insertions(+), 159 deletions(-)
Aaron Ahmed (1):
ftrace: Initialize modname and offset in print_rec()
Adrian Martinez (1):
KEYS: Fix key_reject_and_link() race with keyring restriction
Austin Schuh (1):
io_uring/wait: wake real-time waiters from hard interrupt context
Cen Zhang (4):
keys: Avoid the owner account dereference in named keyring lookup
keys: Check the authorization payload in process keyring searches
keys: Protect the type name while describing a key
keys: Protect the read method check against type removal
Christian Brauner (10):
coredump: hold RCU while releasing parked threads
signal: don't retarget shared signals in a dying thread group
signal: only SIGKILL and the freezers interrupt a coredumping task
io-wq: order the exit bit against worker creation task work
ptrace: refuse to change the signal mask of a user worker
fork: release the files of a failed fork after sched_cancel_fork()
exit: hang up the tty before closing the files
signal: allow taks to temporarily block TIF_NOTIFY_SIGNAL
coredump: prevent TIF_NOTIFY_SIGNAL from interrupting coredumps
pid_namespace: prevent TIF_NOTIFY_SIGNAL from interrupting the reaper
David Carlier (2):
tracing: Hold trace_types_lock when updating modules in persistent instances
tracing: Hold trace_types_lock when resetting last boot data from readers
Donggeun Yoo (4):
tracing: Save the event file instead of the compatible histogram
tracing: Unregister field variable histograms when the command fails
tracing: Add the bucket size to expr_field_str()
tracing: Fix 64-bit and signed histogram fields on 32-bit kernels
Greg Kroah-Hartman (1):
Linux 7.3.1
Haoran Wang (1):
tracing/syscalls: Use copy_from_user for the faultable syscall buffer
Haris Okanovic (1):
genirq/proc: Fix missing CPU header in /proc/interrupts
Jens Axboe (2):
io_uring: end the drain when the drain request completes io_uring/poll: don't loop on HUP with multiple references
Juanlu Herrero (1):
io_uring/poll: avoid retry wakeup loss when dropping ownership
Junyeong Lee (1):
io_uring/waitid: prevent cancel reference wrap
Kyle Zeng (2):
tracing: Reject incomplete event filter expressions
keys: make keyring indexes independent of kernel addresses
Lee Jones (1):
tracing/histograms: Verify event_call identity when updating synth_event refcount
Pauli Virtanen (1):
Bluetooth: L2CAP: refuse __l2cap_chan_add if chan already has conn
SJ Park (1):
mm/damon/core: error damos_commit_quota_goal() for zero target_value
Sasha Levin (1):
tools/dma: fix building with O=
Srish Srinivasan (1):
keys/trusted_keys: return immediately after TPM unseal failure
Stefano Garzarella (1):
KEYS: trusted: Fix blob allocation size in tpm2_key_decode()
Tamaki Yanagawa (1):
io_uring/net: keep recv buffer select length within MAX_RW_COUNT
Weiming Shi (1):
asymmetric_keys: reject trust keys without IDs