All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Alexey Dobriyan <adobriyan@gmail.com>,
	Jens Axboe <axboe@kernel.dk>,
	Rajani Kantha <rajanikantha@engineer.com>
Subject: [PATCH 6.1 34/49] block: fix integer overflow in BLKSECDISCARD
Date: Thu, 30 Jan 2025 15:02:10 +0100	[thread overview]
Message-ID: <20250130140135.201870569@linuxfoundation.org> (raw)
In-Reply-To: <20250130140133.825446496@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexey Dobriyan <adobriyan@gmail.com>

commit 697ba0b6ec4ae04afb67d3911799b5e2043b4455 upstream.

I independently rediscovered

	commit 22d24a544b0d49bbcbd61c8c0eaf77d3c9297155
	block: fix overflow in blk_ioctl_discard()

but for secure erase.

Same problem:

	uint64_t r[2] = {512, 18446744073709551104ULL};
	ioctl(fd, BLKSECDISCARD, r);

will enter near infinite loop inside blkdev_issue_secure_erase():

	a.out: attempt to access beyond end of device
	loop0: rw=5, sector=3399043073, nr_sectors = 1024 limit=2048
	bio_check_eod: 3286214 callbacks suppressed

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Link: https://lore.kernel.org/r/9e64057f-650a-46d1-b9f7-34af391536ef@p183
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Rajani Kantha <rajanikantha@engineer.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 block/ioctl.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -115,7 +115,7 @@ static int blk_ioctl_discard(struct bloc
 		return -EINVAL;
 
 	filemap_invalidate_lock(inode->i_mapping);
-	err = truncate_bdev_range(bdev, mode, start, start + len - 1);
+	err = truncate_bdev_range(bdev, mode, start, end - 1);
 	if (err)
 		goto fail;
 	err = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL);
@@ -127,7 +127,7 @@ fail:
 static int blk_ioctl_secure_erase(struct block_device *bdev, fmode_t mode,
 		void __user *argp)
 {
-	uint64_t start, len;
+	uint64_t start, len, end;
 	uint64_t range[2];
 	int err;
 
@@ -142,11 +142,12 @@ static int blk_ioctl_secure_erase(struct
 	len = range[1];
 	if ((start & 511) || (len & 511))
 		return -EINVAL;
-	if (start + len > bdev_nr_bytes(bdev))
+	if (check_add_overflow(start, len, &end) ||
+	    end > bdev_nr_bytes(bdev))
 		return -EINVAL;
 
 	filemap_invalidate_lock(bdev->bd_inode->i_mapping);
-	err = truncate_bdev_range(bdev, mode, start, start + len - 1);
+	err = truncate_bdev_range(bdev, mode, start, end - 1);
 	if (!err)
 		err = blkdev_issue_secure_erase(bdev, start >> 9, len >> 9,
 						GFP_KERNEL);



  parent reply	other threads:[~2025-01-30 14:30 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 14:01 [PATCH 6.1 00/49] 6.1.128-rc1 review Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 01/49] ASoC: wm8994: Add depends on MFD core Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 02/49] ASoC: samsung: Add missing selects for MFD_WM8994 Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 03/49] seccomp: Stub for !CONFIG_SECCOMP Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 04/49] scsi: iscsi: Fix redundant response for ISCSI_UEVENT_GET_HOST_STATS request Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 05/49] drm/amd/display: Use HW lock mgr for PSR1 Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 06/49] irqchip/sunxi-nmi: Add missing SKIP_WAKE flag Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 07/49] ASoC: samsung: midas_wm1811: Map missing jack kcontrols Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 08/49] ASoC: samsung: Add missing depends on I2C Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 09/49] regmap: detach regmap from dev on regmap_exit Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 10/49] ipv6: Fix soft lockups in fib6_select_path under high next hop churn Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 11/49] softirq: Allow raising SCHED_SOFTIRQ from SMP-call-function on RT kernel Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 12/49] xfs: bump max fsgeom struct version Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 13/49] xfs: hoist freeing of rt data fork extent mappings Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 14/49] xfs: prevent rt growfs when quota is enabled Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 15/49] xfs: rt stubs should return negative errnos when rt disabled Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 16/49] xfs: fix units conversion error in xfs_bmap_del_extent_delay Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 17/49] xfs: make sure maxlen is still congruent with prod when rounding down Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 18/49] xfs: introduce protection for drop nlink Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 19/49] xfs: handle nimaps=0 from xfs_bmapi_write in xfs_alloc_file_space Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 20/49] xfs: allow read IO and FICLONE to run concurrently Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 21/49] xfs: factor out xfs_defer_pending_abort Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 22/49] xfs: abort intent items when recovery intents fail Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 23/49] xfs: only remap the written blocks in xfs_reflink_end_cow_extent Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 24/49] xfs: up(ic_sema) if flushing data device fails Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 25/49] xfs: fix internal error from AGFL exhaustion Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 26/49] xfs: inode recovery does not validate the recovered inode Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 27/49] xfs: clean up dqblk extraction Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 28/49] xfs: dquot recovery does not validate the recovered dquot Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 29/49] xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 30/49] xfs: respect the stable writes flag on the RT device Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 31/49] gfs2: Truncate address space when flipping GFS2_DIF_JDATA flag Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 32/49] io_uring: fix waiters missing wake ups Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 33/49] net: sched: fix ets qdisc OOB Indexing Greg Kroah-Hartman
2025-01-30 14:02 ` Greg Kroah-Hartman [this message]
2025-01-30 14:02 ` [PATCH 6.1 35/49] Revert "HID: multitouch: Add support for lenovo Y9000P Touchpad" Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 36/49] vfio/platform: check the bounds of read/write syscalls Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 37/49] ext4: fix access to uninitialised lock in fc replay path Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 38/49] ipv4: ip_tunnel: Fix suspicious RCU usage warning in ip_tunnel_find() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 39/49] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 40/49] wifi: iwlwifi: add a few rate index validity checks Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 41/49] smb: client: fix UAF in async decryption Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 42/49] USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 43/49] Revert "usb: gadget: u_serial: Disable ep before setting port to null to fix the crash caused by port being null" Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 44/49] ALSA: usb-audio: Add delay quirk for USB Audio Device Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 45/49] Input: atkbd - map F23 key to support default copilot shortcut Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 46/49] Input: xpad - add unofficial Xbox 360 wireless receiver clone Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 47/49] Input: xpad - add support for wooting two he (arm) Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 48/49] smb: client: fix NULL ptr deref in crypto_aead_setkey() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 49/49] ASoC: samsung: midas_wm1811: Fix Headphone Switch control creation Greg Kroah-Hartman
2025-01-30 17:58 ` [PATCH 6.1 00/49] 6.1.128-rc1 review Mark Brown
2025-01-30 21:31 ` Florian Fainelli
2025-01-31  5:38 ` Jon Hunter
2025-01-31 12:57 ` Pavel Machek
2025-01-31 13:57 ` Ron Economos
2025-01-31 15:26 ` Naresh Kamboju
2025-01-31 16:58 ` Muhammad Usama Anjum
2025-02-01  8:15 ` [PATCH 6.1] " Hardik Garg
2025-02-01 12:19 ` [PATCH 6.1 00/49] " Peter Schneider

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=20250130140135.201870569@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=adobriyan@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=patches@lists.linux.dev \
    --cc=rajanikantha@engineer.com \
    --cc=stable@vger.kernel.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 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.