From: akpm@linux-foundation.org
To: deller@gmx.de, mm-commits@vger.kernel.org, stable@vger.kernel.org
Subject: + usercopy-do-not-fail-on-memory-from-former-init-sections.patch added to -mm tree
Date: Fri, 07 Jan 2022 15:47:01 -0800 [thread overview]
Message-ID: <20220107234701.4ZAlIDHdY%akpm@linux-foundation.org> (raw)
The patch titled
Subject: usercopy: do not fail on memory from former init sections
has been added to the -mm tree. Its filename is
usercopy-do-not-fail-on-memory-from-former-init-sections.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/usercopy-do-not-fail-on-memory-from-former-init-sections.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/usercopy-do-not-fail-on-memory-from-former-init-sections.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Helge Deller <deller@gmx.de>
Subject: usercopy: do not fail on memory from former init sections
On some platforms the memory area between the _stext and the _etext
symbols includes the init sections (parisc and csky). If the init
sections are freed after bootup, the kernel may reuse this memory.
In one test the usercopy checks if the given address is inside the .text
section (from _stext to _etext), and it wrongly fails on the mentioned
platforms if the memory is from the former init section.
Fix this failure by first checking against the init sections before
checking against the _stext/_etext section.
Link: https://lkml.kernel.org/r/YdeHDDAP+TY5wNeT@ls3530
Fixes: 98400ad75e95 ("parisc: Fix backtrace to always include init funtion names")
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/usercopy.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
--- a/mm/usercopy.c~usercopy-do-not-fail-on-memory-from-former-init-sections
+++ a/mm/usercopy.c
@@ -113,6 +113,15 @@ static bool overlaps(const unsigned long
return true;
}
+static bool inside_init_area(const unsigned long ptr, unsigned long n,
+ char *start, char *end)
+{
+ unsigned long initlow = (unsigned long) start;
+ unsigned long inithigh = (unsigned long) end;
+
+ return (ptr >= initlow && (ptr + n) < inithigh);
+}
+
/* Is this address range in the kernel text area? */
static inline void check_kernel_text_object(const unsigned long ptr,
unsigned long n, bool to_user)
@@ -121,6 +130,12 @@ static inline void check_kernel_text_obj
unsigned long texthigh = (unsigned long)_etext;
unsigned long textlow_linear, texthigh_linear;
+ /* Ok if inside the former init sections */
+ if (inside_init_area(ptr, n, __init_begin, __init_end))
+ return;
+ if (inside_init_area(ptr, n, _sinittext, _einittext))
+ return;
+
if (overlaps(ptr, n, textlow, texthigh))
usercopy_abort("kernel text", NULL, to_user, ptr - textlow, n);
_
Patches currently in -mm which might be from deller@gmx.de are
usercopy-do-not-fail-on-memory-from-former-init-sections.patch
reply other threads:[~2022-01-07 23:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220107234701.4ZAlIDHdY%akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=deller@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox