From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Md Sadre Alam <quic_mdalam@quicinc.com>,
mani@kernel.org, miquel.raynal@bootlin.com, richard@nod.at,
vigneshr@ti.com, linux-mtd@lists.infradead.org,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: konrad.dybcio@somainline.org, quic_srichara@quicinc.com,
stable@vger.kernel.org
Subject: Re: [PATCH V5] mtd: rawnand: qcom: fix memory corruption that causes panic
Date: Thu, 21 Apr 2022 09:35:27 +0200 [thread overview]
Message-ID: <20220421073527.71690-1-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <1650268107-5363-1-git-send-email-quic_mdalam@quicinc.com>
On Mon, 2022-04-18 at 07:48:27 UTC, Md Sadre Alam wrote:
> This patch fixes a memory corruption that occurred in the
> nand_scan() path for Hynix nand device.
>
> On boot, for Hynix nand device will panic at a weird place:
> | Unable to handle kernel NULL pointer dereference at virtual
> address 00000070
> | [00000070] *pgd=00000000
> | Internal error: Oops: 5 [#1] PREEMPT SMP ARM
> | Modules linked in:
> | CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.17.0-01473-g13ae1769cfb0
> #38
> | Hardware name: Generic DT based system
> | PC is at nandc_set_reg+0x8/0x1c
> | LR is at qcom_nandc_command+0x20c/0x5d0
> | pc : [<c088b74c>] lr : [<c088d9c8>] psr: 00000113
> | sp : c14adc50 ip : c14ee208 fp : c0cc970c
> | r10: 000000a3 r9 : 00000000 r8 : 00000040
> | r7 : c16f6a00 r6 : 00000090 r5 : 00000004 r4 :c14ee040
> | r3 : 00000000 r2 : 0000000b r1 : 00000000 r0 :c14ee040
> | Flags: nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
> | Control: 10c5387d Table: 8020406a DAC: 00000051
> | Register r0 information: slab kmalloc-2k start c14ee000 pointer offset
> 64 size 2048
> | Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
> | nandc_set_reg from qcom_nandc_command+0x20c/0x5d0
> | qcom_nandc_command from nand_readid_op+0x198/0x1e8
> | nand_readid_op from hynix_nand_has_valid_jedecid+0x30/0x78
> | hynix_nand_has_valid_jedecid from hynix_nand_init+0xb8/0x454
> | hynix_nand_init from nand_scan_with_ids+0xa30/0x14a8
> | nand_scan_with_ids from qcom_nandc_probe+0x648/0x7b0
> | qcom_nandc_probe from platform_probe+0x58/0xac
>
> The problem is that the nand_scan()'s qcom_nand_attach_chip callback
> is updating the nandc->max_cwperpage from 1 to 4 or 8 based on page size.
> This causes the sg_init_table of clear_bam_transaction() in the driver's
> qcom_nandc_command() to memset much more than what was initially
> allocated by alloc_bam_transaction().
>
> This patch will update nandc->max_cwperpage 1 to 4 or 8 based on page
> size in qcom_nand_attach_chip call back after freeing the previously
> allocated memory for bam txn as per nandc->max_cwperpage = 1 and then
> again allocating bam txn as per nandc->max_cwperpage = 4 or 8 based on
> page size in qcom_nand_attach_chip call back itself.
>
> Cc: stable@vger.kernel.org
> Fixes: 6a3cec64f18c ("mtd: rawnand: qcom: convert driver to nand_scan()")
> Reported-by: Konrad Dybcio <konrad.dybcio@somainline.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Co-developed-by: Sricharan R <quic_srichara@quicinc.com>
> Signed-off-by: Sricharan R <quic_srichara@quicinc.com>
> Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.
Miquel
prev parent reply other threads:[~2022-04-21 7:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-18 7:48 [PATCH V5] mtd: rawnand: qcom: fix memory corruption that causes panic Md Sadre Alam
2022-04-21 7:35 ` Miquel Raynal [this message]
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=20220421073527.71690-1-miquel.raynal@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=konrad.dybcio@somainline.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mani@kernel.org \
--cc=quic_mdalam@quicinc.com \
--cc=quic_srichara@quicinc.com \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.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 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).