5.10.275-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1793/1848 perf mmap: Preserve the consumed cursor in forward mode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <[email protected]>
[ Upstream commit 1e826983ceef421d7047ed76581840b778294ad4 ]
perf_mmap__read_event() updates prev as it consumes forward-buffer records. perf_mmap__read_done() then overwrites prev with a fresh producer head, even when unread records remain.
perf_kvm__mmap_read_idx() stops after 25 records per mmap and calls read_done(). If more records are pending, prev advances past them. The next drain starts at that new position and skips the unread remainder.
An event arriving after the last empty read_event() and before read_done() can also be skipped. read_done() does not itself update the kernel's data_tail.
Only refresh prev for overwrite buffers, which need the current head as the end of the next backward read. Leave the forward cursor at the consumed position.
--- tools/lib/perf/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/perf/mmap.c +1 -1
@@ -191,7 +191,7 @@ void perf_mmap__read_done(struct perf_mmap *map)/* * Check if event was unmapped due to a POLLHUP/POLLERR. */ -if (!refcount_read (&map->refcnt)) +if (!refcount_read (&map->refcnt) || !map->overwrite)return ; map->prev =perf_mmap__read_head (map);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1794/1848 net: dsa: mv88e6xxx: fix 6351 family statistics snapshot
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 9663edfa71e8807890203578dab6db60c6b548c4 ]
The 88E6171, 88E6175, 88E6350 and 88E6351 take the port number in the low bits of the statistics operation register. The 6320 snapshot helper instead encodes the port as (port + 1) << 5. On an EA4500 with an 88E6171, this causes ethtool -S to return physical port 0's MIB counters for every user port. Traffic on other ports does not update their reported hardware counters.
Before the snapshot operation was moved into the chip operations, only the 6320 and 6352 families used the shifted encoding. The refactoring incorrectly assigned that encoding to all four 6351 family chips.
Use the unshifted snapshot helper for the entire 6351 family. This matches the Marvell DSDT statsCapture() implementation, which uses the raw port number for chips outside DEV_RMON_PORT_BITS, including these four chips.
The original 88E6171 change was tested on an EA4500: pings through different switch ports updated only the corresponding port's hardware counters. The other three chips have not been hardware tested.
--- drivers/net/dsa/mv88e6xxx/chip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -4
@@ -3608,7 +3608,7 @@ static const struct mv88e6xxx_ops mv88e6171_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3702,7 +3702,7 @@ static const struct mv88e6xxx_ops mv88e6175_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
@@ -4315,7 +4315,7 @@ static const struct mv88e6xxx_ops mv88e6350_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
@@ -4356,7 +4356,7 @@ static const struct mv88e6xxx_ops mv88e6351_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1795/1848 usbnet: fix EVENT_RX_PAUSED race in usbnet_skb_return()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ömer Mete Kaya <[email protected]>
[ Upstream commit 67ae1b80cf73f592b35e4b5e5001a24d6d6c8637 ]
On SMP, usbnet_skb_return() can observe EVENT_RX_PAUSED as set on CPU0 while usbnet_resume_rx() clears the flag and drains rxq_pause on CPU1. The skb can then be queued after the drain has completed and remain stranded until the next MTU change or device stop.
Synchronize the EVENT_RX_PAUSED state transition and paused-queue dequeue operations with rxq_pause.lock. In usbnet_resume_rx() splice the paused queue into a local queue under the lock, then drain the local queue lock-free. In usbnet_skb_return() use a double-check pattern under rxq_pause.lock on the slow path, keeping the normal RX fast path lock-free. Use spin_lock_irqsave() to match the lockdep class shared with other sk_buff_head locks taken from hardirq context in defer_bh().
Discovered by Sashiko, not triggered, not tested on real hardware.
--- drivers/net/usb/usbnet.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/net/usb/usbnet.c +16 -4
@@ -318,9 +318,14 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)unsigned long flags;int status; -if (test_bit (EVENT_RX_PAUSED , &dev->flags)) { -skb_queue_tail (&dev->rxq_pause, skb); -return ; +if (unlikely (test_bit (EVENT_RX_PAUSED , &dev->flags))) { +spin_lock_irqsave (&dev->rxq_pause.lock, flags); +if (test_bit (EVENT_RX_PAUSED , &dev->flags)) { +__skb_queue_tail (&dev->rxq_pause, skb); +spin_unlock_irqrestore (&dev->rxq_pause.lock, flags); +return ; + } +spin_unlock_irqrestore (&dev->rxq_pause.lock, flags); }/* only update if unset to allow minidriver rx_fixup override */
@@ -683,13 +688,20 @@ EXPORT_SYMBOL_GPL(usbnet_pause_rx);void usbnet_resume_rx (struct usbnet *dev) { +struct sk_buff_head q;struct sk_buff *skb; +unsigned long flags;int num =0 ; +__skb_queue_head_init (&q); +local_bh_disable (); +spin_lock_irqsave (&dev->rxq_pause.lock, flags);clear_bit (EVENT_RX_PAUSED , &dev->flags); +skb_queue_splice_init (&dev->rxq_pause, &q); +spin_unlock_irqrestore (&dev->rxq_pause.lock, flags); -while ((skb =skb_dequeue (&dev->rxq_pause)) !=NULL ) { +while ((skb =__skb_dequeue (&q))) {usbnet_skb_return (dev, skb); num++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1796/1848 ASoC: xilinx: formatter_pcm: Fix read-modify-write of AUD_CTRL in hw_params
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 3b54e739273752b370e49b09976da152fa3b802c ]
xlnx_formatter_pcm_hw_params() does a read-modify-write on XLNX_AUD_CTRL but only ORs in the new data width and active channel values without clearing the old ones. If hw_params is called more than once on an open stream, these fields may retain bits from the previous configuration, resulting in an incorrect sample width or channel count.
Clear both fields before writing the new values, and use FIELD_PREP() so the values cannot spill into neighbouring bits.
--- sound/soc/xilinx/xlnx_formatter_pcm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
sound/soc/xilinx/xlnx_formatter_pcm.c +10 -8
@@ -6,6 +6,7 @@// // Author: Maruthi Srinivas Bayyavarapu <[email protected]> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/module.h>
@@ -57,8 +58,8 @@#define CFG_S2MM_XFER_SHIFT 29#define CFG_S2MM_PKG_MASK BIT(28) -#define AUD_CTRL_DATA_WIDTH_SHIFT 16 -#define AUD_CTRL_ACTIVE_CH_SHIFT 19 +#define AUD_CTRL_DATA_WIDTH_MASK GENMASK(18, 16) +#define AUD_CTRL_ACTIVE_CH_MASK GENMASK(22, 19)#define PERIOD_CFG_PERIODS_SHIFT 16#define PERIODS_MIN 2
@@ -509,28 +510,29 @@ static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component,writel (high, stream_data->mmio +XLNX_AUD_BUFF_ADDR_MSB ); val =readl (stream_data->mmio +XLNX_AUD_CTRL ); + val &= ~(AUD_CTRL_DATA_WIDTH_MASK |AUD_CTRL_ACTIVE_CH_MASK ); bits_per_sample =params_width (params);switch (bits_per_sample) {case 8 : - val |= (BIT_DEPTH_8 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_8 );break ;case 16 : - val |= (BIT_DEPTH_16 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_16 );break ;case 20 : - val |= (BIT_DEPTH_20 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_20 );break ;case 24 : - val |= (BIT_DEPTH_24 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_24 );break ;case 32 : - val |= (BIT_DEPTH_32 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_32 );break ;default :return -EINVAL ; } - val |= active_ch <<AUD_CTRL_ACTIVE_CH_SHIFT ; + val |=FIELD_PREP (AUD_CTRL_ACTIVE_CH_MASK , active_ch);writel (val, stream_data->mmio +XLNX_AUD_CTRL ); val = (params_periods (params) <<PERIOD_CFG_PERIODS_SHIFT )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1797/1848 nvmet: prevent double-free after metadata SGL allocation failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 2f61b9d1d54edf75a352c43eebe3804144b5d44e ]
If metadata SGL allocation fails, nvmet_req_alloc_sgls() frees req->sg without clearing it. The RDMA error completion path later frees the same scatterlist again.
Use nvmet_req_free_sgls() instead so that the scatterlist pointers and counts are cleared before response cleanup.
--- drivers/nvme/target/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/core.c +1 -1
@@ -1061,7 +1061,7 @@ int nvmet_req_alloc_sgls(struct nvmet_req *req)return 0 ; out_free: -sgl_free (req->sg); +nvmet_req_free_sgls (req); out:return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1798/1848 nvme: add TCP TSAS definitions
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 646f45b23218c7a97a84259d8eeb22dad5711fc8 ]
Stable-dep-of: 60385038754e ("nvmet: use the enabled transport when disabling a port")
--- include/linux/nvme.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/nvme.h +10 -0
@@ -92,6 +92,13 @@ enum { NVMF_RDMA_CMS_RDMA_CM = 1, /* Sockets based endpoint addressing */ }; +/* TSAS SECTYPE for TCP transport */ +enum { +NVMF_TCP_SECTYPE_NONE =0 ,/* No Security */ +NVMF_TCP_SECTYPE_TLS12 =1 ,/* TLSv1.2, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */ +NVMF_TCP_SECTYPE_TLS13 =2 ,/* TLSv1.3, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */ +}; +#define NVME_AQ_DEPTH 32#define NVME_NR_AEN_COMMANDS 1#define NVME_AQ_BLK_MQ_DEPTH (NVME_AQ_DEPTH - NVME_NR_AEN_COMMANDS)
@@ -1314,6 +1321,9 @@ struct nvmf_disc_rsp_page_entry {__u16 pkey;__u8 resv10[246 ]; } rdma; +struct tcp { +__u8 sectype; + } tcp; } tsas; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1799/1848 nvmet: make TCP sectype settable via configfs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 3f123494db725d899fdf990d894648bcc33cf7a3 ]
Add a new configfs attribute 'addr_tsas' to make the TCP sectype settable via configfs.
Stable-dep-of: 60385038754e ("nvmet: use the enabled transport when disabling a port")
--- drivers/nvme/target/configfs.c | 75 +++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-)
drivers/nvme/target/configfs.c +74 -1
@@ -154,6 +154,11 @@ static const struct nvmet_type_name_map nvmet_addr_treq[] = { { NVMF_TREQ_NOT_REQUIRED, "not required" }, }; +static inline u8 nvmet_port_disc_addr_treq_mask (struct nvmet_port *port) +{ +return (port->disc_addr.treq & ~NVME_TREQ_SECURE_CHANNEL_MASK ); +} +static ssize_t nvmet_addr_treq_show (struct config_item *item,char *page) { u8 treq = to_nvmet_port(item)->disc_addr.treq &
@@ -172,7 +177,7 @@ static ssize_t nvmet_addr_treq_store(struct config_item *item, const char *page, size_t count) {struct nvmet_port *port =to_nvmet_port (item); -u8 treq = port->disc_addr.treq & ~NVME_TREQ_SECURE_CHANNEL_MASK ; +u8 treq =nvmet_port_disc_addr_treq_mask (port);int i;if (nvmet_is_port_enabled (port, __func__))
@@ -299,6 +304,11 @@ static void nvmet_port_init_tsas_rdma(struct nvmet_port *port) port->disc_addr.tsas.rdma.cms =NVMF_RDMA_CMS_RDMA_CM ; } +static void nvmet_port_init_tsas_tcp (struct nvmet_port *port,int sectype) +{ + port->disc_addr.tsas.tcp.sectype = sectype; +} +static ssize_t nvmet_addr_trtype_store (struct config_item *item,const char *page,size_t count) {
@@ -321,11 +331,73 @@ static ssize_t nvmet_addr_trtype_store(struct config_item *item, port->disc_addr.trtype = nvmet_transport[i].type;if (port->disc_addr.trtype ==NVMF_TRTYPE_RDMA )nvmet_port_init_tsas_rdma (port); +else if (port->disc_addr.trtype ==NVMF_TRTYPE_TCP ) +nvmet_port_init_tsas_tcp (port,NVMF_TCP_SECTYPE_NONE );return count; }CONFIGFS_ATTR (nvmet_, addr_trtype); +static const struct nvmet_type_name_map nvmet_addr_tsas_tcp[] = { + {NVMF_TCP_SECTYPE_NONE ,"none" }, + {NVMF_TCP_SECTYPE_TLS13 ,"tls1.3" }, +}; + +static const struct nvmet_type_name_map nvmet_addr_tsas_rdma[] = { + {NVMF_RDMA_QPTYPE_CONNECTED ,"connected" }, + {NVMF_RDMA_QPTYPE_DATAGRAM ,"datagram" }, +}; + +static ssize_t nvmet_addr_tsas_show (struct config_item *item, +char *page) +{ +struct nvmet_port *port =to_nvmet_port (item); +int i; + +if (port->disc_addr.trtype ==NVMF_TRTYPE_TCP ) { +for (i =0 ; i <ARRAY_SIZE (nvmet_addr_tsas_tcp); i++) { +if (port->disc_addr.tsas.tcp.sectype == nvmet_addr_tsas_tcp[i].type) +return sprintf (page,"%s\n" , nvmet_addr_tsas_tcp[i].name); + } + }else if (port->disc_addr.trtype ==NVMF_TRTYPE_RDMA ) { +for (i =0 ; i <ARRAY_SIZE (nvmet_addr_tsas_rdma); i++) { +if (port->disc_addr.tsas.rdma.qptype == nvmet_addr_tsas_rdma[i].type) +return sprintf (page,"%s\n" , nvmet_addr_tsas_rdma[i].name); + } + } +return sprintf (page,"reserved\n" ); +} + +static ssize_t nvmet_addr_tsas_store (struct config_item *item, +const char *page,size_t count) +{ +struct nvmet_port *port =to_nvmet_port (item); +u8 sectype; +int i; + +if (nvmet_is_port_enabled (port, __func__)) +return -EACCES ; + +if (port->disc_addr.trtype !=NVMF_TRTYPE_TCP ) +return -EINVAL ; + +for (i =0 ; i <ARRAY_SIZE (nvmet_addr_tsas_tcp); i++) { +if (sysfs_streq (page, nvmet_addr_tsas_tcp[i].name)) { + sectype = nvmet_addr_tsas_tcp[i].type; + goto found; + } + } + +pr_err ("Invalid value '%s' for tsas\n" , page); +return -EINVAL ; + +found: +nvmet_port_init_tsas_tcp (port, sectype); +return count; +} + +CONFIGFS_ATTR (nvmet_, addr_tsas); +/* * Namespace structures & file operation functions below */
@@ -1487,6 +1559,7 @@ static struct configfs_attribute *nvmet_port_attrs[] = { &nvmet_attr_addr_traddr, &nvmet_attr_addr_trsvcid, &nvmet_attr_addr_trtype, + &nvmet_attr_addr_tsas, &nvmet_attr_param_inline_data_size, #ifdef CONFIG_BLK_DEV_INTEGRITY &nvmet_attr_param_pi_enable,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1800/1848 nvmet: use the enabled transport when disabling a port
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rongzheng Wang <[email protected]>
[ Upstream commit 60385038754ed9fb05dab127b35f88c702252505 ]
nvmet_disable_port() looks up the transport from the current disc_addr.trtype, while nvmet_enable_port() records the transport in port->tr_ops. If trtype is changed while a port is being enabled, the port can be removed through a different transport, passing the private data of the original transport to the wrong ->remove_port().
The same mismatch is reachable with loop and RDMA: loop add_port() leaves port->priv NULL, and RDMA remove_port() dereferences it.
Use port->tr_ops for removal and serialize trtype changes with nvmet_config_sem in nvmet_addr_trtype_store(), so the transport that added the port is also the one that removes it.
--- drivers/nvme/target/configfs.c | 16 ++++++++++++---- drivers/nvme/target/core.c | 8 +++++--- 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/nvme/target/configfs.c +12 -4
@@ -313,10 +313,15 @@ static ssize_t nvmet_addr_trtype_store(struct config_item *item, const char *page, size_t count) {struct nvmet_port *port =to_nvmet_port (item); +ssize_t ret = count;int i; -if (nvmet_is_port_enabled (port, __func__)) -return -EACCES ; +down_write (&nvmet_config_sem); + +if (nvmet_is_port_enabled (port, __func__)) { + ret = -EACCES ; + goto out; + }for (i =0 ; i <ARRAY_SIZE (nvmet_transport); i++) {if (sysfs_streq (page, nvmet_transport[i].name))
@@ -324,7 +329,8 @@ static ssize_t nvmet_addr_trtype_store(struct config_item *item, }pr_err ("Invalid value '%s' for trtype\n" , page); -return -EINVAL ; + ret = -EINVAL ; + goto out; found:memset (&port->disc_addr.tsas,0 ,NVMF_TSAS_SIZE );
@@ -333,7 +339,9 @@ static ssize_t nvmet_addr_trtype_store(struct config_item *item,nvmet_port_init_tsas_rdma (port); else if (port->disc_addr.trtype == NVMF_TRTYPE_TCP) nvmet_port_init_tsas_tcp(port, NVMF_TCP_SECTYPE_NONE); -return count; +out: +up_write (&nvmet_config_sem); +return ret; }CONFIGFS_ATTR (nvmet_, addr_trtype);
drivers/nvme/target/core.c +5 -3
@@ -367,11 +367,13 @@ void nvmet_disable_port(struct nvmet_port *port)lockdep_assert_held (&nvmet_config_sem); - port->enabled = false; - port->tr_ops =NULL ; +if (!port->enabled) +return ; - ops = nvmet_transports[port->disc_addr.trtype]; + ops = port->tr_ops; + port->enabled = false; ops->remove_port (port); + port->tr_ops =NULL ;module_put (ops->owner); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1801/1848 nvmet-tcp: stop listening when a port is removed
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit ece0f4e67f08792c8572080fb0fcc231554f08ca ]
nvmet_tcp_accept_work() accepts until there's nothing left. A connection that is already dead when accepted is torn down right there, which takes a few ms, and more can arrive meanwhile. nvmet_tcp_remove_port() waits for the work with cancel_work_sync(), so someone opening and closing connections in a loop keeps the removal from finishing. It holds nvmet_config_sem for writing, so nothing can be configured and no port answers a Connect until the flood stops. No secret needed, just an admin removing the port at the wrong time.
Shut the listening socket down first. Pending connections are dropped, as they were on release, and the next kernel_accept() fails and ends the work.
--- drivers/nvme/target/tcp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/target/tcp.c +2 -0
@@ -1827,6 +1827,8 @@ static void nvmet_tcp_remove_port(struct nvmet_port *nport) port->sock->sk->sk_data_ready = port->data_ready; port->sock->sk->sk_user_data =NULL ;write_unlock_bh (&port->sock->sk->sk_callback_lock); +/* The accept work goes on for as long as there is something to accept */ +kernel_sock_shutdown (port->sock,SHUT_RDWR );cancel_work_sync (&port->accept_work);/* * Destroy the remaining queues, which are not belong to any
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1802/1848 nvmet-tcp: dont read a removed port at Connect time
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 3f98ce65a87979e881343dcf082c9595ec90ddc7 ]
nvmet_tcp_alloc_cmd() takes the nvmet port of a command from queue->port, and the commands of a queue are allocated from the io work when the Connect arrives. nvmet_tcp_remove_port() shuts down the queues that have no controller yet and frees the port without waiting for them, they're released later from a work. An io work handling a Connect at that moment reads the freed port for every command of the queue and hands the result to the core.
Note the nvmet port in the queue at allocation. It outlives the transport port.
--- drivers/nvme/target/tcp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/target/tcp.c +4 -1
@@ -94,6 +94,7 @@ enum nvmet_tcp_queue_state {struct nvmet_tcp_queue {struct socket *sock;struct nvmet_tcp_port *port; +struct nvmet_port *nport;struct work_struct io_work;struct nvmet_cq nvme_cq;struct nvmet_sq nvme_sq;
@@ -1370,7 +1371,7 @@ static int nvmet_tcp_alloc_cmd(struct nvmet_tcp_queue *queue,u8 hdgst =nvmet_tcp_hdgst_len (queue); c->queue = queue; - c->req.port = queue->port->nport; + c->req.port = queue->nport; c->cmd_pdu =page_frag_alloc (&queue->pf_cache,sizeof (*c->cmd_pdu) + hdgst,GFP_KERNEL | __GFP_ZERO);
@@ -1647,6 +1648,8 @@ static int nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,INIT_WORK (&queue->io_work, nvmet_tcp_io_work); queue->sock = newsock; queue->port = port; +/* The port may be gone when the commands are allocated */ + queue->nport = port->nport; queue->nr_cmds =0 ;spin_lock_init (&queue->state_lock); queue->state =NVMET_TCP_Q_CONNECTING ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1803/1848 blk-mq: add new API of blk_mq_hctx_set_fq_lock_class
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit fb01a2932e81a1fb2273f87ff92dc8172b8880ee ]
flush_end_io() may be called recursively from some driver, such as nvme-loop, so lockdep may complain 'possible recursive locking'. Commit b3c6a5997541("block: Fix a lockdep complaint triggered by request queue flushing") tried to address this issue by assigning dynamically allocated per-flush-queue lock class. This solution adds synchronize_rcu() for each hctx's release handler, and causes horrible SCSI MQ probe delay(more than half an hour on megaraid sas).
Add new API of blk_mq_hctx_set_fq_lock_class() for these drivers, so we just need to use driver specific lock class for avoiding the lockdep warning of 'possible recursive locking'.
Stable-dep-of: 64e21d782020 ("nvme-loop: don't BUG() if a scan runs beside a reset")
--- block/blk-flush.c | 25 +++++++++++++++++++++++++ include/linux/blk-mq.h | 3 +++ 2 files changed, 28 insertions(+)
block/blk-flush.c +25 -0
@@ -509,3 +509,28 @@ void blk_free_flush_queue(struct blk_flush_queue *fq)kfree (fq->flush_rq);kfree (fq); } + +/* +* Allow driver to set its own lock class to fq->mq_flush_lock for +* avoiding lockdep complaint. +* +* flush_end_io() may be called recursively from some driver, such as +* nvme-loop, so lockdep may complain 'possible recursive locking' because +* all 'struct blk_flush_queue' instance share same mq_flush_lock lock class +* key. We need to assign different lock class for these driver's +* fq->mq_flush_lock for avoiding the lockdep warning. +* +* Use dynamically allocated lock class key for each 'blk_flush_queue' +* instance is over-kill, and more worse it introduces horrible boot delay +* issue because synchronize_rcu() is implied in lockdep_unregister_key which +* is called for each hctx release. SCSI probing may synchronously create and +* destroy lots of MQ request_queues for non-existent devices, and some robot +* test kernel always enable lockdep option. It is observed that more than half +* an hour is taken during SCSI MQ probe with per-fq lock class. +*/ +void blk_mq_hctx_set_fq_lock_class (struct blk_mq_hw_ctx *hctx, +struct lock_class_key *key) +{ +lockdep_set_class (&hctx->fq->mq_flush_lock, key); +} +EXPORT_SYMBOL_GPL (blk_mq_hctx_set_fq_lock_class);
include/linux/blk-mq.h +3 -0
@@ -5,6 +5,7 @@#include <linux/blkdev.h> #include <linux/sbitmap.h> #include <linux/srcu.h> +#include <linux/lockdep.h> struct blk_mq_tags ;struct blk_flush_queue ;
@@ -594,5 +595,7 @@ static inline void blk_mq_cleanup_rq(struct request *rq) }blk_qc_t blk_mq_submit_bio (struct bio *bio); +void blk_mq_hctx_set_fq_lock_class (struct blk_mq_hw_ctx *hctx, +struct lock_class_key *key);#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1804/1848 nvme-loop: use blk_mq_hctx_set_fq_lock_class to set loops lock class
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit 88c9979334aa5ff8c814ddf578f3113ed6c5ce8e ]
Set nvme-loop's lock class via blk_mq_hctx_set_fq_lock_class for avoiding lockdep possible recursive locking, then we can remove the dynamically allocated lock class for each flush queue, finally we can avoid horrible SCSI probe delay.
This way may not address situation in which one nvme-loop is backed on another nvme-loop. However, in reality, people seldom uses this way for test. Even though someone played in this way, it is just one recursive locking false positive, no real deadlock issue.
Stable-dep-of: 64e21d782020 ("nvme-loop: don't BUG() if a scan runs beside a reset")
--- drivers/nvme/target/loop.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/nvme/target/loop.c +10 -0
@@ -211,6 +211,8 @@ static int nvme_loop_init_request(struct blk_mq_tag_set *set, (set == &ctrl->tag_set) ? hctx_idx + 1 : 0); } +static struct lock_class_key loop_hctx_fq_lock_key; +static int nvme_loop_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) {
@@ -219,6 +221,14 @@ static int nvme_loop_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,BUG_ON (hctx_idx >= ctrl->ctrl.queue_count); +/* +* flush_end_io() can be called recursively for us, so use our own +* lock class key for avoiding lockdep possible recursive locking, +* then we can remove the dynamically allocated lock class for each +* flush queue, that way may cause horrible boot delay. +*/ +blk_mq_hctx_set_fq_lock_class (hctx, &loop_hctx_fq_lock_key); + hctx->driver_data = queue;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1805/1848 nvme-loop: dont BUG() if a scan runs beside a reset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 64e21d782020e267ca57765a30216c38b34f296d ]
A reset sets queue_count to 1 while it destroys the I/O queues and counts it back up when the new ones are made, and it doesn't stop the scan work. A new namespace found in that window trips the check in nvme_loop_init_hctx() for every hctx but the first:
kernel BUG at drivers/nvme/target/loop.c:224!
nvme_loop_init_hctx+0x7d/0x80 __blk_mq_realloc_hw_ctxs+0x3af/0xa80 nvme_alloc_ns+0x1a2/0x22f0
The check protects nothing. ctrl->queues has nr_io_queues + 1 entries for the life of the controller, the tag set never has more hardware queues than that, and nvme_loop_queue_rq() rejects requests until the controller is live again.
Remove it.
--- drivers/nvme/target/loop.c | 2 -- 1 file changed, 2 deletions(-)
drivers/nvme/target/loop.c +0 -2
@@ -219,8 +219,6 @@ static int nvme_loop_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,struct nvme_loop_ctrl *ctrl = data;struct nvme_loop_queue *queue = &ctrl->queues[hctx_idx +1 ]; -BUG_ON (hctx_idx >= ctrl->ctrl.queue_count); -/* * flush_end_io() can be called recursively for us, so use our own * lock class key for avoiding lockdep possible recursive locking,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1806/1848 nvmet-rdma: disable interrupts under rsp_wr_wait_lock
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 14e4e09443ac2b5cd90c1e313ee3c0bdd4928e0d ]
rsp_wr_wait_lock protects the list of commands waiting for room in the send queue, and it's taken with plain spin_lock(). But nvmet_rdma_queue_response() calls nvmet_rdma_release_rsp() directly if ib_post_send() fails, and that processes the wait list. The call chain starts in nvmet_req_complete(), which for a block device namespace runs from the bio end_io callback, which can be in hard interrupt context. An interrupt that completes a command on a CPU holding the lock for the same queue spins forever. Lockdep over siw with a null_blk namespace:
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage
Use spin_lock_irqsave() for both takers. The processing loop still drops the lock, and restores the caller's interrupt state, around nvmet_rdma_execute_command().
--- drivers/nvme/target/rdma.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/nvme/target/rdma.c +9 -6
@@ -511,7 +511,9 @@ static int nvmet_rdma_post_recv(struct nvmet_rdma_device *ndev,static void nvmet_rdma_process_wr_wait_list (struct nvmet_rdma_queue *queue) { -spin_lock (&queue->rsp_wr_wait_lock); +unsigned long flags; + +spin_lock_irqsave (&queue->rsp_wr_wait_lock, flags);while (!list_empty (&queue->rsp_wr_wait_list)) {struct nvmet_rdma_rsp *rsp;bool ret;
@@ -520,16 +522,16 @@ static void nvmet_rdma_process_wr_wait_list(struct nvmet_rdma_queue *queue) struct nvmet_rdma_rsp, wait_list);list_del (&rsp->wait_list); -spin_unlock (&queue->rsp_wr_wait_lock); +spin_unlock_irqrestore (&queue->rsp_wr_wait_lock, flags); ret =nvmet_rdma_execute_command (rsp); -spin_lock (&queue->rsp_wr_wait_lock); +spin_lock_irqsave (&queue->rsp_wr_wait_lock, flags);if (!ret) {list_add (&rsp->wait_list, &queue->rsp_wr_wait_list);break ; } } -spin_unlock (&queue->rsp_wr_wait_lock); +spin_unlock_irqrestore (&queue->rsp_wr_wait_lock, flags); }static u16 nvmet_rdma_check_pi_status (struct ib_mr *sig_mr)
@@ -977,6 +979,7 @@ static bool nvmet_rdma_execute_command(struct nvmet_rdma_rsp *rsp)static void nvmet_rdma_handle_command (struct nvmet_rdma_queue *queue,struct nvmet_rdma_rsp *cmd) { +unsigned long flags;u16 status; ib_dma_sync_single_for_cpu(queue->dev->device,
@@ -995,9 +998,9 @@ static void nvmet_rdma_handle_command(struct nvmet_rdma_queue *queue, goto out_err;if (unlikely (!nvmet_rdma_execute_command (cmd))) { -spin_lock (&queue->rsp_wr_wait_lock); +spin_lock_irqsave (&queue->rsp_wr_wait_lock, flags);list_add_tail (&cmd->wait_list, &queue->rsp_wr_wait_list); -spin_unlock (&queue->rsp_wr_wait_lock); +spin_unlock_irqrestore (&queue->rsp_wr_wait_lock, flags); }return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1807/1848 nvmet-rdma: fix double puts after a failed RDMA WRITE
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit f1dac2a2e75260d1466d9f03ccf0944d6d0449a4 ]
For a read with T10-PI the RDMA WRITE is posted alone and nvmet_rdma_write_data_done() posts the SEND once the metadata check result is known. By then the request has been completed and its references put: __nvmet_req_complete() put ns->ref and the pc_ref, and nvmet_req_complete() sq->ref, right after queuing the response. The error branch of nvmet_rdma_write_data_done() copies the one from nvmet_rdma_read_data_done() and calls nvmet_req_uninit(), which puts all three again. A WRITE fails whenever the connection ends with reads in flight, which is up to the host. Depending on timing the sq->ref count goes to zero early and the queue is freed under the remaining completions, or never reaches zero and nvmet_sq_destroy() sleeps forever, or percpu_ref_put() dereferences NULL after percpu_ref_exit(). ns->ref stays too low for good, so disabling the namespace hangs too. Reproduced with KASAN over rxe with a test patch forcing the PI path.
Drop the nvmet_req_uninit(). The branch still releases the RDMA context and the response, which is all the request owns at that point.
--- drivers/nvme/target/rdma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/target/rdma.c +4 -1
@@ -801,7 +801,10 @@ static void nvmet_rdma_write_data_done(struct ib_cq *cq, struct ib_wc *wc)if (unlikely (wc->status !=IB_WC_SUCCESS )) {nvmet_rdma_rw_ctx_destroy (rsp); -nvmet_req_uninit (&rsp->req); +/* +* Unlike in nvmet_rdma_read_data_done(), the request has been +* completed and its references are put: no nvmet_req_uninit(). +*/ nvmet_rdma_release_rsp (rsp);if (wc->status !=IB_WC_WR_FLUSH_ERR ) { pr_info("RDMA WRITE for CQE failed with status %s (%d).\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1808/1848 blk-throttle: dont truncate the cgroup v1 iops limits
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 7d96874ba80ba7a2ab578ea9139c2af79c353b88 ]
tg_set_conf() parses the limit into a u64 and stores the iops ones through an unsigned int, so anything above UINT_MAX is truncated and a multiple of 2^32 becomes a limit of 0. The next IO of the group then divides by it in tg_within_iops_limit().
Clamp to UINT_MAX, which means no limit, like tg_set_limit() does on the default hierarchy.
--- block/blk-throttle.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-throttle.c +2 -1
@@ -1480,7 +1480,8 @@ static ssize_t tg_set_conf(struct kernfs_open_file *of,if (is_u64) *(u64 *)((void *)tg +of_cft (of)->private) = v;else - *(unsigned int *)((void *)tg +of_cft (of)->private) = v; + *(unsigned int *)((void *)tg +of_cft (of)->private) = +min_t (u64, v,UINT_MAX );tg_conf_updated (tg, false); ret =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1809/1848 net: dcb: initialize PFC value before calling getpfccfg
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit ca87a2dffbb550fc934647d5e8d1c4ae85590132 ]
dcbnl_getpfccfg() and dcbnl_cee_fill() pass the address of an uninitialized stack u8 to the driver's getpfccfg() op and then put it into the netlink reply unconditionally. The op returns void, so the core cannot tell whether the driver wrote the value.
i40e_dcbnl_get_pfc_cfg() and ice_dcbnl_get_pfc_cfg() return without writing *setting unless the DCBX agent is host managed and in CEE mode. Both drivers normally run with firmware managed DCBX (DCB_CAP_DCBX_LLD_MANAGED), and i40e with FW LLDP disabled runs host managed in IEEE mode, so on a DCB capable i40e/ice port the PFC values in DCB_CMD_PFC_GCFG and DCB_CMD_CEE_GET replies, and in the CEE part of RTNLGRP_DCB notifications, come from uninitialized stack. The same u8 is reused for all eight priorities, so this is one byte per reply.
dcb_doit() only requires CAP_NET_ADMIN for RTM_SETDCB, so the GET commands are available to unprivileged users.
Set the value to 0 before each call, like the PG config path already presets its outputs to DCB_ATTR_VALUE_UNDEFINED. 0 is also what the reply contains today on kernels built with CONFIG_INIT_STACK_ALL_ZERO, so nothing changes for those.
Found by code inspection, compile-tested only (W=1). I don't have i40e/ice hardware to check the reply.
--- net/dcb/dcbnl.c | 2 ++ 1 file changed, 2 insertions(+)
net/dcb/dcbnl.c +2 -0
@@ -247,6 +247,7 @@ static int dcbnl_getpfccfg(struct net_device *netdev, struct nlmsghdr *nlh,if (!getall && !data[i])continue ; + value =0 ; netdev->dcbnl_ops->getpfccfg (netdev, i -DCB_PFC_UP_ATTR_0 , &value); ret =nla_put_u8 (skb, i, value);
@@ -1260,6 +1261,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev) goto nla_put_failure;for (i =DCB_PFC_UP_ATTR_0 ; i <=DCB_PFC_UP_ATTR_7 ; i++) { + value =0 ; ops->getpfccfg (netdev, i -DCB_PFC_UP_ATTR_0 , &value);if (nla_put_u8 (skb, i, value)) goto nla_put_failure;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1810/1848 rtc: s35390a: Add missing newline to dev_err
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Probst <[email protected]>
[ Upstream commit a27b25bb9b422c8468cb6965b2d72b7b64187fd2 ]
--- drivers/rtc/rtc-s35390a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-s35390a.c +1 -1
@@ -474,7 +474,7 @@ static int s35390a_probe(struct i2c_client *client, buf =0 ; err =s35390a_set_reg (s35390a,S35390A_CMD_STATUS2 , &buf,1 );if (err <0 ) { -dev_err (dev,"error disabling alarm" ); +dev_err (dev,"error disabling alarm\n" );return err; } }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1811/1848 rtc: s35390a: Fix alarm not disabling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Probst <[email protected]>
[ Upstream commit d93f29e41089bbb14637289fe77bdd72b71e9ac5 ]
Implement alarm_irq_enable callback.
--- drivers/rtc/rtc-s35390a.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
drivers/rtc/rtc-s35390a.c +24 -5
@@ -273,6 +273,24 @@ static int s35390a_rtc_read_time(struct device *dev, struct rtc_time *tm)return 0 ; } +static int s35390a_rtc_alarm_irq_enable (struct device *dev,unsigned int enabled) +{ +struct s35390a *s35390a =dev_get_drvdata (dev); +u8 sts; +int err; + +if (enabled) + sts =S35390A_INT2_MODE_ALARM ; +else + sts =S35390A_INT2_MODE_NOINTR ; + + err =s35390a_set_reg (s35390a,S35390A_CMD_STATUS2 , &sts,sizeof (sts)); +if (err <0 ) +return err; + +return 0 ; +} +static int s35390a_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alm) {struct i2c_client *client =to_i2c_client (dev);
@@ -416,11 +434,12 @@ static int s35390a_rtc_ioctl(struct device *dev, unsigned int cmd, }static const struct rtc_class_ops s35390a_rtc_ops = { - .read_time = s35390a_rtc_read_time, - .set_time = s35390a_rtc_set_time, - .set_alarm = s35390a_rtc_set_alarm, - .read_alarm = s35390a_rtc_read_alarm, - .ioctl = s35390a_rtc_ioctl, + .read_time = s35390a_rtc_read_time, + .set_time = s35390a_rtc_set_time, + .set_alarm = s35390a_rtc_set_alarm, + .read_alarm = s35390a_rtc_read_alarm, + .alarm_irq_enable = s35390a_rtc_alarm_irq_enable, + .ioctl = s35390a_rtc_ioctl, }; static int s35390a_probe(struct i2c_client *client,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1812/1848 blk-mq: keep sharing tags fairly after a queue update
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 620cfc7a664278a55d068ed88fff1242fddc4ef2 ]
A hctx only gets BLK_MQ_F_TAG_QUEUE_SHARED from blk_mq_add_queue_tag_set(). The hctxs blk_mq_update_nr_hw_queues() allocates for queues that joined long ago never get it, so they aren't counted in active_queues and hctx_may_queue() lets them take all the tags. One NVMe namespace can starve the others after the first update.
Set the flag on the new hctxs.
--- block/blk-mq.c | 3 +++ 1 file changed, 3 insertions(+)
block/blk-mq.c +3 -0
@@ -3776,6 +3776,9 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, goto fallback; }blk_mq_map_swqueue (q); +/* The new hctxs don't know yet that they share their tags */ +if (set->flags &BLK_MQ_F_TAG_QUEUE_SHARED ) +queue_set_hctx_shared (q, true); } reregister:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1813/1848 block: partitions/mac: compute the sectors in 64 bits
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 6c55f94317249bc195e197f6a8730c843e72ea8c ]
start_block and block_count are converted to 512 byte sectors in 32-bit arithmetic, although put_partition() takes a sector_t. With a block size above 512 bytes anything beyond 2TiB wraps and the partition lands on top of another one.
--- block/partitions/mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/partitions/mac.c +2 -2
@@ -95,8 +95,8 @@ int mac_partition(struct parsed_partitions *state)if (be16_to_cpu (part->signature) !=MAC_PARTITION_MAGIC )break ;put_partition (state, slot, -be32_to_cpu (part->start_block) * (secsize/512 ), -be32_to_cpu (part->block_count) * (secsize/512 )); + (sector_t )be32_to_cpu (part->start_block) * (secsize/512 ), + (sector_t )be32_to_cpu (part->block_count) * (secsize/512 ));if (!strncasecmp (part->type,"Linux_RAID" ,10 )) state->parts[slot].flags =ADDPART_FLAG_RAID ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1814/1848 drbd: take req_lock to skip the initial sync as peer
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit bf7fff620c890a7ee0b444f1c7e9f0d1263a30ac ]
_drbd_set_state() must be called with req_lock held. drbd_adm_new_c_uuid() does, receive_uuids() on the peer doesn't, so a concurrent state change gets lost: the device is Secondary again, or its failed disk UpToDate, while the work for the lost change is already queued.
--- drivers/block/drbd/drbd_receiver.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/drbd/drbd_receiver.c +2 -0
@@ -4331,8 +4331,10 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info BM_LOCKED_TEST_ALLOWED);_drbd_uuid_set (device,UI_CURRENT , p_uuid[UI_CURRENT ]);_drbd_uuid_set (device,UI_BITMAP ,0 ); +spin_lock_irq (&device->resource->req_lock);_drbd_set_state (_NS2 (device, disk,D_UP_TO_DATE , pdsk,D_UP_TO_DATE ),CS_VERBOSE ,NULL ); +spin_unlock_irq (&device->resource->req_lock);drbd_md_sync (device); updated_uuids =1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1815/1848 selftests: net: txtimestamp: fix out-of-bounds read in raw UDP checksum
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamie Nguyen <[email protected]>
[ Upstream commit 8daacee78b3d2798fcf92398b6dff364eab64466 ]
With -r (SOCK_RAW, IPPROTO_UDP) the test writes only the UDP header and payload, and the kernel adds the IP header. get_udp_csum() still expects the IP source and destination addresses to directly precede the UDP header, and reads 2 * alen bytes before the start of the buffer: 8 bytes for IPv4, 32 bytes for IPv6.
ASan reports a heap-buffer-overflow for both -4 -r and -6 -r. Without ASan the read usually goes unnoticed, but it faults when the buffer is the first chunk in the heap. That happens on Ubuntu 26.04, where the kselftest runner wraps the test in uutils stdbuf, and txtimestamp.sh fails with SIGSEGV on every run.
Even without a crash, -r packets were sent with a checksum computed over unrelated heap memory, so their UDP checksum was invalid.
Build the pseudo-header from the destination address and checksum only the UDP header and payload. -R and -P already write daddr as both the source and destination address, so their checksums are unchanged. With -r the kernel selects the source address, which equals daddr for the loopback addresses used by txtimestamp.sh.
--- tools/testing/selftests/net/txtimestamp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
tools/testing/selftests/net/txtimestamp.c +14 -9
@@ -412,19 +412,25 @@ static uint16_t get_ip_csum(const uint16_t *start, int num_words,return ~sum; } -static uint16_t get_udp_csum (const struct udphdr *udph,int alen) +static uint16_t get_udp_csum (const struct udphdr *udph,bool is_ipv4) { -unsigned long pseudo_sum, csum_len; -const void *csum_start = udph; +const void *addr = is_ipv4 ? (void *)&daddr.sin_addr : &daddr6.sin6_addr; +int alen = is_ipv4 ?sizeof (struct in_addr ) :sizeof (struct in6_addr ); +uint16_t addr16[sizeof (struct in6_addr ) /sizeof (uint16_t )]; +unsigned long pseudo_sum; +int i; pseudo_sum =htons (IPPROTO_UDP ); pseudo_sum += udph->len; -/* checksum ip(v6) addresses + udp header + payload */ - csum_start -= alen *2 ; - csum_len =ntohs (udph->len) + alen *2 ; +/* pseudo-header source and destination: both are daddr */ +memcpy (addr16, addr, alen); +for (i =0 ; i < alen /2 ; i++) + pseudo_sum +=2 * addr16[i]; -return get_ip_csum (csum_start, csum_len >>1 , pseudo_sum); +/* checksum udp header + payload */ +return get_ip_csum ((const uint16_t *)udph,ntohs (udph->len) >>1 , + pseudo_sum); }static int fill_header_ipv4 (void *p)
@@ -473,8 +479,7 @@ static void fill_header_udp(void *p, bool is_ipv4) udph->len =ntohs (sizeof (*udph) + cfg_payload_len); udph->check =0 ; - udph->check =get_udp_csum (udph, is_ipv4 ?sizeof (struct in_addr ) : -sizeof (struct in6_addr )); + udph->check =get_udp_csum (udph, is_ipv4); }static void do_test (int family,unsigned int report_opt)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1816/1848 apparmor: report a label allocation failure as -ENOMEM
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Bélair <[email protected]>
[ Upstream commit 07aee062c6ecaa7199be583c83a1c74ae9885f03 ]
aa_label_strn_parse() returns -ENOENT for every failure, so a caller cannot tell "no such profile" from "could not allocate a label".
Report an allocation failure as -ENOMEM.
--- security/apparmor/label.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
security/apparmor/label.c +10 -4
@@ -1950,12 +1950,18 @@ struct aa_label *aa_label_strn_parse(struct aa_label *base, const char *str, goto out; } -if (create) +if (create) { label =aa_vec_find_or_create_label (vec, len, gfp); -else +if (!label) { +/* not absence: creating only fails on allocation */ + label =ERR_PTR (-ENOMEM ); + goto out; + } + }else { label =vec_find (vec, len); -if (!label) - goto fail; +if (!label) + goto fail; + } out:/* use adjusted len from after vec_unique, not original */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1817/1848 apparmor: Fix namespace reference leak in __aa_find_or_create_ns()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 8f1f7f664c1822af34c5465f9820b4e39146786b ]
When the namespace already exists, the reference taken by aa_get_ns() is overwritten with ERR_PTR(-EEXIST) without being released. The caller in apparmorfs.c clears ns on IS_ERR() and so cannot drop it either, leaking the reference on raced mkdir of an existing namespace.
Release the reference before returning -EEXIST.
--- security/apparmor/policy_ns.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
security/apparmor/policy_ns.c +4 -2
@@ -291,10 +291,12 @@ struct aa_ns *__aa_find_or_create_ns(struct aa_ns *parent, const char *name,/* try and find the specified ns */ /* released by caller */ ns =aa_get_ns (__aa_find_ns (&parent->sub_ns, name)); -if (!ns) +if (!ns) { ns =__aa_create_ns (parent, name, dir); -else + }else { +aa_put_ns (ns); ns =ERR_PTR (-EEXIST ); + }/* return ref */ return ns;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1818/1848 net: bgmac: fix TX DMA unmapping and slot cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 4f45e97b3aac2282f2b436d97338c9c2c484d093 ]
When mapping a fragment fails, bgmac_dma_tx_add() unwinds with the wrong slots. It passes the failed fragment's slot->dma_addr, which holds the mapping error, to dma_unmap_single() for the head. The fragment loop indexes from ring->end instead of ring->end + 1, so it unmaps the head a second time as a page and leaves the last mapped fragment mapped. None of the affected slots get their dma_addr cleared either, which includes the head slot when mapping the head fails.
bgmac_dma_tx_ring_free() unmaps every slot with a non-zero dma_addr, so tearing down the ring unmaps these addresses again. It also frees the skbs of pending TX slots but leaves slot->skb and slot->dma_addr set. The slots survive a down/up cycle, and bgmac_dma_tx_add() only sets slot->skb on the last slot of a packet. If a slot with a stale pointer is later used for the head or a fragment of a scatter/gather packet, bgmac_dma_tx_free() frees the old skb a second time when that slot completes.
bgmac_dma_tx_ring_free() also picks dma_unmap_single() or dma_unmap_page() by looking at slot->skb, which is set on the last slot of a packet, while the head was mapped with dma_map_single() and the fragments with skb_frag_dma_map().
In the error path, unmap the head and each mapped fragment from their own slots, and clear dma_addr on every slot the failed packet touched. In bgmac_dma_tx_ring_free(), choose the unmap function by the SOF flag of the descriptor like bgmac_dma_tx_free() does, unmap every slot before freeing any skb, since a packet can wrap around the end of the ring with its skb on the last slot, and clear both fields.
This was found through code inspection by an LLM while hitting other bugs on an Asus RT-N16. It did not hit these ones specifically.
--- drivers/net/ethernet/broadcom/bgmac.c | 47 +++++++++++++++++---------- 1 file changed, 30 insertions(+), 17 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +30 -17
@@ -208,19 +208,24 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,return NETDEV_TX_OK ; err_dma: -dma_unmap_single (dma_dev, slot->dma_addr,skb_headlen (skb), -DMA_TO_DEVICE ); + slot->dma_addr =0 ;while (i-- >0 ) { -int index = (ring->end + i) %BGMAC_TX_RING_SLOTS ; -struct bgmac_slot_info *slot = &ring->slots[index]; -u32 ctl1 =le32_to_cpu (ring->cpu_base[index].ctl1); -int len = ctl1 &BGMAC_DESC_CTL1_LEN ; - -dma_unmap_page (dma_dev, slot->dma_addr, len,DMA_TO_DEVICE ); + index = (ring->end +1 + i) %BGMAC_TX_RING_SLOTS ; + slot = &ring->slots[index]; +dma_unmap_page (dma_dev, slot->dma_addr, +skb_frag_size (&skb_shinfo (skb)->frags[i]), +DMA_TO_DEVICE ); + slot->dma_addr =0 ; } + slot = &ring->slots[ring->end %BGMAC_TX_RING_SLOTS ]; +dma_unmap_single (dma_dev, slot->dma_addr,skb_headlen (skb), +DMA_TO_DEVICE ); + err_dma_head: + slot->dma_addr =0 ; +netdev_err (bgmac->net_dev,"Mapping error of skb on ring 0x%X\n" , ring->mmio_base);
@@ -535,17 +540,25 @@ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,unsigned int len = ctl1 &BGMAC_DESC_CTL1_LEN ; slot = &ring->slots[i]; -dev_kfree_skb (slot->skb); -if (!slot->dma_addr) -continue ; +if (slot->dma_addr) { +if (le32_to_cpu (dma_desc[i].ctl0) &BGMAC_DESC_CTL0_SOF ) +dma_unmap_single (dma_dev, slot->dma_addr, + len,DMA_TO_DEVICE ); +else +dma_unmap_page (dma_dev, slot->dma_addr, + len,DMA_TO_DEVICE ); + slot->dma_addr =0 ; + } + } -if (slot->skb) -dma_unmap_single (dma_dev, slot->dma_addr, - len,DMA_TO_DEVICE ); -else -dma_unmap_page (dma_dev, slot->dma_addr, - len,DMA_TO_DEVICE ); +/* A packet can wrap around the end of the ring with its skb on the +* last slot, so free the skbs only once every slot is unmapped. +*/ +for (i =0 ; i <BGMAC_TX_RING_SLOTS ; i++) { + slot = &ring->slots[i]; +dev_kfree_skb (slot->skb); + slot->skb =NULL ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1819/1848 netlink: check sk_rcvbuf before charging the dump skb
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jhonata Poma-Hansen <[email protected]>
[ Upstream commit b45d37740cfb4bdfccef3fbd9fd970fd3224438f ]
Since commit ae8f160e7eb2 ("netlink: Fix wraparounds of sk->sk_rmem_alloc."), netlink_dump() charges the dump skb first and queues it only if sk_rmem_alloc is still below sk_rcvbuf. Commit a215b5723922 ("netlink: make sure we allow at least one dump skb") added an exception for an empty socket.
A dump that starts while something else is still charged to a socket with a small receive buffer fails with ENOBUFS and stays running. Every recvmsg() retries it, fails again and sets sk_err, so a reader that peeks before reading, as libnl does, gets ENOBUFS on the read after each peek, never consumes the message at the head of the queue and spins forever.
I hit this with "iw dev wlan0 scan" hanging at 100% CPU on an arm64 board with a 6.6 based kernel (iw 5.19 sets SO_RCVBUF to 8KiB). A kprobe trace showed the scan dump starting while the NEW_SCAN_RESULTS notification iw had just read was still charged to its socket, because iw had preempted the sender before netlink_broadcast() returned.
Check the limit before charging, as before ae8f160e7eb2, which also covers the empty socket. netlink_recvmsg() continues a dump only at or below half of sk_rcvbuf, so the skb is then always queued, and a dump goes over the limit by at most one skb. Refuse a skb that would take sk_rmem_alloc past INT_MAX, so the wraparound stays fixed.
Reproduced on net in a KVM guest with a userspace reproducer and the selftest in the next patch; both pass with this fix.
--- net/netlink/af_netlink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/netlink/af_netlink.c +5 -1
@@ -2264,9 +2264,13 @@ static int netlink_dump(struct sock *sk, bool lock_taken)if (!skb) goto errout_skb; +/* Check the limit before charging the skb: netlink_recvmsg() continues +* the dump at or below half of sk_rcvbuf, and the skb must be queued +* then. Keep sk_rmem_alloc at or below INT_MAX. +*/ rcvbuf =READ_ONCE (sk->sk_rcvbuf); rmem =atomic_add_return (skb->truesize, &sk->sk_rmem_alloc); -if (rmem != skb->truesize && rmem >= rcvbuf) { +if (rmem - skb->truesize >= rcvbuf || rmem >INT_MAX ) {atomic_sub (skb->truesize, &sk->sk_rmem_alloc); goto errout_skb; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1820/1848 watch_queue: keep info_id separate from rcu_head
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiyu Zhang <[email protected]>
[ Upstream commit 53d72818f9e2aeb03a6053544ee6efa4eb2a3988 ]
struct watch overlays info_id with rcu_head. A notification poster reads info_id under rcu_read_lock(), but a concurrent final put can enqueue the watch with call_rcu(). Enqueueing the callback writes rcu_head before the grace period has elapsed, so it can corrupt info_id while the object remains legally visible to the reader.
__post_watch_notification() then merges that value into the notification info word without masking it. Pointer bits can corrupt WATCH_INFO_LENGTH and make post_one_notification() copy beyond the posting task's stack record.
Give info_id storage separate from rcu_head so RCU enqueueing cannot modify it. Place it after the kref, which uses existing tail padding on x86-64. Mask info_id with WATCH_INFO_ID at the point of use as an additional invariant check.
An unprivileged shell and keyctl reproducer was run for 30 seconds in QEMU. The vulnerable baseline produced malformed notification lengths, while this change completed with 288631 key notifications and no malformed record.
--- include/linux/watch_queue.h | 6 ++---- kernel/watch_queue.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)
include/linux/watch_queue.h +2 -4
@@ -53,10 +53,7 @@ struct watch_queue {* Representation of a watch on an object. */ struct watch { -union { -struct rcu_head rcu; -u32 info_id;/* ID to be OR'd in to info field */ - }; +struct rcu_head rcu;struct watch_queue __rcu *queue;/* Queue to post events to */ struct hlist_node queue_node;/* Link in queue->watches */ struct watch_list __rcu *watch_list;
@@ -65,6 +62,7 @@ struct watch {void *private;/* Private data for the watched object */ u64 id;/* Internal identifier */ struct kref usage;/* Object usage count */ +u32 info_id;/* ID to be OR'd in to info field */ };/*
kernel/watch_queue.c +1 -1
@@ -217,7 +217,7 @@ void __post_watch_notification(struct watch_list *wlist,if (watch->id != id)continue ; n->info &= ~WATCH_INFO_ID ; - n->info |= watch->info_id; + n->info |= watch->info_id &WATCH_INFO_ID ; wqueue =rcu_dereference (watch->queue); wf =rcu_dereference (wqueue->filter);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1821/1848 splice: retry tee() instead of returning 0 when it races
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolai Zeldovich <[email protected]>
[ Upstream commit b2aa970a0a03c117306f48d75a4c3125a8cc9957 ]
tee() can return 0 while the input pipe still has writers, when another task reads the input pipe or fills the output pipe at the same time. tee(2) documents 0 as "no data was copied" because the input pipe has no writers, and loops built on it (the man page example breaks out on 0) stop early. In a test with one thread writing 1 byte at a time to the input pipe, one reading it and one draining the output pipe, about one tee() call in 150 returned 0.
do_tee() runs ipipe_prep() and opipe_prep() to wait for data and room, each under its own pipe lock, and only then takes both locks in link_pipe(). If the input pipe was emptied or the output pipe filled in between, link_pipe() finds nothing to do and returns 0. splice_pipe_to_pipe(), which was modelled on tee(), handles the same race by dropping both locks and going back to the prep steps ("A zero return value means EOF, so retry instead"), and returns -EAGAIN for SPLICE_F_NONBLOCK.
Do the same in link_pipe(): move the prep steps into it and retry when nothing was linked although the input pipe still has writers.
Tested under QEMU (x86_64) with the program in the notes: 154 of 22698 tee() calls returned 0 before the change, none of 34429 after it.
--- fs/splice.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-)
fs/splice.c +31 -12
@@ -1592,6 +1592,15 @@ static int link_pipe(struct pipe_inode_info *ipipe,unsigned int i_mask, o_mask;int ret =0 ; +retry: + ret =ipipe_prep (ipipe, flags); +if (ret) +return ret; + + ret =opipe_prep (opipe, flags); +if (ret) +return ret; +/* * Potential ABBA deadlock, work around it by ordering lock * grabbing by pipe info address. Otherwise two different processes
@@ -1615,13 +1624,32 @@ static int link_pipe(struct pipe_inode_info *ipipe, i_head = ipipe->head; o_tail = opipe->tail; +if (pipe_empty (i_head, i_tail) && !ipipe->writers) +break ; +/* * If we have iterated all input buffers or run out of * output room, break. */ if (pipe_empty (i_head, i_tail) || -pipe_full (o_head, o_tail, opipe->max_usage)) -break ; +pipe_full (o_head, o_tail, opipe->max_usage)) { +if (ret) +break ; + +if (flags &SPLICE_F_NONBLOCK ) { + ret = -EAGAIN ; +break ; + } + +/* +* We raced with another reader/writer and haven't +* linked any buffers. A zero return value means EOF, +* so retry instead. +*/ +pipe_unlock (ipipe); +pipe_unlock (opipe); + goto retry; + } ibuf = &ipipe->bufs[i_tail & i_mask]; obuf = &opipe->bufs[o_head & o_mask];
@@ -1691,16 +1719,7 @@ long do_tee(struct file *in, struct file *out, size_t len, unsigned int flags)if ((in->f_flags | out->f_flags) &O_NONBLOCK ) flags |=SPLICE_F_NONBLOCK ; -/* -* Keep going, unless we encounter an error. The ipipe/opipe -* ordering doesn't really matter. -*/ - ret =ipipe_prep (ipipe, flags); -if (!ret) { - ret =opipe_prep (opipe, flags); -if (!ret) - ret =link_pipe (ipipe, opipe, len, flags); - } + ret =link_pipe (ipipe, opipe, len, flags); }if (ret >0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1822/1848 rtc: ds1685: arm the wake-up alarm at power-off only if an alarm is set
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <[email protected]>
[ Upstream commit c2373bcd50d9654b76eac585c7c98105665b3321 ]
ds1685_rtc_poweroff() always sets WIE. The wake-up alarm then compares the time-of-day and date alarm registers, which hold whatever was last written to them, and a match powers the machine straight back on.
Set WIE only when AIE is set in Control B, and clear it otherwise.
--- drivers/rtc/rtc-ds1685.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/rtc/rtc-ds1685.c +12 -6
@@ -1379,7 +1379,7 @@ module_platform_driver(ds1685_rtc_driver);void __noreturn ds1685_rtc_poweroff (struct platform_device *pdev) { -u8 ctrla, ctrl4a, ctrl4b; +u8 ctrla, ctrlb, ctrl4a, ctrl4b;struct ds1685_priv *rtc;/* Check for valid RTC data, else, spin forever. */
@@ -1406,6 +1406,8 @@ ds1685_rtc_poweroff(struct platform_device *pdev) ctrla &= ~(RTC_CTRL_A_DV2 ); rtc->write (rtc,RTC_CTRL_A , ctrla); + ctrlb = rtc->read (rtc,RTC_CTRL_B ); +/* * Read Control 4A and check the status of the auxillary * battery. This must be present and working (VRT2 = 1)
@@ -1420,13 +1422,17 @@ ds1685_rtc_poweroff(struct platform_device *pdev)/* * The auxillary battery is present and working. -* Enable extended functions (ABE=1), enable -* wake-up (WIE=1), and enable kickstart (KSE=1) -* in Control 4B. +* Enable extended functions (ABE=1) and kickstart +* (KSE=1) in Control 4B. Enable wake-up (WIE=1) only +* if an alarm is set, else stale alarm registers +* can power the system back on. */ ctrl4b = rtc->read (rtc,RTC_EXT_CTRL_4B ); - ctrl4b |= (RTC_CTRL_4B_ABE |RTC_CTRL_4B_WIE | -RTC_CTRL_4B_KSE ); + ctrl4b |= (RTC_CTRL_4B_ABE |RTC_CTRL_4B_KSE ); +if (ctrlb &RTC_CTRL_B_AIE ) + ctrl4b |=RTC_CTRL_4B_WIE ; +else + ctrl4b &= ~(RTC_CTRL_4B_WIE ); rtc->write (rtc,RTC_EXT_CTRL_4B , ctrl4b); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1823/1848 rtc: ds1685: do not sleep in the power-off handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <[email protected]>
[ Upstream commit 21a829af60a7f5c7456f1f0ff9b6b0eff0ceb738 ]
Power-off handlers run from an atomic notifier chain and must not sleep. Use mdelay() for the delay before setting PAB.
--- drivers/rtc/rtc-ds1685.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1685.c +1 -1
@@ -1438,7 +1438,7 @@ ds1685_rtc_poweroff(struct platform_device *pdev)/* Set PAB to 1 in Control 4A to power the system down. */ dev_warn (&pdev->dev,"Powerdown.\n" ); -msleep (20 ); +mdelay (20 ); rtc->write (rtc,RTC_EXT_CTRL_4A , (ctrl4a |RTC_CTRL_4A_PAB ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1824/1848 libbpf: fix cross-endian build with newer libbpf
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dominique Martinet <[email protected]>
commit 087f3964f4b3 ("libbpf: Support layout section handling in BTF") added extra data to the BTF header.
This extra data is ignored in the native case, but when building with different endianness the bswap code in old libbpf would check for strict size equality, leading to build failures such as this when BTF data is generated with a newer version of libbpf (through pahole)
BTFIDS vmlinux.unstripped
libbpf: Can't load BTF with non-native endianness due to unsupported header length 32
FAILED: load BTF from vmlinux.unstripped: Operation not supported make[2]: *** [../scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255
Newer libbpf versions also properly ignore trailing data in the bswap case, but the patch is too intrusive to backport, so take the header length comparison fix from it instead.
--- tools/lib/bpf/btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/btf.c +2 -2
@@ -191,14 +191,14 @@ static int btf_parse_hdr(struct btf *btf)struct btf_header *hdr = btf->hdr;__u32 meta_left; -if (btf->raw_size <sizeof (struct btf_header )) { + if (btf->raw_size < offsetofend(struct btf_header, str_len)) {pr_debug ("BTF header not found\n" );return -EINVAL ; }if (hdr->magic ==bswap_16 (BTF_MAGIC )) { btf->swapped_endian = true; -if (bswap_32 (hdr->hdr_len) !=sizeof (struct btf_header )) { + if (bswap_32(hdr->hdr_len) < offsetofend(struct btf_header, str_len)) {pr_warn ("Can't load BTF with non-native endianness due to unsupported header length %u\n" ,bswap_32 (hdr->hdr_len));return -ENOTSUP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1825/1848 irqchip/gic-v3-its: Fix over allocation in itt_alloc_pool()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Price <[email protected]>
commit bc88d44bd7e45b992cf8c2c2ffbc7bb3e24db4a7 upstream.
itt_alloc_pool() calls its_alloc_pages_node() to allocate an individual page to add to the pool (for allocations <PAGE_SIZE). However the final argument of its_alloc_pages_node() is the page order not the number of pages. Currently it allocates two pages and leaks the second page. Fix it by passing 0 instead (1 << 0 = 1 page).
--- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +1 -1
@@ -264,7 +264,7 @@ static void *itt_alloc_pool(int node, inif (addr)break ; - page =its_alloc_pages_node (node,GFP_KERNEL | __GFP_ZERO,1 ); + page =its_alloc_pages_node (node,GFP_KERNEL | __GFP_ZERO,0 );if (!page)break ;
Greg Kroah-Hartman
maintainerPATCH 1826/1848 selftests/net: fix typo in tcp_mmap
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 905a9eb5f636f3312964b162362e4d6ca4e37378 upstream.
kernel test robot reported the following warning:
All warnings (new ones prefixed by >>):
tcp_mmap.c: In function 'child_thread':
Quoted 1 line
Quoted 1 line
tcp_mmap.c:211:61: warning: 'lu' may be used uninitialized in this function [-Wmaybe-uninitialized]
211 | zc.length = min(chunk_size, FILE_SZ - lu);
We want to read FILE_SZ bytes, so the correct expression should be (FILE_SZ - total)
--- tools/testing/selftests/net/tcp_mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/tcp_mmap.c +1 -1
@@ -206,7 +206,7 @@ void *child_thread(void *arg)memset (&zc,0 ,sizeof (zc)); zc.address = (__u64)((unsigned long )addr); - zc.length =min (chunk_size,FILE_SZ - lu); + zc.length =min (chunk_size,FILE_SZ - total); res =getsockopt (fd,IPPROTO_TCP ,TCP_ZEROCOPY_RECEIVE , &zc, &zc_len);
Greg Kroah-Hartman
maintainerPATCH 1827/1848 dmaengine: ste_dma40: use correct print specfier for resource_size_t
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinod Koul <[email protected]>
commit ef1e1c41a11d37069029bc0563c2fa6915d9880b upstream.
We should use %pR for printing resource_size_t, so update that fixing the warning:
drivers/dma/ste_dma40.c:3556:25: warning: format specifies type 'unsigned int' but the argument has type 'resource_size_t' (aka 'unsigned long long') [-Wformat]
--- drivers/dma/ste_dma40.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/ste_dma40.c +2 -2
@@ -3647,8 +3647,8 @@ static int __init d40_probe(struct platf } base->lcpa_size =resource_size (&res_lcpa); base->phy_lcpa = res_lcpa.start; -dev_info (dev,"found LCPA SRAM at 0x%08x, size 0x%08x\n" , - (u32 )base->phy_lcpa, base->lcpa_size); +dev_info (dev,"found LCPA SRAM at 0x%08x, size %pR\n" , + (u32 )base->phy_lcpa, &base->lcpa_size);/* We make use of ESRAM memory for this. */ val =readl (base->virtbase +D40_DREG_LCPA );
Greg Kroah-Hartman
maintainerPATCH 1828/1848 dmaengine: ste_dma40: use proper format string for resource_size_t
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 41be14c71bae05c8daa3de5ae7fd7c2a7bc0d057 upstream.
A fixup for a printk format string warning causes an out-of-bounds variable access as the %pR string expects a struct resource instead of a plain resource_size_t.
Change both to the special %pap and %pap helpers for these types.
--- drivers/dma/ste_dma40.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/ste_dma40.c +2 -2
@@ -3647,8 +3647,8 @@ static int __init d40_probe(struct platf } base->lcpa_size =resource_size (&res_lcpa); base->phy_lcpa = res_lcpa.start; -dev_info (dev,"found LCPA SRAM at 0x%08x, size %pR\n" , - (u32 )base->phy_lcpa, &base->lcpa_size); +dev_info (dev,"found LCPA SRAM at %pad, size %pa\n" , + &base->phy_lcpa, &base->lcpa_size);/* We make use of ESRAM memory for this. */ val =readl (base->virtbase +D40_DREG_LCPA );
Greg Kroah-Hartman
maintainerPATCH 1829/1848 kconfig: initialize sym->curr.tri to no for all symbol types again
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
commit bfef491df67022c56aab3b831044f8d259f9441f upstream.
Geert Uytterhoeven reported that commit 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable") changed the default value of CONFIG_LOG_CPU_MAX_BUF_SHIFT from 12 to 0.
As it turned out, this is an undefined behavior because sym_calc_value() stopped setting the sym->curr.tri field for 'int', 'hex', and 'string' symbols.
This commit restores the original behavior, where 'int', 'hex', 'string' symbols are interpreted as false if used in boolean contexts.
CONFIG_LOG_CPU_MAX_BUF_SHIFT will default to 12 again, irrespective of CONFIG_BASE_SMALL. Presumably, this is not the intended behavior, as already reported [1], but this is another issue that should be addressed by a separate patch.
[1]: https://lore.kernel.org/all/[email protected]/
--- scripts/kconfig/symbol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/kconfig/symbol.c +3 -1
@@ -354,6 +354,8 @@ void sym_calc_value(struct symbol *sym) oldval = sym->curr; + newval.tri = no; +switch (sym->type) {case S_INT : newval.val ="0" ;
@@ -366,7 +368,7 @@ void sym_calc_value(struct symbol *sym)break ;case S_BOOLEAN :case S_TRISTATE : - newval = symbol_no.curr; + newval.val ="n" ;break ;default : sym->curr.val = sym->name;
Greg Kroah-Hartman
maintainerPATCH 1830/1848 irqchip/gic-v3-its: Restore quirk probing for ACPI-based systems
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 8b02da04ad978827e5ccd675acf170198f747a7a upstream.
While refactoring the way the ITSs are probed, the handling of quirks applicable to ACPI-based platforms was lost. As a result, systems such as HIP07 lose their GICv4 functionnality, and some other may even fail to boot, unless they are configured to boot with DT.
Move the enabling of quirks into its_probe_one(), making it common to all firmware implementations.
--- drivers/irqchip/irq-gic-v3-its.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +2 -1
@@ -5110,6 +5110,8 @@ static int __init its_probe_one(struct iu32 ctlr;int err; +its_enable_quirks (its); +if (is_v4 (its)) {if (!(its->typer &GITS_TYPER_VMOVP )) { err =its_compute_its_list_map (its);
@@ -5449,7 +5451,6 @@ static int __init its_of_probe(struct deif (!its)return -ENOMEM ; -its_enable_quirks (its); err =its_probe_one (its);if (err) {its_node_destroy (its);
Greg Kroah-Hartman
maintainerPATCH 1831/1848 nvmet: do not return reserved for empty TSAS values
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
commit f31e85a4d7c6ac4a3e014129c9cdc31592ea29f3 upstream.
The 'TSAS' value is only defined for TCP and RDMA, but returning 'reserved' for undefined values tricked nvmetcli to try to write 'reserved' when restoring from a config file. This caused an error and the configuration would not be applied.
--- drivers/nvme/target/configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/configfs.c +1 -1
@@ -373,7 +373,7 @@ static ssize_t nvmet_addr_tsas_show(strureturn sprintf (page,"%s\n" , nvmet_addr_tsas_rdma[i].name); } } -return sprintf (page,"reserved\n" ); +return sprintf (page,"\n" ); } static ssize_t nvmet_addr_tsas_store(struct config_item *item,
Greg Kroah-Hartman
maintainerPATCH 1832/1848 selftests/net: fix EVP_MD_CTX leak in tcp_mmap
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Yan <[email protected]>
commit f4ef35efbb49527293309f668ea73ec5de9b8e7a upstream.
In tcp_mmap.c, both child_thread() and main() allocate an EVP_MD_CTX via EVP_MD_CTX_new() when integrity checking is enabled, but neither function releases the context. child_thread() misses the free in its common cleanup block, and main() returns without freeing the context.
This results in a SHA256 context leak on every run that uses the ‑i (integrity) option. Add the missing EVP_MD_CTX_free() calls to the appropriate cleanup paths to fix the leak.
--- tools/testing/selftests/net/tcp_mmap.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/net/tcp_mmap.c +4 -0
@@ -297,6 +297,8 @@ end: ru.ru_nvcsw); } error: +if (ctx) +EVP_MD_CTX_free (ctx);munmap (buffer, buffer_sz);close (fd);if (zflg)
@@ -587,6 +589,8 @@ int main(int argc, char *argv[])EVP_DigestFinal_ex (ctx, digest, &digest_len);send (fd, digest, (size_t )SHA256_DIGEST_LENGTH ,0 ); } +if (ctx) +EVP_MD_CTX_free (ctx);close (fd);munmap (buffer, buffer_sz);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 1833/1848 irqchip/gic-v3-its: Fix its node leak in gic_acpi_parse_madt_its()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 698a8648ca8051d34722b09b8a8088c741120ac3 upstream.
Fix its node leak when its_probe_one() failed ingic_acpi_parse_madt_its().
--- drivers/irqchip/irq-gic-v3-its.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +6 -2
@@ -5602,9 +5602,13 @@ static int __init gic_acpi_parse_madt_it } err =its_probe_one (its); -if (!err) -return 0 ; +if (err) + goto probe_err; +return 0 ; + +probe_err: +its_node_destroy (its); node_err:iort_deregister_domain_token (its_entry->translation_id); dom_err:
Greg Kroah-Hartman
maintainerPATCH 1834/1848 printk: Fix LOG_CPU_MAX_BUF_SHIFT when BASE_SMALL is enabled
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yoann Congal <[email protected]>
commit 320bf43190514be5c00e11f47ec2160dd3993844 upstream.
LOG_CPU_MAX_BUF_SHIFT default value depends on BASE_SMALL:
config LOG_CPU_MAX_BUF_SHIFT
default 12 if !BASE_SMALL
default 0 if BASE_SMALL
But, BASE_SMALL is a config of type int and "!BASE_SMALL" is always evaluated to true whatever is the value of BASE_SMALL.
This patch fixes this by using the correct conditional operator for int type : BASE_SMALL != 0.
Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for BASE_SMALL defconfigs, but that will not be a big impact due to this code in kernel/printk/printk.c:
/* by default this will only continue through for large > 64 CPUs */ if (cpu_extra <= __LOG_BUF_LEN / 2)
return;
Systems using CONFIG_BASE_SMALL and having 64+ CPUs should be quite rare.
Quoted 4 lines · John Ogness <[email protected]> (printk reviewer) wrote:
For printk this will mean that
BASE_SMALLsystems were probably previously allocating/using the dynamic ringbuffer and now they will just continue to use the static ringbuffer. Which is fine and saves memory (as it should).
Quoted 4 lines · Petr Mladek <[email protected]> (printk maintainer) wrote:
More precisely, it allocated the buffer dynamically when the sum of per-CPU-extra space exceeded half of the default static ring buffer. This happened for systems with more than 64 CPUs with the default config values.
--- init/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
init/Kconfig +2 -2
@@ -715,8 +715,8 @@ config LOG_CPU_MAX_BUF_SHIFT int "CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)" depends on SMP range 0 21 - default 12 if !BASE_SMALL - default 0 if BASE_SMALL + default 0 if BASE_SMALL != 0 + default 12 depends on PRINTK help This option allows to increase the default ring buffer size
Greg Kroah-Hartman
maintainerPATCH 1835/1848 software node: Fix device_add_software_node()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heikki Krogerus <[email protected]>
commit 2a92c90f2ecca4475d6050f2f938a1755a8954cc upstream.
The function device_add_software_node() was meant to register the node supplied to it, but only if that node wasn't already registered. Right now the function attempts to always register the node. That will cause a failure with nodes that are already registered.
Fixing that by incrementing the reference count of the nodes that have already been registered, and only registering the new nodes. Also, clarifying the behaviour in the function documentation.
--- drivers/base/swnode.c | 26 +++++++++++++++++--------- include/linux/property.h | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-)
drivers/base/swnode.c +17 -9
@@ -869,25 +869,33 @@ EXPORT_SYMBOL_GPL(fwnode_remove_software/** * device_add_software_node - Assign software node to a device * @dev: The device the software node is meant for. -* @swnode: The software node. +* @node: The software node. * -* This function will register @swnode and make it the secondary firmware node -* pointer of @dev. If @dev has no primary node, then @swnode will become the primary -* node. +* This function will make @node the secondary firmware node pointer of @dev. If +* @dev has no primary node, then @node will become the primary node. The +* function will register @node automatically if it wasn't already registered. */ -int device_add_software_node (struct device *dev,const struct software_node *swnode) +int device_add_software_node (struct device *dev,const struct software_node *node) { +struct swnode *swnode;int ret;/* Only one software node per device. */ if (dev_to_swnode (dev))return -EBUSY ; - ret =software_node_register (swnode); -if (ret) -return ret; + swnode =software_node_to_swnode (node); +if (swnode) { +kobject_get (&swnode->kobj); + }else { + ret =software_node_register (node); +if (ret) +return ret; -set_secondary_fwnode (dev,software_node_fwnode (swnode)); + swnode =software_node_to_swnode (node); + } + +set_secondary_fwnode (dev, &swnode->fwnode);return 0 ; }
include/linux/property.h +1 -1
@@ -492,7 +492,7 @@ fwnode_create_software_node(const struct const struct fwnode_handle *parent);void fwnode_remove_software_node (struct fwnode_handle *fwnode); -int device_add_software_node (struct device *dev,const struct software_node *swnode); +int device_add_software_node (struct device *dev,const struct software_node *node);void device_remove_software_node (struct device *dev);#endif /* _LINUX_PROPERTY_H_ */
Greg Kroah-Hartman
maintainerPATCH 1836/1848 software node: Allow node addition to already existing device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heikki Krogerus <[email protected]>
commit b622b24519f5b008f6d4e20e5675eaffa8fbd87b upstream.
If the node is added to an already exiting device, the node needs to be also linked to the device separately.
This will make sure the reference count is kept in balance also when the node is injected to a device afterwards.
--- drivers/base/swnode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/base/swnode.c +3 -2
@@ -896,6 +896,7 @@ int device_add_software_node(struct devi }set_secondary_fwnode (dev, &swnode->fwnode); +software_node_notify (dev,KOBJ_ADD );return 0 ; }
@@ -932,8 +933,8 @@ int software_node_notify(struct device *switch (action) {case KOBJ_ADD : - ret =sysfs_create_link (&dev->kobj, &swnode->kobj, -"software_node" ); + ret =sysfs_create_link_nowarn (&dev->kobj, &swnode->kobj, +"software_node" );if (ret)break ;
Greg Kroah-Hartman
maintainerPATCH 1837/1848 mfd: Remove software node conditionally and locate at right place
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 5a23e8b0fd6010e25ae58362292235cc9213ca57 upstream.
Currently the software node is removed in error case and at ->remove() stage unconditionally, that ruins the symmetry. Besides, in some cases, when mfd_add_device() fails, the device_remove_software_node() call may lead to NULL pointer dereference:
BUG: kernel NULL pointer dereference, address: 00000000 ... EIP: strlen+0x12/0x20 ... kernfs_name_hash+0x13/0x70 kernfs_find_ns+0x32/0xc0 kernfs_remove_by_name_ns+0x2a/0x90 sysfs_remove_link+0x16/0x30 software_node_notify.cold+0x34/0x6b device_remove_software_node+0x5a/0x90 mfd_add_device.cold+0x30a/0x427
Fix all these by guarding device_remove_software_node() with a conditional and locating it at the right place.
--- drivers/mfd/mfd-core.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/mfd/mfd-core.c +9 -6
@@ -293,18 +293,18 @@ match:if (has_acpi_companion (&pdev->dev)) { ret =acpi_check_resource_conflict (&res[r]);if (ret) - goto fail_of_entry; + goto fail_res_conflict; } } } ret =platform_device_add_resources (pdev, res, cell->num_resources);if (ret) - goto fail_of_entry; + goto fail_res_conflict; ret =platform_device_add (pdev);if (ret) - goto fail_of_entry; + goto fail_res_conflict;if (cell->pm_runtime_no_callbacks)pm_runtime_no_callbacks (&pdev->dev);
@@ -313,13 +313,15 @@ match:return 0 ; +fail_res_conflict: +if (cell->swnode) +device_remove_software_node (&pdev->dev); fail_of_entry:list_for_each_entry_safe (of_entry, tmp, &mfd_of_node_list, list)if (of_entry->dev == &pdev->dev) {list_del (&of_entry->list);kfree (of_entry); } -device_remove_software_node (&pdev->dev); fail_alias: regulator_bulk_unregister_supply_alias(&pdev->dev, cell->parent_supplies,
@@ -385,11 +387,12 @@ static int mfd_remove_devices_fn(structif (level && cell->level > *level)return 0 ; +if (cell->swnode) +device_remove_software_node (&pdev->dev); +regulator_bulk_unregister_supply_alias (dev, cell->parent_supplies, cell->num_parent_supplies); -device_remove_software_node (&pdev->dev); -platform_device_unregister (pdev);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 1838/1848 RDMA/hns: Fix some print issues
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yixing Liu <[email protected]>
commit 125073e76ba3c7cdedef0fb538d2f22be1f33f92 upstream.
Remove redundant print and fix a character type mismatch.
--- drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +- drivers/infiniband/hw/hns/hns_roce_qp.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hns/hns_roce_mr.c +1 -1
@@ -1028,7 +1028,7 @@ int hns_roce_mtr_create(struct hns_roce_ &buf_page_shift, udata ? user_addr & ~PAGE_MASK : 0);if (buf_page_cnt <1 || buf_page_shift <HNS_HW_PAGE_SHIFT ) { -ibdev_err (ibdev,"failed to init mtr cfg, count %d shift %d.\n" , +ibdev_err (ibdev,"failed to init mtr cfg, count %d shift %u.\n" , buf_page_cnt, buf_page_shift);return -EINVAL ; }
drivers/infiniband/hw/hns/hns_roce_qp.c +1 -3
@@ -628,9 +628,7 @@ static int set_kernel_sq_size(struct hnsif (!cap->max_send_wr || cap->max_send_wr > hr_dev->caps.max_wqes || cap->max_send_sge > hr_dev->caps.max_sq_sg) { -ibdev_err (ibdev, -"failed to check SQ WR or SGE num, ret = %d.\n" , - -EINVAL ); +ibdev_err (ibdev,"failed to check SQ WR or SGE num.\n" );return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 1839/1848 crypto: tcrypt - fix skcipher multi-buffer tests for 1420B blocks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horia Geantă <[email protected]>
commit 3ae88f676aa63366ffa9eebb8ae787c7e19f0c57 upstream.
Commit ad6d66bcac77e ("crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks") mentions:
Quoted 3 lines
power-of-2 block size. So let's add 1420 bytes explicitly, and round it up to the next blocksize multiple of the algo in question if it does not support 1420 byte blocks.
but misses updating skcipher multi-buffer tests.
Fix this by using the proper (rounded) input size.
--- crypto/tcrypt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
crypto/tcrypt.c +2 -3
@@ -1148,7 +1148,7 @@ static void test_mb_skcipher_speed(constif (bs >XBUFSIZE *PAGE_SIZE ) {pr_err ("template (%u) too big for buffer (%lu)\n" , - *b_size,XBUFSIZE *PAGE_SIZE ); + bs,XBUFSIZE *PAGE_SIZE ); goto out; }
@@ -1201,8 +1201,7 @@ static void test_mb_skcipher_speed(constmemset (cur->xbuf[p],0xff , k);skcipher_request_set_crypt (cur->req, cur->sg, - cur->sg, *b_size, - iv); + cur->sg, bs, iv); }if (secs) {
Greg Kroah-Hartman
maintainerPATCH 1840/1848 drm/msm/dp: stop link training after link training 2 failed
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuogee Hsieh <[email protected]>
commit 9051d629dbf7a998a40f7eac65a9512b01bc3bb8 upstream.
Each DP link training contains link training 1 followed by link training 2. There is maximum of 5 retries of DP link training before declared link training failed. It is required to stop link training at end of link training 2 if it is failed so that next link training 1 can start freshly. This patch fixes link compliance test case 4.3.1.13 (Source Device Link Training EQ Fallback Test).
Changes in v10:
-- group into one series
Changes in v11:
-- drop drm/msm/dp: dp_link_parse_sink_count() return immediately if aux read
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/dp/dp_ctrl.c +3 -0
@@ -1732,6 +1732,9 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_c/* end with failure */ break ;/* lane == 1 already */ } + +/* stop link training before start re training */ +dp_ctrl_clear_training_pattern (ctrl); } rc =dp_ctrl_reinitialize_mainlink (ctrl);
Greg Kroah-Hartman
maintainerPATCH 1841/1848 drm/msm/dp: always add fail-safe mode into connector mode list
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuogee Hsieh <[email protected]>
commit d4aca422539c441a7f3fec749287b36de37d9b6b upstream.
Some of DP link compliant test expects to return fail-safe mode if prefer detailed timing mode can not be supported by mainlink's lane and rate after link training. Therefore add fail-safe mode into connector mode list as backup mode. This patch fixes test case 4.2.2.1.
Changes in v2:
-- add Fixes text string
--- drivers/gpu/drm/msm/dp/dp_panel.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/dp/dp_panel.c +5 -0
@@ -207,6 +207,11 @@ int dp_panel_read_sink_caps(struct dp_paif (drm_add_modes_noedid (connector,640 ,480 ))drm_set_preferred_mode (connector,640 ,480 );mutex_unlock (&connector->dev->mode_config.mutex); + }else { +/* always add fail-safe mode as backup mode */ +mutex_lock (&connector->dev->mode_config.mutex); +drm_add_modes_noedid (connector,640 ,480 ); +mutex_unlock (&connector->dev->mode_config.mutex); }if (panel->aux_cfg_update_done) {
Greg Kroah-Hartman
maintainerPATCH 1842/1848 drm/msm/dp: do not stop transmitting phy test pattern during DP phy compliance test
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuogee Hsieh <[email protected]>
commit 2788b4efa60c1e03ac10a156f3fdbd3be0f9198c upstream.
At normal operation, transmit phy test pattern has to be terminated before DP controller switch to video ready state. However during phy compliance testing, transmit phy test pattern should not be terminated until end of compliance test which usually indicated by unplugged interrupt.
Only stop sending the train pattern in dp_ctrl_on_stream() if we're not doing compliance testing. We also no longer reset 'p_level' and 'v_level' within dp_ctrl_on_link() due to both 'p_level' and 'v_level' are acquired from link status at previous dpcd read and we like to use those level to start link training.
Changes in v2:
-- add more details commit text
-- correct Fixes
Changes in v3:
-- drop unnecessary braces
Patchwork: https://patchwork.freedesktop.org/patch/483564/
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +6 -8
@@ -1677,8 +1677,6 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_c ctrl->link->link_params.rate, ctrl->link->link_params.num_lanes, ctrl->dp_ctrl.pixel_rate); - ctrl->link->phy_params.p_level =0 ; - ctrl->link->phy_params.v_level =0 ; rc =dp_ctrl_enable_mainlink_clocks (ctrl);if (rc)
@@ -1802,12 +1800,6 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp } } -if (!dp_ctrl_channel_eq_ok (ctrl)) -dp_ctrl_link_retrain (ctrl); - -/* stop txing train pattern to end link training */ -dp_ctrl_clear_training_pattern (ctrl); - ret =dp_ctrl_enable_stream_clocks (ctrl);if (ret) {DRM_ERROR ("Failed to start pixel clocks. ret=%d\n" , ret);
@@ -1819,6 +1811,12 @@ int dp_ctrl_on_stream(struct dp_ctrl *dpreturn 0 ; } +if (!dp_ctrl_channel_eq_ok (ctrl)) +dp_ctrl_link_retrain (ctrl); + +/* stop txing train pattern to end link training */ +dp_ctrl_clear_training_pattern (ctrl); +/* * Set up transfer unit values and set controller state to send * video.
Greg Kroah-Hartman
maintainerPATCH 1843/1848 power: supply: ab8500: Fix error handling in ab8500_charger_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Can <[email protected]>
commit c4d33381b134da188ccd1084aef21e2b8c3c422e upstream.
The ab8500_charger_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, all ab8500_charger_component_drivers are not unregistered.
Fix by unregister ab8500_charger_component_drivers when platform_driver_register() failed.
--- drivers/power/supply/ab8500_charger.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/power/supply/ab8500_charger.c +8 -1
@@ -3740,7 +3740,14 @@ static int __init ab8500_charger_init(voif (ret)return ret; -return platform_driver_register (&ab8500_charger_driver); + ret =platform_driver_register (&ab8500_charger_driver); +if (ret) { +platform_unregister_drivers (ab8500_charger_component_drivers, +ARRAY_SIZE (ab8500_charger_component_drivers)); +return ret; + } + +return 0 ; } static void __exit ab8500_charger_exit(void)
Greg Kroah-Hartman
maintainerPATCH 1844/1848 kconfig: fix file name in warnings when loading KCONFIG_DEFCONFIG_LIST
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
commit a314f52a0210730d0d556de76bb7388e76d4597d upstream.
Most 'make *config' commands use .config as the base configuration file.
When .config does not exist, Kconfig tries to load a file listed in KCONFIG_DEFCONFIG_LIST instead.
However, since commit b75b0a819af9 ("kconfig: change defconfig_list option to environment variable"), warning messages have displayed an incorrect file name in such cases.
Below is a demonstration using Debian Trixie. While loading /boot/config-6.12.9-amd64, the warning messages incorrectly show .config as the file name.
With this commit, the correct file name is displayed in warnings.
[Before]
$ rm -f .config $ make config # # using defaults found in /boot/config-6.12.9-amd64 # .config:6804:warning: symbol value 'm' invalid for FB_BACKLIGHT .config:9895:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC
[After]
$ rm -f .config $ make config # # using defaults found in /boot/config-6.12.9-amd64 # /boot/config-6.12.9-amd64:6804:warning: symbol value 'm' invalid for FB_BACKLIGHT /boot/config-6.12.9-amd64:9895:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC
--- scripts/kconfig/confdata.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/kconfig/confdata.c +4 -2
@@ -388,10 +388,12 @@ int conf_read_simple(const char *name, i *p ='\0' ; - in =zconf_fopen (env); + name = env; + + in =zconf_fopen (name);if (in) {conf_message ("using defaults found in %s" , - env); + name); goto load; }
Greg Kroah-Hartman
maintainerPATCH 1845/1848 software node: Handle software node injection to an existing device properly
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heikki Krogerus <[email protected]>
commit 5dca69e26fe97f17d4a6cbd6872103c868577b14 upstream.
The function software_node_notify() - the function that creates and removes the symlinks between the node and the device - was called unconditionally in device_add_software_node() and device_remove_software_node(), but it needs to be called in those functions only in the special case where the node is added to a device that has already been registered.
This fixes NULL pointer dereference that happens if device_remove_software_node() is used with device that was never registered.
--- drivers/base/swnode.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/base/swnode.c +12 -4
@@ -896,7 +896,15 @@ int device_add_software_node(struct devi }set_secondary_fwnode (dev, &swnode->fwnode); -software_node_notify (dev,KOBJ_ADD ); + +/* +* If the device has been fully registered by the time this function is +* called, software_node_notify() must be called separately so that the +* symlinks get created and the reference count of the node is kept in +* balance. +*/ +if (device_is_registered (dev)) +software_node_notify (dev,KOBJ_ADD );return 0 ; }
@@ -916,7 +924,8 @@ void device_remove_software_node(structif (!swnode)return ; -software_node_notify (dev,KOBJ_REMOVE ); +if (device_is_registered (dev)) +software_node_notify (dev,KOBJ_REMOVE );set_secondary_fwnode (dev,NULL );kobject_put (&swnode->kobj); }
@@ -933,8 +942,7 @@ int software_node_notify(struct device *switch (action) {case KOBJ_ADD : - ret =sysfs_create_link_nowarn (&dev->kobj, &swnode->kobj, -"software_node" ); + ret =sysfs_create_link (&dev->kobj, &swnode->kobj,"software_node" );if (ret)break ;
Greg Kroah-Hartman
maintainerPATCH 1846/1848 drm/msm/dp: add fail safe mode outside of event_mutex context
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuogee Hsieh <[email protected]>
commit 8b2c181e3dcf7562445af6702ee94aaedcbe13c8 upstream.
There is possible circular locking dependency detected on event_mutex (see below logs). This is due to set fail safe mode is done at dp_panel_read_sink_caps() within event_mutex scope. To break this possible circular locking, this patch move setting fail safe mode out of event_mutex scope.
[ 23.958078] ======================================================
[ 23.964430] WARNING: possible circular locking dependency detected
[ 23.970777] 5.17.0-rc2-lockdep-00088-g05241de1f69e #148 Not tainted
[ 23.977219] ------------------------------------------------------
[ 23.983570] DrmThread/1574 is trying to acquire lock:
[ 23.988763] ffffff808423aab0 (&dp->event_mutex){+.+.}-{3:3}, at: msm_dp_displ ay_enable+0x58/0x164
[ 23.997895]
[ 23.997895] but task is already holding lock:
[ 24.003895] ffffff808420b280 (&kms->commit_lock[i]/1){+.+.}-{3:3}, at: lock_c rtcs+0x80/0x8c
[ 24.012495]
[ 24.012495] which lock already depends on the new lock.
[ 24.012495]
[ 24.020886]
[ 24.020886] the existing dependency chain (in reverse order) is:
[ 24.028570]
[ 24.028570] -> #5 (&kms->commit_lock[i]/1){+.+.}-{3:3}:
[ 24.035472] __mutex_lock+0xc8/0x384
[ 24.039695] mutex_lock_nested+0x54/0x74
[ 24.044272] lock_crtcs+0x80/0x8c
[ 24.048222] msm_atomic_commit_tail+0x1e8/0x3d0
[ 24.053413] commit_tail+0x7c/0xfc
[ 24.057452] drm_atomic_helper_commit+0x158/0x15c
[ 24.062826] drm_atomic_commit+0x60/0x74
[ 24.067403] drm_mode_atomic_ioctl+0x6b0/0x908
[ 24.072508] drm_ioctl_kernel+0xe8/0x168
[ 24.077086] drm_ioctl+0x320/0x370
[ 24.081123] drm_compat_ioctl+0x40/0xdc
[ 24.085602] __arm64_compat_sys_ioctl+0xe0/0x150
[ 24.090895] invoke_syscall+0x80/0x114
[ 24.095294] el0_svc_common.constprop.3+0xc4/0xf8
[ 24.100668] do_el0_svc_compat+0x2c/0x54
[ 24.105242] el0_svc_compat+0x4c/0xe4
[ 24.109548] el0t_32_sync_handler+0xc4/0xf4
[ 24.114381] el0t_32_sync+0x178
[ 24.118688]
[ 24.118688] -> #4 (&kms->commit_lock[i]){+.+.}-{3:3}:
[ 24.125408] __mutex_lock+0xc8/0x384
[ 24.129628] mutex_lock_nested+0x54/0x74
[ 24.134204] lock_crtcs+0x80/0x8c
[ 24.138155] msm_atomic_commit_tail+0x1e8/0x3d0
[ 24.143345] commit_tail+0x7c/0xfc
[ 24.147382] drm_atomic_helper_commit+0x158/0x15c
[ 24.152755] drm_atomic_commit+0x60/0x74
[ 24.157323] drm_atomic_helper_set_config+0x68/0x90
[ 24.162869] drm_mode_setcrtc+0x394/0x648
[ 24.167535] drm_ioctl_kernel+0xe8/0x168
[ 24.172102] drm_ioctl+0x320/0x370
[ 24.176135] drm_compat_ioctl+0x40/0xdc
[ 24.180621] __arm64_compat_sys_ioctl+0xe0/0x150
[ 24.185904] invoke_syscall+0x80/0x114
[ 24.190302] el0_svc_common.constprop.3+0xc4/0xf8
[ 24.195673] do_el0_svc_compat+0x2c/0x54
[ 24.200241] el0_svc_compat+0x4c/0xe4
[ 24.204544] el0t_32_sync_handler+0xc4/0xf4
[ 24.209378] el0t_32_sync+0x174/0x178
[ 24.213680] -> #3 (crtc_ww_class_mutex){+.+.}-{3:3}:
[ 24.220308] __ww_mutex_lock.constprop.20+0xe8/0x878
[ 24.225951] ww_mutex_lock+0x60/0xd0
[ 24.230166] modeset_lock+0x190/0x19c
[ 24.234467] drm_modeset_lock+0x34/0x54
[ 24.238953] drmm_mode_config_init+0x550/0x764
[ 24.244065] msm_drm_bind+0x170/0x59c
[ 24.248374] try_to_bring_up_master+0x244/0x294
[ 24.253572] __component_add+0xf4/0x14c
[ 24.258057] component_add+0x2c/0x38
[ 24.262273] dsi_dev_attach+0x2c/0x38
[ 24.266575] dsi_host_attach+0xc4/0x120
[ 24.271060] mipi_dsi_attach+0x34/0x48
[ 24.275456] devm_mipi_dsi_attach+0x28/0x68
[ 24.280298] ti_sn_bridge_probe+0x2b4/0x2dc
[ 24.285137] auxiliary_bus_probe+0x78/0x90
[ 24.289893] really_probe+0x1e4/0x3d8
[ 24.294194] __driver_probe_device+0x14c/0x164
[ 24.299298] driver_probe_device+0x54/0xf8
[ 24.304043] __device_attach_driver+0xb4/0x118
[ 24.309145] bus_for_each_drv+0xb0/0xd4
[ 24.313628] __device_attach+0xcc/0x158
[ 24.318112] device_initial_probe+0x24/0x30
[ 24.322954] bus_probe_device+0x38/0x9c
[ 24.327439] deferred_probe_work_func+0xd4/0xf0
[ 24.332628] process_one_work+0x2f0/0x498
[ 24.337289] process_scheduled_works+0x44/0x48
[ 24.342391] worker_thread+0x1e4/0x26c
[ 24.346788] kthread+0xe4/0xf4
[ 24.350470] ret_from_fork+0x10/0x20
[ 24.354683]
[ 24.354683]
[ 24.354683] -> #2 (crtc_ww_class_acquire){+.+.}-{0:0}:
[ 24.361489] drm_modeset_acquire_init+0xe4/0x138
[ 24.366777] drm_helper_probe_detect_ctx+0x44/0x114
[ 24.372327] check_connector_changed+0xbc/0x198
[ 24.377517] drm_helper_hpd_irq_event+0xcc/0x11c
[ 24.382804] dsi_hpd_worker+0x24/0x30
[ 24.387104] process_one_work+0x2f0/0x498
[ 24.391762] worker_thread+0x1d0/0x26c
[ 24.396158] kthread+0xe4/0xf4
[ 24.399840] ret_from_fork+0x10/0x20
[ 24.404053]
[ 24.404053] -> #1 (&dev->mode_config.mutex){+.+.}-{3:3}:
[ 24.411032] __mutex_lock+0xc8/0x384
[ 24.415247] mutex_lock_nested+0x54/0x74
[ 24.419819] dp_panel_read_sink_caps+0x23c/0x26c
[ 24.425108] dp_display_process_hpd_high+0x34/0xd4
[ 24.430570] dp_display_usbpd_configure_cb+0x30/0x3c
[ 24.436205] hpd_event_thread+0x2ac/0x550
[ 24.440864] kthread+0xe4/0xf4
[ 24.444544] ret_from_fork+0x10/0x20
[ 24.448757]
[ 24.448757] -> #0 (&dp->event_mutex){+.+.}-{3:3}:
[ 24.455116] __lock_acquire+0xe2c/0x10d8
[ 24.459690] lock_acquire+0x1ac/0x2d0
[ 24.463988] __mutex_lock+0xc8/0x384
[ 24.468201] mutex_lock_nested+0x54/0x74
[ 24.472773] msm_dp_display_enable+0x58/0x164
[ 24.477789] dp_bridge_enable+0x24/0x30
[ 24.482273] drm_atomic_bridge_chain_enable+0x78/0x9c
[ 24.488006] drm_atomic_helper_commit_modeset_enables+0x1bc/0x244
[ 24.494801] msm_atomic_commit_tail+0x248/0x3d0
[ 24.499992] commit_tail+0x7c/0xfc
[ 24.504031] drm_atomic_helper_commit+0x158/0x15c
[ 24.509404] drm_atomic_commit+0x60/0x74
[ 24.513976] drm_mode_atomic_ioctl+0x6b0/0x908
[ 24.519079] drm_ioctl_kernel+0xe8/0x168
[ 24.523650] drm_ioctl+0x320/0x370
[ 24.527689] drm_compat_ioctl+0x40/0xdc
[ 24.532175] __arm64_compat_sys_ioctl+0xe0/0x150
[ 24.537463] invoke_syscall+0x80/0x114
[ 24.541861] el0_svc_common.constprop.3+0xc4/0xf8
[ 24.547235] do_el0_svc_compat+0x2c/0x54
[ 24.551806] el0_svc_compat+0x4c/0xe4
[ 24.556106] el0t_32_sync_handler+0xc4/0xf4
[ 24.560948] el0t_32_sync+0x174/0x178Changes in v2:
-- add circular lockiing trace
Patchwork: https://patchwork.freedesktop.org/patch/481396/
--- drivers/gpu/drm/msm/dp/dp_display.c | 6 ++++++ drivers/gpu/drm/msm/dp/dp_panel.c | 20 ++++++++++---------- drivers/gpu/drm/msm/dp/dp_panel.h | 1 + 3 files changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +6 -0
@@ -600,6 +600,12 @@ static int dp_hpd_plug_handle(struct dp_mutex_unlock (&dp->event_mutex); +/* +* add fail safe mode outside event_mutex scope +* to avoid potiential circular lock with drm thread +*/ +dp_panel_add_fail_safe_mode (dp->dp_display.connector); +/* uevent will complete connection part */ return 0 ; };
drivers/gpu/drm/msm/dp/dp_panel.c +10 -10
@@ -152,6 +152,15 @@ static int dp_panel_update_modes(structreturn rc; } +void dp_panel_add_fail_safe_mode (struct drm_connector *connector) +{ +/* fail safe edid */ +mutex_lock (&connector->dev->mode_config.mutex); +if (drm_add_modes_noedid (connector,640 ,480 )) +drm_set_preferred_mode (connector,640 ,480 ); +mutex_unlock (&connector->dev->mode_config.mutex); +} +int dp_panel_read_sink_caps (struct dp_panel *dp_panel,struct drm_connector *connector) {
@@ -202,16 +211,7 @@ int dp_panel_read_sink_caps(struct dp_pa goto end; } -/* fail safe edid */ -mutex_lock (&connector->dev->mode_config.mutex); -if (drm_add_modes_noedid (connector,640 ,480 )) -drm_set_preferred_mode (connector,640 ,480 ); -mutex_unlock (&connector->dev->mode_config.mutex); - }else { -/* always add fail-safe mode as backup mode */ -mutex_lock (&connector->dev->mode_config.mutex); -drm_add_modes_noedid (connector,640 ,480 ); -mutex_unlock (&connector->dev->mode_config.mutex); +dp_panel_add_fail_safe_mode (connector); }if (panel->aux_cfg_update_done) {
drivers/gpu/drm/msm/dp/dp_panel.h +1 -0
@@ -59,6 +59,7 @@ int dp_panel_init_panel_info(struct dp_pint dp_panel_deinit (struct dp_panel *dp_panel);int dp_panel_timing_cfg (struct dp_panel *dp_panel);void dp_panel_dump_regs (struct dp_panel *dp_panel); +void dp_panel_add_fail_safe_mode (struct drm_connector *connector);int dp_panel_read_sink_caps (struct dp_panel *dp_panel,struct drm_connector *connector); u32 dp_panel_get_mode_bpp(struct dp_panel *dp_panel, u32 mode_max_bpp,
Greg Kroah-Hartman
maintainerPATCH 1847/1848 time/kunit: Use correct format specifier
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Gow <[email protected]>
commit e0a1284b293bdf91a68a6d1a0479ad476d0d8ec2 upstream.
'days' is a s64 (from div_s64), and so should use a %lld specifier.
This was found by extending KUnit's assertion macros to use gcc's __printf attribute.
--- kernel/time/time_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/time_test.c +1 -1
@@ -73,7 +73,7 @@ static void time64_to_tm_test_date_range days =div_s64 (secs,86400 ); -#define FAIL_MSG "%05ld/%02d/%02d (%2d) : %ld", \ +#define FAIL_MSG "%05ld/%02d/%02d (%2d) : %lld", \ year, month, mdday, yday, daysKUNIT_ASSERT_EQ_MSG (test, year -1900 , result.tm_year,FAIL_MSG );
Greg Kroah-Hartman
maintainerPATCH 1848/1848 power: supply: ab8500: Fix use-after-free in power_supply_changed()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waqar Hameed <[email protected]>
commit c4af8a98bb52825a5331ae1d0604c0ea6956ba4b upstream.
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Commit 1c1f13a006ed ("power: supply: ab8500: Move to componentized binding") introduced this issue during a refactorization. Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/ab8500_charger.c | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/power/supply/ab8500_charger.c +20 -20
@@ -3476,26 +3476,6 @@ static int ab8500_charger_probe(struct preturn ret; } -/* Request interrupts */ -for (i =0 ; i <ARRAY_SIZE (ab8500_charger_irq); i++) { - irq =platform_get_irq_byname (pdev, ab8500_charger_irq[i].name); -if (irq <0 ) -return irq; - - ret =devm_request_threaded_irq (dev, - irq,NULL , ab8500_charger_irq[i].isr, -IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , - ab8500_charger_irq[i].name, di); - -if (ret !=0 ) { -dev_err (dev,"failed to request %s IRQ %d: %d\n" - , ab8500_charger_irq[i].name, irq, ret); -return ret; - } -dev_dbg (dev,"Requested %s IRQ %d: %d\n" , - ab8500_charger_irq[i].name, irq, ret); - } -/* initialize lock */ spin_lock_init (&di->usb_state.usb_lock);mutex_init (&di->usb_ipt_crnt_lock);
@@ -3553,6 +3533,26 @@ static int ab8500_charger_probe(struct pINIT_DELAYED_WORK (&di->usb_charger_attached_work, ab8500_charger_usb_attached_work); +/* Request interrupts */ +for (i =0 ; i <ARRAY_SIZE (ab8500_charger_irq); i++) { + irq =platform_get_irq_byname (pdev, ab8500_charger_irq[i].name); +if (irq <0 ) +return irq; + + ret =devm_request_threaded_irq (dev, + irq,NULL , ab8500_charger_irq[i].isr, +IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , + ab8500_charger_irq[i].name, di); + +if (ret !=0 ) { +dev_err (dev,"failed to request %s IRQ %d: %d\n" + , ab8500_charger_irq[i].name, irq, ret); +return ret; + } +dev_dbg (dev,"Requested %s IRQ %d: %d\n" , + ab8500_charger_irq[i].name, irq, ret); + } +/* * For ABB revision 1.0 and 1.1 there is a bug in the watchdog * logic. That means we have to continuously kick the charger
Greg Kroah-Hartman wrote on Wed, Nov 18, 2026 at 03:33:58PM +0100:
Quoted 5 lines
This is the start of the stable review cycle for the 5.10.275 release. There are 1848 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.
Quoted 8 lines
Responses should be made by Fri, 20 Nov 2026 14:55:32 +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.10.275-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.
After reverting commit f3edd3784bfa ("bpf: Update the SRH state if End.B6 fails late") for the build failure reported a couple of times, Tested 12d2575b30ab ("Linux 5.10.275-rc1") on:
- arm i.MX6ULL (Armadillo 640)
- arm64 i.MX8MP (Armadillo G4)
- arm64 i.MX8ULP (Armadillo IoT A9E)
No other obvious regression in dmesg or basic tests:
Signature · 1 line
Dominique Martinet