<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/mtd/mtdchar.c, branch linux-4.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.9.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.9.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-05-22T08:40:23Z</updated>
<entry>
<title>mtd: require write permissions for locking and badblock ioctls</title>
<updated>2021-05-22T08:40:23Z</updated>
<author>
<name>Michael Walle</name>
</author>
<published>2021-03-03T15:57:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9625b00cac6630479c0ff4b9fafa88bee636e1f0'/>
<id>urn:sha1:9625b00cac6630479c0ff4b9fafa88bee636e1f0</id>
<content type='text'>
[ Upstream commit 1e97743fd180981bef5f01402342bb54bf1c6366 ]

MEMLOCK, MEMUNLOCK and OTPLOCK modify protection bits. Thus require
write permission. Depending on the hardware MEMLOCK might even be
write-once, e.g. for SPI-NOR flashes with their WP# tied to GND. OTPLOCK
is always write-once.

MEMSETBADBLOCK modifies the bad block table.

Fixes: f7e6b19bc764 ("mtd: properly check all write ioctls for permissions")
Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Acked-by: Rafał Miłecki &lt;rafal@milecki.pl&gt;
Acked-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210303155735.25887-1-michael@walle.cc
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>mtd: properly check all write ioctls for permissions</title>
<updated>2020-08-21T09:01:54Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
</author>
<published>2020-07-16T11:53:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=583d42400532fbd6228b0254d7c732b771e4750d'/>
<id>urn:sha1:583d42400532fbd6228b0254d7c732b771e4750d</id>
<content type='text'>
commit f7e6b19bc76471ba03725fe58e0c218a3d6266c3 upstream.

When doing a "write" ioctl call, properly check that we have permissions
to do so before copying anything from userspace or anything else so we
can "fail fast".  This includes also covering the MEMWRITE ioctl which
previously missed checking for this.

Cc: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Cc: Richard Weinberger &lt;richard@nod.at&gt;
Cc: Vignesh Raghavendra &lt;vigneshr@ti.com&gt;
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
[rw: Fixed locking issue]
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtdchar: fix overflows in adjustment of `count`</title>
<updated>2018-09-26T06:36:37Z</updated>
<author>
<name>Jann Horn</name>
</author>
<published>2018-07-07T03:37:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=23bd97eaebc55d5eef9d3cd41e3bd6189a0e9dd6'/>
<id>urn:sha1:23bd97eaebc55d5eef9d3cd41e3bd6189a0e9dd6</id>
<content type='text'>
[ Upstream commit 6c6bc9ea84d0008024606bf5ba10519e20d851bf ]

The first checks in mtdchar_read() and mtdchar_write() attempt to limit
`count` such that `*ppos + count &lt;= mtd-&gt;size`. However, they ignore the
possibility of `*ppos &gt; mtd-&gt;size`, allowing the calculation of `count` to
wrap around. `mtdchar_lseek()` prevents seeking beyond mtd-&gt;size, but the
pread/pwrite syscalls bypass this.

I haven't found any codepath on which this actually causes dangerous
behavior, but it seems like a sensible change anyway.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jann Horn &lt;jannh@google.com&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.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>
</entry>
<entry>
<title>mtdchar: fix usage of mtd_ooblayout_ecc()</title>
<updated>2018-03-28T16:39:23Z</updated>
<author>
<name>OuYang ZhiZhong</name>
</author>
<published>2018-03-11T07:59:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9eab80eded7bb767f2f0770b3380e6affd3dc2c5'/>
<id>urn:sha1:9eab80eded7bb767f2f0770b3380e6affd3dc2c5</id>
<content type='text'>
commit 6de564939e14327148e31ddcf769e34105176447 upstream.

Section was not properly computed. The value of OOB region definition is
always ECC section 0 information in the OOB area, but we want to get all
the ECC bytes information, so we should call
mtd_ooblayout_ecc(mtd, section++, &amp;oobregion) until it returns -ERANGE.

Fixes: c2b78452a9db ("mtd: use mtd_ooblayout_xxx() helpers where appropriate")
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: OuYang ZhiZhong &lt;ouyzz@yealink.com&gt;
Signed-off-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: kill the nand_ecclayout struct</title>
<updated>2016-05-05T21:51:51Z</updated>
<author>
<name>Boris Brezillon</name>
</author>
<published>2016-02-04T09:16:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=aab616e31d1c7ec3726f7f5cbdaaec98759ebe93'/>
<id>urn:sha1:aab616e31d1c7ec3726f7f5cbdaaec98759ebe93</id>
<content type='text'>
Now that all MTD drivers have moved to the mtd_ooblayout_ops model we can
safely remove the struct nand_ecclayout definition, and all the remaining
places where it was still used.

Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>mtd: create an mtd_ooblayout_ops struct to ease ECC layout definition</title>
<updated>2016-04-19T20:05:55Z</updated>
<author>
<name>Boris Brezillon</name>
</author>
<published>2016-02-03T18:01:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=adbbc3bc827eb1f43a932d783f09ba55c8ec8379'/>
<id>urn:sha1:adbbc3bc827eb1f43a932d783f09ba55c8ec8379</id>
<content type='text'>
ECC layout definitions are currently exposed using the nand_ecclayout
struct which embeds oobfree and eccpos arrays with predefined size.
This approach was acceptable when NAND chips were providing relatively
small OOB regions, but MLC and TLC now provide OOB regions of several
hundreds of bytes, which implies a non negligible overhead for everybody
even those who only need to support legacy NANDs.

Create an mtd_ooblayout_ops interface providing the same functionality
(expose the ECC and oobfree layout) without the need for this huge
structure.

The mtd-&gt;ecclayout is now deprecated and should be replaced by the
equivalent mtd_ooblayout_ops. In the meantime we provide a wrapper around
the -&gt;ecclayout field to ease migration to this new model.

Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>mtd: use mtd_ooblayout_xxx() helpers where appropriate</title>
<updated>2016-04-19T20:05:48Z</updated>
<author>
<name>Boris Brezillon</name>
</author>
<published>2016-02-03T19:10:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c2b78452a9db438d592bf72af7bb2ae3062cb922'/>
<id>urn:sha1:c2b78452a9db438d592bf72af7bb2ae3062cb922</id>
<content type='text'>
The mtd_ooblayout_xxx() helper functions have been added to avoid direct
accesses to the ecclayout field, and thus ease for future reworks.
Use these helpers in all places where the oobfree[] and eccpos[] arrays
where directly accessed.

Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>mtd: provide proper 32/64-bit compat_ioctl() support for BLKPG</title>
<updated>2015-09-29T20:37:04Z</updated>
<author>
<name>Brian Norris</name>
</author>
<published>2015-09-21T20:26:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=53bb724f94f57b67213e08a4c155c8c5eb74c644'/>
<id>urn:sha1:53bb724f94f57b67213e08a4c155c8c5eb74c644</id>
<content type='text'>
After a bit of poking around wondering why my 32-bit user-space can't
seem to send a proper ioctl(BLKPG) to an MTD on my 64-bit kernel
(ARM64), I noticed that struct blkpg_ioctl_arg is actually pretty
unsuitable for use in the ioctl() ABI, due to its use of raw pointers,
and its lack of alignment/packing restrictions (32-bit arch'es tend to
pack the 4 fields into 4 32-bit words, whereas 64-bit arch'es would add
padding after the third int, and make this 6 32-bit words).

Anyway, this means BLKPG deserves some special compat_ioctl handling. Do
the conversion in a small shim for MTD.

block/compat_ioctl.c already has compat support for the block subsystem,
but it does so by a re-marshalling data to/from user-space (see
compat_blkpg_ioctl()). Personally, I think this approach is cleaner.

Tested only on MTD, with an ARM32 user space on an ARM64 kernel.

Signed-off-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
</content>
</entry>
<entry>
<title>fs: introduce f_op-&gt;mmap_capabilities for nommu mmap support</title>
<updated>2015-01-20T21:02:58Z</updated>
<author>
<name>Christoph Hellwig</name>
</author>
<published>2015-01-14T09:42:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b4caecd48005fbed3949dde6c1cb233142fd69e9'/>
<id>urn:sha1:b4caecd48005fbed3949dde6c1cb233142fd69e9</id>
<content type='text'>
Since "BDI: Provide backing device capability information [try #3]" the
backing_dev_info structure also provides flags for the kind of mmap
operation available in a nommu environment, which is entirely unrelated
to it's original purpose.

Introduce a new nommu-only file operation to provide this information to
the nommu mmap code instead.  Splitting this from the backing_dev_info
structure allows to remove lots of backing_dev_info instance that aren't
otherwise needed, and entirely gets rid of the concept of providing a
backing_dev_info for a character device.  It also removes the need for
the mtd_inodefs filesystem.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@fb.com&gt;
</content>
</entry>
<entry>
<title>mtd: terminate user-provided string</title>
<updated>2014-08-19T18:53:09Z</updated>
<author>
<name>Brian Norris</name>
</author>
<published>2014-07-22T02:08:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1cc8d8413327a684cd5e93cd52ececb0223bb40b'/>
<id>urn:sha1:1cc8d8413327a684cd5e93cd52ececb0223bb40b</id>
<content type='text'>
Noticed by Coverity as a potential security issue.

Signed-off-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
</content>
</entry>
</feed>
