From: akpm@linux-foundation.org
To: mm-commits@vger.kernel.org, vdavydov.dev@gmail.com,
shakeelb@google.com, mhocko@kernel.org, hannes@cmpxchg.org,
songmuchun@bytedance.com
Subject: [to-be-updated] mm-memcontrol-fix-out-of-bounds-on-the-buf-returned-by-memory_stat_format.patch removed from -mm tree
Date: Wed, 16 Sep 2020 15:59:50 -0700 [thread overview]
Message-ID: <20200916225950.mdOKd%akpm@linux-foundation.org> (raw)
The patch titled
Subject: mm: memcontrol: fix out-of-bounds on the buf returned by memory_stat_format
has been removed from the -mm tree. Its filename was
mm-memcontrol-fix-out-of-bounds-on-the-buf-returned-by-memory_stat_format.patch
This patch was dropped because an updated version will be merged
------------------------------------------------------
From: Muchun Song <songmuchun@bytedance.com>
Subject: mm: memcontrol: fix out-of-bounds on the buf returned by memory_stat_format
The memory_stat_format() returns a format string, but the return buf may
not including the trailing '\0', so the users may read the buf out of
bounds.
Link: https://lkml.kernel.org/r/20200912155100.25578-1-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/memcontrol.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--- a/mm/memcontrol.c~mm-memcontrol-fix-out-of-bounds-on-the-buf-returned-by-memory_stat_format
+++ a/mm/memcontrol.c
@@ -1456,12 +1456,13 @@ static bool mem_cgroup_wait_acct_move(st
return false;
}
-static char *memory_stat_format(struct mem_cgroup *memcg)
+static const char *memory_stat_format(struct mem_cgroup *memcg)
{
struct seq_buf s;
int i;
- seq_buf_init(&s, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE);
+ /* Reserve a byte for the trailing null */
+ seq_buf_init(&s, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE - 1);
if (!s.buffer)
return NULL;
@@ -1570,7 +1571,8 @@ static char *memory_stat_format(struct m
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
/* The above should easily fit into one page */
- WARN_ON_ONCE(seq_buf_has_overflowed(&s));
+ if (WARN_ON_ONCE(seq_buf_putc(&s, '\0')))
+ s.buffer[PAGE_SIZE - 1] = '\0';
return s.buffer;
}
@@ -1608,7 +1610,7 @@ void mem_cgroup_print_oom_context(struct
*/
void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)
{
- char *buf;
+ const char *buf;
pr_info("memory: usage %llukB, limit %llukB, failcnt %lu\n",
K((u64)page_counter_read(&memcg->memory)),
@@ -6373,7 +6375,7 @@ static int memory_events_local_show(stru
static int memory_stat_show(struct seq_file *m, void *v)
{
struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
- char *buf;
+ const char *buf;
buf = memory_stat_format(memcg);
if (!buf)
_
Patches currently in -mm which might be from songmuchun@bytedance.com are
kprobes-fix-kill-kprobe-which-has-been-marked-as-gone.patch
mm-memcontrol-fix-missing-suffix-of-workingset_restore.patch
mmhwpoison-refactor-soft_offline_huge_page-and-__soft_offline_page-fix-2.patch
reply other threads:[~2020-09-16 22:59 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=20200916225950.mdOKd%akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=shakeelb@google.com \
--cc=songmuchun@bytedance.com \
--cc=vdavydov.dev@gmail.com \
/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.