public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Christian Lamparter <chunkeey@gmail.com>
Cc: linux-mtd@lists.infradead.org,
	Abhishek Sahu <absahu@codeaurora.org>,
	Marek Vasut <marek.vasut@gmail.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Richard Weinberger <richard@nod.at>,
	Boris Brezillon <bbrezillon@kernel.org>
Subject: Re: [PATCH] mtd: rawnand: qcom: fix memory corruption that causes panic
Date: Tue, 8 Jan 2019 12:01:21 +0100	[thread overview]
Message-ID: <20190108120121.1ebee938@xps13> (raw)
In-Reply-To: <20181223003126.1704-1-chunkeey@gmail.com>

Hi Christian,

Christian Lamparter <chunkeey@gmail.com> wrote on Sun, 23 Dec 2018
01:31:26 +0100:

> This patch fixes a memory corruption that occurred in the
> qcom-nandc driver since it was converted to nand_scan().
> 
> On boot, an affected device will panic from a NPE at a weird place:
> | Unable to handle kernel NULL pointer dereference at virtual address 0
> | pgd = (ptrval)
> | [00000000] *pgd=00000000
> | Internal error: Oops: 80000005 [#1] SMP ARM
> | CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.9 #0
> | Hardware name: Generic DT based system
> | PC is at   (null)
> | LR is at nand_block_isbad+0x90/0xa4
> | pc : [<00000000>]    lr : [<c0592240>]    psr: 80000013
> | sp : cf839d40  ip : 00000000  fp : cfae9e20
> | r10: cf815810  r9 : 00000000  r8 : 00000000
> | r7 : 00000000  r6 : 00000000  r5 : 00000001  r4 : cf815810
> | r3 : 00000000  r2 : cfae9810  r1 : ffffffff  r0 : cf815810
> | Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> | Control: 10c5387d  Table: 8020406a  DAC: 00000051
> | Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
> | [<c0592240>] (nand_block_isbad) from [<c0580a94>]
> | [<c0580a94>] (allocate_partition) from [<c05811e4>]
> | [<c05811e4>] (add_mtd_partitions) from [<c0581164>]
> | [<c0581164>] (parse_mtd_partitions) from [<c057def4>]
> | [<c057def4>] (mtd_device_parse_register) from [<c059d274>]
> | [<c059d274>] (qcom_nandc_probe) from [<c0567f00>]
> 
> The problem is that the nand_scan()'s qcom_nand_attach_chip callback
> is updating the nandc->max_cwperpage from 1 to 4. This causes the
> sg_init_table of clear_bam_transaction() in the driver's
> qcom_nandc_block_bad() to memset much more than what was initially
> allocated by alloc_bam_transaction().
> 
> This patch restores the old behavior by reallocating the shared bam
> transaction alloc_bam_transaction() after the chip was identified,
> but before mtd_device_parse_register() (which is an alias for
> mtd_device_register() - see panic) gets called. This fixes the
> corruption and the driver is working again.
> 
> Cc: stable@vger.kernel.org
> Fixes: 6a3cec64f18c ("mtd: rawnand: qcom: convert driver to nand_scan()")
> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
> ---

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

  reply	other threads:[~2019-01-08 11:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-23  0:31 [PATCH] mtd: rawnand: qcom: fix memory corruption that causes panic Christian Lamparter
2019-01-08 11:01 ` Miquel Raynal [this message]
2019-01-08 16:14 ` Boris Brezillon
  -- strict thread matches above, loose matches on Subject: below --
2022-04-14  5:39 [PATCH] " Md Sadre Alam
2022-04-14  8:15 ` Miquel Raynal
     [not found]   ` <DM6PR02MB580382FA47C4884AFC1A98D0FAEF9@DM6PR02MB5803.namprd02.prod.outlook.com>
2022-04-14 12:20     ` FW: " Md Sadre Alam
2022-04-14 12:42       ` Miquel Raynal
2022-04-14 14:39         ` Manivannan Sadhasivam
2022-04-14 14:59           ` Miquel Raynal
2022-04-14 15:31             ` Md Sadre Alam

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=20190108120121.1ebee938@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=absahu@codeaurora.org \
    --cc=bbrezillon@kernel.org \
    --cc=chunkeey@gmail.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    /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