From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Dan Carpenter <dan.carpenter@linaro.org>,
Filipe Manana <fdmanana@suse.com>,
David Sterba <dsterba@suse.com>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 88/88] btrfs: use u64 for buffer sizes in the tree search ioctls
Date: Wed, 15 Nov 2023 15:36:40 -0500 [thread overview]
Message-ID: <20231115191431.338512411@linuxfoundation.org> (raw)
In-Reply-To: <20231115191426.221330369@linuxfoundation.org>
4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit dec96fc2dcb59723e041416b8dc53e011b4bfc2e ]
In the tree search v2 ioctl we use the type size_t, which is an unsigned
long, to track the buffer size in the local variable 'buf_size'. An
unsigned long is 32 bits wide on a 32 bits architecture. The buffer size
defined in struct btrfs_ioctl_search_args_v2 is a u64, so when we later
try to copy the local variable 'buf_size' to the argument struct, when
the search returns -EOVERFLOW, we copy only 32 bits which will be a
problem on big endian systems.
Fix this by using a u64 type for the buffer sizes, not only at
btrfs_ioctl_tree_search_v2(), but also everywhere down the call chain
so that we can use the u64 at btrfs_ioctl_tree_search_v2().
Fixes: cc68a8a5a433 ("btrfs: new ioctl TREE_SEARCH_V2")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/linux-btrfs/ce6f4bd6-9453-4ffe-ba00-cee35495e10f@moroto.mountain/
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/ioctl.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e3f18edc1afee..23beabb489231 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2045,7 +2045,7 @@ static noinline int key_in_sk(struct btrfs_key *key,
static noinline int copy_to_sk(struct btrfs_path *path,
struct btrfs_key *key,
struct btrfs_ioctl_search_key *sk,
- size_t *buf_size,
+ u64 *buf_size,
char __user *ubuf,
unsigned long *sk_offset,
int *num_found)
@@ -2177,7 +2177,7 @@ static noinline int copy_to_sk(struct btrfs_path *path,
static noinline int search_ioctl(struct inode *inode,
struct btrfs_ioctl_search_key *sk,
- size_t *buf_size,
+ u64 *buf_size,
char __user *ubuf)
{
struct btrfs_fs_info *info = btrfs_sb(inode->i_sb);
@@ -2249,7 +2249,7 @@ static noinline int btrfs_ioctl_tree_search(struct file *file,
struct btrfs_ioctl_search_key sk;
struct inode *inode;
int ret;
- size_t buf_size;
+ u64 buf_size;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -2283,8 +2283,8 @@ static noinline int btrfs_ioctl_tree_search_v2(struct file *file,
struct btrfs_ioctl_search_args_v2 args;
struct inode *inode;
int ret;
- size_t buf_size;
- const size_t buf_limit = SZ_16M;
+ u64 buf_size;
+ const u64 buf_limit = SZ_16M;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
--
2.42.0
next prev parent reply other threads:[~2023-11-15 20:46 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 20:35 [PATCH 4.19 00/88] 4.19.299-rc1 review Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 01/88] vfs: fix readahead(2) on block devices Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 02/88] genirq/matrix: Exclude managed interrupts in irq_matrix_allocated() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 03/88] i40e: fix potential memory leaks in i40e_remove() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 04/88] tcp_metrics: add missing barriers on delete Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 05/88] tcp_metrics: properly set tp->snd_ssthresh in tcp_init_metrics() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 06/88] tcp_metrics: do not create an entry from tcp_init_metrics() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 07/88] wifi: rtlwifi: fix EDCA limit set by BT coexistence Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 08/88] can: dev: move driver related infrastructure into separate subdir Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 09/88] can: dev: can_restart(): dont crash kernel if carrier is OK Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 10/88] can: dev: can_restart(): fix race condition between controller restart and netif_carrier_on() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 11/88] thermal: core: prevent potential string overflow Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 12/88] chtls: fix tp->rcv_tstamp initialization Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 13/88] ACPI: sysfs: Fix create_pnp_modalias() and create_of_modalias() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 14/88] ipv6: avoid atomic fragment on GSO packets Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 15/88] macsec: Fix traffic counters/statistics Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 16/88] macsec: use DEV_STATS_INC() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 17/88] net: add DEV_STATS_READ() helper Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 18/88] ipvlan: properly track tx_errors Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 19/88] regmap: debugfs: Fix a erroneous check after snprintf() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 20/88] clk: qcom: clk-rcg2: Fix clock rate overflow for high parent frequencies Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 21/88] clk: keystone: pll: fix a couple NULL vs IS_ERR() checks Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 22/88] clk: npcm7xx: Fix incorrect kfree Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 23/88] clk: mediatek: clk-mt6797: Add check for mtk_alloc_clk_data Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 24/88] clk: mediatek: clk-mt2701: " Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 25/88] platform/x86: wmi: Fix probe failure when failing to register WMI devices Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 26/88] platform/x86: wmi: remove unnecessary initializations Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 27/88] platform/x86: wmi: Fix opening of char device Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 28/88] hwmon: (coretemp) Fix potentially truncated sysfs attribute name Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 29/88] drm/rockchip: vop: Fix reset of state in duplicate state crtc funcs Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 30/88] drm/radeon: possible buffer overflow Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 31/88] drm/rockchip: cdn-dp: Fix some error handling paths in cdn_dp_probe() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 32/88] ARM: dts: qcom: mdm9615: populate vsdcc fixed regulator Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 33/88] firmware: ti_sci: Mark driver as non removable Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 34/88] clk: scmi: Free scmi_clk allocated when the clocks with invalid info are skipped Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 35/88] hwrng: geode - fix accessing registers Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 36/88] sched/rt: Provide migrate_disable/enable() inlines Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 37/88] nd_btt: Make BTT lanes preemptible Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 38/88] HID: cp2112: Use irqchip template Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 39/88] hid: cp2112: Fix duplicate workqueue initialization Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 40/88] ARM: 9321/1: memset: cast the constant byte to unsigned char Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 41/88] ext4: move ix sanity check to corrent position Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 42/88] RDMA/hfi1: Workaround truncation compilation error Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 43/88] sh: bios: Revive earlyprintk support Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 44/88] ASoC: Intel: Skylake: Fix mem leak when parsing UUIDs fails Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 45/88] ASoC: ams-delta.c: use component after check Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 46/88] mfd: dln2: Fix double put in dln2_probe Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 47/88] leds: pwm: simplify if condition Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 48/88] leds: pwm: convert to atomic PWM API Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 49/88] leds: pwm: Dont disable the PWM when the LED should be off Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 50/88] ledtrig-cpu: Limit to 8 CPUs Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 51/88] leds: trigger: ledtrig-cpu:: Fix output may be truncated issue for cpu Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 52/88] tty: tty_jobctrl: fix pid memleak in disassociate_ctty() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 53/88] usb: dwc2: fix possible NULL pointer dereference caused by driver concurrency Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 54/88] dmaengine: ti: edma: handle irq_of_parse_and_map() errors Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 55/88] misc: st_core: Do not call kfree_skb() under spin_lock_irqsave() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 56/88] tools: iio: privatize globals and functions in iio_generic_buffer.c file Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 57/88] tools: iio: iio_generic_buffer: Fix some integer type and calculation Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 58/88] tools: iio: iio_generic_buffer ensure alignment Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 59/88] USB: usbip: fix stub_dev hub disconnect Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 60/88] dmaengine: pxa_dma: Remove an erroneous BUG_ON() in pxad_free_desc() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 61/88] f2fs: fix to initialize map.m_pblk in f2fs_precache_extents() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 62/88] pcmcia: cs: fix possible hung task and memory leak pccardd() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 63/88] pcmcia: ds: fix refcount leak in pcmcia_device_add() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 64/88] pcmcia: ds: fix possible name leak in error path " Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 65/88] media: bttv: fix use after free error due to btv->timeout timer Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 66/88] media: s3c-camif: Avoid inappropriate kfree() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 67/88] media: dvb-usb-v2: af9035: fix missing unlock Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 68/88] pwm: sti: Avoid conditional gotos Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 69/88] pwm: sti: Reduce number of allocations and drop usage of chip_data Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 70/88] pwm: brcmstb: Utilize appropriate clock APIs in suspend/resume Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 71/88] Input: synaptics-rmi4 - fix use after free in rmi_unregister_function() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 72/88] llc: verify mac len before reading mac header Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 73/88] tipc: Change nla_policy for bearer-related names to NLA_NUL_STRING Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 74/88] dccp: Call security_inet_conn_request() after setting IPv4 addresses Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 75/88] dccp/tcp: Call security_inet_conn_request() after setting IPv6 addresses Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 76/88] r8169: improve rtl_set_rx_mode Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 77/88] net: r8169: Disable multicast filter for RTL8168H and RTL8107E Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 78/88] net/smc: postpone release of clcsock Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 79/88] net/smc: wait for pending work before clcsock release_sock Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 80/88] net/smc: fix dangling sock under state SMC_APPFINCLOSEWAIT Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 81/88] tg3: power down device only on SYSTEM_POWER_OFF Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 82/88] r8169: respect userspace disabling IFF_MULTICAST Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 83/88] netfilter: xt_recent: fix (increase) ipv6 literal buffer length Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 84/88] fbdev: imsttfb: Fix error path of imsttfb_probe() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 85/88] fbdev: imsttfb: fix a resource leak in probe Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 86/88] fbdev: fsl-diu-fb: mark wr_reg_wa() static Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 87/88] Revert "mmc: core: Capture correct oemid-bits for eMMC cards" Greg Kroah-Hartman
2023-11-15 20:36 ` Greg Kroah-Hartman [this message]
2023-11-16 11:13 ` [PATCH 4.19 00/88] 4.19.299-rc1 review Naresh Kamboju
2023-11-17 4:24 ` Guenter Roeck
2023-11-17 17:00 ` 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=20231115191431.338512411@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=dan.carpenter@linaro.org \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--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 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).