From: Josh Poimboeuf <[email protected]>

To avoid continued attempted use of a bad .sframe section, remove it
on demand when the first sign of corruption is detected.

Signed-off-by: Josh Poimboeuf <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
Reviewed-by: Indu Bhagat <[email protected]>
Signed-off-by: Jens Remus <[email protected]>
---

Notes (jremus):
    Changes in v15:
    - sframe_find(): Align to normalized error code usage and remove .sframe
      for all but ENOENT.  Also remove if user_read_access_begin() fails.

 kernel/unwind/sframe.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c
index f723c1a32f90..02331956009a 100644
--- a/kernel/unwind/sframe.c
+++ b/kernel/unwind/sframe.c
@@ -360,16 +360,23 @@ int sframe_find(unsigned long ip, struct 
unwind_user_frame *frame)
                return -ENOENT;
 
        if (!user_read_access_begin((void __user *)sec->sframe_start,
-                                   sec->sframe_end - sec->sframe_start))
-               return -EFAULT;
+                                   sec->sframe_end - sec->sframe_start)) {
+               ret = -EFAULT;
+               goto end;
+       }
 
        ret = __find_fde(sec, ip, &fde);
        if (ret)
-               goto end;
+               goto end_uaccess;
 
        ret = __find_fre(sec, &fde, ip, frame);
-end:
+end_uaccess:
        user_read_access_end();
+
+end:
+       if (ret && ret != -ENOENT)
+               WARN_ON_ONCE(sframe_remove_section(sec->sframe_start));
+
        return ret;
 }
 
-- 
2.51.0


Reply via email to