All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 4.14 02/22] tracing: Fix check for trace_percpu_buffer validity in get_trace_buf()
Date: Mon, 10 Jan 2022 08:22:55 +0100	[thread overview]
Message-ID: <20220110071814.345627921@linuxfoundation.org> (raw)
In-Reply-To: <20220110071814.261471354@linuxfoundation.org>

From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

commit 823e670f7ed616d0ce993075c8afe0217885f79d upstream.

With the new osnoise tracer, we are seeing the below splat:
    Kernel attempted to read user page (c7d880000) - exploit attempt? (uid: 0)
    BUG: Unable to handle kernel data access on read at 0xc7d880000
    Faulting instruction address: 0xc0000000002ffa10
    Oops: Kernel access of bad area, sig: 11 [#1]
    LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
    ...
    NIP [c0000000002ffa10] __trace_array_vprintk.part.0+0x70/0x2f0
    LR [c0000000002ff9fc] __trace_array_vprintk.part.0+0x5c/0x2f0
    Call Trace:
    [c0000008bdd73b80] [c0000000001c49cc] put_prev_task_fair+0x3c/0x60 (unreliable)
    [c0000008bdd73be0] [c000000000301430] trace_array_printk_buf+0x70/0x90
    [c0000008bdd73c00] [c0000000003178b0] trace_sched_switch_callback+0x250/0x290
    [c0000008bdd73c90] [c000000000e70d60] __schedule+0x410/0x710
    [c0000008bdd73d40] [c000000000e710c0] schedule+0x60/0x130
    [c0000008bdd73d70] [c000000000030614] interrupt_exit_user_prepare_main+0x264/0x270
    [c0000008bdd73de0] [c000000000030a70] syscall_exit_prepare+0x150/0x180
    [c0000008bdd73e10] [c00000000000c174] system_call_vectored_common+0xf4/0x278

osnoise tracer on ppc64le is triggering osnoise_taint() for negative
duration in get_int_safe_duration() called from
trace_sched_switch_callback()->thread_exit().

The problem though is that the check for a valid trace_percpu_buffer is
incorrect in get_trace_buf(). The check is being done after calculating
the pointer for the current cpu, rather than on the main percpu pointer.
Fix the check to be against trace_percpu_buffer.

Link: https://lkml.kernel.org/r/a920e4272e0b0635cf20c444707cbce1b2c8973d.1640255304.git.naveen.n.rao@linux.vnet.ibm.com

Cc: stable@vger.kernel.org
Fixes: e2ace001176dc9 ("tracing: Choose static tp_printk buffer by explicit nesting count")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2820,7 +2820,7 @@ static char *get_trace_buf(void)
 {
 	struct trace_buffer_struct *buffer = this_cpu_ptr(trace_percpu_buffer);
 
-	if (!buffer || buffer->nesting >= 4)
+	if (!trace_percpu_buffer || buffer->nesting >= 4)
 		return NULL;
 
 	buffer->nesting++;



  parent reply	other threads:[~2022-01-10  7:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10  7:22 [PATCH 4.14 00/22] 4.14.262-rc1 review Greg Kroah-Hartman
2022-01-10  7:22 ` [PATCH 4.14 01/22] Bluetooth: btusb: Apply QCA Rome patches for some ATH3012 models Greg Kroah-Hartman
2022-01-10  7:22 ` Greg Kroah-Hartman [this message]
2022-01-10  7:22 ` [PATCH 4.14 03/22] tracing: Tag trace_percpu_buffer as a percpu pointer Greg Kroah-Hartman
2022-01-10  7:22 ` [PATCH 4.14 04/22] virtio_pci: Support surprise removal of virtio pci device Greg Kroah-Hartman
2022-01-10  7:22 ` [PATCH 4.14 05/22] ieee802154: atusb: fix uninit value in atusb_set_extended_addr Greg Kroah-Hartman
2022-01-10  7:22 ` [PATCH 4.14 06/22] RDMA/core: Dont infoleak GRH fields Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 07/22] mac80211: initialize variable have_higher_than_11mbit Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 08/22] i40e: fix use-after-free in i40e_sync_filters_subtask() Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 09/22] i40e: Fix incorrect netdevs real number of RX/TX queues Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 10/22] ipv6: Check attribute length for RTA_GATEWAY in multipath route Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 11/22] ipv6: Check attribute length for RTA_GATEWAY when deleting " Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 12/22] sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 13/22] xfs: map unwritten blocks in XFS_IOC_{ALLOC,FREE}SP just like fallocate Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 14/22] power: reset: ltc2952: Fix use of floating point literals Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 15/22] rndis_host: support Hytera digital radios Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 16/22] phonet: refcount leak in pep_sock_accep Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 17/22] ipv6: Continue processing multipath route even if gateway attribute is invalid Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 18/22] ipv6: Do cleanup if attribute validation fails in multipath route Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 19/22] scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown() Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 20/22] ip6_vti: initialize __ip6_tnl_parm struct in vti6_siocdevprivate Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 21/22] net: udp: fix alignment problem in udp4_seq_show() Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 4.14 22/22] mISDN: change function names to avoid conflicts Greg Kroah-Hartman
2022-01-10 11:49 ` [PATCH 4.14 00/22] 4.14.262-rc1 review Jon Hunter
2022-01-10 23:49 ` Guenter Roeck
2022-01-11  6:24 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220110071814.345627921@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.