linux_dsm_epyc7002/drivers/mtd/ubi
Artem Bityutskiy 0e707ae79b UBI: do propagate positive error codes up
UBI uses positive function return codes internally, and should not propagate
them up, except in the place this path fixes. Here is the original bug report
from Dan Carpenter:

The problem is really in ubi_eba_read_leb().

drivers/mtd/ubi/eba.c
   412                  err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1);
   413                  if (err && err != UBI_IO_BITFLIPS) {
   414                          if (err > 0) {
   415                                  /*
   416                                   * The header is either absent or corrupted.
   417                                   * The former case means there is a bug -
   418                                   * switch to read-only mode just in case.
   419                                   * The latter case means a real corruption - we
   420                                   * may try to recover data. FIXME: but this is
   421                                   * not implemented.
   422                                   */
   423                                  if (err == UBI_IO_BAD_HDR_EBADMSG ||
   424                                      err == UBI_IO_BAD_HDR) {
   425                                          ubi_warn("corrupted VID header at PEB %d, LEB %d:%d",
   426                                                   pnum, vol_id, lnum);
   427                                          err = -EBADMSG;
   428                                  } else
   429                                          ubi_ro_mode(ubi);

On this path we return UBI_IO_FF and UBI_IO_FF_BITFLIPS and it
eventually gets passed to ERR_PTR().  We probably dereference the bad
pointer and oops.  At that point we've gone read only so it was already
a bad situation...

   430                          }
   431                          goto out_free;
   432                  } else if (err == UBI_IO_BITFLIPS)
   433                          scrub = 1;
   434

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-01-28 16:09:25 +01:00
..
attach.c UBI: Extend UBI layer debug/messaging capabilities 2014-11-07 12:08:51 +02:00
block.c UBI: Block: Add blk-mq support 2015-01-28 16:05:20 +01:00
build.c UBI: extend UBI layer debug/messaging capabilities - cosmetics 2015-01-28 16:09:09 +01:00
cdev.c UBI: extend UBI layer debug/messaging capabilities - cosmetics 2015-01-28 16:09:09 +01:00
debug.c UBI: Extend UBI layer debug/messaging capabilities 2014-11-07 12:08:51 +02:00
debug.h mtd: rename random32() to prandom_u32() 2013-02-04 09:26:28 +02:00
eba.c UBI: do propagate positive error codes up 2015-01-28 16:09:25 +01:00
fastmap.c UBI: Extend UBI layer debug/messaging capabilities 2014-11-07 12:08:51 +02:00
gluebi.c UBI: gluebi: rename misleading variables 2012-11-30 13:54:41 +02:00
io.c UBI: extend UBI layer debug/messaging capabilities - cosmetics 2015-01-28 16:09:09 +01:00
kapi.c UBI: Add initial support for scatter gather 2015-01-28 16:04:26 +01:00
Kconfig UBI: block: Add CONFIG_BLOCK dependency 2014-03-04 14:49:53 +02:00
Makefile UBI: R/O block driver on top of UBI volumes 2014-02-28 16:29:48 +02:00
misc.c UBI: Extend UBI layer debug/messaging capabilities 2014-11-07 12:08:51 +02:00
ubi-media.h UBI: Add fastmap on-flash data structures 2012-10-03 12:29:37 +03:00
ubi.h UBI: clean-up printing helpers 2015-01-28 16:09:17 +01:00
upd.c UBI: Fix invalid vfree() 2014-11-07 15:14:09 +02:00
vmt.c UBI: Extend UBI layer debug/messaging capabilities 2014-11-07 12:08:51 +02:00
vtbl.c UBI: extend UBI layer debug/messaging capabilities - cosmetics 2015-01-28 16:09:09 +01:00
wl.c UBI: extend UBI layer debug/messaging capabilities - cosmetics 2015-01-28 16:09:09 +01:00