<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/mtd, branch v4.9.100</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>mtd: cfi: cmdset_0002: Do not allow read/write to suspend erase block.</title>
<updated>2018-05-01T22:13:07+00:00</updated>
<author>
<name>Joakim Tjernlund</name>
<email>joakim.tjernlund@infinera.com</email>
</author>
<published>2018-03-01T13:39:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f48bbbae0421bdf002f3fb565f1308695b2560a6'/>
<id>f48bbbae0421bdf002f3fb565f1308695b2560a6</id>
<content type='text'>
commit 7b70eb14392a7cf505f9b358d06c33b5af73d1e7 upstream.

Currently it is possible to read and/or write to suspend EB's.
Writing /dev/mtdX or /dev/mtdblockX from several processes may
break the flash state machine.

Taken from cfi_cmdset_0001 driver.

Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 7b70eb14392a7cf505f9b358d06c33b5af73d1e7 upstream.

Currently it is possible to read and/or write to suspend EB's.
Writing /dev/mtdX or /dev/mtdblockX from several processes may
break the flash state machine.

Taken from cfi_cmdset_0001 driver.

Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: cfi: cmdset_0001: Workaround Micron Erase suspend bug.</title>
<updated>2018-05-01T22:13:07+00:00</updated>
<author>
<name>Joakim Tjernlund</name>
<email>joakim.tjernlund@transmode.se</email>
</author>
<published>2018-03-01T13:39:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0d8f3797ed5d7204c0238825fe434a949822c60e'/>
<id>0d8f3797ed5d7204c0238825fe434a949822c60e</id>
<content type='text'>
commit 46a16a2283f9e678a4e26829175e0c37a5191860 upstream.

Some Micron chips does not work well wrt Erase suspend for
boot blocks. This avoids the issue by not allowing Erase suspend
for the boot blocks for the 28F00AP30(1GBit) chip.

Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 46a16a2283f9e678a4e26829175e0c37a5191860 upstream.

Some Micron chips does not work well wrt Erase suspend for
boot blocks. This avoids the issue by not allowing Erase suspend
for the boot blocks for the 28F00AP30(1GBit) chip.

Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: cfi: cmdset_0001: Do not allow read/write to suspend erase block.</title>
<updated>2018-05-01T22:13:07+00:00</updated>
<author>
<name>Joakim Tjernlund</name>
<email>joakim.tjernlund@transmode.se</email>
</author>
<published>2018-03-01T13:39:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=54a21fe4d8bbb0e82ac75e55bb8d46c4c3326ee4'/>
<id>54a21fe4d8bbb0e82ac75e55bb8d46c4c3326ee4</id>
<content type='text'>
commit 6510bbc88e3258631831ade49033537081950605 upstream.

Currently it is possible to read and/or write to suspend EB's.
Writing /dev/mtdX or /dev/mtdblockX from several processes may
break the flash state machine.

Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 6510bbc88e3258631831ade49033537081950605 upstream.

Currently it is possible to read and/or write to suspend EB's.
Writing /dev/mtdX or /dev/mtdblockX from several processes may
break the flash state machine.

Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>ubi: Reject MLC NAND</title>
<updated>2018-04-24T07:34:09+00:00</updated>
<author>
<name>Richard Weinberger</name>
<email>richard@nod.at</email>
</author>
<published>2018-03-03T10:45:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c64c4c81aed52fc84be225ce47863a41eb4f7bb6'/>
<id>c64c4c81aed52fc84be225ce47863a41eb4f7bb6</id>
<content type='text'>
commit b5094b7f135be34630e3ea8a98fa215715d0f29d upstream.

While UBI and UBIFS seem to work at first sight with MLC NAND, you will
most likely lose all your data upon a power-cut or due to read/write
disturb.
In order to protect users from bad surprises, refuse to attach to MLC
NAND.

Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Acked-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Acked-by: Artem Bityutskiy &lt;dedekind1@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit b5094b7f135be34630e3ea8a98fa215715d0f29d upstream.

While UBI and UBIFS seem to work at first sight with MLC NAND, you will
most likely lose all your data upon a power-cut or due to read/write
disturb.
In order to protect users from bad surprises, refuse to attach to MLC
NAND.

Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Acked-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Acked-by: Artem Bityutskiy &lt;dedekind1@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>ubi: Fix error for write access</title>
<updated>2018-04-24T07:34:09+00:00</updated>
<author>
<name>Romain Izard</name>
<email>romain.izard.pro@gmail.com</email>
</author>
<published>2018-01-29T10:18:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=434a1dd2c0e4f6af3fa4ca9cc3e88bbf07b8f41c'/>
<id>434a1dd2c0e4f6af3fa4ca9cc3e88bbf07b8f41c</id>
<content type='text'>
commit 78a8dfbabbece22bee58ac4cb26cab10e7a19c5d upstream.

When opening a device with write access, ubiblock_open returns an error
code. Currently, this error code is -EPERM, but this is not the right
value.

The open function for other block devices returns -EROFS when opening
read-only devices with FMODE_WRITE set. When used with dm-verity, the
veritysetup userspace tool is expecting EROFS, and refuses to use the
ubiblock device.

Use -EROFS for ubiblock as well. As a result, veritysetup accepts the
ubiblock device as valid.

Cc: stable@vger.kernel.org
Fixes: 9d54c8a33eec (UBI: R/O block driver on top of UBI volumes)
Signed-off-by: Romain Izard &lt;romain.izard.pro@gmail.com&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 78a8dfbabbece22bee58ac4cb26cab10e7a19c5d upstream.

When opening a device with write access, ubiblock_open returns an error
code. Currently, this error code is -EPERM, but this is not the right
value.

The open function for other block devices returns -EROFS when opening
read-only devices with FMODE_WRITE set. When used with dm-verity, the
veritysetup userspace tool is expecting EROFS, and refuses to use the
ubiblock device.

Use -EROFS for ubiblock as well. As a result, veritysetup accepts the
ubiblock device as valid.

Cc: stable@vger.kernel.org
Fixes: 9d54c8a33eec (UBI: R/O block driver on top of UBI volumes)
Signed-off-by: Romain Izard &lt;romain.izard.pro@gmail.com&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>ubi: fastmap: Don't flush fastmap work on detach</title>
<updated>2018-04-24T07:34:09+00:00</updated>
<author>
<name>Richard Weinberger</name>
<email>richard@nod.at</email>
</author>
<published>2018-01-17T22:15:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=00f308c0eea4d2f7bc5bb3b9d0947f2219f53760'/>
<id>00f308c0eea4d2f7bc5bb3b9d0947f2219f53760</id>
<content type='text'>
commit 29b7a6fa1ec07e8480b0d9caf635a4498a438bf4 upstream.

At this point UBI volumes have already been free()'ed and fastmap can no
longer access these data structures.

Reported-by: Martin Townsend &lt;mtownsend1973@gmail.com&gt;
Fixes: 74cdaf24004a ("UBI: Fastmap: Fix memory leaks while closing the WL sub-system")
Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 29b7a6fa1ec07e8480b0d9caf635a4498a438bf4 upstream.

At this point UBI volumes have already been free()'ed and fastmap can no
longer access these data structures.

Reported-by: Martin Townsend &lt;mtownsend1973@gmail.com&gt;
Fixes: 74cdaf24004a ("UBI: Fastmap: Fix memory leaks while closing the WL sub-system")
Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: mtd_oobtest: Handle bitflips during reads</title>
<updated>2018-04-13T17:48:31+00:00</updated>
<author>
<name>Miquel Raynal</name>
<email>miquel.raynal@free-electrons.com</email>
</author>
<published>2018-01-11T20:39:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f6df92f22be342118d2eedbbcc5ca1953aab1a13'/>
<id>f6df92f22be342118d2eedbbcc5ca1953aab1a13</id>
<content type='text'>
[ Upstream commit 12663b442e5ac5aa3d6097cd3f287c71ba46d26e ]

Reads from NAND devices usually trigger bitflips, this is an expected
behavior. While bitflips are under a given threshold, the MTD core
returns 0. However, when the number of corrected bitflips is above this
same threshold, -EUCLEAN is returned to inform the upper layer that this
block is slightly dying and soon the ECC engine will be overtaken so
actions should be taken to move the data out of it.

This particular condition should not be treated like an error and the
test should continue.

Signed-off-by: Miquel Raynal &lt;miquel.raynal@free-electrons.com&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 12663b442e5ac5aa3d6097cd3f287c71ba46d26e ]

Reads from NAND devices usually trigger bitflips, this is an expected
behavior. While bitflips are under a given threshold, the MTD core
returns 0. However, when the number of corrected bitflips is above this
same threshold, -EUCLEAN is returned to inform the upper layer that this
block is slightly dying and soon the ECC engine will be overtaken so
actions should be taken to move the data out of it.

This particular condition should not be treated like an error and the
test should continue.

Signed-off-by: Miquel Raynal &lt;miquel.raynal@free-electrons.com&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: nand: check ecc-&gt;total sanity in nand_scan_tail</title>
<updated>2018-04-13T17:48:15+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>yamada.masahiro@socionext.com</email>
</author>
<published>2017-05-25T04:50:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2d0eb3f188e1de0fadaca05b413ea44c217fa7dd'/>
<id>2d0eb3f188e1de0fadaca05b413ea44c217fa7dd</id>
<content type='text'>
[ Upstream commit 79e0348c4e24fd1affdcf055e0269755580e0fcc ]

Drivers are supposed to set correct ecc-&gt;{size,strength,bytes} before
calling nand_scan_tail(), but it does not complain about ecc-&gt;total
bigger than oobsize.

In this case, chip-&gt;scan_bbt() crashes due to memory corruption, but
it is hard to debug.  It would be kind to fail it earlier with a clear
message.

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 79e0348c4e24fd1affdcf055e0269755580e0fcc ]

Drivers are supposed to set correct ecc-&gt;{size,strength,bytes} before
calling nand_scan_tail(), but it does not complain about ecc-&gt;total
bigger than oobsize.

In this case, chip-&gt;scan_bbt() crashes due to memory corruption, but
it is hard to debug.  It would be kind to fail it earlier with a clear
message.

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: nand: gpmi: Fix gpmi_nand_init() error path</title>
<updated>2018-04-13T17:48:15+00:00</updated>
<author>
<name>Boris Brezillon</name>
<email>boris.brezillon@free-electrons.com</email>
</author>
<published>2017-04-10T08:35:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8bf4782062a0a0f6b9ca68f3f6625e1a5fe455fc'/>
<id>8bf4782062a0a0f6b9ca68f3f6625e1a5fe455fc</id>
<content type='text'>
[ Upstream commit 4d02423e9afe6c46142ce98bbcaf5167316dbfbf ]

The GPMI driver is wrongly assuming that nand_release() can safely be
called on an uninitialized/unregistered NAND device.

Add a new err_nand_cleanup label in the error path and only execute if
nand_scan_tail() succeeded.

Note that we now call nand_cleanup() instead of nand_release()
(nand_release() is actually grouping the mtd_device_unregister() and
nand_cleanup() in one call) because there's no point in trying to
unregister a device that has never been registered.

Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Reviewed-by: Marek Vasut &lt;marek.vasut@gmail.com&gt;
Acked-by: Han Xu &lt;han.xu@nxp.com&gt;
Reviewed-by: Marek Vasut &lt;marek.vasut@gmail.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 4d02423e9afe6c46142ce98bbcaf5167316dbfbf ]

The GPMI driver is wrongly assuming that nand_release() can safely be
called on an uninitialized/unregistered NAND device.

Add a new err_nand_cleanup label in the error path and only execute if
nand_scan_tail() succeeded.

Note that we now call nand_cleanup() instead of nand_release()
(nand_release() is actually grouping the mtd_device_unregister() and
nand_cleanup() in one call) because there's no point in trying to
unregister a device that has never been registered.

Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Reviewed-by: Marek Vasut &lt;marek.vasut@gmail.com&gt;
Acked-by: Han Xu &lt;han.xu@nxp.com&gt;
Reviewed-by: Marek Vasut &lt;marek.vasut@gmail.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ubi: fastmap: Fix slab corruption</title>
<updated>2018-04-13T17:47:52+00:00</updated>
<author>
<name>Rabin Vincent</name>
<email>rabinv@axis.com</email>
</author>
<published>2017-04-03T11:44:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0d84e3b5a64ac3405a103e579d8a903fad916798'/>
<id>0d84e3b5a64ac3405a103e579d8a903fad916798</id>
<content type='text'>
[ Upstream commit 8a1435880f452430b41374d27ac4a33e7bd381ea ]

Booting with UBI fastmap and SLUB debugging enabled results in the
following splats.  The problem is that ubi_scan_fastmap() moves the
fastmap blocks from the scan_ai (allocated in scan_fast()) to the ai
allocated in ubi_attach().  This results in two problems:

 - When the scan_ai is freed, aebs which were allocated from its slab
   cache are still in use.

 - When the other ai is being destroyed in destroy_ai(), the
   arguments to kmem_cache_free() call are incorrect since aebs on its
   -&gt;fastmap list were allocated with a slab cache from a differnt ai.

Fix this by making a copy of the aebs in ubi_scan_fastmap() instead of
moving them.

 =============================================================================
 BUG ubi_aeb_slab_cache (Not tainted): Objects remaining in ubi_aeb_slab_cache on __kmem_cache_shutdown()
 -----------------------------------------------------------------------------

 INFO: Slab 0xbfd2da3c objects=17 used=1 fp=0xb33d7748 flags=0x40000080
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B           4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;8026c47c&gt;] (slab_err+0x78/0x88)
 [&lt;8026c47c&gt;] (slab_err) from [&lt;802735bc&gt;] (__kmem_cache_shutdown+0x180/0x3e0)
 [&lt;802735bc&gt;] (__kmem_cache_shutdown) from [&lt;8024e13c&gt;] (shutdown_cache+0x1c/0x60)
 [&lt;8024e13c&gt;] (shutdown_cache) from [&lt;8024ed64&gt;] (kmem_cache_destroy+0x19c/0x20c)
 [&lt;8024ed64&gt;] (kmem_cache_destroy) from [&lt;8057cc14&gt;] (destroy_ai+0x1dc/0x1e8)
 [&lt;8057cc14&gt;] (destroy_ai) from [&lt;8057f04c&gt;] (ubi_attach+0x3f4/0x450)
 [&lt;8057f04c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 INFO: Object 0xb33d7e88 @offset=3720
 INFO: Allocated in scan_peb+0x608/0x81c age=72 cpu=1 pid=118
 	kmem_cache_alloc+0x3b0/0x43c
 	scan_peb+0x608/0x81c
 	ubi_attach+0x124/0x450
 	ubi_attach_mtd_dev+0x60c/0xff8
 	ctrl_cdev_ioctl+0x110/0x2b8
 	do_vfs_ioctl+0xac/0xa00
 	SyS_ioctl+0x3c/0x64
 	ret_fast_syscall+0x0/0x1c
 kmem_cache_destroy ubi_aeb_slab_cache: Slab cache still has objects
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B           4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;8024ed80&gt;] (kmem_cache_destroy+0x1b8/0x20c)
 [&lt;8024ed80&gt;] (kmem_cache_destroy) from [&lt;8057cc14&gt;] (destroy_ai+0x1dc/0x1e8)
 [&lt;8057cc14&gt;] (destroy_ai) from [&lt;8057f04c&gt;] (ubi_attach+0x3f4/0x450)
 [&lt;8057f04c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 cache_from_obj: Wrong slab cache. ubi_aeb_slab_cache but object is from ubi_aeb_slab_cache
 ------------[ cut here ]------------
 WARNING: CPU: 1 PID: 118 at mm/slab.h:354 kmem_cache_free+0x39c/0x450
 Modules linked in:
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B           4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;80120e40&gt;] (__warn+0xf4/0x10c)
 [&lt;80120e40&gt;] (__warn) from [&lt;80120f20&gt;] (warn_slowpath_null+0x28/0x30)
 [&lt;80120f20&gt;] (warn_slowpath_null) from [&lt;80271fe0&gt;] (kmem_cache_free+0x39c/0x450)
 [&lt;80271fe0&gt;] (kmem_cache_free) from [&lt;8057cb88&gt;] (destroy_ai+0x150/0x1e8)
 [&lt;8057cb88&gt;] (destroy_ai) from [&lt;8057ef1c&gt;] (ubi_attach+0x2c4/0x450)
 [&lt;8057ef1c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 ---[ end trace 2bd8396277fd0a0b ]---
 =============================================================================
 BUG ubi_aeb_slab_cache (Tainted: G    B   W      ): page slab pointer corrupt.
 -----------------------------------------------------------------------------

 INFO: Allocated in scan_peb+0x608/0x81c age=104 cpu=1 pid=118
 	kmem_cache_alloc+0x3b0/0x43c
 	scan_peb+0x608/0x81c
 	ubi_attach+0x124/0x450
 	ubi_attach_mtd_dev+0x60c/0xff8
 	ctrl_cdev_ioctl+0x110/0x2b8
 	do_vfs_ioctl+0xac/0xa00
 	SyS_ioctl+0x3c/0x64
 	ret_fast_syscall+0x0/0x1c
 INFO: Slab 0xbfd2da3c objects=17 used=1 fp=0xb33d7748 flags=0x40000081
 INFO: Object 0xb33d7e88 @offset=3720 fp=0xb33d7da0

 Redzone b33d7e80: cc cc cc cc cc cc cc cc                          ........
 Object b33d7e88: 02 00 00 00 01 00 00 00 00 f0 ff 7f ff ff ff ff  ................
 Object b33d7e98: 00 00 00 00 00 00 00 00 bd 16 00 00 00 00 00 00  ................
 Object b33d7ea8: 00 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00  ................
 Redzone b33d7eb8: cc cc cc cc                                      ....
 Padding b33d7f60: 5a 5a 5a 5a 5a 5a 5a 5a                          ZZZZZZZZ
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B   W       4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;80271770&gt;] (free_debug_processing+0x320/0x3c4)
 [&lt;80271770&gt;] (free_debug_processing) from [&lt;80271ad0&gt;] (__slab_free+0x2bc/0x430)
 [&lt;80271ad0&gt;] (__slab_free) from [&lt;80272024&gt;] (kmem_cache_free+0x3e0/0x450)
 [&lt;80272024&gt;] (kmem_cache_free) from [&lt;8057cb88&gt;] (destroy_ai+0x150/0x1e8)
 [&lt;8057cb88&gt;] (destroy_ai) from [&lt;8057ef1c&gt;] (ubi_attach+0x2c4/0x450)
 [&lt;8057ef1c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 FIX ubi_aeb_slab_cache: Object at 0xb33d7e88 not freed

Signed-off-by: Rabin Vincent &lt;rabinv@axis.com&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 8a1435880f452430b41374d27ac4a33e7bd381ea ]

Booting with UBI fastmap and SLUB debugging enabled results in the
following splats.  The problem is that ubi_scan_fastmap() moves the
fastmap blocks from the scan_ai (allocated in scan_fast()) to the ai
allocated in ubi_attach().  This results in two problems:

 - When the scan_ai is freed, aebs which were allocated from its slab
   cache are still in use.

 - When the other ai is being destroyed in destroy_ai(), the
   arguments to kmem_cache_free() call are incorrect since aebs on its
   -&gt;fastmap list were allocated with a slab cache from a differnt ai.

Fix this by making a copy of the aebs in ubi_scan_fastmap() instead of
moving them.

 =============================================================================
 BUG ubi_aeb_slab_cache (Not tainted): Objects remaining in ubi_aeb_slab_cache on __kmem_cache_shutdown()
 -----------------------------------------------------------------------------

 INFO: Slab 0xbfd2da3c objects=17 used=1 fp=0xb33d7748 flags=0x40000080
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B           4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;8026c47c&gt;] (slab_err+0x78/0x88)
 [&lt;8026c47c&gt;] (slab_err) from [&lt;802735bc&gt;] (__kmem_cache_shutdown+0x180/0x3e0)
 [&lt;802735bc&gt;] (__kmem_cache_shutdown) from [&lt;8024e13c&gt;] (shutdown_cache+0x1c/0x60)
 [&lt;8024e13c&gt;] (shutdown_cache) from [&lt;8024ed64&gt;] (kmem_cache_destroy+0x19c/0x20c)
 [&lt;8024ed64&gt;] (kmem_cache_destroy) from [&lt;8057cc14&gt;] (destroy_ai+0x1dc/0x1e8)
 [&lt;8057cc14&gt;] (destroy_ai) from [&lt;8057f04c&gt;] (ubi_attach+0x3f4/0x450)
 [&lt;8057f04c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 INFO: Object 0xb33d7e88 @offset=3720
 INFO: Allocated in scan_peb+0x608/0x81c age=72 cpu=1 pid=118
 	kmem_cache_alloc+0x3b0/0x43c
 	scan_peb+0x608/0x81c
 	ubi_attach+0x124/0x450
 	ubi_attach_mtd_dev+0x60c/0xff8
 	ctrl_cdev_ioctl+0x110/0x2b8
 	do_vfs_ioctl+0xac/0xa00
 	SyS_ioctl+0x3c/0x64
 	ret_fast_syscall+0x0/0x1c
 kmem_cache_destroy ubi_aeb_slab_cache: Slab cache still has objects
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B           4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;8024ed80&gt;] (kmem_cache_destroy+0x1b8/0x20c)
 [&lt;8024ed80&gt;] (kmem_cache_destroy) from [&lt;8057cc14&gt;] (destroy_ai+0x1dc/0x1e8)
 [&lt;8057cc14&gt;] (destroy_ai) from [&lt;8057f04c&gt;] (ubi_attach+0x3f4/0x450)
 [&lt;8057f04c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 cache_from_obj: Wrong slab cache. ubi_aeb_slab_cache but object is from ubi_aeb_slab_cache
 ------------[ cut here ]------------
 WARNING: CPU: 1 PID: 118 at mm/slab.h:354 kmem_cache_free+0x39c/0x450
 Modules linked in:
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B           4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;80120e40&gt;] (__warn+0xf4/0x10c)
 [&lt;80120e40&gt;] (__warn) from [&lt;80120f20&gt;] (warn_slowpath_null+0x28/0x30)
 [&lt;80120f20&gt;] (warn_slowpath_null) from [&lt;80271fe0&gt;] (kmem_cache_free+0x39c/0x450)
 [&lt;80271fe0&gt;] (kmem_cache_free) from [&lt;8057cb88&gt;] (destroy_ai+0x150/0x1e8)
 [&lt;8057cb88&gt;] (destroy_ai) from [&lt;8057ef1c&gt;] (ubi_attach+0x2c4/0x450)
 [&lt;8057ef1c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 ---[ end trace 2bd8396277fd0a0b ]---
 =============================================================================
 BUG ubi_aeb_slab_cache (Tainted: G    B   W      ): page slab pointer corrupt.
 -----------------------------------------------------------------------------

 INFO: Allocated in scan_peb+0x608/0x81c age=104 cpu=1 pid=118
 	kmem_cache_alloc+0x3b0/0x43c
 	scan_peb+0x608/0x81c
 	ubi_attach+0x124/0x450
 	ubi_attach_mtd_dev+0x60c/0xff8
 	ctrl_cdev_ioctl+0x110/0x2b8
 	do_vfs_ioctl+0xac/0xa00
 	SyS_ioctl+0x3c/0x64
 	ret_fast_syscall+0x0/0x1c
 INFO: Slab 0xbfd2da3c objects=17 used=1 fp=0xb33d7748 flags=0x40000081
 INFO: Object 0xb33d7e88 @offset=3720 fp=0xb33d7da0

 Redzone b33d7e80: cc cc cc cc cc cc cc cc                          ........
 Object b33d7e88: 02 00 00 00 01 00 00 00 00 f0 ff 7f ff ff ff ff  ................
 Object b33d7e98: 00 00 00 00 00 00 00 00 bd 16 00 00 00 00 00 00  ................
 Object b33d7ea8: 00 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00  ................
 Redzone b33d7eb8: cc cc cc cc                                      ....
 Padding b33d7f60: 5a 5a 5a 5a 5a 5a 5a 5a                          ZZZZZZZZ
 CPU: 1 PID: 118 Comm: ubiattach Tainted: G    B   W       4.9.15 #3
 [&lt;80111910&gt;] (unwind_backtrace) from [&lt;8010d498&gt;] (show_stack+0x18/0x1c)
 [&lt;8010d498&gt;] (show_stack) from [&lt;804a3274&gt;] (dump_stack+0xb4/0xe0)
 [&lt;804a3274&gt;] (dump_stack) from [&lt;80271770&gt;] (free_debug_processing+0x320/0x3c4)
 [&lt;80271770&gt;] (free_debug_processing) from [&lt;80271ad0&gt;] (__slab_free+0x2bc/0x430)
 [&lt;80271ad0&gt;] (__slab_free) from [&lt;80272024&gt;] (kmem_cache_free+0x3e0/0x450)
 [&lt;80272024&gt;] (kmem_cache_free) from [&lt;8057cb88&gt;] (destroy_ai+0x150/0x1e8)
 [&lt;8057cb88&gt;] (destroy_ai) from [&lt;8057ef1c&gt;] (ubi_attach+0x2c4/0x450)
 [&lt;8057ef1c&gt;] (ubi_attach) from [&lt;8056fe70&gt;] (ubi_attach_mtd_dev+0x60c/0xff8)
 [&lt;8056fe70&gt;] (ubi_attach_mtd_dev) from [&lt;80571d78&gt;] (ctrl_cdev_ioctl+0x110/0x2b8)
 [&lt;80571d78&gt;] (ctrl_cdev_ioctl) from [&lt;8029c77c&gt;] (do_vfs_ioctl+0xac/0xa00)
 [&lt;8029c77c&gt;] (do_vfs_ioctl) from [&lt;8029d10c&gt;] (SyS_ioctl+0x3c/0x64)
 [&lt;8029d10c&gt;] (SyS_ioctl) from [&lt;80108860&gt;] (ret_fast_syscall+0x0/0x1c)
 FIX ubi_aeb_slab_cache: Object at 0xb33d7e88 not freed

Signed-off-by: Rabin Vincent &lt;rabinv@axis.com&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
