From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Jan Kara <jack@suse.cz>,
Ian Abbott <abbotti@mev.co.uk>
Subject: [ 042/135] udf: Fix data corruption for files in ICB
Date: Mon, 17 Sep 2012 01:37:07 +0100 [thread overview]
Message-ID: <20120917003632.057232218@decadent.org.uk> (raw)
In-Reply-To: <20120917003625.784119135@decadent.org.uk>
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <jack@suse.cz>
commit 9c2fc0de1a6e638fe58c354a463f544f42a90a09 upstream.
When a file is stored in ICB (inode), we overwrite part of the file, and
the page containing file's data is not in page cache, we end up corrupting
file's data by overwriting them with zeros. The problem is we use
simple_write_begin() which simply zeroes parts of the page which are not
written to. The problem has been introduced by be021ee4 (udf: convert to
new aops).
Fix the problem by providing a ->write_begin function which makes the page
properly uptodate.
Reported-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
fs/udf/file.c | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 7f3f7ba..d1c6093 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -39,20 +39,24 @@
#include "udf_i.h"
#include "udf_sb.h"
-static int udf_adinicb_readpage(struct file *file, struct page *page)
+static void __udf_adinicb_readpage(struct page *page)
{
struct inode *inode = page->mapping->host;
char *kaddr;
struct udf_inode_info *iinfo = UDF_I(inode);
- BUG_ON(!PageLocked(page));
-
kaddr = kmap(page);
- memset(kaddr, 0, PAGE_CACHE_SIZE);
memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size);
+ memset(kaddr + inode->i_size, 0, PAGE_CACHE_SIZE - inode->i_size);
flush_dcache_page(page);
SetPageUptodate(page);
kunmap(page);
+}
+
+static int udf_adinicb_readpage(struct file *file, struct page *page)
+{
+ BUG_ON(!PageLocked(page));
+ __udf_adinicb_readpage(page);
unlock_page(page);
return 0;
@@ -77,6 +81,25 @@ static int udf_adinicb_writepage(struct page *page,
return 0;
}
+static int udf_adinicb_write_begin(struct file *file,
+ struct address_space *mapping, loff_t pos,
+ unsigned len, unsigned flags, struct page **pagep,
+ void **fsdata)
+{
+ struct page *page;
+
+ if (WARN_ON_ONCE(pos >= PAGE_CACHE_SIZE))
+ return -EIO;
+ page = grab_cache_page_write_begin(mapping, 0, flags);
+ if (!page)
+ return -ENOMEM;
+ *pagep = page;
+
+ if (!PageUptodate(page) && len != PAGE_CACHE_SIZE)
+ __udf_adinicb_readpage(page);
+ return 0;
+}
+
static int udf_adinicb_write_end(struct file *file,
struct address_space *mapping,
loff_t pos, unsigned len, unsigned copied,
@@ -98,8 +121,8 @@ static int udf_adinicb_write_end(struct file *file,
const struct address_space_operations udf_adinicb_aops = {
.readpage = udf_adinicb_readpage,
.writepage = udf_adinicb_writepage,
- .write_begin = simple_write_begin,
- .write_end = udf_adinicb_write_end,
+ .write_begin = udf_adinicb_write_begin,
+ .write_end = udf_adinicb_write_end,
};
static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
next prev parent reply other threads:[~2012-09-17 0:59 UTC|newest]
Thread overview: 141+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-17 0:36 [ 000/135] 3.2.30-stable review Ben Hutchings
2012-09-17 0:36 ` [ 001/135] [PARISC] Redefine ATOMIC_INIT and ATOMIC64_INIT to drop the casts Ben Hutchings
2012-09-17 0:36 ` [ 002/135] ARM: S3C24XX: Fix s3c2410_dma_enqueue parameters Ben Hutchings
2012-09-17 0:36 ` [ 003/135] ARM: OMAP2+: Fix dmtimer set source clock failure Ben Hutchings
2012-09-17 0:36 ` [ 004/135] ARM: Orion: Set eth packet size csum offload limit Ben Hutchings
2012-09-17 0:36 ` [ 005/135] iwlwifi: fix flow handler debug code Ben Hutchings
2012-09-17 0:36 ` [ 006/135] iwlwifi: protect SRAM debugfs Ben Hutchings
2012-09-17 0:36 ` [ 007/135] Input: i8042 - add Gigabyte T1005 series netbooks to noloop table Ben Hutchings
2012-09-17 0:36 ` [ 008/135] [SCSI] mpt2sas: Fix for Driver oops, when loading driver with max_queue_depth command line option to a very small value Ben Hutchings
2012-09-17 0:36 ` [ 009/135] [SCSI] megaraid_sas: Move poll_aen_lock initializer Ben Hutchings
2012-09-17 0:36 ` [ 010/135] [SCSI] Fix Device not ready issue on mpt2sas Ben Hutchings
2012-09-17 0:36 ` [ 011/135] hwmon: (asus_atk0110) Add quirk for Asus M5A78L Ben Hutchings
2012-09-17 0:36 ` [ 012/135] drm/i915: Fix assert_pch_hdmi_disabled to mention HDMI (not DP) Ben Hutchings
2012-09-17 0:36 ` [ 013/135] drm/i915: fix wrong order of parameters in port checking functions Ben Hutchings
2012-09-17 0:36 ` [ 014/135] OMAPFB: fix framebuffer console colors Ben Hutchings
2012-09-17 0:36 ` [ 015/135] ARM: imx6: spin the cpu until hardware takes it down Ben Hutchings
2012-09-17 0:36 ` [ 016/135] ARM: dts: imx51-babbage: fix esdhc cd/wp properties Ben Hutchings
2012-09-17 0:36 ` [ 017/135] xen/setup: Fix one-off error when adding for-balloon PFNs to the P2M Ben Hutchings
2012-09-17 0:36 ` [ 018/135] ARM: imx: select CPU_FREQ_TABLE when needed Ben Hutchings
2012-09-17 0:36 ` [ 019/135] drm: remove some potentially dangerous DRM_ERRORs Ben Hutchings
2012-09-17 0:36 ` [ 020/135] drm: Check for invalid cursor flags Ben Hutchings
2012-09-17 0:36 ` [ 021/135] HID: multitouch: support PixArt optical touch screen Ben Hutchings
2012-09-17 0:36 ` [ 022/135] HID: add NOGET quirk for Eaton Ellipse MAX UPS Ben Hutchings
2012-09-17 0:36 ` [ 023/135] drm/radeon: dont disable plls that are in use by other crtcs Ben Hutchings
2012-09-17 0:36 ` [ 024/135] drm/radeon/atom: rework DIG modesetting on DCE3+ Ben Hutchings
2012-09-17 0:36 ` [ 025/135] drm/radeon: force dma32 to fix regression rs4xx,rs6xx,rs740 Ben Hutchings
2012-09-17 0:36 ` [ 026/135] drm/edid/quirks: ViewSonic VA2026w Ben Hutchings
2012-09-17 0:36 ` [ 027/135] drm: Add EDID_QUIRK_FORCE_REDUCED_BLANKING for ASUS VW222S Ben Hutchings
2012-09-17 0:36 ` [ 028/135] e1000e: DoS while TSO enabled caused by link partner with small MSS Ben Hutchings
2012-09-17 0:36 ` [ 029/135] ext3: Fix fdatasync() for files with only i_size changes Ben Hutchings
2012-09-17 0:36 ` [ 030/135] UBI: fix a horrible memory deallocation bug Ben Hutchings
2012-09-17 0:36 ` [ 031/135] fuse: fix retrieve length Ben Hutchings
2012-09-17 0:36 ` [ 032/135] mmc: mxs-mmc: fix deadlock in SDIO IRQ case Ben Hutchings
2012-09-17 0:36 ` [ 033/135] mmc: mxs-mmc: fix deadlock caused by recursion loop Ben Hutchings
2012-09-17 0:36 ` [ 034/135] mmc: sdhci-esdhc: break out early if clock is 0 Ben Hutchings
2012-09-17 0:37 ` [ 035/135] mmc: card: Skip secure erase on MoviNAND; causes unrecoverable corruption Ben Hutchings
2012-09-17 0:37 ` [ 036/135] powerpc: Update DSCR on all CPUs when writing sysfs dscr_default Ben Hutchings
2012-09-17 0:37 ` [ 037/135] powerpc: Keep thread.dscr and thread.dscr_inherit in sync Ben Hutchings
2012-09-17 0:37 ` [ 038/135] powerpc: Fix DSCR inheritance in copy_thread() Ben Hutchings
2012-09-17 0:37 ` [ 039/135] powerpc: Restore correct DSCR in context switch Ben Hutchings
2012-09-17 0:37 ` [ 040/135] powerpc/xics: Harden xics hypervisor backend Ben Hutchings
2012-09-17 0:37 ` [ 041/135] powerpc: Make sure IPI handlers see data written by IPI senders Ben Hutchings
2012-09-17 0:37 ` Ben Hutchings [this message]
2012-09-17 0:37 ` [ 043/135] xen: Use correct masking in xen_swiotlb_alloc_coherent Ben Hutchings
2012-09-17 0:37 ` [ 044/135] Remove user-triggerable BUG from mpol_to_str Ben Hutchings
2012-09-17 0:37 ` [ 045/135] CIFS: Fix error handling in cifs_push_mandatory_locks Ben Hutchings
2012-09-17 0:37 ` [ 046/135] drm/vmwgfx: add MODULE_DEVICE_TABLE so vmwgfx loads at boot Ben Hutchings
2012-09-17 0:37 ` [ 047/135] i2c-designware: Fix build error if CONFIG_I2C_DESIGNWARE_PLATFORM=y && CONFIG_I2C_DESIGNWARE_PCI=y Ben Hutchings
2012-09-17 0:37 ` [ 048/135] net: Allow driver to limit number of GSO segments per skb Ben Hutchings
2012-09-17 0:37 ` [ 049/135] sfc: Fix maximum number of TSO segments and minimum TX queue size Ben Hutchings
2012-09-17 0:37 ` [ 050/135] tcp: Apply device TSO segment limit earlier Ben Hutchings
2012-09-17 0:37 ` [ 051/135] net_sched: gact: Fix potential panic in tcf_gact() Ben Hutchings
2012-09-17 0:37 ` [ 052/135] isdnloop: fix and simplify isdnloop_init() Ben Hutchings
2012-09-17 0:37 ` [ 053/135] pptp: lookup route with the proper net namespace Ben Hutchings
2012-09-17 0:37 ` [ 054/135] net/core: Fix potential memory leak in dev_set_alias() Ben Hutchings
2012-09-17 0:37 ` [ 055/135] af_packet: remove BUG statement in tpacket_destruct_skb Ben Hutchings
2012-09-17 0:37 ` [ 056/135] ipv6: addrconf: Avoid calling netdevice notifiers with RCU read-side lock Ben Hutchings
2012-09-17 0:37 ` [ 057/135] atm: fix info leak in getsockopt(SO_ATMPVC) Ben Hutchings
2012-09-17 0:37 ` [ 058/135] atm: fix info leak via getsockname() Ben Hutchings
2012-09-17 0:37 ` [ 059/135] Bluetooth: HCI - Fix info leak in getsockopt(HCI_FILTER) Ben Hutchings
2012-09-17 0:37 ` [ 060/135] Bluetooth: HCI - Fix info leak via getsockname() Ben Hutchings
2012-09-17 0:37 ` [ 061/135] Bluetooth: RFCOMM - Fix info leak in getsockopt(BT_SECURITY) Ben Hutchings
2012-09-17 0:37 ` [ 062/135] Bluetooth: RFCOMM - Fix info leak in ioctl(RFCOMMGETDEVLIST) Ben Hutchings
2012-09-17 0:37 ` [ 063/135] Bluetooth: RFCOMM - Fix info leak via getsockname() Ben Hutchings
2012-09-17 0:37 ` [ 064/135] Bluetooth: L2CAP " Ben Hutchings
2012-09-17 0:37 ` [ 065/135] llc: fix " Ben Hutchings
2012-09-17 0:37 ` [ 066/135] dccp: fix info leak via getsockopt(DCCP_SOCKOPT_CCID_TX_INFO) Ben Hutchings
2012-09-17 0:37 ` [ 067/135] ipvs: fix info leak in getsockopt(IP_VS_SO_GET_TIMEOUT) Ben Hutchings
2012-09-17 0:37 ` [ 068/135] net: fix info leak in compat dev_ifconf() Ben Hutchings
2012-09-17 0:37 ` [ 069/135] af_packet: dont emit packet on orig fanout group Ben Hutchings
2012-09-17 0:37 ` [ 070/135] af_netlink: force credentials passing [CVE-2012-3520] Ben Hutchings
2012-09-17 0:37 ` [ 071/135] netlink: fix possible spoofing from non-root processes Ben Hutchings
2012-09-17 0:37 ` [ 072/135] gianfar: fix default tx vlan offload feature flag Ben Hutchings
2012-09-17 0:37 ` [ 073/135] l2tp: avoid to use synchronize_rcu in tunnel free function Ben Hutchings
2012-09-17 0:37 ` [ 074/135] net: ipv4: ipmr_expire_timer causes crash when removing net namespace Ben Hutchings
2012-09-17 0:37 ` [ 075/135] bnx2x: fix 57840_MF pci id Ben Hutchings
2012-09-17 0:37 ` [ 076/135] workqueue: UNBOUND -> REBIND morphing in rebind_workers() should be atomic Ben Hutchings
2012-09-17 0:37 ` [ 077/135] fixing dmi match for hp t5745 and hp st5747 thin client Ben Hutchings
2012-09-17 0:37 ` [ 078/135] time: Improve sanity checking of timekeeping inputs Ben Hutchings
2012-09-17 0:37 ` [ 079/135] time: Avoid making adjustments if we havent accumulated anything Ben Hutchings
2012-09-17 0:37 ` [ 080/135] time: Move ktime_t overflow checking into timespec_valid_strict Ben Hutchings
2012-09-17 0:37 ` [ 081/135] drm/i915: Wait for all pending operations to the fb before disabling the pipe Ben Hutchings
2012-09-17 0:37 ` [ 082/135] xhci: Fix bug after deq ptr set to link TRB Ben Hutchings
2012-09-17 0:37 ` [ 083/135] ARM: 7487/1: mm: avoid setting nG bit for user mappings that arent present Ben Hutchings
2012-09-17 0:37 ` [ 084/135] i2c-i801: Add device IDs for Intel Lynx Point Ben Hutchings
2012-09-17 0:37 ` [ 085/135] i2c-i801: Add Device IDs for Intel Lynx Point-LP PCH Ben Hutchings
2012-09-17 0:37 ` [ 086/135] USB: option: add ZTE K5006-Z Ben Hutchings
2012-09-17 0:37 ` [ 087/135] USB: option: replace ZTE K5006-Z entry with vendor class rule Ben Hutchings
2012-09-17 0:37 ` [ 088/135] ARM: 7496/1: hw_breakpoint: dont rely on dfsr to show watchpoint access type Ben Hutchings
2012-09-17 0:37 ` [ 089/135] drm/i915: SDVO hotplug have different interrupt status bits for i915/i965/g4x Ben Hutchings
2012-09-17 0:37 ` [ 090/135] drm/i915: only enable sdvo hotplug irq if needed Ben Hutchings
2012-09-17 0:37 ` [ 091/135] can: mcp251x: avoid repeated frame bug Ben Hutchings
2012-09-17 0:37 ` [ 092/135] perf_event: Switch to internal refcount, fix race with close() Ben Hutchings
2012-09-17 0:37 ` [ 093/135] NFS: Fix the initialisation of the readdir cookieverf array Ben Hutchings
2012-09-17 0:37 ` [ 094/135] NFS: Fix a problem with the legacy binary mount code Ben Hutchings
2012-09-17 0:38 ` [ 095/135] staging: comedi: das08: Correct AI encoding for das08jr-16-ao Ben Hutchings
2012-09-17 0:38 ` [ 096/135] staging: comedi: das08: Correct AO output " Ben Hutchings
2012-09-17 0:38 ` [ 097/135] staging: vt6656: [BUG] - Failed connection, incorrect endian Ben Hutchings
2012-09-17 0:38 ` [ 098/135] xhci: Recognize USB 3.0 devices as superspeed at powerup Ben Hutchings
2012-09-17 0:38 ` [ 099/135] Intel xhci: Only switch the switchable ports Ben Hutchings
2012-09-17 0:38 ` [ 100/135] rt2x00: Identify ASUS USB-N53 device Ben Hutchings
2012-09-17 0:38 ` [ 101/135] rt2x00: Fix word size of rt2500usb MAC_CSR19 register Ben Hutchings
2012-09-17 0:38 ` [ 102/135] rt2x00: Fix rfkill polling prior to interface start Ben Hutchings
2012-09-17 0:38 ` [ 103/135] rt2800usb: Added rx packet length validity check Ben Hutchings
2012-09-17 0:38 ` [ 104/135] staging: zcache: fix cleancache race condition with shrinker Ben Hutchings
2012-09-17 0:38 ` [ 105/135] xhci: Switch PPT ports to EHCI on shutdown Ben Hutchings
2012-09-17 0:38 ` [ 106/135] xhci: Fix a logical vs bitwise AND bug Ben Hutchings
2012-09-17 0:38 ` [ 107/135] xhci: Make handover code more robust Ben Hutchings
2012-09-17 0:38 ` [ 108/135] usb: host: xhci: Fix Compliance Mode on SN65LVPE502CP Hardware Ben Hutchings
2012-09-17 0:38 ` [ 109/135] usb: host: xhci: fix compilation error for non-PCI based stacks Ben Hutchings
2012-09-17 0:38 ` [ 110/135] tty: serial: imx: console write routing is unsafe on SMP Ben Hutchings
2012-09-17 0:38 ` [ 111/135] tty: serial: imx: dont reinit clock in imx_setup_ufcr() Ben Hutchings
2012-09-17 0:38 ` [ 112/135] ibmveth: Fix alignment of rx queue bug Ben Hutchings
2012-09-17 0:38 ` [ 113/135] USB: ftdi-sio: add support for more Physik Instrumente devices Ben Hutchings
2012-09-17 0:38 ` [ 114/135] USB: ftdi_sio: PID for NZR SEM 16+ USB Ben Hutchings
2012-09-17 0:38 ` [ 115/135] USB: add device quirk for Joss Optical touchboard Ben Hutchings
2012-09-17 0:38 ` [ 116/135] kobject: fix oops with "input0: bad kobj_uevent_env content in show_uevent()" Ben Hutchings
2012-09-17 0:38 ` [ 117/135] NFS: return error from decode_getfh in decode open Ben Hutchings
2012-09-19 1:26 ` Herton Ronaldo Krzesinski
2012-09-19 3:39 ` Ben Hutchings
2012-09-19 15:53 ` Myklebust, Trond
2012-09-20 1:21 ` Ben Hutchings
2012-09-17 0:38 ` [ 118/135] SUNRPC: Fix a UDP transport regression Ben Hutchings
2012-09-17 0:38 ` [ 119/135] ARM: 7513/1: Make sure dtc is built before running it Ben Hutchings
2012-09-17 0:38 ` [ 120/135] ARM: 7526/1: traps: send SIGILL if get_user fails on undef handling path Ben Hutchings
2012-09-17 0:38 ` [ 121/135] ALSA: hda - Fix Oops at codec reset/reconfig Ben Hutchings
2012-09-17 0:38 ` [ 122/135] USB: ftdi_sio: do not claim CDC ACM function Ben Hutchings
2012-09-17 0:38 ` [ 123/135] staging: r8712u: fix bug in r8712_recv_indicatepkt() Ben Hutchings
2012-09-17 0:38 ` [ 124/135] EHCI: Update qTD next pointer in QH overlay region during unlink Ben Hutchings
2012-09-17 0:38 ` [ 125/135] hwmon: (twl4030-madc-hwmon) Initialize uninitialized structure elements Ben Hutchings
2012-09-17 0:38 ` [ 126/135] ALSA: ice1724: Use linear scale for AK4396 volume control Ben Hutchings
2012-09-17 0:38 ` [ 127/135] vmwgfx: add dumb ioctl support Ben Hutchings
2012-09-17 0:38 ` [ 128/135] ahci: Add alternate identifier for the 88SE9172 Ben Hutchings
2012-09-17 0:38 ` [ 129/135] drm/radeon: fix up pll selection on DCE5/6 Ben Hutchings
2012-09-17 0:38 ` [ 130/135] drm/radeon: fix ordering in pll picking on dce4+ Ben Hutchings
2012-09-17 0:38 ` [ 131/135] drm/radeon: rework pll selection (v3) Ben Hutchings
2012-09-17 0:38 ` [ 132/135] drm/nouveau: fix booting with plymouth + dumb support Ben Hutchings
2012-09-17 0:38 ` [ 133/135] eCryptfs: Copy up attributes of the lower target inode after rename Ben Hutchings
2012-09-17 0:38 ` [ 134/135] VFS: make vfs_fstat() use f[get|put]_light() Ben Hutchings
2012-09-17 0:38 ` [ 135/135] vfs: make O_PATH file descriptors usable for fstat() Ben Hutchings
2012-09-17 0:53 ` [ 000/135] 3.2.30-stable review Ben Hutchings
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=20120917003632.057232218@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=abbotti@mev.co.uk \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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
Powered by JetHome