android_kernel_samsung_univ.../drivers
Richard Weinberger 1ba1f09456 UBI: Fix static volume checks when Fastmap is used
commit 1900149c835ab5b48bea31a823ea5e5a401fb560 upstream.

Ezequiel reported that he's facing UBI going into read-only
mode after power cut. It turned out that this behavior happens
only when updating a static volume is interrupted and Fastmap is
used.

A possible trace can look like:
ubi0 warning: ubi_io_read_vid_hdr [ubi]: no VID header found at PEB 2323, only 0xFF bytes
ubi0 warning: ubi_eba_read_leb [ubi]: switch to read-only mode
CPU: 0 PID: 833 Comm: ubiupdatevol Not tainted 4.6.0-rc2-ARCH #4
Hardware name: SAMSUNG ELECTRONICS CO., LTD. 300E4C/300E5C/300E7C/NP300E5C-AD8AR, BIOS P04RAP 10/15/2012
0000000000000286 00000000eba949bd ffff8800c45a7b38 ffffffff8140d841
ffff8801964be000 ffff88018eaa4800 ffff8800c45a7bb8 ffffffffa003abf6
ffffffff850e2ac0 8000000000000163 ffff8801850e2ac0 ffff8801850e2ac0
Call Trace:
[<ffffffff8140d841>] dump_stack+0x63/0x82
[<ffffffffa003abf6>] ubi_eba_read_leb+0x486/0x4a0 [ubi]
[<ffffffffa00453b3>] ubi_check_volume+0x83/0xf0 [ubi]
[<ffffffffa0039d97>] ubi_open_volume+0x177/0x350 [ubi]
[<ffffffffa00375d8>] vol_cdev_open+0x58/0xb0 [ubi]
[<ffffffff8124b08e>] chrdev_open+0xae/0x1d0
[<ffffffff81243bcf>] do_dentry_open+0x1ff/0x300
[<ffffffff8124afe0>] ? cdev_put+0x30/0x30
[<ffffffff81244d36>] vfs_open+0x56/0x60
[<ffffffff812545f4>] path_openat+0x4f4/0x1190
[<ffffffff81256621>] do_filp_open+0x91/0x100
[<ffffffff81263547>] ? __alloc_fd+0xc7/0x190
[<ffffffff812450df>] do_sys_open+0x13f/0x210
[<ffffffff812451ce>] SyS_open+0x1e/0x20
[<ffffffff81a99e32>] entry_SYSCALL_64_fastpath+0x1a/0xa4

UBI checks static volumes for data consistency and reads the
whole volume upon first open. If the volume is found erroneous
users of UBI cannot read from it, but another volume update is
possible to fix it. The check is performed by running
ubi_eba_read_leb() on every allocated LEB of the volume.
For static volumes ubi_eba_read_leb() computes the checksum of all
data stored in a LEB. To verify the computed checksum it has to read
the LEB's volume header which stores the original checksum.
If the volume header is not found UBI treats this as fatal internal
error and switches to RO mode. If the UBI device was attached via a
full scan the assumption is correct, the volume header has to be
present as it had to be there while scanning to get known as mapped.
If the attach operation happened via Fastmap the assumption is no
longer correct. When attaching via Fastmap UBI learns the mapping
table from Fastmap's snapshot of the system state and not via a full
scan. It can happen that a LEB got unmapped after a Fastmap was
written to the flash. Then UBI can learn the LEB still as mapped and
accessing it returns only 0xFF bytes. As UBI is not a FTL it is
allowed to have mappings to empty PEBs, it assumes that the layer
above takes care of LEB accounting and referencing.
UBIFS does so using the LEB property tree (LPT).
For static volumes UBI blindly assumes that all LEBs are present and
therefore special actions have to be taken.

The described situation can happen when updating a static volume is
interrupted, either by a user or a power cut.
The volume update code first unmaps all LEBs of a volume and then
writes LEB by LEB. If the sequence of operations is interrupted UBI
detects this either by the absence of LEBs, no volume header present
at scan time, or corrupted payload, detected via checksum.
In the Fastmap case the former method won't trigger as no scan
happened and UBI automatically thinks all LEBs are present.
Only by reading data from a LEB it detects that the volume header is
missing and incorrectly treats this as fatal error.
To deal with the situation ubi_eba_read_leb() from now on checks
whether we attached via Fastmap and handles the absence of a
volume header like a data corruption error.
This way interrupted static volume updates will correctly get detected
also when Fastmap is used.

Reported-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-01 12:15:54 -07:00
..
accessibility
acpi ACPI / osi: Fix an issue that acpi_osi=!* cannot disable ACPICA internal strings 2016-06-01 12:15:50 -07:00
amba
android
ata ata: ahci-platform: Add ports-implemented DT bindings. 2016-05-11 11:21:21 +02:00
atm
auxdisplay
base regmap: spmi: Fix regmap_spmi_ext_read in multi-byte case 2016-05-18 17:06:48 -07:00
bcma
block nbd: ratelimit error msgs after socket close 2016-05-11 11:21:10 +02:00
bluetooth Bluetooth: vhci: Fix race at creating hci device 2016-06-01 12:15:50 -07:00
bus bus: imx-weim: Take the 'status' property value into account 2016-05-04 14:48:54 -07:00
cdrom
char tpm: fix the cleanup of struct tpm_chip 2016-04-12 09:08:47 -07:00
clk clk: bcm2835: add locking to pll*_on/off methods 2016-06-01 12:15:53 -07:00
clocksource
connector
cpufreq cpufreq: intel_pstate: Fix processing for turbo activation ratio 2016-05-04 14:48:44 -07:00
cpuidle ARM: cpuidle: Pass on arm_cpuidle_suspend()'s return value 2016-05-11 11:21:19 +02:00
crypto crypto: sun4i-ss - Replace spinlock_bh by spin_lock_irq{save|restore} 2016-06-01 12:15:49 -07:00
dca
devfreq
dio
dma dmaengine: pxa_dma: fix the maximum requestor line 2016-05-04 14:48:42 -07:00
dma-buf
edac EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback 2016-05-04 14:48:48 -07:00
eisa
extcon extcon: max77843: Use correct size for reading the interrupt register 2016-05-04 14:48:54 -07:00
firewire
firmware efi: Expose non-blocking set_variable() wrapper to efivars 2016-05-04 14:48:49 -07:00
fmc
fpga
gpio
gpu drm/radeon: fix DP link training issue with second 4K monitor 2016-05-18 17:06:57 -07:00
hid HID: Fix boot delay for Creative SB Omni Surround 5.1 with quirk 2016-05-11 11:21:15 +02:00
hsi
hv
hwmon hwmon: (max1111) Return -ENODEV from max1111_read_channel if not instantiated 2016-04-20 15:41:52 +09:00
hwspinlock
hwtracing stm class: Select CONFIG_SRCU 2016-05-04 14:48:54 -07:00
i2c i2c: exynos5: Fix possible ABBA deadlock by keeping I2C clock prepared 2016-05-04 14:48:47 -07:00
ide
idle intel_idle: prevent SKL-H boot failure when C8+C9+C10 enabled 2016-04-12 09:09:05 -07:00
iio iio: ak8975: fix maybe-uninitialized warning 2016-05-11 11:21:23 +02:00
infiniband IB/srp: Fix a debug kernel crash 2016-06-01 12:15:53 -07:00
input Input: pwm-beeper - fix - scheduling while atomic 2016-06-01 12:15:49 -07:00
iommu iommu/dma: Restore scatterlist offsets correctly 2016-05-04 14:48:45 -07:00
ipack
irqchip irqchip/gic-v3: Configure all interrupts as non-secure Group-1 2016-06-01 12:15:49 -07:00
isdn
leds
lguest
lightnvm
macintosh
mailbox
mcb mcb: Fixed bar number assignment for the gdd 2016-06-01 12:15:53 -07:00
md MD: make bio mergeable 2016-05-11 11:21:13 +02:00
media Revert "[media] videobuf2-v4l2: Verify planes array in buffer dequeueing" 2016-05-18 17:06:55 -07:00
memory
memstick
message
mfd mfd: omap-usb-tll: Fix scheduling while atomic BUG 2016-06-01 12:15:49 -07:00
misc mei: bus: call mei_cl_read_start under device lock 2016-06-01 12:15:50 -07:00
mmc mmc: sdhci-pci: Remove MMC_CAP_BUS_WIDTH_TEST for Intel controllers 2016-06-01 12:15:50 -07:00
mtd UBI: Fix static volume checks when Fastmap is used 2016-06-01 12:15:54 -07:00
net can: fix handling of unmodifiable configuration options 2016-06-01 12:15:50 -07:00
nfc
ntb
nubus
nvdimm libnvdimm, pfn: fix uuid validation 2016-04-20 15:41:54 +09:00
nvme
nvmem nvmem: mxs-ocotp: fix buffer overflow in read 2016-05-11 11:21:21 +02:00
of of: alloc anywhere from memblock if range not specified 2016-04-12 09:08:55 -07:00
oprofile
parisc
parport
pci PCI: Disable IO/MEM decoding for devices with non-compliant BARs 2016-04-12 09:08:37 -07:00
pcmcia pcmcia: db1xxx_ss: fix last irq_to_gpio user 2016-04-20 15:42:09 +09:00
perf
phy
pinctrl pinctrl: at91-pio4: fix pull-up/down logic 2016-05-18 17:06:47 -07:00
platform dell-rbtn: Ignore ACPI notifications if device is suspended 2016-06-01 12:15:50 -07:00
pnp
power
powercap
pps
ps3
ptp
pwm pwm: brcmstb: Fix check of devm_ioremap_resource() return code 2016-05-04 14:48:47 -07:00
rapidio
ras
regulator regulator: axp20x: Fix axp22x ldo_io voltage ranges 2016-05-18 17:06:51 -07:00
remoteproc
reset
rpmsg
rtc rtc: max77686: Properly handle regmap_irq_get_virq() error code 2016-05-04 14:48:52 -07:00
s390 s390/dasd: fix diag 0x250 inline assembly 2016-03-16 08:42:58 -07:00
sbus
scsi qla1280: Don't allocate 512kb of host tags 2016-05-18 17:06:52 -07:00
sfi
sh
sn
soc soc: rockchip: power-domain: fix err handle while probing 2016-05-11 11:21:11 +02:00
spi spi: spi-ti-qspi: Handle truncated frames properly 2016-05-18 17:06:47 -07:00
spmi
ssb
staging staging: comedi: das1800: fix possible NULL dereference 2016-06-01 12:15:52 -07:00
target target: Fix target_release_cmd_kref shutdown comp leak 2016-04-12 09:09:02 -07:00
tc
thermal thermal: rockchip: fix a impossible condition caused by the warning 2016-05-04 14:48:54 -07:00
thunderbolt thunderbolt: Fix double free of drom buffer 2016-06-01 12:15:53 -07:00
tty serial: samsung: Reorder the sequence of clock control when call s3c24xx_serial_set_termios() 2016-06-01 12:15:53 -07:00
uio
usb usb: gadget: udc: core: Fix argument of dev_err() in usb_gadget_map_request() 2016-06-01 12:15:52 -07:00
uwb
vfio
vhost
video fbdev: da8xx-fb: fix videomodes of lcd panels 2016-05-04 14:48:51 -07:00
virt
virtio virtio: virtio 1.0 cs04 spec compliance for reset 2016-04-20 15:42:10 +09:00
vlynq
vme
w1
watchdog watchdog: rc32434_wdt: fix ioctl error handling 2016-04-12 09:08:54 -07:00
xen xen/evtchn: fix ring resize when binding new events 2016-05-11 11:21:15 +02:00
zorro
Kconfig
Makefile