]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Dec 2018 11:00:11 +0000 (12:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Dec 2018 11:00:11 +0000 (12:00 +0100)
added patches:
arm-function_graph-simplify-with-function_graph_enter.patch
arm64-function_graph-simplify-with-function_graph_enter.patch
asoc-intel-cht_bsw_max98090_ti-add-quirk-for-boards-using-pmc_plt_clk_0.patch
asoc-pcm186x-fix-device-reset-registers-trigger-value.patch
binder-fix-race-that-allows-malicious-free-of-live-buffer.patch
ext2-fix-potential-use-after-free.patch
ext2-initialize-opts.s_mount_opt-as-zero-before-using-it.patch
function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch
function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch
function_graph-make-ftrace_push_return_trace-static.patch
function_graph-move-return-callback-before-update-of-curr_ret_stack.patch
function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch
function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch
microblaze-function_graph-simplify-with-function_graph_enter.patch
mips-function_graph-simplify-with-function_graph_enter.patch
nds32-function_graph-simplify-with-function_graph_enter.patch
parisc-function_graph-simplify-with-function_graph_enter.patch
powerpc-function_graph-simplify-with-function_graph_enter.patch
riscv-function_graph-simplify-with-function_graph_enter.patch
s390-function_graph-simplify-with-function_graph_enter.patch
sh-function_graph-simplify-with-function_graph_enter.patch
sparc-function_graph-simplify-with-function_graph_enter.patch
x86-function_graph-simplify-with-function_graph_enter.patch

24 files changed:
queue-4.19/arm-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/arm64-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/asoc-intel-cht_bsw_max98090_ti-add-quirk-for-boards-using-pmc_plt_clk_0.patch [new file with mode: 0644]
queue-4.19/asoc-pcm186x-fix-device-reset-registers-trigger-value.patch [new file with mode: 0644]
queue-4.19/binder-fix-race-that-allows-malicious-free-of-live-buffer.patch [new file with mode: 0644]
queue-4.19/ext2-fix-potential-use-after-free.patch [new file with mode: 0644]
queue-4.19/ext2-initialize-opts.s_mount_opt-as-zero-before-using-it.patch [new file with mode: 0644]
queue-4.19/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch [new file with mode: 0644]
queue-4.19/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch [new file with mode: 0644]
queue-4.19/function_graph-make-ftrace_push_return_trace-static.patch [new file with mode: 0644]
queue-4.19/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch [new file with mode: 0644]
queue-4.19/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch [new file with mode: 0644]
queue-4.19/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch [new file with mode: 0644]
queue-4.19/microblaze-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/mips-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/nds32-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/parisc-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/powerpc-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/riscv-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/s390-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/sh-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/sparc-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]
queue-4.19/x86-function_graph-simplify-with-function_graph_enter.patch [new file with mode: 0644]

diff --git a/queue-4.19/arm-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/arm-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..8026e6d
--- /dev/null
@@ -0,0 +1,66 @@
+From f1f5b14afd7cce39e6a9b25c685e1ea34c231096 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:19:26 -0500
+Subject: ARM: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit f1f5b14afd7cce39e6a9b25c685e1ea34c231096 upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have ARM use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Russell King <linux@armlinux.org.uk>
+Cc: linux-arm-kernel@lists.infradead.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/kernel/ftrace.c |   17 +----------------
+ 1 file changed, 1 insertion(+), 16 deletions(-)
+
+--- a/arch/arm/kernel/ftrace.c
++++ b/arch/arm/kernel/ftrace.c
+@@ -227,9 +227,7 @@ void prepare_ftrace_return(unsigned long
+                          unsigned long frame_pointer)
+ {
+       unsigned long return_hooker = (unsigned long) &return_to_handler;
+-      struct ftrace_graph_ent trace;
+       unsigned long old;
+-      int err;
+       if (unlikely(atomic_read(&current->tracing_graph_pause)))
+               return;
+@@ -237,21 +235,8 @@ void prepare_ftrace_return(unsigned long
+       old = *parent;
+       *parent = return_hooker;
+-      trace.func = self_addr;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace)) {
++      if (function_graph_enter(old, self_addr, frame_pointer, NULL))
+               *parent = old;
+-              return;
+-      }
+-
+-      err = ftrace_push_return_trace(old, self_addr, &trace.depth,
+-                                     frame_pointer, NULL);
+-      if (err == -EBUSY) {
+-              *parent = old;
+-              return;
+-      }
+ }
+ #ifdef CONFIG_DYNAMIC_FTRACE
diff --git a/queue-4.19/arm64-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/arm64-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..6259867
--- /dev/null
@@ -0,0 +1,63 @@
+From 01e0ab2c4ff12358f15a856fd1a7bbea0670972b Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:21:51 -0500
+Subject: arm64: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 01e0ab2c4ff12358f15a856fd1a7bbea0670972b upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have arm64 use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Catalin Marinas <catalin.marinas@arm.com>
+Cc: linux-arm-kernel@lists.infradead.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Acked-by: Will Deacon <will.deacon@arm.com>
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm64/kernel/ftrace.c |   15 +--------------
+ 1 file changed, 1 insertion(+), 14 deletions(-)
+
+--- a/arch/arm64/kernel/ftrace.c
++++ b/arch/arm64/kernel/ftrace.c
+@@ -216,8 +216,6 @@ void prepare_ftrace_return(unsigned long
+ {
+       unsigned long return_hooker = (unsigned long)&return_to_handler;
+       unsigned long old;
+-      struct ftrace_graph_ent trace;
+-      int err;
+       if (unlikely(atomic_read(&current->tracing_graph_pause)))
+               return;
+@@ -229,18 +227,7 @@ void prepare_ftrace_return(unsigned long
+        */
+       old = *parent;
+-      trace.func = self_addr;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace))
+-              return;
+-
+-      err = ftrace_push_return_trace(old, self_addr, &trace.depth,
+-                                     frame_pointer, NULL);
+-      if (err == -EBUSY)
+-              return;
+-      else
++      if (!function_graph_enter(old, self_addr, frame_pointer, NULL))
+               *parent = return_hooker;
+ }
diff --git a/queue-4.19/asoc-intel-cht_bsw_max98090_ti-add-quirk-for-boards-using-pmc_plt_clk_0.patch b/queue-4.19/asoc-intel-cht_bsw_max98090_ti-add-quirk-for-boards-using-pmc_plt_clk_0.patch
new file mode 100644 (file)
index 0000000..359d7a9
--- /dev/null
@@ -0,0 +1,100 @@
+From a182ecd3809c8d5a2da80c520f3602e301c5317e Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Wed, 31 Oct 2018 15:22:25 +0100
+Subject: ASoC: intel: cht_bsw_max98090_ti: Add quirk for boards using pmc_plt_clk_0
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit a182ecd3809c8d5a2da80c520f3602e301c5317e upstream.
+
+Some boards such as the Swanky model Chromebooks use pmc_plt_clk_0 for the
+mclk instead of pmc_plt_clk_3.
+
+This commit adds a DMI based quirk for this.
+
+This fixing audio no longer working on these devices after
+commit 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
+that commit fixes us unnecessary keeping unused clocks on, but in case
+of the Swanky that was breaking audio support since we were not using
+the right clock in the cht_bsw_max98090_ti machine driver.
+
+Cc: stable@vger.kernel.org
+Fixes: 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
+Reported-and-tested-by: Dean Wallace <duffydack73@gmail.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/soc/intel/boards/cht_bsw_max98090_ti.c |   32 ++++++++++++++++++++++++---
+ 1 file changed, 29 insertions(+), 3 deletions(-)
+
+--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
++++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+@@ -19,6 +19,7 @@
+  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  */
++#include <linux/dmi.h>
+ #include <linux/module.h>
+ #include <linux/platform_device.h>
+ #include <linux/slab.h>
+@@ -35,6 +36,8 @@
+ #define CHT_PLAT_CLK_3_HZ     19200000
+ #define CHT_CODEC_DAI "HiFi"
++#define QUIRK_PMC_PLT_CLK_0                           0x01
++
+ struct cht_mc_private {
+       struct clk *mclk;
+       struct snd_soc_jack jack;
+@@ -385,11 +388,29 @@ static struct snd_soc_card snd_soc_card_
+       .num_controls = ARRAY_SIZE(cht_mc_controls),
+ };
++static const struct dmi_system_id cht_max98090_quirk_table[] = {
++      {
++              /* Swanky model Chromebook (Toshiba Chromebook 2) */
++              .matches = {
++                      DMI_MATCH(DMI_PRODUCT_NAME, "Swanky"),
++              },
++              .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
++      },
++      {}
++};
++
+ static int snd_cht_mc_probe(struct platform_device *pdev)
+ {
++      const struct dmi_system_id *dmi_id;
+       struct device *dev = &pdev->dev;
+       int ret_val = 0;
+       struct cht_mc_private *drv;
++      const char *mclk_name;
++      int quirks = 0;
++
++      dmi_id = dmi_first_match(cht_max98090_quirk_table);
++      if (dmi_id)
++              quirks = (unsigned long)dmi_id->driver_data;
+       drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
+       if (!drv)
+@@ -411,11 +432,16 @@ static int snd_cht_mc_probe(struct platf
+       snd_soc_card_cht.dev = &pdev->dev;
+       snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
+-      drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
++      if (quirks & QUIRK_PMC_PLT_CLK_0)
++              mclk_name = "pmc_plt_clk_0";
++      else
++              mclk_name = "pmc_plt_clk_3";
++
++      drv->mclk = devm_clk_get(&pdev->dev, mclk_name);
+       if (IS_ERR(drv->mclk)) {
+               dev_err(&pdev->dev,
+-                      "Failed to get MCLK from pmc_plt_clk_3: %ld\n",
+-                      PTR_ERR(drv->mclk));
++                      "Failed to get MCLK from %s: %ld\n",
++                      mclk_name, PTR_ERR(drv->mclk));
+               return PTR_ERR(drv->mclk);
+       }
diff --git a/queue-4.19/asoc-pcm186x-fix-device-reset-registers-trigger-value.patch b/queue-4.19/asoc-pcm186x-fix-device-reset-registers-trigger-value.patch
new file mode 100644 (file)
index 0000000..733f56f
--- /dev/null
@@ -0,0 +1,37 @@
+From 5277715639ff6f75c729e657690751a831112c4b Mon Sep 17 00:00:00 2001
+From: Andreas Dannenberg <dannenberg@ti.com>
+Date: Thu, 15 Nov 2018 11:01:31 -0600
+Subject: ASoC: pcm186x: Fix device reset-registers trigger value
+
+From: Andreas Dannenberg <dannenberg@ti.com>
+
+commit 5277715639ff6f75c729e657690751a831112c4b upstream.
+
+According to the current device datasheet (TI Lit # SLAS831D, revised
+March 2018) the value written to the device's PAGE register to trigger
+a complete register reset should be 0xfe, not 0xff. So go ahead and
+update to the correct value.
+
+Reported-by: Stephane Le Provost <stephane.leprovost@mediatek.com>
+Tested-by: Stephane Le Provost <stephane.leprovost@mediatek.com>
+Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
+Acked-by: Andrew F. Davis <afd@ti.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Cc: stable@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/soc/codecs/pcm186x.h |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/sound/soc/codecs/pcm186x.h
++++ b/sound/soc/codecs/pcm186x.h
+@@ -139,7 +139,7 @@ enum pcm186x_type {
+ #define PCM186X_MAX_REGISTER          PCM186X_CURR_TRIM_CTRL
+ /* PCM186X_PAGE */
+-#define PCM186X_RESET                 0xff
++#define PCM186X_RESET                 0xfe
+ /* PCM186X_ADCX_INPUT_SEL_X */
+ #define PCM186X_ADC_INPUT_SEL_POL     BIT(7)
diff --git a/queue-4.19/binder-fix-race-that-allows-malicious-free-of-live-buffer.patch b/queue-4.19/binder-fix-race-that-allows-malicious-free-of-live-buffer.patch
new file mode 100644 (file)
index 0000000..031d2de
--- /dev/null
@@ -0,0 +1,119 @@
+From 7bada55ab50697861eee6bb7d60b41e68a961a9c Mon Sep 17 00:00:00 2001
+From: Todd Kjos <tkjos@android.com>
+Date: Tue, 6 Nov 2018 15:55:32 -0800
+Subject: binder: fix race that allows malicious free of live buffer
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Todd Kjos <tkjos@android.com>
+
+commit 7bada55ab50697861eee6bb7d60b41e68a961a9c upstream.
+
+Malicious code can attempt to free buffers using the BC_FREE_BUFFER
+ioctl to binder. There are protections against a user freeing a buffer
+while in use by the kernel, however there was a window where
+BC_FREE_BUFFER could be used to free a recently allocated buffer that
+was not completely initialized. This resulted in a use-after-free
+detected by KASAN with a malicious test program.
+
+This window is closed by setting the buffer's allow_user_free attribute
+to 0 when the buffer is allocated or when the user has previously freed
+it instead of waiting for the caller to set it. The problem was that
+when the struct buffer was recycled, allow_user_free was stale and set
+to 1 allowing a free to go through.
+
+Signed-off-by: Todd Kjos <tkjos@google.com>
+Acked-by: Arve Hjønnevåg <arve@android.com>
+Cc: stable <stable@vger.kernel.org> # 4.14
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/android/binder.c       |   21 ++++++++++++---------
+ drivers/android/binder_alloc.c |   16 ++++++----------
+ drivers/android/binder_alloc.h |    3 +--
+ 3 files changed, 19 insertions(+), 21 deletions(-)
+
+--- a/drivers/android/binder.c
++++ b/drivers/android/binder.c
+@@ -2971,7 +2971,6 @@ static void binder_transaction(struct bi
+               t->buffer = NULL;
+               goto err_binder_alloc_buf_failed;
+       }
+-      t->buffer->allow_user_free = 0;
+       t->buffer->debug_id = t->debug_id;
+       t->buffer->transaction = t;
+       t->buffer->target_node = target_node;
+@@ -3465,14 +3464,18 @@ static int binder_thread_write(struct bi
+                       buffer = binder_alloc_prepare_to_free(&proc->alloc,
+                                                             data_ptr);
+-                      if (buffer == NULL) {
+-                              binder_user_error("%d:%d BC_FREE_BUFFER u%016llx no match\n",
+-                                      proc->pid, thread->pid, (u64)data_ptr);
+-                              break;
+-                      }
+-                      if (!buffer->allow_user_free) {
+-                              binder_user_error("%d:%d BC_FREE_BUFFER u%016llx matched unreturned buffer\n",
+-                                      proc->pid, thread->pid, (u64)data_ptr);
++                      if (IS_ERR_OR_NULL(buffer)) {
++                              if (PTR_ERR(buffer) == -EPERM) {
++                                      binder_user_error(
++                                              "%d:%d BC_FREE_BUFFER u%016llx matched unreturned or currently freeing buffer\n",
++                                              proc->pid, thread->pid,
++                                              (u64)data_ptr);
++                              } else {
++                                      binder_user_error(
++                                              "%d:%d BC_FREE_BUFFER u%016llx no match\n",
++                                              proc->pid, thread->pid,
++                                              (u64)data_ptr);
++                              }
+                               break;
+                       }
+                       binder_debug(BINDER_DEBUG_FREE_BUFFER,
+--- a/drivers/android/binder_alloc.c
++++ b/drivers/android/binder_alloc.c
+@@ -151,16 +151,12 @@ static struct binder_buffer *binder_allo
+               else {
+                       /*
+                        * Guard against user threads attempting to
+-                       * free the buffer twice
++                       * free the buffer when in use by kernel or
++                       * after it's already been freed.
+                        */
+-                      if (buffer->free_in_progress) {
+-                              binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+-                                                 "%d:%d FREE_BUFFER u%016llx user freed buffer twice\n",
+-                                                 alloc->pid, current->pid,
+-                                                 (u64)user_ptr);
+-                              return NULL;
+-                      }
+-                      buffer->free_in_progress = 1;
++                      if (!buffer->allow_user_free)
++                              return ERR_PTR(-EPERM);
++                      buffer->allow_user_free = 0;
+                       return buffer;
+               }
+       }
+@@ -500,7 +496,7 @@ static struct binder_buffer *binder_allo
+       rb_erase(best_fit, &alloc->free_buffers);
+       buffer->free = 0;
+-      buffer->free_in_progress = 0;
++      buffer->allow_user_free = 0;
+       binder_insert_allocated_buffer_locked(alloc, buffer);
+       binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
+                    "%d: binder_alloc_buf size %zd got %pK\n",
+--- a/drivers/android/binder_alloc.h
++++ b/drivers/android/binder_alloc.h
+@@ -50,8 +50,7 @@ struct binder_buffer {
+       unsigned free:1;
+       unsigned allow_user_free:1;
+       unsigned async_transaction:1;
+-      unsigned free_in_progress:1;
+-      unsigned debug_id:28;
++      unsigned debug_id:29;
+       struct binder_transaction *transaction;
diff --git a/queue-4.19/ext2-fix-potential-use-after-free.patch b/queue-4.19/ext2-fix-potential-use-after-free.patch
new file mode 100644 (file)
index 0000000..8dbcad4
--- /dev/null
@@ -0,0 +1,36 @@
+From ecebf55d27a11538ea84aee0be643dd953f830d5 Mon Sep 17 00:00:00 2001
+From: Pan Bian <bianpan2016@163.com>
+Date: Sun, 25 Nov 2018 08:58:02 +0800
+Subject: ext2: fix potential use after free
+
+From: Pan Bian <bianpan2016@163.com>
+
+commit ecebf55d27a11538ea84aee0be643dd953f830d5 upstream.
+
+The function ext2_xattr_set calls brelse(bh) to drop the reference count
+of bh. After that, bh may be freed. However, following brelse(bh),
+it reads bh->b_data via macro HDR(bh). This may result in a
+use-after-free bug. This patch moves brelse(bh) after reading field.
+
+CC: stable@vger.kernel.org
+Signed-off-by: Pan Bian <bianpan2016@163.com>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext2/xattr.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/ext2/xattr.c
++++ b/fs/ext2/xattr.c
+@@ -612,9 +612,9 @@ skip_replace:
+       }
+ cleanup:
+-      brelse(bh);
+       if (!(bh && header == HDR(bh)))
+               kfree(header);
++      brelse(bh);
+       up_write(&EXT2_I(inode)->xattr_sem);
+       return error;
diff --git a/queue-4.19/ext2-initialize-opts.s_mount_opt-as-zero-before-using-it.patch b/queue-4.19/ext2-initialize-opts.s_mount_opt-as-zero-before-using-it.patch
new file mode 100644 (file)
index 0000000..9824321
--- /dev/null
@@ -0,0 +1,32 @@
+From e5f5b717983bccfa033282e9886811635602510e Mon Sep 17 00:00:00 2001
+From: xingaopeng <xingaopeng@huawei.com>
+Date: Sat, 24 Nov 2018 19:21:59 +0800
+Subject: ext2: initialize opts.s_mount_opt as zero before using it
+
+From: xingaopeng <xingaopeng@huawei.com>
+
+commit e5f5b717983bccfa033282e9886811635602510e upstream.
+
+We need to initialize opts.s_mount_opt as zero before using it, else we
+may get some unexpected mount options.
+
+Fixes: 088519572ca8 ("ext2: Parse mount options into a dedicated structure")
+CC: stable@vger.kernel.org
+Signed-off-by: xingaopeng <xingaopeng@huawei.com>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext2/super.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/fs/ext2/super.c
++++ b/fs/ext2/super.c
+@@ -895,6 +895,7 @@ static int ext2_fill_super(struct super_
+       if (sb->s_magic != EXT2_SUPER_MAGIC)
+               goto cantfind_ext2;
++      opts.s_mount_opt = 0;
+       /* Set defaults before we parse the mount options */
+       def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
+       if (def_mount_opts & EXT2_DEFM_DEBUG)
diff --git a/queue-4.19/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch b/queue-4.19/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch
new file mode 100644 (file)
index 0000000..5254924
--- /dev/null
@@ -0,0 +1,70 @@
+From 8114865ff82e200b383e46821c25cb0625b842b5 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:10:15 -0500
+Subject: function_graph: Create function_graph_enter() to consolidate architecture code
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 8114865ff82e200b383e46821c25cb0625b842b5 upstream.
+
+Currently all the architectures do basically the same thing in preparing the
+function graph tracer on entry to a function. This code can be pulled into a
+generic location and then this will allow the function graph tracer to be
+fixed, as well as extended.
+
+Create a new function graph helper function_graph_enter() that will call the
+hook function (ftrace_graph_entry) and the shadow stack operation
+(ftrace_push_return_trace), and remove the need of the architecture code to
+manage the shadow stack.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/ftrace.h               |    3 +++
+ kernel/trace/trace_functions_graph.c |   16 ++++++++++++++++
+ 2 files changed, 19 insertions(+)
+
+--- a/include/linux/ftrace.h
++++ b/include/linux/ftrace.h
+@@ -779,6 +779,9 @@ extern void return_to_handler(void);
+ extern int
+ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
+                        unsigned long frame_pointer, unsigned long *retp);
++extern int
++function_graph_enter(unsigned long ret, unsigned long func,
++                   unsigned long frame_pointer, unsigned long *retp);
+ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
+                                   unsigned long ret, unsigned long *retp);
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -182,6 +182,22 @@ ftrace_push_return_trace(unsigned long r
+       return 0;
+ }
++int function_graph_enter(unsigned long ret, unsigned long func,
++                       unsigned long frame_pointer, unsigned long *retp)
++{
++      struct ftrace_graph_ent trace;
++
++      trace.func = func;
++      trace.depth = current->curr_ret_stack + 1;
++
++      /* Only trace if the calling function expects to */
++      if (!ftrace_graph_entry(&trace))
++              return -EBUSY;
++
++      return ftrace_push_return_trace(ret, func, &trace.depth,
++                                      frame_pointer, retp);
++}
++
+ /* Retrieve a function return address to the trace stack on thread info.*/
+ static void
+ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,
diff --git a/queue-4.19/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch b/queue-4.19/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch
new file mode 100644 (file)
index 0000000..e2368e5
--- /dev/null
@@ -0,0 +1,48 @@
+From b1b35f2e218a5b57d03bbc3b0667d5064570dc60 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Tue, 20 Nov 2018 12:51:07 -0500
+Subject: function_graph: Have profiler use curr_ret_stack and not depth
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit b1b35f2e218a5b57d03bbc3b0667d5064570dc60 upstream.
+
+The profiler uses trace->depth to find its entry on the ret_stack, but the
+depth may not match the actual location of where its entry is (if an
+interrupt were to preempt the processing of the profiler for another
+function, the depth and the curr_ret_stack will be different).
+
+Have it use the curr_ret_stack as the index to find its ret_stack entry
+instead of using the depth variable, as that is no longer guaranteed to be
+the same.
+
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/trace/ftrace.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/kernel/trace/ftrace.c
++++ b/kernel/trace/ftrace.c
+@@ -817,7 +817,7 @@ function_profile_call(unsigned long ip,
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ static int profile_graph_entry(struct ftrace_graph_ent *trace)
+ {
+-      int index = trace->depth;
++      int index = current->curr_ret_stack;
+       function_profile_call(trace->func, 0, NULL, NULL);
+@@ -852,7 +852,7 @@ static void profile_graph_return(struct
+       if (!fgraph_graph_time) {
+               int index;
+-              index = trace->depth;
++              index = current->curr_ret_stack;
+               /* Append this call time to the parent time to subtract */
+               if (index)
diff --git a/queue-4.19/function_graph-make-ftrace_push_return_trace-static.patch b/queue-4.19/function_graph-make-ftrace_push_return_trace-static.patch
new file mode 100644 (file)
index 0000000..602fade
--- /dev/null
@@ -0,0 +1,49 @@
+From d125f3f866df88da5a85df00291f88f0baa89f7c Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Mon, 19 Nov 2018 07:40:39 -0500
+Subject: function_graph: Make ftrace_push_return_trace() static
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit d125f3f866df88da5a85df00291f88f0baa89f7c upstream.
+
+As all architectures now call function_graph_enter() to do the entry work,
+no architecture should ever call ftrace_push_return_trace(). Make it static.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/ftrace.h               |    3 ---
+ kernel/trace/trace_functions_graph.c |    2 +-
+ 2 files changed, 1 insertion(+), 4 deletions(-)
+
+--- a/include/linux/ftrace.h
++++ b/include/linux/ftrace.h
+@@ -777,9 +777,6 @@ struct ftrace_ret_stack {
+ extern void return_to_handler(void);
+ extern int
+-ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
+-                       unsigned long frame_pointer, unsigned long *retp);
+-extern int
+ function_graph_enter(unsigned long ret, unsigned long func,
+                    unsigned long frame_pointer, unsigned long *retp);
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -118,7 +118,7 @@ print_graph_duration(struct trace_array
+                    struct trace_seq *s, u32 flags);
+ /* Add a function return address to the trace stack on thread info.*/
+-int
++static int
+ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
+                        unsigned long frame_pointer, unsigned long *retp)
+ {
diff --git a/queue-4.19/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch b/queue-4.19/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch
new file mode 100644 (file)
index 0000000..71ffa40
--- /dev/null
@@ -0,0 +1,88 @@
+From 552701dd0fa7c3d448142e87210590ba424694a0 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Mon, 19 Nov 2018 15:18:40 -0500
+Subject: function_graph: Move return callback before update of curr_ret_stack
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 552701dd0fa7c3d448142e87210590ba424694a0 upstream.
+
+In the past, curr_ret_stack had two functions. One was to denote the depth
+of the call graph, the other is to keep track of where on the ret_stack the
+data is used. Although they may be slightly related, there are two cases
+where they need to be used differently.
+
+The one case is that it keeps the ret_stack data from being corrupted by an
+interrupt coming in and overwriting the data still in use. The other is just
+to know where the depth of the stack currently is.
+
+The function profiler uses the ret_stack to save a "subtime" variable that
+is part of the data on the ret_stack. If curr_ret_stack is modified too
+early, then this variable can be corrupted.
+
+The "max_depth" option, when set to 1, will record the first functions going
+into the kernel. To see all top functions (when dealing with timings), the
+depth variable needs to be lowered before calling the return hook. But by
+lowering the curr_ret_stack, it makes the data on the ret_stack still being
+used by the return hook susceptible to being overwritten.
+
+Now that there's two variables to handle both cases (curr_ret_depth), we can
+move them to the locations where they can handle both cases.
+
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/trace/trace_functions_graph.c |   22 +++++++++++++---------
+ 1 file changed, 13 insertions(+), 9 deletions(-)
+
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -261,7 +261,13 @@ ftrace_pop_return_trace(struct ftrace_gr
+       trace->func = current->ret_stack[index].func;
+       trace->calltime = current->ret_stack[index].calltime;
+       trace->overrun = atomic_read(&current->trace_overrun);
+-      trace->depth = current->curr_ret_depth;
++      trace->depth = current->curr_ret_depth--;
++      /*
++       * We still want to trace interrupts coming in if
++       * max_depth is set to 1. Make sure the decrement is
++       * seen before ftrace_graph_return.
++       */
++      barrier();
+ }
+ /*
+@@ -275,9 +281,14 @@ unsigned long ftrace_return_to_handler(u
+       ftrace_pop_return_trace(&trace, &ret, frame_pointer);
+       trace.rettime = trace_clock_local();
++      ftrace_graph_return(&trace);
++      /*
++       * The ftrace_graph_return() may still access the current
++       * ret_stack structure, we need to make sure the update of
++       * curr_ret_stack is after that.
++       */
+       barrier();
+       current->curr_ret_stack--;
+-      current->curr_ret_depth--;
+       /*
+        * The curr_ret_stack can be less than -1 only if it was
+        * filtered out and it's about to return from the function.
+@@ -288,13 +299,6 @@ unsigned long ftrace_return_to_handler(u
+               return ret;
+       }
+-      /*
+-       * The trace should run after decrementing the ret counter
+-       * in case an interrupt were to come in. We don't want to
+-       * lose the interrupt if max_depth is set.
+-       */
+-      ftrace_graph_return(&trace);
+-
+       if (unlikely(!ret)) {
+               ftrace_graph_stop();
+               WARN_ON(1);
diff --git a/queue-4.19/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch b/queue-4.19/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch
new file mode 100644 (file)
index 0000000..88b5ad8
--- /dev/null
@@ -0,0 +1,56 @@
+From 7c6ea35ef50810aa12ab26f21cb858d980881576 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Tue, 20 Nov 2018 12:40:25 -0500
+Subject: function_graph: Reverse the order of pushing the ret_stack and the callback
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 7c6ea35ef50810aa12ab26f21cb858d980881576 upstream.
+
+The function graph profiler uses the ret_stack to store the "subtime" and
+reuse it by nested functions and also on the return. But the current logic
+has the profiler callback called before the ret_stack is updated, and it is
+just modifying the ret_stack that will later be allocated (it's just lucky
+that the "subtime" is not touched when it is allocated).
+
+This could also cause a crash if we are at the end of the ret_stack when
+this happens.
+
+By reversing the order of the allocating the ret_stack and then calling the
+callbacks attached to a function being traced, the ret_stack entry is no
+longer used before it is allocated.
+
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/trace/trace_functions_graph.c |   10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -188,15 +188,17 @@ int function_graph_enter(unsigned long r
+       trace.func = func;
+       trace.depth = ++current->curr_ret_depth;
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace))
+-              goto out;
+-
+       if (ftrace_push_return_trace(ret, func,
+                                    frame_pointer, retp))
+               goto out;
++      /* Only trace if the calling function expects to */
++      if (!ftrace_graph_entry(&trace))
++              goto out_ret;
++
+       return 0;
++ out_ret:
++      current->curr_ret_stack--;
+  out:
+       current->curr_ret_depth--;
+       return -EBUSY;
diff --git a/queue-4.19/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch b/queue-4.19/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch
new file mode 100644 (file)
index 0000000..1827370
--- /dev/null
@@ -0,0 +1,140 @@
+From 39eb456dacb543de90d3bc6a8e0ac5cf51ac475e Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Mon, 19 Nov 2018 08:07:12 -0500
+Subject: function_graph: Use new curr_ret_depth to manage depth instead of curr_ret_stack
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 39eb456dacb543de90d3bc6a8e0ac5cf51ac475e upstream.
+
+Currently, the depth of the ret_stack is determined by curr_ret_stack index.
+The issue is that there's a race between setting of the curr_ret_stack and
+calling of the callback attached to the return of the function.
+
+Commit 03274a3ffb44 ("tracing/fgraph: Adjust fgraph depth before calling
+trace return callback") moved the calling of the callback to after the
+setting of the curr_ret_stack, even stating that it was safe to do so, when
+in fact, it was the reason there was a barrier() there (yes, I should have
+commented that barrier()).
+
+Not only does the curr_ret_stack keep track of the current call graph depth,
+it also keeps the ret_stack content from being overwritten by new data.
+
+The function profiler, uses the "subtime" variable of ret_stack structure
+and by moving the curr_ret_stack, it allows for interrupts to use the same
+structure it was using, corrupting the data, and breaking the profiler.
+
+To fix this, there needs to be two variables to handle the call stack depth
+and the pointer to where the ret_stack is being used, as they need to change
+at two different locations.
+
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/sched.h                |    1 +
+ kernel/trace/ftrace.c                |    3 +++
+ kernel/trace/trace_functions_graph.c |   21 +++++++++++++--------
+ 3 files changed, 17 insertions(+), 8 deletions(-)
+
+--- a/include/linux/sched.h
++++ b/include/linux/sched.h
+@@ -1108,6 +1108,7 @@ struct task_struct {
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+       /* Index of current stored address in ret_stack: */
+       int                             curr_ret_stack;
++      int                             curr_ret_depth;
+       /* Stack of return addresses for return function tracing: */
+       struct ftrace_ret_stack         *ret_stack;
+--- a/kernel/trace/ftrace.c
++++ b/kernel/trace/ftrace.c
+@@ -6814,6 +6814,7 @@ static int alloc_retstack_tasklist(struc
+                       atomic_set(&t->tracing_graph_pause, 0);
+                       atomic_set(&t->trace_overrun, 0);
+                       t->curr_ret_stack = -1;
++                      t->curr_ret_depth = -1;
+                       /* Make sure the tasks see the -1 first: */
+                       smp_wmb();
+                       t->ret_stack = ret_stack_list[start++];
+@@ -7038,6 +7039,7 @@ graph_init_task(struct task_struct *t, s
+ void ftrace_graph_init_idle_task(struct task_struct *t, int cpu)
+ {
+       t->curr_ret_stack = -1;
++      t->curr_ret_depth = -1;
+       /*
+        * The idle task has no parent, it either has its own
+        * stack or no stack at all.
+@@ -7068,6 +7070,7 @@ void ftrace_graph_init_task(struct task_
+       /* Make sure we do not use the parent ret_stack */
+       t->ret_stack = NULL;
+       t->curr_ret_stack = -1;
++      t->curr_ret_depth = -1;
+       if (ftrace_graph_active) {
+               struct ftrace_ret_stack *ret_stack;
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -119,7 +119,7 @@ print_graph_duration(struct trace_array
+ /* Add a function return address to the trace stack on thread info.*/
+ static int
+-ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
++ftrace_push_return_trace(unsigned long ret, unsigned long func,
+                        unsigned long frame_pointer, unsigned long *retp)
+ {
+       unsigned long long calltime;
+@@ -177,8 +177,6 @@ ftrace_push_return_trace(unsigned long r
+ #ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
+       current->ret_stack[index].retp = retp;
+ #endif
+-      *depth = current->curr_ret_stack;
+-
+       return 0;
+ }
+@@ -188,14 +186,20 @@ int function_graph_enter(unsigned long r
+       struct ftrace_graph_ent trace;
+       trace.func = func;
+-      trace.depth = current->curr_ret_stack + 1;
++      trace.depth = ++current->curr_ret_depth;
+       /* Only trace if the calling function expects to */
+       if (!ftrace_graph_entry(&trace))
+-              return -EBUSY;
++              goto out;
+-      return ftrace_push_return_trace(ret, func, &trace.depth,
+-                                      frame_pointer, retp);
++      if (ftrace_push_return_trace(ret, func,
++                                   frame_pointer, retp))
++              goto out;
++
++      return 0;
++ out:
++      current->curr_ret_depth--;
++      return -EBUSY;
+ }
+ /* Retrieve a function return address to the trace stack on thread info.*/
+@@ -257,7 +261,7 @@ ftrace_pop_return_trace(struct ftrace_gr
+       trace->func = current->ret_stack[index].func;
+       trace->calltime = current->ret_stack[index].calltime;
+       trace->overrun = atomic_read(&current->trace_overrun);
+-      trace->depth = index;
++      trace->depth = current->curr_ret_depth;
+ }
+ /*
+@@ -273,6 +277,7 @@ unsigned long ftrace_return_to_handler(u
+       trace.rettime = trace_clock_local();
+       barrier();
+       current->curr_ret_stack--;
++      current->curr_ret_depth--;
+       /*
+        * The curr_ret_stack can be less than -1 only if it was
+        * filtered out and it's about to return from the function.
diff --git a/queue-4.19/microblaze-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/microblaze-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..ecdb007
--- /dev/null
@@ -0,0 +1,62 @@
+From 556763e5a500d71879d632867b75826551acd49c Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:23:30 -0500
+Subject: microblaze: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 556763e5a500d71879d632867b75826551acd49c upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have microblaze use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Michal Simek <monstr@monstr.eu>
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/microblaze/kernel/ftrace.c |   15 ++-------------
+ 1 file changed, 2 insertions(+), 13 deletions(-)
+
+--- a/arch/microblaze/kernel/ftrace.c
++++ b/arch/microblaze/kernel/ftrace.c
+@@ -22,8 +22,7 @@
+ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
+ {
+       unsigned long old;
+-      int faulted, err;
+-      struct ftrace_graph_ent trace;
++      int faulted;
+       unsigned long return_hooker = (unsigned long)
+                               &return_to_handler;
+@@ -63,18 +62,8 @@ void prepare_ftrace_return(unsigned long
+               return;
+       }
+-      err = ftrace_push_return_trace(old, self_addr, &trace.depth, 0, NULL);
+-      if (err == -EBUSY) {
++      if (function_graph_enter(old, self_addr, 0, NULL))
+               *parent = old;
+-              return;
+-      }
+-
+-      trace.func = self_addr;
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace)) {
+-              current->curr_ret_stack--;
+-              *parent = old;
+-      }
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/queue-4.19/mips-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/mips-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..b12598f
--- /dev/null
@@ -0,0 +1,72 @@
+From 8712b27c5723c26400a2b350faf1d6d9fd7ffaad Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:25:18 -0500
+Subject: MIPS: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 8712b27c5723c26400a2b350faf1d6d9fd7ffaad upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have MIPS use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Ralf Baechle <ralf@linux-mips.org>
+Cc: Paul Burton <paul.burton@mips.com>
+Cc: James Hogan <jhogan@kernel.org>
+Cc: linux-mips@linux-mips.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/mips/kernel/ftrace.c |   14 ++------------
+ 1 file changed, 2 insertions(+), 12 deletions(-)
+
+--- a/arch/mips/kernel/ftrace.c
++++ b/arch/mips/kernel/ftrace.c
+@@ -322,7 +322,6 @@ void prepare_ftrace_return(unsigned long
+                          unsigned long fp)
+ {
+       unsigned long old_parent_ra;
+-      struct ftrace_graph_ent trace;
+       unsigned long return_hooker = (unsigned long)
+           &return_to_handler;
+       int faulted, insns;
+@@ -369,12 +368,6 @@ void prepare_ftrace_return(unsigned long
+       if (unlikely(faulted))
+               goto out;
+-      if (ftrace_push_return_trace(old_parent_ra, self_ra, &trace.depth, fp,
+-                                   NULL) == -EBUSY) {
+-              *parent_ra_addr = old_parent_ra;
+-              return;
+-      }
+-
+       /*
+        * Get the recorded ip of the current mcount calling site in the
+        * __mcount_loc section, which will be used to filter the function
+@@ -382,13 +375,10 @@ void prepare_ftrace_return(unsigned long
+        */
+       insns = core_kernel_text(self_ra) ? 2 : MCOUNT_OFFSET_INSNS + 1;
+-      trace.func = self_ra - (MCOUNT_INSN_SIZE * insns);
++      self_ra -= (MCOUNT_INSN_SIZE * insns);
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace)) {
+-              current->curr_ret_stack--;
++      if (function_graph_enter(old_parent_ra, self_ra, fp, NULL))
+               *parent_ra_addr = old_parent_ra;
+-      }
+       return;
+ out:
+       ftrace_graph_stop();
diff --git a/queue-4.19/nds32-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/nds32-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..5a10164
--- /dev/null
@@ -0,0 +1,64 @@
+From d48ebb24866edea2c35be02a878f25bc65529370 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:26:35 -0500
+Subject: nds32: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit d48ebb24866edea2c35be02a878f25bc65529370 upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have nds32 use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Greentime Hu <greentime@andestech.com>
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/nds32/kernel/ftrace.c |   18 ++----------------
+ 1 file changed, 2 insertions(+), 16 deletions(-)
+
+--- a/arch/nds32/kernel/ftrace.c
++++ b/arch/nds32/kernel/ftrace.c
+@@ -211,29 +211,15 @@ void prepare_ftrace_return(unsigned long
+                          unsigned long frame_pointer)
+ {
+       unsigned long return_hooker = (unsigned long)&return_to_handler;
+-      struct ftrace_graph_ent trace;
+       unsigned long old;
+-      int err;
+       if (unlikely(atomic_read(&current->tracing_graph_pause)))
+               return;
+       old = *parent;
+-      trace.func = self_addr;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace))
+-              return;
+-
+-      err = ftrace_push_return_trace(old, self_addr, &trace.depth,
+-                                     frame_pointer, NULL);
+-
+-      if (err == -EBUSY)
+-              return;
+-
+-      *parent = return_hooker;
++      if (!function_graph_enter(old, self_addr, frame_pointer, NULL))
++              *parent = return_hooker;
+ }
+ noinline void ftrace_graph_caller(void)
diff --git a/queue-4.19/parisc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/parisc-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..39fedb4
--- /dev/null
@@ -0,0 +1,65 @@
+From a87532c78d291265efadc4b20a8c7a70cd59ea29 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:27:43 -0500
+Subject: parisc: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit a87532c78d291265efadc4b20a8c7a70cd59ea29 upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have parisc use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
+Cc: Helge Deller <deller@gmx.de>
+Cc: linux-parisc@vger.kernel.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/parisc/kernel/ftrace.c |   17 +++--------------
+ 1 file changed, 3 insertions(+), 14 deletions(-)
+
+--- a/arch/parisc/kernel/ftrace.c
++++ b/arch/parisc/kernel/ftrace.c
+@@ -30,7 +30,6 @@ static void __hot prepare_ftrace_return(
+                                       unsigned long self_addr)
+ {
+       unsigned long old;
+-      struct ftrace_graph_ent trace;
+       extern int parisc_return_to_handler;
+       if (unlikely(ftrace_graph_is_dead()))
+@@ -41,19 +40,9 @@ static void __hot prepare_ftrace_return(
+       old = *parent;
+-      trace.func = self_addr;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace))
+-              return;
+-
+-        if (ftrace_push_return_trace(old, self_addr, &trace.depth,
+-                                   0, NULL) == -EBUSY)
+-                return;
+-
+-      /* activate parisc_return_to_handler() as return point */
+-      *parent = (unsigned long) &parisc_return_to_handler;
++      if (!function_graph_enter(old, self_addr, 0, NULL))
++              /* activate parisc_return_to_handler() as return point */
++              *parent = (unsigned long) &parisc_return_to_handler;
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/queue-4.19/powerpc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/powerpc-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..be645b8
--- /dev/null
@@ -0,0 +1,64 @@
+From fe60522ec60082a1dd735691b82c64f65d4ad15e Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:28:53 -0500
+Subject: powerpc/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit fe60522ec60082a1dd735691b82c64f65d4ad15e upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have powerpc use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Cc: Paul Mackerras <paulus@samba.org>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: linuxppc-dev@lists.ozlabs.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/kernel/trace/ftrace.c |   15 ++-------------
+ 1 file changed, 2 insertions(+), 13 deletions(-)
+
+--- a/arch/powerpc/kernel/trace/ftrace.c
++++ b/arch/powerpc/kernel/trace/ftrace.c
+@@ -697,7 +697,6 @@ int ftrace_disable_ftrace_graph_caller(v
+  */
+ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip)
+ {
+-      struct ftrace_graph_ent trace;
+       unsigned long return_hooker;
+       if (unlikely(ftrace_graph_is_dead()))
+@@ -708,18 +707,8 @@ unsigned long prepare_ftrace_return(unsi
+       return_hooker = ppc_function_entry(return_to_handler);
+-      trace.func = ip;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace))
+-              goto out;
+-
+-      if (ftrace_push_return_trace(parent, ip, &trace.depth, 0,
+-                                   NULL) == -EBUSY)
+-              goto out;
+-
+-      parent = return_hooker;
++      if (!function_graph_enter(parent, ip, 0, NULL))
++              parent = return_hooker;
+ out:
+       return parent;
+ }
diff --git a/queue-4.19/riscv-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/riscv-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..f3b3f68
--- /dev/null
@@ -0,0 +1,62 @@
+From e949b6db51dc172a35c962bc4414ca148315fe21 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:31:44 -0500
+Subject: riscv/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit e949b6db51dc172a35c962bc4414ca148315fe21 upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have riscv use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Greentime Hu <greentime@andestech.com>
+Cc: Alan Kao <alankao@andestech.com>
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/riscv/kernel/ftrace.c |   14 ++------------
+ 1 file changed, 2 insertions(+), 12 deletions(-)
+
+--- a/arch/riscv/kernel/ftrace.c
++++ b/arch/riscv/kernel/ftrace.c
+@@ -132,7 +132,6 @@ void prepare_ftrace_return(unsigned long
+ {
+       unsigned long return_hooker = (unsigned long)&return_to_handler;
+       unsigned long old;
+-      struct ftrace_graph_ent trace;
+       int err;
+       if (unlikely(atomic_read(&current->tracing_graph_pause)))
+@@ -144,17 +143,8 @@ void prepare_ftrace_return(unsigned long
+        */
+       old = *parent;
+-      trace.func = self_addr;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      if (!ftrace_graph_entry(&trace))
+-              return;
+-
+-      err = ftrace_push_return_trace(old, self_addr, &trace.depth,
+-                                     frame_pointer, parent);
+-      if (err == -EBUSY)
+-              return;
+-      *parent = return_hooker;
++      if (function_graph_enter(old, self_addr, frame_pointer, parent))
++              *parent = return_hooker;
+ }
+ #ifdef CONFIG_DYNAMIC_FTRACE
diff --git a/queue-4.19/s390-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/s390-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..c792638
--- /dev/null
@@ -0,0 +1,60 @@
+From 18588e1487b19e45bd90bd55ec8d3a1d44f3257f Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:33:17 -0500
+Subject: s390/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 18588e1487b19e45bd90bd55ec8d3a1d44f3257f upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have s390 use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
+Cc: Julian Wiedmann <jwi@linux.ibm.com>
+Cc: linux-s390@vger.kernel.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/s390/kernel/ftrace.c |   13 ++-----------
+ 1 file changed, 2 insertions(+), 11 deletions(-)
+
+--- a/arch/s390/kernel/ftrace.c
++++ b/arch/s390/kernel/ftrace.c
+@@ -203,22 +203,13 @@ device_initcall(ftrace_plt_init);
+  */
+ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip)
+ {
+-      struct ftrace_graph_ent trace;
+-
+       if (unlikely(ftrace_graph_is_dead()))
+               goto out;
+       if (unlikely(atomic_read(&current->tracing_graph_pause)))
+               goto out;
+       ip -= MCOUNT_INSN_SIZE;
+-      trace.func = ip;
+-      trace.depth = current->curr_ret_stack + 1;
+-      /* Only trace if the calling function expects to. */
+-      if (!ftrace_graph_entry(&trace))
+-              goto out;
+-      if (ftrace_push_return_trace(parent, ip, &trace.depth, 0,
+-                                   NULL) == -EBUSY)
+-              goto out;
+-      parent = (unsigned long) return_to_handler;
++      if (!function_graph_enter(parent, ip, 0, NULL))
++              parent = (unsigned long) return_to_handler;
+ out:
+       return parent;
+ }
index de50e03c7a922c40aa5759ea541f5ceef4733fc1..48f5655a05c57b77eaba97a0f4cf807e328511be 100644 (file)
@@ -95,3 +95,26 @@ alsa-hda-realtek-support-alc300.patch
 alsa-hda-realtek-fix-headset-mic-detection-for-msi-ms-b171.patch
 alsa-hda-realtek-fix-the-pop-noise-on-headphone-for-lenovo-laptops.patch
 alsa-hda-realtek-add-auto-mute-quirk-for-hp-spectre-x360-laptop.patch
+function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch
+arm-function_graph-simplify-with-function_graph_enter.patch
+microblaze-function_graph-simplify-with-function_graph_enter.patch
+x86-function_graph-simplify-with-function_graph_enter.patch
+nds32-function_graph-simplify-with-function_graph_enter.patch
+powerpc-function_graph-simplify-with-function_graph_enter.patch
+sh-function_graph-simplify-with-function_graph_enter.patch
+sparc-function_graph-simplify-with-function_graph_enter.patch
+parisc-function_graph-simplify-with-function_graph_enter.patch
+riscv-function_graph-simplify-with-function_graph_enter.patch
+s390-function_graph-simplify-with-function_graph_enter.patch
+arm64-function_graph-simplify-with-function_graph_enter.patch
+mips-function_graph-simplify-with-function_graph_enter.patch
+function_graph-make-ftrace_push_return_trace-static.patch
+function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch
+function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch
+function_graph-move-return-callback-before-update-of-curr_ret_stack.patch
+function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch
+binder-fix-race-that-allows-malicious-free-of-live-buffer.patch
+ext2-initialize-opts.s_mount_opt-as-zero-before-using-it.patch
+ext2-fix-potential-use-after-free.patch
+asoc-intel-cht_bsw_max98090_ti-add-quirk-for-boards-using-pmc_plt_clk_0.patch
+asoc-pcm186x-fix-device-reset-registers-trigger-value.patch
diff --git a/queue-4.19/sh-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/sh-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..79e45db
--- /dev/null
@@ -0,0 +1,64 @@
+From bc715ee4dbc5db462c59b9cfba92d31b3274fe3a Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:35:37 -0500
+Subject: sh/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit bc715ee4dbc5db462c59b9cfba92d31b3274fe3a upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have superh use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
+Cc: Rich Felker <dalias@libc.org>
+Cc: linux-sh@vger.kernel.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/sh/kernel/ftrace.c |   16 ++--------------
+ 1 file changed, 2 insertions(+), 14 deletions(-)
+
+--- a/arch/sh/kernel/ftrace.c
++++ b/arch/sh/kernel/ftrace.c
+@@ -321,8 +321,7 @@ int ftrace_disable_ftrace_graph_caller(v
+ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
+ {
+       unsigned long old;
+-      int faulted, err;
+-      struct ftrace_graph_ent trace;
++      int faulted;
+       unsigned long return_hooker = (unsigned long)&return_to_handler;
+       if (unlikely(ftrace_graph_is_dead()))
+@@ -365,18 +364,7 @@ void prepare_ftrace_return(unsigned long
+               return;
+       }
+-      err = ftrace_push_return_trace(old, self_addr, &trace.depth, 0, NULL);
+-      if (err == -EBUSY) {
++      if (function_graph_enter(old, self_addr, 0, NULL))
+               __raw_writel(old, parent);
+-              return;
+-      }
+-
+-      trace.func = self_addr;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace)) {
+-              current->curr_ret_stack--;
+-              __raw_writel(old, parent);
+-      }
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/queue-4.19/sparc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/sparc-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..049349f
--- /dev/null
@@ -0,0 +1,55 @@
+From 9c4bf5e0db164f330a2d3e128e9832661f69f0e9 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:37:40 -0500
+Subject: sparc/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 9c4bf5e0db164f330a2d3e128e9832661f69f0e9 upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have sparc use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: "David S. Miller" <davem@davemloft.net>
+Cc: sparclinux@vger.kernel.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/sparc/kernel/ftrace.c |   11 +----------
+ 1 file changed, 1 insertion(+), 10 deletions(-)
+
+--- a/arch/sparc/kernel/ftrace.c
++++ b/arch/sparc/kernel/ftrace.c
+@@ -126,20 +126,11 @@ unsigned long prepare_ftrace_return(unsi
+                                   unsigned long frame_pointer)
+ {
+       unsigned long return_hooker = (unsigned long) &return_to_handler;
+-      struct ftrace_graph_ent trace;
+       if (unlikely(atomic_read(&current->tracing_graph_pause)))
+               return parent + 8UL;
+-      trace.func = self_addr;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace))
+-              return parent + 8UL;
+-
+-      if (ftrace_push_return_trace(parent, self_addr, &trace.depth,
+-                                   frame_pointer, NULL) == -EBUSY)
++      if (function_graph_enter(parent, self_addr, frame_pointer, NULL))
+               return parent + 8UL;
+       return return_hooker;
diff --git a/queue-4.19/x86-function_graph-simplify-with-function_graph_enter.patch b/queue-4.19/x86-function_graph-simplify-with-function_graph_enter.patch
new file mode 100644 (file)
index 0000000..eac0fed
--- /dev/null
@@ -0,0 +1,65 @@
+From 07f7175b43827640d1e69c9eded89aa089a234b4 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:14:10 -0500
+Subject: x86/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 07f7175b43827640d1e69c9eded89aa089a234b4 upstream.
+
+The function_graph_enter() function does the work of calling the function
+graph hook function and the management of the shadow stack, simplifying the
+work done in the architecture dependent prepare_ftrace_return().
+
+Have x86 use the new code, and remove the shadow stack management as well as
+having to set up the trace structure.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: Borislav Petkov <bp@alien8.de>
+Cc: "H. Peter Anvin" <hpa@zytor.com>
+Cc: x86@kernel.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kernel/ftrace.c |   15 +--------------
+ 1 file changed, 1 insertion(+), 14 deletions(-)
+
+--- a/arch/x86/kernel/ftrace.c
++++ b/arch/x86/kernel/ftrace.c
+@@ -994,7 +994,6 @@ void prepare_ftrace_return(unsigned long
+ {
+       unsigned long old;
+       int faulted;
+-      struct ftrace_graph_ent trace;
+       unsigned long return_hooker = (unsigned long)
+                               &return_to_handler;
+@@ -1046,19 +1045,7 @@ void prepare_ftrace_return(unsigned long
+               return;
+       }
+-      trace.func = self_addr;
+-      trace.depth = current->curr_ret_stack + 1;
+-
+-      /* Only trace if the calling function expects to */
+-      if (!ftrace_graph_entry(&trace)) {
++      if (function_graph_enter(old, self_addr, frame_pointer, parent))
+               *parent = old;
+-              return;
+-      }
+-
+-      if (ftrace_push_return_trace(old, self_addr, &trace.depth,
+-                                   frame_pointer, parent) == -EBUSY) {
+-              *parent = old;
+-              return;
+-      }
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */