5.4.211-rc1 review
Subsystems (10)
Greg Kroah-Hartman
maintainerPATCH 306/389 NFSv4/pnfs: Fix a use-after-free bug in open
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 2135e5d56278ffdb1c2e6d325dc6b87f669b9dac upstream.
If someone cancels the open RPC call, then we must not try to free either the open slot or the layoutget operation arguments, since they are likely still in use by the hung RPC call.
--- fs/nfs/nfs4proc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/nfs/nfs4proc.c +6 -5
@@ -3039,12 +3039,13 @@ static int _nfs4_open_and_get_state(stru } out: -if (opendata->lgp) { -nfs4_lgopen_release (opendata->lgp); - opendata->lgp =NULL ; - } -if (!opendata->cancelled) +if (!opendata->cancelled) { +if (opendata->lgp) { +nfs4_lgopen_release (opendata->lgp); + opendata->lgp =NULL ; + }nfs4_sequence_free_slot (&opendata->o_res.seq_res); + }return ret; }
Greg Kroah-Hartman
maintainerPATCH 307/389 can: mcp251x: Fix race condition on receive interrupt
In reply to Greg Kroah-HartmanFrom: Sebastian Würl <[email protected]>
commit d80d60b0db6ff3dd2e29247cc2a5166d7e9ae37e upstream.
The mcp251x driver uses both receiving mailboxes of the CAN controller chips. For retrieving the CAN frames from the controller via SPI, it checks once per interrupt which mailboxes have been filled and will retrieve the messages accordingly.
This introduces a race condition, as another CAN frame can enter mailbox 1 while mailbox 0 is emptied. If now another CAN frame enters mailbox 0 until the interrupt handler is called next, mailbox 0 is emptied before mailbox 1, leading to out-of-order CAN frames in the network device.
This is fixed by checking the interrupt flags once again after freeing mailbox 0, to correctly also empty mailbox 1 before leaving the handler.
For reproducing the bug I created the following setup:
- Two CAN devices, one Raspberry Pi with MCP2515, the other can be any.
- Setup CAN to 1 MHz
- Spam bursts of 5 CAN-messages with increasing CAN-ids
- Continue sending the bursts while sleeping a second between the bursts
- Check on the RPi whether the received messages have increasing CAN-ids
- Without this patch, every burst of messages will contain a flipped pair
v3: https://lore.kernel.org/all/[email protected]
v2: https://lore.kernel.org/all/[email protected]
v1: https://lore.kernel.org/all/[email protected]
--- drivers/net/can/spi/mcp251x.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/net/can/spi/mcp251x.c +15 -3
@@ -756,9 +756,6 @@ static irqreturn_t mcp251x_can_ist(int imcp251x_read_2regs (spi,CANINTF , &intf, &eflag); -/* mask out flags we don't care about */ - intf &=CANINTF_RX |CANINTF_TX |CANINTF_ERR ; -/* receive buffer 0 */ if (intf &CANINTF_RX0IF ) {mcp251x_hw_rx (spi,0 );
@@ -768,6 +765,18 @@ static irqreturn_t mcp251x_can_ist(int iif (mcp251x_is_2510 (spi))mcp251x_write_bits (spi,CANINTF ,CANINTF_RX0IF ,0x00 ); + +/* check if buffer 1 is already known to be full, no need to re-read */ +if (!(intf &CANINTF_RX1IF )) { +u8 intf1, eflag1; + +/* intf needs to be read again to avoid a race condition */ +mcp251x_read_2regs (spi,CANINTF , &intf1, &eflag1); + +/* combine flags from both operations for error handling */ + intf |= intf1; + eflag |= eflag1; + } }/* receive buffer 1 */
@@ -778,6 +787,9 @@ static irqreturn_t mcp251x_can_ist(int i clear_intf |=CANINTF_RX1IF ; } +/* mask out flags we don't care about */ + intf &=CANINTF_RX |CANINTF_TX |CANINTF_ERR ; +/* any error or tx interrupt we need to clear? */ if (intf & (CANINTF_ERR |CANINTF_TX )) clear_intf |= intf & (CANINTF_ERR |CANINTF_TX );
Greg Kroah-Hartman
maintainerPATCH 308/389 sunrpc: fix expiry of auth creds
In reply to Greg Kroah-HartmanFrom: Dan Aloni <[email protected]>
commit f1bafa7375c01ff71fb7cb97c06caadfcfe815f3 upstream.
Before this commit, with a large enough LRU of expired items (100), the loop skipped all the expired items and was entirely ineffectual in trimming the LRU list.
--- net/sunrpc/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/auth.c +1 -1
@@ -494,7 +494,7 @@ rpcauth_prune_expired(struct list_head ** Enforce a 60 second garbage collection moratorium * Note that the cred_unused list must be time-ordered. */ -if (!time_in_range (cred->cr_expire, expired, jiffies)) +if (time_in_range (cred->cr_expire, expired, jiffies))continue ;if (!rpcauth_unhash_cred (cred))continue ;
Greg Kroah-Hartman
maintainerPATCH 309/389 SUNRPC: Reinitialise the backchannel request buffers before reuse
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 6622e3a73112fc336c1c2c582428fb5ef18e456a upstream.
When we're reusing the backchannel requests instead of freeing them, then we should reinitialise any values of the send/receive xdr_bufs so that they reflect the available space.
--- net/sunrpc/backchannel_rqst.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
net/sunrpc/backchannel_rqst.c +14 -0
@@ -64,6 +64,17 @@ static void xprt_free_allocation(structkfree (req); } +static void xprt_bc_reinit_xdr_buf (struct xdr_buf *buf) +{ + buf->head[0 ].iov_len =PAGE_SIZE ; + buf->tail[0 ].iov_len =0 ; + buf->pages =NULL ; + buf->page_len =0 ; + buf->flags =0 ; + buf->len =0 ; + buf->buflen =PAGE_SIZE ; +} +static int xprt_alloc_xdr_buf (struct xdr_buf *buf,gfp_t gfp_flags) {struct page *page;
@@ -292,6 +303,9 @@ void xprt_free_bc_rqst(struct rpc_rqst **/ spin_lock_bh (&xprt->bc_pa_lock);if (xprt_need_to_requeue (xprt)) { +xprt_bc_reinit_xdr_buf (&req->rq_snd_buf); +xprt_bc_reinit_xdr_buf (&req->rq_rcv_buf); + req->rq_rcv_buf.len =PAGE_SIZE ;list_add_tail (&req->rq_bc_pa_list, &xprt->bc_pa_list); xprt->bc_alloc_count++;atomic_inc (&xprt->bc_slot_count);
Greg Kroah-Hartman
maintainerPATCH 310/389 devlink: Fix use-after-free after a failed reload
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
commit 6b4db2e528f650c7fb712961aac36455468d5902 upstream.
After a failed devlink reload, devlink parameters are still registered, which means user space can set and get their values. In the case of the mlxsw "acl_region_rehash_interval" parameter, these operations will trigger a use-after-free [1].
Fix this by rejecting set and get operations while in the failed state. Return the "-EOPNOTSUPP" error code which does not abort the parameters dump, but instead causes it to skip over the problematic parameter.
Another possible fix is to perform these checks in the mlxsw parameter callbacks, but other drivers might be affected by the same problem and I am not aware of scenarios where these stricter checks will cause a regression.
[1]mlxsw_spectrum3 0000:00:10.0: Port 125: Failed to register netdev mlxsw_spectrum3 0000:00:10.0: Failed to create ports
==================================================================
BUG: KASAN: use-after-free in mlxsw_sp_acl_tcam_vregion_rehash_intrvl_get+0xbd/0xd0 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c:904
Read of size 4 at addr ffff8880099dcfd8 by task kworker/u4:4/777
CPU: 1 PID: 777 Comm: kworker/u4:4 Not tainted 5.19.0-rc7-custom-126601-gfe26f28c586d #1
Hardware name: QEMU MSN4700, BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
Workqueue: netns cleanup_net
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x92/0xbd lib/dump_stack.c:106
print_address_description mm/kasan/report.c:313 [inline]
print_report.cold+0x5e/0x5cf mm/kasan/report.c:429
kasan_report+0xb9/0xf0 mm/kasan/report.c:491
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:306
mlxsw_sp_acl_tcam_vregion_rehash_intrvl_get+0xbd/0xd0 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c:904
mlxsw_sp_acl_region_rehash_intrvl_get+0x49/0x60 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c:1106
mlxsw_sp_params_acl_region_rehash_intrvl_get+0x33/0x80 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:3854
devlink_param_get net/core/devlink.c:4981 [inline]
devlink_nl_param_fill+0x238/0x12d0 net/core/devlink.c:5089
devlink_param_notify+0xe5/0x230 net/core/devlink.c:5168
devlink_ns_change_notify net/core/devlink.c:4417 [inline]
devlink_ns_change_notify net/core/devlink.c:4396 [inline]
devlink_reload+0x15f/0x700 net/core/devlink.c:4507
devlink_pernet_pre_exit+0x112/0x1d0 net/core/devlink.c:12272
ops_pre_exit_list net/core/net_namespace.c:152 [inline]
cleanup_net+0x494/0xc00 net/core/net_namespace.c:582
process_one_work+0x9fc/0x1710 kernel/workqueue.c:2289
worker_thread+0x675/0x10b0 kernel/workqueue.c:2436
kthread+0x30c/0x3d0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
</TASK>
The buggy address belongs to the physical page:
page:ffffea0000267700 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x99dc
flags: 0x100000000000000(node=0|zone=1)
raw: 0100000000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8880099dce80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff8880099dcf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff8880099dcf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff8880099dd000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff8880099dd080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================--- net/core/devlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/devlink.c +2 -2
@@ -2953,7 +2953,7 @@ static int devlink_param_get(struct devl const struct devlink_param *param, struct devlink_param_gset_ctx *ctx) { - if (!param->get) + if (!param->get || devlink->reload_failed) return -EOPNOTSUPP;return param->get (devlink, param->id, ctx); }
@@ -2962,7 +2962,7 @@ static int devlink_param_set(struct devl const struct devlink_param *param, struct devlink_param_gset_ctx *ctx) { - if (!param->set) + if (!param->set || devlink->reload_failed) return -EOPNOTSUPP;return param->set (devlink, param->id, ctx); }
Greg Kroah-Hartman
maintainerPATCH 311/389 net: bgmac: Fix a BUG triggered by wrong bytes_compl
In reply to Greg Kroah-HartmanFrom: Sandor Bodo-Merle <[email protected]>
commit 1b7680c6c1f6de9904f1d9b05c952f0c64a03350 upstream.
On one of our machines we got:
kernel BUG at lib/dynamic_queue_limits.c:27!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM CPU: 0 PID: 1166 Comm: irq/41-bgmac Tainted: G W O 4.14.275-rt132 #1 Hardware name: BRCM XGS iProc task: ee3415c0 task.stack: ee32a000 PC is at dql_completed+0x168/0x178 LR is at bgmac_poll+0x18c/0x6d8 pc : [<c03b9430>] lr : [<c04b5a18>] psr: 800a0313
sp : ee32be14 ip : 000005ea fp : 00000bd4
r10: ee558500 r9 : c0116298 r8 : 00000002
r7 : 00000000 r6 : ef128810 r5 : 01993267 r4 : 01993851 r3 : ee558000 r2 : 000070e1 r1 : 00000bd4 r0 : ee52c180
Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 12c5387d Table: 8e88c04a DAC: 00000051 Process irq/41-bgmac (pid: 1166, stack limit = 0xee32a210)
Stack: (0xee32be14 to 0xee32c000)
be00: ee558520 ee52c100 ef128810
be20: 00000000 00000002 c0116298 c04b5a18 00000000 c0a0c8c4 c0951780 00000040
be40: c0701780 ee558500 ee55d520 ef05b340 ef6f9780 ee558520 00000001 00000040
be60: ffffe000 c0a56878 ef6fa040 c0952040 0000012c c0528744 ef6f97b0 fffcfb6a
be80: c0a04104 2eda8000 c0a0c4ec c0a0d368 ee32bf44 c0153534 ee32be98 ee32be98
bea0: ee32bea0 ee32bea0 ee32bea8 ee32bea8 00000000 c01462e4 ffffe000 ef6f22a8
bec0: ffffe000 00000008 ee32bee4 c0147430 ffffe000 c094a2a8 00000003 ffffe000
bee0: c0a54528 00208040 0000000c c0a0c8c4 c0a65980 c0124d3c 00000008 ee558520
bf00: c094a23c c0a02080 00000000 c07a9910 ef136970 ef136970 ee30a440 ef136900
bf20: ee30a440 00000001 ef136900 ee30a440 c016d990 00000000 c0108db0 c012500c
bf40: ef136900 c016da14 ee30a464 ffffe000 00000001 c016dd14 00000000 c016db28
bf60: ffffe000 ee21a080 ee30a400 00000000 ee32a000 ee30a440 c016dbfc ee25fd70
bf80: ee21a09c c013edcc ee32a000 ee30a400 c013ec7c 00000000 00000000 00000000
bfa0: 00000000 00000000 00000000 c0108470 00000000 00000000 00000000 00000000
bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [<c03b9430>] (dql_completed) from [<c04b5a18>] (bgmac_poll+0x18c/0x6d8) [<c04b5a18>] (bgmac_poll) from [<c0528744>] (net_rx_action+0x1c4/0x494) [<c0528744>] (net_rx_action) from [<c0124d3c>] (do_current_softirqs+0x1ec/0x43c) [<c0124d3c>] (do_current_softirqs) from [<c012500c>] (__local_bh_enable+0x80/0x98) [<c012500c>] (__local_bh_enable) from [<c016da14>] (irq_forced_thread_fn+0x84/0x98) [<c016da14>] (irq_forced_thread_fn) from [<c016dd14>] (irq_thread+0x118/0x1c0) [<c016dd14>] (irq_thread) from [<c013edcc>] (kthread+0x150/0x158) [<c013edcc>] (kthread) from [<c0108470>] (ret_from_fork+0x14/0x24)
Code: a83f15e0 0200001a 0630a0e1 c3ffffea (f201f0e7)
The issue seems similar to commit 90b3b339364c ("net: hisilicon: Fix a BUG trigered by wrong bytes_compl") and potentially introduced by commit b38c83dd0866 ("bgmac: simplify tx ring index handling").
If there is an RX interrupt between setting ring->end
and netdev_sent_queue() we can hit the BUG_ON as bgmac_dma_tx_free() can miscalculate the queue size while called from bgmac_poll().
The machine which triggered the BUG runs a v4.14 RT kernel - but the issue seems present in mainline too.
--- drivers/net/ethernet/broadcom/bgmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bgmac.c +1 -1
@@ -189,8 +189,8 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac, } slot->skb = skb; - ring->end += nr_frags +1 ;netdev_sent_queue (net_dev, skb->len); + ring->end += nr_frags +1 ;wmb ();
Signature · 1 line
2.37.2
Greg Kroah-Hartman
maintainerPATCH 312/389 pinctrl: nomadik: Fix refcount leak in nmk_pinctrl_dt_subnode_to_map
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
commit 4b32e054335ea0ce50967f63a7bfd4db058b14b9 upstream.
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak."
--- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +3 -1
@@ -1461,8 +1461,10 @@ static int nmk_pinctrl_dt_subnode_to_map has_config =nmk_pinctrl_dt_get_config (np, &configs); np_config =of_parse_phandle (np,"ste,config" ,0 ); -if (np_config) +if (np_config) { has_config |=nmk_pinctrl_dt_get_config (np_config, &configs); +of_node_put (np_config); + }if (has_config) {const char *gpio_name;const char *pin;
Greg Kroah-Hartman
maintainerPATCH 313/389 pinctrl: qcom: msm8916: Allow CAMSS GP clocks to be muxed
In reply to Greg Kroah-HartmanFrom: Nikita Travkin <[email protected]>
commit 44339391c666e46cba522d19c65a6ad1071c68b7 upstream.
GPIO 31, 32 can be muxed to GCC_CAMSS_GP(1,2)_CLK respectively but the function was never assigned to the pingroup (even though the function exists already).
Add this mode to the related pins.
--- drivers/pinctrl/qcom/pinctrl-msm8916.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/qcom/pinctrl-msm8916.c +2 -2
@@ -844,8 +844,8 @@ static const struct msm_pingroup msm8916PINGROUP (28 , pwr_modem_enabled_a,NA ,NA ,NA ,NA ,NA , qdss_tracedata_b,NA , atest_combodac),PINGROUP (29 , cci_i2c,NA ,NA ,NA ,NA ,NA , qdss_tracedata_b,NA , atest_combodac),PINGROUP (30 , cci_i2c,NA ,NA ,NA ,NA ,NA ,NA ,NA , qdss_tracedata_b), -PINGROUP (31 , cci_timer0,NA ,NA ,NA ,NA ,NA ,NA ,NA ,NA ), -PINGROUP (32 , cci_timer1,NA ,NA ,NA ,NA ,NA ,NA ,NA ,NA ), +PINGROUP (31 , cci_timer0, flash_strobe,NA ,NA ,NA ,NA ,NA ,NA ,NA ), +PINGROUP (32 , cci_timer1, flash_strobe,NA ,NA ,NA ,NA ,NA ,NA ,NA ),PINGROUP (33 , cci_async,NA ,NA ,NA ,NA ,NA ,NA ,NA , qdss_tracedata_b),PINGROUP (34 , pwr_nav_enabled_a,NA ,NA ,NA ,NA ,NA ,NA ,NA , qdss_tracedata_b), PINGROUP(35, pwr_crypto_enabled_a, NA, NA, NA, NA, NA, NA, NA, qdss_tracedata_b),
Greg Kroah-Hartman
maintainerPATCH 314/389 pinctrl: sunxi: Add I/O bias setting for H6 R-PIO
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
commit fc153c8f283bf5925615195fc9d4056414d7b168 upstream.
H6 requires I/O bias configuration on both of its PIO devices. Previously it was only done for the main PIO.
The setting for Port L is at bit 0, so the bank calculation needs to account for the pin base. Otherwise the wrong bit is used.
--- drivers/pinctrl/sunxi/pinctrl-sun50i-h6-r.c | 1 + drivers/pinctrl/sunxi/pinctrl-sunxi.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sun50i-h6-r.c +1 -0
@@ -105,6 +105,7 @@ static const struct sunxi_pinctrl_desc s .npins = ARRAY_SIZE(sun50i_h6_r_pins), .pin_base = PL_BASE, .irq_banks = 2, + .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL, };static int sun50i_h6_r_pinctrl_probe (struct platform_device *pdev)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +4 -3
@@ -616,7 +616,7 @@ static int sunxi_pinctrl_set_io_bias_cfgunsigned pin, struct regulator *supply) { - unsigned short bank = pin / PINS_PER_BANK; + unsigned short bank;unsigned long flags;u32 val, reg;int uV;
@@ -632,6 +632,9 @@ static int sunxi_pinctrl_set_io_bias_cfgif (uV ==0 )return 0 ; + pin -= pctl->desc->pin_base; + bank = pin /PINS_PER_BANK ; +switch (pctl->desc->io_bias_cfg_variant) {case BIAS_VOLTAGE_GRP_CONFIG :/*
@@ -649,8 +652,6 @@ static int sunxi_pinctrl_set_io_bias_cfgelse val =0xD ;/* 3.3V */ - pin -= pctl->desc->pin_base; - reg =readl (pctl->membase +sunxi_grp_config_reg (pin)); reg &= ~IO_BIAS_MASK ;writel (reg | val, pctl->membase +sunxi_grp_config_reg (pin));
Greg Kroah-Hartman
maintainerPATCH 315/389 ACPI: property: Return type of acpi_add_nondev_subnodes() should be bool
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit 85140ef275f577f64e8a2c5789447222dfc14fc4 upstream.
The value acpi_add_nondev_subnodes() returns is bool so change the return type of the function to match that.
--- drivers/acpi/property.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +4 -4
@@ -152,10 +152,10 @@ static bool acpi_nondev_subnode_ok(acpi_return acpi_nondev_subnode_data_ok (handle, link, list, parent); } -static int acpi_add_nondev_subnodes (acpi_handle scope, -const union acpi_object *links, -struct list_head *list, -struct fwnode_handle *parent) +static bool acpi_add_nondev_subnodes (acpi_handle scope, +const union acpi_object *links, +struct list_head *list, +struct fwnode_handle *parent) {bool ret = false;int i;
Greg Kroah-Hartman
maintainerPATCH 316/389 geneve: do not use RT_TOS for IPv6 flowlabel
In reply to Greg Kroah-HartmanFrom: Matthias May <[email protected]>
commit ca2bb69514a8bc7f83914122f0d596371352416c upstream.
According to Guillaume Nault RT_TOS should never be used for IPv6.
Quote:RT_TOS() is an old macro used to interprete IPv4 TOS as described in the obsolete RFC 1349. It's conceptually wrong to use it even in IPv4 code, although, given the current state of the code, most of the existing calls have no consequence.
But using RT_TOS() in IPv6 code is always a bug: IPv6 never had a "TOS" field to be interpreted the RFC 1349 way. There's no historical compatibility to worry about.
--- drivers/net/geneve.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/geneve.c +1 -2
@@ -851,8 +851,7 @@ static struct dst_entry *geneve_get_v6_d use_cache = false; } - fl6->flowlabel =ip6_make_flowinfo (RT_TOS (prio), - info->key.label); + fl6->flowlabel =ip6_make_flowinfo (prio, info->key.label); dst_cache = (struct dst_cache *)&info->dst_cache;if (use_cache) { dst =dst_cache_get_ip6 (dst_cache, &fl6->saddr);
Greg Kroah-Hartman
maintainerPATCH 317/389 plip: avoid rcu debug splat
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
commit bc3c8fe3c79bcdae4d90e3726054fac5cca8ac32 upstream.
WARNING: suspicious RCU usage 5.2.0-rc2-00605-g2638eb8b50cfc #1 Not tainted drivers/net/plip/plip.c:1110 suspicious rcu_dereference_check() usage!
plip_open is called with RTNL held, switch to the correct helper.
--- drivers/net/plip/plip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/plip/plip.c +1 -1
@@ -1103,7 +1103,7 @@ plip_open(struct net_device *dev)/* Any address will do - we take the first. We already have the first two bytes filled with 0xfc, from plip_init_dev(). */ -const struct in_ifaddr *ifa =rcu_dereference (in_dev->ifa_list); +const struct in_ifaddr *ifa =rtnl_dereference (in_dev->ifa_list);if (ifa !=NULL ) {memcpy (dev->dev_addr+2 , &ifa->ifa_local,4 ); }
Greg Kroah-Hartman
maintainerPATCH 318/389 vsock: Fix memory leak in vsock_connect()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit 7e97cfed9929eaabc41829c395eb0d1350fccb9d upstream.
An O_NONBLOCK vsock_connect() request may try to reschedule @connect_work. Imagine the following sequence of vsock_connect() requests:
1. The 1st, non-blocking request schedules @connect_work, which will
expire after 200 jiffies. Socket state is now SS_CONNECTING;
2. Later, the 2nd, blocking request gets interrupted by a signal after a few jiffies while waiting for the connection to be established. Socket state is back to SS_UNCONNECTED, but @connect_work is still pending, and will expire after 100 jiffies.
3. Now, the 3rd, non-blocking request tries to schedule @connect_work again. Since @connect_work is already scheduled, schedule_delayed_work() silently returns. sock_hold() is called twice, but sock_put() will only be called once in vsock_connect_timeout(), causing a memory leak reported by syzbot:
BUG: memory leak
unreferenced object 0xffff88810ea56a40 (size 1232):
comm "syz-executor756", pid 3604, jiffies 4294947681 (age 12.350s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
28 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 (..@............
backtrace:
[<ffffffff837c830e>] sk_prot_alloc+0x3e/0x1b0 net/core/sock.c:1930
[<ffffffff837cbe22>] sk_alloc+0x32/0x2e0 net/core/sock.c:1989
[<ffffffff842ccf68>] __vsock_create.constprop.0+0x38/0x320 net/vmw_vsock/af_vsock.c:734
[<ffffffff842ce8f1>] vsock_create+0xc1/0x2d0 net/vmw_vsock/af_vsock.c:2203
[<ffffffff837c0cbb>] __sock_create+0x1ab/0x2b0 net/socket.c:1468
[<ffffffff837c3acf>] sock_create net/socket.c:1519 [inline]
[<ffffffff837c3acf>] __sys_socket+0x6f/0x140 net/socket.c:1561
[<ffffffff837c3bba>] __do_sys_socket net/socket.c:1570 [inline]
[<ffffffff837c3bba>] __se_sys_socket net/socket.c:1568 [inline]
[<ffffffff837c3bba>] __x64_sys_socket+0x1a/0x20 net/socket.c:1568
[<ffffffff84512815>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff84512815>] do_syscall_64+0x35/0x80 arch/x86/entry/common.c:80
[<ffffffff84600068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
<...>Use mod_delayed_work() instead: if @connect_work is already scheduled, reschedule it, and undo sock_hold() to keep the reference count balanced.
--- net/vmw_vsock/af_vsock.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/vmw_vsock/af_vsock.c +8 -1
@@ -1207,7 +1207,14 @@ static int vsock_stream_connect(struct s* timeout fires. */ sock_hold (sk); -schedule_delayed_work (&vsk->connect_work, timeout); + +/* If the timeout function is already scheduled, +* reschedule it, then ungrab the socket refcount to +* keep it balanced. +*/ +if (mod_delayed_work (system_wq, &vsk->connect_work, + timeout)) +sock_put (sk);/* Skip ahead to preserve error code set above. */ goto out_wait;
Greg Kroah-Hartman
maintainerPATCH 319/389 vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit a3e7b29e30854ed67be0d17687e744ad0c769c4b upstream.
Imagine two non-blocking vsock_connect() requests on the same socket. The first request schedules @connect_work, and after it times out, vsock_connect_timeout() sets *sock* state back to TCP_CLOSE, but keeps *socket* state as SS_CONNECTING.
Later, the second request returns -EALREADY, meaning the socket "already has a pending connection in progress", even though the first request has already timed out.
As suggested by Stefano, fix it by setting *socket* state back to SS_UNCONNECTED, so that the second request will return -ETIMEDOUT.
--- net/vmw_vsock/af_vsock.c | 1 + 1 file changed, 1 insertion(+)
net/vmw_vsock/af_vsock.c +1 -0
@@ -1110,6 +1110,7 @@ static void vsock_connect_timeout(structif (sk->sk_state ==TCP_SYN_SENT && (sk->sk_shutdown !=SHUTDOWN_MASK )) { sk->sk_state =TCP_CLOSE ; + sk->sk_socket->state =SS_UNCONNECTED ; sk->sk_err =ETIMEDOUT ; sk->sk_error_report (sk);vsock_transport_cancel_pkt (vsk);
Greg Kroah-Hartman
maintainerPATCH 320/389 dt-bindings: arm: qcom: fix MSM8916 MTP compatibles
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit bb35fe1efbae4114bd288fae0f56070f563adcfc upstream.
The order of compatibles for MSM8916 MTP board is different:
msm8916-mtp.dtb: /: compatible: 'oneOf' conditional failed, one must be fixed:
['qcom,msm8916-mtp', 'qcom,msm8916-mtp/1', 'qcom,msm8916'] is too long
--- Documentation/devicetree/bindings/arm/qcom.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/qcom.yaml +1 -1
@@ -112,8 +112,8 @@ properties: - const: qcom,msm8974 - items: - - const: qcom,msm8916-mtp/1 - const: qcom,msm8916-mtp + - const: qcom,msm8916-mtp/1 - const: qcom,msm8916 - items:
Greg Kroah-Hartman
maintainerPATCH 321/389 tools/vm/slabinfo: use alphabetic order when two values are equal
In reply to Greg Kroah-HartmanFrom: Yuanzheng Song <[email protected]>
commit 4f5ceb8851f0081af54313abbf56de1615911faf upstream.
When the number of partial slabs in each cache is the same (e.g., the value are 0), the results of the slabinfo -X -N5 and slabinfo -P -N5 are different.
/ # slabinfo -X -N5
...
Slabs sorted by number of partial slabs
---------------------------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
inode_cache 15180 392 6217728 758/0/1 20 1 0 95 a kernfs_node_cache 22494 88 2002944 488/0/1 46 0 0 98 shmem_inode_cache 663 464 319488 38/0/1 17 1 0 96 biovec-max 50 3072 163840 4/0/1 10 3 0 93 A dentry 19050 136 2600960 633/0/2 30 0 0 99 a
/ # slabinfo -P -N5
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg bdev_cache 32 984 32.7K 1/0/1 16 2 0 96 Aa ext4_inode_cache 42 752 32.7K 1/0/1 21 2 0 96 a dentry 19050 136 2.6M 633/0/2 30 0 0 99 a TCPv6 17 1840 32.7K 0/0/1 17 3 0 95 A RAWv6 18 856 16.3K 0/0/1 18 2 0 94 A
This problem is caused by the sort_slabs(). So let's use alphabetic order when two values are equal in the sort_slabs().
By the way, the content of the slabinfo -h is not aligned because the
-P|--partial Sort by number of partial slabs
uses tabs instead of spaces. So let's use spaces instead of tabs to fix it.
--- tools/vm/slabinfo.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
tools/vm/slabinfo.c +22 -10
@@ -125,7 +125,7 @@ static void usage(void)"-n|--numa Show NUMA information\n" "-N|--lines=K Show the first K slabs\n" "-o|--ops Show kmem_cache_ops\n" -"-P|--partial Sort by number of partial slabs\n" +"-P|--partial Sort by number of partial slabs\n" "-r|--report Detailed report on single slabs\n" "-s|--shrink Shrink slabs\n" "-S|--Size Sort by size\n"
@@ -1045,15 +1045,27 @@ static void sort_slabs(void)for (s2 = s1 +1 ; s2 < slabinfo + slabs; s2++) {int result; -if (sort_size) - result =slab_size (s1) <slab_size (s2); -else if (sort_active) - result =slab_activity (s1) <slab_activity (s2); -else if (sort_loss) - result =slab_waste (s1) <slab_waste (s2); -else if (sort_partial) - result = s1->partial < s2->partial; -else +if (sort_size) { +if (slab_size (s1) ==slab_size (s2)) + result =strcasecmp (s1->name, s2->name); +else + result =slab_size (s1) <slab_size (s2); + }else if (sort_active) { +if (slab_activity (s1) ==slab_activity (s2)) + result =strcasecmp (s1->name, s2->name); +else + result =slab_activity (s1) <slab_activity (s2); + }else if (sort_loss) { +if (slab_waste (s1) ==slab_waste (s2)) + result =strcasecmp (s1->name, s2->name); +else + result =slab_waste (s1) <slab_waste (s2); + }else if (sort_partial) { +if (s1->partial == s2->partial) + result =strcasecmp (s1->name, s2->name); +else + result = s1->partial < s2->partial; + }else result =strcasecmp (s1->name, s2->name);if (show_inverted)
Greg Kroah-Hartman
maintainerPATCH 322/389 tools build: Switch to new openssl API for test-libcrypto
In reply to Greg Kroah-HartmanFrom: Roberto Sassu <[email protected]>
commit 5b245985a6de5ac18b5088c37068816d413fb8ed upstream.
Switch to new EVP API for detecting libcrypto, as Fedora 36 returns an error when it encounters the deprecated function MD5_Init() and the others.
The error would be interpreted as missing libcrypto, while in reality it is not.
--- tools/build/feature/test-libcrypto.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
tools/build/feature/test-libcrypto.c +11 -4
@@ -1,16 +1,23 @@// SPDX-License-Identifier: GPL-2.0 +#include <openssl/evp.h> #include <openssl/sha.h> #include <openssl/md5.h> int main (void ) { -MD5_CTX context; +EVP_MD_CTX *mdctx;unsigned char md[MD5_DIGEST_LENGTH +SHA_DIGEST_LENGTH ];unsigned char dat[] ="12345" ; +unsigned int digest_len; -MD5_Init (&context); -MD5_Update (&context, &dat[0 ],sizeof (dat)); -MD5_Final (&md[0 ], &context); + mdctx =EVP_MD_CTX_new (); +if (!mdctx) +return 0 ; + +EVP_DigestInit_ex (mdctx,EVP_md5 (),NULL ); +EVP_DigestUpdate (mdctx, &dat[0 ],sizeof (dat)); +EVP_DigestFinal_ex (mdctx, &md[0 ], &digest_len); +EVP_MD_CTX_free (mdctx);SHA1 (&dat[0 ],sizeof (dat), &md[0 ]);
Greg Kroah-Hartman
maintainerPATCH 323/389 NTB: ntb_tool: uninitialized heap data in tool_fn_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 45e1058b77feade4e36402828bfe3e0d3363177b upstream.
The call to:
ret = simple_write_to_buffer(buf, size, offp, ubuf, size);
will return success if it is able to write even one byte to "buf". The value of "*offp" controls which byte. This could result in reading uninitialized data when we do the sscanf() on the next line.
This code is not really desigined to handle partial writes where *offp is non-zero and the "buf" is preserved and re-used between writes. Just ban partial writes and replace the simple_write_to_buffer() with copy_from_user().
--- drivers/ntb/test/ntb_tool.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/ntb/test/ntb_tool.c +5 -3
@@ -367,14 +367,16 @@ static ssize_t tool_fn_write(struct toolu64 bits;int n; +if (*offp) +return 0 ; + buf =kmalloc (size +1 ,GFP_KERNEL );if (!buf)return -ENOMEM ; - ret =simple_write_to_buffer (buf, size, offp, ubuf, size); -if (ret <0 ) { +if (copy_from_user (buf, ubuf, size)) {kfree (buf); -return ret; +return -EFAULT ; } buf[size] =0 ;
Greg Kroah-Hartman
maintainerPATCH 324/389 nfp: ethtool: fix the display error of `ethtool -m DEVNAME`
In reply to Greg Kroah-HartmanFrom: Yu Xiao <[email protected]>
commit 4ae97cae07e15d41e5c0ebabba64c6eefdeb0bbe upstream.
The port flag isn't set to NFP_PORT_CHANGED when using ethtool -m DEVNAME before, so the port state (e.g. interface) cannot be updated. Therefore, it caused that ethtool -m DEVNAME sometimes cannot read the correct information.
E.g. ethtool -m DEVNAME cannot work when load driver before plug in optical module, as the port interface is still NONE without port update.
Now update the port state before sending info to NIC to ensure that port interface is correct (latest state).
--- drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +2 -0
@@ -1127,6 +1127,8 @@ nfp_port_get_module_info(struct net_deviu8 data; port =nfp_port_from_netdev (netdev); +/* update port state to get latest interface */ +set_bit (NFP_PORT_CHANGED , &port->flags); eth_port =nfp_port_get_eth_port (port);if (!eth_port)return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 325/389 xen/xenbus: fix return type in xenbus_file_read()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 32ad11127b95236dfc52375f3707853194a7f4b4 upstream.
This code tries to store -EFAULT in an unsigned int. The xenbus_file_read() function returns type ssize_t so the negative value is returned as a positive value to the user.
This change forces another change to the min() macro. Originally, the min() macro used "unsigned" type which checkpatch complains about. Also unsigned type would break if "len" were not capped at MAX_RW_COUNT. Use size_t for the min(). (No effect on runtime for the min_t() change).
--- drivers/xen/xenbus/xenbus_dev_frontend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/xenbus/xenbus_dev_frontend.c +2 -2
@@ -128,7 +128,7 @@ static ssize_t xenbus_file_read(struct f {struct xenbus_file_priv *u = filp->private_data;struct read_buffer *rb; -unsigned i; +ssize_t i;int ret;mutex_lock (&u->reply_mutex);
@@ -148,7 +148,7 @@ again: rb = list_entry(u->read_buffers.next, struct read_buffer, list); i =0 ;while (i < len) { -unsigned sz =min ((unsigned )len - i, rb->len - rb->cons); +size_t sz =min_t (size_t, len - i, rb->len - rb->cons); ret =copy_to_user (ubuf + i, &rb->msg[rb->cons], sz);
Greg Kroah-Hartman
maintainerPATCH 326/389 atm: idt77252: fix use-after-free bugs caused by tst_timer
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
commit 3f4093e2bf4673f218c0bf17d8362337c400e77b upstream.
There are use-after-free bugs caused by tst_timer. The root cause is that there are no functions to stop tst_timer in idt77252_exit(). One of the possible race conditions is shown below:
(thread 1) | (thread 2)
| idt77252_init_one
| init_card
| fill_tst
| mod_timer(&card->tst_timer, ...)
idt77252_exit | (wait a time)
| tst_timer
|
| ...
kfree(card) // FREE |
| card->soft_tst[e] // USEThe idt77252_dev is deallocated in idt77252_exit() and used in timer handler.
This patch adds del_timer_sync() in idt77252_exit() in order that the timer handler could be stopped before the idt77252_dev is deallocated.
--- drivers/atm/idt77252.c | 1 + 1 file changed, 1 insertion(+)
drivers/atm/idt77252.c +1 -0
@@ -3766,6 +3766,7 @@ static void __exit idt77252_exit(void) card = idt77252_chain; dev = card->atmdev; idt77252_chain = card->next; +del_timer_sync (&card->tst_timer);if (dev->phy->stop) dev->phy->stop (dev);
Greg Kroah-Hartman
maintainerPATCH 327/389 dpaa2-eth: trace the allocated address instead of page struct
In reply to Greg Kroah-HartmanFrom: Chen Lin <[email protected]>
commit e34f49348f8b7a53205b6f77707a3a6a40cf420b upstream.
We should trace the allocated address instead of page struct.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +2 -2
@@ -971,8 +971,8 @@ static int add_bufs(struct dpaa2_eth_pri buf_array[i] = addr;/* tracing point */ -trace_dpaa2_eth_buf_seed (priv->net_dev, - page,DPAA2_ETH_RX_BUF_RAW_SIZE , +trace_dpaa2_eth_buf_seed (priv->net_dev,page_address (page), +DPAA2_ETH_RX_BUF_RAW_SIZE , addr, priv->rx_buf_size, bpid); }
Greg Kroah-Hartman
maintainerPATCH 328/389 tee: add overflow check in register_shm_helper()
In reply to Greg Kroah-HartmanFrom: Jens Wiklander <[email protected]>
commit 573ae4f13f630d6660008f1974c0a8a29c30e18a upstream.
With special lengths supplied by user space, register_shm_helper() has an integer overflow when calculating the number of pages covered by a supplied user space memory region.
This causes internal_get_user_pages_fast() a helper function of pin_user_pages_fast() to do a NULL pointer dereference:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 Modules linked in: CPU: 1 PID: 173 Comm: optee_example_a Not tainted 5.19.0 #11 Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 pc : internal_get_user_pages_fast+0x474/0xa80 Call trace: internal_get_user_pages_fast+0x474/0xa80 pin_user_pages_fast+0x24/0x4c register_shm_helper+0x194/0x330 tee_shm_register_user_buf+0x78/0x120 tee_ioctl+0xd0/0x11a0 __arm64_sys_ioctl+0xa8/0xec invoke_syscall+0x48/0x114
Fix this by adding an an explicit call to access_ok() in tee_shm_register_user_buf() to catch an invalid user space address early.
--- drivers/tee/tee_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tee/tee_core.c +3 -0
@@ -182,6 +182,9 @@ tee_ioctl_shm_register(struct tee_contexif (data.flags)return -EINVAL ; +if (!access_ok ((void __user *)(unsigned long )data.addr, data.length)) +return -EFAULT ; + shm =tee_shm_register (ctx, data.addr, data.length,TEE_SHM_DMA_BUF |TEE_SHM_USER_MAPPED );if (IS_ERR (shm))
Greg Kroah-Hartman
maintainerPATCH 329/389 nios2: page fault et.al. are *not* restartable syscalls...
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 8535c239ac674f7ead0f2652932d35c52c4123b2 upstream.
make sure that ->orig_r2 is negative for everything except the syscalls.
--- arch/nios2/include/asm/entry.h | 3 ++- arch/nios2/kernel/entry.S | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-)
arch/nios2/include/asm/entry.h +2 -1
@@ -50,7 +50,8 @@ stw r13, PT_R13(sp) stw r14, PT_R14(sp) stw r15, PT_R15(sp) - stw r2, PT_ORIG_R2(sp) + movi r24, -1 + stw r24, PT_ORIG_R2(sp) stw r7, PT_ORIG_R7(sp) stw ra, PT_RA(sp)
arch/nios2/kernel/entry.S +1 -3
@@ -185,6 +185,7 @@ ENTRY(handle_system_call) ldw r5, PT_R5(sp) local_restart: + stw r2, PT_ORIG_R2(sp) /* Check that the requested system call is within limits */ movui r1, __NR_syscalls bgeu r2, r1, ret_invsyscall
@@ -336,9 +337,6 @@ external_interrupt: /* skip if no interrupt is pending */ beq r12, r0, ret_from_interrupt - movi r24, -1 - stw r24, PT_ORIG_R2(sp) - /* * Process an external hardware interrupt. */
Greg Kroah-Hartman
maintainerPATCH 330/389 nios2: dont leave NULLs in sys_call_table[]
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 45ec746c65097c25e77d24eae8fee0def5b6cc5d upstream.
fill the gaps in there with sys_ni_syscall, as everyone does...
--- arch/nios2/kernel/entry.S | 1 - arch/nios2/kernel/syscall_table.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
arch/nios2/kernel/entry.S +0 -1
@@ -193,7 +193,6 @@ local_restart: movhi r11, %hiadj(sys_call_table) add r1, r1, r11 ldw r1, %lo(sys_call_table)(r1) - beq r1, r0, ret_invsyscall /* Check if we are being traced */ GET_THREAD_INFO r11
arch/nios2/kernel/syscall_table.c +1 -0
@@ -13,5 +13,6 @@#define __SYSCALL (nr, call) [nr] = (call),void *sys_call_table[__NR_syscalls] = { + [0 ... __NR_syscalls-1 ] = sys_ni_syscall, #include <asm/unistd.h> };
Greg Kroah-Hartman
maintainerPATCH 331/389 nios2: traced syscall does need to check the syscall number
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 25ba820ef36bdbaf9884adeac69b6e1821a7df76 upstream.
all checks done before letting the tracer modify the register state are worthless...
--- arch/nios2/kernel/entry.S | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/nios2/kernel/entry.S +8 -3
@@ -255,9 +255,9 @@ traced_system_call: ldw r6, PT_R6(sp) ldw r7, PT_R7(sp) - /* Fetch the syscall function, we don't need to check the boundaries - * since this is already done. - */ + /* Fetch the syscall function. */ + movui r1, __NR_syscalls + bgeu r2, r1, traced_invsyscall slli r1, r2, 2 movhi r11,%hiadj(sys_call_table) add r1, r1, r11
@@ -287,6 +287,11 @@ end_translate_rc_and_ret2: RESTORE_SWITCH_STACK br ret_from_exception + /* If the syscall number was invalid return ENOSYS */ +traced_invsyscall: + movi r2, -ENOSYS + br translate_rc_and_ret2 + Luser_return: GET_THREAD_INFO r11 /* get thread_info pointer */ ldw r10, TI_FLAGS(r11) /* get thread_info->flags */
Greg Kroah-Hartman
maintainerPATCH 332/389 nios2: fix syscall restart checks
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 2d631bd58fe0ea3e3350212e23c9aba1fb606514 upstream.
sys_foo() returns -512 (aka -ERESTARTSYS) => do_signal() sees 512 in r2 and 1 in r1.
sys_foo() returns 512 => do_signal() sees 512 in r2 and 0 in r1.
The former is restart-worthy; the latter obviously isn't.
--- arch/nios2/kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/nios2/kernel/signal.c +1 -1
@@ -240,7 +240,7 @@ static int do_signal(struct pt_regs *reg/* * If we were from a system call, check for system call restarting... */ -if (regs->orig_r2 >=0 ) { +if (regs->orig_r2 >=0 && regs->r1) { continue_addr = regs->ea; restart_addr = continue_addr -4 ; retval = regs->r2;
Greg Kroah-Hartman
maintainerPATCH 333/389 nios2: restarts apply only to the first sigframe we build...
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 411a76b7219555c55867466c82d70ce928d6c9e1 upstream.
--- arch/nios2/kernel/signal.c | 1 + 1 file changed, 1 insertion(+)
arch/nios2/kernel/signal.c +1 -0
@@ -261,6 +261,7 @@ static int do_signal(struct pt_regs *reg regs->ea = restart_addr;break ; } + regs->orig_r2 =-1 ; }if (get_signal (&ksig)) {
Greg Kroah-Hartman
maintainerPATCH 334/389 nios2: add force_successful_syscall_return()
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit fd0c153daad135d0ec1a53c5dbe6936a724d6ae1 upstream.
If we use the ancient SysV syscall ABI, we'd better have tell the kernel how to claim that a negative return value is a success. Use ->orig_r2 for that - it's inaccessible via ptrace, so it's a fair game for changes and it's normally[*] non-negative on return from syscall. Set to -1; syscall is not going to be restart-worthy by definition, so we won't interfere with that use either.
[*] the only exception is rt_sigreturn(), where we skip the entire messing with r1/r2 anyway.
--- arch/nios2/include/asm/ptrace.h | 2 ++ arch/nios2/kernel/entry.S | 6 ++++++ 2 files changed, 8 insertions(+)
arch/nios2/include/asm/ptrace.h +2 -0
@@ -74,6 +74,8 @@ extern void show_regs(struct pt_regs *); ((struct pt_regs *)((unsigned long )current_thread_info () +THREAD_SIZE )\ - 1) +#define force_successful_syscall_return () (current_pt_regs()->orig_r2 = -1) +int do_syscall_trace_enter (void );void do_syscall_trace_exit (void );#endif /* __ASSEMBLY__ */
arch/nios2/kernel/entry.S +6 -0
@@ -213,6 +213,9 @@ local_restart: translate_rc_and_ret: movi r1, 0 bge r2, zero, 3f + ldw r1, PT_ORIG_R2(sp) + addi r1, r1, 1 + beq r1, zero, 3f sub r2, zero, r2 movi r1, 1 3:
@@ -276,6 +279,9 @@ traced_system_call: translate_rc_and_ret2: movi r1, 0 bge r2, zero, 4f + ldw r1, PT_ORIG_R2(sp) + addi r1, r1, 1 + beq r1, zero, 4f sub r2, zero, r2 movi r1, 1 4:
Greg Kroah-Hartman
maintainerPATCH 335/389 iavf: Fix adminq error handling
In reply to Greg Kroah-HartmanFrom: Przemyslaw Patynowski <[email protected]>
commit 419831617ed349992c84344dbd9e627f9e68f842 upstream.
iavf_alloc_asq_bufs/iavf_alloc_arq_bufs allocates with dma_alloc_coherent
memory for VF mailbox.
Free DMA regions for both ASQ and ARQ in case error happens during
configuration of ASQ/ARQ registers.
Without this change it is possible to see when unloading interface:
74626.583369: dma_debug_device_change: device driver has pending DMA allocations while released from device [count=32] One of leaked entries details: [device address=0x0000000b27ff9000] [size=4096 bytes] [mapped with DMA_BIDIRECTIONAL] [mapped as coherent]
--- drivers/net/ethernet/intel/iavf/iavf_adminq.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_adminq.c +13 -2
@@ -324,6 +324,7 @@ static enum iavf_status iavf_config_arq_static enum iavf_status iavf_init_asq (struct iavf_hw *hw) {enum iavf_status ret_code =0 ; +int i;if (hw->aq.asq.count >0 ) {/* queue already initialized */
@@ -354,12 +355,17 @@ static enum iavf_status iavf_init_asq(st/* initialize base registers */ ret_code =iavf_config_asq_regs (hw);if (ret_code) - goto init_adminq_free_rings; + goto init_free_asq_bufs;/* success! */ hw->aq.asq.count = hw->aq.num_asq_entries; goto init_adminq_exit; +init_free_asq_bufs: +for (i =0 ; i < hw->aq.num_asq_entries; i++) +iavf_free_dma_mem (hw, &hw->aq.asq.r.asq_bi[i]); +iavf_free_virt_mem (hw, &hw->aq.asq.dma_head); + init_adminq_free_rings:iavf_free_adminq_asq (hw);
@@ -383,6 +389,7 @@ init_adminq_exit:static enum iavf_status iavf_init_arq (struct iavf_hw *hw) {enum iavf_status ret_code =0 ; +int i;if (hw->aq.arq.count >0 ) {/* queue already initialized */
@@ -413,12 +420,16 @@ static enum iavf_status iavf_init_arq(st/* initialize base registers */ ret_code =iavf_config_arq_regs (hw);if (ret_code) - goto init_adminq_free_rings; + goto init_free_arq_bufs;/* success! */ hw->aq.arq.count = hw->aq.num_arq_entries; goto init_adminq_exit; +init_free_arq_bufs: +for (i =0 ; i < hw->aq.num_arq_entries; i++) +iavf_free_dma_mem (hw, &hw->aq.arq.r.arq_bi[i]); +iavf_free_virt_mem (hw, &hw->aq.arq.dma_head); init_adminq_free_rings:iavf_free_adminq_arq (hw);
Greg Kroah-Hartman
maintainerPATCH 336/389 clk: rockchip: add sclk_mac_lbtest to rk3188_critical_clocks
In reply to Greg Kroah-HartmanFrom: Alex Bee <[email protected]>
commit ef990bcad58cf1d13c5a49191a2c2342eb8d6709 upstream.
Since the loopbacktest clock is not exported and is not touched in the driver, it has to be added to rk3188_critical_clocks to be protected from being disabled and in order to get the emac working.
--- drivers/clk/rockchip/clk-rk3188.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/rockchip/clk-rk3188.c +1 -0
@@ -751,6 +751,7 @@ static const char *const rk3188_critical"pclk_peri" ,"hclk_cpubus" ,"hclk_vio_bus" , + "sclk_mac_lbtest", };static struct rockchip_clk_provider *__init rk3188_common_clk_init (struct device_node *np)
Greg Kroah-Hartman
maintainerPATCH 337/389 netfilter: nf_tables: really skip inactive sets when allocating name
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
commit 271c5ca826e0c3c53e0eb4032f8eaedea1ee391c upstream.
While looping to build the bitmap of used anonymous set names, check the current set in the iteration, instead of the one that is being created.
--- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -3253,7 +3253,7 @@ cont:list_for_each_entry (i, &ctx->table->sets, list) {int tmp; -if (!nft_is_active_next (ctx->net, set)) +if (!nft_is_active_next (ctx->net, i))continue ;if (!sscanf (i->name, name, &tmp))continue ;
Greg Kroah-Hartman
maintainerPATCH 338/389 powerpc/pci: Fix get_phb_number() locking
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 8d48562a2729742f767b0fdd994d6b2a56a49c63 upstream.
The recent change to get_phb_number() causes a DEBUG_ATOMIC_SLEEP warning on some systems:
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
1 lock held by swapper/1:
#0: c157efb0 (hose_spinlock){+.+.}-{2:2}, at: pcibios_alloc_controller+0x64/0x220
Preemption disabled at:
[<00000000>] 0x0
CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0-yocto-standard+ #1
Call Trace:
[d101dc90] [c073b264] dump_stack_lvl+0x50/0x8c (unreliable)
[d101dcb0] [c0093b70] __might_resched+0x258/0x2a8
[d101dcd0] [c0d3e634] __mutex_lock+0x6c/0x6ec
[d101dd50] [c0a84174] of_alias_get_id+0x50/0xf4
[d101dd80] [c002ec78] pcibios_alloc_controller+0x1b8/0x220
[d101ddd0] [c140c9dc] pmac_pci_init+0x198/0x784
[d101de50] [c140852c] discover_phbs+0x30/0x4c
[d101de60] [c0007fd4] do_one_initcall+0x94/0x344
[d101ded0] [c1403b40] kernel_init_freeable+0x1a8/0x22c
[d101df10] [c00086e0] kernel_init+0x34/0x160
[d101df30] [c001b334] ret_from_kernel_thread+0x5c/0x64This is because pcibios_alloc_controller() holds hose_spinlock but of_alias_get_id() takes of_mutex which can sleep.
The hose_spinlock protects the phb_bitmap, and also the hose_list, but it doesn't need to be held while get_phb_number() calls the OF routines, because those are only looking up information in the device tree.
So fix it by having get_phb_number() take the hose_spinlock itself, only where required, and then dropping the lock before returning. pcibios_alloc_controller() then needs to take the lock again before the list_add() but that's safe, the order of the list is not important.
--- arch/powerpc/kernel/pci-common.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
arch/powerpc/kernel/pci-common.c +10 -6
@@ -66,10 +66,6 @@ void set_pci_dma_ops(const struct dma_ma pci_dma_ops = dma_ops; } -/* -* This function should run under locking protection, specifically -* hose_spinlock. -*/ static int get_phb_number (struct device_node *dn) {int ret, phb_id =-1 ;
@@ -106,15 +102,20 @@ static int get_phb_number(struct device_if (!ret) phb_id = (int )(prop & (MAX_PHBS -1 )); +spin_lock (&hose_spinlock); +/* We need to be sure to not use the same PHB number twice. */ if ((phb_id >=0 ) && !test_and_set_bit (phb_id, phb_bitmap)) -return phb_id; + goto out_unlock;/* If everything fails then fallback to dynamic PHB numbering. */ phb_id =find_first_zero_bit (phb_bitmap,MAX_PHBS );BUG_ON (phb_id >=MAX_PHBS );set_bit (phb_id, phb_bitmap); +out_unlock: +spin_unlock (&hose_spinlock); +return phb_id; }
@@ -125,10 +126,13 @@ struct pci_controller *pcibios_alloc_con phb =zalloc_maybe_bootmem (sizeof (struct pci_controller ),GFP_KERNEL );if (phb ==NULL )return NULL ; -spin_lock (&hose_spinlock); + phb->global_number =get_phb_number (dev); + +spin_lock (&hose_spinlock);list_add_tail (&phb->list_node, &hose_list);spin_unlock (&hose_spinlock); + phb->dn = dev; phb->is_dynamic =slab_is_available ();#ifdef CONFIG_PPC64
Greg Kroah-Hartman
maintainerPATCH 339/389 net: dsa: mv88e6060: prevent crash on an unused port
In reply to Greg Kroah-HartmanFrom: Sergei Antonov <[email protected]>
commit 246bbf2f977ea36aaf41f5d24370fef433250728 upstream.
If the port isn't a CPU port nor a user port, 'cpu_dp' is a null pointer and a crash happened on dereferencing it in mv88e6060_setup_port():
[ 9.575872] Unable to handle kernel NULL pointer dereference at virtual address 00000014 ... [ 9.942216] mv88e6060_setup from dsa_register_switch+0x814/0xe84 [ 9.948616] dsa_register_switch from mdio_probe+0x2c/0x54 [ 9.954433] mdio_probe from really_probe.part.0+0x98/0x2a0 [ 9.960375] really_probe.part.0 from driver_probe_device+0x30/0x10c [ 9.967029] driver_probe_device from __device_attach_driver+0xb8/0x13c [ 9.973946] __device_attach_driver from bus_for_each_drv+0x90/0xe0 [ 9.980509] bus_for_each_drv from __device_attach+0x110/0x184 [ 9.986632] __device_attach from bus_probe_device+0x8c/0x94 [ 9.992577] bus_probe_device from deferred_probe_work_func+0x78/0xa8 [ 9.999311] deferred_probe_work_func from process_one_work+0x290/0x73c [ 10.006292] process_one_work from worker_thread+0x30/0x4b8 [ 10.012155] worker_thread from kthread+0xd4/0x10c [ 10.017238] kthread from ret_from_fork+0x14/0x3c
--- drivers/net/dsa/mv88e6060.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/dsa/mv88e6060.c +3 -0
@@ -117,6 +117,9 @@ static int mv88e6060_setup_port(struct mint addr =REG_PORT (p);int ret; +if (dsa_is_unused_port (priv->ds, p)) +return 0 ; +/* Do not force flow control, disable Ingress and Egress * Header tagging, disable VLAN tunneling, and set the port * state to Forwarding. Additionally, if this is the CPU
Greg Kroah-Hartman
maintainerPATCH 340/389 net: moxa: pass pdev instead of ndev to DMA functions
In reply to Greg Kroah-HartmanFrom: Sergei Antonov <[email protected]>
commit 3a12df22a8f68954a4ba48435c06b3d1791c87c4 upstream.
dma_map_single() calls fail in moxart_mac_setup_desc_ring() and moxart_mac_start_xmit() which leads to an incessant output of this:
[ 16.043925] moxart-ethernet 92000000.mac eth0: DMA mapping error [ 16.050957] moxart-ethernet 92000000.mac eth0: DMA mapping error [ 16.058229] moxart-ethernet 92000000.mac eth0: DMA mapping error
Passing pdev to DMA is a common approach among net drivers.
--- drivers/net/ethernet/moxa/moxart_ether.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/moxa/moxart_ether.c +10 -10
@@ -77,7 +77,7 @@ static void moxart_mac_free_memory(strucint i;for (i =0 ; i <RX_DESC_NUM ; i++) -dma_unmap_single (&ndev->dev, priv->rx_mapping[i], +dma_unmap_single (&priv->pdev->dev, priv->rx_mapping[i], priv->rx_buf_size,DMA_FROM_DEVICE );if (priv->tx_desc_base)
@@ -147,11 +147,11 @@ static void moxart_mac_setup_desc_ring(s desc + RX_REG_OFFSET_DESC1); priv->rx_buf[i] = priv->rx_buf_base + priv->rx_buf_size * i; - priv->rx_mapping[i] =dma_map_single (&ndev->dev, + priv->rx_mapping[i] =dma_map_single (&priv->pdev->dev, priv->rx_buf[i], priv->rx_buf_size,DMA_FROM_DEVICE ); -if (dma_mapping_error (&ndev->dev, priv->rx_mapping[i])) +if (dma_mapping_error (&priv->pdev->dev, priv->rx_mapping[i]))netdev_err (ndev,"DMA mapping error\n" ); moxart_desc_write(priv->rx_mapping[i],
@@ -240,7 +240,7 @@ static int moxart_rx_poll(struct napi_stif (len >RX_BUF_SIZE ) len =RX_BUF_SIZE ; -dma_sync_single_for_cpu (&ndev->dev, +dma_sync_single_for_cpu (&priv->pdev->dev, priv->rx_mapping[rx_head], priv->rx_buf_size,DMA_FROM_DEVICE ); skb =netdev_alloc_skb_ip_align (ndev, len);
@@ -294,7 +294,7 @@ static void moxart_tx_finished(struct neunsigned int tx_tail = priv->tx_tail;while (tx_tail != tx_head) { -dma_unmap_single (&ndev->dev, priv->tx_mapping[tx_tail], +dma_unmap_single (&priv->pdev->dev, priv->tx_mapping[tx_tail], priv->tx_len[tx_tail],DMA_TO_DEVICE ); ndev->stats.tx_packets++;
@@ -357,9 +357,9 @@ static int moxart_mac_start_xmit(struct len = skb->len >TX_BUF_SIZE ?TX_BUF_SIZE : skb->len; - priv->tx_mapping[tx_head] =dma_map_single (&ndev->dev, skb->data, + priv->tx_mapping[tx_head] =dma_map_single (&priv->pdev->dev, skb->data, len,DMA_TO_DEVICE ); -if (dma_mapping_error (&ndev->dev, priv->tx_mapping[tx_head])) { +if (dma_mapping_error (&priv->pdev->dev, priv->tx_mapping[tx_head])) {netdev_err (ndev,"DMA mapping error\n" ); goto out_unlock; }
@@ -378,7 +378,7 @@ static int moxart_mac_start_xmit(struct len =ETH_ZLEN ; } -dma_sync_single_for_device (&ndev->dev, priv->tx_mapping[tx_head], +dma_sync_single_for_device (&priv->pdev->dev, priv->tx_mapping[tx_head], priv->tx_buf_size,DMA_TO_DEVICE ); txdes1 =TX_DESC1_LTS |TX_DESC1_FTS | (len &TX_DESC1_BUF_SIZE_MASK );
@@ -498,7 +498,7 @@ static int moxart_mac_probe(struct platf priv->tx_buf_size =TX_BUF_SIZE ; priv->rx_buf_size =RX_BUF_SIZE ; - priv->tx_desc_base =dma_alloc_coherent (&pdev->dev,TX_REG_DESC_SIZE * + priv->tx_desc_base =dma_alloc_coherent (p_dev,TX_REG_DESC_SIZE *TX_DESC_NUM , &priv->tx_base,GFP_DMA |GFP_KERNEL );if (!priv->tx_desc_base) {
@@ -506,7 +506,7 @@ static int moxart_mac_probe(struct platf goto init_fail; } - priv->rx_desc_base =dma_alloc_coherent (&pdev->dev,RX_REG_DESC_SIZE * + priv->rx_desc_base =dma_alloc_coherent (p_dev,RX_REG_DESC_SIZE *RX_DESC_NUM , &priv->rx_base,GFP_DMA |GFP_KERNEL );if (!priv->rx_desc_base) {
Greg Kroah-Hartman
maintainerPATCH 341/389 net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry
In reply to Greg Kroah-HartmanFrom: Arun Ramadoss <[email protected]>
commit 36c0d935015766bf20d621c18313f17691bda5e3 upstream.
In the ksz9477_fdb_dump function it reads the ALU control register and exit from the timeout loop if there is valid entry or search is complete. After exiting the loop, it reads the alu entry and report to the user space irrespective of entry is valid. It works till the valid entry. If the loop exited when search is complete, it reads the alu table. The table returns all ones and it is reported to user space. So bridge fdb show gives ff:ff:ff:ff:ff:ff as last entry for every port. To fix it, after exiting the loop the entry is reported only if it is valid one.
--- drivers/net/dsa/microchip/ksz9477.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/dsa/microchip/ksz9477.c +3 -0
@@ -766,6 +766,9 @@ static int ksz9477_port_fdb_dump(struct goto exit; } +if (!(ksz_data &ALU_VALID )) +continue ; +/* read ALU table */ ksz9477_read_table (dev, alu_table);
Greg Kroah-Hartman
maintainerPATCH 342/389 ice: Ignore EEXIST when setting promisc mode
In reply to Greg Kroah-HartmanFrom: Grzegorz Siwik <[email protected]>
commit 11e551a2efa4481bd4f616ab75374a2710b480e9 upstream.
Ignore EEXIST error when setting promiscuous mode. This fix is needed because the driver could set promiscuous mode when it still has not cleared properly.
Promiscuous mode could be set only once, so setting it second time will be rejected.
--- drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_switch.c +1 -1
@@ -2627,7 +2627,7 @@ ice_set_vlan_vsi_promisc(struct ice_hw *else status =ice_set_vsi_promisc (hw, vsi_handle, promisc_mask, vlan_id); -if (status) +if (status && status != -EEXIST )break ; }
Greg Kroah-Hartman
maintainerPATCH 343/389 i40e: Fix to stop tx_timeout recovery if GLOBR fails
In reply to Greg Kroah-HartmanFrom: Alan Brady <[email protected]>
commit 57c942bc3bef0970f0b21f8e0998e76a900ea80d upstream.
When a tx_timeout fires, the PF attempts to recover by incrementally resetting. First we try a PFR, then CORER and finally a GLOBR. If the GLOBR fails, then we keep hitting the tx_timeout and incrementing the recovery level and issuing dmesgs, which is both annoying to the user and accomplishes nothing.
If the GLOBR fails, then we're pretty much totally hosed, and there's not much else we can do to recover, so this makes it such that we just kill the VSI and stop hitting the tx_timeout in such a case.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -1
@@ -409,7 +409,9 @@ static void i40e_tx_timeout(struct net_dset_bit (__I40E_GLOBAL_RESET_REQUESTED, pf->state);break ;default : -netdev_err (netdev,"tx_timeout recovery unsuccessful\n" ); +netdev_err (netdev,"tx_timeout recovery unsuccessful, device is in non-recoverable state.\n" ); +set_bit (__I40E_DOWN_REQUESTED, pf->state); +set_bit (__I40E_VSI_DOWN_REQUESTED, vsi->state);break ; }
Greg Kroah-Hartman
maintainerPATCH 344/389 fec: Fix timer capture timing in `fec_ptp_enable_pps()`
In reply to Greg Kroah-HartmanFrom: Csókás Bence <[email protected]>
commit 61d5e2a251fb20c2c5e998c3f1d52ed6d5360319 upstream.
Code reimplements functionality already in fec_ptp_read(), but misses check for FEC_QUIRK_BUG_CAPTURE. Replace with function call.
--- drivers/net/ethernet/freescale/fec_ptp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/freescale/fec_ptp.c +1 -5
@@ -141,11 +141,7 @@ static int fec_ptp_enable_pps(struct fec* NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds * to current timer would be next second. */ - tempval =readl (fep->hwp +FEC_ATIME_CTRL ); - tempval |=FEC_T_CTRL_CAPTURE ; -writel (tempval, fep->hwp +FEC_ATIME_CTRL ); - - tempval =readl (fep->hwp +FEC_ATIME ); + tempval = fep->cc.read (&fep->cc);/* Convert the ptp local counter to 1588 timestamp */ ns =timecounter_cyc2time (&fep->tc, tempval); ts =ns_to_timespec64 (ns);
Greg Kroah-Hartman
maintainerPATCH 345/389 igb: Add lock to avoid data race
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
commit 6faee3d4ee8be0f0367d0c3d826afb3571b7a5e0 upstream.
The commit c23d92b80e0b ("igb: Teardown SR-IOV before unregister_netdev()") places the unregister_netdev() call after the igb_disable_sriov() call to avoid functionality issue.
However, it introduces several race conditions when detaching a device. For example, when .remove() is called, the below interleaving leads to use-after-free.
(FREE from device detaching) | (USE from netdev core)
igb_remove | igb_ndo_get_vf_config
igb_disable_sriov | vf >= adapter->vfs_allocated_count?
kfree(adapter->vf_data) |
adapter->vfs_allocated_count = 0 |
| memcpy(... adapter->vf_data[vf]Moreover, the igb_disable_sriov() also suffers from data race with the requests from VF driver.
(FREE from device detaching) | (USE from requests) igb_remove | igb_msix_other igb_disable_sriov | igb_msg_task kfree(adapter->vf_data) | vf < adapter->vfs_allocated_count adapter->vfs_allocated_count = 0 |
To this end, this commit first eliminates the data races from netdev core by using rtnl_lock (similar to commit 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")). And then adds a spinlock to eliminate races from driver requests. (similar to commit 1e53834ce541 ("ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero")
--- drivers/net/ethernet/intel/igb/igb.h | 2 ++ drivers/net/ethernet/intel/igb/igb_main.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igb/igb.h +2 -0
@@ -594,6 +594,8 @@ struct igb_adapter {struct igb_mac_addr *mac_table;struct vf_mac_filter vf_macs;struct vf_mac_filter *vf_mac_list; +/* lock for VF resources */ +spinlock_t vfs_lock; };/* flags controlling PTP/1588 function */
drivers/net/ethernet/intel/igb/igb_main.c +11 -1
@@ -3491,6 +3491,7 @@ static int igb_disable_sriov(struct pci_struct net_device *netdev =pci_get_drvdata (pdev);struct igb_adapter *adapter =netdev_priv (netdev);struct e1000_hw *hw = &adapter->hw; +unsigned long flags;/* reclaim resources allocated to VFs */ if (adapter->vf_data) {
@@ -3503,12 +3504,13 @@ static int igb_disable_sriov(struct pci_pci_disable_sriov (pdev);msleep (500 ); } - +spin_lock_irqsave (&adapter->vfs_lock, flags);kfree (adapter->vf_mac_list); adapter->vf_mac_list =NULL ;kfree (adapter->vf_data); adapter->vf_data =NULL ; adapter->vfs_allocated_count =0 ; +spin_unlock_irqrestore (&adapter->vfs_lock, flags);wr32 (E1000_IOVCTL ,E1000_IOVCTL_REUSE_VFQ );wrfl ();msleep (100 );
@@ -3668,7 +3670,9 @@ static void igb_remove(struct pci_dev *pigb_release_hw_control (adapter);#ifdef CONFIG_PCI_IOV +rtnl_lock ();igb_disable_sriov (pdev); +rtnl_unlock ();#endif unregister_netdev (netdev);
@@ -3829,6 +3833,9 @@ static int igb_sw_init(struct igb_adaptespin_lock_init (&adapter->nfc_lock);spin_lock_init (&adapter->stats64_lock); + +/* init spinlock to avoid concurrency of VF resources */ +spin_lock_init (&adapter->vfs_lock);#ifdef CONFIG_PCI_IOV switch (hw->mac.type) {case e1000_82576:
@@ -7569,8 +7576,10 @@ unlock:static void igb_msg_task (struct igb_adapter *adapter) {struct e1000_hw *hw = &adapter->hw; +unsigned long flags;u32 vf; +spin_lock_irqsave (&adapter->vfs_lock, flags);for (vf =0 ; vf < adapter->vfs_allocated_count; vf++) {/* process any reset requests */ if (!igb_check_for_rst (hw, vf))
@@ -7584,6 +7593,7 @@ static void igb_msg_task(struct igb_adapif (!igb_check_for_ack (hw, vf))igb_rcv_ack_from_vf (adapter, vf); } +spin_unlock_irqrestore (&adapter->vfs_lock, flags); }/**
Greg Kroah-Hartman
maintainerPATCH 346/389 gcc-plugins: Undefine LATENT_ENTROPY_PLUGIN when plugin disabled for a file
In reply to Greg Kroah-HartmanFrom: Andrew Donnellan <[email protected]>
commit 012e8d2034f1bda8863435cd589636e618d6a659 upstream.
Commit 36d4b36b6959 ("lib/nodemask: inline next_node_in() and node_random()") refactored some code by moving node_random() from lib/nodemask.c to include/linux/nodemask.h, thus requiring nodemask.h to include random.h, which conditionally defines add_latent_entropy() depending on whether the macro LATENT_ENTROPY_PLUGIN is defined.
This broke the build on powerpc, where nodemask.h is indirectly included in arch/powerpc/kernel/prom_init.c, part of the early boot machinery that is excluded from the latent entropy plugin using DISABLE_LATENT_ENTROPY_PLUGIN. It turns out that while we add a gcc flag to disable the actual plugin, we don't undefine LATENT_ENTROPY_PLUGIN.
This leads to the following:
CC arch/powerpc/kernel/prom_init.o
In file included from ./include/linux/nodemask.h:97,
from ./include/linux/mmzone.h:17,
from ./include/linux/gfp.h:7,
from ./include/linux/xarray.h:15,
from ./include/linux/radix-tree.h:21,
from ./include/linux/idr.h:15,
from ./include/linux/kernfs.h:12,
from ./include/linux/sysfs.h:16,
from ./include/linux/kobject.h:20,
from ./include/linux/pci.h:35,
from arch/powerpc/kernel/prom_init.c:24:
./include/linux/random.h: In function 'add_latent_entropy':
./include/linux/random.h:25:46: error: 'latent_entropy' undeclared (first use in this function); did you mean 'add_latent_entropy'?
25 | add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
| ^~~~~~~~~~~~~~
| add_latent_entropy ./include/linux/random.h:25:46: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [scripts/Makefile.build:249: arch/powerpc/kernel/prom_init.o] Fehler 1
make[1]: *** [scripts/Makefile.build:465: arch/powerpc/kernel] Fehler 2
make: *** [Makefile:1855: arch/powerpc] Error 2
Change the DISABLE_LATENT_ENTROPY_PLUGIN flags to undefine LATENT_ENTROPY_PLUGIN for files where the plugin is disabled.
--- scripts/Makefile.gcc-plugins | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.gcc-plugins +1 -1
@@ -6,7 +6,7 @@ gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_EN gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) \ += -DLATENT_ENTROPY_PLUGIN ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY - DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable + DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable -ULATENT_ENTROPY_PLUGIN endif export DISABLE_LATENT_ENTROPY_PLUGIN
Greg Kroah-Hartman
maintainerPATCH 347/389 locking/atomic: Make test_and_*_bit() ordered on failure
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit 415d832497098030241605c52ea83d4e2cfa7879 upstream.
These operations are documented as always ordered in include/asm-generic/bitops/instrumented-atomic.h, and producer-consumer type use cases where one side needs to ensure a flag is left pending after some shared data was updated rely on this ordering, even in the failure case.
This is the case with the workqueue code, which currently suffers from a reproducible ordering violation on Apple M1 platforms (which are notoriously out-of-order) that ends up causing the TTY layer to fail to deliver data to userspace properly under the right conditions. This change fixes that bug.
Change the documentation to restrict the "no order on failure" story to the _lock() variant (for which it makes sense), and remove the early-exit from the generic implementation, which is what causes the missing barrier semantics in that case. Without this, the remaining atomic op is fully ordered (including on ARM64 LSE, as of recent versions of the architecture spec).
--- Documentation/atomic_bitops.txt | 2 +- include/asm-generic/bitops/atomic.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
Documentation/atomic_bitops.txt +1 -1
@@ -59,7 +59,7 @@ Like with atomic_t, the rule of thumb is - RMW operations that have a return value are fully ordered. - RMW operations that are conditional are unordered on FAILURE, - otherwise the above rules apply. In the case of test_and_{}_bit() operations, + otherwise the above rules apply. In the case of test_and_set_bit_lock(), if the bit in memory is unchanged by the operation then it is deemed to have failed.
include/asm-generic/bitops/atomic.h +0 -6
@@ -35,9 +35,6 @@ static inline int test_and_set_bit(unsigunsigned long mask =BIT_MASK (nr); p +=BIT_WORD (nr); -if (READ_ONCE (*p) & mask) -return 1 ; - old =atomic_long_fetch_or (mask, (atomic_long_t *)p);return !!(old & mask); }
@@ -48,9 +45,6 @@ static inline int test_and_clear_bit(unsunsigned long mask =BIT_MASK (nr); p +=BIT_WORD (nr); -if (!(READ_ONCE (*p) & mask)) -return 0 ; - old =atomic_long_fetch_andnot (mask, (atomic_long_t *)p);return !!(old & mask); }
Greg Kroah-Hartman
maintainerPATCH 348/389 drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 91b3c8dbe898df158fd2a84675f3a284ff6666f7 ]
In this function, there are two refcount leak bugs:
(1) when breaking out of for_each_endpoint_of_node(), we need call the of_node_put() for the 'ep';
(2) we should call of_node_put() for the reference returned by of_graph_get_remote_port() when it is not used anymore.
--- drivers/gpu/drm/meson/meson_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_drv.c +4 -1
@@ -124,8 +124,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)for_each_endpoint_of_node (dev->of_node, ep) {/* If the endpoint node exists, consider it enabled */ remote =of_graph_get_remote_port (ep); -if (remote) +if (remote) { +of_node_put (remote); +of_node_put (ep);return true; + } }return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 349/389 PCI: Add ACS quirk for Broadcom BCM5750x NICs
In reply to Greg Kroah-HartmanFrom: Pavan Chebbi <[email protected]>
[ Upstream commit afd306a65cedb9589564bdb23a0c368abc4215fd ]
The Broadcom BCM5750x NICs may be multi-function devices. They do not advertise ACS capability. Peer-to-peer transactions are not possible between the individual functions, so it is safe to treat them as fully isolated.
Add an ACS quirk for these devices so the functions can be in independent IOMMU groups and attached individually to userspace applications using VFIO.
--- drivers/pci/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pci/quirks.c +3 -0
@@ -4943,6 +4943,9 @@ static const struct pci_dev_acs_enabled { { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs },/* Broadcom multi-function device */ { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0x1750, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0x1751, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0x1752, pci_quirk_mf_endpoint_acs }, { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs },/* Amazon Annapurna Labs */ { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 350/389 usb: cdns3 fix use-after-free at workaround 2
In reply to Greg Kroah-HartmanFrom: Frank Li <[email protected]>
[ Upstream commit 7d602f30149a117eea260208b1661bc404c21dfd ]
BUG: KFENCE: use-after-free read in __list_del_entry_valid+0x10/0xac
cdns3_wa2_remove_old_request()
{
...
kfree(priv_req->request.buf);
cdns3_gadget_ep_free_request(&priv_ep->endpoint, &priv_req->request);
list_del_init(&priv_req->list);
^^^ use after free
...
}cdns3_gadget_ep_free_request() free the space pointed by priv_req, but priv_req is used in the following list_del_init().
This patch move list_del_init() before cdns3_gadget_ep_free_request().
--- drivers/usb/cdns3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/cdns3/gadget.c +1 -1
@@ -549,9 +549,9 @@ static void cdns3_wa2_remove_old_request(struct cdns3_endpoint *priv_ep)trace_cdns3_wa2 (priv_ep,"removes eldest request" );kfree (priv_req->request.buf); +list_del_init (&priv_req->list);cdns3_gadget_ep_free_request (&priv_ep->endpoint, &priv_req->request); -list_del_init (&priv_req->list); --priv_ep->wa2_counter;if (!chain)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 351/389 usb: gadget: uvc: call uvc uvcg_warn on completed status instead of uvcg_info
In reply to Greg Kroah-HartmanFrom: Michael Grzeschik <[email protected]>
[ Upstream commit a725d0f6dfc5d3739d6499f30ec865305ba3544d ]
Likewise to the uvcvideo hostside driver, this patch is changing the usb_request message of an non zero completion handler call from dev_info to dev_warn.
--- drivers/usb/gadget/function/uvc_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/uvc_video.c +1 -1
@@ -191,7 +191,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) goto requeue;default : -uvcg_info (&video->uvc->func, +uvcg_warn (&video->uvc->func,"VS request completed with status %d.\n" , req->status);uvcg_queue_cancel (queue,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 352/389 irqchip/tegra: Fix overflow implicit truncation warnings
In reply to Greg Kroah-HartmanFrom: Sai Prakash Ranjan <[email protected]>
[ Upstream commit 443685992bda9bb4f8b17fc02c9f6c60e62b1461 ]
Fix -Woverflow warnings for tegra irqchip driver which is a result of moving arm64 custom MMIO accessor macros to asm-generic function implementations giving a bonus type-checking now and uncovering these overflow warnings.
drivers/irqchip/irq-tegra.c: In function ‘tegra_ictlr_suspend’:drivers/irqchip/irq-tegra.c:151:18: warning: large integer implicitly truncated to unsigned type [-Woverflow]
writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
^--- drivers/irqchip/irq-tegra.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-tegra.c +5 -5
@@ -148,10 +148,10 @@ static int tegra_ictlr_suspend(void) lic->cop_iep[i] =readl_relaxed (ictlr +ICTLR_COP_IEP_CLASS );/* Disable COP interrupts */ -writel_relaxed (~0ul , ictlr +ICTLR_COP_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_COP_IER_CLR );/* Disable CPU interrupts */ -writel_relaxed (~0ul , ictlr +ICTLR_CPU_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_CPU_IER_CLR );/* Enable the wakeup sources of ictlr */ writel_relaxed (lic->ictlr_wake_mask[i], ictlr +ICTLR_CPU_IER_SET );
@@ -172,12 +172,12 @@ static void tegra_ictlr_resume(void)writel_relaxed (lic->cpu_iep[i], ictlr +ICTLR_CPU_IEP_CLASS ); -writel_relaxed (~0ul , ictlr +ICTLR_CPU_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_CPU_IER_CLR );writel_relaxed (lic->cpu_ier[i], ictlr +ICTLR_CPU_IER_SET );writel_relaxed (lic->cop_iep[i], ictlr +ICTLR_COP_IEP_CLASS ); -writel_relaxed (~0ul , ictlr +ICTLR_COP_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_COP_IER_CLR );writel_relaxed (lic->cop_ier[i], ictlr +ICTLR_COP_IER_SET ); }
@@ -312,7 +312,7 @@ static int __init tegra_ictlr_init(struct device_node *node, lic->base[i] = base;/* Disable all interrupts */ -writel_relaxed (~0UL , base +ICTLR_CPU_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), base +ICTLR_CPU_IER_CLR );/* All interrupts target IRQ */ writel_relaxed (0 , base +ICTLR_CPU_IEP_CLASS );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 353/389 drm/meson: Fix overflow implicit truncation warnings
In reply to Greg Kroah-HartmanFrom: Sai Prakash Ranjan <[email protected]>
[ Upstream commit 98692f52c588225034cbff458622c2c06dfcb544 ]
Fix -Woverflow warnings for drm/meson driver which is a result of moving arm64 custom MMIO accessor macros to asm-generic function implementations giving a bonus type-checking now and uncovering these overflow warnings.
drivers/gpu/drm/meson/meson_viu.c: In function ‘meson_viu_init’:drivers/gpu/drm/meson/meson_registers.h:1826:48: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
#define VIU_OSD_BLEND_REORDER(dest, src) ((src) << (dest * 4))
^
drivers/gpu/drm/meson/meson_viu.c:472:18: note: in expansion of macro ‘VIU_OSD_BLEND_REORDER’
writel_relaxed(VIU_OSD_BLEND_REORDER(0, 1) |
^~~~~~~~~~~~~~~~~~~~~--- drivers/gpu/drm/meson/meson_viu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/meson/meson_viu.c +11 -11
@@ -400,17 +400,17 @@ void meson_viu_init(struct meson_drm *priv) priv->io_base + _REG(VD2_IF0_LUMA_FIFO_SIZE));if (meson_vpu_is_compatible (priv,VPU_COMPATIBLE_G12A )) { -writel_relaxed (VIU_OSD_BLEND_REORDER (0 ,1 ) | -VIU_OSD_BLEND_REORDER (1 ,0 ) | -VIU_OSD_BLEND_REORDER (2 ,0 ) | -VIU_OSD_BLEND_REORDER (3 ,0 ) | -VIU_OSD_BLEND_DIN_EN (1 ) | -VIU_OSD_BLEND1_DIN3_BYPASS_TO_DOUT1 | -VIU_OSD_BLEND1_DOUT_BYPASS_TO_BLEND2 | -VIU_OSD_BLEND_DIN0_BYPASS_TO_DOUT0 | -VIU_OSD_BLEND_BLEN2_PREMULT_EN (1 ) | -VIU_OSD_BLEND_HOLD_LINES (4 ), - priv->io_base +_REG (VIU_OSD_BLEND_CTRL )); +u32 val = (u32 )VIU_OSD_BLEND_REORDER (0 ,1 ) | + (u32 )VIU_OSD_BLEND_REORDER (1 ,0 ) | + (u32 )VIU_OSD_BLEND_REORDER (2 ,0 ) | + (u32 )VIU_OSD_BLEND_REORDER (3 ,0 ) | + (u32 )VIU_OSD_BLEND_DIN_EN (1 ) | + (u32 )VIU_OSD_BLEND1_DIN3_BYPASS_TO_DOUT1 | + (u32 )VIU_OSD_BLEND1_DOUT_BYPASS_TO_BLEND2 | + (u32 )VIU_OSD_BLEND_DIN0_BYPASS_TO_DOUT0 | + (u32 )VIU_OSD_BLEND_BLEN2_PREMULT_EN (1 ) | + (u32 )VIU_OSD_BLEND_HOLD_LINES (4 ); +writel_relaxed (val, priv->io_base +_REG (VIU_OSD_BLEND_CTRL ));writel_relaxed (OSD_BLEND_PATH_SEL_ENABLE , priv->io_base +_REG (OSD1_BLEND_SRC_CTRL ));
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 354/389 usb: host: ohci-ppc-of: Fix refcount leak bug
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 40a959d7042bb7711e404ad2318b30e9f92c6b9b ]
In ohci_hcd_ppc_of_probe(), of_find_compatible_node() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.
--- drivers/usb/host/ohci-ppc-of.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/ohci-ppc-of.c +1 -0
@@ -169,6 +169,7 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)release_mem_region (res.start,0x4 ); }else pr_debug ("%s: cannot get ehci offset from fdt\n" , __FILE__); +of_node_put (np); }irq_dispose_mapping (irq);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 355/389 usb: renesas: Fix refcount leak bug
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 9d6d5303c39b8bc182475b22f45504106a07f086 ]
In usbhs_rza1_hardware_init(), of_find_node_by_name() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.
--- drivers/usb/renesas_usbhs/rza.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/renesas_usbhs/rza.c +4 -0
@@ -23,6 +23,10 @@ static int usbhs_rza1_hardware_init(struct platform_device *pdev) extal_clk =of_find_node_by_name (NULL ,"extal" );of_property_read_u32 (usb_x1_clk,"clock-frequency" , &freq_usb);of_property_read_u32 (extal_clk,"clock-frequency" , &freq_extal); + +of_node_put (usb_x1_clk); +of_node_put (extal_clk); +if (freq_usb ==0 ) {if (freq_extal ==12000000 ) {/* Select 12MHz XTAL */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 356/389 vboxguest: Do not use devm for irq
In reply to Greg Kroah-HartmanFrom: Pascal Terjan <[email protected]>
[ Upstream commit 6169525b76764acb81918aa387ac168fb9a55575 ]
When relying on devm it doesn't get freed early enough which causes the following warning when unloading the module:
[249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest' [249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140
[249348.837379] Call Trace: [249348.837385] unregister_irq_proc+0xbd/0xe0 [249348.837392] free_desc+0x23/0x60 [249348.837396] irq_free_descs+0x4a/0x70 [249348.837401] irq_domain_free_irqs+0x160/0x1a0 [249348.837452] mp_unmap_irq+0x5c/0x60 [249348.837458] acpi_unregister_gsi_ioapic+0x29/0x40 [249348.837463] acpi_unregister_gsi+0x17/0x30 [249348.837467] acpi_pci_irq_disable+0xbf/0xe0 [249348.837473] pcibios_disable_device+0x20/0x30 [249348.837478] pci_disable_device+0xef/0x120 [249348.837482] vbg_pci_remove+0x6c/0x70 [vboxguest]
--- drivers/virt/vboxguest/vboxguest_linux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/virt/vboxguest/vboxguest_linux.c +6 -3
@@ -361,8 +361,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) goto err_vbg_core_exit; } - ret =devm_request_irq (dev, pci->irq, vbg_core_isr,IRQF_SHARED , -DEVICE_NAME , gdev); + ret =request_irq (pci->irq, vbg_core_isr,IRQF_SHARED ,DEVICE_NAME , + gdev);if (ret) {vbg_err ("vboxguest: Error requesting irq: %d\n" , ret); goto err_vbg_core_exit;
@@ -372,7 +372,7 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)if (ret) {vbg_err ("vboxguest: Error misc_register %s failed: %d\n" ,DEVICE_NAME , ret); - goto err_vbg_core_exit; + goto err_free_irq; } ret =misc_register (&gdev->misc_device_user);
@@ -408,6 +408,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)misc_deregister (&gdev->misc_device_user); err_unregister_misc_device:misc_deregister (&gdev->misc_device); +err_free_irq: +free_irq (pci->irq, gdev); err_vbg_core_exit:vbg_core_exit (gdev); err_disable_pcidev:
@@ -424,6 +426,7 @@ static void vbg_pci_remove(struct pci_dev *pci) vbg_gdev =NULL ;mutex_unlock (&vbg_gdev_mutex); +free_irq (pci->irq, gdev);device_remove_file (gdev->dev, &dev_attr_host_features);device_remove_file (gdev->dev, &dev_attr_host_version);misc_deregister (&gdev->misc_device_user);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 357/389 clk: qcom: ipq8074: dont disable gcc_sleep_clk_src
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit 1bf7305e79aab095196131bdc87a97796e0e3fac ]
Once the usb sleep clocks are disabled, clock framework is trying to disable the sleep clock source also.
However, it seems that it cannot be disabled and trying to do so produces:
[ 245.436390] ------------[ cut here ]------------ [ 245.441233] gcc_sleep_clk_src status stuck at 'on' [ 245.441254] WARNING: CPU: 2 PID: 223 at clk_branch_wait+0x130/0x140 [ 245.450435] Modules linked in: xhci_plat_hcd xhci_hcd dwc3 dwc3_qcom leds_gpio [ 245.456601] CPU: 2 PID: 223 Comm: sh Not tainted 5.18.0-rc4 #215 [ 245.463889] Hardware name: Xiaomi AX9000 (DT) [ 245.470050] pstate: 204000c5 (nzCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 245.474307] pc : clk_branch_wait+0x130/0x140 [ 245.481073] lr : clk_branch_wait+0x130/0x140 [ 245.485588] sp : ffffffc009f2bad0 [ 245.489838] x29: ffffffc009f2bad0 x28: ffffff8003e6c800 x27: 0000000000000000 [ 245.493057] x26: 0000000000000000 x25: 0000000000000000 x24: ffffff800226ef20 [ 245.500175] x23: ffffffc0089ff550 x22: 0000000000000000 x21: ffffffc008476ad0 [ 245.507294] x20: 0000000000000000 x19: ffffffc00965ac70 x18: fffffffffffc51a7 [ 245.514413] x17: 68702e3030303837 x16: 3a6d726f6674616c x15: ffffffc089f2b777 [ 245.521531] x14: ffffffc0095c9d18 x13: 0000000000000129 x12: 0000000000000129 [ 245.528649] x11: 00000000ffffffea x10: ffffffc009621d18 x9 : 0000000000000001 [ 245.535767] x8 : 0000000000000001 x7 : 0000000000017fe8 x6 : 0000000000000001 [ 245.542885] x5 : ffffff803fdca6d8 x4 : 0000000000000000 x3 : 0000000000000027 [ 245.550002] x2 : 0000000000000027 x1 : 0000000000000023 x0 : 0000000000000026 [ 245.557122] Call trace: [ 245.564229] clk_branch_wait+0x130/0x140 [ 245.566490] clk_branch2_disable+0x2c/0x40 [ 245.570656] clk_core_disable+0x60/0xb0 [ 245.574561] clk_core_disable+0x68/0xb0 [ 245.578293] clk_disable+0x30/0x50 [ 245.582113] dwc3_qcom_remove+0x60/0xc0 [dwc3_qcom] [ 245.585588] platform_remove+0x28/0x60 [ 245.590361] device_remove+0x4c/0x80 [ 245.594179] device_release_driver_internal+0x1dc/0x230 [ 245.597914] device_driver_detach+0x18/0x30 [ 245.602861] unbind_store+0xec/0x110 [ 245.607027] drv_attr_store+0x24/0x40 [ 245.610847] sysfs_kf_write+0x44/0x60 [ 245.614405] kernfs_fop_write_iter+0x128/0x1c0 [ 245.618052] new_sync_write+0xc0/0x130 [ 245.622391] vfs_write+0x1d4/0x2a0 [ 245.626123] ksys_write+0x58/0xe0 [ 245.629508] __arm64_sys_write+0x1c/0x30 [ 245.632895] invoke_syscall.constprop.0+0x5c/0x110 [ 245.636890] do_el0_svc+0xa0/0x150 [ 245.641488] el0_svc+0x18/0x60 [ 245.644872] el0t_64_sync_handler+0xa4/0x130 [ 245.647914] el0t_64_sync+0x174/0x178 [ 245.652340] ---[ end trace 0000000000000000 ]---
So, add CLK_IS_CRITICAL flag to the clock so that the kernel won't try to disable the sleep clock.
--- drivers/clk/qcom/gcc-ipq8074.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-ipq8074.c +1 -0
@@ -667,6 +667,7 @@ static struct clk_branch gcc_sleep_clk_src = { }, .num_parents = 1, .ops = &clk_branch2_ops, + .flags = CLK_IS_CRITICAL, }, }, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 358/389 scsi: lpfc: Prevent buffer overflow crashes in debugfs with malformed user input
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
[ Upstream commit f8191d40aa612981ce897e66cda6a88db8df17bb ]
Malformed user input to debugfs results in buffer overflow crashes. Adapt input string lengths to fit within internal buffers, leaving space for NULL terminators.
--- drivers/scsi/lpfc/lpfc_debugfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +10 -10
@@ -2402,8 +2402,8 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,struct lpfc_sli4_hdw_queue *qp;struct lpfc_multixri_pool *multixri_pool; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;/* Protect copy from user */ if (!access_ok (buf, nbytes))
@@ -2487,8 +2487,8 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,if (!phba->targetport)return -ENXIO ; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
@@ -2629,8 +2629,8 @@ lpfc_debugfs_nvmektime_write(struct file *file, const char __user *buf,char mybuf[64 ];char *pbuf; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
@@ -2757,8 +2757,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,char mybuf[64 ];char *pbuf; -if (nbytes >63 ) - nbytes =63 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
@@ -2863,8 +2863,8 @@ lpfc_debugfs_cpucheck_write(struct file *file, const char __user *buf,char *pbuf;int i, j; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 359/389 gadgetfs: ep_io - wait until IRQ finishes
In reply to Greg Kroah-HartmanFrom: Jozef Martiniak <[email protected]>
[ Upstream commit 04cb742d4d8f30dc2e83b46ac317eec09191c68e ]
after usb_ep_queue() if wait_for_completion_interruptible() is interrupted we need to wait until IRQ gets finished.
Otherwise complete() from epio_complete() can corrupt stack.
--- drivers/usb/gadget/legacy/inode.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/legacy/inode.c +1 -0
@@ -362,6 +362,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len)spin_unlock_irq (&epdata->dev->lock);DBG (epdata->dev,"endpoint gone\n" ); +wait_for_completion (&done); epdata->status = -ENODEV ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 360/389 cxl: Fix a memory leak in an error handling path
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 3a15b45b5454da862376b5d69a4967f5c6fa1368 ]
A bitmap_zalloc() must be balanced by a corresponding bitmap_free() in the error handling path of afu_allocate_irqs().
--- drivers/misc/cxl/irq.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/cxl/irq.c +1 -0
@@ -349,6 +349,7 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) out: cxl_ops->release_irq_ranges (&ctx->irqs, ctx->afu->adapter); +bitmap_free (ctx->irq_bitmap);afu_irq_name_free (ctx);return -ENOMEM ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 361/389 PCI/ACPI: Guard ARM64-specific mcfg_quirks
In reply to Greg Kroah-HartmanFrom: Huacai Chen <[email protected]>
[ Upstream commit 40a6cc141b4b9580de140bcb3e893445708acc5d ]
Guard ARM64-specific quirks with CONFIG_ARM64 to avoid build errors, since mcfg_quirks will be shared by more than one architectures.
--- drivers/acpi/pci_mcfg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/pci_mcfg.c +3 -0
@@ -41,6 +41,8 @@ struct mcfg_fixup { static struct mcfg_fixup mcfg_quirks[] = {/* { OEM_ID, OEM_TABLE_ID, REV, SEGMENT, BUS_RANGE, ops, cfgres }, */ +#ifdef CONFIG_ARM64 +#define AL_ECAM (table_id, rev, seg, ops) \ { "AMAZON", table_id, rev, seg, MCFG_BUS_ANY, ops }
@@ -162,6 +164,7 @@ static struct mcfg_fixup mcfg_quirks[] = {ALTRA_ECAM_QUIRK (1 ,13 ),ALTRA_ECAM_QUIRK (1 ,14 ), ALTRA_ECAM_QUIRK(1, 15), +#endif /* ARM64 */ };static char mcfg_oem_id[ACPI_OEM_ID_SIZE ];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 362/389 um: add "noreboot" command line option for PANIC_TIMEOUT=-1 setups
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
[ Upstream commit dda520d07b95072a0b63f6c52a8eb566d08ea897 ]
QEMU has a -no-reboot option, which halts instead of reboots when the guest asks to reboot. This is invaluable when used with CONFIG_PANIC_TIMEOUT=-1 (and panic_on_warn), because it allows panics and warnings to be caught immediately in CI. Implement this in UML too, by way of a basic setup param.
--- arch/um/os-Linux/skas/process.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/um/os-Linux/skas/process.c +16 -1
@@ -5,6 +5,7 @@*/ #include <stdlib.h> +#include <stdbool.h> #include <unistd.h> #include <sched.h> #include <errno.h>
@@ -641,10 +642,24 @@ void halt_skas(void)UML_LONGJMP (&initial_jmpbuf,INIT_JMP_HALT ); } +static bool noreboot; + +static int __init noreboot_cmd_param (char *str,int *add) +{ + noreboot = true; +return 0 ; +} + +__uml_setup ("noreboot" , noreboot_cmd_param, +"noreboot\n" +" Rather than rebooting, exit always, akin to QEMU's -no-reboot option.\n" +" This is useful if you're using CONFIG_PANIC_TIMEOUT in order to catch\n" +" crashes in CI\n" ); +void reboot_skas (void ) {block_signals_trace (); -UML_LONGJMP (&initial_jmpbuf,INIT_JMP_REBOOT ); +UML_LONGJMP (&initial_jmpbuf, noreboot ?INIT_JMP_HALT :INIT_JMP_REBOOT ); }void __switch_mm (struct mm_id *mm_idp)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 363/389 selftests/kprobe: Do not test for GRP/ without event failures
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
[ Upstream commit f5eab65ff2b76449286d18efc7fee3e0b72f7d9b ]
A new feature is added where kprobes (and other probes) do not need to explicitly state the event name when creating a probe. The event name will come from what is being attached.
That is:
# echo 'p:foo/ vfs_read' > kprobe_events
Will no longer error, but instead create an event:
# cat kprobe_events p:foo/p_vfs_read_0 vfs_read
This should not be tested as an error case anymore. Remove it from the selftest as now this feature "breaks" the selftest as it no longer fails as expected.
--- .../selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +0 -1
@@ -24,7 +24,6 @@ check_error 'p:^/bar vfs_read' # NO_GROUP_NAME check_error 'p:^12345678901234567890123456789012345678901234567890123456789012345/bar vfs_read' # GROUP_TOO_LONG check_error 'p:^foo.1/bar vfs_read' # BAD_GROUP_NAME -check_error 'p:foo/^ vfs_read' # NO_EVENT_NAME check_error 'p:foo/^12345678901234567890123456789012345678901234567890123456789012345 vfs_read' # EVENT_TOO_LONG check_error 'p:foo/^bar.1 vfs_read' # BAD_EVENT_NAME
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 364/389 dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 1e42f82cbec7b2cc4873751e7791e6611901c5fc ]
It's not allowed to quit remove early without cleaning up completely. Otherwise this results in resource leaks that probably yield graver problems later. Here for example some tasklets might survive the lifetime of the sprd-dma device and access sdev which is freed after .remove() returns.
As none of the device freeing requires an active device, just ignore the return value of pm_runtime_get_sync().
--- drivers/dma/sprd-dma.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dma/sprd-dma.c +1 -4
@@ -1201,11 +1201,8 @@ static int sprd_dma_remove(struct platform_device *pdev) {struct sprd_dma_dev *sdev =platform_get_drvdata (pdev);struct sprd_dma_chn *c, *cn; -int ret; - ret =pm_runtime_get_sync (&pdev->dev); -if (ret <0 ) -return ret; +pm_runtime_get_sync (&pdev->dev);/* explicitly free the irq */ if (sdev->irq >0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 365/389 nvmet-tcp: fix lockdep complaint on nvmet_tcp_wq flush during queue teardown
In reply to Greg Kroah-HartmanFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 533d2e8b4d5e4c89772a0adce913525fb86cbbee ]
We probably need nvmet_tcp_wq to have MEM_RECLAIM as we are sending/receiving for the socket from works on this workqueue. Also this eliminates lockdep complaints:
--
[ 6174.010200] workqueue: WQ_MEM_RECLAIM nvmet-wq:nvmet_tcp_release_queue_work [nvmet_tcp] is flushing !WQ_MEM_RECLAIM nvmet_tcp_wq:nvmet_tcp_io_work [nvmet_tcp] [ 6174.010216] WARNING: CPU: 20 PID: 14456 at kernel/workqueue.c:2628
check_flush_dependency+0x110/0x14c
--- drivers/nvme/target/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/tcp.c +2 -1
@@ -1762,7 +1762,8 @@ static int __init nvmet_tcp_init(void) {int ret; - nvmet_tcp_wq =alloc_workqueue ("nvmet_tcp_wq" ,WQ_HIGHPRI ,0 ); + nvmet_tcp_wq =alloc_workqueue ("nvmet_tcp_wq" , +WQ_MEM_RECLAIM |WQ_HIGHPRI ,0 );if (!nvmet_tcp_wq)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 366/389 drivers:md:fix a potential use-after-free bug
In reply to Greg Kroah-HartmanFrom: Wentao_Liang <[email protected]>
[ Upstream commit 104212471b1c1817b311771d817fb692af983173 ]
In line 2884, "raid5_release_stripe(sh);" drops the reference to sh and may cause sh to be released. However, sh is subsequently used in lines 2886 "if (sh->batch_head && sh != sh->batch_head)". This may result in an use-after-free bug.
It can be fixed by moving "raid5_release_stripe(sh);" to the bottom of the function.
--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
@@ -2666,10 +2666,10 @@ static void raid5_end_write_request(struct bio *bi)if (!test_and_clear_bit (R5_DOUBLE_LOCKED , &sh->dev[i].flags))clear_bit (R5_LOCKED , &sh->dev[i].flags);set_bit (STRIPE_HANDLE , &sh->state); -raid5_release_stripe (sh);if (sh->batch_head && sh != sh->batch_head)raid5_release_stripe (sh->batch_head); +raid5_release_stripe (sh); }static void raid5_error (struct mddev *mddev,struct md_rdev *rdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 367/389 ext4: avoid remove directory when directory is corrupted
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
[ Upstream commit b24e77ef1c6d4dbf42749ad4903c97539cc9755a ]
Now if check directoy entry is corrupted, ext4_empty_dir may return true then directory will be removed when file system mounted with "errors=continue". In order not to make things worse just return false when directory is corrupted.
--- fs/ext4/namei.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
fs/ext4/namei.c +2 -5
@@ -2929,11 +2929,8 @@ bool ext4_empty_dir(struct inode *inode) de = (struct ext4_dir_entry_2 *) (bh->b_data + (offset & (sb->s_blocksize -1 )));if (ext4_check_dir_entry (inode,NULL , de, bh, - bh->b_data, bh->b_size, offset)) { - offset = (offset | (sb->s_blocksize -1 )) +1 ; -continue ; - } -if (le32_to_cpu (de->inode)) { + bh->b_data, bh->b_size, offset) || +le32_to_cpu (de->inode)) {brelse (bh);return false; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 368/389 ext4: avoid resizing to a partial cluster size
In reply to Greg Kroah-HartmanFrom: Kiselev, Oleg <[email protected]>
[ Upstream commit 69cb8e9d8cd97cdf5e293b26d70a9dee3e35e6bd ]
This patch avoids an attempt to resize the filesystem to an unaligned cluster boundary. An online resize to a size that is not integral to cluster size results in the last iteration attempting to grow the fs by a negative amount, which trips a BUG_ON and leaves the fs with a corrupted in-memory superblock.
--- fs/ext4/resize.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ext4/resize.c +10 -0
@@ -1979,6 +1979,16 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count) }brelse (bh); +/* +* For bigalloc, trim the requested size to the nearest cluster +* boundary to avoid creating an unusable filesystem. We do this +* silently, instead of returning an error, to avoid breaking +* callers that blindly resize the filesystem to the full size of +* the underlying block device. +*/ +if (ext4_has_feature_bigalloc (sb)) + n_blocks_count &= ~((1 <<EXT4_CLUSTER_BITS (sb)) -1 ); + retry: o_blocks_count =ext4_blocks_count (es);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 369/389 lib/list_debug.c: Detect uninitialized lists
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 0cc011c576aaa4de505046f7a6c90933d7c749a9 ]
In some circumstances, attempts are made to add entries to or to remove entries from an uninitialized list. A prime example is amdgpu_bo_vm_destroy(): It is indirectly called from ttm_bo_init_reserved() if that function fails, and tries to remove an entry from a list. However, that list is only initialized in amdgpu_bo_create_vm() after the call to ttm_bo_init_reserved() returned success. This results in crashes such as
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 1 PID: 1479 Comm: chrome Not tainted 5.10.110-15768-g29a72e65dae5 Hardware name: Google Grunt/Grunt, BIOS Google_Grunt.11031.149.0 07/15/2020 RIP: 0010:__list_del_entry_valid+0x26/0x7d ... Call Trace: amdgpu_bo_vm_destroy+0x48/0x8b ttm_bo_init_reserved+0x1d7/0x1e0 amdgpu_bo_create+0x212/0x476 ? amdgpu_bo_user_destroy+0x23/0x23 ? kmem_cache_alloc+0x60/0x271 amdgpu_bo_create_vm+0x40/0x7d amdgpu_vm_pt_create+0xe8/0x24b ...
Check if the list's prev and next pointers are NULL to catch such problems.
--- lib/list_debug.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
lib/list_debug.c +10 -2
@@ -20,7 +20,11 @@ bool __list_add_valid(struct list_head *new, struct list_head *prev, struct list_head *next) { - if (CHECK_DATA_CORRUPTION(next->prev != prev, + if (CHECK_DATA_CORRUPTION(prev == NULL, + "list_add corruption. prev is NULL.\n") || + CHECK_DATA_CORRUPTION(next == NULL, + "list_add corruption. next is NULL.\n") || + CHECK_DATA_CORRUPTION(next->prev != prev, "list_add corruption. next->prev should be prev (%px), but was %px. (next=%px).\n", prev, next->prev, next) || CHECK_DATA_CORRUPTION(prev->next != next,
@@ -42,7 +46,11 @@ bool __list_del_entry_valid(struct list_head *entry) prev = entry->prev; next = entry->next; -if (CHECK_DATA_CORRUPTION (next ==LIST_POISON1 , +if (CHECK_DATA_CORRUPTION (next ==NULL , +"list_del corruption, %px->next is NULL\n" , entry) || +CHECK_DATA_CORRUPTION (prev ==NULL , +"list_del corruption, %px->prev is NULL\n" , entry) || +CHECK_DATA_CORRUPTION (next ==LIST_POISON1 ,"list_del corruption, %px->next is LIST_POISON1 (%px)\n" , entry,LIST_POISON1 ) || CHECK_DATA_CORRUPTION(prev == LIST_POISON2,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 370/389 tty: serial: Fix refcount leak bug in ucc_uart.c
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit d24d7bb2cd947676f9b71fb944d045e09b8b282f ]
In soc_info(), of_find_node_by_type() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.
--- drivers/tty/serial/ucc_uart.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/ucc_uart.c +2 -0
@@ -1141,6 +1141,8 @@ static unsigned int soc_info(unsigned int *rev_h, unsigned int *rev_l)/* No compatible property, so try the name. */ soc_string = np->name; +of_node_put (np); +/* Extract the SOC number from the "PowerPC," string */ if ((sscanf (soc_string,"PowerPC,%u" , &soc) !=1 ) || !soc)return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 371/389 vfio: Clear the caps->buf to NULL after free
In reply to Greg Kroah-HartmanFrom: Schspa Shi <[email protected]>
[ Upstream commit 6641085e8d7b3f061911517f79a2a15a0a21b97b ]
On buffer resize failure, vfio_info_cap_add() will free the buffer, report zero for the size, and return -ENOMEM. As additional hardening, also clear the buffer pointer to prevent any chance of a double free.
--- drivers/vfio/vfio.c | 1 + 1 file changed, 1 insertion(+)
drivers/vfio/vfio.c +1 -0
@@ -1802,6 +1802,7 @@ struct vfio_info_cap_header *vfio_info_cap_add(struct vfio_info_cap *caps, buf =krealloc (caps->buf, caps->size + size,GFP_KERNEL );if (!buf) {kfree (caps->buf); + caps->buf =NULL ; caps->size =0 ;return ERR_PTR (-ENOMEM ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 372/389 mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 7a9f743ceead60ed454c46fbc3085ee9a79cbebb ]
We should call of_node_put() for the reference 'uctl_node' returned by of_get_parent() which will increase the refcount. Otherwise, there will be a refcount leak bug.
--- arch/mips/cavium-octeon/octeon-platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -1
@@ -86,11 +86,12 @@ static void octeon2_usb_clocks_start(struct device *dev) "refclk-frequency", &clock_rate);if (i) {dev_err (dev,"No UCTL \"refclk-frequency\"\n" ); +of_node_put (uctl_node); goto exit; } i =of_property_read_string (uctl_node,"refclk-type" , &clock_type); - +of_node_put (uctl_node);if (!i &&strcmp ("crystal" , clock_type) ==0 ) is_crystal_clock = true; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 373/389 riscv: dts: sifive: Add fu540 topology information
In reply to Greg Kroah-HartmanFrom: Conor Dooley <[email protected]>
[ Upstream commit af8f260abc608c06e4466a282b53f1e2dc09f042 ]
The fu540 has no cpu-map node, so tools like hwloc cannot correctly parse the topology. Add the node using the existing node labels.
--- arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/riscv/boot/dts/sifive/fu540-c000.dtsi +24 -0
@@ -129,6 +129,30 @@ interrupt-controller; }; }; + + cpu-map { + cluster0 { + core0 { + cpu = <&cpu0>; + }; + + core1 { + cpu = <&cpu1>; + }; + + core2 { + cpu = <&cpu2>; + }; + + core3 { + cpu = <&cpu3>; + }; + + core4 { + cpu = <&cpu4>; + }; + }; + }; }; soc { #address-cells = <2>;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 374/389 riscv: mmap with PROT_WRITE but no PROT_READ is invalid
In reply to Greg Kroah-HartmanFrom: Celeste Liu <[email protected]>
[ Upstream commit 2139619bcad7ac44cc8f6f749089120594056613 ]
As mentioned in Table 4.5 in RISC-V spec Volume 2 Section 4.3, write but not read is "Reserved for future use.". For now, they are not valid. In the current code, -wx is marked as invalid, but -w- is not marked as invalid.
This patch refines that judgment.
--- arch/riscv/kernel/sys_riscv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/riscv/kernel/sys_riscv.c +2 -3
@@ -18,9 +18,8 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,if (unlikely (offset & (~PAGE_MASK >> page_shift_offset)))return -EINVAL ; -if ((prot &PROT_WRITE ) && (prot &PROT_EXEC )) -if (unlikely (!(prot &PROT_READ ))) -return -EINVAL ; +if (unlikely ((prot &PROT_WRITE ) && !(prot &PROT_READ ))) +return -EINVAL ;return ksys_mmap_pgoff (addr, len, prot, flags, fd, offset >> (PAGE_SHIFT - page_shift_offset));
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 375/389 RISC-V: Add fast call path of crash_kexec()
In reply to Greg Kroah-HartmanFrom: Xianting Tian <[email protected]>
[ Upstream commit 3f1901110a89b0e2e13adb2ac8d1a7102879ea98 ]
Currently, almost all archs (x86, arm64, mips...) support fast call of crash_kexec() when "regs && kexec_should_crash()" is true. But RISC-V not, it can only enter crash system via panic(). However panic() doesn't pass the regs of the real accident scene to crash_kexec(), it caused we can't get accurate backtrace via gdb,
$ riscv64-linux-gnu-gdb vmlinux vmcore Reading symbols from vmlinux... [New LWP 95] #0 console_unlock () at kernel/printk/printk.c:2557 2557 if (do_cond_resched) (gdb) bt #0 console_unlock () at kernel/printk/printk.c:2557 #1 0x0000000000000000 in ?? ()
With the patch we can get the accurate backtrace,
$ riscv64-linux-gnu-gdb vmlinux vmcore Reading symbols from vmlinux... [New LWP 95] #0 0xffffffe00063a4e0 in test_thread (data=<optimized out>) at drivers/test_crash.c:81 81 *(int *)p = 0xdead; (gdb) (gdb) bt #0 0xffffffe00064d5c0 in test_thread (data=<optimized out>) at drivers/test_crash.c:81 #1 0x0000000000000000 in ?? ()
Test code to produce NULL address dereference in test_crash.c,
void *p = NULL; *(int *)p = 0xdead;
--- arch/riscv/kernel/traps.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/riscv/kernel/traps.c +4 -0
@@ -15,6 +15,7 @@#include <linux/mm.h> #include <linux/module.h> #include <linux/irq.h> +#include <linux/kexec.h> #include <asm/processor.h> #include <asm/ptrace.h>
@@ -43,6 +44,9 @@ void die(struct pt_regs *regs, const char *str) ret =notify_die (DIE_OOPS , str, regs,0 , regs->scause,SIGSEGV ); +if (regs &&kexec_should_crash (current)) +crash_kexec (regs); +bust_spinlocks (0 );add_taint (TAINT_DIE ,LOCKDEP_NOW_UNRELIABLE );spin_unlock_irq (&die_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 376/389 watchdog: export lockup_detector_reconfigure
In reply to Greg Kroah-HartmanFrom: Laurent Dufour <[email protected]>
[ Upstream commit 7c56a8733d0a2a4be2438a7512566e5ce552fccf ]
In some circumstances it may be interesting to reconfigure the watchdog from inside the kernel.
On PowerPC, this may helpful before and after a LPAR migration (LPM) is initiated, because it implies some latencies, watchdog, and especially NMI watchdog is expected to be triggered during this operation. Reconfiguring the watchdog with a factor, would prevent it to happen too frequently during LPM.
Rename lockup_detector_reconfigure() as __lockup_detector_reconfigure() and create a new function lockup_detector_reconfigure() calling __lockup_detector_reconfigure() under the protection of watchdog_mutex.
--- include/linux/nmi.h | 2 ++ kernel/watchdog.c | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-)
include/linux/nmi.h +2 -0
@@ -122,6 +122,8 @@ int watchdog_nmi_probe(void);int watchdog_nmi_enable (unsigned int cpu);void watchdog_nmi_disable (unsigned int cpu); +void lockup_detector_reconfigure (void ); +/** * touch_nmi_watchdog - restart NMI watchdog timeout. *
kernel/watchdog.c +16 -5
@@ -568,7 +568,7 @@ int lockup_detector_offline_cpu(unsigned int cpu)return 0 ; } -static void lockup_detector_reconfigure (void ) +static void __lockup_detector_reconfigure (void ) {cpus_read_lock ();watchdog_nmi_stop ();
@@ -588,6 +588,13 @@ static void lockup_detector_reconfigure(void)__lockup_detector_cleanup (); } +void lockup_detector_reconfigure (void ) +{ +mutex_lock (&watchdog_mutex); +__lockup_detector_reconfigure (); +mutex_unlock (&watchdog_mutex); +} +/* * Create the watchdog thread infrastructure and configure the detector(s). *
@@ -608,13 +615,13 @@ static __init void lockup_detector_setup(void)return ;mutex_lock (&watchdog_mutex); -lockup_detector_reconfigure (); +__lockup_detector_reconfigure (); softlockup_initialized = true; mutex_unlock(&watchdog_mutex); }#else /* CONFIG_SOFTLOCKUP_DETECTOR */ -static void lockup_detector_reconfigure (void ) +static void __lockup_detector_reconfigure (void ) {cpus_read_lock ();watchdog_nmi_stop ();
@@ -622,9 +629,13 @@ static void lockup_detector_reconfigure(void)watchdog_nmi_start (); cpus_read_unlock(); } +void lockup_detector_reconfigure (void ) +{ +__lockup_detector_reconfigure (); +}static inline void lockup_detector_setup (void ) { -lockup_detector_reconfigure (); +__lockup_detector_reconfigure (); }#endif /* !CONFIG_SOFTLOCKUP_DETECTOR */
@@ -664,7 +675,7 @@ static void proc_watchdog_update(void) {/* Remove impossible cpus to keep sysctl output clean. */ cpumask_and (&watchdog_cpumask, &watchdog_cpumask, cpu_possible_mask); -lockup_detector_reconfigure (); +__lockup_detector_reconfigure (); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 377/389 powerpc/32: Dont always pass -mcpu=powerpc to the compiler
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit 446cda1b21d9a6b3697fe399c6a3a00ff4a285f5 ]
Since commit 4bf4f42a2feb ("powerpc/kbuild: Set default generic machine type for 32-bit compile"), when building a 32 bits kernel with a bi-arch version of GCC, or when building a book3s/32 kernel, the option -mcpu=powerpc is passed to GCC at all time, relying on it being eventually overriden by a subsequent -mcpu=xxxx.
But when building the same kernel with a 32 bits only version of GCC, that is not done, relying on gcc being built with the expected default CPU.
This logic has two problems. First, it is a bit fragile to rely on whether the GCC version is bi-arch or not, because today we can have bi-arch versions of GCC configured with a 32 bits default. Second, there are some versions of GCC which don't support -mcpu=powerpc, for instance for e500 SPE-only versions.
So, stop relying on this approximative logic and allow the user to decide whether he/she wants to use the toolchain's default CPU or if he/she wants to set one, and allow only possible CPUs based on the selected target.
--- arch/powerpc/Makefile | 26 +------------------------- arch/powerpc/platforms/Kconfig.cputype | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 28 deletions(-)
arch/powerpc/Makefile +1 -25
@@ -17,23 +17,6 @@ HAS_BIARCH := $(call cc-option-yn, -m32) # Set default 32 bits cross compilers for vdso and boot wrapper CROSS32_COMPILE ?= -ifeq ($(HAS_BIARCH),y) -ifeq ($(CROSS32_COMPILE),) -ifdef CONFIG_PPC32 -# These options will be overridden by any -mcpu option that the CPU -# or platform code sets later on the command line, but they are needed -# to set a sane 32-bit cpu target for the 64-bit cross compiler which -# may default to the wrong ISA. -KBUILD_CFLAGS += -mcpu=powerpc -KBUILD_AFLAGS += -mcpu=powerpc -endif -endif -endif - -ifdef CONFIG_PPC_BOOK3S_32 -KBUILD_CFLAGS += -mcpu=powerpc -endif - # If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use # ppc64_defconfig because we have nothing better to go on. uname := $(shell uname -m)
@@ -192,6 +175,7 @@ endif endif CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU)) +AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU)) # Altivec option not allowed with e500mc64 in GCC. ifdef CONFIG_ALTIVEC
@@ -202,14 +186,6 @@ endif CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU) CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU)) -ifdef CONFIG_PPC32 -ifdef CONFIG_PPC_E500MC -CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc) -else -CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc) -endif -endif - asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr)
arch/powerpc/platforms/Kconfig.cputype +18 -3
@@ -118,9 +118,9 @@ config GENERIC_CPU depends on PPC64 && CPU_LITTLE_ENDIAN select ARCH_HAS_FAST_MULTIPLIER -config GENERIC_CPU +config POWERPC_CPU bool "Generic 32 bits powerpc" - depends on PPC32 && !PPC_8xx + depends on PPC32 && !PPC_8xx && !PPC_85xx config CELL_CPU bool "Cell Broadband Engine"
@@ -174,11 +174,23 @@ config G4_CPU depends on PPC_BOOK3S_32 select ALTIVEC +config E500_CPU + bool "e500 (8540)" + depends on PPC_85xx && !PPC_E500MC + +config E500MC_CPU + bool "e500mc" + depends on PPC_85xx && PPC_E500MC + +config TOOLCHAIN_DEFAULT_CPU + bool "Rely on the toolchain's implicit default CPU" + depends on PPC32 + endchoice config TARGET_CPU_BOOL bool - default !GENERIC_CPU + default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU config TARGET_CPU string
@@ -193,6 +205,9 @@ config TARGET_CPU default "e300c2" if E300C2_CPU default "e300c3" if E300C3_CPU default "G4" if G4_CPU + default "8540" if E500_CPU + default "e500mc" if E500MC_CPU + default "powerpc" if POWERPC_CPU config PPC_BOOK3S def_bool y
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 378/389 ALSA: core: Add async signal helpers
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit ef34a0ae7a2654bc9e58675e36898217fb2799d8 ]
Currently the call of kill_fasync() from an interrupt handler might lead to potential spin deadlocks, as spotted by syzkaller. Unfortunately, it's not so trivial to fix this lock chain as it's involved with the tasklist_lock that is touched in allover places.
As a temporary workaround, this patch provides the way to defer the async signal notification in a work. The new helper functions, snd_fasync_helper() and snd_kill_faync() are replacements for fasync_helper() and kill_fasync(), respectively. In addition, snd_fasync_free() needs to be called at the destructor of the relevant file object.
--- include/sound/core.h | 8 ++++ sound/core/misc.c | 94 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+)
include/sound/core.h +8 -0
@@ -440,4 +440,12 @@ snd_pci_quirk_lookup_id(u16 vendor, u16 device, }#endif +/* async signal helpers */ +struct snd_fasync ; + +int snd_fasync_helper (int fd,struct file *file,int on, +struct snd_fasync **fasyncp); +void snd_kill_fasync (struct snd_fasync *fasync,int signal,int poll); +void snd_fasync_free (struct snd_fasync *fasync); +#endif /* __SOUND_CORE_H */
sound/core/misc.c +94 -0
103 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 379/389 ALSA: timer: Use deferred fasync helper
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit 95cc637c1afd83fb7dd3d7c8a53710488f4caf9c ]
For avoiding the potential deadlock via kill_fasync() call, use the new fasync helpers to defer the invocation from PCI API. Note that it's merely a workaround.
--- sound/core/timer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
sound/core/timer.c +6 -5
@@ -61,7 +61,7 @@ struct snd_timer_user {unsigned int filter;struct timespec tstamp;/* trigger tstamp */ wait_queue_head_t qchange_sleep; -struct fasync_struct *fasync; +struct snd_fasync *fasync;struct mutex ioctl_lock; };
@@ -1317,7 +1317,7 @@ static void snd_timer_user_interrupt(struct snd_timer_instance *timeri, } __wake:spin_unlock (&tu->qlock); -kill_fasync (&tu->fasync,SIGIO ,POLL_IN ); +snd_kill_fasync (tu->fasync,SIGIO ,POLL_IN );wake_up (&tu->qchange_sleep); }
@@ -1354,7 +1354,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,spin_lock_irqsave (&tu->qlock, flags);snd_timer_user_append_to_tqueue (tu, &r1);spin_unlock_irqrestore (&tu->qlock, flags); -kill_fasync (&tu->fasync,SIGIO ,POLL_IN ); +snd_kill_fasync (tu->fasync,SIGIO ,POLL_IN );wake_up (&tu->qchange_sleep); }
@@ -1421,7 +1421,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,spin_unlock (&tu->qlock);if (append ==0 )return ; -kill_fasync (&tu->fasync,SIGIO ,POLL_IN ); +snd_kill_fasync (tu->fasync,SIGIO ,POLL_IN );wake_up (&tu->qchange_sleep); }
@@ -1487,6 +1487,7 @@ static int snd_timer_user_release(struct inode *inode, struct file *file)if (tu->timeri)snd_timer_close (tu->timeri);mutex_unlock (&tu->ioctl_lock); +snd_fasync_free (tu->fasync);kfree (tu->queue);kfree (tu->tqueue);kfree (tu);
@@ -2050,7 +2051,7 @@ static int snd_timer_user_fasync(int fd, struct file * file, int on)struct snd_timer_user *tu; tu = file->private_data; -return fasync_helper (fd, file, on, &tu->fasync); +return snd_fasync_helper (fd, file, on, &tu->fasync); } static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 380/389 f2fs: fix to avoid use f2fs_bug_on() in f2fs_new_node_page()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 141170b759e03958f296033bb7001be62d1d363b ]
As Dipanjan Das <[email protected]> reported, syzkaller found a f2fs bug as below:
RIP: 0010:f2fs_new_node_page+0x19ac/0x1fc0 fs/f2fs/node.c:1295 Call Trace: write_all_xattrs fs/f2fs/xattr.c:487 [inline] __f2fs_setxattr+0xe76/0x2e10 fs/f2fs/xattr.c:743 f2fs_setxattr+0x233/0xab0 fs/f2fs/xattr.c:790 f2fs_xattr_generic_set+0x133/0x170 fs/f2fs/xattr.c:86 __vfs_setxattr+0x115/0x180 fs/xattr.c:182 __vfs_setxattr_noperm+0x125/0x5f0 fs/xattr.c:216 __vfs_setxattr_locked+0x1cf/0x260 fs/xattr.c:277 vfs_setxattr+0x13f/0x330 fs/xattr.c:303 setxattr+0x146/0x160 fs/xattr.c:611 path_setxattr+0x1a7/0x1d0 fs/xattr.c:630 __do_sys_lsetxattr fs/xattr.c:653 [inline] __se_sys_lsetxattr fs/xattr.c:649 [inline] __x64_sys_lsetxattr+0xbd/0x150 fs/xattr.c:649 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0
NAT entry and nat bitmap can be inconsistent, e.g. one nid is free in nat bitmap, and blkaddr in its NAT entry is not NULL_ADDR, it may trigger BUG_ON() in f2fs_new_node_page(), fix it.
--- fs/f2fs/node.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/node.c +5 -1
@@ -1240,7 +1240,11 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)dec_valid_node_count (sbi, dn->inode, !ofs); goto fail; } -f2fs_bug_on (sbi, new_ni.blk_addr !=NULL_ADDR ); +if (unlikely (new_ni.blk_addr !=NULL_ADDR )) { + err = -EFSCORRUPTED ; +set_sbi_flag (sbi,SBI_NEED_FSCK ); + goto fail; + }#endif new_ni.nid = dn->nid; new_ni.ino = dn->inode->i_ino;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 381/389 smb3: check xattr value length earlier
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit 5fa2cffba0b82336a2244d941322eb1627ff787b ]
Coverity complains about assigning a pointer based on value length before checking that value length goes beyond the end of the SMB. Although this is even more unlikely as value length is a single byte, and the pointer is not dereferenced until laterm, it is clearer to check the lengths first.
Addresses-Coverity: 1467704 ("Speculative execution data leak")
--- fs/cifs/smb2ops.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/cifs/smb2ops.c +3 -2
@@ -960,9 +960,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,size_t name_len, value_len, user_name_len;while (src_size >0 ) { - name = &src->ea_data[0 ]; name_len = (size_t )src->ea_name_length; - value = &src->ea_data[src->ea_name_length +1 ]; value_len = (size_t )le16_to_cpu (src->ea_value_length);if (name_len ==0 )
@@ -974,6 +972,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size, goto out; } + name = &src->ea_data[0 ]; + value = &src->ea_data[src->ea_name_length +1 ]; +if (ea_name) {if (ea_name_len == name_len &&memcmp (ea_name, name, name_len) ==0 ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 382/389 powerpc/64: Init jump labels before parse_early_param()
In reply to Greg Kroah-HartmanFrom: Zhouyi Zhou <[email protected]>
[ Upstream commit ca829e05d3d4f728810cc5e4b468d9ebc7745eb3 ]
On 64-bit, calling jump_label_init() in setup_feature_keys() is too late because static keys may be used in subroutines of parse_early_param() which is again subroutine of early_init_devtree().
For example booting with "threadirqs":
static_key_enable_cpuslocked(): static key '0xc000000002953260' used before call to jump_label_init()
WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 static_key_enable_cpuslocked+0xfc/0x120
...
NIP static_key_enable_cpuslocked+0xfc/0x120
LR static_key_enable_cpuslocked+0xf8/0x120
Call Trace:
static_key_enable_cpuslocked+0xf8/0x120 (unreliable)
static_key_enable+0x30/0x50
setup_forced_irqthreads+0x28/0x40
do_early_param+0xa0/0x108
parse_args+0x290/0x4e0
parse_early_options+0x48/0x5c
parse_early_param+0x58/0x84
early_init_devtree+0xd4/0x518
early_setup+0xb4/0x214So call jump_label_init() just before parse_early_param() in early_init_devtree().
--- arch/powerpc/kernel/prom.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/kernel/prom.c +7 -0
@@ -740,6 +740,13 @@ void __init early_init_devtree(void *params)of_scan_flat_dt (early_init_dt_scan_root,NULL );of_scan_flat_dt (early_init_dt_scan_memory_ppc,NULL ); +/* +* As generic code authors expect to be able to use static keys +* in early_param() handlers, we initialize the static keys just +* before parsing early params (it's fine to call jump_label_init() +* more than once). +*/ +jump_label_init ();parse_early_param ();/* make sure we've parsed cmdline for mem= before this */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 383/389 video: fbdev: i740fb: Check the argument of i740_calc_vclk()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 40bf722f8064f50200b8c4f8946cd625b441dda9 ]
Since the user can control the arguments of the ioctl() from the user space, under special arguments that may result in a divide-by-zero bug.
If the user provides an improper 'pixclock' value that makes the argumet of i740_calc_vclk() less than 'I740_RFREQ_FIX', it will cause a divide-by-zero bug in:
drivers/video/fbdev/i740fb.c:353 p_best = min(15, ilog2(I740_MAX_VCO_FREQ / (freq / I740_RFREQ_FIX)));
The following log can reveal it:
divide error: 0000 [#1] PREEMPT SMP KASAN PTI
RIP: 0010:i740_calc_vclk drivers/video/fbdev/i740fb.c:353 [inline] RIP: 0010:i740fb_decode_var drivers/video/fbdev/i740fb.c:646 [inline] RIP: 0010:i740fb_set_par+0x163f/0x3b70 drivers/video/fbdev/i740fb.c:742 Call Trace: fb_set_var+0x604/0xeb0 drivers/video/fbdev/core/fbmem.c:1034 do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1110 fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1189
Fix this by checking the argument of i740_calc_vclk() first.
--- drivers/video/fbdev/i740fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/video/fbdev/i740fb.c +7 -2
@@ -400,7 +400,7 @@ static int i740fb_decode_var(const struct fb_var_screeninfo *var,u32 xres, right, hslen, left, xtotal;u32 yres, lower, vslen, upper, ytotal;u32 vxres, xoffset, vyres, yoffset; -u32 bpp, base, dacspeed24, mem; +u32 bpp, base, dacspeed24, mem, freq;u8 r7;int i;
@@ -643,7 +643,12 @@ static int i740fb_decode_var(const struct fb_var_screeninfo *var, par->atc[VGA_ATC_OVERSCAN ] =0 ;/* Calculate VCLK that most closely matches the requested dot clock */ -i740_calc_vclk ((((u32 )1e9 ) / var->pixclock) * (u32)(1e3 ), par); + freq = (((u32 )1e9 ) / var->pixclock) * (u32)(1e3 ); +if (freq <I740_RFREQ_FIX ) { +fb_dbg (info,"invalid pixclock\n" ); + freq =I740_RFREQ_FIX ; + } +i740_calc_vclk (freq, par);/* Since we program the clocks ourselves, always use VCLK2. */ par->misc |=0x0C ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 384/389 MIPS: tlbex: Explicitly compare _PAGE_NO_EXEC against 0
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 74de14fe05dd6b151d73cb0c73c8ec874cbdcde6 ]
When CONFIG_XPA is enabled, Clang warns:
arch/mips/mm/tlbex.c:629:24: error: converting the result of '<<' to a boolean; did you mean '(1 << _PAGE_NO_EXEC_SHIFT) != 0'? [-Werror,-Wint-in-bool-context]
if (cpu_has_rixi && !!_PAGE_NO_EXEC) {
^
arch/mips/include/asm/pgtable-bits.h:174:28: note: expanded from macro '_PAGE_NO_EXEC'
# define _PAGE_NO_EXEC (1 << _PAGE_NO_EXEC_SHIFT)
^
arch/mips/mm/tlbex.c:2568:24: error: converting the result of '<<' to a boolean; did you mean '(1 << _PAGE_NO_EXEC_SHIFT) != 0'? [-Werror,-Wint-in-bool-context]
if (!cpu_has_rixi || !_PAGE_NO_EXEC) {
^
arch/mips/include/asm/pgtable-bits.h:174:28: note: expanded from macro '_PAGE_NO_EXEC'
# define _PAGE_NO_EXEC (1 << _PAGE_NO_EXEC_SHIFT)
^
2 errors generated._PAGE_NO_EXEC can be '0' or '1 << _PAGE_NO_EXEC_SHIFT' depending on the build and runtime configuration, which is what the negation operators are trying to convey. To silence the warning, explicitly compare against 0 so the result of the '<<' operator is not implicitly converted to a boolean.
According to its documentation, GCC enables -Wint-in-bool-context with -Wall but this warning is not visible when building the same configuration with GCC. It appears GCC only warns when compiling C++, not C, although the documentation makes no note of this:
https://godbolt.org/z/x39q3brxf
--- arch/mips/mm/tlbex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/mm/tlbex.c +2 -2
@@ -629,7 +629,7 @@ static __maybe_unused void build_convert_pte_to_entrylo(u32 **p,return ; } -if (cpu_has_rixi && !!_PAGE_NO_EXEC) { +if (cpu_has_rixi && _PAGE_NO_EXEC !=0 ) {if (fill_includes_sw_bits) {UASM_i_ROTR (p, reg, reg,ilog2 (_PAGE_GLOBAL)); }else {
@@ -2568,7 +2568,7 @@ static void check_pabits(void)unsigned long entry;unsigned pabits, fillbits; -if (!cpu_has_rixi || !_PAGE_NO_EXEC) { +if (!cpu_has_rixi || _PAGE_NO_EXEC ==0 ) {/* * We'll only be making use of the fact that we can rotate bits * into the fill if the CPU supports RIXI, so don't bother
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 385/389 tracing/probes: Have kprobes and uprobes use $COMM too
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit ab8384442ee512fc0fc72deeb036110843d0e7ff upstream.
Both $comm and $COMM can be used to get current->comm in eprobes and the filtering and histogram logic. Make kprobes and uprobes consistent in this regard and allow both $comm and $COMM as well. Currently kprobes and uprobes only handle $comm, which is inconsistent with the other utilities, and can be confusing to users.
--- kernel/trace/trace_probe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace_probe.c +3 -2
@@ -300,7 +300,7 @@ static int parse_probe_vars(char *arg, c } }else goto inval_var; - }else if (strcmp (arg,"comm" ) ==0 ) { + }else if (strcmp (arg,"comm" ) ==0 ||strcmp (arg,"COMM" ) ==0 ) { code->op =FETCH_OP_COMM ; #ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API } else if (((flags & TPARG_FL_MASK) ==
@@ -595,7 +595,8 @@ static int traceprobe_parse_probe_arg_bo* Since $comm and immediate string can not be dereferred, * we can find those by strcmp. */ -if (strcmp (arg,"$comm" ) ==0 ||strncmp (arg,"\\\"" ,2 ) ==0 ) { +if (strcmp (arg,"$comm" ) ==0 ||strcmp (arg,"$COMM" ) ==0 || +strncmp (arg,"\\\"" ,2 ) ==0 ) {/* The type of $comm must be "string", and not an array. */ if (parg->count || (t &&strcmp (t,"string" )))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 386/389 can: j1939: j1939_sk_queue_activate_next_locked(): replace WARN_ON_ONCE with netdev_warn_once()
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
commit 8ef49f7f8244424adcf4a546dba4cbbeb0b09c09 upstream.
We should warn user-space that it is doing something wrong when trying to activate sessions with identical parameters but WARN_ON_ONCE macro can not be used here as it serves a different purpose.
So it would be good to replace it with netdev_warn_once() message.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- net/can/j1939/socket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/can/j1939/socket.c +4 -1
@@ -178,7 +178,10 @@ activate_next:if (!first)return ; -if (WARN_ON_ONCE (j1939_session_activate (first))) { +if (j1939_session_activate (first)) { +netdev_warn_once (first->priv->ndev, +"%s: 0x%p: Identical session is already activated.\n" , + __func__, first); first->err = -EBUSY ; goto activate_next; }else {
Greg Kroah-Hartman
maintainerPATCH 387/389 can: j1939: j1939_session_destroy(): fix memory leak of skbs
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
commit 8c21c54a53ab21842f5050fa090f26b03c0313d6 upstream.
We need to drop skb references taken in j1939_session_skb_queue() when destroying a session in j1939_session_destroy(). Otherwise those skbs would be lost.
Link to Syzkaller info and repro: https://forge.ispras.ru/issues/11743.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
V1: https://lore.kernel.org/all/[email protected]
--- net/can/j1939/transport.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/can/j1939/transport.c +7 -1
@@ -260,6 +260,8 @@ static void __j1939_session_drop(structstatic void j1939_session_destroy (struct j1939_session *session) { +struct sk_buff *skb; +if (session->err)j1939_sk_errqueue (session,J1939_ERRQUEUE_ABORT );else
@@ -270,7 +272,11 @@ static void j1939_session_destroy(structWARN_ON_ONCE (!list_empty (&session->sk_session_queue_entry));WARN_ON_ONCE (!list_empty (&session->active_session_list_entry)); -skb_queue_purge (&session->skb_queue); +while ((skb =skb_dequeue (&session->skb_queue)) !=NULL ) { +/* drop ref taken in j1939_session_skb_queue() */ +skb_unref (skb); +kfree_skb (skb); + }__j1939_session_drop (session);j1939_priv_put (session->priv);kfree (session);
Greg Kroah-Hartman
maintainerPATCH 388/389 btrfs: only write the sectors in the vertical stripe which has data stripes
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit bd8f7e627703ca5707833d623efcd43f104c7b3f upstream.
If we have only 8K partial write at the beginning of a full RAID56 stripe, we will write the following contents:
0 8K 32K 64K
Disk 1 (data): |XX| | |
Disk 2 (data): | | | Disk 3 (parity): |XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|
|X| means the sector will be written back to disk.
Note that, although we won't write any sectors from disk 2, but we will write the full 64KiB of parity to disk.
This behavior is fine for now, but not for the future (especially for RAID56J, as we waste quite some space to journal the unused parity stripes).
So here we will also utilize the btrfs_raid_bio::dbitmap, anytime we queue a higher level bio into an rbio, we will update rbio::dbitmap to indicate which vertical stripes we need to writeback.
And at finish_rmw(), we also check dbitmap to see if we need to write any sector in the vertical stripe.
So after the patch, above example will only lead to the following writeback pattern:
0 8K 32K 64K
Disk 1 (data): |XX| | |
Disk 2 (data): | | | Disk 3 (parity): |XX| | |
--- fs/btrfs/raid56.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-)
fs/btrfs/raid56.c +51 -4
@@ -334,6 +334,9 @@ static void merge_rbio(struct btrfs_raid {bio_list_merge (&dest->bio_list, &victim->bio_list); dest->bio_list_bytes += victim->bio_list_bytes; +/* Also inherit the bitmaps from @victim. */ +bitmap_or (dest->dbitmap, victim->dbitmap, dest->dbitmap, + dest->stripe_npages); dest->generic_bio_cnt += victim->generic_bio_cnt;bio_list_init (&victim->bio_list); }
@@ -878,6 +881,12 @@ static void rbio_orig_end_io(struct btrfif (rbio->generic_bio_cnt)btrfs_bio_counter_sub (rbio->fs_info, rbio->generic_bio_cnt); +/* +* Clear the data bitmap, as the rbio may be cached for later usage. +* do this before before unlock_stripe() so there will be no new bio +* for this bio. +*/ +bitmap_clear (rbio->dbitmap,0 , rbio->stripe_npages);/* * At this moment, rbio->bio_list is empty, however since rbio does not
@@ -1212,6 +1221,9 @@ static noinline void finish_rmw(struct belse BUG (); +/* We should have at least one data sector. */ +ASSERT (bitmap_weight (rbio->dbitmap, rbio->stripe_npages)); +/* at this point we either have a full stripe, * or we've read the full stripe from the drive. * recalculate the parity and write the new results.
@@ -1285,6 +1297,11 @@ static noinline void finish_rmw(struct bfor (stripe =0 ; stripe < rbio->real_stripes; stripe++) {for (pagenr =0 ; pagenr < rbio->stripe_npages; pagenr++) {struct page *page; + +/* This vertical stripe has no data, skip it. */ +if (!test_bit (pagenr, rbio->dbitmap)) +continue ; +if (stripe < rbio->nr_data) { page =page_in_rbio (rbio, stripe, pagenr,1 );if (!page)
@@ -1309,6 +1326,11 @@ static noinline void finish_rmw(struct bfor (pagenr =0 ; pagenr < rbio->stripe_npages; pagenr++) {struct page *page; + +/* This vertical stripe has no data, skip it. */ +if (!test_bit (pagenr, rbio->dbitmap)) +continue ; +if (stripe < rbio->nr_data) { page =page_in_rbio (rbio, stripe, pagenr,1 );if (!page)
@@ -1748,6 +1770,33 @@ static void btrfs_raid_unplug(struct blkrun_plug (plug); } +/* Add the original bio into rbio->bio_list, and update rbio::dbitmap. */ +static void rbio_add_bio (struct btrfs_raid_bio *rbio,struct bio *orig_bio) +{ +const struct btrfs_fs_info *fs_info = rbio->fs_info; +const u64 orig_logical = orig_bio->bi_iter.bi_sector <<SECTOR_SHIFT ; +const u64 full_stripe_start = rbio->bbio->raid_map[0 ]; +const u32 orig_len = orig_bio->bi_iter.bi_size; +const u32 sectorsize = fs_info->sectorsize; +u64 cur_logical; + +ASSERT (orig_logical >= full_stripe_start && + orig_logical + orig_len <= full_stripe_start + + rbio->nr_data * rbio->stripe_len); + +bio_list_add (&rbio->bio_list, orig_bio); + rbio->bio_list_bytes += orig_bio->bi_iter.bi_size; + +/* Update the dbitmap. */ +for (cur_logical = orig_logical; cur_logical < orig_logical + orig_len; + cur_logical += sectorsize) { +int bit = ((u32)(cur_logical - full_stripe_start) >> +PAGE_SHIFT ) % rbio->stripe_npages; + +set_bit (bit, rbio->dbitmap); + } +} +/* * our main entry point for writes from the rest of the FS. */
@@ -1764,9 +1813,8 @@ int raid56_parity_write(struct btrfs_fs_btrfs_put_bbio (bbio);return PTR_ERR (rbio); } -bio_list_add (&rbio->bio_list, bio); - rbio->bio_list_bytes = bio->bi_iter.bi_size; rbio->operation =BTRFS_RBIO_WRITE ; +rbio_add_bio (rbio, bio);btrfs_bio_counter_inc_noblocked (fs_info); rbio->generic_bio_cnt =1 ;
@@ -2170,8 +2218,7 @@ int raid56_parity_recover(struct btrfs_f } rbio->operation =BTRFS_RBIO_READ_REBUILD ; -bio_list_add (&rbio->bio_list, bio); - rbio->bio_list_bytes = bio->bi_iter.bi_size; +rbio_add_bio (rbio, bio); rbio->faila =find_logical_bio_stripe (rbio, bio);if (rbio->faila ==-1 ) {
Greg Kroah-Hartman
maintainerPATCH 389/389 btrfs: raid56: dont trust any cached sector in __raid56_parity_recover()
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit f6065f8edeb25f4a9dfe0b446030ad995a84a088 upstream.
[BUG]
There is a small workload which will always fail with recent kernel:
(A simplified version from btrfs/125 test case)
mkfs.btrfs -f -m raid5 -d raid5 -b 1G $dev1 $dev2 $dev3 mount $dev1 $mnt xfs_io -f -c "pwrite -S 0xee 0 1M" $mnt/file1 sync umount $mnt btrfs dev scan -u $dev3 mount -o degraded $dev1 $mnt xfs_io -f -c "pwrite -S 0xff 0 128M" $mnt/file2 umount $mnt btrfs dev scan mount $dev1 $mnt btrfs balance start --full-balance $mnt umount $mnt
The failure is always failed to read some tree blocks:
BTRFS info (device dm-4): relocating block group 217710592 flags data|raid5 BTRFS error (device dm-4): parent transid verify failed on 38993920 wanted 9 found 7 BTRFS error (device dm-4): parent transid verify failed on 38993920 wanted 9 found 7
...
[CAUSE]
With the recently added debug output, we can see all RAID56 operations related to full stripe 38928384:
56.1183: raid56_read_partial: full_stripe=38928384 devid=2 type=DATA1 offset=0 opf=0x0 physical=9502720 len=65536 56.1185: raid56_read_partial: full_stripe=38928384 devid=3 type=DATA2 offset=16384 opf=0x0 physical=9519104 len=16384 56.1185: raid56_read_partial: full_stripe=38928384 devid=3 type=DATA2 offset=49152 opf=0x0 physical=9551872 len=16384 56.1187: raid56_write_stripe: full_stripe=38928384 devid=3 type=DATA2 offset=0 opf=0x1 physical=9502720 len=16384 56.1188: raid56_write_stripe: full_stripe=38928384 devid=3 type=DATA2 offset=32768 opf=0x1 physical=9535488 len=16384 56.1188: raid56_write_stripe: full_stripe=38928384 devid=1 type=PQ1 offset=0 opf=0x1 physical=30474240 len=16384 56.1189: raid56_write_stripe: full_stripe=38928384 devid=1 type=PQ1 offset=32768 opf=0x1 physical=30507008 len=16384 56.1218: raid56_write_stripe: full_stripe=38928384 devid=3 type=DATA2 offset=49152 opf=0x1 physical=9551872 len=16384 56.1219: raid56_write_stripe: full_stripe=38928384 devid=1 type=PQ1 offset=49152 opf=0x1 physical=30523392 len=16384 56.2721: raid56_parity_recover: full stripe=38928384 eb=39010304 mirror=2
56.2723: raid56_parity_recover: full stripe=38928384 eb=39010304 mirror=2
56.2724: raid56_parity_recover: full stripe=38928384 eb=39010304 mirror=2
Before we enter raid56_parity_recover(), we have triggered some metadata write for the full stripe 38928384, this leads to us to read all the sectors from disk.
Furthermore, btrfs raid56 write will cache its calculated P/Q sectors to avoid unnecessary read.
This means, for that full stripe, after any partial write, we will have stale data, along with P/Q calculated using that stale data.
Thankfully due to patch "btrfs: only write the sectors in the vertical stripe which has data stripes" we haven't submitted all the corrupted P/Q to disk.
When we really need to recover certain range, aka in raid56_parity_recover(), we will use the cached rbio, along with its cached sectors (the full stripe is all cached).
This explains why we have no event raid56_scrub_read_recover() triggered.
Since we have the cached P/Q which is calculated using the stale data, the recovered one will just be stale.
In our particular test case, it will always return the same incorrect metadata, thus causing the same error message "parent transid verify failed on 39010304 wanted 9 found 7" again and again.
[BTRFS DESTRUCTIVE RMW PROBLEM]
Test case btrfs/125 (and above workload) always has its trouble with the destructive read-modify-write (RMW) cycle:
0 32K 64K Data1: | Good | Good | Data2: | Bad | Bad | Parity: | Good | Good |
In above case, if we trigger any write into Data1, we will use the bad data in Data2 to re-generate parity, killing the only chance to recovery Data2, thus Data2 is lost forever.
This destructive RMW cycle is not specific to btrfs RAID56, but there are some btrfs specific behaviors making the case even worse:
- Btrfs will cache sectors for unrelated vertical stripes.
In above example, if we're only writing into 0~32K range, btrfs will still read data range (32K ~ 64K) of Data1, and (64K~128K) of Data2. This behavior is to cache sectors for later update.
Incidentally commit d4e28d9b5f04 ("btrfs: raid56: make steal_rbio() subpage compatible") has a bug which makes RAID56 to never trust the cached sectors, thus slightly improve the situation for recovery.
Unfortunately, follow up fix "btrfs: update stripe_sectors::uptodate in steal_rbio" will revert the behavior back to the old one.
- Btrfs raid56 partial write will update all P/Q sectors and cache them
This means, even if data at (64K ~ 96K) of Data2 is free space, and only (96K ~ 128K) of Data2 is really stale data.
And we write into that (96K ~ 128K), we will update all the parity sectors for the full stripe.
This unnecessary behavior will completely kill the chance of recovery.
Thankfully, an unrelated optimization "btrfs: only write the sectors in the vertical stripe which has data stripes" will prevent submitting the write bio for untouched vertical sectors.
That optimization will keep the on-disk P/Q untouched for a chance for later recovery.
[FIX]
Although we have no good way to completely fix the destructive RMW (unless we go full scrub for each partial write), we can still limit the damage.
With patch "btrfs: only write the sectors in the vertical stripe which has data stripes" now we won't really submit the P/Q of unrelated vertical stripes, so the on-disk P/Q should still be fine.
Now we really need to do is just drop all the cached sectors when doing recovery.
By this, we have a chance to read the original P/Q from disk, and have a chance to recover the stale data, while still keep the cache to speed up regular write path.
In fact, just dropping all the cache for recovery path is good enough to allow the test case btrfs/125 along with the small script to pass reliably.
The lack of metadata write after the degraded mount, and forced metadata COW is saving us this time.
So this patch will fix the behavior by not trust any cache in __raid56_parity_recover(), to solve the problem while still keep the cache useful.
But please note that this test pass DOES NOT mean we have solved the destructive RMW problem, we just do better damage control a little better.
Related patches:
- btrfs: only write the sectors in the vertical stripe
- d4e28d9b5f04 ("btrfs: raid56: make steal_rbio() subpage compatible")
- btrfs: update stripe_sectors::uptodate in steal_rbio
--- fs/btrfs/raid56.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
fs/btrfs/raid56.c +6 -13
@@ -2116,9 +2116,12 @@ static int __raid56_parity_recover(strucatomic_set (&rbio->error,0 );/* -* read everything that hasn't failed. Thanks to the -* stripe cache, it is possible that some or all of these -* pages are going to be uptodate. +* Read everything that hasn't failed. However this time we will +* not trust any cached sector. +* As we may read out some stale data but higher layer is not reading +* that stale part. +* +* So here we always re-read everything in recovery path. */ for (stripe =0 ; stripe < rbio->real_stripes; stripe++) {if (rbio->faila == stripe || rbio->failb == stripe) {
@@ -2127,16 +2130,6 @@ static int __raid56_parity_recover(struc }for (pagenr =0 ; pagenr < rbio->stripe_npages; pagenr++) { -struct page *p; - -/* -* the rmw code may have already read this -* page in -*/ - p =rbio_stripe_page (rbio, stripe, pagenr); -if (PageUptodate (p)) -continue ; - ret =rbio_add_io_page (rbio, &bio_list,rbio_stripe_page (rbio, stripe, pagenr), stripe, pagenr, rbio->stripe_len);
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.211 release. There are 389 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 25 Aug 2022 08:00:15 +0000. Anything received after that time might be too late.
Build results:
total: 161 pass: 161 fail: 0 Qemu test results: total: 446 pass: 446 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.211 release. There are 389 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 25 Aug 2022 08:00:15 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.211-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.211 release. There are 389 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 25 Aug 2022 08:00:15 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.211-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro's test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.4.211-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-5.4.y
* git commit: 1cece69eaa889a27cf3e9f2051fcc57eda957271
* git describe: v5.4.210-390-g1cece69eaa88
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.4.y/build/v5.4.210-390-g1cece69eaa88
## No test Regressions (compared to v5.4.210)
## No metric Regressions (compared to v5.4.210)
## No test Fixes (compared to v5.4.210)
## No metric Fixes (compared to v5.4.210)
## Test result summary
total: 64174, pass: 57363, fail: 716, skip: 6017, xfail: 78
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 302 total, 302 passed, 0 failed
* arm64: 61 total, 57 passed, 4 failed
* i386: 28 total, 26 passed, 2 failed
* mips: 45 total, 45 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 54 total, 54 passed, 0 failed
* riscv: 27 total, 26 passed, 1 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x86_64: 54 total, 52 passed, 2 failed
## Test suites summary
* kunit
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.211 release. There are 389 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 25 Aug 2022 08:00:15 +0000. Anything received after that time might be too late.
Build test (gcc version 11.3.1 20220819):
mips: 65 configs -> no failure
arm: 106 configs -> no failure
arm64: 2 configs -> no failurex86_64: 4 configs -> no failure
alpha allmodconfig -> no failure
powerpc allmodconfig -> no failure
riscv allmodconfig -> no failure
s390 allmodconfig -> no failure
xtensa allmodconfig -> no failure
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
[1]. https://openqa.qa.codethink.co.uk/tests/1685
--
Regards
Sudip
A message that is not in the archive (sent off-list or not yet received): [email protected]
Greg Kroah-Hartman
maintainerQuoted 16 lines · zhouzhixiu
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.211 release.
There are 389 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know. Responses should be made by Thu, 25 Aug 2022 08:00:15
+0000. Anything received after that time might be too late. The whole
patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.211-rc1.gz
or in the git tree and branch at:git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
linux-5.4.y and the diffstat can be found below. thanks, greg k-hTested on arm64 and x86 for 5.4.211-rc1,
Kernel repo:
Quoted 8 lines
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Branch: linux-5.10.yVersion:
5.4.211-rc1Commit:1cece69eaa889a27cf3e9f2051fcc57eda957271Compiler: gcc
version 7.3.0 (GCC) arm64:--------------------------------------------------------------------Testcase
Result Summary:total: 9017passed: 9017failed: 0timeout: 0--------------------------------------------------------------------x86:--------------------------------------------------------------------Testcase Result Summary:total: 9017passed: 9017failed: 0timeout: 0--------------------------------------------------------------------Tested-by:
Hulk Robot <[email protected]>
Your emails are being sent in html format and not being accepted by the mialing list.
Also this response is very odd :(