From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH AUTOSEL 5.7 251/388] powerpc/kasan: Fix error detection on memory allocation
Date: Wed, 17 Jun 2020 21:05:48 -0400 [thread overview]
Message-ID: <20200618010805.600873-251-sashal@kernel.org> (raw)
In-Reply-To: <20200618010805.600873-1-sashal@kernel.org>
From: Christophe Leroy <christophe.leroy@csgroup.eu>
[ Upstream commit d132443a73d7a131775df46f33000f67ed92de1e ]
In case (k_start & PAGE_MASK) doesn't equal (kstart), 'va' will never be
NULL allthough 'block' is NULL
Check the return of memblock_alloc() directly instead of
the resulting address in the loop.
Fixes: 509cd3f2b473 ("powerpc/32: Simplify KASAN init")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/7cb8ca82042bfc45a5cfe726c921cd7e7eeb12a3.1589866984.git.christophe.leroy@csgroup.eu
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/powerpc/mm/kasan/kasan_init_32.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
index cbcad369fcb2..8b15fe09b967 100644
--- a/arch/powerpc/mm/kasan/kasan_init_32.c
+++ b/arch/powerpc/mm/kasan/kasan_init_32.c
@@ -76,15 +76,14 @@ static int __init kasan_init_region(void *start, size_t size)
return ret;
block = memblock_alloc(k_end - k_start, PAGE_SIZE);
+ if (!block)
+ return -ENOMEM;
for (k_cur = k_start & PAGE_MASK; k_cur < k_end; k_cur += PAGE_SIZE) {
pmd_t *pmd = pmd_ptr_k(k_cur);
void *va = block + k_cur - k_start;
pte_t pte = pfn_pte(PHYS_PFN(__pa(va)), PAGE_KERNEL);
- if (!va)
- return -ENOMEM;
-
__set_pte_at(&init_mm, k_cur, pte_offset_kernel(pmd, k_cur), pte, 0);
}
flush_tlb_kernel_range(k_start, k_end);
--
2.25.1
next prev parent reply other threads:[~2020-06-18 2:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200618010805.600873-1-sashal@kernel.org>
2020-06-18 1:01 ` [PATCH AUTOSEL 5.7 013/388] ASoC: fsl_esai: Disable exception interrupt before scheduling tasklet Sasha Levin
2020-06-18 1:02 ` [PATCH AUTOSEL 5.7 032/388] powerpc/kasan: Fix stack overflow by increasing THREAD_SHIFT Sasha Levin
2020-06-18 1:02 ` [PATCH AUTOSEL 5.7 058/388] ps3disk: use the default segment boundary Sasha Levin
2020-06-18 1:02 ` [PATCH AUTOSEL 5.7 065/388] powerpc/book3s64/radix/tlb: Determine hugepage flush correctly Sasha Levin
2020-06-18 1:02 ` [PATCH AUTOSEL 5.7 072/388] powerpc/ptdump: Add _PAGE_COHERENT flag Sasha Levin
2020-06-18 1:02 ` [PATCH AUTOSEL 5.7 080/388] powerpc/perf/hv-24x7: Fix inconsistent output values incase multiple hv-24x7 events run Sasha Levin
2020-06-18 1:03 ` [PATCH AUTOSEL 5.7 086/388] powerpc/crashkernel: Take "mem=" option into account Sasha Levin
2020-06-18 1:03 ` [PATCH AUTOSEL 5.7 107/388] scsi: ibmvscsi: Don't send host info in adapter info MAD after LPM Sasha Levin
2020-06-18 1:03 ` [PATCH AUTOSEL 5.7 110/388] ibmvnic: Flush existing work items before device removal Sasha Levin
2020-06-18 1:04 ` [PATCH AUTOSEL 5.7 146/388] tty: hvc: Fix data abort due to race in hvc_open Sasha Levin
2020-06-18 1:05 ` [PATCH AUTOSEL 5.7 205/388] powerpc/64: Don't initialise init_task->thread.regs Sasha Levin
2020-06-18 1:05 ` [PATCH AUTOSEL 5.7 218/388] powerpc/64s/exception: Fix machine check no-loss idle wakeup Sasha Levin
2020-06-18 1:05 ` [PATCH AUTOSEL 5.7 219/388] powerpc/64s/exceptions: Machine check reconcile irq state Sasha Levin
2020-06-18 1:05 ` [PATCH AUTOSEL 5.7 220/388] powerpc/pseries/ras: Fix FWNMI_VALID off by one Sasha Levin
2020-06-18 1:05 ` [PATCH AUTOSEL 5.7 226/388] powerpc/ps3: Fix kexec shutdown hang Sasha Levin
2020-06-18 1:05 ` [PATCH AUTOSEL 5.7 249/388] powerpc/powernv: add NULL check after kzalloc Sasha Levin
2020-06-18 1:05 ` [PATCH AUTOSEL 5.7 250/388] powerpc/64s/pgtable: fix an undefined behaviour Sasha Levin
2020-06-18 1:05 ` Sasha Levin [this message]
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 277/388] powerpc/32s: Don't warn when mapping RO data ROX Sasha Levin
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 278/388] powerpc/8xx: Drop CONFIG_8xx_COPYBACK option Sasha Levin
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 287/388] KVM: PPC: Book3S HV: Ignore kmemleak false positives Sasha Levin
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 288/388] KVM: PPC: Book3S: Fix some RCU-list locks Sasha Levin
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 289/388] KVM: PPC: Book3S HV: Relax check on H_SVM_INIT_ABORT Sasha Levin
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 302/388] powerpc/4xx: Don't unmap NULL mbase Sasha Levin
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 303/388] powerpc/64s/kuap: Add missing isync to KUAP restore paths Sasha Levin
2020-06-18 1:06 ` [PATCH AUTOSEL 5.7 306/388] ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed Sasha Levin
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=20200618010805.600873-251-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).