From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Changwei Ge <chge@linux.alibaba.com>, Andrew Morton <akpm@linux-foundation.org>, Joseph Qi <joseph.qi@linux.alibaba.com>, Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>, Junxiao Bi <junxiao.bi@oracle.com>, Changwei Ge <gechangwei@live.cn>, Gang He <ghe@suse.com>, Jun Piao <piaojun@huawei.com>, Linus Torvalds <torvalds@linux-foundation.org>, Sasha Levin <sashal@kernel.org>, ocfs2-devel@oss.oracle.com Subject: [PATCH AUTOSEL 5.5 51/75] ocfs2: no need try to truncate file beyond i_size Date: Sat, 18 Apr 2020 10:08:46 -0400 [thread overview] Message-ID: <20200418140910.8280-51-sashal@kernel.org> (raw) In-Reply-To: <20200418140910.8280-1-sashal@kernel.org> From: Changwei Ge <chge@linux.alibaba.com> [ Upstream commit 783fda856e1034dee90a873f7654c418212d12d7 ] Linux fallocate(2) with FALLOC_FL_PUNCH_HOLE mode set, its offset can exceed the inode size. Ocfs2 now doesn't allow that offset beyond inode size. This restriction is not necessary and violates fallocate(2) semantics. If fallocate(2) offset is beyond inode size, just return success and do nothing further. Otherwise, ocfs2 will crash the kernel. kernel BUG at fs/ocfs2//alloc.c:7264! ocfs2_truncate_inline+0x20f/0x360 [ocfs2] ocfs2_remove_inode_range+0x23c/0xcb0 [ocfs2] __ocfs2_change_file_space+0x4a5/0x650 [ocfs2] ocfs2_fallocate+0x83/0xa0 [ocfs2] vfs_fallocate+0x148/0x230 SyS_fallocate+0x48/0x80 do_syscall_64+0x79/0x170 Signed-off-by: Changwei Ge <chge@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Cc: <stable@vger.kernel.org> Link: http://lkml.kernel.org/r/20200407082754.17565-1-chge@linux.alibaba.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/ocfs2/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 88534eb0e7c2a..3d5b6b989db26 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -7403,6 +7403,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; struct ocfs2_inline_data *idata = &di->id2.i_data; + /* No need to punch hole beyond i_size. */ + if (start >= i_size_read(inode)) + return 0; + if (end > i_size_read(inode)) end = i_size_read(inode); -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Changwei Ge <chge@linux.alibaba.com>, Andrew Morton <akpm@linux-foundation.org>, Joseph Qi <joseph.qi@linux.alibaba.com>, Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>, Junxiao Bi <junxiao.bi@oracle.com>, Changwei Ge <gechangwei@live.cn>, Gang He <ghe@suse.com>, Jun Piao <piaojun@huawei.com>, Linus Torvalds <torvalds@linux-foundation.org>, Sasha Levin <sashal@kernel.org>, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH AUTOSEL 5.5 51/75] ocfs2: no need try to truncate file beyond i_size Date: Sat, 18 Apr 2020 10:08:46 -0400 [thread overview] Message-ID: <20200418140910.8280-51-sashal@kernel.org> (raw) In-Reply-To: <20200418140910.8280-1-sashal@kernel.org> From: Changwei Ge <chge@linux.alibaba.com> [ Upstream commit 783fda856e1034dee90a873f7654c418212d12d7 ] Linux fallocate(2) with FALLOC_FL_PUNCH_HOLE mode set, its offset can exceed the inode size. Ocfs2 now doesn't allow that offset beyond inode size. This restriction is not necessary and violates fallocate(2) semantics. If fallocate(2) offset is beyond inode size, just return success and do nothing further. Otherwise, ocfs2 will crash the kernel. kernel BUG at fs/ocfs2//alloc.c:7264! ocfs2_truncate_inline+0x20f/0x360 [ocfs2] ocfs2_remove_inode_range+0x23c/0xcb0 [ocfs2] __ocfs2_change_file_space+0x4a5/0x650 [ocfs2] ocfs2_fallocate+0x83/0xa0 [ocfs2] vfs_fallocate+0x148/0x230 SyS_fallocate+0x48/0x80 do_syscall_64+0x79/0x170 Signed-off-by: Changwei Ge <chge@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Cc: <stable@vger.kernel.org> Link: https://urldefense.com/v3/__http://lkml.kernel.org/r/20200407082754.17565-1-chge at linux.alibaba.com__;!!GqivPVa7Brio!KZZrGW26OLoti718gCEJhQjYe-B4sBBsaYgRYZETZlE8Tiv2sbY0lmzH52M7oouYdQl2PA$ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/ocfs2/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 88534eb0e7c2a..3d5b6b989db26 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -7403,6 +7403,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; struct ocfs2_inline_data *idata = &di->id2.i_data; + /* No need to punch hole beyond i_size. */ + if (start >= i_size_read(inode)) + return 0; + if (end > i_size_read(inode)) end = i_size_read(inode); -- 2.20.1
next prev parent reply other threads:[~2020-04-18 14:12 UTC|newest] Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-18 14:07 [PATCH AUTOSEL 5.5 01/75] iommu/amd: Fix the configuration of GCR3 table root pointer Sasha Levin 2020-04-18 14:07 ` Sasha Levin 2020-04-18 14:07 ` [PATCH AUTOSEL 5.5 02/75] tools/testing/nvdimm: Fix compilation failure without CONFIG_DEV_DAX_PMEM_COMPAT Sasha Levin 2020-04-18 14:07 ` Sasha Levin 2020-04-18 14:07 ` [PATCH AUTOSEL 5.5 03/75] watchdog: reset last_hw_keepalive time at start Sasha Levin 2020-04-18 14:07 ` [PATCH AUTOSEL 5.5 04/75] ovl: fix value of i_ino for lower hardlink corner case Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 05/75] iommu/vt-d: Fix page request descriptor size Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 06/75] acpi/nfit: improve bounds checking for 'func' Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 07/75] iommu/vt-d: Fix mm reference leak Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 08/75] scsi: lpfc: Fix kasan slab-out-of-bounds error in lpfc_unreg_login Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 09/75] xfs: correctly acount for reclaimable slabs Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 10/75] scsi: lpfc: Fix crash after handling a pci error Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 11/75] scsi: lpfc: Fix crash in target side cable pulls hitting WAIT_FOR_UNREG Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 12/75] scsi: libfc: If PRLI rejected, move rport to PLOGI state Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 13/75] ceph: return ceph_mdsc_do_request() errors from __get_parent() Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 14/75] ceph: don't skip updating wanted caps when cap is stale Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 15/75] pwm: rcar: Fix late Runtime PM enablement Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 16/75] nvme-tcp: fix possible crash in write_zeroes processing Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 17/75] ASoC: dpcm: allow start or stop during pause for backend Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 18/75] scsi: iscsi: Report unbind session event when the target has been removed Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 19/75] tools/test/nvdimm: Fix out of tree build Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 20/75] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 21/75] nvme: fix deadlock caused by ANA update wrong locking Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 22/75] drm/amd/display: Update stream adjust in dc_stream_adjust_vmin_vmax Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 23/75] dma-direct: fix data truncation in dma_direct_get_required_mask() Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 24/75] dma-debug: fix displaying of dma allocation type Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 25/75] kernel/gcov/fs.c: gcov_seq_next() should increase position index Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 26/75] selftests: kmod: fix handling test numbers above 9 Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 27/75] ipc/util.c: sysvipc_find_ipc() should increase position index Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 28/75] kconfig: qconf: Fix a few alignment issues Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 29/75] lib/raid6/test: fix build on distros whose /bin/sh is not bash Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 30/75] block: fix busy device checking in blk_drop_partitions Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 31/75] KVM: s390: vsie: Fix possible race when shadowing region 3 tables Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 32/75] drm/nouveau: workaround runpm fail by disabling PCI power management on certain intel bridges Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 33/75] s390/cio: generate delayed uevent for vfio-ccw subchannels Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 34/75] s390/cio: avoid duplicated 'ADD' uevents Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 35/75] loop: Better discard support for block devices Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 36/75] pwm: pca9685: Fix PWM/GPIO inter-operation Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 37/75] Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled" Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 38/75] powerpc/pseries: Fix MCE handling on pseries Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 39/75] drm/amdkfd: kfree the wrong pointer Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 40/75] nvme: fix compat address handling in several ioctls Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 41/75] pwm: renesas-tpu: Fix late Runtime PM enablement Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 42/75] pwm: bcm2835: Dynamically allocate base Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 43/75] scsi: lpfc: Fix erroneous cpu limit of 128 on I/O statistics Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 44/75] drm/vc4: Fix HDMI mode validation Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 45/75] iommu/virtio: Fix freeing of incomplete domains Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 46/75] scsi: lpfc: Fix lockdep error - register non-static key Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 47/75] iommu/vt-d: Silence RCU-list debugging warning in dmar_find_atsr() Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 48/75] platform/chrome: cros_ec_rpmsg: Fix race with host event Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 49/75] libnvdimm: Out of bounds read in __nd_ioctl() Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 50/75] platform/chrome: cros_ec: Query EC protocol version if EC transitions between RO/RW Sasha Levin 2020-04-18 14:08 ` Sasha Levin [this message] 2020-04-18 14:08 ` [Ocfs2-devel] [PATCH AUTOSEL 5.5 51/75] ocfs2: no need try to truncate file beyond i_size Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 52/75] hfsplus: fix crash and filesystem corruption when deleting files Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 53/75] ALSA: hda: Add driver blacklist Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 54/75] ALSA: hda/realtek - Add quirk for MSI GL63 Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 55/75] perf/core: Disable page faults when getting phys address Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 56/75] libata: Return correct status in sata_pmp_eh_recover_pm() when ATA_DFLAG_DETACH is set Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 57/75] drm/amd/display: Calculate scaling ratios on every medium/full update Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 58/75] ALSA: ice1724: Fix invalid access for enumerated ctl items Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 59/75] ALSA: hda: Fix potential access overflow in beep helper Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 60/75] KVM: s390: vsie: Fix delivery of addressing exceptions Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 61/75] ASoC: Intel: bytcr_rt5640: Add quirk for MPMAN MPWIN895CL tablet Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 62/75] ipmi: fix hung processes in __get_guid() Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 63/75] ALSA: usb-audio: Add Pioneer DJ DJM-250MK2 quirk Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:08 ` [PATCH AUTOSEL 5.5 64/75] ALSA: hda/realtek - Add quirk for Lenovo Carbon X1 8th gen Sasha Levin 2020-04-18 14:08 ` Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 65/75] scsi: mpt3sas: Fix kernel panic observed on soft HBA unplug Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 66/75] xhci: Ensure link state is U3 after setting USB_SS_PORT_LS_U3 Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 67/75] xhci: Wait until link state trainsits to U0 after setting USB_SS_PORT_LS_U0 Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 68/75] xhci: Finetune host initiated USB3 rootport link suspend and resume Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 69/75] drm/amd/display: Not doing optimize bandwidth if flip pending Sasha Levin 2020-04-18 14:09 ` Sasha Levin 2020-04-18 14:09 ` Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 70/75] ASoC: SOF: trace: fix unconditional free in trace release Sasha Levin 2020-04-18 14:09 ` Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 71/75] powerpc/powernv/ioda: Fix ref count for devices with their own PE Sasha Levin 2020-04-18 14:09 ` Sasha Levin 2020-04-21 11:07 ` Frederic Barrat 2020-04-21 11:07 ` Frederic Barrat 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 72/75] pci/hotplug/pnv-php: Remove erroneous warning Sasha Levin 2020-04-18 14:09 ` Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 73/75] ocxl: Add PCI hotplug dependency to Kconfig Sasha Levin 2020-04-18 14:09 ` Sasha Levin 2020-04-19 16:32 ` Andrew Donnellan 2020-04-19 16:32 ` Andrew Donnellan 2020-04-19 23:40 ` Sasha Levin 2020-04-19 23:40 ` Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 74/75] virtio-blk: improve virtqueue error to BLK_STS Sasha Levin 2020-04-18 14:09 ` [PATCH AUTOSEL 5.5 75/75] block: fix busy device checking in blk_drop_partitions again Sasha Levin
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=20200418140910.8280-51-sashal@kernel.org \ --to=sashal@kernel.org \ --cc=akpm@linux-foundation.org \ --cc=chge@linux.alibaba.com \ --cc=gechangwei@live.cn \ --cc=ghe@suse.com \ --cc=jlbec@evilplan.org \ --cc=joseph.qi@linux.alibaba.com \ --cc=junxiao.bi@oracle.com \ --cc=linux-kernel@vger.kernel.org \ --cc=mark@fasheh.com \ --cc=ocfs2-devel@oss.oracle.com \ --cc=piaojun@huawei.com \ --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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.