Commit b71f515c authored by Qiujun Huang's avatar Qiujun Huang Committed by zhaoxiaoqiang11
Browse files

pstore/zone: Use GFP_ATOMIC to allocate zone buffer

stable inclusion
from stable-v5.10.163
commit 44cf50587e822714f52ceeadd16b6c38d1b29d0f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7PJ9N

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=44cf50587e822714f52ceeadd16b6c38d1b29d0f



----------------------------------------------------

commit 99b3b837 upstream.

There is a case found when triggering a panic_on_oom, pstore fails to dump
kmsg. Because psz_kmsg_write_record can't get the new buffer.

Handle this by using GFP_ATOMIC to allocate a buffer at lower watermark.

Signed-off-by: default avatarQiujun Huang <hqjagain@gmail.com>
Fixes: 335426c6 ("pstore/zone: Provide way to skip "broken" zone for MTD devices")
Cc: WeiXiong Liao <gmpy.liaowx@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/CAJRQjofRCF7wjrYmw3D7zd5QZnwHQq+F8U-mJDJ6NZ4bddYdLA@mail.gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent 4f800c6e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -761,7 +761,7 @@ static inline int notrace psz_kmsg_write_record(struct psz_context *cxt,
		/* avoid destroying old data, allocate a new one */
		len = zone->buffer_size + sizeof(*zone->buffer);
		zone->oldbuf = zone->buffer;
		zone->buffer = kzalloc(len, GFP_KERNEL);
		zone->buffer = kzalloc(len, GFP_ATOMIC);
		if (!zone->buffer) {
			zone->buffer = zone->oldbuf;
			return -ENOMEM;