linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Eric Biggers <ebiggers@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Qiujun Huang <anenbupt@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 78/92] fs/minix: set s_maxbytes correctly
Date: Thu, 20 Aug 2020 11:22:03 +0200	[thread overview]
Message-ID: <20200820091541.715985654@linuxfoundation.org> (raw)
In-Reply-To: <20200820091537.490965042@linuxfoundation.org>

From: Eric Biggers <ebiggers@google.com>

[ Upstream commit 32ac86efff91a3e4ef8c3d1cadd4559e23c8e73a ]

The minix filesystem leaves super_block::s_maxbytes at MAX_NON_LFS rather
than setting it to the actual filesystem-specific limit.  This is broken
because it means userspace doesn't see the standard behavior like getting
EFBIG and SIGXFSZ when exceeding the maximum file size.

Fix this by setting s_maxbytes correctly.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Qiujun Huang <anenbupt@gmail.com>
Link: http://lkml.kernel.org/r/20200628060846.682158-5-ebiggers@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/minix/inode.c    | 12 +++++++-----
 fs/minix/itree_v1.c |  2 +-
 fs/minix/itree_v2.c |  3 +--
 fs/minix/minix.h    |  1 -
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 4f994de46e6b9..03fe8bac36cf4 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -155,8 +155,10 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
 	return 0;
 }
 
-static bool minix_check_superblock(struct minix_sb_info *sbi)
+static bool minix_check_superblock(struct super_block *sb)
 {
+	struct minix_sb_info *sbi = minix_sb(sb);
+
 	if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
 		return false;
 
@@ -166,7 +168,7 @@ static bool minix_check_superblock(struct minix_sb_info *sbi)
 	 * of indirect blocks which places the limit well above U32_MAX.
 	 */
 	if (sbi->s_version == MINIX_V1 &&
-	    sbi->s_max_size > (7 + 512 + 512*512) * BLOCK_SIZE)
+	    sb->s_maxbytes > (7 + 512 + 512*512) * BLOCK_SIZE)
 		return false;
 
 	return true;
@@ -207,7 +209,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
 	sbi->s_zmap_blocks = ms->s_zmap_blocks;
 	sbi->s_firstdatazone = ms->s_firstdatazone;
 	sbi->s_log_zone_size = ms->s_log_zone_size;
-	sbi->s_max_size = ms->s_max_size;
+	s->s_maxbytes = ms->s_max_size;
 	s->s_magic = ms->s_magic;
 	if (s->s_magic == MINIX_SUPER_MAGIC) {
 		sbi->s_version = MINIX_V1;
@@ -238,7 +240,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
 		sbi->s_zmap_blocks = m3s->s_zmap_blocks;
 		sbi->s_firstdatazone = m3s->s_firstdatazone;
 		sbi->s_log_zone_size = m3s->s_log_zone_size;
-		sbi->s_max_size = m3s->s_max_size;
+		s->s_maxbytes = m3s->s_max_size;
 		sbi->s_ninodes = m3s->s_ninodes;
 		sbi->s_nzones = m3s->s_zones;
 		sbi->s_dirsize = 64;
@@ -250,7 +252,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
 	} else
 		goto out_no_fs;
 
-	if (!minix_check_superblock(sbi))
+	if (!minix_check_superblock(s))
 		goto out_illegal_sb;
 
 	/*
diff --git a/fs/minix/itree_v1.c b/fs/minix/itree_v1.c
index 046cc96ee7adb..c0d418209ead1 100644
--- a/fs/minix/itree_v1.c
+++ b/fs/minix/itree_v1.c
@@ -29,7 +29,7 @@ static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
 	if (block < 0) {
 		printk("MINIX-fs: block_to_path: block %ld < 0 on dev %pg\n",
 			block, inode->i_sb->s_bdev);
-	} else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
+	} else if (block >= inode->i_sb->s_maxbytes/BLOCK_SIZE) {
 		if (printk_ratelimit())
 			printk("MINIX-fs: block_to_path: "
 			       "block %ld too big on dev %pg\n",
diff --git a/fs/minix/itree_v2.c b/fs/minix/itree_v2.c
index f7fc7eccccccd..ee8af2f9e2828 100644
--- a/fs/minix/itree_v2.c
+++ b/fs/minix/itree_v2.c
@@ -32,8 +32,7 @@ static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
 	if (block < 0) {
 		printk("MINIX-fs: block_to_path: block %ld < 0 on dev %pg\n",
 			block, sb->s_bdev);
-	} else if ((u64)block * (u64)sb->s_blocksize >=
-			minix_sb(sb)->s_max_size) {
+	} else if ((u64)block * (u64)sb->s_blocksize >= sb->s_maxbytes) {
 		if (printk_ratelimit())
 			printk("MINIX-fs: block_to_path: "
 			       "block %ld too big on dev %pg\n",
diff --git a/fs/minix/minix.h b/fs/minix/minix.h
index df081e8afcc3c..168d45d3de73e 100644
--- a/fs/minix/minix.h
+++ b/fs/minix/minix.h
@@ -32,7 +32,6 @@ struct minix_sb_info {
 	unsigned long s_zmap_blocks;
 	unsigned long s_firstdatazone;
 	unsigned long s_log_zone_size;
-	unsigned long s_max_size;
 	int s_dirsize;
 	int s_namelen;
 	struct buffer_head ** s_imap;
-- 
2.25.1




  parent reply	other threads:[~2020-08-20  9:55 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-20  9:20 [PATCH 4.19 00/92] 4.19.141-rc1 review Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 01/92] smb3: warn on confusing error scenario with sec=krb5 Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 02/92] genirq/affinity: Make affinity setting if activated opt-in Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 03/92] PCI: hotplug: ACPI: Fix context refcounting in acpiphp_grab_context() Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 04/92] PCI: Mark AMD Navi10 GPU rev 0x00 ATS as broken Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 05/92] PCI: Add device even if driver attach failed Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 06/92] PCI: qcom: Define some PARF params needed for ipq8064 SoC Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 07/92] PCI: qcom: Add support for tx term offset for rev 2.1.0 Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 08/92] PCI: Probe bridge window attributes once at enumeration-time Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 09/92] btrfs: free anon block device right after subvolume deletion Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 10/92] btrfs: dont allocate anonymous block device for user invisible roots Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 11/92] btrfs: ref-verify: fix memory leak in add_block_entry Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 12/92] btrfs: dont traverse into the seed devices in show_devname Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 13/92] btrfs: open device without device_list_mutex Greg Kroah-Hartman
2020-08-20  9:20 ` [PATCH 4.19 14/92] btrfs: fix messages after changing compression level by remount Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 15/92] btrfs: only search for left_info if there is no right_info in try_merge_free_space Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 16/92] btrfs: fix memory leaks after failure to lookup checksums during inode logging Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 17/92] btrfs: fix return value mixup in btrfs_get_extent Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 18/92] dt-bindings: iio: io-channel-mux: Fix compatible string in example code Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 19/92] iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw() Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 20/92] xtensa: fix xtensa_pmu_setup prototype Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 21/92] cifs: Fix leak when handling lease break for cached root fid Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 22/92] powerpc: Allow 4224 bytes of stack expansion for the signal frame Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 23/92] powerpc: Fix circular dependency between percpu.h and mmu.h Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 24/92] media: vsp1: dl: Fix NULL pointer dereference on unbind Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 25/92] net: ethernet: stmmac: Disable hardware multicast filter Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 26/92] net: stmmac: dwmac1000: provide multicast filter fallback Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 27/92] net/compat: Add missing sock updates for SCM_RIGHTS Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 28/92] md/raid5: Fix Force reconstruct-write io stuck in degraded raid5 Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 29/92] bcache: allocate meta data pages as compound pages Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 30/92] bcache: fix overflow in offset_to_stripe() Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 31/92] mac80211: fix misplaced while instead of if Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 32/92] driver core: Avoid binding drivers to dead devices Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 33/92] MIPS: CPU#0 is not hotpluggable Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 34/92] ext2: fix missing percpu_counter_inc Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 35/92] ocfs2: change slot number type s16 to u16 Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 36/92] mm/page_counter.c: fix protection usage propagation Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 37/92] ftrace: Setup correct FTRACE_FL_REGS flags for module Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 38/92] kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler Greg Kroah-Hartman
2020-09-28 20:02   ` Naresh Kamboju
2020-09-28 22:09     ` Steven Rostedt
2020-09-28 22:15       ` Steven Rostedt
2020-09-29  5:49         ` Masami Hiramatsu
2020-09-29  6:52           ` Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 39/92] tracing/hwlat: Honor the tracing_cpumask Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 40/92] tracing: Use trace_sched_process_free() instead of exit() for pid tracing Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 41/92] watchdog: f71808e_wdt: indicate WDIOF_CARDRESET support in watchdog_info.options Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 42/92] watchdog: f71808e_wdt: remove use of wrong watchdog_info option Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 43/92] watchdog: f71808e_wdt: clear watchdog timeout occurred flag Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 44/92] pseries: Fix 64 bit logical memory block panic Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 45/92] module: Correctly truncate sysfs sections output Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 46/92] perf intel-pt: Fix FUP packet state Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 47/92] remoteproc: qcom: q6v5: Update running state before requesting stop Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 48/92] drm/imx: imx-ldb: Disable both channels for split mode in enc->disable() Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 49/92] mfd: arizona: Ensure 32k clock is put on driver unbind and error Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 50/92] RDMA/ipoib: Return void from ipoib_ib_dev_stop() Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 51/92] RDMA/ipoib: Fix ABBA deadlock with ipoib_reap_ah() Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 52/92] media: rockchip: rga: Introduce color fmt macros and refactor CSC mode logic Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 53/92] media: rockchip: rga: Only set output CSC mode for RGB input Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 54/92] USB: serial: ftdi_sio: make process-packet buffer unsigned Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 55/92] USB: serial: ftdi_sio: clean up receive processing Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 56/92] USB: serial: ftdi_sio: fix break and sysrq handling Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 57/92] mmc: renesas_sdhi_internal_dmac: clean up the code for dma complete Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 58/92] gpu: ipu-v3: image-convert: Combine rotate/no-rotate irq handlers Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 59/92] dm rq: dont call blk_mq_queue_stopped() in dm_stop_queue() Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 60/92] selftests/powerpc: ptrace-pkey: Rename variables to make it easier to follow code Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 61/92] selftests/powerpc: ptrace-pkey: Update the test to mark an invalid pkey correctly Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 62/92] selftests/powerpc: ptrace-pkey: Dont update expected UAMOR value Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 63/92] iommu/omap: Check for failure of a call to omap_iommu_dump_ctx Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 64/92] iommu/vt-d: Enforce PASID devTLB field mask Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 65/92] i2c: rcar: slave: only send STOP event when we have been addressed Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 66/92] clk: clk-atlas6: fix return value check in atlas6_clk_init() Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 67/92] pwm: bcm-iproc: handle clk_get_rate() return Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 68/92] tools build feature: Use CC and CXX from parent Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 69/92] i2c: rcar: avoid race when unregistering slave Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 70/92] openrisc: Fix oops caused when dumping stack Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 71/92] scsi: lpfc: nvmet: Avoid hang / use-after-free again when destroying targetport Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 72/92] watchdog: initialize device before misc_register Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 73/92] Input: sentelic - fix error return when fsp_reg_write fails Greg Kroah-Hartman
2020-08-20  9:21 ` [PATCH 4.19 74/92] drm/vmwgfx: Use correct vmw_legacy_display_unit pointer Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 75/92] drm/vmwgfx: Fix two list_for_each loop exit tests Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 76/92] net: qcom/emac: add missed clk_disable_unprepare in error path of emac_clks_phase1_init Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 77/92] nfs: Fix getxattr kernel panic and memory overflow Greg Kroah-Hartman
2020-08-20  9:22 ` Greg Kroah-Hartman [this message]
2020-08-20  9:22 ` [PATCH 4.19 79/92] fs/minix: fix block limit check for V1 filesystems Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 80/92] fs/minix: remove expected error message in block_to_path() Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 81/92] fs/ufs: avoid potential u32 multiplication overflow Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 82/92] test_kmod: avoid potential double free in trigger_config_run_type() Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 83/92] mfd: dln2: Run event handler loop under spinlock Greg Kroah-Hartman
2020-08-21  7:21   ` Pavel Machek
2020-08-21  9:06     ` Andy Shevchenko
2020-08-21  9:14       ` Greg Kroah-Hartman
2020-08-21  9:15         ` Greg Kroah-Hartman
2020-08-21 10:54           ` Andy Shevchenko
2020-08-21 11:21             ` Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 84/92] ALSA: echoaudio: Fix potential Oops in snd_echo_resume() Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 85/92] perf bench mem: Always memset source before memcpy Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 86/92] tools build feature: Quote CC and CXX for their arguments Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 87/92] sh: landisk: Add missing initialization of sh_io_port_base Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 88/92] khugepaged: retract_page_tables() remember to test exit Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 89/92] arm64: dts: marvell: espressobin: add ethernet alias Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 90/92] drm/radeon: fix fb_div check in ni_init_smc_spll_table() Greg Kroah-Hartman
2020-08-21  7:27   ` Pavel Machek
2020-08-21  7:37     ` Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 91/92] drm: Added orientation quirk for ASUS tablet model T103HAF Greg Kroah-Hartman
2020-08-20  9:22 ` [PATCH 4.19 92/92] drm/amdgpu: Fix bug where DPM is not enabled after hibernate and resume Greg Kroah-Hartman
2020-08-20 20:03 ` [PATCH 4.19 00/92] 4.19.141-rc1 review Guenter Roeck
2020-08-20 20:05 ` Guenter Roeck
2020-08-20 23:49 ` Shuah Khan
2020-08-21  7:09 ` Naresh Kamboju
2020-08-21  7:39 ` Pavel Machek

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=20200820091541.715985654@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=anenbupt@gmail.com \
    --cc=ebiggers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).