Skip to content
Snippets Groups Projects
  1. Mar 17, 2021
    • Piotr Krysiuk's avatar
      bpf: Prohibit alu ops for pointer types not defining ptr_limit · f232326f
      Piotr Krysiuk authored
      
      The purpose of this patch is to streamline error propagation and in particular
      to propagate retrieve_ptr_limit() errors for pointer types that are not defining
      a ptr_limit such that register-based alu ops against these types can be rejected.
      
      The main rationale is that a gap has been identified by Piotr in the existing
      protection against speculatively out-of-bounds loads, for example, in case of
      ctx pointers, unprivileged programs can still perform pointer arithmetic. This
      can be abused to execute speculatively out-of-bounds loads without restrictions
      and thus extract contents of kernel memory.
      
      Fix this by rejecting unprivileged programs that attempt any pointer arithmetic
      on unprotected pointer types. The two affected ones are pointer to ctx as well
      as pointer to map. Field access to a modified ctx' pointer is rejected at a
      later point in time in the verifier, and 7c696732 ("bpf: Permit map_ptr
      arithmetic with opcode add and offset 0") only relevant for root-only use cases.
      Risk of unprivileged program breakage is considered very low.
      
      Fixes: 7c696732 ("bpf: Permit map_ptr arithmetic with opcode add and offset 0")
      Fixes: b2157399 ("bpf: prevent out-of-bounds speculation")
      Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Co-developed-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f232326f
  2. Mar 16, 2021
  3. Mar 08, 2021
  4. Mar 05, 2021
  5. Mar 04, 2021
    • Jens Axboe's avatar
      kernel: provide create_io_thread() helper · cc440e87
      Jens Axboe authored
      
      Provide a generic helper for setting up an io_uring worker. Returns a
      task_struct so that the caller can do whatever setup is needed, then call
      wake_up_new_task() to kick it into gear.
      
      Add a kernel_clone_args member, io_thread, which tells copy_process() to
      mark the task with PF_IO_WORKER.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      cc440e87
    • Ilya Leoshkevich's avatar
      bpf: Account for BPF_FETCH in insn_has_def32() · 83a28819
      Ilya Leoshkevich authored
      insn_has_def32() returns false for 32-bit BPF_FETCH insns. This makes
      adjust_insn_aux_data() incorrectly set zext_dst, as can be seen in [1].
      This happens because insn_no_def() does not know about the BPF_FETCH
      variants of BPF_STX.
      
      Fix in two steps.
      
      First, replace insn_no_def() with insn_def_regno(), which returns the
      register an insn defines. Normally insn_no_def() calls are followed by
      insn->dst_reg uses; replace those with the insn_def_regno() return
      value.
      
      Second, adjust the BPF_STX special case in is_reg64() to deal with
      queries made from opt_subreg_zext_lo32_rnd_hi32(), where the state
      information is no longer available. Add a comment, since the purpose
      of this special case is not clear at first glance.
      
        [1] https://lore.kernel.org/bpf/20210223150845.1857620-1-jackmanb@google.com/
      
      
      
      Fixes: 5ffa2550 ("bpf: Add instructions for atomic_[cmp]xchg")
      Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Acked-by: default avatarBrendan Jackman <jackmanb@google.com>
      Link: https://lore.kernel.org/bpf/20210301154019.129110-1-iii@linux.ibm.com
      83a28819
    • Steven Rostedt (VMware)'s avatar
      tracing: Skip selftests if tracing is disabled · ee666a18
      Steven Rostedt (VMware) authored
      
      If tracing is disabled for some reason (traceoff_on_warning, command line,
      etc), the ftrace selftests are guaranteed to fail, as their results are
      defined by trace data in the ring buffers. If the ring buffers are turned
      off, the tests will fail, due to lack of data.
      
      Because tracing being disabled is for a specific reason (warning, user
      decided to, etc), it does not make sense to enable tracing to run the self
      tests, as the test output may corrupt the reason for the tracing to be
      disabled.
      
      Instead, simply skip the self tests and report that they are being skipped
      due to tracing being disabled.
      
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      ee666a18
    • Vamshi K Sthambamkadi's avatar
      tracing: Fix memory leak in __create_synth_event() · f40fc799
      Vamshi K Sthambamkadi authored
      kmemleak report:
      unreferenced object 0xc5a6f708 (size 8):
        comm "ftracetest", pid 1209, jiffies 4294911500 (age 6.816s)
        hex dump (first 8 bytes):
          00 c1 3d 60 14 83 1f 8a                          ..=`....
        backtrace:
          [<f0aa4ac4>] __kmalloc_track_caller+0x2a6/0x460
          [<7d3d60a6>] kstrndup+0x37/0x70
          [<45a0e739>] argv_split+0x1c/0x120
          [<c17982f8>] __create_synth_event+0x192/0xb00
          [<0708b8a3>] create_synth_event+0xbb/0x150
          [<3d1941e1>] create_dyn_event+0x5c/0xb0
          [<5cf8b9e3>] trace_parse_run_command+0xa7/0x140
          [<04deb2ef>] dyn_event_write+0x10/0x20
          [<8779ac95>] vfs_write+0xa9/0x3c0
          [<ed93722a>] ksys_write+0x89/0xc0
          [<b9ca0507>] __ia32_sys_write+0x15/0x20
          [<7ce02d85>] __do_fast_syscall_32+0x45/0x80
          [<cb0ecb35>] do_fast_syscall_32+0x29/0x60
          [<2467454a>] do_SYSENTER_32+0x15/0x20
          [<9beaa61d>] entry_SYSENTER_32+0xa9/0xfc
      unreferenced object 0xc5a6f078 (size 8):
        comm "ftracetest", pid 1209, jiffies 4294911500 (age 6.816s)
        hex dump (first 8 bytes):
          08 f7 a6 c5 00 00 00 00                          ........
        backtrace:
          [<bbac096a>] __kmalloc+0x2b6/0x470
          [<aa2624b4>] argv_split+0x82/0x120
          [<c17982f8>] __create_synth_event+0x192/0xb00
          [<0708b8a3>] create_synth_event+0xbb/0x150
          [<3d1941e1>] create_dyn_event+0x5c/0xb0
          [<5cf8b9e3>] trace_parse_run_command+0xa7/0x140
          [<04deb2ef>] dyn_event_write+0x10/0x20
          [<8779ac95>] vfs_write+0xa9/0x3c0
          [<ed93722a>] ksys_write+0x89/0xc0
          [<b9ca0507>] __ia32_sys_write+0x15/0x20
          [<7ce02d85>] __do_fast_syscall_32+0x45/0x80
          [<cb0ecb35>] do_fast_syscall_32+0x29/0x60
          [<2467454a>] do_SYSENTER_32+0x15/0x20
          [<9beaa61d>] entry_SYSENTER_32+0xa9/0xfc
      
      In __create_synth_event(), while iterating field/type arguments, the
      argv_split() will return array of atleast 2 elements even when zero
      arguments(argc=0) are passed. for e.g. when there is double delimiter
      or string ends with delimiter
      
      To fix call argv_free() even when argc=0.
      
      Link: https://lkml.kernel.org/r/20210304094521.GA1826@cosmos
      
      
      
      Signed-off-by: default avatarVamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      f40fc799
    • Steven Rostedt (VMware)'s avatar
      ring-buffer: Add a little more information and a WARN when time stamp going backwards is detected · 6549de1f
      Steven Rostedt (VMware) authored
      
      When the CONFIG_RING_BUFFER_VALIDATE_TIME_DELTAS is enabled, and the time
      stamps are detected as not being valid, it reports information about the
      write stamp, but does not show the before_stamp which is still useful
      information. Also, it should give a warning once, such that tests detect
      this happening.
      
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      6549de1f
    • Steven Rostedt (VMware)'s avatar
      ring-buffer: Force before_stamp and write_stamp to be different on discard · 6f6be606
      Steven Rostedt (VMware) authored
      
      Part of the logic of the new time stamp code depends on the before_stamp and
      the write_stamp to be different if the write_stamp does not match the last
      event on the buffer, as it will be used to calculate the delta of the next
      event written on the buffer.
      
      The discard logic depends on this, as the next event to come in needs to
      inject a full timestamp as it can not rely on the last event timestamp in
      the buffer because it is unknown due to events after it being discarded. But
      by changing the write_stamp back to the time before it, it forces the next
      event to use a full time stamp, instead of relying on it.
      
      The issue came when a full time stamp was used for the event, and
      rb_time_delta() returns zero in that case. The update to the write_stamp
      (which subtracts delta) made it not change. Then when the event is removed
      from the buffer, because the before_stamp and write_stamp still match, the
      next event written would calculate its delta from the write_stamp, but that
      would be wrong as the write_stamp is of the time of the event that was
      discarded.
      
      In the case that the delta change being made to write_stamp is zero, set the
      before_stamp to zero as well, and this will force the next event to inject a
      full timestamp and not use the current write_stamp.
      
      Cc: stable@vger.kernel.org
      Fixes: a389d86f ("ring-buffer: Have nested events still record running time stamp")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      6f6be606
    • Rolf Eike Beer's avatar
      69268094
    • Yordan Karadzhov (VMware)'s avatar
      tracing: Remove duplicate declaration from trace.h · 70d443d8
      Yordan Karadzhov (VMware) authored
      A declaration of function "int trace_empty(struct trace_iterator *iter)"
      shows up twice in the header file kernel/trace/trace.h
      
      Link: https://lkml.kernel.org/r/20210304092348.208033-1-y.karadz@gmail.com
      
      
      
      Signed-off-by: default avatarYordan Karadzhov (VMware) <y.karadz@gmail.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      70d443d8
  6. Feb 26, 2021
  7. Feb 24, 2021
  8. Feb 23, 2021
  9. Feb 22, 2021
  10. Feb 20, 2021
  11. Feb 19, 2021
Loading