6.18.52-rc1 review
Greg Kroah-Hartman
maintainerPATCH 1362/1518 net: tcp: block mixing readable and unreadable frags
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mina Almasry <[email protected]>
[ Upstream commit d9c56501c72fdac937e8b770f31655c46832f1a5 ]
Protect tcp_sendmsg_locked() from mistakenly mixing readable and unreadable page fragments in the same SKB.
Check that the devmem binding matches the existing SKB's readability. If a mismatch is detected, avoid collapsing and create a new segment.
--- net/ipv4/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +2 -1
@@ -1203,7 +1203,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)trace_tcp_sendmsg_locked (sk, msg, skb, size_goal); -if (copy <=0 || !tcp_skb_can_collapse_to (skb)) { +if (copy <=0 || !tcp_skb_can_collapse_to (skb) || +unlikely (skb_frags_readable (skb) != !binding)) {bool first_skb; new_segment:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1363/1518 net: sched: fix 32-bit backlog wrap in gred, bfifo and plug enqueue
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 4c660ee8c809637909f4f7eb1017f7b9401c75c4 ]
gred_enqueue(), bfifo_enqueue() and plug_enqueue() admit a packet when the current backlog plus the packet length fits within the queue limit:
sch->qstats.backlog + qdisc_pkt_len(skb) <= sch->limit (gred default VQ) gred_backlog+qdisc_pkt_len(skb) <= q->limit (gred configured VQ) sch->qstats.backlog + qdisc_pkt_len(skb) <= sch->limit (bfifo)
sch->qstats.backlog + skb->len <= q->limit (plug)
sch->qstats.backlog and q->backlog are u32, and qdisc_pkt_len()/skb->len are unsigned int, so all sums are computed in 32 bits and wrap at 2^32. Once the true backlog exceeds 4 GiB the wrapped sum becomes small and admission keeps succeeding, so the queue grows without bound and the kernel can be driven to OOM.
Promote the sums to u64 so admission stops once the true backlog exceeds the limit. The limit is u32, so the bounded queue stays below 2^32 and the stored u32 backlog never wraps.
The bug can only be reproduced as root (albeit with ridiculous setup):
attach a gred (or bfifo/plug) qdisc with a limit near 4 GiB, leaving the default VQ unconfigured (for gred), and drive >4 GiB of queued traffic (e.g. via a size table / stab to inflate qdisc_pkt_len, or sustained high-rate traffic). The u32 backlog+len sum wraps at 2^32, admission keeps succeeding, and the queue grows unboundedly to OOM.
--- net/sched/sch_fifo.c | 2 +- net/sched/sch_gred.c | 4 ++-- net/sched/sch_plug.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
net/sched/sch_fifo.c +1 -1
@@ -19,7 +19,7 @@static int bfifo_enqueue (struct sk_buff *skb,struct Qdisc *sch,struct sk_buff **to_free) { -if (likely (sch->qstats.backlog +qdisc_pkt_len (skb) <= +if (likely ((u64 )sch->qstats.backlog +qdisc_pkt_len (skb) <=READ_ONCE (sch->limit)))return qdisc_enqueue_tail (skb, sch);
net/sched/sch_gred.c +2 -2
@@ -179,7 +179,7 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc *sch,* if no default DP has been configured. This * allows for DP flows to be left untouched. */ -if (likely (sch->qstats.backlog +qdisc_pkt_len (skb) <= +if (likely ((u64 )sch->qstats.backlog +qdisc_pkt_len (skb) <= sch->limit))return qdisc_enqueue_tail (skb, sch);else
@@ -244,7 +244,7 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc *sch,break ; } -if (gred_backlog (t, q, sch) +qdisc_pkt_len (skb) <= q->limit) { +if ((u64 )gred_backlog (t, q, sch) +qdisc_pkt_len (skb) <= q->limit) { q->backlog +=qdisc_pkt_len (skb);return qdisc_enqueue_tail (skb, sch); }
net/sched/sch_plug.c +1 -1
@@ -89,7 +89,7 @@ static int plug_enqueue(struct sk_buff *skb, struct Qdisc *sch, {struct plug_sched_data *q =qdisc_priv (sch); -if (likely (sch->qstats.backlog + skb->len <= q->limit)) { +if (likely ((u64 )sch->qstats.backlog + skb->len <= q->limit)) {if (!q->unplug_indefinite) q->pkts_current_epoch++;return qdisc_enqueue_tail (skb, sch);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1364/1518 net/smc: free stashed qentry before overwrite in REQ_ADD_LINK to ADD_LINK transition
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahanta Jambigi <[email protected]>
[ Upstream commit 036322025d6e440cb75fc6fecbba9a16b271a2ae ]
When smc_llc_event_handler() transitions the local LLC flow from SMC_LLC_FLOW_REQ_ADD_LINK to SMC_LLC_FLOW_ADD_LINK on arrival of an ADD_LINK request, it calls smc_llc_flow_qentry_set() unconditionally:
if (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_REQ_ADD_LINK) {
lgr->llc_flow_lcl.type = SMC_LLC_FLOW_ADD_LINK;
smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, qentry);
...
}A CONFIRM_LINK or ADD_LINK_CONT arriving while flow->type is SMC_LLC_FLOW_REQ_ADD_LINK is stashed into flow->qentry via the SMC_LLC_CONFIRM_LINK / SMC_LLC_ADD_LINK_CONT handler (which stores into flow->qentry for any non-NONE flow type). When the subsequent ADD_LINK arrives, the REQ_ADD_LINK branch overwrites flow->qentry with the new pointer without first freeing the stashed allocation, leaking one kmalloc object.
The stashed entry has no consumer: smc_llc_wait() is only called from llc_add_link_work, which is not yet scheduled while the flow type remains REQ_ADD_LINK. No waiter is sleeping on llc_msg_waiter at this point. It is safe to unconditionally free any stashed qentry before the overwrite.
Call smc_llc_flow_qentry_del() before smc_llc_flow_qentry_set() in the REQ_ADD_LINK branch. smc_llc_flow_qentry_del() already checks flow->qentry before freeing, so the normal path where no entry is stashed is a no-op.
--- net/smc/smc_llc.c | 2 ++ 1 file changed, 2 insertions(+)
net/smc/smc_llc.c +2 -0
@@ -1945,6 +1945,8 @@ static void smc_llc_event_handler(struct smc_llc_qentry *qentry)if (lgr->llc_flow_lcl.type ==SMC_LLC_FLOW_REQ_ADD_LINK ) {/* server started add_link processing */ +/* free any qentry stashed in REQ_ADD_LINK state */ +smc_llc_flow_qentry_del (&lgr->llc_flow_lcl); lgr->llc_flow_lcl.type =SMC_LLC_FLOW_ADD_LINK ;smc_llc_flow_qentry_set (&lgr->llc_flow_lcl, qentry);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1365/1518 net/smc: free pending qentry in smc_llc_flow_stop() before memset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahanta Jambigi <[email protected]>
[ Upstream commit 5ee0ceddc7785c6dcf4a8107fef01f0414a354f4 ]
smc_llc_flow_stop() resets a flow struct with a blind memset:
spin_lock_bh(&lgr->llc_flow_lock); memset(flow, 0, sizeof(*flow)); flow->type = SMC_LLC_FLOW_NONE; spin_unlock_bh(&lgr->llc_flow_lock);
If flow->qentry is non-NULL at this point the pointer is overwritten without the allocation being freed, leaking one kmalloc object.
A late-arriving duplicate CONFIRM_LINK or ADD_LINK_CONT message can set flow->qentry after the legitimate message has been consumed by the waiter via smc_llc_flow_qentry_clr() (which NULLs the pointer but leaves flow->type non-zero) but before the flow completes and smc_llc_flow_stop() runs. In that window the duplicate is stashed into flow->qentry, and then lost when smc_llc_flow_stop() zeros the struct.
Call smc_llc_flow_qentry_del() inside the lock before the memset. smc_llc_flow_qentry_del() already checks flow->qentry before freeing, so the normal case where no entry is pending is a no-op.
--- net/smc/smc_llc.c | 1 + 1 file changed, 1 insertion(+)
net/smc/smc_llc.c +1 -0
@@ -341,6 +341,7 @@ int smc_llc_flow_initiate(struct smc_link_group *lgr,void smc_llc_flow_stop (struct smc_link_group *lgr,struct smc_llc_flow *flow) {spin_lock_bh (&lgr->llc_flow_lock); +smc_llc_flow_qentry_del (flow);memset (flow,0 ,sizeof (*flow)); flow->type =SMC_LLC_FLOW_NONE ;spin_unlock_bh (&lgr->llc_flow_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1366/1518 NFSv4.2: fix LAYOUTSTATS send buffer exhaustion
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit c75ef2137e749f2673f0617cfdaae53b2bb7195a ]
encode_layoutstats_maxsz budgets XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE), i.e. 256 bytes, for the layoutupdate4 body written by the layout driver. The flexfiles record can exceed that.
ff_layout_encode_ff_layoutupdate() emits, per data server, a netaddr4, an nfs_fh4, two ff_io_latency4, an nfstime4 and a bool. A data server whose filehandle is NFS_MAXFHSIZE bytes long already accounts for 132 of those bytes, and the two ff_io_latency4 at 64 bytes each, the nfstime4 and the bool add a further 144, so the body passes 256 bytes before the netaddr4 is encoded at all. encode_layoutstats() additionally writes the deviceid4 and the layoutupdate4 lou_type word, neither of which the macro accounts for.
The filehandle and the address are both chosen by the server, through LAYOUTGET and GETDEVICEINFO, so it can drive the encoder past the end of the send buffer. xdr_reserve_space() returns NULL once that happens, and the two ff_layout_encode_io_latency() calls run with dss_info->mirror->lock held, so a NULL return there leaves the lock permanently held.
Raise PNFS_LAYOUTSTATS_MAXSIZE to 384 so that the record fits inside the reservation.
--- include/linux/nfs_xdr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/nfs_xdr.h +1 -1
@@ -351,7 +351,7 @@ struct nfs4_layoutreturn {struct nfs4_xdr_opaque_data ld_private; }; -#define PNFS_LAYOUTSTATS_MAXSIZE 256 +#define PNFS_LAYOUTSTATS_MAXSIZE 384struct nfs42_layoutstat_args ;struct nfs42_layoutstat_devinfo ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1367/1518 NFSv4/pnfs: key the data server cache on the NFS version
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 13c23c5cb977f66390795437fd3837887ce1fd75 ]
nfs4_pnfs_ds_add() keys the per-net data server cache on the multipath address set alone, and struct nfs4_pnfs_ds records no version. That suffices for the files layout driver, which always connects with version 4, but flexfiles takes its version tuple from GETDEVICEINFO per device, and one address can legitimately serve both NFSv3 and NFSv4.
Two deviceids on one address with different ds_versions[0].version therefore share a single nfs4_pnfs_ds, and whichever mirror connects first pins ds_clp to its own version. The other one is handed that client anyway, so it selects rpc_call_ops for a version the connection does not speak, and the mismatched sequence-slot handling dereferences NULL.
Add the version to the cache key so the two cannot alias, giving each version its own nfs4_pnfs_ds and connection while both mirrors stay usable. Only the major version is compared, since that is what selects rpc_call_ops and rpc_ops; v4.0 and v4.1 keep sharing a client. The files layout driver passes the 4 it already hardcodes at connect time.
--- fs/nfs/filelayout/filelayoutdev.c | 3 ++- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 3 ++- fs/nfs/pnfs.h | 3 ++- fs/nfs/pnfs_nfs.c | 14 +++++++++----- 4 files changed, 15 insertions(+), 8 deletions(-)
fs/nfs/filelayout/filelayoutdev.c +2 -1
@@ -170,7 +170,8 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_free_deviceid; } - dsaddr->ds_list[i] =nfs4_pnfs_ds_add (net, &dsaddrs, gfp_flags); + dsaddr->ds_list[i] =nfs4_pnfs_ds_add (net, &dsaddrs,4 , + gfp_flags);if (!dsaddr->ds_list[i]) goto out_err_drain_dsaddrs;trace_fl_getdevinfo (server, &pdev->dev_id, dsaddr->ds_list[i]->ds_remotestr);
fs/nfs/flexfilelayout/flexfilelayoutdev.c +2 -1
@@ -149,7 +149,8 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, new_ds->ds_versions = ds_versions; new_ds->ds_versions_cnt = version_count; - new_ds->ds =nfs4_pnfs_ds_add (net, &dsaddrs, gfp_flags); + new_ds->ds =nfs4_pnfs_ds_add (net, &dsaddrs, ds_versions[0 ].version, + gfp_flags);if (!new_ds->ds) goto out_err_drain_dsaddrs;
fs/nfs/pnfs.h +2 -1
@@ -63,6 +63,7 @@ struct nfs4_pnfs_ds {const struct net *ds_net;struct nfs_client *ds_clp;refcount_t ds_count; +u32 ds_version;/* cache key, with ds_addrs */ unsigned long ds_state;#define NFS4DS_CONNECTING 0/* ds is establishing connection */ };
@@ -417,7 +418,7 @@ void pnfs_generic_write_commit_done(struct rpc_task *task, void *data);void nfs4_pnfs_ds_put (struct nfs4_pnfs_ds *ds);struct nfs4_pnfs_ds *nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs, -gfp_t gfp_flags); +u32 version,gfp_t gfp_flags);void nfs4_pnfs_v3_ds_connect_unload (void ); int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, struct nfs4_deviceid_node *devid, unsigned int timeo,
fs/nfs/pnfs_nfs.c +9 -5
@@ -603,15 +603,17 @@ _same_data_server_addrs_locked(const struct list_head *dsaddrs1, }/* -* Lookup DS by addresses. nfs4_ds_cache_lock is held +* Lookup DS by addresses and NFS version. nfs4_ds_cache_lock is held */ static struct nfs4_pnfs_ds * -_data_server_lookup_locked (const struct nfs_net *nn,const struct list_head *dsaddrs) +_data_server_lookup_locked (const struct nfs_net *nn, +const struct list_head *dsaddrs,u32 version) {struct nfs4_pnfs_ds *ds;list_for_each_entry (ds, &nn->nfs4_data_server_cache, ds_node) -if (_same_data_server_addrs_locked (&ds->ds_addrs, dsaddrs)) +if (ds->ds_version == version && +_same_data_server_addrs_locked (&ds->ds_addrs, dsaddrs))return ds;return NULL ; }
@@ -719,7 +721,8 @@ nfs4_pnfs_remotestr(struct list_head *dsaddrs, gfp_t gfp_flags)* uncached and return cached struct nfs4_pnfs_ds. */ struct nfs4_pnfs_ds * -nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs,gfp_t gfp_flags) +nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs,u32 version, +gfp_t gfp_flags) {struct nfs_net *nn =net_generic (net, nfs_net_id);struct nfs4_pnfs_ds *tmp_ds, *ds =NULL ;
@@ -738,7 +741,7 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_fla remotestr =nfs4_pnfs_remotestr (dsaddrs, gfp_flags);spin_lock (&nn->nfs4_data_server_lock); - tmp_ds =_data_server_lookup_locked (nn, dsaddrs); + tmp_ds =_data_server_lookup_locked (nn, dsaddrs, version);if (tmp_ds ==NULL ) {INIT_LIST_HEAD (&ds->ds_addrs);list_splice_init (dsaddrs, &ds->ds_addrs);
@@ -747,6 +750,7 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_flaINIT_LIST_HEAD (&ds->ds_node); ds->ds_net = net; ds->ds_clp =NULL ; + ds->ds_version = version;list_add (&ds->ds_node, &nn->nfs4_data_server_cache);dprintk ("%s add new data server %s\n" , __func__, ds->ds_remotestr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1368/1518 rtc: pcf85363: Add error checking to regmap calls in probe()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmo Chou <[email protected]>
[ Upstream commit 78acddfde75177a27000f076e3e828743e38877e ]
The probe() function ignores errors returned by regmap operations. If an I2C transport error occurs (e.g., -ENXIO), the driver continues probing and may register a non-functional RTC device.
Propagate errors from all unchecked regmap calls in probe() using dev_err_probe().
--- drivers/rtc/rtc-pcf85363.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/rtc/rtc-pcf85363.c +12 -5
@@ -426,8 +426,8 @@ static int pcf85363_probe(struct i2c_client *client) err =pcf85363_load_capacitance (pcf85363, client->dev.of_node);if (err <0 ) -dev_warn (&client->dev,"failed to set xtal load capacitance: %d" , - err); +return dev_err_probe (&client->dev, err, +"failed to set xtal load capacitance\n" ); pcf85363->rtc->ops = &rtc_ops; pcf85363->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ;
@@ -436,9 +436,16 @@ static int pcf85363_probe(struct i2c_client *client) wakeup_source =device_property_read_bool (&client->dev,"wakeup-source" );if (client->irq >0 || wakeup_source) { -regmap_write (pcf85363->regmap,CTRL_FLAGS ,0 ); -regmap_update_bits (pcf85363->regmap,CTRL_PIN_IO , -PIN_IO_INTAPM ,PIN_IO_INTA_OUT ); + err =regmap_write (pcf85363->regmap,CTRL_FLAGS ,0 ); +if (err) +return dev_err_probe (&client->dev, err, +"failed to clear flags\n" ); + + err =regmap_update_bits (pcf85363->regmap,CTRL_PIN_IO , +PIN_IO_INTAPM ,PIN_IO_INTA_OUT ); +if (err) +return dev_err_probe (&client->dev, err, +"failed to set interrupt pin mode\n" ); }if (client->irq >0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1369/1518 bnxt_en: Fix call to hardware monitoring event handler
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 622d698df4239fef3e0eb51fe59f4198f957f28a ]
The first parameter of hwmon_notify_event() is supposed to be the hardware monitoring device. The bnxt driver calls it with the platform device as first parameter instead. This API break results in undefined behavior and may result in a crash.
Pass the hardware monitoring device as parameter instead to fix the problem.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c +1 -1
@@ -40,7 +40,7 @@ void bnxt_hwmon_notify_event(struct bnxt *bp)return ; } -hwmon_notify_event (&bp->pdev->dev, hwmon_temp, attr,0 ); +hwmon_notify_event (bp->hwmon_dev, hwmon_temp, attr,0 ); }static int bnxt_hwrm_temp_query (struct bnxt *bp,u8 *temp)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1370/1518 bnxt_en: Gate TPH enablement behind BNXT_SUPPORTS_QUEUE_API check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Walsh <[email protected]>
[ Upstream commit a70859cf31214e546cb73da7142f190138dae9ab ]
In bnxt_request_irq(), pcie_enable_tph() is called unconditionally to enable PCIe TPH when setting up interrupts.
If the NIC hardware or firmware capabilities do not support queue ops, attempting to enable TPH during bnxt_request_irq() is unnecessary.
As a result a flood of "RX queue restart failed: err=-95" messages is seen upon boot.
Older NICs (pre-Thor / BCM57414) do not support TPH or queue management. TPH requires queue management to restart the queue. NICs that support queue management (with updated FW) all support TPH.
Gate the call to pcie_enable_tph() and setting of bp->tph_mode behind BNXT_SUPPORTS_QUEUE_API(bp) to ensure TPH is only initialized on devices capable of supporting queue ops. This prevents a guaranteed -EOPNOTSUPP error from occurring due to NULL operations.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -3
@@ -11772,9 +11772,11 @@ static int bnxt_request_irq(struct bnxt *bp)#endif /* Enable TPH support as part of IRQ request */ - rc =pcie_enable_tph (bp->pdev,PCI_TPH_ST_IV_MODE ); -if (!rc) - bp->tph_mode =PCI_TPH_ST_IV_MODE ; +if (BNXT_SUPPORTS_QUEUE_API (bp)) { + rc =pcie_enable_tph (bp->pdev,PCI_TPH_ST_IV_MODE ); +if (!rc) + bp->tph_mode =PCI_TPH_ST_IV_MODE ; + }for (i =0 , j =0 ; i < bp->cp_nr_rings; i++) {int map_idx =bnxt_cp_num_to_irq_num (bp, i);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1371/1518 ptp: netc: fix period truncation and potential divide-by-zero in PEROUT
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Fang <[email protected]>
[ Upstream commit 777dbc9914b2f003f1d44af80c7a4a395c5961b2 ]
The max_period bound in net_timer_enable_perout() was computed as:
max_period = (u64)NETC_TMR_DEFAULT_FIPER + integral_period;
which exceeds U32_MAX when integral_period > 0 (e.g. 0x100000002 for the default 333333333 Hz clock). A period_ns that passes this check but exceeds U32_MAX is then silently truncated when stored into the u32 struct netc_pp::period field.
A truncated value of zero can reach netc_timer_set_perout_alarm(), where the local u32 period variable would also be 0, causing a divide-by-zero in roundup_u64(delta, period) whenever the stime < min_time branch is taken (which always happens for a start time of {0, 0}).
Additionally, netc_timer_enable_periodic_pulse() and netc_timer_enable_fiper() both compute:
fiper = pp->period - integral_period;
A zero pp->period results in an unsigned wraparound to 0xFFFFFFFD, mis-programming the FIPER hardware register.
Fix all three issues by capping max_period at NETC_TMR_DEFAULT_FIPER (0xFFFFFFFF). This ensures that any period_ns passing the range check fits in a u32 without truncation, so the stored value is always valid and non-zero. The accepted range is reduced by integral_period ns (typically only a few nanoseconds), which is negligible in practice.
--- drivers/ptp/ptp_netc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/ptp/ptp_netc.c +5 -5
@@ -440,7 +440,7 @@ static int net_timer_enable_perout(struct netc_timer *priv, }if (on) { -u64 period_ns, gclk_period, max_period, min_period; +u64 period_ns, gclk_period, min_period;struct timespec64 period, stime;u32 integral_period;int alarm_id;
@@ -450,12 +450,12 @@ static int net_timer_enable_perout(struct netc_timer *priv, period_ns =timespec64_to_ns (&period); integral_period =netc_timer_get_integral_period (priv); - max_period = (u64 )NETC_TMR_DEFAULT_FIPER + integral_period; gclk_period =netc_timer_get_gclk_period (priv); min_period = gclk_period *4 + integral_period; -if (period_ns > max_period || period_ns < min_period) { -dev_err (dev,"The period range is %llu ~ %llu\n" , - min_period, max_period); +if (period_ns >NETC_TMR_DEFAULT_FIPER || + period_ns < min_period) { +dev_err (dev,"The period range is %llu ~ %lu\n" , + min_period,NETC_TMR_DEFAULT_FIPER ); err = -EINVAL ; goto unlock_spinlock; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1372/1518 net: txgbe: support RX desc merge mode
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit a71e367773482a78566abd862dfee9cc3bb9332e ]
RX descriptor merge mode is supported on AML devices. When it is enabled, the hardware process the RX descriptors in batches.
Stable-dep-of: 7bf29145d7a9 ("net: txgbe: fix MISC interrupt unmasking in non-MSI-X mode and device shutdown")
--- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 10 ++++++++++ drivers/net/ethernet/wangxun/libwx/wx_type.h | 7 +++++++ drivers/net/ethernet/wangxun/libwx/wx_vf.h | 1 + drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c | 3 +++ drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 1 + drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c | 11 +++++++++++ 6 files changed, 33 insertions(+)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +10 -0
@@ -1935,6 +1935,10 @@ static void wx_configure_rx_ring(struct wx *wx, rxdctl |= (ring->count /128 ) <<WX_PX_RR_CFG_RR_SIZE_SHIFT ; rxdctl |=0x1 <<WX_PX_RR_CFG_RR_THER_SHIFT ; + +if (test_bit (WX_FLAG_RX_MERGE_ENABLED , wx->flags)) + rxdctl |=WX_PX_RR_CFG_DESC_MERGE ; +wr32 (wx,WX_PX_RR_CFG (reg_idx), rxdctl);/* reset head and tail pointers */
@@ -2190,6 +2194,12 @@ void wx_configure_rx(struct wx *wx)/* set_rx_buffer_len must be called before ring initialization */ wx_set_rx_buffer_len (wx); +if (test_bit (WX_FLAG_RX_MERGE_ENABLED , wx->flags)) { +wr32 (wx,WX_RDM_DCACHE_CTL ,WX_RDM_DCACHE_CTL_EN ); +wr32m (wx,WX_RDM_RSC_CTL , +WX_RDM_RSC_CTL_FREE_CTL |WX_RDM_RSC_CTL_FREE_CNT_DIS , +WX_RDM_RSC_CTL_FREE_CTL ); + }/* Setup the HW Rx Head and Tail Descriptor Pointers and * the Base and Length of the Rx Descriptor Ring */
drivers/net/ethernet/wangxun/libwx/wx_type.h +7 -0
@@ -83,8 +83,13 @@/*********************** Receive DMA registers **************************/ #define WX_RDM_VF_RE (_i) (0x12004 + ((_i) * 4)) +#define WX_RDM_RSC_CTL 0x1200C +#define WX_RDM_RSC_CTL_FREE_CNT_DIS BIT(8) +#define WX_RDM_RSC_CTL_FREE_CTL BIT(7)#define WX_RDM_PF_QDE (_i) (0x12080 + ((_i) * 4))#define WX_RDM_VFRE_CLR (_i) (0x120A0 + ((_i) * 4)) +#define WX_RDM_DCACHE_CTL 0x120A8 +#define WX_RDM_DCACHE_CTL_EN BIT(0)#define WX_RDM_DRP_PKT 0x12500#define WX_RDM_PKT_CNT 0x12504#define WX_RDM_BYTE_CNT_LSB 0x12508
@@ -449,6 +454,7 @@ enum WX_MSCA_CMD_value {#define WX_PX_RR_CFG_VLAN BIT(31)#define WX_PX_RR_CFG_DROP_EN BIT(30)#define WX_PX_RR_CFG_SPLIT_MODE BIT(26) +#define WX_PX_RR_CFG_DESC_MERGE BIT(19)#define WX_PX_RR_CFG_RR_THER_SHIFT 16#define WX_PX_RR_CFG_RR_HDR_SZ GENMASK(15, 12)#define WX_PX_RR_CFG_RR_BUF_SZ GENMASK(11, 8)
@@ -1233,6 +1239,7 @@ enum wx_pf_flags {WX_FLAG_NEED_MODULE_RESET ,WX_FLAG_NEED_UPDATE_LINK ,WX_FLAG_NEED_DO_RESET , +WX_FLAG_RX_MERGE_ENABLED , WX_PF_FLAGS_NBITS /* must be last */ };
drivers/net/ethernet/wangxun/libwx/wx_vf.h +1 -0
@@ -74,6 +74,7 @@#define WX_VXRXDCTL_BUFSZ (f) FIELD_PREP(GENMASK(11, 8), f)#define WX_VXRXDCTL_HDRSZ_MASK GENMASK(15, 12)#define WX_VXRXDCTL_HDRSZ (f) FIELD_PREP(GENMASK(15, 12), f) +#define WX_VXRXDCTL_DESC_MERGE BIT(19)#define WX_VXRXDCTL_RSCMAX_MASK GENMASK(24, 23)#define WX_VXRXDCTL_RSCMAX (f) FIELD_PREP(GENMASK(24, 23), f)#define WX_VXRXDCTL_RSCEN BIT(29)
drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c +3 -0
@@ -272,6 +272,9 @@ void wx_configure_rx_ring_vf(struct wx *wx, struct wx_ring *ring) rxdctl |=WX_VXRXDCTL_RSCMAX (0 ); rxdctl |=WX_VXRXDCTL_RSCEN ; +if (test_bit (WX_FLAG_RX_MERGE_ENABLED , wx->flags)) + rxdctl |=WX_VXRXDCTL_DESC_MERGE ; +wr32 (wx,WX_VXRXDCTL (reg_idx), rxdctl);/* pf/vf reuse */
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +1 -0
@@ -423,6 +423,7 @@ static int txgbe_sw_init(struct wx *wx)break ;case wx_mac_aml:case wx_mac_aml40: +set_bit (WX_FLAG_RX_MERGE_ENABLED , wx->flags);set_bit (WX_FLAG_SWFW_RING , wx->flags); wx->swfw_index =0 ;break ;
drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c +11 -0
@@ -157,6 +157,17 @@ static int txgbevf_sw_init(struct wx *wx) wx->set_num_queues = txgbevf_set_num_queues; +switch (wx->mac.type) { +case wx_mac_sp: +break ; +case wx_mac_aml: +case wx_mac_aml40: +set_bit (WX_FLAG_RX_MERGE_ENABLED , wx->flags); +break ; +default : +break ; + } +return 0 ; err_reset_hw:kfree (wx->vfinfo);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1373/1518 net: txgbe: support RSC offload
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit eaed17770637af6d35d9b5465d91f1256a5eaacf ]
Support to enable and disable RSC for txgbe devices.
Stable-dep-of: 7bf29145d7a9 ("net: txgbe: fix MISC interrupt unmasking in non-MSI-X mode and device shutdown")
--- .../net/ethernet/wangxun/libwx/wx_ethtool.c | 61 ++++++++++++- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 50 ++++++++++- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 90 +++++++++++++++++-- drivers/net/ethernet/wangxun/libwx/wx_sriov.c | 4 + drivers/net/ethernet/wangxun/libwx/wx_type.h | 33 +++++-- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 3 + 6 files changed, 224 insertions(+), 17 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +59 -2
@@ -51,6 +51,11 @@ static const struct wx_stats wx_gstrings_fdir_stats[] = { WX_STAT("fdir_miss", stats.fdirmiss), }; +static const struct wx_stats wx_gstrings_rsc_stats[] = { +WX_STAT ("rsc_aggregated" , rsc_count), +WX_STAT ("rsc_flushed" , rsc_flush), +}; +/* drivers allocates num_tx_queues and num_rx_queues symmetrically so * we set the num_rx_queues to evaluate to num_tx_queues. This is * used because we do not have a good way to get the max number of
@@ -64,16 +69,21 @@ static const struct wx_stats wx_gstrings_fdir_stats[] = { (sizeof(struct wx_queue_stats) / sizeof(u64)))#define WX_GLOBAL_STATS_LEN ARRAY_SIZE(wx_gstrings_stats)#define WX_FDIR_STATS_LEN ARRAY_SIZE(wx_gstrings_fdir_stats) +#define WX_RSC_STATS_LEN ARRAY_SIZE(wx_gstrings_rsc_stats)#define WX_STATS_LEN (WX_GLOBAL_STATS_LEN + WX_QUEUE_STATS_LEN)int wx_get_sset_count (struct net_device *netdev,int sset) {struct wx *wx =netdev_priv (netdev); +int len =WX_STATS_LEN ;switch (sset) {case ETH_SS_STATS : -return (test_bit (WX_FLAG_FDIR_CAPABLE , wx->flags)) ? -WX_STATS_LEN +WX_FDIR_STATS_LEN :WX_STATS_LEN ; +if (test_bit (WX_FLAG_FDIR_CAPABLE , wx->flags)) + len +=WX_FDIR_STATS_LEN ; +if (test_bit (WX_FLAG_RSC_CAPABLE , wx->flags)) + len +=WX_RSC_STATS_LEN ; +return len;default :return -EOPNOTSUPP ; }
@@ -94,6 +104,10 @@ void wx_get_strings(struct net_device *netdev, u32 stringset, u8 *data)for (i =0 ; i <WX_FDIR_STATS_LEN ; i++)ethtool_puts (&p, wx_gstrings_fdir_stats[i].stat_string); } +if (test_bit (WX_FLAG_RSC_CAPABLE , wx->flags)) { +for (i =0 ; i <WX_RSC_STATS_LEN ; i++) +ethtool_puts (&p, wx_gstrings_rsc_stats[i].stat_string); + }for (i =0 ; i < netdev->num_tx_queues; i++) {ethtool_sprintf (&p,"tx_queue_%u_packets" , i);ethtool_sprintf (&p,"tx_queue_%u_bytes" , i);
@@ -131,6 +145,13 @@ void wx_get_ethtool_stats(struct net_device *netdev, } } +if (test_bit (WX_FLAG_RSC_CAPABLE , wx->flags)) { +for (k =0 ; k <WX_RSC_STATS_LEN ; k++) { + p = (char *)wx + wx_gstrings_rsc_stats[k].stat_offset; + data[i++] = *(u64 *)p; + } + } +for (j =0 ; j < netdev->num_tx_queues; j++) { ring = wx->tx_ring[j];if (!ring) {
@@ -322,6 +343,40 @@ int wx_get_coalesce(struct net_device *netdev, }EXPORT_SYMBOL (wx_get_coalesce); +static void wx_update_rsc (struct wx *wx) +{ +struct net_device *netdev = wx->netdev; +bool need_reset = false; + +/* nothing to do if LRO or RSC are not enabled */ +if (!test_bit (WX_FLAG_RSC_CAPABLE , wx->flags) || + !(netdev->features &NETIF_F_LRO )) +return ; + +/* check the feature flag value and enable RSC if necessary */ +if (wx->rx_itr_setting ==1 || + wx->rx_itr_setting >WX_MIN_RSC_ITR ) { +if (!test_bit (WX_FLAG_RSC_ENABLED , wx->flags)) { +set_bit (WX_FLAG_RSC_ENABLED , wx->flags); +dev_info (&wx->pdev->dev, +"rx-usecs value high enough to re-enable RSC\n" ); + + need_reset = true; + } +/* if interrupt rate is too high then disable RSC */ + }else if (test_bit (WX_FLAG_RSC_ENABLED , wx->flags)) { +clear_bit (WX_FLAG_RSC_ENABLED , wx->flags); +dev_info (&wx->pdev->dev, +"rx-usecs set too low, disabling RSC\n" ); + + need_reset = true; + } + +/* reset the device to apply the new RSC setting */ +if (need_reset && wx->do_reset) + wx->do_reset (netdev); +} + int wx_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec, struct kernel_ethtool_coalesce *kernel_coal,
@@ -414,6 +469,8 @@ int wx_set_coalesce(struct net_device *netdev,wx_write_eitr (q_vector); } +wx_update_rsc (wx); +return 0 ; }EXPORT_SYMBOL (wx_set_coalesce);
drivers/net/ethernet/wangxun/libwx/wx_hw.c +48 -2
91 lines not on this page · raw message
drivers/net/ethernet/wangxun/libwx/wx_lib.c +83 -7
161 lines not on this page · raw message
drivers/net/ethernet/wangxun/libwx/wx_sriov.c +4 -0
@@ -122,6 +122,10 @@ static int __wx_enable_sriov(struct wx *wx, u8 num_vfs)WX_CFG_PORT_CTL_NUM_VT_MASK , value); +/* Disable RSC when in SR-IOV mode */ +clear_bit (WX_FLAG_RSC_CAPABLE , wx->flags); +clear_bit (WX_FLAG_RSC_ENABLED , wx->flags); +return ret; }
drivers/net/ethernet/wangxun/libwx/wx_type.h +27 -6
@@ -426,6 +426,7 @@ enum WX_MSCA_CMD_value {#define WX_7K_ITR 595#define WX_12K_ITR 336#define WX_20K_ITR 200 +#define WX_MIN_RSC_ITR 24#define WX_SP_MAX_EITR 0x00000FF8U#define WX_AML_MAX_EITR 0x00000FFFU#define WX_EM_MAX_EITR 0x00007FFCU
@@ -453,7 +454,9 @@ enum WX_MSCA_CMD_value {/* PX_RR_CFG bit definitions */ #define WX_PX_RR_CFG_VLAN BIT(31)#define WX_PX_RR_CFG_DROP_EN BIT(30) +#define WX_PX_RR_CFG_RSC BIT(29)#define WX_PX_RR_CFG_SPLIT_MODE BIT(26) +#define WX_PX_RR_CFG_MAX_RSCBUF_16 FIELD_PREP(GENMASK(24, 23), 3)#define WX_PX_RR_CFG_DESC_MERGE BIT(19)#define WX_PX_RR_CFG_RR_THER_SHIFT 16#define WX_PX_RR_CFG_RR_HDR_SZ GENMASK(15, 12)
@@ -551,14 +554,9 @@ enum WX_MSCA_CMD_value {/* Supported Rx Buffer Sizes */ #define WX_RXBUFFER_256 256/* Used for skb receive header */ #define WX_RXBUFFER_2K 2048 +#define WX_RXBUFFER_3K 3072#define WX_MAX_RXBUFFER 16384/* largest size for single descriptor */ -#if MAX_SKB_FRAGS <8 -#define WX_RX_BUFSZ ALIGN(WX_MAX_RXBUFFER / MAX_SKB_FRAGS, 1024) -#else -#define WX_RX_BUFSZ WX_RXBUFFER_2K -#endif -#define WX_RX_BUFFER_WRITE 16/* Must be power of 2 */ #define WX_MAX_DATA_PER_TXD BIT(14)
@@ -650,6 +648,12 @@ enum wx_l2_ptypes {#define WX_RXD_PKTTYPE (_rxd) \ ((le32_to_cpu((_rxd)->wb.lower.lo_dword.data) >> 9) & 0xFF) + +#define WX_RXD_RSCCNT_MASK GENMASK(20, 17) +#define WX_RXD_RSCCNT_SHIFT 17 +#define WX_RXD_NEXTP_MASK GENMASK(19, 4) +#define WX_RXD_NEXTP_SHIFT 4 +/*********************** Transmit Descriptor Config Masks ****************/ #define WX_TXD_STAT_DD BIT(0)/* Descriptor Done */ #define WX_TXD_DTYP_DATA 0/* Adv Data Descriptor */
@@ -1036,6 +1040,8 @@ struct wx_rx_queue_stats {u64 csum_good_cnt;u64 csum_err;u64 alloc_rx_buff_failed; +u64 rsc_count; +u64 rsc_flush; };/* iterator for handling rings in ring container */
@@ -1076,6 +1082,7 @@ struct wx_ring {*/ u16 next_to_use;u16 next_to_clean; +u16 rx_buf_len; union { u16 next_to_alloc; struct {
@@ -1232,6 +1239,7 @@ enum wx_pf_flags {WX_FLAG_FDIR_HASH ,WX_FLAG_FDIR_PERFECT ,WX_FLAG_RSC_CAPABLE , +WX_FLAG_RSC_ENABLED ,WX_FLAG_RX_HWTSTAMP_ENABLED ,WX_FLAG_RX_HWTSTAMP_IN_REGISTER , WX_FLAG_PTP_PPS_ENABLED,
@@ -1346,6 +1354,8 @@ struct wx {u64 hw_csum_rx_good;u64 hw_csum_rx_error;u64 alloc_rx_buff_failed; +u64 rsc_count; +u64 rsc_flush;unsigned int num_vfs;struct vf_data_storage *vfinfo;struct vf_macvlans vf_mvs;
@@ -1477,4 +1487,15 @@ static inline int wx_set_state_reset(struct wx *wx) return 0; } +static inline unsigned int wx_rx_pg_order (struct wx_ring *ring) +{ +#if (PAGE_SIZE <8192 ) +if (ring->rx_buf_len ==WX_RXBUFFER_3K ) +return 1 ; +#endif +return 0 ; +} + +#define wx_rx_pg_size (_ring) (PAGE_SIZE << wx_rx_pg_order(_ring)) +#endif /* _WX_TYPE_H_ */
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +3 -0
@@ -398,6 +398,7 @@ static int txgbe_sw_init(struct wx *wx) wx->configure_fdir = txgbe_configure_fdir;set_bit (WX_FLAG_RSC_CAPABLE , wx->flags); +set_bit (WX_FLAG_RSC_ENABLED , wx->flags);set_bit (WX_FLAG_MULTI_64_FUNC , wx->flags);/* enable itr by default in dynamic mode */
@@ -802,6 +803,8 @@ static int txgbe_probe(struct pci_dev *pdev, netdev->features |=NETIF_F_HIGHDMA ; netdev->hw_features |=NETIF_F_GRO ; netdev->features |=NETIF_F_GRO ; + netdev->hw_features |=NETIF_F_LRO ; + netdev->features |=NETIF_F_LRO ; netdev->features |=NETIF_F_RX_UDP_TUNNEL_PORT ; netdev->priv_flags |=IFF_UNICAST_FLT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1374/1518 net: wangxun: replace busy-wait reset flag with kernel mutex
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit d48df7e7c3fb456d2dc907707a124dab8462eb19 ]
Replace the busy-wait loop using test_and_set_bit(WX_STATE_RESETTING) with a proper per-device mutex to serialize reset operations.
The reset flag is reserved for other code paths (like watchdog), which need tocheck if a reset is in process.
Stable-dep-of: 7bf29145d7a9 ("net: txgbe: fix MISC interrupt unmasking in non-MSI-X mode and device shutdown")
--- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 1 + drivers/net/ethernet/wangxun/libwx/wx_type.h | 16 +--------------- .../net/ethernet/wangxun/libwx/wx_vf_common.c | 6 ++++-- drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 6 +++--- .../net/ethernet/wangxun/txgbe/txgbe_ethtool.c | 6 +++--- drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 10 +++------- 6 files changed, 15 insertions(+), 30 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +1 -0
@@ -2508,6 +2508,7 @@ int wx_sw_init(struct wx *wx)return -ENOMEM ; } +mutex_init (&wx->reset_lock);bitmap_zero (wx->state,WX_STATE_NBITS );bitmap_zero (wx->flags,WX_PF_FLAGS_NBITS ); wx->misc_irq_domain = false;
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -15
@@ -1394,6 +1394,7 @@ struct wx {struct timer_list service_timer;struct work_struct service_task; +struct mutex reset_lock;/* mutex for reset */ };#define WX_INTR_ALL (~0ULL)
@@ -1472,21 +1473,6 @@ static inline struct wx *phylink_to_wx(struct phylink_config *config) return container_of(config, struct wx, phylink_config); } -static inline int wx_set_state_reset (struct wx *wx) -{ -u8 timeout =50 ; - -while (test_and_set_bit (WX_STATE_RESETTING , wx->state)) { - timeout--; -if (!timeout) -return -EBUSY ; - -usleep_range (1000 ,2000 ); - } - -return 0 ; -} -static inline unsigned int wx_rx_pg_order (struct wx_ring *ring) {#if (PAGE_SIZE <8192 )
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c +4 -2
@@ -339,14 +339,16 @@ static void wxvf_down(struct wx *wx)static void wxvf_reinit_locked (struct wx *wx) { -while (test_and_set_bit (WX_STATE_RESETTING , wx->state)) -usleep_range (1000 ,2000 ); +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state); +wxvf_down (wx);wx_free_irq (wx);wx_configure_vf (wx);wx_request_msix_irqs_vf (wx);wxvf_up_complete (wx);clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock); }static void wxvf_reset_subtask (struct wx *wx)
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +3 -3
@@ -64,9 +64,8 @@ static int ngbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count)return 0 ; - err =wx_set_state_reset (wx); -if (err) -return err; +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state);if (!netif_running (wx->netdev)) {for (i =0 ; i < wx->num_tx_queues; i++)
@@ -97,6 +96,7 @@ static int ngbe_set_ringparam(struct net_device *netdev, clear_reset:clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock);return err; }
drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c +3 -3
@@ -58,9 +58,8 @@ static int txgbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count)return 0 ; - err =wx_set_state_reset (wx); -if (err) -return err; +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state);if (!netif_running (wx->netdev)) {for (i =0 ; i < wx->num_tx_queues; i++)
@@ -90,6 +89,7 @@ static int txgbe_set_ringparam(struct net_device *netdev, clear_reset:clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock);return err; }
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +3 -7
@@ -602,20 +602,16 @@ int txgbe_setup_tc(struct net_device *dev, u8 tc)static void txgbe_reinit_locked (struct wx *wx) { -int err =0 ; -netif_trans_update (wx->netdev); - err =wx_set_state_reset (wx); -if (err) { -wx_err (wx,"wait device reset timeout\n" ); -return ; - } +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state);txgbe_down (wx);txgbe_up (wx);clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock); }void txgbe_do_reset (struct net_device *netdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1375/1518 net: wangxun: schedule hardware stats update in watchdog
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit dc33e52b8ce6f2d42dce18da12dc47d6c21f2e8b ]
Hardware statistics should be updated periodically in the watchdog to prevent 32-bit registers from overflowing. This is also required for the upcoming pause frame accounting logic, which relies on regular statistics sampling.
Stable-dep-of: 7bf29145d7a9 ("net: txgbe: fix MISC interrupt unmasking in non-MSI-X mode and device shutdown")
--- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 9 +++++ drivers/net/ethernet/wangxun/libwx/wx_type.h | 1 + drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 36 ++++++++++++++++++- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 1 + 4 files changed, 46 insertions(+), 1 deletion(-)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +9 -0
@@ -2508,6 +2508,7 @@ int wx_sw_init(struct wx *wx)return -ENOMEM ; } +spin_lock_init (&wx->hw_stats_lock);mutex_init (&wx->reset_lock);bitmap_zero (wx->state,WX_STATE_NBITS );bitmap_zero (wx->flags,WX_PF_FLAGS_NBITS );
@@ -2840,6 +2841,12 @@ void wx_update_stats(struct wx *wx)u64 restart_queue =0 , tx_busy =0 ;u32 i; +if (!netif_running (wx->netdev) || +test_bit (WX_STATE_RESETTING , wx->state)) +return ; + +spin_lock (&wx->hw_stats_lock); +/* gather some stats to the wx struct that are per queue */ for (i =0 ; i < wx->num_rx_queues; i++) {struct wx_ring *rx_ring = wx->rx_ring[i];
@@ -2908,6 +2915,8 @@ void wx_update_stats(struct wx *wx)for (i = wx->num_vfs * wx->num_rx_queues_per_pool; i < wx->mac.max_rx_queues; i++) hwstats->qmprc +=rd32 (wx,WX_PX_MPRC (i)); + +spin_unlock (&wx->hw_stats_lock); }EXPORT_SYMBOL (wx_update_stats);
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -0
@@ -1348,6 +1348,7 @@ struct wx {bool default_up;struct wx_hw_stats stats; +spinlock_t hw_stats_lock;/* spinlock for accessing to hw stats */ u64 tx_busy;u64 non_eop_descs;u64 restart_queue;
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +35 -1
@@ -138,6 +138,26 @@ static int ngbe_sw_init(struct wx *wx)return 0 ; } +/** +* ngbe_service_task - manages and runs subtasks +* @work: pointer to work_struct containing our data +**/ +static void ngbe_service_task (struct work_struct *work) +{ + struct wx *wx = container_of(work, struct wx, service_task); + +wx_update_stats (wx); + +wx_service_event_complete (wx); +} + +static void ngbe_init_service (struct wx *wx) +{ +timer_setup (&wx->service_timer, wx_service_timer,0 ); +INIT_WORK (&wx->service_task, ngbe_service_task); +clear_bit (WX_STATE_SERVICE_SCHED , wx->state); +} +/** * ngbe_irq_enable - Enable default interrupt generation settings * @wx: board private structure
@@ -370,6 +390,10 @@ static void ngbe_disable_device(struct wx *wx)wx_napi_disable_all (wx);netif_tx_stop_all_queues (netdev);netif_tx_disable (netdev); + +timer_delete_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); +if (wx->gpio_ctrl)ngbe_sfp_modules_txrx_powerctl (wx, false);wx_irq_disable (wx);
@@ -409,6 +433,7 @@ void ngbe_up(struct wx *wx)wx_napi_enable_all (wx);/* enable transmits */ netif_tx_start_all_queues (wx->netdev); +mod_timer (&wx->service_timer, jiffies);/* clear any pending interrupts, may auto mask */ rd32 (wx,WX_PX_IC (0 ));
@@ -772,9 +797,11 @@ static int ngbe_probe(struct pci_dev *pdev,eth_hw_addr_set (netdev, wx->mac.perm_addr);wx_mac_set_default_filter (wx, wx->mac.perm_addr); +ngbe_init_service (wx); + err =wx_init_interrupt_scheme (wx);if (err) - goto err_free_mac_table; + goto err_cancel_service;/* phy Interface Configuration */ err =ngbe_mdio_init (wx);
@@ -794,6 +821,9 @@ static int ngbe_probe(struct pci_dev *pdev,wx_control_hw (wx, false); err_clear_interrupt_scheme:wx_clear_interrupt_scheme (wx); +err_cancel_service: +timer_delete_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); err_free_mac_table:kfree (wx->rss_key);kfree (wx->mac_table);
@@ -822,6 +852,10 @@ static void ngbe_remove(struct pci_dev *pdev) netdev = wx->netdev;wx_disable_sriov (wx);unregister_netdev (netdev); + +timer_shutdown_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); +phylink_destroy (wx->phylink);pci_release_selected_regions (pdev,pci_select_bars (pdev,IORESOURCE_MEM ));
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +1 -0
@@ -130,6 +130,7 @@ static void txgbe_service_task(struct work_struct *work)txgbe_module_detection_subtask (wx);txgbe_link_config_subtask (wx); +wx_update_stats (wx);wx_service_event_complete (wx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1376/1518 net: wangxun: introduce WX_STATE_DOWN to serialize device shutdown state
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit 7116ffb48ad0af7a6d066c3e80329270920858fe ]
Replace various netif_running() checks with an explicit WX_STATE_DOWN state bit to track whether the device datapath and interrupt handling are operational.
The previous logic relied on netif_running() to gate interrupt reenablement, queue wakeups, statistics updates, and service task execution. However, netif_running() only reflects the administrative state of the netdevice and does not fully serialize against teardown and reset paths. During device shutdown and reset flows, asynchronous contexts such as interrupt handlers, NAPI poll, and service work could still observe netif_running() as true while device resources were already being disabled or freed.
Stable-dep-of: 7bf29145d7a9 ("net: txgbe: fix MISC interrupt unmasking in non-MSI-X mode and device shutdown")
--- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 3 ++- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 9 ++++++--- drivers/net/ethernet/wangxun/libwx/wx_sriov.c | 2 +- drivers/net/ethernet/wangxun/libwx/wx_type.h | 1 + drivers/net/ethernet/wangxun/libwx/wx_vf_common.c | 8 ++++++-- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 12 ++++++++---- drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c | 2 +- drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 4 ++++ 8 files changed, 29 insertions(+), 12 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +2 -1
@@ -2512,6 +2512,7 @@ int wx_sw_init(struct wx *wx)mutex_init (&wx->reset_lock);bitmap_zero (wx->state,WX_STATE_NBITS );bitmap_zero (wx->flags,WX_PF_FLAGS_NBITS ); +set_bit (WX_STATE_DOWN , wx->state); wx->misc_irq_domain = false;return 0 ;
@@ -2841,7 +2842,7 @@ void wx_update_stats(struct wx *wx)u64 restart_queue =0 , tx_busy =0 ;u32 i; -if (!netif_running (wx->netdev) || +if (test_bit (WX_STATE_DOWN , wx->state) ||test_bit (WX_STATE_RESETTING , wx->state))return ;
drivers/net/ethernet/wangxun/libwx/wx_lib.c +6 -3
@@ -872,7 +872,7 @@ static bool wx_clean_tx_irq(struct wx_q_vector *q_vector,if (__netif_subqueue_stopped (tx_ring->netdev, tx_ring->queue_index) && -netif_running (tx_ring->netdev)) { + !test_bit (WX_STATE_DOWN , wx->state)) {netif_wake_subqueue (tx_ring->netdev, tx_ring->queue_index); ++tx_ring->tx_stats.restart_queue;
@@ -960,7 +960,7 @@ static int wx_poll(struct napi_struct *napi, int budget)if (likely (napi_complete_done (napi, work_done))) {if (wx->adaptive_itr)wx_update_dim_sample (q_vector); -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state))wx_intr_enable (wx,WX_INTR_Q (q_vector->v_idx)); }
@@ -2339,6 +2339,8 @@ int wx_init_interrupt_scheme(struct wx *wx)wx_cache_ring_rss (wx); +set_bit (WX_STATE_DOWN , wx->state); +return 0 ; }EXPORT_SYMBOL (wx_init_interrupt_scheme);
@@ -3280,7 +3282,8 @@ EXPORT_SYMBOL(wx_set_ring);void wx_service_event_schedule (struct wx *wx) { -if (!test_and_set_bit (WX_STATE_SERVICE_SCHED , wx->state)) +if (!test_bit (WX_STATE_DOWN , wx->state) && + !test_and_set_bit (WX_STATE_SERVICE_SCHED , wx->state))queue_work (system_power_efficient_wq, &wx->service_task); }EXPORT_SYMBOL (wx_service_event_schedule);
drivers/net/ethernet/wangxun/libwx/wx_sriov.c +1 -1
@@ -900,7 +900,7 @@ static void wx_set_vf_link_state(struct wx *wx, int vf, int state) wx->vfinfo[vf].link_state = state;switch (state) {case IFLA_VF_LINK_STATE_AUTO : -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state)) wx->vfinfo[vf].link_enable = true;else wx->vfinfo[vf].link_enable = false;
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -0
@@ -1178,6 +1178,7 @@ struct wx_hw_stats { };enum wx_state { +WX_STATE_DOWN ,WX_STATE_RESETTING ,WX_STATE_SWFW_BUSY ,WX_STATE_PTP_RUNNING ,
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c +6 -2
@@ -67,7 +67,7 @@ static irqreturn_t wx_msix_misc_vf(int __always_unused irq, void *data)set_bit (WX_FLAG_NEED_UPDATE_LINK , wx->flags);/* Clear the interrupt */ -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state))wr32 (wx,WX_VXIMC , wx->eims_other);return IRQ_HANDLED ;
@@ -277,6 +277,7 @@ static void wxvf_up_complete(struct wx *wx)wx_configure_msix_vf (wx);smp_mb__before_atomic (); +clear_bit (WX_STATE_DOWN , wx->state);wx_napi_enable_all (wx);/* clear any pending interrupts, may auto mask */
@@ -326,6 +327,9 @@ static void wxvf_down(struct wx *wx) {struct net_device *netdev = wx->netdev; +if (test_and_set_bit (WX_STATE_DOWN , wx->state)) +return ; +timer_delete_sync (&wx->service_timer);netif_tx_stop_all_queues (netdev);netif_tx_disable (netdev);
@@ -359,7 +363,7 @@ static void wxvf_reset_subtask(struct wx *wx)rtnl_lock ();if (test_bit (WX_STATE_RESETTING , wx->state) || - !(netif_running (wx->netdev))) { +test_bit (WX_STATE_DOWN , wx->state)) {rtnl_unlock ();return ; }
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +8 -4
@@ -206,7 +206,7 @@ static irqreturn_t ngbe_intr(int __always_unused irq, void *data)/* shared interrupt alert! * the interrupt that we masked before the EICR read. */ -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state))ngbe_irq_enable (wx, true);return IRQ_NONE ;/* Not our interrupt */ }
@@ -222,7 +222,7 @@ static irqreturn_t ngbe_intr(int __always_unused irq, void *data)/* would disable interrupts here but it is auto disabled */ napi_schedule_irqoff (&q_vector->napi); -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state))ngbe_irq_enable (wx, false);return IRQ_HANDLED ;
@@ -237,7 +237,7 @@ static irqreturn_t __ngbe_msix_misc(struct wx *wx, u32 eicr)wx_ptp_check_pps_event (wx);/* re-enable the original interrupt state, no lsc, no queues */ -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state))ngbe_irq_enable (wx, false);return IRQ_HANDLED ;
@@ -264,7 +264,7 @@ static irqreturn_t ngbe_misc_and_queue(int __always_unused irq, void *data)/* queue */ q_vector = wx->q_vector[0 ];napi_schedule_irqoff (&q_vector->napi); -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state))ngbe_irq_enable (wx, true);return IRQ_HANDLED ; }
@@ -365,6 +365,9 @@ static void ngbe_disable_device(struct wx *wx)struct net_device *netdev = wx->netdev;u32 i; +if (test_and_set_bit (WX_STATE_DOWN , wx->state)) +return ; +if (wx->num_vfs) {/* Clear EITR Select mapping */ wr32 (wx,WX_PX_ITRSEL ,0 );
@@ -430,6 +433,7 @@ void ngbe_up(struct wx *wx)/* make sure to complete pre-operations */ smp_mb__before_atomic (); +clear_bit (WX_STATE_DOWN , wx->state);wx_napi_enable_all (wx);/* enable transmits */ netif_tx_start_all_queues (wx->netdev);
drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c +1 -1
@@ -141,7 +141,7 @@ static irqreturn_t txgbe_misc_irq_handle(int irq, void *data)/* shared interrupt alert! * the interrupt that we masked before the ICR read. */ -if (netif_running (wx->netdev)) +if (!test_bit (WX_STATE_DOWN , wx->state))txgbe_irq_enable (wx, true);return IRQ_NONE ;/* Not our interrupt */ }
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +4 -0
@@ -152,6 +152,7 @@ static void txgbe_up_complete(struct wx *wx)/* make sure to complete pre-operations */ smp_mb__before_atomic (); +clear_bit (WX_STATE_DOWN , wx->state);wx_napi_enable_all (wx);switch (wx->mac.type) {
@@ -218,6 +219,9 @@ static void txgbe_disable_device(struct wx *wx)struct net_device *netdev = wx->netdev;u32 i; +if (test_and_set_bit (WX_STATE_DOWN , wx->state)) +return ; +wx_disable_pcie_master (wx);/* disable receives */ wx_disable_rx (wx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1377/1518 net: txgbe: fix MISC interrupt unmasking in non-MSI-X mode and device shutdown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit 7bf29145d7a9564162c6b18f8d23760e141e2d15 ]
In txgbe_misc_irq_thread_fn(), the driver unmasks the miscellaneous interrupt at the end of the handler using TXGBE_INTR_MISC(wx) (which resolves to BIT(wx->num_q_vectors)). While this is correct for MSI-X mode, it is incorrect for legacy INTx or single MSI modes.
Due to hardware behavior, the WX_PX_MISC_IVAR register is completely ignored by the hardware when MSI-X is disabled. In non-MSI-X mode, the hardware forcibly merges all interrupt causes (both Queue and MISC) into a single bit: BIT(0) of the interrupt register.
Unconditionally unmasking TXGBE_INTR_MISC(wx) (e.g., BIT(1)) in non-MSI-X mode means the actual MISC interrupt bit (BIT(0)) is not unmasked promptly at the end of the MISC thread. Instead, it remains masked until NAPI completes its polling and unmasks the shared BIT(0). This delays the assertion of subsequent MISC interrupts, preventing timely handling of events like link state changes.
Fix this by explicitly checking pdev->msix_enabled and falling back to BIT(0) as the interrupt mask for the MISC cause when MSI-X is disabled.
Additionally, unconditionally unmasking the interrupt at the end of the thread introduces a race condition during device teardown. Guarding the wx_intr_enable() call with a check for the WX_STATE_DOWN bit, to prevent re-arming the interrupt during device shutdown.
--- drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c +4 -1
@@ -164,6 +164,7 @@ static irqreturn_t txgbe_misc_irq_thread_fn(int irq, void *data)struct wx *wx = txgbe->wx;unsigned int nhandled =0 ;unsigned int sub_irq; +u64 misc_mask;u32 eicr; eicr = txgbe->eicr;
@@ -183,7 +184,9 @@ static irqreturn_t txgbe_misc_irq_thread_fn(int irq, void *data) nhandled++; } -wx_intr_enable (wx,TXGBE_INTR_MISC (wx)); + misc_mask = wx->pdev->msix_enabled ?TXGBE_INTR_MISC (wx) :BIT (0 ); +if (!test_bit (WX_STATE_DOWN , wx->state)) +wx_intr_enable (wx, misc_mask);return (nhandled >0 ?IRQ_HANDLED :IRQ_NONE ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1378/1518 net: libwx: fix concurrent bitmap overwrite in PTP setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit f05516dd7b865666ea7d67e90d0edb588ae9ad18 ]
In wx_ptp_set_timestamp_mode(), the driver copies the global wx->flags bitmap to a local variable, modifies the PTP-related bits, and then writes the entire bitmap back using memcpy().
This Read-Copy-Update pattern is unsafe and introduces a critical race condition. Other asynchronous contexts (such as Tx timeout routines or GPIO IRQ handlers) update individual bits in wx->flags concurrently using atomic bitops like set_bit() or clear_bit(). The memcpy() write-back can silently overwrite and drop these concurrent changes, potentially causing the driver to miss critical module reset or PCIe recovery requests.
Fix this by removing the local bitmap copy. Instead, evaluate the intended PTP flag states locally and apply them directly to wx->flags using atomic set_bit() and clear_bit() operations only after the hardware is successfully configured.
--- drivers/net/ethernet/wangxun/libwx/wx_ptp.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_ptp.c +6 -12
@@ -555,13 +555,11 @@ static int wx_ptp_set_timestamp_mode(struct wx *wx, {u32 tsync_tx_ctl =WX_TSC_1588_CTL_ENABLED ;u32 tsync_rx_ctl =WX_PSR_1588_CTL_ENABLED ; -DECLARE_BITMAP (flags,WX_PF_FLAGS_NBITS );u32 tsync_rx_mtrl =PTP_EV_PORT <<16 ; +bool rx_tstamp = false;bool is_l2 = false;u32 regval; -memcpy (flags, wx->flags,sizeof (wx->flags)); -switch (config->tx_type) {case HWTSTAMP_TX_OFF : tsync_tx_ctl =0 ;
@@ -576,20 +574,16 @@ static int wx_ptp_set_timestamp_mode(struct wx *wx,case HWTSTAMP_FILTER_NONE : tsync_rx_ctl =0 ; tsync_rx_mtrl =0 ; -clear_bit (WX_FLAG_RX_HWTSTAMP_ENABLED , flags); -clear_bit (WX_FLAG_RX_HWTSTAMP_IN_REGISTER , flags);break ;case HWTSTAMP_FILTER_PTP_V1_L4_SYNC : tsync_rx_ctl |=WX_PSR_1588_CTL_TYPE_L4_V1 ; tsync_rx_mtrl |=WX_PSR_1588_MSG_V1_SYNC ; -set_bit (WX_FLAG_RX_HWTSTAMP_ENABLED , flags); -set_bit (WX_FLAG_RX_HWTSTAMP_IN_REGISTER , flags); + rx_tstamp = true;break ;case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ : tsync_rx_ctl |=WX_PSR_1588_CTL_TYPE_L4_V1 ; tsync_rx_mtrl |=WX_PSR_1588_MSG_V1_DELAY_REQ ; -set_bit (WX_FLAG_RX_HWTSTAMP_ENABLED , flags); -set_bit (WX_FLAG_RX_HWTSTAMP_IN_REGISTER , flags); + rx_tstamp = true;break ;case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_L2_EVENT :
@@ -602,9 +596,8 @@ static int wx_ptp_set_timestamp_mode(struct wx *wx,case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ : tsync_rx_ctl |=WX_PSR_1588_CTL_TYPE_EVENT_V2 ; is_l2 = true; + rx_tstamp = true; config->rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT ; -set_bit (WX_FLAG_RX_HWTSTAMP_ENABLED , flags); -set_bit (WX_FLAG_RX_HWTSTAMP_IN_REGISTER , flags);break ;default :/* register PSR_1588_MSG must be set in order to do V1 packets,
@@ -643,7 +636,8 @@ static int wx_ptp_set_timestamp_mode(struct wx *wx,WX_WRITE_FLUSH (wx);/* configure adapter flags only when HW is actually configured */ -memcpy (wx->flags, flags,sizeof (wx->flags)); +assign_bit (WX_FLAG_RX_HWTSTAMP_ENABLED , wx->flags, rx_tstamp); +assign_bit (WX_FLAG_RX_HWTSTAMP_IN_REGISTER , wx->flags, rx_tstamp);/* clear TX/RX timestamp state, just to be sure */ wx_ptp_clear_tx_timestamp (wx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1379/1518 net: page_pool: Remove zone/policy GFP flags when allocating XArray entries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Zhang <[email protected]>
[ Upstream commit 039f248a6cc1f4dec895c001de2c600842022e58 ]
Net drivers request GFP flags according to both the current context and the device constraints, but the XArray entry itself is by no mean used by the device. Passing though device constraints to XArray allocation is a bug and will be warned and fixed up by slab, e.g.:
Unexpected gfp: 0x4 (GFP_DMA32). Fixing up to gfp: 0x82820 (GFP_ATOMIC|__GFP_NOWARN|__GFP_NOMEMALLOC). Fix your code!
CPU: 2 UID: 0 PID: 1071629 Comm: kworker/u80:1 Not tainted 7.2.0-rc7+ #1 PREEMPT(lazy)
Hardware name: LENOVO 21Q4/LNVNB161216, BIOS PXCN27WW 10/20/2025
Workqueue: mt76 mt792x_pm_wake_work [mt792x_lib]
Call Trace:
<TASK>
dump_stack_lvl+0x6e/0x90
kmalloc_fix_flags+0x4d/0x6a
refill_objects+0x10a/0x330
__pcs_replace_empty_main+0x292/0x5c0
kmem_cache_alloc_lru_noprof+0x4c2/0x680
? __xas_nomem+0x3a/0x120
__xas_nomem+0x3a/0x120
__xa_alloc+0xd4/0x190
page_pool_dma_map+0xef/0x400
__page_pool_alloc_netmems_slow+0xed/0x480
? lock_release+0x280/0x490
page_pool_alloc_frag_netmem+0xe0/0x3a0
page_pool_alloc_frag+0xe/0x20
mt76_dma_rx_fill_buf+0x1f6/0x580 [mt76]
mt76_dma_rx_reset+0x1cf/0x230 [mt76]
mt792x_wpdma_reset+0x183/0x1b0 [mt792x_lib]
mt792x_wpdma_reinit_cond+0x5e/0xa0 [mt792x_lib]
mt792xe_mcu_drv_pmctrl+0x28/0x60 [mt792x_lib]
mt792x_mcu_drv_pmctrl+0x3e/0x90 [mt792x_lib]
mt792x_pm_wake_work+0x2d/0x1d0 [mt792x_lib]
? process_one_work+0x20e/0x600
process_one_work+0x230/0x600
? process_one_work+0x256/0x600
worker_thread+0x1ec/0x3c0
? rescuer_thread+0x610/0x610
kthread+0xf2/0x130
? kthread_affine_node+0x140/0x140
ret_from_fork+0x2a5/0x380
? kthread_affine_node+0x140/0x140
ret_from_fork_asm+0x11/0x20
</TASK>Currently mt76 and stmmac may allocate page pool pages with GFP_DMA32.
Fix it by removing zone/policy GFP flags when allocating XArray entries. This is inspired by commit 96d578088085 ("iommu/dma: Use the gfp parameter in __iommu_dma_alloc_noncontiguous()").
--- net/core/page_pool.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/page_pool.c +7 -0
@@ -482,6 +482,13 @@ static int page_pool_register_dma_index(struct page_pool *pool,if (unlikely (!PP_DMA_INDEX_BITS )) goto out; +/* +* Drivers request GFP flags according to both the current context and +* the device constraints, but the XArray entry itself is by no mean +* used by the device, so remove zone/policy flags. +*/ + gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_COMP); +if (in_softirq ()) err =xa_alloc (&pool->dma_mapped, &id,netmem_to_page (netmem),PP_DMA_INDEX_LIMIT , gfp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1380/1518 net_sched: sch_fq: fix pacing delay underflow with pacing offload
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 137b8ae233cabe7fc77cce86f5ba33bf1b369e26 ]
When pacing offload is enabled (q->offload_horizon > 0), FQ can dequeue packets early (now < f->time_next_packet).
In this case, the drift calculation (now - f->time_next_packet) underflows to a large unsigned value.
min(len/2, now - f->time_next_packet) then evaluates to len/2, incorrectly halving the pacing delay for the next packet.
Fix this by only applying drift compensation if now > f->time_next_packet.
This bug was triggered when flow_max_rate was set on the qdisc or for non EDT packets (packets with a zero skb->tstamp).
--- net/sched/sch_fq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/sched/sch_fq.c +6 -2
@@ -771,8 +771,12 @@ static struct sk_buff *fq_dequeue(struct Qdisc *sch)* f->time_next_packet was set when prior packet was sent, * and current time (@now) can be too late by tens of us. */ -if (f->time_next_packet) - len -=min (len/2 , now - f->time_next_packet); +if (f->time_next_packet) { +s64 drift = now - f->time_next_packet; + +if (drift >0 ) + len -=min_t (u64, len /2 , drift); + } f->time_next_packet = now + len; } out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1381/1518 syscore: Pass context data to callbacks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thierry Reding <[email protected]>
[ Upstream commit a97fbc3ee3e2a536fafaff04f21f45472db71769 ]
Several drivers can benefit from registering per-instance data along with the syscore operations. To achieve this, move the modifiable fields out of the syscore_ops structure and into a separate struct syscore that can be registered with the framework. Add a void * driver data field for drivers to store contextual data that will be passed to the syscore ops.
Stable-dep-of: cee0d90bceae ("Drivers: hv: vmbus: Skip VMBus module cleanup for non-nested root partition")
--- arch/arm/mach-exynos/mcpm-exynos.c | 12 ++-- arch/arm/mach-exynos/suspend.c | 48 +++++++------ arch/arm/mach-pxa/generic.h | 6 +- arch/arm/mach-pxa/irq.c | 10 ++- arch/arm/mach-pxa/mfp-pxa2xx.c | 10 ++- arch/arm/mach-pxa/mfp-pxa3xx.c | 10 ++- arch/arm/mach-pxa/pxa25x.c | 4 +- arch/arm/mach-pxa/pxa27x.c | 4 +- arch/arm/mach-pxa/pxa3xx.c | 4 +- arch/arm/mach-pxa/smemc.c | 12 ++-- arch/arm/mach-s3c/irq-pm-s3c64xx.c | 12 ++-- arch/arm/mach-s5pv210/pm.c | 10 ++- arch/arm/mach-versatile/integrator_ap.c | 12 ++-- arch/arm/mm/cache-b15-rac.c | 12 ++-- arch/loongarch/kernel/smp.c | 12 ++-- arch/mips/alchemy/common/dbdma.c | 12 ++-- arch/mips/alchemy/common/irq.c | 24 ++++--- arch/mips/alchemy/common/usb.c | 12 ++-- arch/mips/pci/pci-alchemy.c | 16 +++-- arch/powerpc/platforms/cell/spu_base.c | 10 ++- arch/powerpc/platforms/powermac/pic.c | 12 ++-- arch/powerpc/sysdev/fsl_lbc.c | 12 ++-- arch/powerpc/sysdev/fsl_pci.c | 12 ++-- arch/powerpc/sysdev/ipic.c | 12 ++-- arch/powerpc/sysdev/mpic.c | 14 ++-- arch/powerpc/sysdev/mpic_timer.c | 10 ++- arch/sh/mm/pmb.c | 10 ++- arch/x86/events/amd/ibs.c | 12 ++-- arch/x86/hyperv/hv_init.c | 12 ++-- arch/x86/kernel/amd_gart_64.c | 10 ++- arch/x86/kernel/apic/apic.c | 12 ++-- arch/x86/kernel/apic/io_apic.c | 17 +++-- arch/x86/kernel/cpu/aperfmperf.c | 20 +++--- arch/x86/kernel/cpu/intel_epb.c | 16 +++-- arch/x86/kernel/cpu/mce/core.c | 14 ++-- arch/x86/kernel/cpu/microcode/core.c | 15 ++++- arch/x86/kernel/cpu/mtrr/legacy.c | 12 ++-- arch/x86/kernel/cpu/umwait.c | 10 ++- arch/x86/kernel/i8237.c | 10 ++- arch/x86/kernel/i8259.c | 14 ++-- arch/x86/kernel/kvm.c | 12 ++-- drivers/acpi/pci_link.c | 10 ++- drivers/acpi/sleep.c | 12 ++-- drivers/base/firmware_loader/main.c | 12 ++-- drivers/base/syscore.c | 82 ++++++++++++----------- drivers/bus/mvebu-mbus.c | 16 +++-- drivers/clk/at91/pmc.c | 12 ++-- drivers/clk/imx/clk-vf610.c | 12 ++-- drivers/clk/ingenic/jz4725b-cgu.c | 2 +- drivers/clk/ingenic/jz4740-cgu.c | 2 +- drivers/clk/ingenic/jz4755-cgu.c | 2 +- drivers/clk/ingenic/jz4760-cgu.c | 2 +- drivers/clk/ingenic/jz4770-cgu.c | 2 +- drivers/clk/ingenic/jz4780-cgu.c | 2 +- drivers/clk/ingenic/pm.c | 14 ++-- drivers/clk/ingenic/pm.h | 2 +- drivers/clk/ingenic/tcu.c | 12 ++-- drivers/clk/ingenic/x1000-cgu.c | 2 +- drivers/clk/ingenic/x1830-cgu.c | 2 +- drivers/clk/mvebu/common.c | 12 ++-- drivers/clk/rockchip/clk-rk3288.c | 12 ++-- drivers/clk/samsung/clk-s5pv210-audss.c | 12 ++-- drivers/clk/samsung/clk.c | 12 ++-- drivers/clk/tegra/clk-tegra210.c | 12 ++-- drivers/clocksource/timer-armada-370-xp.c | 12 ++-- drivers/cpuidle/cpuidle-psci.c | 12 ++-- drivers/gpio/gpio-mxc.c | 12 ++-- drivers/gpio/gpio-pxa.c | 12 ++-- drivers/gpio/gpio-sa1100.c | 12 ++-- drivers/hv/vmbus_drv.c | 14 ++-- drivers/iommu/amd/init.c | 16 +++-- drivers/iommu/intel/iommu.c | 12 ++-- drivers/irqchip/exynos-combiner.c | 14 ++-- drivers/irqchip/irq-armada-370-xp.c | 12 ++-- drivers/irqchip/irq-bcm7038-l1.c | 12 ++-- drivers/irqchip/irq-gic-v3-its.c | 12 ++-- drivers/irqchip/irq-i8259.c | 12 ++-- drivers/irqchip/irq-imx-gpcv2.c | 16 +++-- drivers/irqchip/irq-loongson-eiointc.c | 12 ++-- drivers/irqchip/irq-loongson-htpic.c | 10 ++- drivers/irqchip/irq-loongson-htvec.c | 12 ++-- drivers/irqchip/irq-loongson-pch-lpc.c | 12 ++-- drivers/irqchip/irq-loongson-pch-pic.c | 12 ++-- drivers/irqchip/irq-mchp-eic.c | 12 ++-- drivers/irqchip/irq-mst-intc.c | 12 ++-- drivers/irqchip/irq-mtk-cirq.c | 12 ++-- drivers/irqchip/irq-renesas-rzg2l.c | 12 ++-- drivers/irqchip/irq-sa11x0.c | 12 ++-- drivers/irqchip/irq-sifive-plic.c | 12 ++-- drivers/irqchip/irq-sun6i-r.c | 18 +++-- drivers/irqchip/irq-tegra.c | 12 ++-- drivers/irqchip/irq-vic.c | 12 ++-- drivers/leds/trigger/ledtrig-cpu.c | 14 ++-- drivers/macintosh/via-pmu.c | 12 ++-- drivers/power/reset/sc27xx-poweroff.c | 10 ++- drivers/sh/clk/core.c | 10 ++- drivers/sh/intc/core.c | 12 ++-- drivers/soc/bcm/brcmstb/biuctrl.c | 12 ++-- drivers/soc/tegra/pmc.c | 17 +++-- drivers/thermal/intel/intel_hfi.c | 12 ++-- drivers/xen/xen-acpi-processor.c | 12 ++-- include/linux/syscore_ops.h | 15 +++-- kernel/cpu_pm.c | 12 ++-- kernel/irq/generic-chip.c | 14 ++-- kernel/irq/pm.c | 11 ++- kernel/printk/printk.c | 11 ++- kernel/time/sched_clock.c | 22 ++++-- kernel/time/timekeeping.c | 22 ++++-- virt/kvm/kvm_main.c | 18 +++-- 109 files changed, 898 insertions(+), 470 deletions(-)
arch/arm/mach-exynos/mcpm-exynos.c +8 -4
@@ -215,7 +215,7 @@ static const struct of_device_id exynos_dt_mcpm_match[] = { {}, }; -static void exynos_mcpm_setup_entry_point (void ) +static void exynos_mcpm_setup_entry_point (void *data) {/* * U-Boot SPL is hardcoded to jump to the start of ns_sram_base_addr
@@ -228,10 +228,14 @@ static void exynos_mcpm_setup_entry_point(void)__raw_writel (__pa_symbol (mcpm_entry_point), ns_sram_base_addr +8 ); } -static struct syscore_ops exynos_mcpm_syscore_ops = { +static const struct syscore_ops exynos_mcpm_syscore_ops = { .resume = exynos_mcpm_setup_entry_point, }; +static struct syscore exynos_mcpm_syscore = { + .ops = &exynos_mcpm_syscore_ops, +}; +static int __init exynos_mcpm_init (void ) {struct device_node *node;
@@ -300,9 +304,9 @@ static int __init exynos_mcpm_init(void)pmu_raw_writel (value,EXYNOS_COMMON_OPTION (i)); } -exynos_mcpm_setup_entry_point (); +exynos_mcpm_setup_entry_point (NULL ); -register_syscore_ops (&exynos_mcpm_syscore_ops); +register_syscore (&exynos_mcpm_syscore);return ret; }
arch/arm/mach-exynos/suspend.c +29 -19
131 lines not on this page · raw message
arch/arm/mach-pxa/generic.h +3 -3
@@ -34,9 +34,9 @@ extern void __init pxa27x_map_io(void);extern void __init pxa3xx_init_irq (void );extern void __init pxa3xx_map_io (void ); -extern struct syscore_ops pxa_irq_syscore_ops; -extern struct syscore_ops pxa2xx_mfp_syscore_ops; -extern struct syscore_ops pxa3xx_mfp_syscore_ops; +extern struct syscore pxa_irq_syscore; +extern struct syscore pxa2xx_mfp_syscore; +extern struct syscore pxa3xx_mfp_syscore;void __init pxa_set_ffuart_info (void *info);void __init pxa_set_btuart_info (void *info);
arch/arm/mach-pxa/irq.c +7 -3
@@ -178,7 +178,7 @@ void __init pxa_init_irq(int irq_nr, int (*fn)(struct irq_data *, unsigned int))static unsigned long saved_icmr[MAX_INTERNAL_IRQS /32 ];static unsigned long saved_ipr[MAX_INTERNAL_IRQS ]; -static int pxa_irq_suspend (void ) +static int pxa_irq_suspend (void *data) {int i;
@@ -197,7 +197,7 @@ static int pxa_irq_suspend(void)return 0 ; } -static void pxa_irq_resume (void ) +static void pxa_irq_resume (void *data) {int i;
@@ -219,11 +219,15 @@ static void pxa_irq_resume(void)#define pxa_irq_resume NULL#endif -struct syscore_ops pxa_irq_syscore_ops = { +static const struct syscore_ops pxa_irq_syscore_ops = { .suspend = pxa_irq_suspend, .resume = pxa_irq_resume, }; +struct syscore pxa_irq_syscore = { + .ops = &pxa_irq_syscore_ops, +}; +#ifdef CONFIG_OF static const struct of_device_id intc_ids[]__initconst = { { .compatible = "marvell,pxa-intc", },
arch/arm/mach-pxa/mfp-pxa2xx.c +7 -3
@@ -346,7 +346,7 @@ static unsigned long saved_gpdr[4];static unsigned long saved_gplr[4 ];static unsigned long saved_pgsr[4 ]; -static int pxa2xx_mfp_suspend (void ) +static int pxa2xx_mfp_suspend (void *data) {int i;
@@ -385,7 +385,7 @@ static int pxa2xx_mfp_suspend(void)return 0 ; } -static void pxa2xx_mfp_resume (void ) +static void pxa2xx_mfp_resume (void *data) {int i;
@@ -404,11 +404,15 @@ static void pxa2xx_mfp_resume(void)#define pxa2xx_mfp_resume NULL#endif -struct syscore_ops pxa2xx_mfp_syscore_ops = { +static const struct syscore_ops pxa2xx_mfp_syscore_ops = { .suspend = pxa2xx_mfp_suspend, .resume = pxa2xx_mfp_resume, }; +struct syscore pxa2xx_mfp_syscore = { + .ops = &pxa2xx_mfp_syscore_ops, +}; +static int __init pxa2xx_mfp_init (void ) {int i;
arch/arm/mach-pxa/mfp-pxa3xx.c +7 -3
@@ -27,13 +27,13 @@* a pull-down mode if they're an active low chip select, and we're * just entering standby. */ -static int pxa3xx_mfp_suspend (void ) +static int pxa3xx_mfp_suspend (void *data) {mfp_config_lpm ();return 0 ; } -static void pxa3xx_mfp_resume (void ) +static void pxa3xx_mfp_resume (void *data) {mfp_config_run ();
@@ -49,7 +49,11 @@ static void pxa3xx_mfp_resume(void)#define pxa3xx_mfp_resume NULL#endif -struct syscore_ops pxa3xx_mfp_syscore_ops = { +static const struct syscore_ops pxa3xx_mfp_syscore_ops = { .suspend = pxa3xx_mfp_suspend, .resume = pxa3xx_mfp_resume, }; + +struct syscore pxa3xx_mfp_syscore = { + .ops = &pxa3xx_mfp_syscore_ops, +};
arch/arm/mach-pxa/pxa25x.c +2 -2
@@ -235,8 +235,8 @@ static int __init pxa25x_init(void)pxa25x_init_pm (); -register_syscore_ops (&pxa_irq_syscore_ops); -register_syscore_ops (&pxa2xx_mfp_syscore_ops); +register_syscore (&pxa_irq_syscore); +register_syscore (&pxa2xx_mfp_syscore);if (!of_have_populated_dt ()) {software_node_register (&pxa2xx_gpiochip_node);
arch/arm/mach-pxa/pxa27x.c +2 -2
@@ -337,8 +337,8 @@ static int __init pxa27x_init(void)pxa27x_init_pm (); -register_syscore_ops (&pxa_irq_syscore_ops); -register_syscore_ops (&pxa2xx_mfp_syscore_ops); +register_syscore (&pxa_irq_syscore); +register_syscore (&pxa2xx_mfp_syscore);if (!of_have_populated_dt ()) {software_node_register (&pxa2xx_gpiochip_node);
arch/arm/mach-pxa/pxa3xx.c +2 -2
@@ -424,8 +424,8 @@ static int __init pxa3xx_init(void)if (cpu_is_pxa320 ())enable_irq_wake (IRQ_WAKEUP1 ); -register_syscore_ops (&pxa_irq_syscore_ops); -register_syscore_ops (&pxa3xx_mfp_syscore_ops); +register_syscore (&pxa_irq_syscore); +register_syscore (&pxa3xx_mfp_syscore); }return ret;
arch/arm/mach-pxa/smemc.c +8 -4
@@ -18,7 +18,7 @@ static unsigned long msc[2];static unsigned long sxcnfg, memclkcfg;static unsigned long csadrcfg[4 ]; -static int pxa3xx_smemc_suspend (void ) +static int pxa3xx_smemc_suspend (void *data) { msc[0 ] =__raw_readl (MSC0 ); msc[1 ] =__raw_readl (MSC1 );
@@ -32,7 +32,7 @@ static int pxa3xx_smemc_suspend(void)return 0 ; } -static void pxa3xx_smemc_resume (void ) +static void pxa3xx_smemc_resume (void *data) {__raw_writel (msc[0 ],MSC0 );__raw_writel (msc[1 ],MSC1 );
@@ -46,11 +46,15 @@ static void pxa3xx_smemc_resume(void)__raw_writel (0x2 ,CSMSADRCFG ); } -static struct syscore_ops smemc_syscore_ops = { +static const struct syscore_ops smemc_syscore_ops = { .suspend = pxa3xx_smemc_suspend, .resume = pxa3xx_smemc_resume, }; +static struct syscore smemc_syscore = { + .ops = &smemc_syscore_ops, +}; +static int __init smemc_init (void ) {if (cpu_is_pxa3xx ()) {
@@ -64,7 +68,7 @@ static int __init smemc_init(void)*/ __raw_writel (0x2 ,CSMSADRCFG ); -register_syscore_ops (&smemc_syscore_ops); +register_syscore (&smemc_syscore); }return 0 ;
arch/arm/mach-s3c/irq-pm-s3c64xx.c +8 -4
@@ -58,7 +58,7 @@ static struct irq_grp_save {static u32 irq_uart_mask[SERIAL_SAMSUNG_UARTS ]; -static int s3c64xx_irq_pm_suspend (void ) +static int s3c64xx_irq_pm_suspend (void *data) {struct irq_grp_save *grp = eint_grp_save;int i;
@@ -79,7 +79,7 @@ static int s3c64xx_irq_pm_suspend(void)return 0 ; } -static void s3c64xx_irq_pm_resume (void ) +static void s3c64xx_irq_pm_resume (void *data) {struct irq_grp_save *grp = eint_grp_save;int i;
@@ -100,18 +100,22 @@ static void s3c64xx_irq_pm_resume(void)S3C_PMDBG ("%s: IRQ configuration restored\n" , __func__); } -static struct syscore_ops s3c64xx_irq_syscore_ops = { +static const struct syscore_ops s3c64xx_irq_syscore_ops = { .suspend = s3c64xx_irq_pm_suspend, .resume = s3c64xx_irq_pm_resume, }; +static struct syscore s3c64xx_irq_syscore = { + .ops = &s3c64xx_irq_syscore_ops, +}; +static __init int s3c64xx_syscore_init (void ) {/* Appropriate drivers (pinctrl, uart) handle this when using DT. */ if (of_have_populated_dt () || !soc_is_s3c64xx ())return 0 ; -register_syscore_ops (&s3c64xx_irq_syscore_ops); +register_syscore (&s3c64xx_irq_syscore);return 0 ; }
arch/arm/mach-s5pv210/pm.c +7 -3
@@ -195,20 +195,24 @@ static const struct platform_suspend_ops s5pv210_suspend_ops = {/* * Syscore operations used to delay restore of certain registers. */ -static void s5pv210_pm_resume (void ) +static void s5pv210_pm_resume (void *data) {s3c_pm_do_restore_core (s5pv210_core_save,ARRAY_SIZE (s5pv210_core_save)); } -static struct syscore_ops s5pv210_pm_syscore_ops = { +static const struct syscore_ops s5pv210_pm_syscore_ops = { .resume = s5pv210_pm_resume, }; +static struct syscore s5pv210_pm_syscore = { + .ops = &s5pv210_pm_syscore_ops, +}; +/* * Initialization entry point. */ void __init s5pv210_pm_init (void ) { -register_syscore_ops (&s5pv210_pm_syscore_ops); +register_syscore (&s5pv210_pm_syscore);suspend_set_ops (&s5pv210_suspend_ops); }
arch/arm/mach-versatile/integrator_ap.c +8 -4
@@ -63,13 +63,13 @@ static void __init ap_map_io(void)#ifdef CONFIG_PM static unsigned long ic_irq_enable; -static int irq_suspend (void ) +static int irq_suspend (void *data) { ic_irq_enable =readl (VA_IC_BASE +IRQ_ENABLE );return 0 ; } -static void irq_resume (void ) +static void irq_resume (void *data) {/* disable all irq sources */ cm_clear_irqs ();
@@ -83,14 +83,18 @@ static void irq_resume(void)#define irq_resume NULL#endif -static struct syscore_ops irq_syscore_ops = { +static const struct syscore_ops irq_syscore_ops = { .suspend = irq_suspend, .resume = irq_resume, }; +static struct syscore irq_syscore = { + .ops = &irq_syscore_ops, +}; +static int __init irq_syscore_init (void ) { -register_syscore_ops (&irq_syscore_ops); +register_syscore (&irq_syscore);return 0 ; }
arch/arm/mm/cache-b15-rac.c +8 -4
@@ -256,7 +256,7 @@ static int b15_rac_dead_cpu(unsigned int cpu)return 0 ; } -static int b15_rac_suspend (void ) +static int b15_rac_suspend (void *data) {/* Suspend the read-ahead cache oeprations, forcing our cache * implementation to fallback to the regular ARMv7 calls.
@@ -271,7 +271,7 @@ static int b15_rac_suspend(void)return 0 ; } -static void b15_rac_resume (void ) +static void b15_rac_resume (void *data) {/* Coming out of a S3 suspend/resume cycle, the read-ahead cache * register RAC_CONFIG0_REG will be restored to its default value, make
@@ -282,11 +282,15 @@ static void b15_rac_resume(void)clear_bit (RAC_SUSPENDED , &b15_rac_flags); } -static struct syscore_ops b15_rac_syscore_ops = { +static const struct syscore_ops b15_rac_syscore_ops = { .suspend = b15_rac_suspend, .resume = b15_rac_resume, }; +static struct syscore b15_rac_syscore = { + .ops = &b15_rac_syscore_ops, +}; +static int __init b15_rac_init (void ) {struct device_node *dn, *cpu_dn;
@@ -347,7 +351,7 @@ static int __init b15_rac_init(void) }if (IS_ENABLED (CONFIG_PM_SLEEP )) -register_syscore_ops (&b15_rac_syscore_ops); +register_syscore (&b15_rac_syscore);spin_lock (&rac_lock); reg =__raw_readl (b15_rac_base +RAC_CONFIG0_REG );
arch/loongarch/kernel/smp.c +8 -4
@@ -535,28 +535,32 @@ int hibernate_resume_nonboot_cpu_disable(void)*/ #ifdef CONFIG_PM -static int loongson_ipi_suspend (void ) +static int loongson_ipi_suspend (void *data) {return 0 ; } -static void loongson_ipi_resume (void ) +static void loongson_ipi_resume (void *data) {iocsr_write32 (0xffffffff ,LOONGARCH_IOCSR_IPI_EN ); } -static struct syscore_ops loongson_ipi_syscore_ops = { +static const struct syscore_ops loongson_ipi_syscore_ops = { .resume = loongson_ipi_resume, .suspend = loongson_ipi_suspend, }; +static struct syscore loongson_ipi_syscore = { + .ops = &loongson_ipi_syscore_ops, +}; +/* * Enable boot cpu ipi before enabling nonboot cpus * during syscore_resume. */ static int __init ipi_pm_init (void ) { -register_syscore_ops (&loongson_ipi_syscore_ops); +register_syscore (&loongson_ipi_syscore);return 0 ; }
arch/mips/alchemy/common/dbdma.c +8 -4
@@ -982,7 +982,7 @@ u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr)static unsigned long alchemy_dbdma_pm_data[NUM_DBDMA_CHANS +1 ][6 ]; -static int alchemy_dbdma_suspend (void ) +static int alchemy_dbdma_suspend (void *data) {int i;void __iomem *addr;
@@ -1019,7 +1019,7 @@ static int alchemy_dbdma_suspend(void)return 0 ; } -static void alchemy_dbdma_resume (void ) +static void alchemy_dbdma_resume (void *data) {int i;void __iomem *addr;
@@ -1044,11 +1044,15 @@ static void alchemy_dbdma_resume(void) } } -static struct syscore_ops alchemy_dbdma_syscore_ops = { +static const struct syscore_ops alchemy_dbdma_syscore_ops = { .suspend = alchemy_dbdma_suspend, .resume = alchemy_dbdma_resume, }; +static struct syscore alchemy_dbdma_syscore = { + .ops = &alchemy_dbdma_syscore_ops, +}; +static int __init dbdma_setup (unsigned int irq,dbdev_tab_t *idtable) {int ret;
@@ -1071,7 +1075,7 @@ static int __init dbdma_setup(unsigned int irq, dbdev_tab_t *idtable)printk (KERN_ERR "Cannot grab DBDMA interrupt!\n" ); else { dbdma_initialized =1 ; -register_syscore_ops (&alchemy_dbdma_syscore_ops); +register_syscore (&alchemy_dbdma_syscore); }return ret;
arch/mips/alchemy/common/irq.c +16 -8
@@ -758,7 +758,7 @@ static inline void alchemy_ic_resume_one(void __iomem *base, unsigned long *d)wmb (); } -static int alchemy_ic_suspend (void ) +static int alchemy_ic_suspend (void *data) {alchemy_ic_suspend_one ((void __iomem *)KSEG1ADDR (AU1000_IC0_PHYS_ADDR ), alchemy_gpic_pmdata);
@@ -767,7 +767,7 @@ static int alchemy_ic_suspend(void)return 0 ; } -static void alchemy_ic_resume (void ) +static void alchemy_ic_resume (void *data) {alchemy_ic_resume_one ((void __iomem *)KSEG1ADDR (AU1000_IC1_PHYS_ADDR ), &alchemy_gpic_pmdata[7 ]);
@@ -775,7 +775,7 @@ static void alchemy_ic_resume(void) alchemy_gpic_pmdata); } -static int alchemy_gpic_suspend (void ) +static int alchemy_gpic_suspend (void *data) {void __iomem *base = (void __iomem *)KSEG1ADDR (AU1300_GPIC_PHYS_ADDR );int i;
@@ -806,7 +806,7 @@ static int alchemy_gpic_suspend(void)return 0 ; } -static void alchemy_gpic_resume (void ) +static void alchemy_gpic_resume (void *data) {void __iomem *base = (void __iomem *)KSEG1ADDR (AU1300_GPIC_PHYS_ADDR );int i;
@@ -837,16 +837,24 @@ static void alchemy_gpic_resume(void)wmb (); } -static struct syscore_ops alchemy_ic_pmops = { +static const struct syscore_ops alchemy_ic_pmops = { .suspend = alchemy_ic_suspend, .resume = alchemy_ic_resume, }; -static struct syscore_ops alchemy_gpic_pmops = { +static struct syscore alchemy_ic_pm = { + .ops = &alchemy_ic_pmops, +}; + +static const struct syscore_ops alchemy_gpic_pmops = { .suspend = alchemy_gpic_suspend, .resume = alchemy_gpic_resume, }; +static struct syscore alchemy_gpic_pm = { + .ops = &alchemy_gpic_pmops, +}; +/******************************************************************************/ /* create chained handlers for the 4 IC requests to the MIPS IRQ ctrl */
@@ -880,7 +888,7 @@ static void __init au1000_init_irq(struct alchemy_irqmap *map)ic_init ((void __iomem *)KSEG1ADDR (AU1000_IC0_PHYS_ADDR ));ic_init ((void __iomem *)KSEG1ADDR (AU1000_IC1_PHYS_ADDR )); -register_syscore_ops (&alchemy_ic_pmops); +register_syscore (&alchemy_ic_pm);mips_cpu_irq_init ();/* register all 64 possible IC0+IC1 irq sources as type "none".
@@ -925,7 +933,7 @@ static void __init alchemy_gpic_init_irq(const struct alchemy_irqmap *dints)int i;void __iomem *bank_base; -register_syscore_ops (&alchemy_gpic_pmops); +register_syscore (&alchemy_gpic_pm);mips_cpu_irq_init ();/* disable & ack all possible interrupt sources */
arch/mips/alchemy/common/usb.c +8 -4
@@ -580,22 +580,26 @@ static void alchemy_usb_pm(int susp) } } -static int alchemy_usb_suspend (void ) +static int alchemy_usb_suspend (void *data) {alchemy_usb_pm (1 );return 0 ; } -static void alchemy_usb_resume (void ) +static void alchemy_usb_resume (void *data) {alchemy_usb_pm (0 ); } -static struct syscore_ops alchemy_usb_pm_ops = { +static const struct syscore_ops alchemy_usb_pm_syscore_ops = { .suspend = alchemy_usb_suspend, .resume = alchemy_usb_resume, }; +static struct syscore alchemy_usb_pm_syscore = { + .ops = &alchemy_usb_pm_syscore_ops, +}; +static int __init alchemy_usb_init (void ) {int ret =0 ;
@@ -620,7 +624,7 @@ static int __init alchemy_usb_init(void) }if (!ret) -register_syscore_ops (&alchemy_usb_pm_ops); +register_syscore (&alchemy_usb_pm_syscore);return ret; }
arch/mips/pci/pci-alchemy.c +10 -6
@@ -304,7 +304,7 @@ static int alchemy_pci_def_idsel(unsigned int devsel, int assert) }/* save PCI controller register contents. */ -static int alchemy_pci_suspend (void ) +static int alchemy_pci_suspend (void *data) {struct alchemy_pci_context *ctx = __alchemy_pci_ctx;if (!ctx)
@@ -326,7 +326,7 @@ static int alchemy_pci_suspend(void)return 0 ; } -static void alchemy_pci_resume (void ) +static void alchemy_pci_resume (void *data) {struct alchemy_pci_context *ctx = __alchemy_pci_ctx;if (!ctx)
@@ -354,9 +354,13 @@ static void alchemy_pci_resume(void)alchemy_pci_wired_entry (ctx);/* install it */ } -static struct syscore_ops alchemy_pci_pmops = { - .suspend = alchemy_pci_suspend, - .resume = alchemy_pci_resume, +static const struct syscore_ops alchemy_pci_syscore_ops = { + .suspend = alchemy_pci_suspend, + .resume = alchemy_pci_resume, +}; + +static struct syscore alchemy_pci_syscore = { + .ops = &alchemy_pci_syscore_ops, };static int alchemy_pci_probe (struct platform_device *pdev)
@@ -478,7 +482,7 @@ static int alchemy_pci_probe(struct platform_device *pdev) __alchemy_pci_ctx = ctx;platform_set_drvdata (pdev, ctx); -register_syscore_ops (&alchemy_pci_pmops); +register_syscore (&alchemy_pci_syscore);register_pci_controller (&ctx->alchemy_pci_ctrl); dev_info(&pdev->dev, "PCI controller at %ld MHz\n",
arch/powerpc/platforms/cell/spu_base.c +7 -3
@@ -726,7 +726,7 @@ static inline void crash_register_spus(struct list_head *list) }#endif -static void spu_shutdown (void ) +static void spu_shutdown (void *data) {struct spu *spu;
@@ -738,10 +738,14 @@ static void spu_shutdown(void)mutex_unlock (&spu_full_list_mutex); } -static struct syscore_ops spu_syscore_ops = { +static const struct syscore_ops spu_syscore_ops = { .shutdown = spu_shutdown, }; +static struct syscore spu_syscore = { + .ops = &spu_syscore_ops, +}; +static int __init init_spu_base (void ) {int i, ret =0 ;
@@ -774,7 +778,7 @@ static int __init init_spu_base(void)crash_register_spus (&spu_full_list);mutex_unlock (&spu_full_list_mutex);spu_add_dev_attr (&dev_attr_stat); -register_syscore_ops (&spu_syscore_ops); +register_syscore (&spu_syscore);spu_init_affinity ();
arch/powerpc/platforms/powermac/pic.c +8 -4
@@ -600,7 +600,7 @@ static int pmacpic_find_viaint(void)return viaint; } -static int pmacpic_suspend (void ) +static int pmacpic_suspend (void *data) {int viaint =pmacpic_find_viaint ();
@@ -621,7 +621,7 @@ static int pmacpic_suspend(void)return 0 ; } -static void pmacpic_resume (void ) +static void pmacpic_resume (void *data) {int i;
@@ -634,15 +634,19 @@ static void pmacpic_resume(void)pmac_unmask_irq (irq_get_irq_data (i)); } -static struct syscore_ops pmacpic_syscore_ops = { +static const struct syscore_ops pmacpic_syscore_ops = { .suspend = pmacpic_suspend, .resume = pmacpic_resume, }; +static struct syscore pmacpic_syscore = { + .ops = &pmacpic_syscore_ops, +}; +static int __init init_pmacpic_syscore (void ) {if (pmac_irq_hw[0 ]) -register_syscore_ops (&pmacpic_syscore_ops); +register_syscore (&pmacpic_syscore);return 0 ; }
arch/powerpc/sysdev/fsl_lbc.c +8 -4
@@ -350,7 +350,7 @@ static int fsl_lbc_ctrl_probe(struct platform_device *dev)#ifdef CONFIG_SUSPEND /* save lbc registers */ -static int fsl_lbc_syscore_suspend (void ) +static int fsl_lbc_syscore_suspend (void *data) {struct fsl_lbc_ctrl *ctrl;struct fsl_lbc_regs __iomem *lbc;
@@ -374,7 +374,7 @@ static int fsl_lbc_syscore_suspend(void) }/* restore lbc registers */ -static void fsl_lbc_syscore_resume (void ) +static void fsl_lbc_syscore_resume (void *data) {struct fsl_lbc_ctrl *ctrl;struct fsl_lbc_regs __iomem *lbc;
@@ -408,10 +408,14 @@ static const struct of_device_id fsl_lbc_match[] = { };#ifdef CONFIG_SUSPEND -static struct syscore_ops lbc_syscore_pm_ops = { +static const struct syscore_ops lbc_syscore_pm_ops = { .suspend = fsl_lbc_syscore_suspend, .resume = fsl_lbc_syscore_resume, }; + +static struct syscore lbc_syscore_pm = { + .ops = &lbc_syscore_pm_ops, +};#endif static struct platform_driver fsl_lbc_ctrl_driver = {
@@ -425,7 +429,7 @@ static struct platform_driver fsl_lbc_ctrl_driver = {static int __init fsl_lbc_init (void ) {#ifdef CONFIG_SUSPEND -register_syscore_ops (&lbc_syscore_pm_ops); +register_syscore (&lbc_syscore_pm);#endif return platform_driver_register (&fsl_lbc_ctrl_driver); }
arch/powerpc/sysdev/fsl_pci.c +8 -4
@@ -1258,7 +1258,7 @@ static void fsl_pci_syscore_do_suspend(struct pci_controller *hose)send_pme_turnoff_message (hose); } -static int fsl_pci_syscore_suspend (void ) +static int fsl_pci_syscore_suspend (void *data) {struct pci_controller *hose, *tmp;
@@ -1291,7 +1291,7 @@ static void fsl_pci_syscore_do_resume(struct pci_controller *hose)setup_pci_atmu (hose); } -static void fsl_pci_syscore_resume (void ) +static void fsl_pci_syscore_resume (void *data) {struct pci_controller *hose, *tmp;
@@ -1299,10 +1299,14 @@ static void fsl_pci_syscore_resume(void) fsl_pci_syscore_do_resume(hose); } -static struct syscore_ops pci_syscore_pm_ops = { +static const struct syscore_ops pci_syscore_pm_ops = { .suspend = fsl_pci_syscore_suspend, .resume = fsl_pci_syscore_resume, }; + +static struct syscore pci_syscore_pm = { + .ops = &pci_syscore_pm_ops, +};#endif void fsl_pcibios_fixup_phb (struct pci_controller *phb)
@@ -1359,7 +1363,7 @@ static struct platform_driver fsl_pci_driver = {static int __init fsl_pci_init (void ) {#ifdef CONFIG_PM_SLEEP -register_syscore_ops (&pci_syscore_pm_ops); +register_syscore (&pci_syscore_pm);#endif return platform_driver_register (&fsl_pci_driver); }
arch/powerpc/sysdev/ipic.c +8 -4
@@ -817,7 +817,7 @@ static struct {u32 sercr; } ipic_saved_state; -static int ipic_suspend (void ) +static int ipic_suspend (void *data) {struct ipic *ipic = primary_ipic;
@@ -848,7 +848,7 @@ static int ipic_suspend(void)return 0 ; } -static void ipic_resume (void ) +static void ipic_resume (void *data) {struct ipic *ipic = primary_ipic;
@@ -870,18 +870,22 @@ static void ipic_resume(void)#define ipic_resume NULL#endif -static struct syscore_ops ipic_syscore_ops = { +static const struct syscore_ops ipic_syscore_ops = { .suspend = ipic_suspend, .resume = ipic_resume, }; +static struct syscore ipic_syscore = { + .ops = &ipic_syscore_ops, +}; +static int __init init_ipic_syscore (void ) {if (!primary_ipic || !primary_ipic->regs)return -ENODEV ;printk (KERN_DEBUG "Registering ipic system core operations\n" ); -register_syscore_ops (&ipic_syscore_ops); +register_syscore (&ipic_syscore);return 0 ; }
arch/powerpc/sysdev/mpic.c +9 -5
@@ -1944,7 +1944,7 @@ static void mpic_suspend_one(struct mpic *mpic) } } -static int mpic_suspend (void ) +static int mpic_suspend (void *data) {struct mpic *mpic = mpics;
@@ -1986,7 +1986,7 @@ static void mpic_resume_one(struct mpic *mpic) }/* end for loop */ } -static void mpic_resume (void ) +static void mpic_resume (void *data) {struct mpic *mpic = mpics;
@@ -1996,19 +1996,23 @@ static void mpic_resume(void) } } -static struct syscore_ops mpic_syscore_ops = { +static const struct syscore_ops mpic_syscore_ops = { .resume = mpic_resume, .suspend = mpic_suspend, }; +static struct syscore mpic_syscore = { + .ops = &mpic_syscore_ops, +}; +static int mpic_init_sys (void ) {int rc; -register_syscore_ops (&mpic_syscore_ops); +register_syscore (&mpic_syscore); rc =subsys_system_register (&mpic_subsys,NULL );if (rc) { -unregister_syscore_ops (&mpic_syscore_ops); +unregister_syscore (&mpic_syscore);pr_err ("mpic: Failed to register subsystem!\n" );return rc; }
arch/powerpc/sysdev/mpic_timer.c +7 -3
@@ -519,7 +519,7 @@ static void __init timer_group_init(struct device_node *np)kfree (priv); } -static void mpic_timer_resume (void ) +static void mpic_timer_resume (void *data) {struct timer_group_priv *priv;
@@ -535,10 +535,14 @@ static const struct of_device_id mpic_timer_ids[] = { {}, }; -static struct syscore_ops mpic_timer_syscore_ops = { +static const struct syscore_ops mpic_timer_syscore_ops = { .resume = mpic_timer_resume, }; +static struct syscore mpic_timer_syscore = { + .ops = &mpic_timer_syscore_ops, +}; +static int __init mpic_timer_init (void ) {struct device_node *np =NULL ;
@@ -546,7 +550,7 @@ static int __init mpic_timer_init(void)for_each_matching_node (np, mpic_timer_ids)timer_group_init (np); -register_syscore_ops (&mpic_timer_syscore_ops); +register_syscore (&mpic_timer_syscore);if (list_empty (&timer_group_list))return -ENODEV ;
arch/sh/mm/pmb.c +7 -3
@@ -857,7 +857,7 @@ static int __init pmb_debugfs_init(void)subsys_initcall (pmb_debugfs_init);#ifdef CONFIG_PM -static void pmb_syscore_resume (void ) +static void pmb_syscore_resume (void *data) {struct pmb_entry *pmbe;int i;
@@ -874,13 +874,17 @@ static void pmb_syscore_resume(void)read_unlock (&pmb_rwlock); } -static struct syscore_ops pmb_syscore_ops = { +static const struct syscore_ops pmb_syscore_ops = { .resume = pmb_syscore_resume, }; +static struct syscore pmb_syscore = { + .ops = &pmb_syscore_ops, +}; +static int __init pmb_sysdev_init (void ) { -register_syscore_ops (&pmb_syscore_ops); +register_syscore (&pmb_syscore);return 0 ; }subsys_initcall (pmb_sysdev_init);
arch/x86/events/amd/ibs.c +8 -4
@@ -1719,26 +1719,30 @@ static int x86_pmu_amd_ibs_starting_cpu(unsigned int cpu)#ifdef CONFIG_PM -static int perf_ibs_suspend (void ) +static int perf_ibs_suspend (void *data) {clear_APIC_ibs ();return 0 ; } -static void perf_ibs_resume (void ) +static void perf_ibs_resume (void *data) {ibs_eilvt_setup ();setup_APIC_ibs (); } -static struct syscore_ops perf_ibs_syscore_ops = { +static const struct syscore_ops perf_ibs_syscore_ops = { .resume = perf_ibs_resume, .suspend = perf_ibs_suspend, }; +static struct syscore perf_ibs_syscore = { + .ops = &perf_ibs_syscore_ops, +}; +static void perf_ibs_pm_init (void ) { -register_syscore_ops (&perf_ibs_syscore_ops); +register_syscore (&perf_ibs_syscore); }#else
arch/x86/hyperv/hv_init.c +8 -4
@@ -351,7 +351,7 @@ static int __init hv_pci_init(void)return 1 ; } -static int hv_suspend (void ) +static int hv_suspend (void *data) {union hv_x64_msr_hypercall_contents hypercall_msr;int ret;
@@ -378,7 +378,7 @@ static int hv_suspend(void)return ret; } -static void hv_resume (void ) +static void hv_resume (void *data) {union hv_x64_msr_hypercall_contents hypercall_msr;int ret;
@@ -405,11 +405,15 @@ static void hv_resume(void) }/* Note: when the ops are called, only CPU0 is online and IRQs are disabled. */ -static struct syscore_ops hv_syscore_ops = { +static const struct syscore_ops hv_syscore_ops = { .suspend = hv_suspend, .resume = hv_resume, }; +static struct syscore hv_syscore = { + .ops = &hv_syscore_ops, +}; +static void (*__initdata old_setup_percpu_clockev)(void );static void __init hv_stimer_setup_percpu_clockev (void )
@@ -569,7 +573,7 @@ void __init hyperv_init(void) x86_init.pci.arch_init = hv_pci_init; -register_syscore_ops (&hv_syscore_ops); +register_syscore (&hv_syscore);if (ms_hyperv.priv_high &HV_ACCESS_PARTITION_ID )hv_get_partition_id ();
arch/x86/kernel/amd_gart_64.c +7 -3
@@ -591,7 +591,7 @@ static void gart_fixup_northbridges(void) } } -static void gart_resume (void ) +static void gart_resume (void *data) {pr_info ("PCI-DMA: Resuming GART IOMMU\n" );
@@ -600,11 +600,15 @@ static void gart_resume(void)enable_gart_translations (); } -static struct syscore_ops gart_syscore_ops = { +static const struct syscore_ops gart_syscore_ops = { .resume = gart_resume, }; +static struct syscore gart_syscore = { + .ops = &gart_syscore_ops, +}; +/* * Private Northbridge GATT initialization in case we cannot use the * AGP driver for some reason.
@@ -650,7 +654,7 @@ static __init int init_amd_gatt(struct agp_kern_info *info) agp_gatt_table = gatt; -register_syscore_ops (&gart_syscore_ops); +register_syscore (&gart_syscore);flush_gart ();
arch/x86/kernel/apic/apic.c +8 -4
@@ -2382,7 +2382,7 @@ static struct {unsigned int apic_cmci; } apic_pm_state; -static int lapic_suspend (void ) +static int lapic_suspend (void *data) {unsigned long flags;int maxlvt;
@@ -2430,7 +2430,7 @@ static int lapic_suspend(void)return 0 ; } -static void lapic_resume (void ) +static void lapic_resume (void *data) {unsigned int l, h;unsigned long flags;
@@ -2510,11 +2510,15 @@ static void lapic_resume(void)* are needed on every CPU up until machine_halt/restart/poweroff. */ -static struct syscore_ops lapic_syscore_ops = { +static const struct syscore_ops lapic_syscore_ops = { .resume = lapic_resume, .suspend = lapic_suspend, }; +static struct syscore lapic_syscore = { + .ops = &lapic_syscore_ops, +}; +static void apic_pm_activate (void ) { apic_pm_state.active =1 ;
@@ -2524,7 +2528,7 @@ static int __init init_lapic_sysfs(void) {/* XXX: remove suspend/resume procs if !apic_pm_state.active? */ if (boot_cpu_has (X86_FEATURE_APIC )) -register_syscore_ops (&lapic_syscore_ops); +register_syscore (&lapic_syscore);return 0 ; }
arch/x86/kernel/apic/io_apic.c +13 -4
@@ -2308,7 +2308,12 @@ static void resume_ioapic_id(int ioapic_idx) } } -static void ioapic_resume (void ) +static int ioapic_suspend (void *data) +{ +return save_ioapic_entries (); +} + +static void ioapic_resume (void *data) {int ioapic_idx;
@@ -2318,14 +2323,18 @@ static void ioapic_resume(void)restore_ioapic_entries (); } -static struct syscore_ops ioapic_syscore_ops = { - .suspend = save_ioapic_entries, +static const struct syscore_ops ioapic_syscore_ops = { + .suspend = ioapic_suspend, .resume = ioapic_resume, }; +static struct syscore ioapic_syscore = { + .ops = &ioapic_syscore_ops, +}; +static int __init ioapic_init_ops (void ) { -register_syscore_ops (&ioapic_syscore_ops); +register_syscore (&ioapic_syscore);return 0 ; }
arch/x86/kernel/cpu/aperfmperf.c +12 -8
@@ -37,7 +37,7 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct aperfmperf, cpu_samples) = { .seq = SEQCNT_ZERO(cpu_samples.seq) }; -static void init_counter_refs (void ) +static void init_counter_refs (void *data) {u64 aperf, mperf;
@@ -289,16 +289,20 @@ static bool __init intel_set_max_freq_ratio(void) }#ifdef CONFIG_PM_SLEEP -static struct syscore_ops freq_invariance_syscore_ops = { +static const struct syscore_ops freq_invariance_syscore_ops = { .resume = init_counter_refs, }; -static void register_freq_invariance_syscore_ops (void ) +static struct syscore freq_invariance_syscore = { + .ops = &freq_invariance_syscore_ops, +}; + +static void register_freq_invariance_syscore (void ) { -register_syscore_ops (&freq_invariance_syscore_ops); +register_syscore (&freq_invariance_syscore); }#else -static inline void register_freq_invariance_syscore_ops (void ) {} +static inline void register_freq_invariance_syscore (void ) {}#endif static void freq_invariance_enable (void )
@@ -308,7 +312,7 @@ static void freq_invariance_enable(void)return ; }static_branch_enable_cpuslocked (&arch_scale_freq_key); -register_freq_invariance_syscore_ops (); +register_freq_invariance_syscore ();pr_info ("Estimated ratio of average max frequency by base frequency (times 1024): %llu\n" , arch_max_freq_ratio); }
@@ -535,7 +539,7 @@ static int __init bp_init_aperfmperf(void)if (!cpu_feature_enabled (X86_FEATURE_APERFMPERF ))return 0 ; -init_counter_refs (); +init_counter_refs (NULL );bp_init_freq_invariance ();return 0 ; }
@@ -544,5 +548,5 @@ early_initcall(bp_init_aperfmperf);void ap_init_aperfmperf (void ) {if (cpu_feature_enabled (X86_FEATURE_APERFMPERF )) -init_counter_refs (); +init_counter_refs (NULL ); }
arch/x86/kernel/cpu/intel_epb.c +10 -6
@@ -75,7 +75,7 @@ static u8 energ_perf_values[] = { [EPB_INDEX_POWERSAVE] = ENERGY_PERF_BIAS_POWERSAVE, }; -static int intel_epb_save (void ) +static int intel_epb_save (void *data) {u64 epb;
@@ -89,7 +89,7 @@ static int intel_epb_save(void)return 0 ; } -static void intel_epb_restore (void ) +static void intel_epb_restore (void *data) {u64 val =this_cpu_read (saved_epb);u64 epb;
@@ -114,11 +114,15 @@ static void intel_epb_restore(void)wrmsrq (MSR_IA32_ENERGY_PERF_BIAS , (epb & ~EPB_MASK ) | val); } -static struct syscore_ops intel_epb_syscore_ops = { +static const struct syscore_ops intel_epb_syscore_ops = { .suspend = intel_epb_save, .resume = intel_epb_restore, }; +static struct syscore intel_epb_syscore = { + .ops = &intel_epb_syscore_ops, +}; +static const char *const energy_perf_strings[] = { [EPB_INDEX_PERFORMANCE ] ="performance" , [EPB_INDEX_BALANCE_PERFORMANCE ] ="balance-performance" ,
@@ -185,7 +189,7 @@ static int intel_epb_online(unsigned int cpu) {struct device *cpu_dev =get_cpu_device (cpu); -intel_epb_restore (); +intel_epb_restore (NULL );if (!cpuhp_tasks_frozen)sysfs_merge_group (&cpu_dev->kobj, &intel_epb_attr_group);
@@ -199,7 +203,7 @@ static int intel_epb_offline(unsigned int cpu)if (!cpuhp_tasks_frozen)sysfs_unmerge_group (&cpu_dev->kobj, &intel_epb_attr_group); -intel_epb_save (); +intel_epb_save (NULL );return 0 ; }
@@ -230,7 +234,7 @@ static __init int intel_epb_init(void)if (ret <0 ) goto err_out_online; -register_syscore_ops (&intel_epb_syscore_ops); +register_syscore (&intel_epb_syscore);return 0 ; err_out_online:
arch/x86/kernel/cpu/mce/core.c +9 -5
@@ -2387,13 +2387,13 @@ static void vendor_disable_error_reporting(void)mce_disable_error_reporting (); } -static int mce_syscore_suspend (void ) +static int mce_syscore_suspend (void *data) {vendor_disable_error_reporting ();return 0 ; } -static void mce_syscore_shutdown (void ) +static void mce_syscore_shutdown (void *data) {vendor_disable_error_reporting (); }
@@ -2403,7 +2403,7 @@ static void mce_syscore_shutdown(void)* Only one CPU is active at this time, the others get re-added later using * CPU hotplug: */ -static void mce_syscore_resume (void ) +static void mce_syscore_resume (void *data) {__mcheck_cpu_init_generic ();__mcheck_cpu_init_vendor (raw_cpu_ptr (&cpu_info));
@@ -2411,12 +2411,16 @@ static void mce_syscore_resume(void)cr4_set_bits (X86_CR4_MCE ); } -static struct syscore_ops mce_syscore_ops = { +static const struct syscore_ops mce_syscore_ops = { .suspend = mce_syscore_suspend, .shutdown = mce_syscore_shutdown, .resume = mce_syscore_resume, }; +static struct syscore mce_syscore = { + .ops = &mce_syscore_ops, +}; +/* * mce_device: Sysfs support */
@@ -2817,7 +2821,7 @@ static __init int mcheck_init_device(void)if (err <0 ) goto err_out_online; -register_syscore_ops (&mce_syscore_ops); +register_syscore (&mce_syscore);return 0 ;
arch/x86/kernel/cpu/microcode/core.c +12 -3
@@ -812,8 +812,17 @@ void microcode_bsp_resume(void)reload_early_microcode (cpu); } -static struct syscore_ops mc_syscore_ops = { - .resume = microcode_bsp_resume, +static void microcode_bsp_syscore_resume (void *data) +{ +microcode_bsp_resume (); +} + +static const struct syscore_ops mc_syscore_ops = { + .resume = microcode_bsp_syscore_resume, +}; + +static struct syscore mc_syscore = { + .ops = &mc_syscore_ops, };static int mc_cpu_online (unsigned int cpu)
@@ -892,7 +901,7 @@ static int __init microcode_init(void) } } -register_syscore_ops (&mc_syscore_ops); +register_syscore (&mc_syscore);cpuhp_setup_state (CPUHP_AP_ONLINE_DYN ,"x86/microcode:online" , mc_cpu_online, mc_cpu_down_prep);
arch/x86/kernel/cpu/mtrr/legacy.c +8 -4
@@ -41,7 +41,7 @@ struct mtrr_value {static struct mtrr_value *mtrr_value; -static int mtrr_save (void ) +static int mtrr_save (void *data) {int i;
@@ -56,7 +56,7 @@ static int mtrr_save(void)return 0 ; } -static void mtrr_restore (void ) +static void mtrr_restore (void *data) {int i;
@@ -69,11 +69,15 @@ static void mtrr_restore(void) } } -static struct syscore_ops mtrr_syscore_ops = { +static const struct syscore_ops mtrr_syscore_ops = { .suspend = mtrr_save, .resume = mtrr_restore, }; +static struct syscore mtrr_syscore = { + .ops = &mtrr_syscore_ops, +}; +void mtrr_register_syscore (void ) { mtrr_value =kcalloc (num_var_ranges,sizeof (*mtrr_value),GFP_KERNEL );
@@ -86,5 +90,5 @@ void mtrr_register_syscore(void)* TBD: is there any system with such CPU which supports * suspend/resume? If no, we should remove the code. */ -register_syscore_ops (&mtrr_syscore_ops); +register_syscore (&mtrr_syscore); }
arch/x86/kernel/cpu/umwait.c +7 -3
@@ -86,15 +86,19 @@ static int umwait_cpu_offline(unsigned int cpu)* trust the firmware nor does it matter if the same value is written * again. */ -static void umwait_syscore_resume (void ) +static void umwait_syscore_resume (void *data) {umwait_update_control_msr (NULL ); } -static struct syscore_ops umwait_syscore_ops = { +static const struct syscore_ops umwait_syscore_ops = { .resume = umwait_syscore_resume, }; +static struct syscore umwait_syscore = { + .ops = &umwait_syscore_ops, +}; +/* sysfs interface */ /*
@@ -226,7 +230,7 @@ static int __init umwait_init(void)return ret; } -register_syscore_ops (&umwait_syscore_ops); +register_syscore (&umwait_syscore);/* * Add umwait control interface. Ignore failure, so at least the
arch/x86/kernel/i8237.c +7 -3
@@ -19,7 +19,7 @@* in asm/dma.h. */ -static void i8237A_resume (void ) +static void i8237A_resume (void *data) {unsigned long flags;int i;
@@ -41,10 +41,14 @@ static void i8237A_resume(void)release_dma_lock (flags); } -static struct syscore_ops i8237_syscore_ops = { +static const struct syscore_ops i8237_syscore_ops = { .resume = i8237A_resume, }; +static struct syscore i8237_syscore = { + .ops = &i8237_syscore_ops, +}; +static int __init i8237A_init_ops (void ) {/*
@@ -70,7 +74,7 @@ static int __init i8237A_init_ops(void)if (x86_pnpbios_disabled () &&dmi_get_bios_year () >=2017 )return -ENODEV ; -register_syscore_ops (&i8237_syscore_ops); +register_syscore (&i8237_syscore);return 0 ; }device_initcall (i8237A_init_ops);
arch/x86/kernel/i8259.c +9 -5
@@ -247,19 +247,19 @@ static void save_ELCR(char *trigger) trigger[1 ] =inb (PIC_ELCR2 ) &0xDE ; } -static void i8259A_resume (void ) +static void i8259A_resume (void *data) {init_8259A (i8259A_auto_eoi);restore_ELCR (irq_trigger); } -static int i8259A_suspend (void ) +static int i8259A_suspend (void *data) {save_ELCR (irq_trigger);return 0 ; } -static void i8259A_shutdown (void ) +static void i8259A_shutdown (void *data) {/* Put the i8259A into a quiescent state that * the kernel initialization code can get it
@@ -269,12 +269,16 @@ static void i8259A_shutdown(void)outb (0xff ,PIC_SLAVE_IMR );/* mask all of 8259A-2 */ } -static struct syscore_ops i8259_syscore_ops = { +static const struct syscore_ops i8259_syscore_ops = { .suspend = i8259A_suspend, .resume = i8259A_resume, .shutdown = i8259A_shutdown, }; +static struct syscore i8259_syscore = { + .ops = &i8259_syscore_ops, +}; +static void mask_8259A (void ) {unsigned long flags;
@@ -444,7 +448,7 @@ EXPORT_SYMBOL(legacy_pic);static int __init i8259A_init_ops (void ) {if (legacy_pic == &default_legacy_pic) -register_syscore_ops (&i8259_syscore_ops); +register_syscore (&i8259_syscore);return 0 ; }
arch/x86/kernel/kvm.c +8 -4
@@ -720,7 +720,7 @@ static int kvm_cpu_down_prepare(unsigned int cpu)#endif -static int kvm_suspend (void ) +static int kvm_suspend (void *data) {u64 val =0 ;
@@ -734,7 +734,7 @@ static int kvm_suspend(void)return 0 ; } -static void kvm_resume (void ) +static void kvm_resume (void *data) {kvm_cpu_online (raw_smp_processor_id ());
@@ -744,11 +744,15 @@ static void kvm_resume(void)#endif } -static struct syscore_ops kvm_syscore_ops = { +static const struct syscore_ops kvm_syscore_ops = { .suspend = kvm_suspend, .resume = kvm_resume, }; +static struct syscore kvm_syscore = { + .ops = &kvm_syscore_ops, +}; +static void kvm_pv_guest_cpu_reboot (void *unused) {kvm_guest_cpu_offline (true);
@@ -858,7 +862,7 @@ static void __init kvm_guest_init(void) machine_ops.crash_shutdown = kvm_crash_shutdown;#endif -register_syscore_ops (&kvm_syscore_ops); +register_syscore (&kvm_syscore);/* * Hard lockup detection is enabled by default. Disable it, as guests
drivers/acpi/pci_link.c +7 -3
@@ -761,7 +761,7 @@ static int acpi_pci_link_resume(struct acpi_pci_link *link)return 0 ; } -static void irqrouter_resume (void ) +static void irqrouter_resume (void *data) {struct acpi_pci_link *link;
@@ -888,10 +888,14 @@ static int __init acpi_irq_balance_set(char *str)__setup ("acpi_irq_balance" , acpi_irq_balance_set); -static struct syscore_ops irqrouter_syscore_ops = { +static const struct syscore_ops irqrouter_syscore_ops = { .resume = irqrouter_resume, }; +static struct syscore irqrouter_syscore = { + .ops = &irqrouter_syscore_ops, +}; +void __init acpi_pci_link_init (void ) {if (acpi_noirq)
@@ -904,6 +908,6 @@ void __init acpi_pci_link_init(void)else acpi_irq_balance =0 ; } -register_syscore_ops (&irqrouter_syscore_ops); +register_syscore (&irqrouter_syscore);acpi_scan_add_handler (&pci_link_handler); }
drivers/acpi/sleep.c +8 -4
@@ -892,13 +892,13 @@ bool acpi_s2idle_wakeup(void)#ifdef CONFIG_PM_SLEEP static u32 saved_bm_rld; -static int acpi_save_bm_rld (void ) +static int acpi_save_bm_rld (void *data) {acpi_read_bit_register (ACPI_BITREG_BUS_MASTER_RLD , &saved_bm_rld);return 0 ; } -static void acpi_restore_bm_rld (void ) +static void acpi_restore_bm_rld (void *data) {u32 resumed_bm_rld =0 ;
@@ -909,14 +909,18 @@ static void acpi_restore_bm_rld(void) acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); } -static struct syscore_ops acpi_sleep_syscore_ops = { +static const struct syscore_ops acpi_sleep_syscore_ops = { .suspend = acpi_save_bm_rld, .resume = acpi_restore_bm_rld, }; +static struct syscore acpi_sleep_syscore = { + .ops = &acpi_sleep_syscore_ops, +}; +static void acpi_sleep_syscore_init (void ) { -register_syscore_ops (&acpi_sleep_syscore_ops); +register_syscore (&acpi_sleep_syscore); }#else static inline void acpi_sleep_syscore_init (void ) {}
drivers/base/firmware_loader/main.c +8 -4
@@ -1646,16 +1646,20 @@ static int fw_pm_notify(struct notifier_block *notify_block, }/* stop caching firmware once syscore_suspend is reached */ -static int fw_suspend (void ) +static int fw_suspend (void *data) { fw_cache.state =FW_LOADER_NO_CACHE ;return 0 ; } -static struct syscore_ops fw_syscore_ops = { +static const struct syscore_ops fw_syscore_ops = { .suspend = fw_suspend, }; +static struct syscore fw_syscore = { + .ops = &fw_syscore_ops, +}; +static int __init register_fw_pm_ops (void ) {int ret;
@@ -1671,14 +1675,14 @@ static int __init register_fw_pm_ops(void)if (ret)return ret; -register_syscore_ops (&fw_syscore_ops); +register_syscore (&fw_syscore); return ret; }static inline void unregister_fw_pm_ops (void ) { -unregister_syscore_ops (&fw_syscore_ops); +unregister_syscore (&fw_syscore);unregister_pm_notifier (&fw_cache.pm_notify); }#else
drivers/base/syscore.c +43 -39
141 lines not on this page · raw message
drivers/bus/mvebu-mbus.c +10 -6
@@ -1006,7 +1006,7 @@ static __init int mvebu_mbus_debugfs_init(void) }fs_initcall (mvebu_mbus_debugfs_init); -static int mvebu_mbus_suspend (void ) +static int mvebu_mbus_suspend (void *data) {struct mvebu_mbus_state *s = &mbus_state;int win;
@@ -1040,7 +1040,7 @@ static int mvebu_mbus_suspend(void)return 0 ; } -static void mvebu_mbus_resume (void ) +static void mvebu_mbus_resume (void *data) {struct mvebu_mbus_state *s = &mbus_state;int win;
@@ -1069,9 +1069,13 @@ static void mvebu_mbus_resume(void) } } -static struct syscore_ops mvebu_mbus_syscore_ops = { - .suspend = mvebu_mbus_suspend, - .resume = mvebu_mbus_resume, +static const struct syscore_ops mvebu_mbus_syscore_ops = { + .suspend = mvebu_mbus_suspend, + .resume = mvebu_mbus_resume, +}; + +static struct syscore mvebu_mbus_syscore = { + .ops = &mvebu_mbus_syscore_ops, }; static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus,
@@ -1118,7 +1122,7 @@ static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus,writel (UNIT_SYNC_BARRIER_ALL , mbus->mbuswins_base +UNIT_SYNC_BARRIER_OFF ); -register_syscore_ops (&mvebu_mbus_syscore_ops); +register_syscore (&mvebu_mbus_syscore);return 0 ; }
drivers/clk/at91/pmc.c +8 -4
@@ -115,7 +115,7 @@ struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,/* Address in SECURAM that say if we suspend to backup mode. */ static void __iomem *at91_pmc_backup_suspend; -static int at91_pmc_suspend (void ) +static int at91_pmc_suspend (void *data) {unsigned int backup;
@@ -129,7 +129,7 @@ static int at91_pmc_suspend(void)return clk_save_context (); } -static void at91_pmc_resume (void ) +static void at91_pmc_resume (void *data) {unsigned int backup;
@@ -143,11 +143,15 @@ static void at91_pmc_resume(void)clk_restore_context (); } -static struct syscore_ops pmc_syscore_ops = { +static const struct syscore_ops pmc_syscore_ops = { .suspend = at91_pmc_suspend, .resume = at91_pmc_resume, }; +static struct syscore pmc_syscore = { + .ops = &pmc_syscore_ops, +}; +static const struct of_device_id pmc_dt_ids[] = { { .compatible ="atmel,sama5d2-pmc" }, { .compatible ="microchip,sama7g5-pmc" , },
@@ -185,7 +189,7 @@ static int __init pmc_register_ops(void)return -ENOMEM ; } -register_syscore_ops (&pmc_syscore_ops); +register_syscore (&pmc_syscore);return 0 ; }
drivers/clk/imx/clk-vf610.c +8 -4
@@ -139,7 +139,7 @@ static struct clk * __init vf610_get_fixed_clock(return clk; }; -static int vf610_clk_suspend (void ) +static int vf610_clk_suspend (void *data) {int i;
@@ -156,7 +156,7 @@ static int vf610_clk_suspend(void)return 0 ; } -static void vf610_clk_resume (void ) +static void vf610_clk_resume (void *data) {int i;
@@ -171,11 +171,15 @@ static void vf610_clk_resume(void)writel_relaxed (ccgr[i],CCM_CCGRx (i)); } -static struct syscore_ops vf610_clk_syscore_ops = { +static const struct syscore_ops vf610_clk_syscore_ops = { .suspend = vf610_clk_suspend, .resume = vf610_clk_resume, }; +static struct syscore vf610_clk_syscore = { + .ops = &vf610_clk_syscore_ops, +}; +static void __init vf610_clocks_init (struct device_node *ccm_node) {struct device_node *np;
@@ -462,7 +466,7 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)for (i =0 ; i <ARRAY_SIZE (clks_init_on); i++)clk_prepare_enable (clk[clks_init_on[i]]); -register_syscore_ops (&vf610_clk_syscore_ops); +register_syscore (&vf610_clk_syscore);/* Add the clocks to provider list */ clk_data.clks = clk;
drivers/clk/ingenic/jz4725b-cgu.c +1 -1
@@ -268,6 +268,6 @@ static void __init jz4725b_cgu_init(struct device_node *np)if (retval)pr_err ("%s: failed to register CGU Clocks\n" , __func__); -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }CLK_OF_DECLARE_DRIVER (jz4725b_cgu,"ingenic,jz4725b-cgu" , jz4725b_cgu_init);
drivers/clk/ingenic/jz4740-cgu.c +1 -1
@@ -266,6 +266,6 @@ static void __init jz4740_cgu_init(struct device_node *np)if (retval)pr_err ("%s: failed to register CGU Clocks\n" , __func__); -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }CLK_OF_DECLARE_DRIVER (jz4740_cgu,"ingenic,jz4740-cgu" , jz4740_cgu_init);
drivers/clk/ingenic/jz4755-cgu.c +1 -1
@@ -337,7 +337,7 @@ static void __init jz4755_cgu_init(struct device_node *np)if (retval)pr_err ("%s: failed to register CGU Clocks\n" , __func__); -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }/* * CGU has some children devices, this is useful for probing children devices
drivers/clk/ingenic/jz4760-cgu.c +1 -1
@@ -436,7 +436,7 @@ static void __init jz4760_cgu_init(struct device_node *np)if (retval)pr_err ("%s: failed to register CGU Clocks\n" , __func__); -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }/* We only probe via devicetree, no need for a platform driver */
drivers/clk/ingenic/jz4770-cgu.c +1 -1
@@ -456,7 +456,7 @@ static void __init jz4770_cgu_init(struct device_node *np)if (retval)pr_err ("%s: failed to register CGU Clocks\n" , __func__); -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }/* We only probe via devicetree, no need for a platform driver */
drivers/clk/ingenic/jz4780-cgu.c +1 -1
@@ -803,6 +803,6 @@ static void __init jz4780_cgu_init(struct device_node *np)return ; } -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }CLK_OF_DECLARE_DRIVER (jz4780_cgu,"ingenic,jz4780-cgu" , jz4780_cgu_init);
drivers/clk/ingenic/pm.c +9 -5
@@ -15,7 +15,7 @@static void __iomem *__maybe_unused ingenic_cgu_base; -static int __maybe_unused ingenic_cgu_pm_suspend (void ) +static int __maybe_unused ingenic_cgu_pm_suspend (void *data) {u32 val =readl (ingenic_cgu_base +CGU_REG_LCR );
@@ -24,22 +24,26 @@ static int __maybe_unused ingenic_cgu_pm_suspend(void)return 0 ; } -static void __maybe_unused ingenic_cgu_pm_resume (void ) +static void __maybe_unused ingenic_cgu_pm_resume (void *data) {u32 val =readl (ingenic_cgu_base +CGU_REG_LCR );writel (val & ~LCR_LOW_POWER_MODE , ingenic_cgu_base +CGU_REG_LCR ); } -static struct syscore_ops __maybe_unused ingenic_cgu_pm_ops = { +static const struct syscore_ops __maybe_unused ingenic_cgu_pm_ops = { .suspend = ingenic_cgu_pm_suspend, .resume = ingenic_cgu_pm_resume, }; -void ingenic_cgu_register_syscore_ops (struct ingenic_cgu *cgu) +static struct syscore __maybe_unused ingenic_cgu_pm = { + .ops = &ingenic_cgu_pm_ops, +}; + +void ingenic_cgu_register_syscore (struct ingenic_cgu *cgu) {if (IS_ENABLED (CONFIG_PM_SLEEP )) { ingenic_cgu_base = cgu->base; -register_syscore_ops (&ingenic_cgu_pm_ops); +register_syscore (&ingenic_cgu_pm); } }
drivers/clk/ingenic/pm.h +1 -1
@@ -7,6 +7,6 @@struct ingenic_cgu ; -void ingenic_cgu_register_syscore_ops (struct ingenic_cgu *cgu); +void ingenic_cgu_register_syscore (struct ingenic_cgu *cgu);#endif /* DRIVERS_CLK_INGENIC_PM_H */
drivers/clk/ingenic/tcu.c +8 -4
@@ -455,7 +455,7 @@ static int __init ingenic_tcu_probe(struct device_node *np)return ret; } -static int __maybe_unused tcu_pm_suspend (void ) +static int __maybe_unused tcu_pm_suspend (void *data) {struct ingenic_tcu *tcu = ingenic_tcu;
@@ -465,7 +465,7 @@ static int __maybe_unused tcu_pm_suspend(void)return 0 ; } -static void __maybe_unused tcu_pm_resume (void ) +static void __maybe_unused tcu_pm_resume (void *data) {struct ingenic_tcu *tcu = ingenic_tcu;
@@ -473,11 +473,15 @@ static void __maybe_unused tcu_pm_resume(void)clk_enable (tcu->clk); } -static struct syscore_ops __maybe_unused tcu_pm_ops = { +static const struct syscore_ops __maybe_unused tcu_pm_ops = { .suspend = tcu_pm_suspend, .resume = tcu_pm_resume, }; +static struct syscore __maybe_unused tcu_pm = { + .ops = &tcu_pm_ops, +}; +static void __init ingenic_tcu_init (struct device_node *np) {int ret =ingenic_tcu_probe (np);
@@ -486,7 +490,7 @@ static void __init ingenic_tcu_init(struct device_node *np)pr_crit ("Failed to initialize TCU clocks: %d\n" , ret);if (IS_ENABLED (CONFIG_PM_SLEEP )) -register_syscore_ops (&tcu_pm_ops); +register_syscore (&tcu_pm); }CLK_OF_DECLARE_DRIVER (jz4740_cgu,"ingenic,jz4740-tcu" , ingenic_tcu_init);
drivers/clk/ingenic/x1000-cgu.c +1 -1
@@ -556,7 +556,7 @@ static void __init x1000_cgu_init(struct device_node *np)return ; } -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }/* * CGU has some children devices, this is useful for probing children devices
drivers/clk/ingenic/x1830-cgu.c +1 -1
@@ -463,7 +463,7 @@ static void __init x1830_cgu_init(struct device_node *np)return ; } -ingenic_cgu_register_syscore_ops (cgu); +ingenic_cgu_register_syscore (cgu); }/* * CGU has some children devices, this is useful for probing children devices
drivers/clk/mvebu/common.c +8 -4
@@ -215,22 +215,26 @@ static struct clk *clk_gating_get_src(return ERR_PTR (-ENODEV ); } -static int mvebu_clk_gating_suspend (void ) +static int mvebu_clk_gating_suspend (void *data) { ctrl->saved_reg =readl (ctrl->base);return 0 ; } -static void mvebu_clk_gating_resume (void ) +static void mvebu_clk_gating_resume (void *data) {writel (ctrl->saved_reg, ctrl->base); } -static struct syscore_ops clk_gate_syscore_ops = { +static const struct syscore_ops clk_gate_syscore_ops = { .suspend = mvebu_clk_gating_suspend, .resume = mvebu_clk_gating_resume, }; +static struct syscore clk_gate_syscore = { + .ops = &clk_gate_syscore_ops, +}; +void __init mvebu_clk_gating_setup (struct device_node *np,const struct clk_gating_soc_desc *desc) {
@@ -284,7 +288,7 @@ void __init mvebu_clk_gating_setup(struct device_node *np,of_clk_add_provider (np, clk_gating_get_src, ctrl); -register_syscore_ops (&clk_gate_syscore_ops); +register_syscore (&clk_gate_syscore);return ; gates_out:
drivers/clk/rockchip/clk-rk3288.c +8 -4
@@ -871,7 +871,7 @@ static const int rk3288_saved_cru_reg_ids[] = {static u32 rk3288_saved_cru_regs[ARRAY_SIZE (rk3288_saved_cru_reg_ids)]; -static int rk3288_clk_suspend (void ) +static int rk3288_clk_suspend (void *data) {int i, reg_id;
@@ -906,7 +906,7 @@ static int rk3288_clk_suspend(void)return 0 ; } -static void rk3288_clk_resume (void ) +static void rk3288_clk_resume (void *data) {int i, reg_id;
@@ -923,11 +923,15 @@ static void rk3288_clk_shutdown(void)writel_relaxed (0xf3030000 , rk3288_cru_base +RK3288_MODE_CON ); } -static struct syscore_ops rk3288_clk_syscore_ops = { +static const struct syscore_ops rk3288_clk_syscore_ops = { .suspend = rk3288_clk_suspend, .resume = rk3288_clk_resume, }; +static struct syscore rk3288_clk_syscore = { + .ops = &rk3288_clk_syscore_ops, +}; +static void __init rk3288_common_init (struct device_node *np,enum rk3288_variant soc) {
@@ -976,7 +980,7 @@ static void __init rk3288_common_init(struct device_node *np,rockchip_register_restart_notifier (ctx,RK3288_GLB_SRST_FST , rk3288_clk_shutdown); -register_syscore_ops (&rk3288_clk_syscore_ops); +register_syscore (&rk3288_clk_syscore);rockchip_clk_of_add_provider (np, ctx); }
drivers/clk/samsung/clk-s5pv210-audss.c +8 -4
@@ -36,7 +36,7 @@ static unsigned long reg_save[][2] = { {ASS_CLK_GATE, 0}, }; -static int s5pv210_audss_clk_suspend (void ) +static int s5pv210_audss_clk_suspend (void *data) {int i;
@@ -46,7 +46,7 @@ static int s5pv210_audss_clk_suspend(void)return 0 ; } -static void s5pv210_audss_clk_resume (void ) +static void s5pv210_audss_clk_resume (void *data) {int i;
@@ -54,10 +54,14 @@ static void s5pv210_audss_clk_resume(void) writel(reg_save[i][1], reg_base + reg_save[i][0]); } -static struct syscore_ops s5pv210_audss_clk_syscore_ops = { +static const struct syscore_ops s5pv210_audss_clk_syscore_ops = { .suspend = s5pv210_audss_clk_suspend, .resume = s5pv210_audss_clk_resume, }; + +static struct syscore s5pv210_audss_clk_syscore = { + .ops = &s5pv210_audss_clk_syscore_ops, +};#endif /* CONFIG_PM_SLEEP */ /* register s5pv210_audss clocks */
@@ -175,7 +179,7 @@ static int s5pv210_audss_clk_probe(struct platform_device *pdev) }#ifdef CONFIG_PM_SLEEP -register_syscore_ops (&s5pv210_audss_clk_syscore_ops); +register_syscore (&s5pv210_audss_clk_syscore);#endif return 0 ;
drivers/clk/samsung/clk.c +8 -4
@@ -271,7 +271,7 @@ void __init samsung_clk_of_register_fixed_ext(struct samsung_clk_provider *ctx, }#ifdef CONFIG_PM_SLEEP -static int samsung_clk_suspend (void ) +static int samsung_clk_suspend (void *data) {struct samsung_clock_reg_cache *reg_cache;
@@ -284,7 +284,7 @@ static int samsung_clk_suspend(void)return 0 ; } -static void samsung_clk_resume (void ) +static void samsung_clk_resume (void *data) {struct samsung_clock_reg_cache *reg_cache;
@@ -293,11 +293,15 @@ static void samsung_clk_resume(void) reg_cache->rd_num); } -static struct syscore_ops samsung_clk_syscore_ops = { +static const struct syscore_ops samsung_clk_syscore_ops = { .suspend = samsung_clk_suspend, .resume = samsung_clk_resume, }; +static struct syscore samsung_clk_syscore = { + .ops = &samsung_clk_syscore_ops, +}; + void samsung_clk_extended_sleep_init(void __iomem *reg_base, const unsigned long *rdump, unsigned long nr_rdump,
@@ -316,7 +320,7 @@ void samsung_clk_extended_sleep_init(void __iomem *reg_base,panic ("could not allocate register dump storage.\n" );if (list_empty (&clock_reg_cache_list)) -register_syscore_ops (&samsung_clk_syscore_ops); +register_syscore (&samsung_clk_syscore); reg_cache->reg_base = reg_base; reg_cache->rd_num = nr_rdump;
drivers/clk/tegra/clk-tegra210.c +8 -4
@@ -3444,7 +3444,7 @@ static void tegra210_disable_cpu_clock(u32 cpu)static u32 spare_reg_ctx, misc_clk_enb_ctx, clk_msk_arm_ctx;static u32 cpu_softrst_ctx[3 ]; -static int tegra210_clk_suspend (void ) +static int tegra210_clk_suspend (void *data) {unsigned int i;
@@ -3465,7 +3465,7 @@ static int tegra210_clk_suspend(void)return 0 ; } -static void tegra210_clk_resume (void ) +static void tegra210_clk_resume (void *data) {unsigned int i;
@@ -3523,13 +3523,17 @@ static void tegra210_cpu_clock_resume(void) }#endif -static struct syscore_ops tegra_clk_syscore_ops = { +static const struct syscore_ops tegra_clk_syscore_ops = { #ifdef CONFIG_PM_SLEEP .suspend = tegra210_clk_suspend, .resume = tegra210_clk_resume, #endif }; +static struct syscore tegra_clk_syscore = { + .ops = &tegra_clk_syscore_ops, +}; +static struct tegra_cpu_car_ops tegra210_cpu_car_ops = { .wait_for_reset = tegra210_wait_cpu_in_reset, .disable_clock = tegra210_disable_cpu_clock,
@@ -3813,6 +3817,6 @@ static void __init tegra210_clock_init(struct device_node *np) tegra_cpu_car_ops = &tegra210_cpu_car_ops; -register_syscore_ops (&tegra_clk_syscore_ops); +register_syscore (&tegra_clk_syscore); }CLK_OF_DECLARE (tegra210,"nvidia,tegra210-car" , tegra210_clock_init);
drivers/clocksource/timer-armada-370-xp.c +8 -4
@@ -207,14 +207,14 @@ static int armada_370_xp_timer_dying_cpu(unsigned int cpu)static u32 timer0_ctrl_reg, timer0_local_ctrl_reg; -static int armada_370_xp_timer_suspend (void ) +static int armada_370_xp_timer_suspend (void *data) { timer0_ctrl_reg =readl (timer_base +TIMER_CTRL_OFF ); timer0_local_ctrl_reg =readl (local_base +TIMER_CTRL_OFF );return 0 ; } -static void armada_370_xp_timer_resume (void ) +static void armada_370_xp_timer_resume (void *data) {writel (0xffffffff , timer_base +TIMER0_VAL_OFF );writel (0xffffffff , timer_base +TIMER0_RELOAD_OFF );
@@ -222,11 +222,15 @@ static void armada_370_xp_timer_resume(void)writel (timer0_local_ctrl_reg, local_base +TIMER_CTRL_OFF ); } -static struct syscore_ops armada_370_xp_timer_syscore_ops = { +static const struct syscore_ops armada_370_xp_timer_syscore_ops = { .suspend = armada_370_xp_timer_suspend, .resume = armada_370_xp_timer_resume, }; +static struct syscore armada_370_xp_timer_syscore = { + .ops = &armada_370_xp_timer_syscore_ops, +}; +static unsigned long armada_370_delay_timer_read (void ) {return ~readl (timer_base +TIMER0_VAL_OFF );
@@ -324,7 +328,7 @@ static int __init armada_370_xp_timer_common_init(struct device_node *np)return res; } -register_syscore_ops (&armada_370_xp_timer_syscore_ops); +register_syscore (&armada_370_xp_timer_syscore);return 0 ; }
drivers/cpuidle/cpuidle-psci.c +8 -4
@@ -177,26 +177,30 @@ static void psci_idle_syscore_switch(bool suspend) } } -static int psci_idle_syscore_suspend (void ) +static int psci_idle_syscore_suspend (void *data) {psci_idle_syscore_switch (true);return 0 ; } -static void psci_idle_syscore_resume (void ) +static void psci_idle_syscore_resume (void *data) {psci_idle_syscore_switch (false); } -static struct syscore_ops psci_idle_syscore_ops = { +static const struct syscore_ops psci_idle_syscore_ops = { .suspend = psci_idle_syscore_suspend, .resume = psci_idle_syscore_resume, }; +static struct syscore psci_idle_syscore = { + .ops = &psci_idle_syscore_ops, +}; +static void psci_idle_init_syscore (void ) {if (psci_cpuidle_use_syscore) -register_syscore_ops (&psci_idle_syscore_ops); +register_syscore (&psci_idle_syscore); }static void psci_idle_init_cpuhp (void )
drivers/gpio/gpio-mxc.c +8 -4
@@ -675,7 +675,7 @@ static const struct dev_pm_ops mxc_gpio_dev_pm_ops = { RUNTIME_PM_OPS(mxc_gpio_runtime_suspend, mxc_gpio_runtime_resume, NULL) }; -static int mxc_gpio_syscore_suspend (void ) +static int mxc_gpio_syscore_suspend (void *data) {struct mxc_gpio_port *port;int ret;
@@ -692,7 +692,7 @@ static int mxc_gpio_syscore_suspend(void)return 0 ; } -static void mxc_gpio_syscore_resume (void ) +static void mxc_gpio_syscore_resume (void *data) {struct mxc_gpio_port *port;int ret;
@@ -709,11 +709,15 @@ static void mxc_gpio_syscore_resume(void) } } -static struct syscore_ops mxc_gpio_syscore_ops = { +static const struct syscore_ops mxc_gpio_syscore_ops = { .suspend = mxc_gpio_syscore_suspend, .resume = mxc_gpio_syscore_resume, }; +static struct syscore mxc_gpio_syscore = { + .ops = &mxc_gpio_syscore_ops, +}; +static struct platform_driver mxc_gpio_driver = { .driver = { .name ="gpio-mxc" ,
@@ -726,7 +730,7 @@ static struct platform_driver mxc_gpio_driver = {static int __init gpio_mxc_init (void ) { -register_syscore_ops (&mxc_gpio_syscore_ops); +register_syscore (&mxc_gpio_syscore);return platform_driver_register (&mxc_gpio_driver); }
drivers/gpio/gpio-pxa.c +8 -4
@@ -747,7 +747,7 @@ static int __init pxa_gpio_dt_init(void)device_initcall (pxa_gpio_dt_init);#ifdef CONFIG_PM -static int pxa_gpio_suspend (void ) +static int pxa_gpio_suspend (void *data) {struct pxa_gpio_chip *pchip = pxa_gpio_chip;struct pxa_gpio_bank *c;
@@ -768,7 +768,7 @@ static int pxa_gpio_suspend(void)return 0 ; } -static void pxa_gpio_resume (void ) +static void pxa_gpio_resume (void *data) {struct pxa_gpio_chip *pchip = pxa_gpio_chip;struct pxa_gpio_bank *c;
@@ -792,14 +792,18 @@ static void pxa_gpio_resume(void)#define pxa_gpio_resume NULL#endif -static struct syscore_ops pxa_gpio_syscore_ops = { +static const struct syscore_ops pxa_gpio_syscore_ops = { .suspend = pxa_gpio_suspend, .resume = pxa_gpio_resume, }; +static struct syscore pxa_gpio_syscore = { + .ops = &pxa_gpio_syscore_ops, +}; +static int __init pxa_gpio_sysinit (void ) { -register_syscore_ops (&pxa_gpio_syscore_ops); +register_syscore (&pxa_gpio_syscore);return 0 ; }postcore_initcall (pxa_gpio_sysinit);
drivers/gpio/gpio-sa1100.c +8 -4
@@ -256,7 +256,7 @@ static void sa1100_gpio_handler(struct irq_desc *desc) }while (mask); } -static int sa1100_gpio_suspend (void ) +static int sa1100_gpio_suspend (void *data) {struct sa1100_gpio_chip *sgc = &sa1100_gpio_chip;
@@ -275,19 +275,23 @@ static int sa1100_gpio_suspend(void)return 0 ; } -static void sa1100_gpio_resume (void ) +static void sa1100_gpio_resume (void *data) {sa1100_update_edge_regs (&sa1100_gpio_chip); } -static struct syscore_ops sa1100_gpio_syscore_ops = { +static const struct syscore_ops sa1100_gpio_syscore_ops = { .suspend = sa1100_gpio_suspend, .resume = sa1100_gpio_resume, }; +static struct syscore sa1100_gpio_syscore = { + .ops = &sa1100_gpio_syscore_ops, +}; +static int __init sa1100_gpio_init_devicefs (void ) { -register_syscore_ops (&sa1100_gpio_syscore_ops); +register_syscore (&sa1100_gpio_syscore);return 0 ; }
drivers/hv/vmbus_drv.c +9 -5
@@ -2895,7 +2895,7 @@ static void hv_crash_handler(struct pt_regs *regs)hv_synic_disable_regs (cpu); }; -static int hv_synic_suspend (void ) +static int hv_synic_suspend (void *data) {/* * When we reach here, all the non-boot CPUs have been offlined.
@@ -2922,7 +2922,7 @@ static int hv_synic_suspend(void)return 0 ; } -static void hv_synic_resume (void ) +static void hv_synic_resume (void *data) {hv_synic_enable_regs (0 );
@@ -2934,11 +2934,15 @@ static void hv_synic_resume(void) }/* The callbacks run only on CPU0, with irqs_disabled. */ -static struct syscore_ops hv_synic_syscore_ops = { +static const struct syscore_ops hv_synic_syscore_ops = { .suspend = hv_synic_suspend, .resume = hv_synic_resume, }; +static struct syscore hv_synic_syscore = { + .ops = &hv_synic_syscore_ops, +}; +static int __init hv_acpi_init (void ) {int ret;
@@ -2981,7 +2985,7 @@ static int __init hv_acpi_init(void)hv_setup_kexec_handler (hv_kexec_handler);hv_setup_crash_handler (hv_crash_handler); -register_syscore_ops (&hv_synic_syscore_ops); +register_syscore (&hv_synic_syscore);return 0 ;
@@ -2995,7 +2999,7 @@ static void __exit vmbus_exit(void) {int cpu; -unregister_syscore_ops (&hv_synic_syscore_ops); +unregister_syscore (&hv_synic_syscore);hv_remove_kexec_handler ();hv_remove_crash_handler ();
drivers/iommu/amd/init.c +10 -6
@@ -3059,7 +3059,7 @@ static void disable_iommus(void)* disable suspend until real resume implemented */ -static void amd_iommu_resume (void ) +static void amd_iommu_resume (void *data) {struct amd_iommu *iommu;
@@ -3074,7 +3074,7 @@ static void amd_iommu_resume(void)amd_iommu_enable_interrupts (); } -static int amd_iommu_suspend (void ) +static int amd_iommu_suspend (void *data) {/* disable IOMMUs to go out of the way for BIOS */ disable_iommus ();
@@ -3082,11 +3082,15 @@ static int amd_iommu_suspend(void)return 0 ; } -static struct syscore_ops amd_iommu_syscore_ops = { +static const struct syscore_ops amd_iommu_syscore_ops = { .suspend = amd_iommu_suspend, .resume = amd_iommu_resume, }; +static struct syscore amd_iommu_syscore = { + .ops = &amd_iommu_syscore_ops, +}; +static void __init free_iommu_resources (void ) {free_iommu_all ();
@@ -3490,7 +3494,7 @@ static int __init state_next(void) init_state =IOMMU_ENABLED ;break ;case IOMMU_ENABLED : -register_syscore_ops (&amd_iommu_syscore_ops); +register_syscore (&amd_iommu_syscore);iommu_snp_enable ();amd_iommu_apply_erratum_snp ();
@@ -3608,12 +3612,12 @@ int __init amd_iommu_enable(void)void amd_iommu_disable (void ) { -amd_iommu_suspend (); +amd_iommu_suspend (NULL ); }int amd_iommu_reenable (int mode) { -amd_iommu_resume (); +amd_iommu_resume (NULL );return 0 ; }
drivers/iommu/intel/iommu.c +8 -4
@@ -2309,7 +2309,7 @@ static void iommu_flush_all(void) } } -static int iommu_suspend (void ) +static int iommu_suspend (void *data) {struct dmar_drhd_unit *drhd;struct intel_iommu *iommu =NULL ;
@@ -2336,7 +2336,7 @@ static int iommu_suspend(void)return 0 ; } -static void iommu_resume (void ) +static void iommu_resume (void *data) {struct dmar_drhd_unit *drhd;struct intel_iommu *iommu =NULL ;
@@ -2367,14 +2367,18 @@ static void iommu_resume(void) } } -static struct syscore_ops iommu_syscore_ops = { +static const struct syscore_ops iommu_syscore_ops = { .resume = iommu_resume, .suspend = iommu_suspend, }; +static struct syscore iommu_syscore = { + .ops = &iommu_syscore_ops, +}; +static void __init init_iommu_pm_ops (void ) { -register_syscore_ops (&iommu_syscore_ops); +register_syscore (&iommu_syscore); }#else
drivers/irqchip/exynos-combiner.c +10 -4
@@ -200,12 +200,13 @@ static void __init combiner_init(void __iomem *combiner_base,/** * combiner_suspend - save interrupt combiner state before suspend +* @data: syscore context * * Save the interrupt enable set register for all combiner groups since * the state is lost when the system enters into a sleep state. * */ -static int combiner_suspend (void ) +static int combiner_suspend (void *data) {int i;
@@ -218,12 +219,13 @@ static int combiner_suspend(void)/** * combiner_resume - restore interrupt combiner state after resume +* @data: syscore context * * Restore the interrupt enable set register for all combiner groups since * the state is lost when the system enters into a sleep state on suspend. * */ -static void combiner_resume (void ) +static void combiner_resume (void *data) {int i;
@@ -240,11 +242,15 @@ static void combiner_resume(void)#define combiner_resume NULL#endif -static struct syscore_ops combiner_syscore_ops = { +static const struct syscore_ops combiner_syscore_ops = { .suspend = combiner_suspend, .resume = combiner_resume, }; +static struct syscore combiner_syscore = { + .ops = &combiner_syscore_ops, +}; +static int __init combiner_of_init (struct device_node *np,struct device_node *parent) {
@@ -264,7 +270,7 @@ static int __init combiner_of_init(struct device_node *np,combiner_init (combiner_base, np); -register_syscore_ops (&combiner_syscore_ops); +register_syscore (&combiner_syscore);return 0 ; }
drivers/irqchip/irq-armada-370-xp.c +8 -4
@@ -726,7 +726,7 @@ static void __exception_irq_entry mpic_handle_irq(struct pt_regs *regs) }while (1 ); } -static int mpic_suspend (void ) +static int mpic_suspend (void *data) {struct mpic *mpic = mpic_data;
@@ -735,7 +735,7 @@ static int mpic_suspend(void)return 0 ; } -static void mpic_resume (void ) +static void mpic_resume (void *data) {struct mpic *mpic = mpic_data;bool src0, src1;
@@ -788,11 +788,15 @@ static void mpic_resume(void)mpic_ipi_resume (mpic); } -static struct syscore_ops mpic_syscore_ops = { +static const struct syscore_ops mpic_syscore_ops = { .suspend = mpic_suspend, .resume = mpic_resume, }; +static struct syscore mpic_syscore = { + .ops = &mpic_syscore_ops, +}; +static int __init mpic_map_region (struct device_node *np,int index,void __iomem **base,phys_addr_t *phys_base) {
@@ -905,7 +909,7 @@ static int __init mpic_of_init(struct device_node *node, struct device_node *par mpic_handle_cascade_irq, mpic); } -register_syscore_ops (&mpic_syscore_ops); +register_syscore (&mpic_syscore);return 0 ; }
drivers/irqchip/irq-bcm7038-l1.c +8 -4
@@ -291,7 +291,7 @@ static int bcm7038_l1_init_one(struct device_node *dn, unsigned int idx,static LIST_HEAD (bcm7038_l1_intcs_list);static DEFINE_RAW_SPINLOCK (bcm7038_l1_intcs_lock); -static int bcm7038_l1_suspend (void ) +static int bcm7038_l1_suspend (void *data) {struct bcm7038_l1_chip *intc;int boot_cpu, word;
@@ -317,7 +317,7 @@ static int bcm7038_l1_suspend(void)return 0 ; } -static void bcm7038_l1_resume (void ) +static void bcm7038_l1_resume (void *data) {struct bcm7038_l1_chip *intc;int boot_cpu, word;
@@ -338,11 +338,15 @@ static void bcm7038_l1_resume(void) } } -static struct syscore_ops bcm7038_l1_syscore_ops = { +static const struct syscore_ops bcm7038_l1_syscore_ops = { .suspend = bcm7038_l1_suspend, .resume = bcm7038_l1_resume, }; +static struct syscore bcm7038_l1_syscore = { + .ops = &bcm7038_l1_syscore_ops, +}; +static int bcm7038_l1_set_wake (struct irq_data *d,unsigned int on) {struct bcm7038_l1_chip *intc =irq_data_get_irq_chip_data (d);
@@ -430,7 +434,7 @@ static int bcm7038_l1_probe(struct platform_device *pdev, struct device_node *paraw_spin_unlock (&bcm7038_l1_intcs_lock);if (list_is_singular (&bcm7038_l1_intcs_list)) -register_syscore_ops (&bcm7038_l1_syscore_ops); +register_syscore (&bcm7038_l1_syscore);#endif pr_info("registered BCM7038 L1 intc (%pOF, IRQs: %d)\n",
drivers/irqchip/irq-gic-v3-its.c +8 -4
@@ -5003,7 +5003,7 @@ static void its_enable_quirks(struct its_node *its) its_quirks, its); } -static int its_save_disable (void ) +static int its_save_disable (void *data) {struct its_node *its;int err =0 ;
@@ -5039,7 +5039,7 @@ static int its_save_disable(void)return err; } -static void its_restore_enable (void ) +static void its_restore_enable (void *data) {struct its_node *its;int ret;
@@ -5099,11 +5099,15 @@ static void its_restore_enable(void)raw_spin_unlock (&its_lock); } -static struct syscore_ops its_syscore_ops = { +static const struct syscore_ops its_syscore_ops = { .suspend = its_save_disable, .resume = its_restore_enable, }; +static struct syscore its_syscore = { + .ops = &its_syscore_ops, +}; +static void __init __iomem *its_map_one (struct resource *res,int *err) {void __iomem *its_base;
@@ -5881,7 +5885,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, } } -register_syscore_ops (&its_syscore_ops); +register_syscore (&its_syscore);return 0 ; }
drivers/irqchip/irq-i8259.c +8 -4
@@ -202,13 +202,13 @@ static void mask_and_ack_8259A(struct irq_data *d) } } -static void i8259A_resume (void ) +static void i8259A_resume (void *data) {if (i8259A_auto_eoi >=0 )init_8259A (i8259A_auto_eoi); } -static void i8259A_shutdown (void ) +static void i8259A_shutdown (void *data) {/* Put the i8259A into a quiescent state that * the kernel initialization code can get it
@@ -220,11 +220,15 @@ static void i8259A_shutdown(void) } } -static struct syscore_ops i8259_syscore_ops = { +static const struct syscore_ops i8259_syscore_ops = { .resume = i8259A_resume, .shutdown = i8259A_shutdown, }; +static struct syscore i8259_syscore = { + .ops = &i8259_syscore_ops, +}; +static void init_8259A (int auto_eoi) {unsigned long flags;
@@ -320,7 +324,7 @@ struct irq_domain * __init __init_i8259_irqs(struct device_node *node)if (request_irq (irq, no_action,IRQF_NO_THREAD ,"cascade" ,NULL ))pr_err ("Failed to register cascade interrupt\n" ); -register_syscore_ops (&i8259_syscore_ops); +register_syscore (&i8259_syscore);return domain; }
drivers/irqchip/irq-imx-gpcv2.c +10 -6
@@ -33,7 +33,7 @@ static void __iomem *gpcv2_idx_to_reg(struct gpcv2_irqchip_data *cd, int i)return cd->gpc_base + cd->cpu2wakeup + i *4 ; } -static int gpcv2_wakeup_source_save (void ) +static int gpcv2_wakeup_source_save (void *data) {struct gpcv2_irqchip_data *cd;void __iomem *reg;
@@ -52,7 +52,7 @@ static int gpcv2_wakeup_source_save(void)return 0 ; } -static void gpcv2_wakeup_source_restore (void ) +static void gpcv2_wakeup_source_restore (void *data) {struct gpcv2_irqchip_data *cd;int i;
@@ -65,9 +65,13 @@ static void gpcv2_wakeup_source_restore(void)writel_relaxed (cd->saved_irq_mask[i],gpcv2_idx_to_reg (cd, i)); } -static struct syscore_ops imx_gpcv2_syscore_ops = { - .suspend = gpcv2_wakeup_source_save, - .resume = gpcv2_wakeup_source_restore, +static const struct syscore_ops gpcv2_syscore_ops = { + .suspend = gpcv2_wakeup_source_save, + .resume = gpcv2_wakeup_source_restore, +}; + +static struct syscore gpcv2_syscore = { + .ops = &gpcv2_syscore_ops, };static int imx_gpcv2_irq_set_wake (struct irq_data *d,unsigned int on)
@@ -276,7 +280,7 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node,writel_relaxed (~0x1 , cd->gpc_base + cd->cpu2wakeup); imx_gpcv2_instance = cd; -register_syscore_ops (&imx_gpcv2_syscore_ops); +register_syscore (&gpcv2_syscore);/* * Clear the OF_POPULATED flag set in of_irq_init so that
drivers/irqchip/irq-loongson-eiointc.c +8 -4
@@ -407,21 +407,25 @@ static struct irq_domain *acpi_get_vec_parent(int node, struct acpi_vector_groupreturn NULL ; } -static int eiointc_suspend (void ) +static int eiointc_suspend (void *data) {return 0 ; } -static void eiointc_resume (void ) +static void eiointc_resume (void *data) {eiointc_router_init (0 ); } -static struct syscore_ops eiointc_syscore_ops = { +static const struct syscore_ops eiointc_syscore_ops = { .suspend = eiointc_suspend, .resume = eiointc_resume, }; +static struct syscore eiointc_syscore = { + .ops = &eiointc_syscore_ops, +}; +static int __init pch_pic_parse_madt (union acpi_subtable_headers *header,const unsigned long end) {
@@ -540,7 +544,7 @@ static int __init eiointc_init(struct eiointc_priv *priv, int parent_irq,eiointc_router_init (0 );if (nr_pics ==1 ) { -register_syscore_ops (&eiointc_syscore_ops); +register_syscore (&eiointc_syscore);cpuhp_setup_state_nocalls (CPUHP_AP_IRQ_EIOINTC_STARTING ,"irqchip/loongarch/eiointc:starting" , eiointc_router_init,NULL );
drivers/irqchip/irq-loongson-htpic.c +7 -3
@@ -71,15 +71,19 @@ static void htpic_reg_init(void)writel (0xffff , htpic->base +HTINT_EN_OFF ); } -static void htpic_resume (void ) +static void htpic_resume (void *data) {htpic_reg_init (); } -struct syscore_ops htpic_syscore_ops = { +static const struct syscore_ops htpic_syscore_ops = { .resume = htpic_resume, }; +static struct syscore htpic_syscore = { + .ops = &htpic_syscore_ops, +}; +static int __init htpic_of_init (struct device_node *node,struct device_node *parent) {unsigned int parent_irq[4 ];
@@ -130,7 +134,7 @@ static int __init htpic_of_init(struct device_node *node, struct device_node *pa htpic_irq_dispatch, htpic); } -register_syscore_ops (&htpic_syscore_ops); +register_syscore (&htpic_syscore);return 0 ;
drivers/irqchip/irq-loongson-htvec.c +8 -4
@@ -159,7 +159,7 @@ static void htvec_reset(struct htvec *priv) } } -static int htvec_suspend (void ) +static int htvec_suspend (void *data) {int i;
@@ -169,7 +169,7 @@ static int htvec_suspend(void)return 0 ; } -static void htvec_resume (void ) +static void htvec_resume (void *data) {int i;
@@ -177,11 +177,15 @@ static void htvec_resume(void)writel (htvec_priv->saved_vec_en[i], htvec_priv->base +HTVEC_EN_OFF +4 * i); } -static struct syscore_ops htvec_syscore_ops = { +static const struct syscore_ops htvec_syscore_ops = { .suspend = htvec_suspend, .resume = htvec_resume, }; +static struct syscore htvec_syscore = { + .ops = &htvec_syscore_ops, +}; +static int htvec_init (phys_addr_t addr,unsigned long size,int num_parents,int parent_irq[],struct fwnode_handle *domain_handle) {
@@ -214,7 +218,7 @@ static int htvec_init(phys_addr_t addr, unsigned long size, htvec_priv = priv; -register_syscore_ops (&htvec_syscore_ops); +register_syscore (&htvec_syscore);return 0 ;
drivers/irqchip/irq-loongson-pch-lpc.c +8 -4
@@ -151,7 +151,7 @@ static int pch_lpc_disabled(struct pch_lpc *priv) (readl (priv->base +LPC_INT_STS ) ==0xffffffff ); } -static int pch_lpc_suspend (void ) +static int pch_lpc_suspend (void *data) { pch_lpc_priv->saved_reg_ctl =readl (pch_lpc_priv->base +LPC_INT_CTL ); pch_lpc_priv->saved_reg_ena =readl (pch_lpc_priv->base +LPC_INT_ENA );
@@ -159,18 +159,22 @@ static int pch_lpc_suspend(void)return 0 ; } -static void pch_lpc_resume (void ) +static void pch_lpc_resume (void *data) {writel (pch_lpc_priv->saved_reg_ctl, pch_lpc_priv->base +LPC_INT_CTL );writel (pch_lpc_priv->saved_reg_ena, pch_lpc_priv->base +LPC_INT_ENA );writel (pch_lpc_priv->saved_reg_pol, pch_lpc_priv->base +LPC_INT_POL ); } -static struct syscore_ops pch_lpc_syscore_ops = { +static const struct syscore_ops pch_lpc_syscore_ops = { .suspend = pch_lpc_suspend, .resume = pch_lpc_resume, }; +static struct syscore pch_lpc_syscore = { + .ops = &pch_lpc_syscore_ops, +}; +int __init pch_lpc_acpi_init (struct irq_domain *parent,struct acpi_madt_lpc_pic *acpi_pchlpc) {
@@ -222,7 +226,7 @@ int __init pch_lpc_acpi_init(struct irq_domain *parent, pch_lpc_priv = priv; pch_lpc_handle = irq_handle; -register_syscore_ops (&pch_lpc_syscore_ops); +register_syscore (&pch_lpc_syscore);return 0 ;
drivers/irqchip/irq-loongson-pch-pic.c +8 -4
@@ -278,7 +278,7 @@ static void pch_pic_reset(struct pch_pic *priv) } } -static int pch_pic_suspend (void ) +static int pch_pic_suspend (void *data) {int i, j;
@@ -296,7 +296,7 @@ static int pch_pic_suspend(void)return 0 ; } -static void pch_pic_resume (void ) +static void pch_pic_resume (void *data) {int i, j;
@@ -313,11 +313,15 @@ static void pch_pic_resume(void) } } -static struct syscore_ops pch_pic_syscore_ops = { +static const struct syscore_ops pch_pic_syscore_ops = { .suspend = pch_pic_suspend, .resume = pch_pic_resume, }; +static struct syscore pch_pic_syscore = { + .ops = &pch_pic_syscore_ops, +}; +static int pch_pic_init (phys_addr_t addr,unsigned long size,int vec_base,struct irq_domain *parent_domain,struct fwnode_handle *domain_handle,u32 gsi_base)
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.53.0
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerPATCH 1382/1518 Drivers: hv: vmbus: Skip VMBus module cleanup for non-nested root partition
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Kelley <[email protected]>
[ Upstream commit cee0d90bceae1dee3bcc70f8d6b2ceb5b87deb42 ]
The VMBus module initialization function, hv_acpi_init(), currently does nothing when running in the root partition and root is not nested in another VM. But the initialization function reports success, so the VMBus module is indeed loaded. VMBus functionality is not actually needed, but the VMBus module must be loaded so that hv_vmbus_exists() can answer correctly. Furthermore, the mshv_root dependency on the VMBus module is needed as described in the commit message for 840b740a35bf ("mshv: Add conditional VMBus dependency").
Loading the VMBus module without actually initializing it causes failures if the module should later be unloaded. The module unload code tries to clean up things that were never initialized, resulting in memory faults and a panic.
Fix this by having VMBus module exit function perform the same check for non-nested root partition, and do nothing in such a case, just like hv_acpi_init().
In the long run, the code that manages the Hyper-V provided SynIC should be refactored to better coordinate the requirements of root partition scenarios and normal VM scenarios, and to hopefully remove the hv_vmbus_exists() dependnecy between mshv_root and VMBus modules. Preventing the current unload failure scenario is an expediency until such a refactoring is done.
--- drivers/hv/vmbus_drv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/hv/vmbus_drv.c +15 -0
@@ -2951,6 +2951,13 @@ static int __init hv_acpi_init(void)return -ENODEV ;if (hv_root_partition () && !hv_nested) +/* +* A non-nested root partition does not need VMBus client +* functionality. However, the mshv_root module may have +* a dependency on the VMBus module as described in +* commit 840b740a35bf. Return success so the module +* loads even though no VMBus initialization is done. +*/ return 0 ;/*
@@ -2999,6 +3006,14 @@ static void __exit vmbus_exit(void) {int cpu; +if (hv_root_partition () && !hv_nested) +/* +* If a non-nested root partition loaded the VMBus module, +* hv_acpi_init() did not do any VMBus initialization. +* There's nothing to clean up, so just return. +*/ +return ; +unregister_syscore (&hv_synic_syscore);hv_remove_kexec_handler ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1383/1518 scsi: qla2xxx: Fix an loop timeout test
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 11e48f5201fd86ffa038809dd9c41144d43ee2e4 ]
This loop timeout with "retries" set to -1, not 0. Fix the test for failure.
--- drivers/scsi/qla2xxx/qla_nx2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_nx2.c +1 -1
@@ -3507,7 +3507,7 @@ qla8044_poll_flash_status_reg(struct scsi_qla_host *vha)msleep (QLA8044_FLASH_STATUS_REG_POLL_DELAY ); } -if (!retries) +if (retries ==-1 ) ret_val =QLA_FUNCTION_FAILED ;return ret_val;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1384/1518 erofs: Fix EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS default logic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit ab74edaeb1ae7c7194e79007e6afdfe788111a3f ]
When NR_CPUS is less than 16, or when SMP is disabled, the default value of 16 is invalid.
While actual configuration picks up a sensible and valid default (NR_CPUS or 1), "make savedefconfig" will still write a line like
CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=1
to the defconfig file, even if that matches the sensible default.
Avoid needlessly enlarging the defconfig files, and reduce churn for updating them, by specifying valid defaults depending on SMP and NR_CPUS.
While at it, make the prompt depend on SMP, as there is no point in asking the user about the maximum number of decompression streams if there is only one valid answer.
--- fs/erofs/Kconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/erofs/Kconfig +5 -3
@@ -121,11 +121,13 @@ config EROFS_FS_ZIP_LZMA If unsure, say N. config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS - int "EROFS LZMA default maximum decompression streams" + int "EROFS LZMA default maximum decompression streams" if SMP depends on EROFS_FS_ZIP_LZMA range 1 NR_CPUS if SMP range 1 1 if !SMP - default 16 + default 16 if SMP && NR_CPUS >= 16 + default NR_CPUS if SMP + default 1 help By default EROFS allocates one LZMA decompression stream per CPU. Each stream can hold a dictionary of up to 8 MiB taken from the
@@ -133,7 +135,7 @@ config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS of memory. This caps the default; the lzma_streams module parameter still overrides it. - If unsure, keep the default of 16. + If unsure, keep the suggested default (16 or lower). config EROFS_FS_ZIP_DEFLATE bool "EROFS DEFLATE compressed data support"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1385/1518 arm64: ptdump: Make note_page_flush() range aware
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei-Lin Chang <[email protected]>
[ Upstream commit 902caade3cfd60f99bf71b355e7c86344bd831e5 ]
note_page_flush() calls note_page() with addr == 0 and level == -1 to dump the last row of a ptdump. addr == 0 (1 << 64 wrapped around) renders a huge region with enormous size for address spaces with IA bits < 64. For example the stage-2 page tables and the EFI runtime page table.
More importantly, the last region of the address space and everything after the address space up to 1 << 64 are merged into one row of output. If the last region within the address space is valid, it will appear to remain valid up to 1 << 64 with the same attributes.
Currently only the EFI runtime ptdump is affected by this, but KVM will soon fix its stage-2 ptdump by using note_page_flush(). Here is an example of an EFI runtime ptdump (last row):
0x0000008000000000-0x0000000000000000 17179868672G PGD
With this patch:
0x0000008000000000-0x0001000000000000 261632G PGD
To fix this, cache the end address of a ptdump in ptdump_pg_state so note_page_flush() can call the final note_page() with the correct end address.
--- arch/arm64/include/asm/ptdump.h | 2 ++ arch/arm64/mm/ptdump.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
arch/arm64/include/asm/ptdump.h +2 -0
@@ -50,6 +50,8 @@ struct ptdump_pg_state {const struct addr_marker *marker;const struct mm_struct *mm;unsigned long start_address; +/* exclusive end, ULONG_MAX represents an end at 1 << 64 */ +unsigned long end_address;int level;ptdesc_t current_prot;bool check_wx;
arch/arm64/mm/ptdump.c +13 -1
@@ -278,9 +278,19 @@ void note_page_pgd(struct ptdump_state *pt_st, unsigned long addr, pgd_t pgd)void note_page_flush (struct ptdump_state *pt_st) { + struct ptdump_pg_state *st = container_of(pt_st, struct ptdump_pg_state, ptdump); +unsigned long end = st->end_address;pte_t pte_zero = {0 }; -note_page (pt_st,0 ,-1 ,pte_val (pte_zero)); +/* +* Address spaces that end at 1 << 64 have end_address == ULONG_MAX, +* but note_page() expects the exclusive end. In this case adjust end +* to the wraparound value 0. +*/ +if (end ==ULONG_MAX ) + end =0 ; + +note_page (pt_st, end,-1 ,pte_val (pte_zero)); }void ptdump_walk (struct seq_file *s,struct ptdump_info *info)
@@ -296,6 +306,7 @@ void ptdump_walk(struct seq_file *s, struct ptdump_info *info) .marker = info->markers, .mm = info->mm, .pg_level = &kernel_pg_levels[0], + .end_address = end, .level = -1, .ptdump = { .note_page_pte = note_page_pte,
@@ -337,6 +348,7 @@ bool ptdump_check_wx(void) { -1, NULL}, }, .pg_level = &kernel_pg_levels[0], + .end_address = ~0UL, .level = -1, .check_wx = true, .ptdump = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1386/1518 arm64: process: Fix context switching MTE store-only tag check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Murzin <[email protected]>
[ Upstream commit b8f070ac3167595069feb1f794c127b805115645 ]
SCTLR_EL1.TCSO0 is set when user opt-in for MTE store-only tag check mode. However, it is not part of SCTLR_USER_MASK which imply that on context switch we never clear SCTLR_EL1.TCSO0, so we are leaking that setting into another task.
Fix that by including SCTLR_EL1_TCSO0_MASK into SCTLR_USER_MASK
--- arch/arm64/include/asm/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/processor.h +1 -1
@@ -256,7 +256,7 @@ static inline void task_set_sve_vl_onexec(struct task_struct *task,#define SCTLR_USER_MASK \ (SCTLR_ELx_ENIA | SCTLR_ELx_ENIB | SCTLR_ELx_ENDA | SCTLR_ELx_ENDB | \ - SCTLR_EL1_TCF0_MASK) + SCTLR_EL1_TCF0_MASK | SCTLR_EL1_TCSO0_MASK)static inline void arch_thread_struct_whitelist (unsigned long *offset,unsigned long *size)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1387/1518 Bluetooth: L2CAP: reject accept queue add unless BT_LISTEN
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit d4bfa78fd67929b62b02013c107973e0c5b7aa9a ]
New sk should not be added to parent socket accept queue after last l2cap_sock_cleanup_listen() has run in l2cap_sock_teardown_cb() and state set to BT_CLOSED, as that can result to UAF on dereferencing the dangling parent reference.
l2cap_sock_new_connection_cb() may race with parent l2cap_chan teardown, due to chan->state accessed without consistent locking:
[Task 1] [Task 2]
l2cap_sock_release(parent) l2cap_connect
l2cap_sock_shutdown pchan = l2cap_global_chan_by_psm
l2cap_chan_lock(pchan)
l2cap_chan_close
l2cap_sock_teardown_cb
pchan->state = BT_CLOSED
l2cap_chan_unlock(pchan) ------> l2cap_chan_lock(pchan)
l2cap_new_connection
l2cap_sock_new_connection_cb
l2cap_chan_lock(pchan) <-------- l2cap_chan_unlock(pchan)
l2cap_sock_kill(parent) /* bt_sk(sk)->parent dangling */Fix by adding check for sk_state == BT_LISTEN after acquiring sk lock in l2cap_sock_new_connection_cb(). Add lock_sock() around sk_state writes where missing, to avoid data races.
Although the data races on pchan->state should be fixed too, this defensive sk_state check probably makes sense in any case.
--- net/bluetooth/l2cap_sock.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/bluetooth/l2cap_sock.c +13 -0
@@ -1539,6 +1539,11 @@ static int l2cap_sock_new_connection_cb(struct l2cap_chan *chan,lock_sock (parent); +if (parent->sk_state !=BT_LISTEN ) { +release_sock (parent); +return -EINVAL ; + } +/* Check for backlog size */ if (sk_acceptq_is_full (parent)) {BT_DBG ("backlog full %d" , parent->sk_ack_backlog);
@@ -1703,10 +1708,14 @@ static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state,if (!sk)return ; +lock_sock (sk); + sk->sk_state = state;if (err) sk->sk_err = err; + +release_sock (sk); } static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
@@ -1782,6 +1791,8 @@ static void l2cap_sock_resume_cb(struct l2cap_chan *chan)if (!sk)return ; +lock_sock (sk); +if (test_and_clear_bit (FLAG_PENDING_SECURITY , &chan->flags)) { sk->sk_state =BT_CONNECTED ; chan->state =BT_CONNECTED ;
@@ -1789,6 +1800,8 @@ static void l2cap_sock_resume_cb(struct l2cap_chan *chan)clear_bit (BT_SK_SUSPEND , &bt_sk (sk)->flags); sk->sk_state_change (sk); + +release_sock (sk); }static void l2cap_sock_set_shutdown_cb (struct l2cap_chan *chan)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1388/1518 Bluetooth: mgmt: fix hdev->discovery.uuids NULL dereference
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Shpakovskiy <[email protected]>
[ Upstream commit 59eecbe2f2f38d8f3e1104bd11da97f9a2c58998 ]
'uuid_count' member of struct 'discovery_state' is assigned and read without any locks, so there is a chance of situation when uuid_count != 0, but uuids is NULL and there will be NULL pointer dereference.
Possible race:
'hci_update_passive_scan_sync'
'hci_discovery_filter_clear'
hdev->discovery.uuid_count = 0;
<----------------------preempted----------------------------->
'start_service_discovery'
// Set uuid_count to value != 0
hdev->discovery.uuid_count = uuid_count;
hdev->discovery.uuids = kmemdup(...);
<----------------------preempted----------------------------->
spin_lock(&hdev->discovery.lock);
kfree(hdev->discovery.uuids);
hdev->discovery.uuids = NULL;
spin_unlock(&hdev->discovery.lock);Now uuids == NULL and uuid_count != 0.
So 'mgmt_device_found' -> 'is_filter_match' -> 'eir_has_uuids' receives non consistent discovery state, where NULL dereference of uuids happens.
To fix it let's add discovery.lock around every read/write of uuid_count, uuids pair of struct members. It is also important to assign uuid_count value only after success kmemdup() allocation in start_service_discovery(), otherwise uuids is NULL, because kmemdup failed, but uuid_count is already assigned to non zero value.
The following panic happens:
[ ] ------------[ cut here ]------------
[ ] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[ ] Internal error: Oops: 0000000096000006 [#1] PREEMPT SMP [ ] CPU: 0 PID: 15056 Comm: kworker/u9:2
[ ] Workqueue: hci0 hci_rx_work
[ ] pstate: 10400009 (nzcV daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ ] pc : eir_has_uuids+0x2d8/0x590
[ ] lr : is_filter_match+0x258/0x320
...
[ ] Call trace:
[ ] eir_has_uuids+0x2d8/0x590 [ ] is_filter_match+0x258/0x320 [ ] mgmt_device_found+0x5b0/0xafc [ ] process_adv_report.part.0+0x8c8/0xf14 [ ] hci_le_adv_report_evt+0x338/0x3f0 [ ] hci_le_meta_evt+0x1f0/0x4c8 [ ] hci_event_packet+0x440/0xc9c [ ] hci_rx_work+0x44c/0xaf8 [ ] process_one_work+0x54c/0x103c [ ] worker_thread+0x6c4/0x10c4 [ ] kthread+0x274/0x2ec [ ] ret_from_fork+0x10/0x20
[ ] Code: 14000004 91004021 eb14003f 54000180 (f9400024) [ ] ---[ end trace 0000000000000000 ]---
--- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/mgmt.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-)
include/net/bluetooth/hci_core.h +1 -1
@@ -916,9 +916,9 @@ static inline void hci_discovery_filter_clear(struct hci_dev *hdev) hdev->discovery.result_filtering = false; hdev->discovery.report_invalid_rssi = true; hdev->discovery.rssi =HCI_RSSI_INVALID ; - hdev->discovery.uuid_count =0 ;spin_lock (&hdev->discovery.lock); + hdev->discovery.uuid_count =0 ;kfree (hdev->discovery.uuids); hdev->discovery.uuids =NULL ;spin_unlock (&hdev->discovery.lock);
net/bluetooth/mgmt.c +13 -5
@@ -6096,6 +6096,7 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,struct mgmt_pending_cmd *cmd;const u16 max_uuid_count = ((U16_MAX -sizeof (*cp)) /16 );u16 uuid_count, expected_len; +u8 (*uuids)[16 ] =NULL ;u8 status;int err;
@@ -6172,12 +6173,10 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev, hdev->discovery.result_filtering = true; hdev->discovery.type = cp->type; hdev->discovery.rssi = cp->rssi; - hdev->discovery.uuid_count = uuid_count;if (uuid_count >0 ) { - hdev->discovery.uuids =kmemdup (cp->uuids, uuid_count *16 , -GFP_KERNEL ); -if (!hdev->discovery.uuids) { + uuids =kmemdup (cp->uuids, uuid_count *sizeof (*uuids),GFP_KERNEL ); +if (!uuids) { err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_START_SERVICE_DISCOVERY, MGMT_STATUS_FAILED,
@@ -6187,6 +6186,11 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev, } } +spin_lock (&hdev->discovery.lock); + hdev->discovery.uuids = uuids; + hdev->discovery.uuid_count = uuid_count; +spin_unlock (&hdev->discovery.lock); + err =hci_cmd_sync_queue (hdev, start_discovery_sync, cmd, start_discovery_complete);if (err <0 ) {
@@ -10365,6 +10369,7 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir, !hci_test_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER))))return false; +spin_lock (&hdev->discovery.lock);if (hdev->discovery.uuid_count !=0 ) {/* If a list of UUIDs is provided in filter, results with no * matching UUID should be dropped.
@@ -10373,9 +10378,12 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir, hdev->discovery.uuids) && !eir_has_uuids(scan_rsp, scan_rsp_len, hdev->discovery.uuid_count, - hdev->discovery.uuids)) + hdev->discovery.uuids)) { +spin_unlock (&hdev->discovery.lock);return false; + } } +spin_unlock (&hdev->discovery.lock);/* If duplicate filtering does not report RSSI changes, then restart * scanning to ensure updated result with updated RSSI values.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1389/1518 Bluetooth: L2CAP: fix race l2cap_sock_cleanup_listen() vs. put_chan
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 66d6ef18548ae6d7dd452b84115fc82c0a73a4ea ]
For L2CAP sockets without owning sk->sk_socket, reading l2cap_pi(sk)->chan may race against concurrent l2cap_sock_kill() -> l2cap_sock_put_chan(). This excludes simultaneous proto_ops callbacks, but access in l2cap_sock_cleanup_listen() has unsafe lockless read.
[Task 1] [Task 2 (hdev->workqueue)]
l2cap_sock_release(parent) l2cap_disconn_cfm
l2cap_sock_cleanup_listen l2cap_conn_del
bt_accept_dequeue l2cap_chan_del
lock_sock(sk) l2cap_sock_teardown_cb
bt_accept_unlink
bt_sk(sk)->parent = NULL
release_sock(sk) ----------------> lock_sock(sk)
parent = /* NULL */
lock_sock(sk) <--------------------- release_sock(sk)
sock_set_flag(sk, SOCK_ZAPPED)
l2cap_sock_close_cb
l2cap_sock_kill(sk)
l2cap_sock_put_chan
chan = READ l2cap_pi(sk)->chan l2cap_pi(sk)->chan = NULL
l2cap_chan_hold_unless_zero l2cap_put_chan(chan)
kref_get_unless_zero(&chan->ref)Task 1 may observe NULL which causes null-ptr-deref.
Fix the race by taking lock_sock() in l2cap_sock_kill() to synchronize with l2cap_sock_cleanup_listen(). hold_unless_zero() is not needed here, l2cap_pi(sk)->chan owns reference if it is non-NULL.
Clarify code comments vs. locking.
--- include/net/bluetooth/l2cap.h | 5 +++++ net/bluetooth/l2cap_sock.c | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-)
include/net/bluetooth/l2cap.h +5 -0
@@ -702,7 +702,12 @@ struct l2cap_rx_busy {struct l2cap_pinfo {struct bt_sock bt; + +/* With owning sk_socket chan may be read without lock, other access +* should hold lock_sock. +*/ struct l2cap_chan *chan; +struct list_head rx_busy; };
net/bluetooth/l2cap_sock.c +13 -10
@@ -1284,7 +1284,12 @@ static void l2cap_sock_kill(struct sock *sk)BT_DBG ("sk %p state %s" , sk,state_to_string (sk->sk_state)); +/* Take lock to synchronize against access without owning sk->sk_socket, +* eg. in l2cap_sock_cleanup_listen(). proto_ops etc. don't need lock. +*/ +lock_sock (sk);l2cap_sock_put_chan (sk); +release_sock (sk);/* Kill poor orphan */ sock_set_flag (sk,SOCK_DEAD );
@@ -1487,14 +1492,10 @@ static void l2cap_sock_cleanup_listen(struct sock *parent)* establish sk_lock -> conn->lock and invert the established * conn->lock -> chan->lock -> sk_lock order (lockdep deadlock). * -* Instead, briefly take the child sk lock to fetch and pin its chan. -* l2cap_conn_del() reaches the chan free only via -* l2cap_chan_del() -> l2cap_sock_teardown_cb(), which itself takes -* the child sk lock; holding it across l2cap_chan_hold_unless_zero() -* therefore guarantees the chan cannot be freed while we read and -* pin it (hold_unless_zero() additionally skips a chan already past -* its last reference). We then drop the sk lock before taking -* chan->lock, so sk and chan locks are never held together. +* Instead, briefly take the child sk lock to synchronize vs. +* l2cap_sock_kill that puts l2cap_pi(sk)->chan. We then drop the sk +* lock before taking chan->lock, so sk and chan locks are never held +* together. * * Since we cannot call l2cap_chan_close() without conn->lock, * schedule l2cap_chan_timeout to close the channel; it already
@@ -1504,10 +1505,12 @@ static void l2cap_sock_cleanup_listen(struct sock *parent)struct l2cap_chan *chan;lock_sock_nested (sk,L2CAP_NESTING_NORMAL ); - chan =l2cap_chan_hold_unless_zero (l2cap_pi (sk)->chan); + chan =l2cap_pi (sk)->chan; +if (chan) +l2cap_chan_hold (chan);release_sock (sk);if (!chan) { -/* l2cap_conn_del() already tearing this child down */ +/* Already torn down */ sock_put (sk);continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1390/1518 Bluetooth: btmtk: Add MT6639 (MT7927) Bluetooth support
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Tia <[email protected]>
[ Upstream commit 28b7c5a6db74e9305c6cbcbe52f259ff1cf85158 ]
The MediaTek MT7927 (Filogic 380) combo WiFi 7 + BT 5.4 module uses hardware variant 0x6639 for its Bluetooth subsystem. Without this patch, the chip fails with "Unsupported hardware variant (00006639)" or hangs during firmware download.
Three changes are needed to support MT6639:
1. CHIPID workaround: On some boards the BT USB MMIO register reads 0x0000 for dev_id, causing the driver to skip the 0x6639 init path. Force dev_id to 0x6639 only when the USB VID/PID matches a known MT6639 device, avoiding misdetection if a future chip also reads zero. This follows the WiFi-side pattern that uses PCI device IDs to scope the same workaround.
2. Firmware naming: MT6639 uses firmware version prefix "2_1" instead of "1_1" used by MT7925 and other variants. The firmware path is mediatek/mt7927/BT_RAM_CODE_MT6639_2_1_hdr.bin, using the mt7927 directory to match the WiFi firmware convention. The filename will likely change to use MT7927 once MediaTek submits a dedicated Linux firmware binary.
3. Section filtering: The MT6639 firmware binary contains 9 sections, but only sections with (dlmodecrctype & 0xff) == 0x01 are Bluetooth-related. Sending the remaining WiFi/other sections causes an irreversible BT subsystem hang requiring a full power cycle. This matches the Windows driver behavior observed via USB captures.
Also add 0x6639 to the reset register (CONNV3) and firmware setup switch cases alongside the existing 0x7925 handling.
Stable-dep-of: 59c3ee19ca88 ("Bluetooth: btmtk: Do not report success when subsys reset fails")
--- drivers/bluetooth/btmtk.c | 60 ++++++++++++++++++++++++++++++++--- drivers/bluetooth/btmtk.h | 7 ++-- drivers/bluetooth/btmtksdio.c | 2 +- 3 files changed, 61 insertions(+), 8 deletions(-)
drivers/bluetooth/btmtk.c +55 -5
@@ -25,6 +25,22 @@/* It is for mt79xx iso data transmission setting */ #define MTK_ISO_THRESHOLD 264 +/* Known MT6639 (MT7927) Bluetooth USB devices. +* Used to scope the zero-CHIPID workaround to real MT6639 hardware, +* since some boards return 0x0000 from the MMIO chip ID register. +*/ +static const struct { +u16 vendor; +u16 product; +} btmtk_mt6639_devs[] = { + {0x0489 ,0xe13a },/* ASUS ROG Crosshair X870E Hero */ + {0x0489 ,0xe0fa },/* Lenovo Legion Pro 7 16ARX9 */ + {0x0489 ,0xe10f },/* Gigabyte Z790 AORUS MASTER X */ + {0x0489 ,0xe110 },/* MSI X870E Ace Max */ + {0x0489 ,0xe116 },/* TP-Link Archer TBE550E */ + {0x13d3 ,0x3588 },/* ASUS ROG STRIX X870E-E */ +}; +struct btmtk_patch_header {u8 datetime[16 ];u8 platform[4 ];
@@ -112,7 +128,11 @@ static void btmtk_coredump_notify(struct hci_dev *hdev, int state)void btmtk_fw_get_filename (char *buf,size_t size,u32 dev_id,u32 fw_ver,u32 fw_flavor) { -if (dev_id ==0x7925 ) +if (dev_id ==0x6639 ) +snprintf (buf, size, +"mediatek/mt7927/BT_RAM_CODE_MT%04x_2_%x_hdr.bin" , + dev_id &0xffff , (fw_ver &0xff ) +1 ); +else if (dev_id ==0x7925 )snprintf (buf, size,"mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin" , dev_id &0xffff , dev_id &0xffff , (fw_ver &0xff ) +1 );
@@ -128,7 +148,8 @@ void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,EXPORT_SYMBOL_GPL (btmtk_fw_get_filename);int btmtk_setup_firmware_79xx (struct hci_dev *hdev,const char *fwname, -wmt_cmd_sync_func_t wmt_cmd_sync) +wmt_cmd_sync_func_t wmt_cmd_sync, +u32 dev_id) {struct btmtk_hci_wmt_params wmt_params;struct btmtk_patch_header *hdr;
@@ -166,6 +187,14 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, section_offset =le32_to_cpu (sectionmap->secoffset); dl_size =le32_to_cpu (sectionmap->bin_info_spec.dlsize); +/* MT6639: only download sections where dlmode byte0 == 0x01, +* matching the Windows driver behavior which skips WiFi/other +* sections that would cause the chip to hang. +*/ +if (dev_id ==0x6639 && dl_size >0 && + (le32_to_cpu (sectionmap->bin_info_spec.dlmodecrctype) &0xff ) !=0x01 ) +continue ; +if (dl_size >0 ) { retry =20 ;while (retry >0 ) {
@@ -847,7 +876,7 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id)if (err <0 )return err;msleep (100 ); - }else if (dev_id ==0x7925 ) { + }else if (dev_id ==0x7925 || dev_id ==0x6639 ) { err =btmtk_usb_uhw_reg_read (hdev,MTK_BT_RESET_REG_CONNV3 , &val);if (err)return err;
@@ -933,7 +962,7 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id) } err =btmtk_usb_id_get (hdev,0x70010200 , &val); -if (err <0 || !val) +if (err <0 || (!val && dev_id !=0x6639 ))bt_dev_err (hdev,"Can't get device id, subsys reset fail." );return err;
@@ -1319,6 +1348,24 @@ int btmtk_usb_setup(struct hci_dev *hdev) fw_flavor = (fw_flavor &0x00000080 ) >>7 ; } +if (!dev_id) { +u16 vid =le16_to_cpu (btmtk_data->udev->descriptor.idVendor); +u16 pid =le16_to_cpu (btmtk_data->udev->descriptor.idProduct); +int i; + +for (i =0 ; i <ARRAY_SIZE (btmtk_mt6639_devs); i++) { +if (vid == btmtk_mt6639_devs[i].vendor && + pid == btmtk_mt6639_devs[i].product) { + dev_id =0x6639 ; +break ; + } + } + +if (dev_id) +bt_dev_info (hdev,"MT6639: CHIPID=0x0000 with VID=%04x PID=%04x, using 0x6639" , + vid, pid); + } + btmtk_data->dev_id = dev_id; err =btmtk_register_coredump (hdev, btmtk_data->drv_name, fw_version);
@@ -1336,11 +1383,13 @@ int btmtk_usb_setup(struct hci_dev *hdev)case 0x7925 :case 0x7961 :case 0x7902 : +case 0x6639 :btmtk_fw_get_filename (fw_bin_name,sizeof (fw_bin_name), dev_id, fw_version, fw_flavor); err =btmtk_setup_firmware_79xx (hdev, fw_bin_name, - btmtk_usb_hci_wmt_sync); + btmtk_usb_hci_wmt_sync, + dev_id);if (err <0 ) {bt_dev_err (hdev,"Failed to set up firmware (%d)" , err);return err;
@@ -1507,3 +1556,4 @@ MODULE_FIRMWARE(FIRMWARE_MT7668);MODULE_FIRMWARE (FIRMWARE_MT7922 );MODULE_FIRMWARE (FIRMWARE_MT7961 );MODULE_FIRMWARE (FIRMWARE_MT7925 ); +MODULE_FIRMWARE (FIRMWARE_MT7927 );
drivers/bluetooth/btmtk.h +5 -2
@@ -8,6 +8,7 @@#define FIRMWARE_MT7902 "mediatek/BT_RAM_CODE_MT7902_1_1_hdr.bin"#define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin"#define FIRMWARE_MT7925 "mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin" +#define FIRMWARE_MT7927 "mediatek/mt7927/BT_RAM_CODE_MT6639_2_1_hdr.bin"#define HCI_EV_WMT 0xe4#define HCI_WMT_MAX_EVENT_SIZE 64
@@ -188,7 +189,8 @@ typedef int (*wmt_cmd_sync_func_t)(struct hci_dev *,int btmtk_set_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr);int btmtk_setup_firmware_79xx (struct hci_dev *hdev,const char *fwname, -wmt_cmd_sync_func_t wmt_cmd_sync); +wmt_cmd_sync_func_t wmt_cmd_sync, +u32 dev_id);int btmtk_setup_firmware (struct hci_dev *hdev,const char *fwname,wmt_cmd_sync_func_t wmt_cmd_sync);
@@ -227,7 +229,8 @@ static inline int btmtk_set_bdaddr(struct hci_dev *hdev,static inline int btmtk_setup_firmware_79xx (struct hci_dev *hdev,const char *fwname, -wmt_cmd_sync_func_t wmt_cmd_sync) +wmt_cmd_sync_func_t wmt_cmd_sync, +u32 dev_id) {return -EOPNOTSUPP ; }
drivers/bluetooth/btmtksdio.c +1 -1
@@ -884,7 +884,7 @@ static int mt79xx_setup(struct hci_dev *hdev, const char *fwname)u8 param =0x1 ;int err; - err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync); + err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync,0 );if (err <0 ) {bt_dev_err (hdev,"Failed to setup 79xx firmware (%d)" , err);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1391/1518 Bluetooth: btmtk: Fix short read errors in btmtk_usb_reg_read()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 0cc4b5649ae83deb8222100dba31aa0f100a19cd ]
If btmtk_usb_reg_read() gets a "short" read from a device, it will accidentally treat that as a "real" read and populate the returned value with some unknown and probably totally invalid data.
Fix this logic error up by calling usb_control_msg_recv() which guarantees a "full" read happens, and then simplify the error checking for when btmtk_usb_reg_read() is called (it's really just btmtk_usb_id_get() that calls btmtk_usb_reg_read(), so fix up those return sites.
Stable-dep-of: 59c3ee19ca88 ("Bluetooth: btmtk: Do not report success when subsys reset fails")
--- drivers/bluetooth/btmtk.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-)
drivers/bluetooth/btmtk.c +15 -21
@@ -815,27 +815,21 @@ static int btmtk_usb_uhw_reg_read(struct hci_dev *hdev, u32 reg, u32 *val)static int btmtk_usb_reg_read (struct hci_dev *hdev,u32 reg,u32 *val) {struct btmtk_data *data =hci_get_priv (hdev); -int pipe, err, size =sizeof (u32); -void *buf; - - buf =kzalloc (size,GFP_KERNEL ); -if (!buf) -return -ENOMEM ; +u8 buf[sizeof (u32)]; +int err; - pipe =usb_rcvctrlpipe (data->udev,0 ); - err =usb_control_msg (data->udev, pipe,0x63 , -USB_TYPE_VENDOR |USB_DIR_IN , - reg >>16 , reg &0xffff , - buf, size,USB_CTRL_GET_TIMEOUT ); + *val =0 ; + err =usb_control_msg_recv (data->udev,0 ,0x63 , +USB_TYPE_VENDOR |USB_DIR_IN , + reg >>16 , reg &0xffff , + buf,sizeof (buf),USB_CTRL_GET_TIMEOUT , +GFP_KERNEL );if (err <0 ) - goto err_free_buf; +return err; *val =get_unaligned_le32 (buf); -err_free_buf: -kfree (buf); - -return err; +return 0 ; }static int btmtk_usb_id_get (struct hci_dev *hdev,u32 reg,u32 *id)
@@ -962,7 +956,7 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id) } err =btmtk_usb_id_get (hdev,0x70010200 , &val); -if (err <0 || (!val && dev_id !=0x6639 )) +if (err || (!val && dev_id !=0x6639 ))bt_dev_err (hdev,"Can't get device id, subsys reset fail." );return err;
@@ -1324,24 +1318,24 @@ int btmtk_usb_setup(struct hci_dev *hdev) calltime =ktime_get (); err =btmtk_usb_id_get (hdev,0x80000008 , &dev_id); -if (err <0 ) { +if (err) {bt_dev_err (hdev,"Failed to get device id (%d)" , err);return err; }if (!dev_id || dev_id !=0x7663 ) { err =btmtk_usb_id_get (hdev,0x70010200 , &dev_id); -if (err <0 ) { +if (err) {bt_dev_err (hdev,"Failed to get device id (%d)" , err);return err; } err =btmtk_usb_id_get (hdev,0x80021004 , &fw_version); -if (err <0 ) { +if (err) {bt_dev_err (hdev,"Failed to get fw version (%d)" , err);return err; } err =btmtk_usb_id_get (hdev,0x70010020 , &fw_flavor); -if (err <0 ) { +if (err) {bt_dev_err (hdev,"Failed to get fw flavor (%d)" , err);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1392/1518 Bluetooth: btmtk: Do not report success when subsys reset fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ismail Tarim <[email protected]>
[ Upstream commit 59c3ee19ca88210bfc0e22ce59218091cb1a3c48 ]
btmtk_usb_subsys_reset() validates the subsystem reset by reading the chip id back. When that read succeeds at the bus level but yields an id of zero, the reset has demonstrably not taken effect: the function logs "Can't get device id, subsys reset fail." and then returns the return value of btmtk_usb_id_get(), which in that case is zero, i.e. success.
btusb_mtk_reset() returns that value unchanged, so its caller cannot tell a completed reset from a failed one.
Return -ENODEV when the chip id reads back as zero, leaving the existing MT6639 exemption intact.
Observed on an MT7902 [13d3:3579]. The path can be reached on demand by asking the controller for a coredump, since btmtk requests a reset once the dump completes:
# echo 1 > /sys/class/bluetooth/hci0/device/coredump
Bluetooth: hci0: Mediatek coredump end
Bluetooth: hci0: Can't get device id, subsys reset fail. usb 3-10: reset high-speed USB device number 5 using xhci_hcd usb 3-10: device descriptor read/64, error -110
usb usb3-port10: attempt power cycle
usb usb3-port10: unable to enumerate USB device
The same sequence occurs unprompted when the controller firmware asserts on its own.
Note that this corrects the error reporting only; it does not by itself make the controller recoverable in the case above.
--- drivers/bluetooth/btmtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/btmtk.c +3 -1
@@ -956,8 +956,10 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id) } err =btmtk_usb_id_get (hdev,0x70010200 , &val); -if (err || (!val && dev_id !=0x6639 )) +if (err || (!val && dev_id !=0x6639 )) {bt_dev_err (hdev,"Can't get device id, subsys reset fail." ); +return err ? err : -ENODEV ; + }return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1393/1518 Bluetooth: btmtk: Do not discard the subsystem reset timeout
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ismail Tarim <[email protected]>
[ Upstream commit 21b50c24843b51f88ac4316dd470d2803da0c42f ]
When the MTK_BT_RST_DONE poll times out, btmtk_usb_subsys_reset() logs "Reset timeout" and keeps the error in err, but err is then overwritten by the return value of the following btmtk_usb_id_get() call, so the timeout is never reported to the caller.
Commit 25b6d7593a3a ("Bluetooth: btmtk: introduce btmtk reset work") discarded the return value of the chip id read, so the function returned the timeout error as intended. Commit 3dcb122b3064 ("Bluetooth: btusb:
mediatek: return error for failed reg access") started assigning err at that call and silently dropped it.
Keep the timeout in a separate variable and return it, restoring the original behaviour without changing the control flow.
--- drivers/bluetooth/btmtk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtk.c +5 -2
@@ -848,6 +848,7 @@ static u32 btmtk_usb_reset_done(struct hci_dev *hdev)int btmtk_usb_subsys_reset (struct hci_dev *hdev,u32 dev_id) { +int reset_err =0 ;u32 val;int err;
@@ -946,8 +947,10 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id) err =readx_poll_timeout (btmtk_usb_reset_done, hdev, val, val &MTK_BT_RST_DONE ,20000 ,1000000 ); -if (err <0 ) +if (err <0 ) {bt_dev_err (hdev,"Reset timeout" ); + reset_err = err; + }if (dev_id ==0x7922 ) { err =btmtk_usb_uhw_reg_write (hdev,MTK_UDMA_INT_STA_BT ,0x000000FF );
@@ -961,7 +964,7 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id)return err ? err : -ENODEV ; } -return err; +return reset_err; }EXPORT_SYMBOL_GPL (btmtk_usb_subsys_reset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1394/1518 Bluetooth: btmtksdio: Take exclusive ownership of the SKB before TX
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 155e3003d1e614f85566b636973df7118e1b4851 ]
btmtksdio_tx_packet() prepends the MediaTek SDIO header with skb_push() and writes into that space after only checking the headroom size. On a cloned SKB that headroom belongs to a buffer shared with the other owner, which the driver has no right to write to.
Cloned SKBs do reach this path: hci_send_cmd_sync() keeps a clone of every HCI command in hdev->sent_cmd before handing the SKB to the driver, and l2cap_ertm_send() clones SKBs for retransmission.
Replace the open-coded headroom check with skb_cow_head(), which both guarantees the headroom and reallocates a private buffer when the SKB is cloned. The cost is one reallocation and copy per cloned packet, the usual price of this pattern in network drivers.
This has no observable effect on its own, as the driver only writes in front of skb->data where no other owner looks. It is a prerequisite for "Bluetooth: btmtksdio: Fix out-of-bounds DMA read in the TX path", which writes padding behind skb->tail, and carries the same Fixes: tag so that both are backported together.
--- drivers/bluetooth/btmtksdio.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/bluetooth/btmtksdio.c +6 -7
@@ -274,13 +274,12 @@ static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev,struct mtkbtsdio_hdr *sdio_hdr;int err; -/* Make sure that there are enough rooms for SDIO header */ -if (unlikely (skb_headroom (skb) <sizeof (*sdio_hdr))) { - err =pskb_expand_head (skb,sizeof (*sdio_hdr),0 , -GFP_ATOMIC ); -if (err <0 ) -return err; - } +/* Make sure that the data buffer is not shared with anyone else and +* that there is enough room for the SDIO header +*/ + err =skb_cow_head (skb,sizeof (*sdio_hdr)); +if (err <0 ) +return err;/* Prepend MediaTek SDIO Specific Header */ skb_push (skb,sizeof (*sdio_hdr));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1395/1518 Bluetooth: btmtksdio: Fix out-of-bounds DMA read in the TX path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit fa0ad2d277c7adead61d1c22411c55cea6990c2a ]
btmtksdio_tx_packet() rounds the transfer size up to the SDIO block size of 256 bytes, but hands the host controller the SKB buffer as is:
err = sdio_writesb(bdev->func, MTK_REG_CTDR, skb->data, round_up(skb->len, MTK_SDIO_BLOCK_SIZE));
Only skb->len bytes hold packet data, so the controller reads up to 255 bytes of uninitialised memory and sends it to the device over the SDIO bus. Depending on how much tailroom slack the SKB allocation happens to carry, that read can also extend past the end of the buffer.
Compute the padded length up front, ensure the SKB has tailroom for it, and zero-fill the padding with skb_put_zero(). skb->len then covers the padding, so sdio_writesb() no longer needs to round up. byte_tx keeps counting the header and the payload only, and the error path restores the SKB so that the caller can requeue it.
Writing behind skb->tail is only safe because the driver owns the buffer, which "Bluetooth: btmtksdio: Take exclusive ownership of the SKB before TX" ensures.
--- drivers/bluetooth/btmtksdio.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/bluetooth/btmtksdio.c +21 -5
@@ -272,6 +272,7 @@ static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev, struct sk_buff *skb) {struct mtkbtsdio_hdr *sdio_hdr; +unsigned int len, pad_len;int err;/* Make sure that the data buffer is not shared with anyone else and
@@ -281,6 +282,18 @@ static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev,if (err <0 )return err; +/* The transfer is rounded up to the SDIO block size, so the buffer +* has to provide tailroom for the padding as well +*/ + len = skb->len +sizeof (*sdio_hdr); + pad_len =round_up (len,MTK_SDIO_BLOCK_SIZE ) - len; + +if (unlikely (skb_tailroom (skb) < pad_len)) { + err =pskb_expand_head (skb,0 , pad_len,GFP_ATOMIC ); +if (err <0 ) +return err; + } +/* Prepend MediaTek SDIO Specific Header */ skb_push (skb,sizeof (*sdio_hdr));
@@ -289,19 +302,22 @@ static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev, sdio_hdr->reserved =cpu_to_le16 (0 ); sdio_hdr->bt_type =hci_skb_pkt_type (skb); +/* Zero the padding so that no uninitialised memory is sent out */ +skb_put_zero (skb, pad_len); +clear_bit (BTMTKSDIO_HW_TX_READY , &bdev->tx_state); - err =sdio_writesb (bdev->func,MTK_REG_CTDR , skb->data, -round_up (skb->len,MTK_SDIO_BLOCK_SIZE )); + err =sdio_writesb (bdev->func,MTK_REG_CTDR , skb->data, skb->len);if (err <0 ) - goto err_skb_pull; + goto err_skb_restore; - bdev->hdev->stat.byte_tx += skb->len; + bdev->hdev->stat.byte_tx += len;kfree_skb (skb);return 0 ; -err_skb_pull: +err_skb_restore: +skb_trim (skb, len);skb_pull (skb,sizeof (*sdio_hdr));return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1396/1518 Bluetooth: btnxpuart: Validate the FW dump header length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
[ Upstream commit 060fa7592bdc043a93b6b7870f5b8551206d315d ]
nxp_process_fw_dump() pulls the ACL header off the frame and then reads seq_num and buf_len from a struct nxp_fw_dump_hdr placed at skb->data, without checking that the ACL payload is long enough to contain it.
h4_recv_buf() collects HCI_ACL_HDR_SIZE bytes of header followed by the number of payload bytes named in that header, so skb->len is 4 + dlen with dlen supplied by the controller and possibly smaller than the 8 byte dump header, or zero. A short frame with connection handle 0xfff therefore reads both fields from beyond the received data.
Beyond the read itself, buf_len is what terminates a dump: a value of zero makes the driver call hci_devcd_complete() and reset the controller, so a truncated frame can end a dump early.
Use skb_pull_data() to validate and pull the FW dump header before accessing its fields. Warn and reject the chunk if the header is truncated.
--- drivers/bluetooth/btnxpuart.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/bluetooth/btnxpuart.c +12 -3
@@ -1368,12 +1368,21 @@ static int nxp_process_fw_dump(struct hci_dev *hdev, struct sk_buff *skb) {struct hci_acl_hdr *acl_hdr = (struct hci_acl_hdr *)skb_pull_data (skb,sizeof (*acl_hdr)); -struct nxp_fw_dump_hdr *fw_dump_hdr = (struct nxp_fw_dump_hdr *)skb->data; +struct nxp_fw_dump_hdr *fw_dump_hdr;struct btnxpuart_dev *nxpdev =hci_get_drvdata (hdev); -__u16 seq_num =__le16_to_cpu (fw_dump_hdr->seq_num); -__u16 buf_len =__le16_to_cpu (fw_dump_hdr->buf_len); +__u16 seq_num; +__u16 buf_len;int err; + fw_dump_hdr =skb_pull_data (skb,sizeof (*fw_dump_hdr)); +if (!fw_dump_hdr) { +bt_dev_warn (hdev,"FW dump: invalid or corrupt fw dump chunk" ); + goto free_skb; + } + + seq_num =__le16_to_cpu (fw_dump_hdr->seq_num); + buf_len =__le16_to_cpu (fw_dump_hdr->buf_len); +if (seq_num ==0x0001 ) {if (test_and_set_bit (BTNXPUART_FW_DUMP_IN_PROGRESS , &nxpdev->tx_state)) {bt_dev_err (hdev,"FW dump already in progress" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1397/1518 Bluetooth: RFCOMM: Validate MTU in rfcomm_apply_pn() to prevent infinite loop
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 44c98fd082eafd49d55a8a4077ff488175b2fe24 ]
rfcomm_apply_pn() accepts the MTU value from a remote PN (Parameter Negotiation) frame without checking for zero. When the remote peer sends an MTU of zero, d->mtu is set to 0. This causes the sendmsg path to enter an infinite loop when fragmenting data, as each fragment has size == min_t(size_t, len, 0) == 0, so the remaining length never decreases. The infinite allocation of zero-length skbs exhausts all system memory.
Fix by clamping d->mtu to RFCOMM_DEFAULT_MTU when the negotiated value is zero, consistent with the initial value assigned in rfcomm_dlc_alloc().
--- net/bluetooth/rfcomm/core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/rfcomm/core.c +4 -0
@@ -1458,6 +1458,10 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn) d->mtu =__le16_to_cpu (pn->mtu); +/* MTU 0 causes an infinite loop when fragmenting in sendmsg */ +if (!d->mtu) + d->mtu =RFCOMM_DEFAULT_MTU ; +if (cr && d->mtu > s->mtu) d->mtu = s->mtu;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1398/1518 xsk: align TX metadata layout across ABIs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit bd7d30bd1d3856d8354b5acef947d68ad1faf886 ]
Add explicit padding before launch_time so xsk_tx_metadata has the same layout on 32-bit and 64-bit systems.
On several architectures (csky, i386, nios2, m65k, openrisc, sh), the old native 32-bit layout put launch_time at offset 12 and had a natural size of 20 bytes. Using sizeof(struct xsk_tx_metadata) as tx_metadata_len was already rejected because the length must be a multiple of eight, so the straightforward use of the interface was broken on those ABIs. Userspace could still register a padded length of 24 bytes, though; mixing the old and new layouts then silently reads launch_time from the wrong offset and misprograms packet launch times. This intentionally replaces that incompatible layout because the affected architectures are unlikely to have any notable users. (x86_64 and arm64 have the most users and are _not_ affected)
--- include/uapi/linux/if_xdp.h | 1 + tools/include/uapi/linux/if_xdp.h | 1 + 2 files changed, 2 insertions(+)
include/uapi/linux/if_xdp.h +1 -0
@@ -149,6 +149,7 @@ struct xsk_tx_metadata {__u16 csum_start;/* Offset from csum_start where checksum should be stored. */ __u16 csum_offset; +__u32 reserved;/* XDP_TXMD_FLAGS_LAUNCH_TIME */ /* Launch time in nanosecond against the PTP HW Clock */
tools/include/uapi/linux/if_xdp.h +1 -0
@@ -149,6 +149,7 @@ struct xsk_tx_metadata {__u16 csum_start;/* Offset from csum_start where checksum should be stored. */ __u16 csum_offset; +__u32 reserved;/* XDP_TXMD_FLAGS_LAUNCH_TIME */ /* Launch time in nanosecond against the PTP HW Clock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1399/1518 xsk: honor XDP_TX_METADATA in zero-copy path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit a6e4b9a6deb9362ef7a0706c70d674e92fe1411a ]
The zero-copy path reads TX metadata whenever the UMEM has metadata space, even if the descriptor does not set XDP_TX_METADATA. Pass descriptor options through the metadata helpers and ignore metadata unless the option is set.
This does not fix the existing per-WQE metadata handling for mlx5 MPWQEs. Only the descriptor that starts a session passes through xsk_tx_metadata_request() and configures offload state shared by the batch. Metadata on descriptors joining an open session is therefore not validated and does not configure its requested offloads. In addition, a non-NULL metadata pointer from such a descriptor is treated as a timestamp completion request even when XDP_TXMD_FLAGS_TIMESTAMP is not set, so its metadata union can be overwritten with an unrequested timestamp. Fixing mixed metadata states within one MPWQE requires a separate change.
--- drivers/net/ethernet/intel/igc/igc_main.c | 3 ++- .../ethernet/mellanox/mlx5/core/en/xsk/tx.c | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- include/net/libeth/xsk.h | 2 +- include/net/xdp_sock_drv.h | 22 +++++++++++-------- include/net/xsk_buff_pool.h | 3 ++- net/xdp/xsk_buff_pool.c | 7 ++++-- 7 files changed, 26 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/igc/igc_main.c +2 -1
@@ -3074,7 +3074,8 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring) olinfo_status = xdp_desc.len <<IGC_ADVTXD_PAYLEN_SHIFT ; dma =xsk_buff_raw_get_dma (pool, xdp_desc.addr); - meta =xsk_buff_get_metadata (pool, xdp_desc.addr); + meta =xsk_buff_get_metadata (pool, xdp_desc.addr, + xdp_desc.options);xsk_buff_raw_dma_sync_for_device (pool, dma, xdp_desc.len); bi = &ring->tx_buffer_info[ntu];
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c +1 -1
@@ -97,7 +97,7 @@ bool mlx5e_xsk_tx(struct mlx5e_xdpsq *sq, unsigned int budget) xdptxd.dma_addr =xsk_buff_raw_get_dma (pool, desc.addr); xdptxd.data =xsk_buff_raw_get_data (pool, desc.addr); xdptxd.len = desc.len; - meta =xsk_buff_get_metadata (pool, desc.addr); + meta =xsk_buff_get_metadata (pool, desc.addr, desc.options);xsk_buff_raw_dma_sync_for_device (pool, xdptxd.dma_addr, xdptxd.len);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -2545,7 +2545,8 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) tx_desc = tx_q->dma_tx + entry; dma_addr =xsk_buff_raw_get_dma (pool, xdp_desc.addr); - meta =xsk_buff_get_metadata (pool, xdp_desc.addr); + meta =xsk_buff_get_metadata (pool, xdp_desc.addr, + xdp_desc.options);xsk_buff_raw_dma_sync_for_device (pool, dma_addr, xdp_desc.len); tx_q->tx_skbuff_dma[entry].buf_type =STMMAC_TXBUF_T_XSK_TX ;
include/net/libeth/xsk.h +1 -1
@@ -196,7 +196,7 @@ __libeth_xsk_xmit_fill_buf_md(const struct xdp_desc *xdesc,struct libeth_xdp_tx_desc desc;struct xdp_desc_ctx ctx; - ctx =xsk_buff_raw_get_ctx (sq->pool, xdesc->addr); + ctx =xsk_buff_raw_get_ctx (sq->pool, xdesc->addr, xdesc->options); desc = (typeof (desc )){ .addr = ctx.dma,__libeth_xdp_tx_len (xdesc->len),
include/net/xdp_sock_drv.h +13 -9
@@ -236,6 +236,7 @@ static inline void *xsk_buff_raw_get_data(struct xsk_buff_pool *pool, u64 addr)* xsk_buff_raw_get_ctx - get &xdp_desc context * @pool: XSk buff pool desc address belongs to * @addr: desc address (from userspace) +* @options: desc options (from userspace) * * Wrapper for xp_raw_get_ctx() to be used in drivers, see its kdoc for * details.
@@ -244,9 +245,9 @@ static inline void *xsk_buff_raw_get_data(struct xsk_buff_pool *pool, u64 addr)* pointer, if it is present (initialized to %NULL otherwise). */ static inline struct xdp_desc_ctx -xsk_buff_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr) +xsk_buff_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr,u32 options) { -return xp_raw_get_ctx (pool, addr); +return xp_raw_get_ctx (pool, addr, options); }#define XDP_TXMD_FLAGS_VALID ( \
@@ -314,18 +315,20 @@ xsk_tx_metadata_request(const struct xsk_buff_pool *pool, }static inline struct xsk_tx_metadata * -__xsk_buff_get_metadata (const struct xsk_buff_pool *pool,void *data) +__xsk_buff_get_metadata (const struct xsk_buff_pool *pool,void *data, +unsigned int options) { -if (!pool->tx_metadata_len) +if (!pool->tx_metadata_len || !(options &XDP_TX_METADATA ))return NULL ;return data - pool->tx_metadata_len; }static inline struct xsk_tx_metadata * -xsk_buff_get_metadata (struct xsk_buff_pool *pool,u64 addr) +xsk_buff_get_metadata (struct xsk_buff_pool *pool,u64 addr,u32 options) { -return __xsk_buff_get_metadata (pool,xp_raw_get_data (pool, addr)); +return __xsk_buff_get_metadata (pool,xp_raw_get_data (pool, addr), + options); }static inline void xsk_buff_dma_sync_for_cpu (struct xdp_buff *xdp)
@@ -506,7 +509,7 @@ static inline void *xsk_buff_raw_get_data(struct xsk_buff_pool *pool, u64 addr) }static inline struct xdp_desc_ctx -xsk_buff_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr) +xsk_buff_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr,u32 options) {return (struct xdp_desc_ctx ){ }; }
@@ -526,13 +529,14 @@ xsk_tx_metadata_request(const struct xsk_buff_pool *pool, }static inline struct xsk_tx_metadata * -__xsk_buff_get_metadata (const struct xsk_buff_pool *pool,void *data) +__xsk_buff_get_metadata (const struct xsk_buff_pool *pool,void *data, +unsigned int options) {return NULL ; }static inline struct xsk_tx_metadata * -xsk_buff_get_metadata (struct xsk_buff_pool *pool,u64 addr) +xsk_buff_get_metadata (struct xsk_buff_pool *pool,u64 addr,u32 options) {return NULL ; }
include/net/xsk_buff_pool.h +2 -1
@@ -154,7 +154,8 @@ struct xdp_desc_ctx {struct xsk_tx_metadata *meta; }; -struct xdp_desc_ctx xp_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr); +struct xdp_desc_ctx xp_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr, +u32 options);static inline dma_addr_t xp_get_dma (struct xdp_buff_xsk *xskb) {
net/xdp/xsk_buff_pool.c +5 -2
@@ -767,6 +767,7 @@ EXPORT_SYMBOL(xp_raw_get_dma);* xp_raw_get_ctx - get &xdp_desc context * @pool: XSk buff pool desc address belongs to * @addr: desc address (from userspace) +* @options: desc options (from userspace) * * Helper for getting desc's DMA address and metadata pointer, if present. * Saves one call on hotpath and double calculation of the actual address.
@@ -775,14 +776,16 @@ EXPORT_SYMBOL(xp_raw_get_dma);* Return: new &xdp_desc_ctx struct containing desc's DMA address and metadata * pointer, if it is present (initialized to %NULL otherwise). */ -struct xdp_desc_ctx xp_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr) +struct xdp_desc_ctx xp_raw_get_ctx (const struct xsk_buff_pool *pool,u64 addr, +u32 options) {struct xdp_desc_ctx ret; addr =__xp_raw_get_addr (pool, addr); ret.dma =__xp_raw_get_dma (pool, addr); - ret.meta =__xsk_buff_get_metadata (pool,__xp_raw_get_data (pool, addr)); + ret.meta =__xsk_buff_get_metadata (pool,__xp_raw_get_data (pool, addr), + options);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1400/1518 gtp: add synchronize_net() in gtp_newlink() error path to prevent use-after-free
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang (Microsoft) <[email protected]>
[ Upstream commit d989e22ae9802c52c56ad4284d0caf26696cf6ae ]
gtp_newlink()'s error path frees tid_hash and addr_hash without waiting for an RCU grace period after clearing sk_user_data. A concurrent gtp_encap_recv() in softirq may still hold the gtp_dev pointer obtained via rcu_dereference_sk_user_data() and access the freed memory.
BUG: KASAN: slab-use-after-free in gtp0_pdp_find+0x1f6/0x200 (gtp.c:152) Call Trace: <IRQ> gtp0_pdp_find+0x1f6/0x200 gtp_encap_recv+0x527/0x24b0 udp_queue_rcv_one_skb+0x75f/0xc10
Add synchronize_net() before the kfree calls in out_hashtable, which covers all error paths from both gtp_encap_enable() and gtp_create_sockets().
--- drivers/net/gtp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/gtp.c +2 -0
@@ -1549,6 +1549,8 @@ static int gtp_newlink(struct net_device *dev, out_encap:gtp_encap_disable (gtp); out_hashtable: +/* Wait for RCU readers that may still reference this gtp_dev. */ +synchronize_net ();kfree (gtp->addr_hash);kfree (gtp->tid_hash);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1401/1518 octeontx2-af: fix NULL deref in NIX TM tree debugfs read path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshumali Gaur <[email protected]>
[ Upstream commit ec65631bd5ec251cdf67a4919fac7a3149a6e235 ]
rvu_dbg_nix_tm_tree_display() dereferences pfvf->sq_ctx without checking whether the SQ context has been allocated. Reading /sys/kernel/debug/octeontx2/nix/tm_tree for a NIX LF whose transmit queues are not set up triggers a kernel oops.
Guard the read path the same way rvu_dbg_nix_tm_tree_write() already does and return -EINVAL with a seq_file message when sq_ctx is NULL.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +6 -0
@@ -1689,6 +1689,12 @@ static int rvu_dbg_nix_tm_tree_display(struct seq_file *m, void *unused)return -EINVAL ; pfvf =rvu_get_pfvf (rvu, pcifunc); + +if (!pfvf->sq_ctx) { +seq_printf (m,"SQ context is not initialized for pcifunc 0x%x\n" , pcifunc); +return -EINVAL ; + } + max_id = pfvf->sq_ctx->qsize;memset (&aq_req,0 ,sizeof (struct nix_aq_enq_req ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1402/1518 octeontx2-vf: fix workqueue and netdev race in probe/remove
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshumali Gaur <[email protected]>
[ Upstream commit 3ba97ff4f873481d370bee7f7dfb87f8296af9be ]
Initialize the VF workqueue before register_netdev() so ndo_set_rx_mode does not queue work on a NULL workqueue. Unregister the netdev before destroying the workqueue, and add proper probe error cleanup.
--- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +13 -7
@@ -736,16 +736,16 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_ptp_destroy; + err =otx2_vf_wq_init (vf); +if (err) + goto err_ipsec_clean; + err =register_netdev (netdev);if (err) {dev_err (dev,"Failed to register netdevice\n" ); - goto err_ipsec_clean; + goto err_wq_destroy; } - err =otx2_vf_wq_init (vf); -if (err) - goto err_unreg_netdev; -otx2vf_set_ethtool_ops (netdev); err =otx2vf_mcam_flow_init (vf);
@@ -788,6 +788,10 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)otx2_shutdown_tc (vf); err_unreg_netdev:unregister_netdev (netdev); +err_wq_destroy: +cancel_work_sync (&vf->reset_task); +cancel_work_sync (&vf->rx_mode_work); +destroy_workqueue (vf->otx2_wq); err_ipsec_clean:cn10k_ipsec_clean (vf); err_ptp_destroy:
@@ -835,11 +839,13 @@ static void otx2vf_remove(struct pci_dev *pdev) }#endif -cancel_work_sync (&vf->reset_task);otx2_unregister_dl (vf);unregister_netdev (netdev); -if (vf->otx2_wq) +if (vf->otx2_wq) { +cancel_work_sync (&vf->reset_task); +cancel_work_sync (&vf->rx_mode_work);destroy_workqueue (vf->otx2_wq); + }cn10k_ipsec_clean (vf);otx2_ptp_destroy (vf);otx2_mcam_flow_del (vf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1403/1518 net: qualcomm: rmnet: restore skb->dev on deaggregated frames
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit a66734a1c5e36525ea07e9f4547fddc51e916de3 ]
rmnet_map_deaggregate() allocates each sub-frame with alloc_skb() and leaves skb->dev NULL. __rmnet_map_ingress_handler() assigns skb->dev = ep->egress_dev only on the data path, but a MAP command frame is dispatched to rmnet_map_command() before that, so rmnet_map_send_ack() runs netif_tx_lock(skb->dev) on a NULL device. An unprivileged user reaches this by unsharing a user+net namespace, creating an rmnet link over a tap device with INGRESS_DEAGGREGATION and INGRESS_MAP_COMMANDS, and writing an aggregated frame carrying a flow-control command to the tap fd.
Restore the assignment dropped by 378e25357ac7, so every skb leaving rmnet_map_deaggregate() has a valid device.
BUG: KASAN: null-ptr-deref in _raw_spin_lock (kernel/locking/spinlock.c:158) Write of size 4 at addr 00000000000004b4 by task exploit/144 Call Trace: _raw_spin_lock (kernel/locking/spinlock.c:158) netif_tx_lock (net/sched/sch_generic.c:497) rmnet_map_command (drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c:67) rmnet_rx_handler (drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:125) __netif_receive_skb_core.constprop.0 (net/core/dev.c:6103) ... __netif_receive_skb_one_core (net/core/dev.c:6214) netif_receive_skb (net/core/dev.c:6474) tun_get_user (drivers/net/tun.c:1966) tun_chr_write_iter (drivers/net/tun.c:2012) vfs_write (fs/read_write.c:687) ksys_write (fs/read_write.c:739) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception in interrupt
--- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +1 -0
@@ -394,6 +394,7 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,if (!skbn)return NULL ; + skbn->dev = skb->dev;skb_reserve (skbn,RMNET_MAP_DEAGGR_HEADROOM );skb_put (skbn, packet_len);memcpy (skbn->data, skb->data, packet_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1404/1518 octeontx2-af: Fix TL3/TL2 link config ENA clearing
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naveen Mamindlapalli <[email protected]>
[ Upstream commit 9edf8d4876e8a2471e66f54d36208eaff2858392 ]
Clear and restore the ENA bit for each TL3/TL2 link entry during SMQ flush instead of repeatedly using the same link index.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +5 -6
@@ -2436,8 +2436,8 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,int pf =rvu_get_pf (rvu->pdev, pcifunc);u8 cgx_id =0 , lmac_id =0 ;u16 tl2_tl3_link_schq; -u8 link, link_level;u64 cfg, bmap =0 ; +u8 link_level;if (!is_rvu_otx2 (rvu)) {/* Skip SMQ flush if pkt count is zero */
@@ -2469,7 +2469,6 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr, link_level =rvu_read64 (rvu, blkaddr,NIX_AF_PSE_CHANNEL_LEVEL ) &0x01 ?NIX_TXSCH_LVL_TL3 :NIX_TXSCH_LVL_TL2 ; tl2_tl3_link_schq = smq_flush_ctx->smq_tree_ctx[link_level].schq; - link = smq_flush_ctx->smq_tree_ctx[NIX_TXSCH_LVL_TL1 ].schq;/* SMQ set enqueue xoff */ cfg =rvu_read64 (rvu, blkaddr,NIX_AF_SMQX_CFG (smq));
@@ -2479,13 +2478,13 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,/* Clear all NIX_AF_TL3_TL2_LINK_CFG[ENA] for the TL3/TL2 queue */ for (i =0 ; i < (rvu->hw->cgx_links + rvu->hw->lbk_links); i++) { cfg =rvu_read64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link)); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i));if (!(cfg &BIT_ULL (12 )))continue ; bmap |=BIT_ULL (i); cfg &= ~BIT_ULL (12 );rvu_write64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link), cfg); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i), cfg); }/* Do SMQ flush and set enqueue xoff */
@@ -2506,10 +2505,10 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,if (!(bmap &BIT_ULL (i)))continue ; cfg =rvu_read64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link)); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i)); cfg |=BIT_ULL (12 );rvu_write64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link), cfg); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i), cfg); }/* clear XOFF on TL2s */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1405/1518 net: enetc: restore RX ring congestion mode after ring reconfiguration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Fang <[email protected]>
[ Upstream commit 9e94d8e14ae45e3fda8c0919f745db3ed3715433 ]
The RX ring congestion mode (CM) is only configured in the phylink .mac_link_up() callback enetc_pl_mac_link_up(), which sets the ENETC_RBMR_CM bit when tx_pause is enabled. This callback runs only when the link status changes.
However, enetc_reconfigure() tears down and re-creates the RX BD rings at runtime without any link status change, for example when attaching or detaching an XDP program, or when enabling/disabling PTP RX hardware timestamping. The rings are rebuilt from a cleared RBMR, so the CM bit is lost. Since the link status does not change, enetc_pl_mac_link_up() is not called again and the CM bit is never restored.
As a result, the ENETC MAC can no longer generate PAUSE frames on ingress congestion, and flow control stops working after such a reconfiguration.
Track the desired CM state in a software flag ENETC_RXBDR_CM. Set or clear this flag in enetc_pl_mac_link_up() according to tx_pause. When the RX BD rings are (re)enabled, enetc_enable_rxbdr() consults this flag and restores the ENETC_RBMR_CM bit accordingly, so flow control survives ring reconfiguration even when the link status does not change.
RBMR is now written as a whole word from enetc_enable_rxbdr() rather than by read-modify-write from several call sites. Serialize the remaining RBMR read-modify-write paths, the congestion mode update and the RX VLAN offload update, with the new si->gen_lock so they cannot race each other.
--- drivers/net/ethernet/freescale/enetc/enetc.c | 72 +++++++++++++++---- drivers/net/ethernet/freescale/enetc/enetc.h | 9 +++ .../net/ethernet/freescale/enetc/enetc_pf.c | 14 +--- 3 files changed, 68 insertions(+), 27 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc.c +57 -15
@@ -72,6 +72,33 @@ void enetc_reset_mac_addr_filter(struct enetc_mac_filter *filter) }EXPORT_SYMBOL_GPL (enetc_reset_mac_addr_filter); +void enetc_set_congestion_mode (struct enetc_ndev_priv *priv,bool enable) +{ +struct enetc_si *si = priv->si; +struct enetc_hw *hw = &si->hw; + +spin_lock (&si->gen_lock); + +if (enable) +set_bit (ENETC_RXBDR_CM , &priv->flags); +else +clear_bit (ENETC_RXBDR_CM , &priv->flags); + +for (int i =0 ; i < priv->num_rx_rings; i++) { +u32 old_rbmr =enetc_rxbdr_rd (hw, i,ENETC_RBMR ); +u32 rbmr; + + rbmr =u32_replace_bits (old_rbmr, enable,ENETC_RBMR_CM ); +if (rbmr == old_rbmr) +continue ; + +enetc_rxbdr_wr (hw, i,ENETC_RBMR , rbmr); + } + +spin_unlock (&si->gen_lock); +} +EXPORT_SYMBOL_GPL (enetc_set_congestion_mode); +static int enetc_num_stack_tx_queues (struct enetc_ndev_priv *priv) {int num_tx_rings = priv->num_tx_rings;
@@ -2624,7 +2651,6 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring, bool extended) {int idx = rx_ring->index; -u32 rbmr =0 ;enetc_rxbdr_wr (hw, idx,ENETC_RBBAR0 ,lower_32_bits (rx_ring->bd_dma_base));
@@ -2652,12 +2678,6 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,enetc_rxbdr_wr (hw, idx,ENETC_RBICR0 ,ENETC_RBICR0_ICEN |0x1 ); rx_ring->ext_en = extended; -if (rx_ring->ext_en) - rbmr |=ENETC_RBMR_BDS ; - -if (rx_ring->ndev->features &NETIF_F_HW_VLAN_CTAG_RX ) - rbmr |=ENETC_RBMR_VTE ; - rx_ring->rcir = hw->reg +ENETC_BDR (RX , idx,ENETC_RBCIR ); rx_ring->idr = hw->reg +ENETC_SIRXIDR ;
@@ -2668,8 +2688,6 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,enetc_lock_mdio ();enetc_refill_rx_ring (rx_ring,enetc_bd_unused (rx_ring));enetc_unlock_mdio (); - -enetc_rxbdr_wr (hw, idx,ENETC_RBMR , rbmr); }static void enetc_setup_bdrs (struct enetc_ndev_priv *priv,bool extended)
@@ -2696,21 +2714,34 @@ static void enetc_enable_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)static void enetc_enable_rxbdr (struct enetc_hw *hw,struct enetc_bdr *rx_ring) { +struct enetc_ndev_priv *priv =netdev_priv (rx_ring->ndev);int idx = rx_ring->index; -u32 rbmr; +u32 rbmr =ENETC_RBMR_EN ; + +if (rx_ring->ext_en) + rbmr |=ENETC_RBMR_BDS ; + +if (rx_ring->ndev->features &NETIF_F_HW_VLAN_CTAG_RX ) + rbmr |=ENETC_RBMR_VTE ; + +if (test_bit (ENETC_RXBDR_CM , &priv->flags)) + rbmr |=ENETC_RBMR_CM ; - rbmr =enetc_rxbdr_rd (hw, idx,ENETC_RBMR ); - rbmr |=ENETC_RBMR_EN ;enetc_rxbdr_wr (hw, idx,ENETC_RBMR , rbmr); }static void enetc_enable_rx_bdrs (struct enetc_ndev_priv *priv) { -struct enetc_hw *hw = &priv->si->hw; +struct enetc_si *si = priv->si; +struct enetc_hw *hw = &si->hw;int i; +spin_lock (&si->gen_lock); +for (i =0 ; i < priv->num_rx_rings; i++)enetc_enable_rxbdr (hw, priv->rx_ring[i]); + +spin_unlock (&si->gen_lock); }static void enetc_enable_tx_bdrs (struct enetc_ndev_priv *priv)
@@ -2740,11 +2771,16 @@ static void enetc_disable_txbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)static void enetc_disable_rx_bdrs (struct enetc_ndev_priv *priv) { -struct enetc_hw *hw = &priv->si->hw; +struct enetc_si *si = priv->si; +struct enetc_hw *hw = &si->hw;int i; +spin_lock (&si->gen_lock); +for (i =0 ; i < priv->num_rx_rings; i++)enetc_disable_rxbdr (hw, priv->rx_ring[i]); + +spin_unlock (&si->gen_lock); }static void enetc_disable_tx_bdrs (struct enetc_ndev_priv *priv)
@@ -3336,11 +3372,16 @@ EXPORT_SYMBOL_GPL(enetc_get_stats);static void enetc_enable_rxvlan (struct net_device *ndev,bool en) {struct enetc_ndev_priv *priv =netdev_priv (ndev); -struct enetc_hw *hw = &priv->si->hw; +struct enetc_si *si = priv->si; +struct enetc_hw *hw = &si->hw;int i; +spin_lock (&si->gen_lock); +for (i =0 ; i < priv->num_rx_rings; i++)enetc_bdr_enable_rxvlan (hw, i, en); + +spin_unlock (&si->gen_lock); }static void enetc_enable_txvlan (struct net_device *ndev,bool en)
@@ -3670,6 +3711,7 @@ int enetc_pci_probe(struct pci_dev *pdev, const char *name, int sizeof_priv) si =PTR_ALIGN (p,ENETC_SI_ALIGN ); si->pad = (char *)si - (char *)p; +spin_lock_init (&si->gen_lock);pci_set_drvdata (pdev, si); si->pdev = pdev;
drivers/net/ethernet/freescale/enetc/enetc.h +9 -0
@@ -309,6 +309,13 @@ struct enetc_si {struct net_device *ndev;/* back ref. */ +/* General-purpose lock serializing updates that must not race, +* e.g. read-modify-write of shared hardware registers and of +* selected priv->flags bits between the phylink link callbacks +* and the ring (re)configuration path. +*/ +spinlock_t gen_lock; +union {struct enetc_cbdr cbd_ring;/* Only ENETC 1.0 */ struct ntmp_user ntmp_user;/* ENETC 4.1 and later */
@@ -413,6 +420,7 @@ enum enetc_active_offloads {enum enetc_flags_bit {ENETC_TX_ONESTEP_TSTAMP_IN_PROGRESS =0 ,ENETC_TX_DOWN , +ENETC_RXBDR_CM , };/* interrupt coalescing modes */
@@ -509,6 +517,7 @@ int enetc_get_driver_data(struct enetc_si *si);void enetc_add_mac_addr_ht_filter (struct enetc_mac_filter *filter,const unsigned char *addr);void enetc_reset_mac_addr_filter (struct enetc_mac_filter *filter); +void enetc_set_congestion_mode (struct enetc_ndev_priv *priv,bool enable);int enetc_open (struct net_device *ndev);int enetc_close (struct net_device *ndev);
drivers/net/ethernet/freescale/enetc/enetc_pf.c +2 -12
@@ -691,8 +691,7 @@ static void enetc_pl_mac_link_up(struct phylink_config *config,struct enetc_hw *hw = &pf->si->hw;struct enetc_si *si = pf->si;struct enetc_ndev_priv *priv; -u32 rbmr, cmd_cfg; -int idx; +u32 cmd_cfg; priv =netdev_priv (pf->si->ndev);
@@ -704,16 +703,7 @@ static void enetc_pl_mac_link_up(struct phylink_config *config,enetc_force_rgmii_mac (si, speed, duplex);/* Flow control */ -for (idx =0 ; idx < priv->num_rx_rings; idx++) { - rbmr =enetc_rxbdr_rd (hw, idx,ENETC_RBMR ); - -if (tx_pause) - rbmr |=ENETC_RBMR_CM ; -else - rbmr &= ~ENETC_RBMR_CM ; - -enetc_rxbdr_wr (hw, idx,ENETC_RBMR , rbmr); - } +enetc_set_congestion_mode (priv, tx_pause);if (tx_pause) {/* When the port first enters congestion, send a PAUSE request
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1406/1518 net/sched: add qstats_cpu_drop_inc() helper
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 3f3aa77ff1c8b45ec8c9e40212f1a24a93e00df3 ]
1) Using this_cpu_inc() is better than going through this_cpu_ptr():
- Single instruction on x86.
- Store tearing prevention.
2) Change tcf_action_update_stats() to use this_cpu_add().
3) Add WRITE_ONCE() to __qdisc_qstats_drop() and qstats_drop_inc() in preparation for lockless "tc qdisc show".
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/0 grow/shrink: 3/17 up/down: 72/-216 (-144) Function old new delta dualpi2_enqueue_skb 462 511 +49 tcf_ife_act 1061 1077 +16 taprio_enqueue 613 620 +7 codel_qdisc_enqueue 149 143 -6 tcf_vlan_act 684 676 -8 tcf_skbedit_act 626 618 -8 tcf_police_act 725 717 -8 tcf_mpls_act 1297 1289 -8 tcf_gate_act 310 302 -8 tcf_gact_act 222 214 -8 tcf_csum_act 2438 2430 -8 tcf_bpf_act 709 701 -8 tcf_action_update_stats 124 115 -9 pie_qdisc_enqueue 865 856 -9 pfifo_enqueue 116 107 -9 choke_enqueue 2069 2059 -10 plug_enqueue 139 128 -11 bfifo_enqueue 121 110 -11 tcf_nat_act 1501 1489 -12 gred_enqueue 1743 1668 -75 Total: Before=24388609, After=24388465, chg -0.00%
Stable-dep-of: 5b483f7791b0 ("net/sched: act_ife: Only operate on Ethernet frames")
--- include/net/act_api.h | 2 +- include/net/sch_generic.h | 9 +++++++-- net/sched/act_api.c | 2 +- net/sched/act_bpf.c | 2 +- net/sched/act_ife.c | 8 ++++---- net/sched/act_mpls.c | 2 +- net/sched/act_police.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/sch_cake.c | 2 +- net/sched/sch_fq_codel.c | 2 +- net/sched/sch_gred.c | 2 +- 11 files changed, 20 insertions(+), 15 deletions(-)
include/net/act_api.h +1 -1
@@ -242,7 +242,7 @@ static inline void tcf_action_update_bstats(struct tc_action *a,static inline void tcf_action_inc_drop_qstats (struct tc_action *a) {if (likely (a->cpu_qstats)) { -qstats_drop_inc (this_cpu_ptr (a->cpu_qstats)); +qstats_cpu_drop_inc (a->cpu_qstats);return ; }atomic_inc (&a->tcfa_drops);
include/net/sch_generic.h +7 -2
@@ -967,12 +967,17 @@ static inline void qdisc_qstats_cpu_requeues_inc(struct Qdisc *sch)static inline void __qdisc_qstats_drop (struct Qdisc *sch,int count) { - sch->qstats.drops += count; +WRITE_ONCE (sch->qstats.drops, sch->qstats.drops + count); }static inline void qstats_drop_inc (struct gnet_stats_queue *qstats) { - qstats->drops++; +WRITE_ONCE (qstats->drops, qstats->drops +1 ); +} + +static inline void qstats_cpu_drop_inc (struct gnet_stats_queue __percpu *qstats) +{ +this_cpu_inc (qstats->drops); }static inline void qstats_overlimit_inc (struct gnet_stats_queue *qstats)
net/sched/act_api.c +1 -1
@@ -1581,7 +1581,7 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets,if (a->cpu_bstats) {_bstats_update (this_cpu_ptr (a->cpu_bstats), bytes, packets); -this_cpu_ptr (a->cpu_qstats)->drops += drops; +this_cpu_add (a->cpu_qstats->drops, drops);if (hw) _bstats_update(this_cpu_ptr(a->cpu_bstats_hw),
net/sched/act_bpf.c +1 -1
@@ -76,7 +76,7 @@ TC_INDIRECT_SCOPE int tcf_bpf_act(struct sk_buff *skb,break ;case TC_ACT_SHOT : action = filter_res; -qstats_drop_inc (this_cpu_ptr (prog->common.cpu_qstats)); +qstats_cpu_drop_inc (prog->common.cpu_qstats);break ;case TC_ACT_UNSPEC : action = prog->tcf_action;
net/sched/act_ife.c +4 -4
@@ -727,7 +727,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, tlv_data =ife_decode (skb, &metalen);if (unlikely (!tlv_data)) { -qstats_drop_inc (this_cpu_ptr (ife->common.cpu_qstats)); +qstats_cpu_drop_inc (ife->common.cpu_qstats);return TC_ACT_SHOT ; }
@@ -740,7 +740,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, curr_data =ife_tlv_meta_decode (tlv_data, ifehdr_end, &mtype, &dlen,NULL );if (!curr_data) { -qstats_drop_inc (this_cpu_ptr (ife->common.cpu_qstats)); +qstats_cpu_drop_inc (ife->common.cpu_qstats);return TC_ACT_SHOT ; }
@@ -755,7 +755,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, }if (WARN_ON (tlv_data != ifehdr_end)) { -qstats_drop_inc (this_cpu_ptr (ife->common.cpu_qstats)); +qstats_cpu_drop_inc (ife->common.cpu_qstats);return TC_ACT_SHOT ; }
@@ -821,7 +821,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,* so lets be conservative.. */ if ((action ==TC_ACT_SHOT ) || exceed_mtu) { drop: -qstats_drop_inc (this_cpu_ptr (ife->common.cpu_qstats)); +qstats_cpu_drop_inc (ife->common.cpu_qstats);return TC_ACT_SHOT ; }
net/sched/act_mpls.c +1 -1
@@ -123,7 +123,7 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,return p->action; drop: -qstats_drop_inc (this_cpu_ptr (m->common.cpu_qstats)); +qstats_cpu_drop_inc (m->common.cpu_qstats);return TC_ACT_SHOT ; }
net/sched/act_police.c +1 -1
@@ -316,7 +316,7 @@ TC_INDIRECT_SCOPE int tcf_police_act(struct sk_buff *skb,qstats_overlimit_inc (this_cpu_ptr (police->common.cpu_qstats)); inc_drops:if (ret ==TC_ACT_SHOT ) -qstats_drop_inc (this_cpu_ptr (police->common.cpu_qstats)); +qstats_cpu_drop_inc (police->common.cpu_qstats); end:return ret; }
net/sched/act_skbedit.c +1 -1
@@ -86,7 +86,7 @@ TC_INDIRECT_SCOPE int tcf_skbedit_act(struct sk_buff *skb,return params->action; err: -qstats_drop_inc (this_cpu_ptr (d->common.cpu_qstats)); +qstats_cpu_drop_inc (d->common.cpu_qstats);return TC_ACT_SHOT ; }
net/sched/sch_cake.c +1 -1
@@ -1829,7 +1829,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,if (ack) {WRITE_ONCE (b->ack_drops, b->ack_drops +1 ); - sch->qstats.drops++; +qdisc_qstats_drop (sch); ack_pkt_len =qdisc_pkt_len (ack); b->bytes += ack_pkt_len; q->buffer_used += skb->truesize - ack->truesize;
net/sched/sch_fq_codel.c +1 -1
@@ -176,7 +176,7 @@ static unsigned int fq_codel_drop(struct Qdisc *sch, unsigned int max_packets, flow->cvars.count += i; q->backlogs[idx] -= len; q->memory_usage -= mem; - sch->qstats.drops += i; +__qdisc_qstats_drop (sch, i); sch->qstats.backlog -= len; sch->q.qlen -= i;return idx;
net/sched/sch_gred.c +1 -1
@@ -389,7 +389,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch) packets +=u64_stats_read (&hw_stats->stats.bstats[i].packets); sch->qstats.qlen += hw_stats->stats.qstats[i].qlen; sch->qstats.backlog += hw_stats->stats.qstats[i].backlog; - sch->qstats.drops += hw_stats->stats.qstats[i].drops; +__qdisc_qstats_drop (sch, hw_stats->stats.qstats[i].drops); sch->qstats.requeues += hw_stats->stats.qstats[i].requeues; sch->qstats.overlimits += hw_stats->stats.qstats[i].overlimits; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1407/1518 net/sched: act_ife: Only operate on Ethernet frames
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 5b483f7791b079bb97d411f1066652ff659207ff ]
act_ife encapsulates/decapsulates the original Ethernet header and uses skb->dev->hard_header_len as the length of that header. That is only correct for Ethernet devices: on a device where hard_header_len does not match the L2 header that was actually pulled (PPP reports PPP_HDRLEN while nothing is stripped on ingress), the ingress skb_push()/skb_pull() use the wrong length and can hit skb_under_panic when headroom is tight.
IFE is Ethernet-only by design - it builds an outer ethhdr, rewrites h_source/h_dest/h_proto, and calls eth_type_trans() on decode - so instead of trying to make the offsets work for arbitrary link types, simply drop packets that do not carry an Ethernet header.
Checking skb->dev->type alone is not enough. We have to cater for a corner case where mirred can redirect an skb from a non-Ethernet device to an Ethernet one, and skb->dev then says nothing about the framing the skb actually has: an skb redirected from ppp0 reaches the target's ingress hook with mac_len 0 and no Ethernet header at all. So at ingress also require mac_len to be ETH_HLEN. On egress mac_len is not maintained, so the device type is all we have; a bogus redirect there yields a malformed frame rather than an out-of-bounds push, and it would be malformed with or without IFE.
That corner case is not theoretical - redirecting from ppp0 into a veth that has an ife encode action on its ingress hook panics without this patch:
skbuff: skb_under_panic: len:98 put:14 head:ffff88800e410000
data:ffff88800e40fff5 tail:0x57 end:0x640 dev:veth3 kernel BUG at net/core/skbuff.c:214! Call Trace: skb_push (net/core/skbuff.c:224 net/core/skbuff.c:2657) tcf_ife_act (net/sched/act_ife.c:829 net/sched/act_ife.c:874) tc_run (net/core/dev.c:4463) netif_receive_skb (net/core/dev.c:6463 net/core/dev.c:6522) tcf_mirred_to_dev (net/sched/act_mirred.c:248 net/sched/act_mirred.c:328) tcf_mirred_act (net/sched/act_mirred.c:489) tc_run (net/core/dev.c:4463) process_backlog (net/core/dev.c:6728)
With Ethernet framing guaranteed, use ETH_HLEN instead of hard_header_len.
--- net/ife/ife.c | 14 +++++++------- net/sched/act_ife.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 11 deletions(-)
net/ife/ife.c +7 -7
@@ -37,7 +37,7 @@ void *ife_encode(struct sk_buff *skb, u16 metalen)* where ORIGDATA = original ethernet header ... */ int hdrm = metalen +IFE_METAHDRLEN ; -int total_push = hdrm + skb->dev->hard_header_len; +int total_push = hdrm +ETH_HLEN ;struct ifeheadr *ifehdr;struct ethhdr *iethh;/* inner ether header */ int skboff =0 ;
@@ -50,9 +50,9 @@ void *ife_encode(struct sk_buff *skb, u16 metalen) iethh = (struct ethhdr *) skb->data;__skb_push (skb, total_push); -memcpy (skb->data, iethh, skb->dev->hard_header_len); +memcpy (skb->data, iethh,ETH_HLEN );skb_reset_mac_header (skb); - skboff += skb->dev->hard_header_len; + skboff +=ETH_HLEN ;/* total metadata length */ ifehdr = (struct ifeheadr *) (skb->data + skboff);
@@ -69,12 +69,12 @@ void *ife_decode(struct sk_buff *skb, u16 *metalen)int total_pull;u16 ifehdrln; -if (!pskb_may_pull (skb, skb->dev->hard_header_len +IFE_METAHDRLEN )) +if (!pskb_may_pull (skb,ETH_HLEN +IFE_METAHDRLEN ))return NULL ; - ifehdr = (struct ifeheadr *) (skb->data + skb->dev->hard_header_len); + ifehdr = (struct ifeheadr *)(skb->data +ETH_HLEN ); ifehdrln =ntohs (ifehdr->metalen); - total_pull = skb->dev->hard_header_len + ifehdrln; + total_pull =ETH_HLEN + ifehdrln;if (unlikely (ifehdrln <2 ))return NULL ;
@@ -82,7 +82,7 @@ void *ife_decode(struct sk_buff *skb, u16 *metalen)if (unlikely (!pskb_may_pull (skb, total_pull +ETH_HLEN )))return NULL ; - ifehdr = (struct ifeheadr *)(skb->data + skb->dev->hard_header_len); + ifehdr = (struct ifeheadr *)(skb->data +ETH_HLEN );skb_set_mac_header (skb, total_pull);__skb_pull (skb, total_pull); *metalen = ifehdrln -IFE_METAHDRLEN ;
net/sched/act_ife.c +28 -4
@@ -28,6 +28,7 @@#include <uapi/linux/tc_act/tc_ife.h> #include <net/tc_act/tc_ife.h> #include <linux/etherdevice.h> +#include <linux/if_arp.h> #include <net/ife.h> #include <net/tc_wrapper.h>
@@ -723,7 +724,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,tcf_lastuse_update (&ife->tcf_tm);if (skb_at_tc_ingress (skb)) -skb_push (skb, skb->dev->hard_header_len); +skb_push (skb,ETH_HLEN ); tlv_data =ife_decode (skb, &metalen);if (unlikely (!tlv_data)) {
@@ -795,7 +796,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,where ORIGDATA = original ethernet header ... */ u16 metalen =ife_get_sz (skb, p); -int hdrm = metalen + skb->dev->hard_header_len +IFE_METAHDRLEN ; +int hdrm = metalen +ETH_HLEN +IFE_METAHDRLEN ;unsigned int skboff =0 ;int new_len = skb->len + hdrm;bool exceed_mtu = false;
@@ -826,7 +827,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a, }if (skb_at_tc_ingress (skb)) -skb_push (skb, skb->dev->hard_header_len); +skb_push (skb,ETH_HLEN ); ife_meta =ife_encode (skb, metalen);if (!ife_meta)
@@ -856,11 +857,27 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a, oethh->h_proto =htons (p->eth_type);if (skb_at_tc_ingress (skb)) -skb_pull (skb, skb->dev->hard_header_len); +skb_pull (skb,ETH_HLEN );return action; } +/* IFE encapsulates the original Ethernet header and, on decode, expects to +* find one, so it can only ever work on skbs that carry one. Loopback carries +* Ethernet header as well, so it qualifies here. +* At ingress, also verify that the L2 header about to be pushed back really +* is an Ethernet header because the skb could've been redirected with mirred +* from a non-Ethernet device. +*/ +static bool tcf_ife_is_eth_skb (const struct sk_buff *skb) +{ +if (skb->dev->type !=ARPHRD_ETHER && + skb->dev->type !=ARPHRD_LOOPBACK ) +return false; + +return !skb_at_tc_ingress (skb) || skb->mac_len ==ETH_HLEN ; +} + TC_INDIRECT_SCOPE int tcf_ife_act(struct sk_buff *skb,const struct tc_action *a,struct tcf_result *res)
@@ -869,6 +886,13 @@ TC_INDIRECT_SCOPE int tcf_ife_act(struct sk_buff *skb,struct tcf_ife_params *p;int ret; +if (unlikely (!tcf_ife_is_eth_skb (skb))) { +bstats_update (this_cpu_ptr (ife->common.cpu_bstats), skb); +tcf_lastuse_update (&ife->tcf_tm); +qstats_cpu_drop_inc (ife->common.cpu_qstats); +return TC_ACT_SHOT ; + } + p =rcu_dereference_bh (ife->params);if (p->flags &IFE_ENCODE ) { ret =tcf_ife_encode (skb, a, res, p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1408/1518 net/rds: use wq_has_sleeper() in rds_cong_map_updated()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit d4f484661961636eb90d287050959e613795f73a ]
rds_cong_map_updated() runs after a peer's congestion map has been rewritten (by rds_tcp_cong_recv() and rds_ib_cong_recv(), or the clear-all in the loopback and IB send-completion paths). It bumps rds_cong_generation and then checks waitqueue_active() on map->m_waitq and on rds_poll_waitq to decide whether anyone needs waking. atomic_inc() carries no ordering and waitqueue_active() is a plain load, so nothing orders the map and generation stores before the wait queue reads. The waiters do the mirror image: rds_cong_wait() adds itself to m_waitq and then tests the port bit, and rds_poll() registers on rds_poll_waitq and then reads the generation. That is the store-buffering pattern described above waitqueue_active() in include/linux/wait.h - the updater can observe an empty wait queue while the waiter still observes the port as congested, and no wake-up is issued.
rds_cong_wait() is an interruptible sleep with no timeout, so a sender blocked on a congested port stays blocked until the next congestion update from that peer arrives or a signal is delivered. A poll() waiter misses the map-updated notification the same way.
Use wq_has_sleeper(), which is waitqueue_active() preceded by the required full barrier, as rds_tcp_state_change() already does for the same pattern.
--- net/rds/cong.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/rds/cong.c +2 -2
@@ -256,9 +256,9 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask) map, &map->m_addr);rds_stats_inc (s_cong_update_received);atomic_inc (&rds_cong_generation); -if (waitqueue_active (&map->m_waitq)) +if (wq_has_sleeper (&map->m_waitq))wake_up (&map->m_waitq); -if (waitqueue_active (&rds_poll_waitq)) +if (wq_has_sleeper (&rds_poll_waitq))wake_up_all (&rds_poll_waitq);if (portmask && !list_empty (&rds_cong_monitor)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1409/1518 octeontx2-pf: fix NULL deref of af_xdp_zc_qidx on rep setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Ghosh <[email protected]>
[ Upstream commit b09a0503c755b6609fad59a84cc7f05b6843a03c ]
af_xdp_zc_qidx tracks receive queues using AF_XDP zero-copy and is allocated during PF/VF probe. Representors and other non-AF_XDP paths leave the pointer NULL, but several call sites used test_bit() on it unconditionally.
Switching to devlink eswitch mode creates representors and runs otx2_init_hw_resources(), which reaches otx2_pool_aq_init() and oopses when dereferencing the NULL bitmap. Add NULL checks before every af_xdp_zc_qidx test_bit() use in the RSS, ethtool, XSK, and pool init paths.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 6 ++++-- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 3 ++- drivers/net/ethernet/marvell/octeontx2/nic/otx2_xsk.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +4 -2
@@ -333,7 +333,8 @@ int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id, const u32 *ind_tbl)/* Get memory to put this msg */ for (idx =0 ; idx < rss->rss_size; idx++) {/* Ignore the queue if AF_XDP zero copy is enabled */ -if (test_bit (ind_tbl[idx], pfvf->af_xdp_zc_qidx)) +if (pfvf->af_xdp_zc_qidx && +test_bit (ind_tbl[idx], pfvf->af_xdp_zc_qidx))continue ; aq =otx2_mbox_alloc_msg_nix_aq_enq (mbox);
@@ -1496,7 +1497,8 @@ int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,if (type !=AURA_NIX_RQ )return 0 ; -if (!test_bit (pool_id, pfvf->af_xdp_zc_qidx)) { +if (!pfvf->af_xdp_zc_qidx || + !test_bit (pool_id, pfvf->af_xdp_zc_qidx)) { pp_params.order =get_order (buf_size); pp_params.flags =PP_FLAG_DMA_MAP ; pp_params.pool_size =min (OTX2_PAGE_POOL_SZ , numptrs);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +2 -1
@@ -934,7 +934,8 @@ static int otx2_get_rxfh(struct net_device *dev,for (idx =0 ; idx < rss->rss_size; idx++) {/* Ignore if the rx queue is AF_XDP zero copy enabled */ -if (test_bit (rss->ind_tbl[idx], pfvf->af_xdp_zc_qidx)) +if (pfvf->af_xdp_zc_qidx && +test_bit (rss->ind_tbl[idx], pfvf->af_xdp_zc_qidx))continue ; indir[idx] = rss->ind_tbl[idx]; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_xsk.c +2 -1
@@ -193,7 +193,8 @@ int otx2_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)void otx2_attach_xsk_buff (struct otx2_nic *pfvf,struct otx2_snd_queue *sq,int qidx) { -if (test_bit (qidx, pfvf->af_xdp_zc_qidx)) +if (pfvf->af_xdp_zc_qidx && +test_bit (qidx, pfvf->af_xdp_zc_qidx)) sq->xsk_pool =xsk_get_pool_from_qid (pfvf->netdev, qidx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1410/1518 cifs: fix clearing stats for fastest execution of each smb2 command
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Sorenson <[email protected]>
[ Upstream commit 48cab1fd5720508148673f59d8ed52c7c7fffca2 ]
The code to clear the 'fastest_cmd' statistics has a typo that repeatedly clears the stat for cmd 0, rather than iterating through each cmd. Fix the typo (0->i).
--- fs/smb/client/cifs_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifs_debug.c +1 -1
@@ -776,7 +776,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,atomic_set (&server->smb2slowcmd[i],0 ); server->time_per_cmd[i] =0 ; server->slowest_cmd[i] =0 ; - server->fastest_cmd[0] = 0; + server->fastest_cmd[i] = 0; }#endif /* CONFIG_CIFS_STATS2 */ list_for_each_entry (ses, &server->smb_ses_list, smb_ses_list) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1411/1518 selftests/mm: skip COW tmpfile cases when fallocate() is unsupported
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 4004c130c358b1561a55323b0e747f20f5133f7b ]
Patch series "selftests/mm: Handle unsupported and transient test conditions", v3.
Several MM selftests report failures when the test environment lacks an underlying prerequisite, such as fallocate() support, MADV_REMOVE, local page-cache semantics, or swap.
This series converts those unsupported cases to SKIP while preserving failures for unexpected errors. It also allows migration tests to retry transient move_pages() failures.
This patch (of 4):
The tmpfile-backed COW cases allocate a one-page file with fallocate() before exercising private and shared mappings. When the filesystem backing tmpfile() does not implement fallocate(), setup fails with EOPNOTSUPP and no COW behavior is exercised.
This occurs when the temporary directory resides on a filesystem with limited allocation support, such as NFSv3. Reporting a failure adds noise because the test prerequisite is absent rather than the COW implementation being broken.
Report EOPNOTSUPP as a skip. Continue treating every other fallocate() error as a failure so unexpected setup regressions remain visible.
--- tools/testing/selftests/mm/cow.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/cow.c +7 -2
@@ -1699,8 +1699,13 @@ static void run_with_tmpfile(non_anon_test_fn fn, const char *desc)/* File consists of a single page filled with zeroes. */ if (fallocate (fd,0 ,0 , pagesize)) { -ksft_perror ("fallocate() failed" ); -log_test_result (KSFT_FAIL ); +if (errno ==EOPNOTSUPP ) { +ksft_print_msg ("fallocate() not supported by filesystem\n" ); +log_test_result (KSFT_SKIP ); + }else { +ksft_perror ("fallocate() failed" ); +log_test_result (KSFT_FAIL ); + } goto close; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1412/1518 maple_tree: catch race in mas_alloc_cyclic()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liam R. Howlett (Oracle) <[email protected]>
[ Upstream commit 35f1342e5b893a740eff2ef9ab337bfaa63ab76d ]
If mas_alloc_cyclic() is called during a low memory situation, it is possible the lock may be dropped so reclaim can occur. There is a window where some other task may allocate the same id and cause the mas_insert() to fail with -EEXIST. In this scenario the function will return -EEXIST, which is not expected.
Modifying the retry on mas_nomem() to re-search for a slot means that any race with other writes will not matter as the lock will be held between finding the index and writing the index.
Moving the flag logic avoids cases where the flag is modified on drop lock/reacquire or when the write fails after clearing the flag.
No existing users are exposed to this issue.
--- lib/maple_tree.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-)
lib/maple_tree.c +24 -19
@@ -4026,35 +4026,40 @@ int mas_alloc_cyclic(struct ma_state *mas, unsigned long *startp, void *entry, unsigned long range_lo, unsigned long range_hi, unsigned long *next, gfp_t gfp) { - unsigned long min = range_lo; -int ret =0 ; - - range_lo =max (min, *next); - ret =mas_empty_area (mas, range_lo, range_hi,1 ); -if ((mas->tree->ma_flags &MT_FLAGS_ALLOC_WRAPPED ) && ret ==0 ) { - mas->tree->ma_flags &= ~MT_FLAGS_ALLOC_WRAPPED ; - ret =1 ; - } -if (ret <0 && range_lo > min) { -mas_reset (mas); - ret =mas_empty_area (mas, min, range_hi,1 ); -if (ret ==0 ) - ret =1 ; - } -if (ret <0 ) -return ret; + int ret; +unsigned long min; + min = range_lo;do { + range_lo =max (min, *next); + ret =mas_empty_area (mas, range_lo, range_hi,1 ); +if (ret <0 && range_lo > min) { +mas_reset (mas); + ret =mas_empty_area (mas, min, range_hi,1 ); +if (ret ==0 ) + ret =1 ; + } +if (ret <0 ) + goto out; +mas_insert (mas, entry); }while (mas_nomem (mas, gfp)); -if (mas_is_err (mas)) -return xa_err (mas->node); +if (mas_is_err (mas)) { + ret =xa_err (mas->node); + goto out; + } + +if ((mas->tree->ma_flags &MT_FLAGS_ALLOC_WRAPPED ) && ret ==0 ) { + mas->tree->ma_flags &= ~MT_FLAGS_ALLOC_WRAPPED ; + ret =1 ; + } *startp = mas->index; *next = *startp +1 ;if (*next ==0 ) mas->tree->ma_flags |=MT_FLAGS_ALLOC_WRAPPED ; +out:mas_destroy (mas);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1413/1518 maple_tree: fix argument name in header
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liam R. Howlett (Oracle) <[email protected]>
[ Upstream commit 00f67814a14e614b749ebe54076ef1e3e6454f2b ]
The mas_prev_range() function takes a min and not a max.
--- include/linux/maple_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/maple_tree.h +1 -1
@@ -539,7 +539,7 @@ void mas_destroy(struct ma_state *mas);int mas_expected_entries (struct ma_state *mas,unsigned long nr_entries);void *mas_prev (struct ma_state *mas,unsigned long min); -void *mas_prev_range (struct ma_state *mas,unsigned long max); +void *mas_prev_range (struct ma_state *mas,unsigned long min);void *mas_next (struct ma_state *mas,unsigned long max);void *mas_next_range (struct ma_state *mas,unsigned long max);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1414/1518 selftests/proc: make proc-maps-race work with READ_IMPLIES_EXEC
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 0685630fdccb62dcb0e3f44525a40578da5f6dc8 ]
test_maps_tearing_from_split times out when READ_IMPLIES_EXEC is set. This happens by default on pre-ARMv6 CPUs, which lack no-execute support.
split_vma() re-maps the first page with mod_info->prot | PROT_EXEC to make it differ from its neighbours. With READ_IMPLIES_EXEC the original mapping is already executable, so no split occurs and the test hangs waiting for the modifier child.
Use PROT_NONE for the split mapping, which always differs from its readable neighbours.
--- tools/testing/selftests/proc/proc-maps-race.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/proc/proc-maps-race.c +2 -1
@@ -340,7 +340,8 @@ static bool query_addr_at(int maps_fd, void *addr,static inline bool split_vma (FIXTURE_DATA (proc_maps_race) *self) { -return mmap (self->mod_info->addr, self->page_size, self->mod_info->prot |PROT_EXEC , +/* PROT_NONE differs from both readable neighbors. */ +return mmap (self->mod_info->addr, self->page_size,PROT_NONE ,MAP_PRIVATE |MAP_ANONYMOUS |MAP_FIXED ,-1 ,0 ) !=MAP_FAILED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1415/1518 net/sched: act_skbmod: fix length calculations and avoid invalid header warnings
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 81d0d1e64f30d9989c829c0953cd6e6c68d9c5fb ]
syzbot reported a warning in skb_network_header_len() triggered by tcf_skbmod_act():
!skb_transport_header_was_set(skb)
WARNING: CPU: 0 PID: 14949 at include/linux/skbuff.h:3243 skb_network_header_len include/linux/skbuff.h:3243 [inline] WARNING: CPU: 0 PID: 14949 at net/sched/act_skbmod.c:55 tcf_skbmod_act+0xfe8/0x1810 net/sched/act_skbmod.c:55
There are a few issues in tcf_skbmod_act():
1. Calling skb_network_header_len() assumes skb->transport_header is set, which is not guaranteed when tcf_skbmod_act() runs at TC ingress.
2. Unconditionally calling skb_mac_header_len() at the beginning of tcf_skbmod_act() triggers a warning on L3 devices (e.g. TUN) where the MAC header is unset, evaluating to an underflowed garbage length.
3. On TC ingress, skb->data points to the network header. Adding the MAC header length to the IP header length causes skb_ensure_writable() to request more bytes than the actual IP packet length, dropping valid short packets (e.g. 28-byte UDP/IPv4 packets).
Fix these by:
- Using skb_network_offset(skb) + sizeof(struct iphdr/ipv6hdr) for SKBMOD_F_ECN so that the required length is correctly calculated on both ingress (offset == 0) and egress (offset == mac_len).
- Setting max_edit_len to ETH_HLEN for Ethernet header modifications after validating ARPHRD_ETHER.
--- net/sched/act_skbmod.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/sched/act_skbmod.c +8 -4
@@ -38,7 +38,6 @@ TC_INDIRECT_SCOPE int tcf_skbmod_act(struct sk_buff *skb,if (unlikely (p->action ==TC_ACT_SHOT )) goto drop; - max_edit_len =skb_mac_header_len (skb); flags = p->flags;/* tcf_skbmod_init() guarantees "flags" to be one of the following:
@@ -51,14 +50,19 @@ TC_INDIRECT_SCOPE int tcf_skbmod_act(struct sk_buff *skb,if (flags ==SKBMOD_F_ECN ) {switch (skb_protocol (skb, true)) {case cpu_to_be16 (ETH_P_IP ): + max_edit_len =sizeof (struct iphdr ); +break ;case cpu_to_be16 (ETH_P_IPV6 ): - max_edit_len +=skb_network_header_len (skb); + max_edit_len =sizeof (struct ipv6hdr );break ;default : goto out; } - }else if (!skb->dev || skb->dev->type !=ARPHRD_ETHER ) { - goto out; + max_edit_len +=skb_network_offset (skb); + }else { +if (!skb->dev || skb->dev->type !=ARPHRD_ETHER ) + goto out; + max_edit_len =ETH_HLEN ; } err =skb_ensure_writable (skb, max_edit_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1416/1518 net: core: check skb_frags_readable before uncloning in skb_copy_ubufs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mina Almasry <[email protected]>
[ Upstream commit 00e11ee9831b3439264e0ae6762a0470126515af ]
skb_copy_ubufs drops clones and modifies the SKB via pskb_expand_head() before checking for !skb_frags_readable(skb). This alters the SKB geometry prior to throwing an -EFAULT on an invalid SKB. Check readability first.
--- net/core/skbuff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/core/skbuff.c +3 -3
@@ -1941,12 +1941,12 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)int i, order, psize, new_frags;u32 d_off; -if (skb_shared (skb) ||skb_unclone (skb, gfp_mask)) -return -EINVAL ; -if (!skb_frags_readable (skb))return -EFAULT ; +if (skb_shared (skb) ||skb_unclone (skb, gfp_mask)) +return -EINVAL ; +if (!num_frags) goto release;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1417/1518 net: fix a resource leak in copy_net_ns() error handling path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
[ Upstream commit 3220b62fbb8a55feebd2a826d5ead0f49f09ed5a ]
Currently, preinit_net() does two things:
(1) call ns_common_init() which might fail
(2) initialize resources which does not fail
However, preinit_net() is returning early when (1) fails, and copy_net_ns() is jumping to the dec_ucounts: label. As a result, resources allocated by net_alloc() are leaking. We need to call key_remove_domain() and net_passive_dec() in order to release resources allocated by net_alloc().
We cannot simply jump to the put_userns: label when preinit_net() failed, for (2) is not yet done. But we can reorder (1) and (2), for there is no dependency between (1) and (2). Therefore, this patch decouples (1) from preinit_net() and changes preinit_net() back to a void function, and calls ns_common_init() after preinit_net() succeeded. Then, we can jump to immediately after ns_common_free() of the put_userns: label.
--- net/core/net_namespace.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
net/core/net_namespace.c +9 -12
@@ -398,14 +398,8 @@ static __net_init void preinit_net_sysctl(struct net *net) }/* init code that must occur even if setup_net() is not called. */ -static __net_init int preinit_net (struct net *net,struct user_namespace *user_ns) +static __net_init void preinit_net (struct net *net,struct user_namespace *user_ns) { -int ret; - - ret =ns_common_init (net); -if (ret) -return ret; -refcount_set (&net->passive,1 );ref_tracker_dir_init (&net->refcnt_tracker,128 ,"net_refcnt" );ref_tracker_dir_init (&net->notrefcnt_tracker,128 ,"net_notrefcnt" );
@@ -426,7 +420,6 @@ static __net_init int preinit_net(struct net *net, struct user_namespace *user_nINIT_LIST_HEAD (&net->ptype_all);INIT_LIST_HEAD (&net->ptype_specific);preinit_net_sysctl (net); -return 0 ; }/*
@@ -571,12 +564,14 @@ struct net *copy_net_ns(u64 flags, goto dec_ucounts; } - rv =preinit_net (net, user_ns); -if (rv <0 ) - goto dec_ucounts; +preinit_net (net, user_ns); net->ucounts = ucounts;get_user_ns (user_ns); + rv =ns_common_init (net); +if (rv) + goto put_userns_no_common; + rv =down_read_killable (&pernet_ops_rwsem);if (rv <0 ) goto put_userns;
@@ -588,6 +583,7 @@ struct net *copy_net_ns(u64 flags,if (rv <0 ) { put_userns:ns_common_free (net); +put_userns_no_common:#ifdef CONFIG_KEYS key_remove_domain (net->key_domain);#endif
@@ -1285,7 +1281,8 @@ void __init net_ns_init(void)* This currently cannot fail as the initial network namespace * has a static inode number. */ -if (preinit_net (&init_net, &init_user_ns)) +preinit_net (&init_net, &init_user_ns); +if (ns_common_init (&init_net))panic ("Could not preinitialize the initial network namespace" );down_write (&pernet_ops_rwsem);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1418/1518 net/sched: fq: add overflow bounds to quantum and initial quantum
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 709f34f7c28dc4dd6c40343d101850f11e172312 ]
fq_init() computes quantum = 2 * psched_mtu() and initial_quantum = 10 * psched_mtu() with no overflow check. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000; the 2 * and 10 * multiplications wrap to 0 in 32-bit arithmetic, so q->quantum == 0. Then in fq_dequeue() the credit-refill loop adds 0 to f->credit (which stays <= 0) and goto begin loops forever under the qdisc lock, creating a soft lockup.
Clamp psched_mtu() to [1, 1 << 20] before multiplying so the product cannot wrap, then cap the result at 1 << 20, matching the bound already enforced on TCA_FQ_QUANTUM in fq_change().
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) is large enough that 2 * psched_mtu() wraps (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_fq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/sched/sch_fq.c +4 -2
@@ -1170,12 +1170,14 @@ static int fq_init(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) {struct fq_sched_data *q =qdisc_priv (sch); +u32 mtu;int i, err; sch->limit =10000 ; q->flow_plimit =100 ; - q->quantum =2 *psched_mtu (qdisc_dev (sch)); - q->initial_quantum =10 *psched_mtu (qdisc_dev (sch)); + mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),1 ,1 <<20 ); + q->quantum =min_t (u32,2 * mtu,1 <<20 ); + q->initial_quantum =min_t (u32,10 * mtu,1 <<20 ); q->flow_refill_delay =msecs_to_jiffies (40 ); q->flow_max_rate = ~0UL ; q->time_next_delayed_flow = ~0ULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1419/1518 net/sched: fq_codel: clamp default quantum and mtu
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit d9ebd8f9aa8b2773235889cb903fafd61f2d8585 ]
fq_codel_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) without clamping. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000, which overflows the signed flow->deficit to INT_MIN in fq_codel_dequeue(), causing an infinite loop and soft lockup. Emulate fq_codel_change() and constrain to [256, FQ_CODEL_QUANTUM_MAX].
The same unclamped psched_mtu() is assigned to q->cparams.mtu a bit below, and fq_codel_change() never updates it. codel_should_drop() tests "*backlog <= params->mtu"; with mtu == 0x80000000 (~2 GiB) and the default 32 MiB memory_limit, the test is always true, so CoDel is silently and completely disabled (no drops, no ECN). Declare a single clamped mtu and assign both q->quantum and q->cparams.mtu from it, which also removes the double psched_mtu() call.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_fq_codel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +4 -2
@@ -507,6 +507,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) {struct fq_codel_sched_data *q =qdisc_priv (sch); +u32 mtu;int i;int err;
@@ -514,13 +515,14 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, q->flows_cnt =1024 ; q->memory_limit =32 <<20 ;/* 32 MBytes */ q->drop_batch_size =64 ; - q->quantum =psched_mtu (qdisc_dev (sch)); + mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,FQ_CODEL_QUANTUM_MAX ); + q->quantum = mtu;INIT_LIST_HEAD (&q->new_flows);INIT_LIST_HEAD (&q->old_flows);codel_params_init (&q->cparams);codel_stats_init (&q->cstats); q->cparams.ecn = true; - q->cparams.mtu =psched_mtu (qdisc_dev (sch)); + q->cparams.mtu = mtu;if (opt) { err =fq_codel_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1420/1518 net/sched: sch_codel: clamp default mtu to avoid disabling CoDel
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 6439461f1618ae176c048673ad28bdb6c68efbfc ]
codel_init() sets q->params.mtu = psched_mtu(qdisc_dev(sch)) without clamping. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000. In codel_should_drop() the test "*backlog <= params->mtu" then compares the backlog against ~2 GiB; with the default sch->limit of DEFAULT_CODEL_LIMIT (1000) packets the backlog can never reach it, so the test is always true and CoDel is silently and completely disabled i.e no drops, no ECN marking, codel degrades to a tail-drop FIFO. codel_change() never updates params.mtu, so the init path is the only place to clamp it. Constrain to [256, 1 << 20], matching the fq_codel bound; 256 is a sane floor that only makes CoDel slightly more willing to act on very small queues, which is the safe direction.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_codel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_codel.c +1 -1
@@ -206,7 +206,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,codel_params_init (&q->params);codel_vars_init (&q->vars);codel_stats_init (&q->stats); - q->params.mtu =psched_mtu (qdisc_dev (sch)); + q->params.mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,1 <<20 );if (opt) {int err =codel_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1421/1518 net/sched: fq_pie: clamp default quantum to avoid signed overflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit c86cd7ed0b0e44779a3d1683f03e4353baf4bdc9 ]
fq_pie_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) without clamping. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000, which overflows the signed flow->deficit to INT_MIN in fq_pie_qdisc_dequeue(), causing an infinite loop and soft lockup. Emulate fq_pie_policy which is already bounded to [1, 1 << 20]; clamp the default to [256, 1 << 20]. 256 matches fq_codel's floor and is a sane minimum for a DRR quantum.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_fq_pie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_fq_pie.c +2 -1
@@ -427,7 +427,8 @@ static int fq_pie_init(struct Qdisc *sch, struct nlattr *opt,pie_params_init (&q->p_params); sch->limit =10 *1024 ; q->p_params.limit = sch->limit; - q->quantum =psched_mtu (qdisc_dev (sch)); + q->quantum =clamp_t (u32,psched_mtu (qdisc_dev (sch)), +256 ,1 <<20 ); q->sch = sch; q->ecn_prob =10 ; q->flows_cnt =1024 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1422/1518 net/sched: hhf: clamp quantum before hhf_change() to avoid overflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 2164b512b97bb053e8ce4d6e95576f11bed6a005 ]
hhf_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) with no overflow check. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes weight * quantum overflow the signed deficit in hhf_dequeue(), spinning forever.
Clamp q->quantum before hhf_change() so both the opt and !opt paths see a sane quantum. Without this, bare "tc qdisc add ... hhf" succeeds with a clamped quantum but "tc qdisc add ... hhf limit 1000" (any option present) fails with -EINVAL because hhf_change() re-validates the unclamped default (sch_hhf.c:559). 256 matches fq_codel's floor and is a sane minimum for a DRR quantum.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_hhf.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sched/sch_hhf.c +4 -0
@@ -623,6 +623,10 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, q->hhf_evict_timeout =HZ ;/* 1 sec */ q->hhf_non_hh_weight =2 ; +if ((int )q->quantum <=0 || + (u64 )q->quantum * q->hhf_non_hh_weight >INT_MAX ) + q->quantum =256 ; +if (opt) {int err =hhf_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1423/1518 net/sched: sfq: clamp quantum to avoid signed overflow soft lockup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 816e90057ab1879562a5b7cc688e35bb9027ae97 ]
sfq_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) (unsigned). A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000, so slot->allot = INT_MIN and INT_MIN + INT_MIN toggles between INT_MIN and 0 forever, spinning sfq_dequeue() under the qdisc lock.
Clamp the quantum to [256, 1 << 20] so the refill loop terminates. The lower bound also covers q->quantum == 0 (psched_mtu() returning 0), which spins sfq_dequeue() identically. sfq_change() already rejects a negative quantum, so only the init path was exposed.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_sfq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_sfq.c +2 -1
@@ -796,7 +796,8 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt, q->tail =NULL ; q->divisor =SFQ_DEFAULT_HASH_DIVISOR ; q->maxflows =SFQ_DEFAULT_FLOWS ; - q->quantum =psched_mtu (qdisc_dev (sch)); + q->quantum =clamp_t (u32,psched_mtu (qdisc_dev (sch)), +256 ,1 <<20 ); q->perturb_period =0 ;get_random_bytes (&q->perturbation,sizeof (q->perturbation));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1424/1518 net/sched: sch_teql: restore skb->dev on the slave failure path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit dc4b95b8fee95113587e93ca116356032d271371 ]
teql_master_xmit() sets skb->dev = slave before calling the slave's ndo_start_xmit(), but never restores it when that transmit fails. The skb then walks on to the next slave still pointing at the previous one.
If a later slave has no resolved neighbour, teql_resolve() hands the skb to neigh_event_send(), which queues it on that neighbour's arp_queue with the stale skb->dev. skb->dev holds no reference, so deleting the previous slave frees the net_device while the skb is still queued. Whatever runs next on that skb - arp_error_report() on timeout, or neigh_direct_output() -> dev_queue_xmit() once the neighbour resolves - causes a UAF like the one below:
BUG: KASAN: slab-use-after-free in __icmp_send (net/ipv4/icmp.c:914 (discriminator 2)) Read of size 4 at addr ffff888106e100b0 by task flood_packet/527 CPU: 0 UID: 0 PID: 527 Comm: flood_packet Not tainted 7.2.0-rc6-g594d90519502 #1 PREEMPT(lazy) Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <IRQ> dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120) print_report (mm/kasan/report.c:378 mm/kasan/report.c:482) ? __pfx__raw_spin_lock_irqsave (./include/asm-generic/qrwlock.h:122 (discriminator 4)) ? __icmp_send (net/ipv4/icmp.c:914 (discriminator 2)) kasan_report (mm/kasan/report.c:595) ? __icmp_send (net/ipv4/icmp.c:914 (discriminator 2)) __icmp_send (net/ipv4/icmp.c:914 (discriminator 2))
[...]ipv4_link_failure (net/ipv4/route.c:1251 net/ipv4/route.c:1258)
? __pfx_ipv4_link_failure (./include/linux/skbuff.h:4327)
? _raw_write_lock (./include/linux/instrumented.h:55 ./include/linux/atomic/atomic-instrumented.h:1301 ./include/asm-generic/qrwlock.h:98 ./include/linux/rwlock_api_smp.h:230 kernel/locking/spinlock.c:304) ? __pfx__raw_write_lock (kernel/locking/spinlock.c:175)arp_error_report (./include/net/dst.h:438 net/ipv4/arp.c:296)neigh_invalidate (net/core/neighbour.c:1077)neigh_timer_handler (net/core/neighbour.c:1169)
[...]
Allocated by task 505: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) __kasan_kmalloc (mm/kasan/common.c:398 mm/kasan/common.c:415) __kvmalloc_node_noprof (./include/linux/kasan.h:263 mm/slub.c:5334 mm/slub.c:6905) alloc_netdev_mqs (net/core/dev.c:12055 (discriminator 2))
rtnl_create_link (net/core/rtnetlink.c:3721)rtnl_newlink (net/core/rtnetlink.c:3903 net/core/rtnetlink.c:4044 net/core/rtnetlink.c:4159) rtnetlink_rcv_msg (net/core/rtnetlink.c:7076)
[...]
Freed by task 536: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) kasan_save_free_info (mm/kasan/generic.c:584) __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285) kfree (./include/linux/kasan.h:235 mm/slub.c:2677 mm/slub.c:6377 mm/slub.c:6692)
device_release (drivers/base/core.c:2636)kobject_put (lib/kobject.c:689 lib/kobject.c:720 ./include/linux/kref.h:65 lib/kobject.c:737) netdev_run_todo (net/core/dev.c:11756)rtnl_dellink (net/core/rtnetlink.c:157 ./include/linux/rtnetlink.h:135 net/core/rtnetlink.c:3651) rtnetlink_rcv_msg (net/core/rtnetlink.c:7076)
[...]
Fix this by restoring skb->dev to the master at the end of each slave's iteration.
--- net/sched/sch_teql.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_teql.c +1 -0
@@ -377,6 +377,7 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev) nores =1 ;break ; } + skb->dev = dev;__skb_pull (skb,skb_network_offset (skb)); }while ((q =rcu_dereference (NEXT_SLAVE (q))) != start);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1425/1518 tpm: st33zp24: Return zero on status read failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 8b92687708f5ef980de01c2042dbd76d11f78547 ]
st33zp24_status() ignores the result of the transport read and returns data even when no byte was received. The I2C transport, for example, skips i2c_master_recv() when the register-select write is short or fails, leaving data uninitialized. The resulting stack value can be interpreted as TPM_STS flags and let status checks complete spuriously.
The status callback cannot propagate a transport error. Return zero unless recv() reports exactly one byte. With no status bits set, callers retry or take their existing timeout or error path instead of acting on an invalid status value.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/char/tpm/st33zp24/st33zp24.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/tpm/st33zp24/st33zp24.c +3 -1
@@ -93,7 +93,9 @@ static u8 st33zp24_status(struct tpm_chip *chip)struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev);u8 data; - tpm_dev->ops->recv (tpm_dev->phy_id,TPM_STS , &data,1 ); +if (tpm_dev->ops->recv (tpm_dev->phy_id,TPM_STS , &data,1 ) !=1 ) +return 0 ; +return data; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1426/1518 tpm: st33zp24: Validate locality read result
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 264216889d39df509b9c8045df53529480b0b718 ]
check_locality() treats every nonzero transport return as success. SPI errors remain negative, while the I2C path can convert a negative write error through its byte-sized status variable. Either result is nonzero even though the TPM_ACCESS byte can remain unwritten, so indeterminate ACTIVE_LOCALITY and VALID bits can falsely report an active locality.
Require recv() to return exactly the requested byte before examining TPM_ACCESS. Transport errors and short reads now report an inactive locality, while successful reads retain the existing behavior.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/char/tpm/st33zp24/st33zp24.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/st33zp24/st33zp24.c +2 -2
@@ -106,10 +106,10 @@ static bool check_locality(struct tpm_chip *chip) {struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev);u8 data; -u8 status; +int status; status = tpm_dev->ops->recv (tpm_dev->phy_id,TPM_ACCESS , &data,1 ); -if (status && (data & +if (status ==1 && (data & (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID )) == (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID ))return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1427/1518 crypto: acomp - allocate async request context when cloning
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit ee440d4fc0d2f15894ab1f64c474a3adbc858880 ]
ACOMP_REQUEST_ON_STACK() reserves only enough storage for the synchronous fallback. When an async implementation is selected, callers clone that stack request before retrying, but acomp_request_clone() currently copies only the stack-sized object. The clone therefore has no storage for the async provider request context, and providers such as QAT write past the allocation through acomp_request_ctx(). KASAN does report a slab OOB write.
Allocate a zeroed clone large enough for the runtime acomp request size, copy only the bytes present in the source object, and preserve the existing fallback-on-allocation-failure behavior. Use the runtime reqsize because an implementation may adjust it during tfm initialization.
--- crypto/acompress.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
crypto/acompress.c +13 -3
@@ -567,12 +567,22 @@ EXPORT_SYMBOL_GPL(acomp_walk_virt);struct acomp_req *acomp_request_clone (struct acomp_req *req,size_t total,gfp_t gfp) { +struct crypto_tfm *tfm = req->base.tfm;struct acomp_req *nreq; +size_t len; - nreq =container_of (crypto_request_clone (&req->base, total, gfp), - struct acomp_req, base); -if (nreq == req) + len =sizeof (*req) + +crypto_acomp_reqsize (crypto_acomp_reqtfm (req)); + len =ALIGN (len,CRYPTO_MINALIGN ); + + nreq =kzalloc (len, gfp); +if (!nreq) { + req->base.tfm = tfm->fb;return req; + } + +memcpy (nreq, req,sizeof (*req)); + nreq->base.flags &= ~CRYPTO_TFM_REQ_ON_STACK ;if (req->src == &req->chain.ssg) nreq->src = &nreq->chain.ssg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1428/1518 apparmor: Replace sprintf/strcpy with scnprintf/strscpy in aa_policy_init
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit b31d3f7385fbb49681d44e7104cfa033cba4b1e8 ]
strcpy() is deprecated and sprintf() does not perform bounds checking either. Although an overflow is unlikely, it's better to proactively avoid it by using the safer strscpy() and scnprintf(), respectively.
Additionally, unify memory allocation for 'hname' to simplify and improve aa_policy_init().
Stable-dep-of: 3daad923a868 ("apparmor: policy_int make sure list heads are initialized before fail path")
--- security/apparmor/lib.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
security/apparmor/lib.c +7 -9
@@ -478,19 +478,17 @@ bool aa_policy_init(struct aa_policy *policy, const char *prefix, const char *name, gfp_t gfp) { char *hname; +size_t hname_sz; + hname_sz = (prefix ?strlen (prefix) +2 :0 ) +strlen (name) +1 ;/* freed by policy_free */ -if (prefix) { - hname =aa_str_alloc (strlen (prefix) +strlen (name) +3 , gfp); -if (hname) -sprintf (hname,"%s//%s" , prefix, name); - }else { - hname =aa_str_alloc (strlen (name) +1 , gfp); -if (hname) -strcpy (hname, name); - } + hname =aa_str_alloc (hname_sz, gfp);if (!hname)return false; +if (prefix) +scnprintf (hname, hname_sz,"%s//%s" , prefix, name); +else +strscpy (hname, name, hname_sz); policy->hname = hname;/* base.name is a substring of fqname */ policy->name =basename (policy->hname);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1429/1518 apparmor: policy_int make sure list heads are initialized before fail path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit 3daad923a8685adb66087e0d819559b7eb6ba975 ]
If profile create fails before policy_init is complete the list heads are not properly initialized causing profile_free() sanity checks to trigger the following splat.
AppArmor WARN aa_policy_destroy: (((!list_empty(&policy->profiles) && (&policy->profiles)->prev != ((void *) 0x122 + (0xdead000000000000UL))))):
WARNING: security/apparmor/lib.c:509 at aa_policy_destroy+0x164/0x1b0 security/apparmor/lib.c:509, CPU#0: syz.0.17/5541 Modules linked in: CPU: 0 UID: 0 PID: 5541 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:aa_policy_destroy+0x16b/0x1b0 security/apparmor/lib.c:509 Code: 85 ed 7e 4d e8 96 bc 37 fd 5b 41 5c 41 5e 41 5f 5d e9 19 27 4e 07 cc e8 83 bc 37 fd 48 8d 3d 0c f0 d3 0b 48 c7 c6 a4 eb 38 8e <67> 48 0f b9 3a e9 04 ff ff ff e8 66 bc 37 fd 48 8d 3d ff ef d3 0b RSP: 0018:ffffc9000345eaa0 EFLAGS: 00010293 RAX: ffffffff848f530d RBX: ffff88803f734800 RCX: ffff88801af2a580 RDX: 0000000000000000 RSI: ffffffff8e38eba4 RDI: ffffffff90634320 RBP: 0000000000000000 R08: 0000000000000cc0 R09: 00000000ffffffff R10: dffffc0000000000 R11: fffffbfff1d95913 R12: dead000000000122 R13: ffff88803f734800 R14: ffff88803f734828 R15: dffffc0000000000 FS: 00007f5f6a1836c0(0000) GS:ffff88808c519000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055d02407b048 CR3: 0000000012aa9000 CR4: 0000000000352ef0 Call Trace: <TASK> aa_free_profile+0x9d/0x9f0 security/apparmor/policy.c:334 aa_alloc_profile+0x1e4/0x3e0 security/apparmor/policy.c:416 unpack_profile security/apparmor/policy_unpack.c:1153 [inline] aa_unpack+0x17db/0x7430 security/apparmor/policy_unpack.c:1748 aa_replace_profiles+0x226/0x2a20 security/apparmor/policy.c:1183 policy_update+0x234/0x4a0 security/apparmor/apparmorfs.c:505 profile_load+0x1cb/0x320 security/apparmor/apparmorfs.c:522 vfs_write+0x296/0xba0 fs/read_write.c:685 ksys_write+0x150/0x270 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f5f6939e0d9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f5f6a183028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f5f69625fa0 RCX: 00007f5f6939e0d9 RDX: 0000000000000041 RSI: 0000200000000400 RDI: 0000000000000003 RBP: 00007f5f6a183090 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 00007f5f69626038 R14: 00007f5f69625fa0 R15: 00007ffe23725c18
--- security/apparmor/lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/apparmor/lib.c +2 -2
@@ -480,6 +480,8 @@ bool aa_policy_init(struct aa_policy *policy, const char *prefix,char *hname;size_t hname_sz; +INIT_LIST_HEAD (&policy->list); +INIT_LIST_HEAD (&policy->profiles); hname_sz = (prefix ?strlen (prefix) +2 :0 ) +strlen (name) +1 ;/* freed by policy_free */ hname =aa_str_alloc (hname_sz, gfp);
@@ -492,8 +494,6 @@ bool aa_policy_init(struct aa_policy *policy, const char *prefix, policy->hname = hname;/* base.name is a substring of fqname */ policy->name =basename (policy->hname); -INIT_LIST_HEAD (&policy->list); -INIT_LIST_HEAD (&policy->profiles);return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1430/1518 ASoC: dapm: Fix off-by-one check on the second enum channel
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 14511c9b54ceeeef487409d73947c89ee8563590 ]
The snd_soc_dapm_put_enum_double() rejects item[0] once it reaches e->items, but it lets item[1] be equal to it. Both go on to snd_soc_enum_item_to_val(), which indexes e->values with no bound of its own, so an enum with a value table reads one element past the end.
The indexing arrived with the MUX consolidation, which relaxed the item[1] check in the same hunk. The value MUX handler it deleted used
Quoted 1 line
= there, and the
snd_soc_put_enum_double()insoc-ops.cstill does.
Only adav80x pairs a value table with two shifts, and its second channel looks accidental, but the control does report two values. Writing three into it reads off the end of adav80x_mux_values. The core catches that only under CONFIG_SND_CTL_INPUT_VALIDATION, which defaults off.
--- sound/soc/soc-dapm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-dapm.c +1 -1
@@ -3549,7 +3549,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, val =snd_soc_enum_item_to_val (e, item[0 ]) << e->shift_l; mask = e->mask << e->shift_l;if (e->shift_l != e->shift_r) { -if (item[1 ] > e->items) +if (item[1 ] >= e->items)return -EINVAL ; val |=snd_soc_enum_item_to_val (e, item[1 ]) << e->shift_r; mask |= e->mask << e->shift_r;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1431/1518 ceph: Fix ERR_PTR(0) in ceph_mkdir()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 4f49c3f8a5a86d237bb202ecb17c2802ddc8fd2f ]
When mkdir succeeds, ceph_mkdir() sets ret to ERR_PTR(0) which is incorrect. It should return NULL instead for success.
--- fs/ceph/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/dir.c +1 -1
@@ -1173,7 +1173,7 @@ static struct dentry *ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, !req->r_reply_info.head->is_target && !req->r_reply_info.head->is_dentry) err =ceph_handle_notrace_create (dir, dentry); - ret =ERR_PTR (err); + ret = err ?ERR_PTR (err) :NULL ; out_req:if (!IS_ERR (ret) && req->r_dentry != dentry)/* Some other dentry was spliced in */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1432/1518 ceph: revalidate ki_pos for O_APPEND writes after cap acquisition
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiubo Li <[email protected]>
[ Upstream commit d2a8d446a09c74c8ddfe108b50dd791c889983fc ]
For O_APPEND writes, ki_pos is set to the current EOF via generic_write_checks() after fetching i_size from the MDS. However, ceph_get_caps() may need to wait for Fwx exclusive caps if the write extends the file (endoff > i_max_size). While waiting for Fwx, the previous Fwx holder (another client) may have already extended the file. When the MDS grants us Fwx, the cap grant message updates the local i_size, but ki_pos remains at the old EOF, causing the append write to land at a stale offset and overwrite data from the other client.
Fix by re-reading i_size_read(inode) after ceph_get_caps() returns. At this point we hold Fwx exclusive caps, no other client can modify the file, and i_size reflects the true EOF from the MDS cap grant. No extra MDS round-trip is needed. Only adjust ki_pos when the EOF has actually changed.
After adjusting ki_pos forward, the write range [pos, pos+count) may now exceed the i_max_size that was validated by ceph_get_caps() for the old range. Re-check against i_max_size and truncate the write if necessary to stay within the MDS-granted limit.
--- fs/ceph/file.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
fs/ceph/file.c +48 -0
@@ -2412,6 +2412,54 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)if (err <0 ) goto out; +/* +* For O_APPEND writes we may have waited for Fwx exclusive caps +* while the previous Fwx holder (another client) extended the +* file. i_size has been updated via the cap grant message from +* the MDS, but ki_pos is still the old EOF. Re-read i_size here +* (no extra MDS round-trip needed) and adjust ki_pos to the true +* EOF. Since we hold Fwx, no other client can change the file. +*/ +if (iocb->ki_flags &IOCB_APPEND ) { +loff_t cur_eof =i_size_read (inode); + +if (cur_eof != pos) { +doutc (cl, +"%p %llx.%llx O_APPEND: pos adjusted %lld -> %lld\n" , + inode,ceph_vinop (inode), pos, cur_eof); + iocb->ki_pos = cur_eof; + pos = cur_eof; +if (pos >= limit) { + err = -EFBIG ; + goto out_caps; + } +iov_iter_truncate (from, limit - pos); + count =iov_iter_count (from); + +/* +* ceph_get_caps() validated the old endoff +* against i_max_size; adjusting ki_pos forward +* may have shifted the write range beyond the +* granted max_size. Re-check and truncate if +* necessary. +*/ +spin_lock (&ci->i_ceph_lock); +if (pos + count > (loff_t )ci->i_max_size) { +loff_t max_size = ci->i_max_size; + +spin_unlock (&ci->i_ceph_lock); +if (pos >= max_size) { + err = -EFBIG ; + goto out_caps; + } +iov_iter_truncate (from, max_size - pos); + count =iov_iter_count (from); + }else { +spin_unlock (&ci->i_ceph_lock); + } + } + } + err =file_update_time (file);if (err) goto out_caps;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1433/1518 libceph: validate banner payload length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit f374967fcdf04001c9b66df1c19106fa83cd91f7 ]
When parsing the Ceph messenger v2 protocol banner, the payload_len field is decoded from the banner prefix. If a client sends a banner with a payload_len of 0, the kernel sets up a 0-length socket read. This violates an invariant in the state machine, triggering a warning in populate_in_iter():
------------[ cut here ]------------ !iov_iter_count(&con->v2.in_iter) WARNING: net/ceph/messenger_v2.c:3129 at populate_in_iter net/ceph/messenger_v2.c:3129 [inline], CPU#1: kworker/1:3/5070 WARNING: net/ceph/messenger_v2.c:3129 at ceph_con_v2_try_read+0x6634/0x6810 net/ceph/messenger_v2.c:3159, CPU#1: kworker/1:3/5070 ... Call Trace: <TASK> ceph_con_workfn+0x1f5/0x14a0 net/ceph/messenger.c:1575 process_one_work kernel/workqueue.c:3322 [inline] process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3486 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
According to the msgr2 protocol specification, the banner payload is expected to contain at least two 64-bit integers (server_feat and server_req_feat). Therefore, payload_len must be at least 16 bytes.
Fix this by adding a check in process_banner_prefix() to reject a payload_len smaller than 16 bytes. This prevents the 0-length read and correctly aborts the connection with a protocol error.
--- net/ceph/messenger_v2.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ceph/messenger_v2.c +5 -0
@@ -2144,6 +2144,11 @@ static int process_banner_prefix(struct ceph_connection *con) payload_len =ceph_decode_16 (&p);dout ("%s con %p payload_len %d\n" , __func__, con, payload_len); +if (payload_len <sizeof (u64) +sizeof (u64)) { + con->error_msg ="protocol error, bad banner payload len" ; +return -EINVAL ; + } +return prepare_read_banner_payload (con, payload_len); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1434/1518 samples/ftrace: Fix kthread_stop() on ERR_PTR in ftrace-direct-modify
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit d79fb758e7e2e7a181eab630c0545a56041c473d ]
ftrace_direct_init() assigns kthread_run()'s return value to simple_tsk without an IS_ERR() check. When kthread_run() fails it returns ERR_PTR(-ENOMEM), but init still returns 0, so the module loads with simple_tsk holding an error pointer. On unload, ftrace_direct_exit() then passes that ERR_PTR to kthread_stop(), leading to a null-pointer-dereference.
Check the return value of kthread_run() with IS_ERR(); on failure, unregister the ftrace direct call and propagate the error code.
--- samples/ftrace/ftrace-direct-modify.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
samples/ftrace/ftrace-direct-modify.c +9 -3
@@ -320,9 +320,15 @@ static int __init ftrace_direct_init(void)ftrace_set_filter_ip (&direct, (unsigned long ) my_ip,0 ,0 ); ret =register_ftrace_direct (&direct, my_tramp); -if (!ret) - simple_tsk =kthread_run (simple_thread,NULL ,"event-sample-fn" ); -return ret; +if (ret) +return ret; + simple_tsk =kthread_run (simple_thread,NULL ,"event-sample-fn" ); +if (IS_ERR (simple_tsk)) { +unregister_ftrace_direct (&direct, my_tramp, true); +return PTR_ERR (simple_tsk); + } + +return 0 ; } static void __exit ftrace_direct_exit(void)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1435/1518 samples/ftrace: Fix kthread_stop() on ERR_PTR in ftrace-direct-multi-modify
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 6727b7618f49401acf373fa3ec5712e2ec52e5cf ]
ftrace_direct_multi_init() assigns kthread_run()'s return value to simple_tsk without an IS_ERR() check. When kthread_run() fails it returns ERR_PTR(-ENOMEM), but init still returns 0, so the module loads with simple_tsk holding an error pointer. On unload, ftrace_direct_multi_exit() then passes that ERR_PTR to kthread_stop(), leading to a null-pointer-dereference.
Check the return value of kthread_run() with IS_ERR(); on failure, unregister the ftrace direct call and propagate the error code.
--- samples/ftrace/ftrace-direct-multi-modify.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
samples/ftrace/ftrace-direct-multi-modify.c +9 -3
@@ -364,9 +364,15 @@ static int __init ftrace_direct_multi_init(void) ret =register_ftrace_direct (&direct, my_tramp); -if (!ret) - simple_tsk =kthread_run (simple_thread,NULL ,"event-sample-fn" ); -return ret; +if (ret) +return ret; + simple_tsk =kthread_run (simple_thread,NULL ,"event-sample-fn" ); +if (IS_ERR (simple_tsk)) { +unregister_ftrace_direct (&direct, my_tramp, true); +return PTR_ERR (simple_tsk); + } + +return 0 ; } static void __exit ftrace_direct_multi_exit(void)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1436/1518 net: ethernet: sun4i-emac: Fix IRQ error handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 991c2be78257cba5bf53cf935fe70f8836964288 ]
irq_of_parse_and_map() returns 0 when parsing or mapping an IRQ fails. The current code checks for -ENXIO and therefore does not detect the failure.
Check for a zero return value and convert it to -ENXIO.
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/allwinner/sun4i-emac.c +2 -2
@@ -996,9 +996,9 @@ static int emac_probe(struct platform_device *pdev)/* fill in parameters for net-dev structure */ ndev->base_addr = (unsigned long )db->membase; ndev->irq =irq_of_parse_and_map (np,0 ); -if (ndev->irq == -ENXIO ) { +if (!ndev->irq) {netdev_err (ndev,"No irq resource\n" ); - ret = ndev->irq; + ret = -ENXIO ; goto out_iounmap; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1437/1518 net/smc: release the internal TCP sock on IPPROTO_SMC socket creation failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifei Chu <[email protected]>
[ Upstream commit cec261b0b4c5c0b044165303198d10ffcdf3414c ]
IPPROTO_SMC sockets create an internal TCP sock ("clcsock") from the proto->init hook. When socket creation fails after proto->init has run - e.g. a cgroup BPF program attached to BPF_CGROUP_INET_SOCK_CREATE denies the socket - sk_common_release() only invokes sk_prot->destroy if it is set, but neither smc_inet_prot nor smc_inet6_prot defines it, and smc_destruct() returns early unless sk_state is SMC_CLOSED. As a result, every failing socket(AF_INET, SOCK_STREAM, IPPROTO_SMC) call leaks one tcp_sock, so an unprivileged task able to attach a deny-all BPF_CGROUP_INET_SOCK_CREATE program to its own cgroup can grow kernel memory unboundedly.
Add a .destroy hook to both protos that releases the clcsock via smc_clcsock_release(). smc_sk_init() hashes the sock into the smc hashinfo before the clcsock is created, and smc_diag dumps walk that hash dereferencing smc->clcsock without taking clcsock_release_lock, while sk_common_release() calls .destroy before .unhash. Unhash the sock before releasing the clcsock, as __smc_release() does, so a concurrent dump cannot observe the release; the second unhash in sk_common_release() is a no-op.
--- net/smc/smc_inet.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/smc/smc_inet.c +16 -0
@@ -15,13 +15,16 @@#include "smc_inet.h" #include "smc.h" +#include "smc_close.h" static int smc_inet_init_sock (struct sock *sk); +static void smc_inet_destroy_sock (struct sock *sk);static struct proto smc_inet_prot = { .name ="INET_SMC" , .owner =THIS_MODULE , .init = smc_inet_init_sock, + .destroy = smc_inet_destroy_sock, .hash = smc_hash_sk, .unhash = smc_unhash_sk, .release_cb = smc_release_cb,
@@ -68,6 +71,7 @@ static struct proto smc_inet6_prot = { .name = "INET6_SMC", .owner = THIS_MODULE, .init = smc_inet_init_sock, + .destroy = smc_inet_destroy_sock, .hash = smc_hash_sk, .unhash = smc_unhash_sk, .release_cb = smc_release_cb,
@@ -116,6 +120,18 @@ static int smc_inet_init_sock(struct sock *sk)return smc_create_clcsk (net, sk, sk->sk_family); } +static void smc_inet_destroy_sock (struct sock *sk) +{ +/* The sock is hashed and smc_diag dumps dereference smc->clcsock +* without clcsock_release_lock, while sk_common_release() calls +* .destroy before .unhash. Unhash first, as __smc_release() does, +* so no dump can observe the clcsock being released; the second +* unhash is a no-op. +*/ + sk->sk_prot->unhash (sk); +smc_clcsock_release (smc_sk (sk)); +} +int __init smc_inet_init (void ) {int rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1438/1518 net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit 63c885688f38a757947d7050b1ee4171215269ce ]
The macros TXGBE_INTR_MISC() and WX_INTR_Q() rely on the standard BIT() macro to generate interrupt masks based on the queue vector index.
On 32-bit architectures, BIT() evaluates to a 32-bit unsigned long. Since the number of queue vectors can be up to 63 on txgbe devices, performing a left shift of 32 or more results in an integer overflow and undefined behavior. This causes incorrect interrupt masking and unmasking logic for both the queue and miscellaneous interrupts on 32-bit systems.
Fix this by replacing BIT() with BIT_ULL() in these macros. This ensures that the bitwise shift is always performed safely on a 64-bit unsigned long long type, regardless of the underlying architecture.
--- drivers/net/ethernet/wangxun/libwx/wx_type.h | 2 +- drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -1
@@ -1400,7 +1400,7 @@ struct wx { };#define WX_INTR_ALL (~0ULL) -#define WX_INTR_Q (i) BIT((i)) +#define WX_INTR_Q (i) BIT_ULL((i))/* register operations */ #define wr32 (a, reg, value) writel((value), ((a)->hw_addr + (reg)))
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h +1 -1
@@ -302,7 +302,7 @@ struct txgbe_fdir_filter {#define TXGBE_DEFAULT_RX_WORK 128#endif -#define TXGBE_INTR_MISC (A ) BIT((A)->num_q_vectors) +#define TXGBE_INTR_MISC (A ) BIT_ULL((A)->num_q_vectors)#define TXGBE_INTR_QALL (A ) (TXGBE_INTR_MISC(A) - 1)#define TXGBE_MAX_EITR GENMASK(11, 3)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1439/1518 net: stmmac: selftests: Pass the IP proto mask in the TC selftest
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 9a56a27e6002e29a6707dc4238d469ec84c3a68e ]
The stmmac TC filtering rules have recently gained sanity checks to make sure the passed keys and their respective masks are aligned with the HW filtering abilities.
The stmmac selftests failed to pass the mask in the match data for L4 filtering tests, and are now failing consistently with -EINVAL :
$ ethtool -t eth1 [...] 23. L4 DA TCP Filtering -22 24. L4 SA TCP Filtering -22 25. L4 DA UDP Filtering -22 26. L4 SA UDP Filtering -22
Let's pass the ip_proto mask in the l4 filtering tests match data. Found on imx8mp, which now have passing L4 tests :
$ ethtool -t eth1 [...] 23. L4 DA TCP Filtering 0 24. L4 SA TCP Filtering 0 25. L4 DA UDP Filtering 0 26. L4 SA UDP Filtering 0
While at it, initialize the masks and keys to avoid re-using whatever was on the stack.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +4 -2
@@ -1452,11 +1452,11 @@ static int __stmmac_test_l4filt(struct stmmac_priv *priv, u32 dst, u32 src,struct {struct flow_dissector_key_basic bkey;struct flow_dissector_key_ports key; - }__aligned(BITS_PER_LONG / 8) keys; + }__aligned(BITS_PER_LONG / 8) keys = { };struct {struct flow_dissector_key_basic bmask;struct flow_dissector_key_ports mask; - }__aligned(BITS_PER_LONG / 8) masks; + }__aligned(BITS_PER_LONG / 8) masks = { };unsigned long dummy_cookie =0xdeadbeef ;struct stmmac_packet_attrs attr = { };struct flow_dissector *dissector;
@@ -1509,6 +1509,8 @@ static int __stmmac_test_l4filt(struct stmmac_priv *priv, u32 dst, u32 src, keys.bkey.ip_proto = udp ?IPPROTO_UDP :IPPROTO_TCP ; keys.key.src =htons (src); keys.key.dst =htons (dst); +/* Match the full IP proto field */ + masks.bmask.ip_proto =0xff ; masks.mask.src = src_mask; masks.mask.dst = dst_mask;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1440/1518 drm/xe/xe_gt_idle: Add CCS to the powergating info print
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balasubramani Vivekanandan <[email protected]>
[ Upstream commit 369ba0d1efe91cccabe98ae53c53b7425f327edf ]
While reading the main GT powergating info from debugfs, include both RCS and CCS engine masks.
--- drivers/gpu/drm/xe/xe_gt_idle.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_gt_idle.c +2 -1
@@ -236,7 +236,8 @@ int xe_gt_idle_pg_print(struct xe_gt *gt, struct drm_printer *p)xe_force_wake_put (gt_to_fw (gt), fw_ref); } -if (gt->info.engine_mask &XE_HW_ENGINE_RCS_MASK ) { +if (gt->info.engine_mask & + (XE_HW_ENGINE_RCS_MASK |XE_HW_ENGINE_CCS_MASK )) {drm_printf (p,"Render Power Gating Enabled: %s\n" ,str_yes_no (pg_enabled &RENDER_POWERGATE_ENABLE ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1441/1518 virtio-net: Ensure that TCP packets dont overflow gso_segs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Mikityanska <[email protected]>
[ Upstream commit c27c449d455aafd9018a3cbab150f1c42c87923f ]
The user can specify any gso_size in a packet crafted with an AF_PACKET PACKET_VNET_HDR socket, even smaller than TCP_MIN_GSO_SIZE = 8. At the same time, GSO_MAX_SIZE = 8 * GSO_MAX_SEGS = 8 * 65535. When the user crafts a packet with gso_size < 8, there is a risk for partial GSO to overflow the 16-bit gso_segs field when dividing the SKB length by gso_size.
Adjust gso_size of TCP packets to be at least TCP_MIN_GSO_SIZE = 8. Keep gso_size of UDP GSO packets, as gso_size=1 is valid and explicitly tested at tools/testing/selftests/net/tun.c:649.
--- include/linux/virtio_net.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/virtio_net.h +4 -0
@@ -6,6 +6,7 @@#include <linux/ip.h> #include <linux/ipv6.h> #include <linux/udp.h> +#include <net/tcp.h> #include <uapi/linux/tcp.h> #include <uapi/linux/virtio_net.h>
@@ -179,6 +180,9 @@ static inline int __virtio_net_hdr_to_skb(struct sk_buff *skb,if (skb->ip_summed ==CHECKSUM_PARTIAL && skb->csum_offset != offsetof(struct tcphdr , check))return -EINVAL ; + +BUILD_BUG_ON (TCP_MIN_GSO_SIZE *GSO_MAX_SEGS <GSO_MAX_SIZE ); + gso_size =max (gso_size,TCP_MIN_GSO_SIZE );break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1442/1518 netfilter: nf_tables: move hardware offload step after building the chain blob
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b1881d362e1924b66f6016c3efd28807032b41bf ]
Allocate the chain blob before the ruleset offload to reduce chances of entering an inconsistent state where the offloaded ruleset in the nic and the software ruleset differ.
--- net/netfilter/nf_tables_api.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/netfilter/nf_tables_api.c +10 -4
@@ -10774,10 +10774,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)return -EAGAIN ; } - err =nft_flow_rule_offload_commit (net); -if (err <0 ) -return err; -/* 1. Allocate space for next generation rules_gen_X[] */ list_for_each_entry_safe (trans, next, &nft_net->commit_list, list) {struct nft_table *table = trans->table;
@@ -10802,6 +10798,16 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) } } +/* must be last, so audit and chain blob set up does not leave hardware +* in consistent state. +*/ + err =nft_flow_rule_offload_commit (net); +if (err <0 ) { +nf_tables_commit_chain_prepare_cancel (net); +nf_tables_commit_audit_free (&adl); +return err; + } +/* step 2. Make rules_gen_X visible to packet path */ list_for_each_entry (table, &nft_net->tables, list) {list_for_each_entry (chain, &table->chains, list)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1443/1518 netfilter: xt_HL: add pr_fmt and checkentry validation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marino Dzalto <[email protected]>
[ Upstream commit 24bd5c2679caf8a228d90cafa221da4b47fd6642 ]
Add pr_fmt to prefix log messages with the module name for easier debugging in dmesg.
Add checkentry functions for IPv4 (ttl_mt_check) and IPv6 (hl_mt6_check) to validate the match mode at rule registration time, rejecting invalid modes with -EINVAL.
The evaluation function returns false in case the mode is unknown, so this is a cleanup, not a bug fix.
Stable-dep-of: 793d9eda4821 ("netfilter: x_tables: replace pr_{info,err}() by pr_info_ratelimited()")
--- net/netfilter/xt_hl.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/netfilter/xt_hl.c +27 -0
@@ -6,6 +6,7 @@* Hop Limit matching module * (C) 2001-2002 Maciej Soltysiak <[email protected]> */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/ip.h> #include <linux/ipv6.h>
@@ -22,6 +23,18 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("ipt_ttl" );MODULE_ALIAS ("ip6t_hl" ); +static int ttl_mt_check (const struct xt_mtchk_param *par) +{ +const struct ipt_ttl_info *info = par->matchinfo; + +if (info->mode >IPT_TTL_GT ) { +pr_err ("Unknown TTL match mode: %d\n" , info->mode); +return -EINVAL ; + } + +return 0 ; +} +static bool ttl_mt (const struct sk_buff *skb,struct xt_action_param *par) {const struct ipt_ttl_info *info = par->matchinfo;
@@ -41,6 +54,18 @@ static bool ttl_mt(const struct sk_buff *skb, struct xt_action_param *par)return false; } +static int hl_mt6_check (const struct xt_mtchk_param *par) +{ +const struct ip6t_hl_info *info = par->matchinfo; + +if (info->mode >IP6T_HL_GT ) { +pr_err ("Unknown Hop Limit match mode: %d\n" , info->mode); +return -EINVAL ; + } + +return 0 ; +} +static bool hl_mt6 (const struct sk_buff *skb,struct xt_action_param *par) {const struct ip6t_hl_info *info = par->matchinfo;
@@ -65,6 +90,7 @@ static struct xt_match hl_mt_reg[] __read_mostly = { .name = "ttl", .revision = 0, .family = NFPROTO_IPV4, + .checkentry = ttl_mt_check, .match = ttl_mt, .matchsize = sizeof(struct ipt_ttl_info), .me = THIS_MODULE,
@@ -73,6 +99,7 @@ static struct xt_match hl_mt_reg[] __read_mostly = { .name = "hl", .revision = 0, .family = NFPROTO_IPV6, + .checkentry = hl_mt6_check, .match = hl_mt6, .matchsize = sizeof(struct ip6t_hl_info), .me = THIS_MODULE,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1444/1518 netfilter: x_tables: replace pr_{info,err}() by pr_info_ratelimited()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 793d9eda4821f75b5f7cc9e6a870b72a58b44c2b ]
Several xtables extension still use pr_err() or pr_info() without ratelimit.
For xt_cgroup, while at this, remove redundant "xt_cgroup:" prefix since pr_fmt is already set on.
--- net/netfilter/xt_cgroup.c | 12 ++++++------ net/netfilter/xt_hl.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
net/netfilter/xt_cgroup.c +6 -6
@@ -23,7 +23,7 @@ MODULE_DESCRIPTION("Xtables: process control group matching");MODULE_ALIAS ("ipt_cgroup" );MODULE_ALIAS ("ip6t_cgroup" ); -#define NET_CLS_CLASSID_INVALID_MSG "xt_cgroup: classid invalid without net_cls cgroups\n" +#define NET_CLS_CLASSID_INVALID_MSG "classid invalid without net_cls cgroups\n"static int cgroup_mt_check_v0 (const struct xt_mtchk_param *par) {
@@ -33,7 +33,7 @@ static int cgroup_mt_check_v0(const struct xt_mtchk_param *par)return -EINVAL ;if (!IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { -pr_info (NET_CLS_CLASSID_INVALID_MSG ); +pr_info_ratelimited (NET_CLS_CLASSID_INVALID_MSG );return -EINVAL ; }
@@ -49,7 +49,7 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par)return -EINVAL ;if (!info->has_path && !info->has_classid) { -pr_info ("xt_cgroup: no path or classid specified\n" ); +pr_info_ratelimited ("no path or classid specified\n" );return -EINVAL ; }
@@ -59,7 +59,7 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par) }if (info->has_classid && !IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { -pr_info (NET_CLS_CLASSID_INVALID_MSG ); +pr_info_ratelimited (NET_CLS_CLASSID_INVALID_MSG );return -EINVAL ; }
@@ -89,7 +89,7 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_param *par)return -EINVAL ;if (!info->has_path && !info->has_classid) { -pr_info ("xt_cgroup: no path or classid specified\n" ); +pr_info_ratelimited ("no path or classid specified\n" );return -EINVAL ; }
@@ -99,7 +99,7 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_param *par) }if (info->has_classid && !IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { -pr_info (NET_CLS_CLASSID_INVALID_MSG ); +pr_info_ratelimited (NET_CLS_CLASSID_INVALID_MSG );return -EINVAL ; }
net/netfilter/xt_hl.c +2 -2
@@ -28,7 +28,7 @@ static int ttl_mt_check(const struct xt_mtchk_param *par)const struct ipt_ttl_info *info = par->matchinfo;if (info->mode >IPT_TTL_GT ) { -pr_err ("Unknown TTL match mode: %d\n" , info->mode); +pr_info_ratelimited ("Unknown TTL match mode: %d\n" , info->mode);return -EINVAL ; }
@@ -59,7 +59,7 @@ static int hl_mt6_check(const struct xt_mtchk_param *par)const struct ip6t_hl_info *info = par->matchinfo;if (info->mode >IP6T_HL_GT ) { -pr_err ("Unknown Hop Limit match mode: %d\n" , info->mode); +pr_info_ratelimited ("Unknown Hop Limit match mode: %d\n" , info->mode);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1445/1518 ALSA: control: Dont add invalid kcontrols to LED layer
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 74e3b979ce8b78a690f8b94ccf2e2c965f7f5c11 ]
The kcontrol LED state layer tries to track the all associated kcontrol elements with naive assumptions that they are readable. But one can create a write-only element that has no get callback (even a user element can do it), and this may lead to a NULL dereference at the call chain of snd_ctl_led_notify(), as found by syzkaller.
For avoiding the Oops, add a sanity check of the kcontrol's info and get callbacks, and just skip the invalid kcontrols before assigning the kctl to the LED layer.
--- sound/core/control_led.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/control_led.c +2 -0
@@ -255,6 +255,8 @@ static int snd_ctl_led_set_id(int card_number, struct snd_ctl_elem_id *id, kctl =snd_ctl_find_id (card, id);if (!kctl)return -ENOENT ; +if (!kctl->info || !kctl->get) +return -EINVAL ; ioff =snd_ctl_get_ioff (kctl, id); vd = &kctl->vd[ioff]; access = vd->access &SNDRV_CTL_ELEM_ACCESS_LED_MASK ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1446/1518 selftests/arm64: Print missing MTE TAP headers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 8d2237e9d6902e234bb89aabb9cd6a9e91357223 ]
Most MTE tests set a TAP plan and emit results without first printing the TAP version header. Direct execution therefore starts with a plan such as "1..20" instead of "TAP version 13".
The problem is particularly visible in the GCR_EL1 context-switch test. It prints its plan before forking 1,024 child processes. When stdout is fully buffered, the plan remains in the stdio buffer. Each child inherits the pending "1..1" line and flushes its copy from exit(), producing repeated plan lines.
ksft_print_header() prints the TAP header and enables line buffering. Call it in every MTE test that is missing it. In the GCR_EL1 test, call it before the plan so the plan is flushed before the children are forked. In the remaining tests, call it before setup and prerequisite checks so early failures and whole-test skips also retain the header.
--- tools/testing/selftests/arm64/mte/check_buffer_fill.c | 2 ++ tools/testing/selftests/arm64/mte/check_child_memory.c | 2 ++ tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c | 1 + tools/testing/selftests/arm64/mte/check_hugetlb_options.c | 2 ++ tools/testing/selftests/arm64/mte/check_ksm_options.c | 2 ++ tools/testing/selftests/arm64/mte/check_mmap_options.c | 2 ++ tools/testing/selftests/arm64/mte/check_tags_inclusion.c | 2 ++ tools/testing/selftests/arm64/mte/check_user_mem.c | 2 ++ 8 files changed, 15 insertions(+)
tools/testing/selftests/arm64/mte/check_buffer_fill.c +2 -0
@@ -406,6 +406,8 @@ int main(int argc, char *argv[])size_t page_size =getpagesize ();int item =ARRAY_SIZE (sizes); +ksft_print_header (); + sizes[item -3 ] = page_size -1 ; sizes[item -2 ] = page_size; sizes[item -1 ] = page_size +1 ;
tools/testing/selftests/arm64/mte/check_child_memory.c +2 -0
@@ -146,6 +146,8 @@ int main(int argc, char *argv[])int err;int item =ARRAY_SIZE (sizes); +ksft_print_header (); + page_size =getpagesize ();if (!page_size) {ksft_print_msg ("ERR: Unable to get page size\n" );
tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c +1 -0
@@ -131,6 +131,7 @@ int main(int argc, char *argv[])if (err)return err; +ksft_print_header ();ksft_set_plan (1 ); evaluate_test(mte_gcr_fork_test(),
tools/testing/selftests/arm64/mte/check_hugetlb_options.c +2 -0
@@ -230,6 +230,8 @@ int main(int argc, char *argv[])void *map_ptr;unsigned long map_size; +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_ksm_options.c +2 -0
@@ -132,6 +132,8 @@ int main(int argc, char *argv[]) {int err; +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_mmap_options.c +2 -0
@@ -945,6 +945,8 @@ int main(int argc, char *argv[]) }, }; +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_tags_inclusion.c +2 -0
@@ -175,6 +175,8 @@ int main(int argc, char *argv[]) {int err; +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_user_mem.c +2 -0
@@ -201,6 +201,8 @@ int main(int argc, char *argv[])int tag_offsets[] = {page_sz,MT_GRANULE_SIZE };char test_name[TEST_NAME_MAX ]; +ksft_print_header (); + page_sz =getpagesize ();if (!page_sz) {ksft_print_msg ("ERR: Unable to get page size\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1447/1518 selftests/arm64: Treat KSM merge_across_nodes as optional
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 1a0dba077f34a2f8faa98308d30d4b546d073145 ]
The MTE KSM test requires write access to KSM sysfs but does not check that it is running as root. It also unconditionally saves, enables and restores the merge_across_nodes attribute. The kernel only creates this attribute when CONFIG_NUMA=y, so a non-NUMA kernel prints the following message three times even though every KSM subtest passes:
# ERR: missing /sys/kernel/mm/ksm/merge_across_nodes
Skip the test when it is not running as root. Check that the optional attribute is readable and writable, treating ENOENT as its expected absence on non-NUMA kernels and skipping the test for other access failures. Only save, enable and restore the attribute when it is available.
Check MTE availability before the privilege and sysfs checks so systems without MTE retain the existing feature-unavailable skip result.
This preserves the existing behavior on NUMA kernels without requiring NUMA or reducing KSM coverage on single-node systems.
--- .../selftests/arm64/mte/check_ksm_options.c | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-)
tools/testing/selftests/arm64/mte/check_ksm_options.c +26 -3
@@ -6,6 +6,7 @@#include <errno.h> #include <fcntl.h> #include <signal.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
@@ -22,6 +23,20 @@static size_t page_sz;static unsigned long ksm_sysfs[5 ]; +static bool has_merge_across_nodes; + +static bool merge_across_nodes_available (void ) +{ +const char *path =PATH_KSM "merge_across_nodes" ; + +if (!access (path,R_OK |W_OK )) +return true; +if (errno ==ENOENT ) +return false; + +ksft_exit_skip ("Unable to read and write %s: %s\n" , path, +strerror (errno)); +}static unsigned long read_sysfs (char *str) {
@@ -56,8 +71,10 @@ static void write_sysfs(char *str, unsigned long val)static void mte_ksm_setup (void ) { - ksm_sysfs[0 ] =read_sysfs (PATH_KSM "merge_across_nodes" ); -write_sysfs (PATH_KSM "merge_across_nodes" ,1 ); +if (has_merge_across_nodes) { + ksm_sysfs[0 ] =read_sysfs (PATH_KSM "merge_across_nodes" ); +write_sysfs (PATH_KSM "merge_across_nodes" ,1 ); + } ksm_sysfs[1 ] =read_sysfs (PATH_KSM "sleep_millisecs" );write_sysfs (PATH_KSM "sleep_millisecs" ,0 ); ksm_sysfs[2 ] =read_sysfs (PATH_KSM "run" );
@@ -70,7 +87,8 @@ static void mte_ksm_setup(void)static void mte_ksm_restore (void ) { -write_sysfs (PATH_KSM "merge_across_nodes" , ksm_sysfs[0 ]); +if (has_merge_across_nodes) +write_sysfs (PATH_KSM "merge_across_nodes" , ksm_sysfs[0 ]);write_sysfs (PATH_KSM "sleep_millisecs" , ksm_sysfs[1 ]);write_sysfs (PATH_KSM "run" , ksm_sysfs[2 ]);write_sysfs (PATH_KSM "max_page_sharing" , ksm_sysfs[3 ]);
@@ -137,6 +155,11 @@ int main(int argc, char *argv[]) err =mte_default_setup ();if (err)return err; + +if (geteuid () !=0 ) +ksft_exit_skip ("Please run the test as root\n" ); + + has_merge_across_nodes =merge_across_nodes_available (); page_sz =getpagesize ();if (!page_sz) {ksft_print_msg ("ERR: Unable to get page size\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1448/1518 selftests/arm64: Fix MTE prctl TAP plan
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit bb52892f9234e4ecd982fa51222aab33ce282f79 ]
The MTE prctl test emits one result from check_basic_read() followed by one result for each of the seven entries in mte_modes[]. However, the TAP plan only accounts for the array entries, producing:
# Planned tests != run tests (7 != 8)
Include the basic read check in the plan so that all eight emitted results are declared.
--- tools/testing/selftests/arm64/mte/check_prctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/arm64/mte/check_prctl.c +1 -1
@@ -119,7 +119,7 @@ int main(void)int i;ksft_print_header (); -ksft_set_plan (ARRAY_SIZE (mte_modes)); +ksft_set_plan (ARRAY_SIZE (mte_modes) +1 );check_basic_read ();for (i =0 ; i <ARRAY_SIZE (mte_modes); i++)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1449/1518 net: airoha: npu: fix missing streaming DMA mask
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Pawlik <[email protected]>
[ Upstream commit 6fe7e31a45e3418a39e6343a85126124feec1c2f ]
The driver calls dma_set_coherent_mask() but never dma_set_mask(), leaving the streaming DMA mask at the bus default. On the non-coherent EN7581 platform (Cortex-A53), this causes the NPU mailbox to hang after approximately 41 calls when using streaming DMA mappings.
Replace dma_set_coherent_mask() with dma_set_mask_and_coherent() to set both the streaming and coherent DMA masks, matching standard driver practice.
--- drivers/net/ethernet/airoha/airoha_npu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/airoha/airoha_npu.c +1 -1
@@ -686,7 +686,7 @@ static int airoha_npu_probe(struct platform_device *pdev) npu->irqs[i] = irq; } - err =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); + err =dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 ));if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1450/1518 net: stmmac: selftests: Check multiple MMC counters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit d29b399150b07796dfa81d8778d4804c08c2a41d ]
The MMC counters report MAC statistics. Multiple counters can be enabled when the IP is integrated, however there's no way to know exactly which ones. Un-implemented counters seem to report 0.
It was found that on StarFive JH7110 and Amlogic SM1, the counter that's used by the selftest (mmc_tx_framecount_g) isn't implemented, triggering an MMC selftest failure.
Both the above SoCs seem to implement mmc_rx_framecount_gb, let's use this counter as well for MMC counter validation.
Note that this doesn't guarantee that we won't encounter the same issue again if another IP implements yet another set of counters that don't include that new one.
If the game of whack-a-mole with implemented counters becomes too hard to maintain, we may simply consider removing the MMC selftest entirely.
--- .../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +10 -4
@@ -415,11 +415,17 @@ static int stmmac_test_mmc(struct stmmac_priv *priv)stmmac_mmc_read (priv, priv->mmcaddr, &final);/* -* The number of MMC counters available depends on HW configuration -* so we just use this one to validate the feature. I hope there is -* not a version without this counter. +* The number of MMC counters available depends on HW configuration, +* and there doesn't seem to be a way to enumerate the implemented +* counters. +* +* Let's check a hand-picked set of counters, knowing that : +* - Starfive JH7110 doesn't implement mmc_tx_framecount_g +* - Amlogic SM1 doesn't implement any mmc_tx_* +* */ -if (final.mmc_tx_framecount_g <= initial.mmc_tx_framecount_g) +if (final.mmc_tx_framecount_g <= initial.mmc_tx_framecount_g && + final.mmc_rx_framecount_gb <= initial.mmc_rx_framecount_gb)return -EINVAL ;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1451/1518 net: stmmac: dwmac1000: Account for the primary MAC address for UC filtering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 9698b6da3714fd2ef47846cb63098d2b2d252e25 ]
The same filter slots are used to store the main MAC address as well as the address for the unicast filter. Let's account for that when deciding whether or not to use promisc when programming the UC list in hardware.
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -1
@@ -187,7 +187,7 @@ static void dwmac1000_set_filter(struct mac_device_info *hw,dwmac1000_set_mchash (ioaddr, mc_filter, mcbitslog2);/* Handle multiple unicast addresses (perfect filtering) */ -if (netdev_uc_count (dev) > perfect_addr_number) +if (netdev_uc_count (dev) +1 > perfect_addr_number)/* Switch to promiscuous mode if more than unicast * addresses are requested than supported by hardware. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1452/1518 net: stmmac: dwmac4: Account for the primary MAC address for UC filtering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 82187f42c014d22520b9c3c4e2cfb519223fb29b ]
The same filter slots are used to store the main MAC address as well as the address for the unicast filter. Let's account for that when deciding whether or not to use promisc when programming the UC list in hardware.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +1 -1
@@ -515,7 +515,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw, value |=GMAC_PACKET_FILTER_HPF ;/* Handle multiple unicast addresses */ -if (netdev_uc_count (dev) > hw->unicast_filter_entries) { +if (netdev_uc_count (dev) +1 > hw->unicast_filter_entries) {/* Switch to promiscuous mode if more than 128 addrs * are required */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1453/1518 net: stmmac: dwxgmac: Account for the primary MAC address for UC filtering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 2739d6f9a2b8729b0d85cbe0dc93e1d68670b6f2 ]
The same filter slots are used to store the main MAC address as well as the address for the unicast filter. Let's account for that when deciding whether or not to use promisc when programming the UC list in hardware.
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +1 -1
@@ -541,7 +541,7 @@ static void dwxgmac2_set_filter(struct mac_device_info *hw,dwxgmac2_set_mchash (ioaddr, mc_filter, mcbitslog2);/* Handle multiple unicast addresses */ -if (netdev_uc_count (dev) > hw->unicast_filter_entries) { +if (netdev_uc_count (dev) +1 > hw->unicast_filter_entries) { value |=XGMAC_FILTER_PR ; }else {struct netdev_hw_addr *ha;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1454/1518 net: stmmac: selftests: Account for the UC filter list for filtering tests
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit cd8c3b2752c684141eab2282e294cae2971a9759 ]
On dwmac, one of the Unicast filter entries is used to store the local HW addr. This means that we have to use promisc mode for any kind of unicast filtering if we only have one slot in our unicast filter.
The number of slots available depends on how the IP is integrated, and we can't autodiscover how many of these slots we have available, so the DT property snps,perfect-filter-entries can be used to specify how many are available.
Most IP variants default to 1 if this isn't specified, which is the case for the amlogic variants (in this case, S905X3).
The stmmac selftests for UC filtering look if we have enough slots in the filter to store the dev->uc list, but doesn't account for the device's own MAC address. The dev->uc list's size we get with netdev_uc_count() also doesn't account for the HW addr.
As the selftest only requires one available slot, in the case of single-slot platforms, that means we erroneously consider we have enough room for the test, when we actually don't, and the filtering test fails.
--- .../stmicro/stmmac/stmmac_selftests.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +18 -3
@@ -499,6 +499,21 @@ static int stmmac_filter_check(struct stmmac_priv *priv)return -EOPNOTSUPP ; } +static int stmmac_uc_filter_check (struct stmmac_priv *priv) +{ +/* For tests involving the UC filter, we need at least one empty +* slot in the UC filter. The UC filters contains netdev_uc_count() + 1 +* entries: The dev->uc list + one entry for the HW address. +* +* Having an empty slot therefore means netdev_uc_count() + 2 entries +* can fit in the filter +*/ +if (netdev_uc_count (priv->dev) +2 > priv->hw->unicast_filter_entries) +return -EOPNOTSUPP ; + +return 0 ; +} +static bool stmmac_hash_check (struct stmmac_priv *priv,unsigned char *addr) {int mc_offset =32 - priv->hw->mcast_bits_log2;
@@ -590,7 +605,7 @@ static int stmmac_test_pfilt(struct stmmac_priv *priv)if (stmmac_filter_check (priv))return -EOPNOTSUPP ; -if (netdev_uc_count (priv->dev) >= priv->hw->unicast_filter_entries) +if (stmmac_uc_filter_check (priv))return -EOPNOTSUPP ;while (--tries) {
@@ -634,7 +649,7 @@ static int stmmac_test_mcfilt(struct stmmac_priv *priv)if (stmmac_filter_check (priv))return -EOPNOTSUPP ; -if (netdev_uc_count (priv->dev) >= priv->hw->unicast_filter_entries) +if (stmmac_uc_filter_check (priv))return -EOPNOTSUPP ;if (netdev_mc_count (priv->dev) >= priv->hw->multicast_filter_bins)return -EOPNOTSUPP ;
@@ -680,7 +695,7 @@ static int stmmac_test_ucfilt(struct stmmac_priv *priv)if (stmmac_filter_check (priv))return -EOPNOTSUPP ; -if (netdev_uc_count (priv->dev) >= priv->hw->unicast_filter_entries) +if (stmmac_uc_filter_check (priv))return -EOPNOTSUPP ;if (netdev_mc_count (priv->dev) >= priv->hw->multicast_filter_bins)return -EOPNOTSUPP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1455/1518 net: stmmac: restore NET_IP_ALIGN in the RX DMA offset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pascal Kneuper <[email protected]>
[ Upstream commit 23680bf5f8c69c923546b84a8e6c401bef8b88fe ]
Since the RX path was converted to zero-copy, the page pool page is handed to the stack directly as the skb head, and the offset the DMA engine writes at is what determines the alignment of the packet headers.
Before the conversion the payload was copied into an skb obtained from napi_alloc_skb(), which reserves NET_SKB_PAD + NET_IP_ALIGN. The conversion moved the headroom into stmmac_rx_offset() but did not carry over NET_IP_ALIGN, so on architectures where NET_IP_ALIGN is 2 the IP header now lands misaligned:
64 (NET_SKB_PAD) + 14 (ethernet) + 20 (IP) = 98
Same for the XDP branch:
256 (XDP_PACKET_HEADROOM) + 14 (ethernet) + 20 (IP) = 290
On ARM32 this is fatal, because ldm and ldrd trap on unaligned addresses even when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set.
Any received echo request panics the machine, e.g:
Unhandled fault: alignment exception (0x001) at 0x81873062
Internal error: : 1 [#1] SMP ARM Hardware name: Altera SOCFPGA Arria10 PC is at icmp_echo+0x38/0xa8 LR is at icmp_rcv+0x22c/0x370 Call trace: icmp_echo from icmp_rcv+0x22c/0x370 icmp_rcv from ip_protocol_deliver_rcu+0x2c/0x224 ip_protocol_deliver_rcu from ip_local_deliver+0xc8/0x1a0 ip_local_deliver from ip_sublist_rcv_finish+0x3c/0x50 ip_sublist_rcv_finish from ip_list_rcv_finish+0x110/0x118 ip_list_rcv_finish from ip_list_rcv+0xc8/0xdc ip_list_rcv from __netif_receive_skb_list_core+0x170/0x1c0 ... napi_complete_done from stmmac_napi_poll_rx+0xcb0/0x1030 Code: e24dd068 e59020a0 e28dc010 e0822001 (e8920003) Kernel panic - not syncing: Fatal exception in interrupt
The faulting instruction is the ldm of *icmp_hdr(skb) in icmp_echo().
Fix by adding NET_IP_ALIGN back to the RX offset, which restores the alignment the stack used to get.
Note that commit a955318fe67e ("stmmac: align RX buffers") made a similar change in 2021 and was reverted by commit 12d125b4574b ("stmmac: Revert "stmmac: align RX buffers"") because it caused packet corruption. That patch raised the offset from 0 without adjusting the buffer size accounting, so the DMA engine could arguably write past the end of the RX buffers, though this was never root caused.
Commit df542f669307 ("net: stmmac: Switch to zero-copy in non-XDP RX path") since derives the page pool allocation from stmmac_rx_offset(), so the extra bytes are accounted for.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
@@ -1326,9 +1326,9 @@ static void stmmac_display_rings(struct stmmac_priv *priv,static unsigned int stmmac_rx_offset (struct stmmac_priv *priv) {if (stmmac_xdp_is_enabled (priv)) -return XDP_PACKET_HEADROOM ; +return XDP_PACKET_HEADROOM +NET_IP_ALIGN ; -return NET_SKB_PAD ; +return NET_SKB_PAD +NET_IP_ALIGN ; }static int stmmac_set_bfsize (int mtu,int bufsize)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1456/1518 net/sched: bound qdisc_pkt_len to prevent qdisc soft lockup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 8f735d64382dcf162f4276d6699d03ad2f859c0b ]
qdisc_get_stab() accepts a user-supplied size table, and __qdisc_calculate_pkt_len() amplifies qdisc_pkt_len() through the overhead, the size-table data (u16), and size_log (up to STAB_SIZE_LOG_MAX). A crafted stab can therefore set qdisc_pkt_len() to ~1 GiB for an ordinary skb. Per-flow deficit schedulers such as DRR and ETS replenish one quantum per loop iteration; with a tiny quantum (1) they spin billions of times under the qdisc lock, producing a soft lockup / RCU stall as illustrated by [email protected].
Cap the final qdisc_pkt_len() to QDISC_PKT_LEN_MAX so the size-table amplification cannot drive deficit schedulers into an unbounded loop. A legitimate size table (e.g. qfq's overhead 999999999, which is handled by dropping) is still accepted.
Introduce cap QDISC_PKT_LEN_MAX (1 << 20) = 1 MiB which is well above any legitimate single-skb wire length: the largest current skb->len is GSO_MAX_SIZE (524280), and an ATM-style size table (53/48 cell tax) amplifies that to ~578 KB, both comfortably below 1 MiB. At the same time, 1 MiB bounds the deficit refill loop to ~1M iterations per packet with quantum=1, which completes in a few milliseconds well under the demonstrated softlockup threshold (~10^9 iterations).
Conditions to recreate the bug:
- CONFIG_NET_SCHED=y, CONFIG_NET_SCH_DRR=y (or CONFIG_NET_SCH_ETS=y).
- Attach a DRR (or ETS) root qdisc with a crafted TCA_STAB that amplifies qdisc_pkt_len to ~1 GiB (e.g. size_log=15, data=[32768]).
- Add a class with a tiny quantum of 1 and send one small packet; the deficit loop spins billions of times under the qdisc lock and trips the softlockup detector (panic with kernel.softlockup_panic=1).
- Reachable as root or from an unprivileged user in a fresh user+net namespace (unshare -Urn) with namespace-local CAP_NET_ADMIN.
--- include/net/pkt_sched.h | 1 + net/sched/sch_api.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
include/net/pkt_sched.h +1 -0
@@ -12,6 +12,7 @@#define DEFAULT_TX_QUEUE_LEN 1000#define STAB_SIZE_LOG_MAX 30 +#define QDISC_PKT_LEN_MAX (1 << 20)/* 1 MiB */ struct qdisc_walker {int stop;
net/sched/sch_api.c +5 -2
@@ -610,8 +610,11 @@ void __qdisc_calculate_pkt_len(struct sk_buff *skb, pkt_len <<= stab->szopts.size_log; out: -if (unlikely (pkt_len <1 )) - pkt_len =1 ; +/* A size table can inflate qdisc_pkt_len() beyond any real packet +* (via overhead, the data table, or size_log); cap it so deficit +* schedulers such as DRR/ETS terminate their refill loops. +*/ + pkt_len =clamp_t (int, pkt_len,1 ,QDISC_PKT_LEN_MAX );qdisc_skb_cb (skb)->pkt_len = pkt_len; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1457/1518 slip: remove slip_hangup() to fix use-after-free in slip_receive_buf()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 23c53269f2baaedf2d92784290cb9ef6db2a3bce ]
Jaeyoung Chung and Eulgyu Kim reported a slab-use-after-free read in slip_receive_buf() when racing against tty hangup.
tty_ldisc_hangup() calls ld->ops->hangup() while holding only a read lock on tty->ldisc_sem (via tty_ldisc_ref()). Because slip_hangup() simply called slip_close(), it ran concurrently with reader functions such as slip_receive_buf().
slip_close() unregisters and frees the net device and its private struct slip, causing concurrent reader threads in slip_receive_buf() to dereference freed memory.
Line discipline close() is already guaranteed to be called under the write lock of tty->ldisc_sem during hangup processing (in tty_ldisc_reinit() or tty_ldisc_kill()).
Remove slip_hangup() so teardown is serialized cleanly by slip_close().
--- drivers/net/slip/slip.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/net/slip/slip.c +0 -8
@@ -886,8 +886,6 @@ static int slip_open(struct tty_struct *tty)* Close down a SLIP channel. * This means flushing out any pending queues, and then returning. This * call is serialized against other ldisc functions. -* -* We also use this method fo a hangup event */ static void slip_close (struct tty_struct *tty)
@@ -915,11 +913,6 @@ static void slip_close(struct tty_struct *tty)unregister_netdev (sl->dev);/* sl_uninit() has dropped the slip_devs[] entry by now */ } - -static void slip_hangup (struct tty_struct *tty) -{ -slip_close (tty); -}/************************************************************************ * STANDARD SLIP ENCAPSULATION * ************************************************************************/
@@ -1280,7 +1273,6 @@ static struct tty_ldisc_ops sl_ldisc = { .name = "slip", .open = slip_open, .close = slip_close, - .hangup = slip_hangup, .ioctl = slip_ioctl, .receive_buf = slip_receive_buf, .write_wakeup = slip_write_wakeup,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1458/1518 net: fec: only stop PTP if it was initialized
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit dd890ae29299636fb037276fc1b5238698d08b03 ]
fec_ptp_init() is only called when fep->bufdesc_ex is available. However, fec_probe() unconditionally calls fec_ptp_stop() on the failed_init path, and fec_drv_remove() unconditionally calls fec_ptp_stop() during device removal.
Check fep->bufdesc_ex before calling fec_ptp_stop() in both paths to avoid stopping PTP when it was not initialized.
--- drivers/net/ethernet/freescale/fec_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +4 -2
@@ -4642,7 +4642,8 @@ fec_probe(struct platform_device *pdev) failed_irq:fec_enet_deinit (ndev); failed_init: -fec_ptp_stop (pdev); +if (fep->bufdesc_ex) +fec_ptp_stop (pdev); failed_reset:pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);
@@ -4684,7 +4685,8 @@ fec_drv_remove(struct platform_device *pdev) ERR_PTR(ret));cancel_work_sync (&fep->tx_timeout_work); -fec_ptp_stop (pdev); +if (fep->bufdesc_ex) +fec_ptp_stop (pdev);unregister_netdev (ndev);fec_enet_mii_remove (fep);if (fep->reg_phy)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1459/1518 usb: atm: usbatm: fix invalid ci_range initialization
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit a60fd8c6dbaa76da4163cf225ed2b9e982540f39 ]
syzbot reported a shift-out-of-bounds in __vcc_connect():
UBSAN: shift-out-of-bounds in net/atm/common.c:382:32 shift exponent -1 is negative CPU: 0 UID: 0 PID: 5987 Comm: syz.0.18 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 08/05/2026 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 ubsan_epilogue+0xa/0x30 lib/ubsan.c:233 __ubsan_handle_shift_out_of_bounds+0x36d/0x400 lib/ubsan.c:494 __vcc_connect+0x14b4/0x19c0 net/atm/common.c:382 vcc_connect+0x328/0x8f0 net/atm/common.c:498 pvc_bind+0x272/0x380 net/atm/pvc.c:52 __sys_bind+0x2e3/0x410 net/socket.c:1976 __x64_sys_bind+0x7a/0x90 net/socket.c:1979 ...
ATM device ci_range fields (vpi_bits and vci_bits) represent the number of bits supported for VPI and VCI addressing on the device. net/atm/common.c directly uses these fields as bit shift counts:
vpi >> dev->ci_range.vpi_bits
vci >> dev->ci_range.vci_bits
1 << vcc->dev->ci_range.vpi_bits
1 << vcc->dev->ci_range.vci_bits
usbatm_atm_init() sets ci_range.vpi_bits and ci_range.vci_bits to ATM_CI_MAX (-1), which is defined in <uapi/linux/atmdev.h> as a sentinel value for userspace ATM_SETCIRANGE requests, not a valid bit count. Shifting by -1 is undefined behavior and triggers UBSAN warnings.
ATM UNI cell headers allow up to 8 bits for VPI (0..255) and 16 bits for VCI (0..65535). Initialize vpi_bits to 8 and vci_bits to 16, as done by solos-pci.
--- drivers/usb/atm/usbatm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/atm/usbatm.c +2 -2
@@ -917,8 +917,8 @@ static int usbatm_atm_init(struct usbatm_data *instance) instance->atm_dev = atm_dev; - atm_dev->ci_range.vpi_bits =ATM_CI_MAX ; - atm_dev->ci_range.vci_bits =ATM_CI_MAX ; + atm_dev->ci_range.vpi_bits =8 ; + atm_dev->ci_range.vci_bits =16 ; atm_dev->signal =ATM_PHY_SIG_UNKNOWN ;/* temp init ATM device, set to 128kbit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1460/1518 tcp: fix corruption of urgent data on multi-segment retransmit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit ce2b807f42ed5e55567b8864ab72963f90779270 ]
On the normal xmit path, while in urgent mode we refuse to build a multi-segment TSO packet, so every segment gets its own urg_ptr:
/* tcp_write_xmit() */ limit = mss_now; if (tso_segs > 1 && !tcp_urg_mode(tp)) limit = tcp_mss_split_point(...);
The retransmit path has no such guard. __tcp_retransmit_skb() builds a segs > 1 skb and hands it to the GSO layer, which only advances th->seq per segment and copies urg_ptr verbatim:
/* __tcp_retransmit_skb() */ len = cur_mss * segs; /* segs > 1, no urg_mode check */ ... /* tcp_gso_segment(): bumps seq only, urg_ptr is copied */
urg_ptr is an offset from the segment's own seq, so a copied value points at a different place on each segment. The receiver rebuilds the absolute urgent seq as seg.seq + urg_ptr, so it walks a moving urgent point instead of the one OOB byte:
seg1 seq 1 urg_ptr 5001 -> urgent @ 5001 (ok) seg2 seq 1001 urg_ptr 5001 -> urgent @ 6001 (wrong, +MSS) seg3 seq 2001 urg_ptr 5001 -> urgent @ 7001 (wrong, +2*MSS)
The real OOB byte is never pointed at, so the receiver stops splicing it out and delivers it as normal in-band data, corrupting the stream.
Guard the retransmit length like the xmit path: keep segs = 1 while in urgent mode.
--- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
@@ -3519,7 +3519,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) avail_wnd = cur_mss; } - len = cur_mss * segs; + len = cur_mss * (tcp_urg_mode (tp) ?1 : segs);if (len > avail_wnd) { len =rounddown (avail_wnd, cur_mss);if (!len)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1461/1518 net/sched: sch_htb: limit htb_classify inner-class filter hops
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 729c4896ab829169f95915d65edd530325910b37 ]
htb_classify() follows each filter-selected inner class by switching to cl->filter_list, but never bounds the number of hops. A filter on an inner class can point back to itself or to another inner class that points back, creating an infinite loop in the packet classification path with the qdisc lock held and BH disabled — a soft lockup / panic from a single packet.
Bound the traversal with a hop counter and drop the packet with a rate-limited warning once the bound is exceeded. The counter is incremented at the point the inner filter chain is picked up, after the TC_ACT_* switch has consumed the classifier verdict, so a terminal TC_ACT_QUEUED/STOLEN/TRAP on the last permitted chain still sets *qerr to __NET_XMIT_STOLEN and the packet is not charged as a drop by this qdisc or its parent.
The bound is TC_HTB_MAXDEPTH, taken from HTB's own parameters rather than from the qdisc hierarchy depth limit. Class levels run from 0 to TC_HTB_MAXDEPTH - 1, so a traversal that strictly descends in level can take at most TC_HTB_MAXDEPTH hops. That descent is what a sane configuration does, but it is assumed here rather than enforced:htb_find() resolves a classid against every class in the qdisc, so a filter may equally select a sibling or an ancestor. The normal root -> inner -> leaf path takes a single hop, so the bound does not affect legitimate classification.
htb_classify() can now return NULL irrespective of CONFIG_NET_CLS_ACT, whereas previously every NULL return sat inside that ifdef. The NULL handler in htb_enqueue() therefore cannot stay conditional either, so drop the ifdef around it. This matches hfsc_enqueue(), which has always handled a NULL class unconditionally. Without it, a kernel built without actions would dereference a NULL class instead of dropping.
Conditions to recreate the bug:
- CONFIG_NET_SCHED, CONFIG_NET_SCH_HTB, CONFIG_NET_CLS_U32, CONFIG_LOCKUP_DETECTOR.
- Create an HTB qdisc on a device (e.g. lo), add an inner class 1:1 with a leaf child 1:10, install a root u32 filter selecting 1:1, and an inner-class u32 filter on 1:1 also selecting 1:1.
- Send one packet (ping). On the unfixed kernel the classify loop spins with the qdisc lock held; with softlockup_panic=1 it panics.
- Reachable from unprivileged user via unshare -Urn (CAP_NET_ADMIN).
--- net/sched/sch_htb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/sched/sch_htb.c +5 -2
@@ -223,6 +223,7 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch,struct htb_class *cl;struct tcf_result res;struct tcf_proto *tcf; +unsigned int hops =0 ;int result;/* allow to select class by setting skb->priority to valid classid;
@@ -265,6 +266,10 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch,if (!cl->level)return cl;/* we hit leaf; return it */ +if (++hops >TC_HTB_MAXDEPTH ) { +pr_warn_ratelimited ("htb: classify loop detected, dropping packet\n" ); +return NULL ; + }/* we have got inner class; apply inner filter chain */ tcf =rcu_dereference_bh (cl->filter_list); }
@@ -632,13 +637,11 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch, }else {return qdisc_drop (skb, sch, to_free); } -#ifdef CONFIG_NET_CLS_ACT }else if (!cl) {if (ret & __NET_XMIT_BYPASS)qdisc_qstats_drop (sch);__qdisc_drop (skb, to_free);return ret; -#endif }else if ((ret =qdisc_enqueue (skb, cl->leaf.q, to_free)) !=NET_XMIT_SUCCESS ) {if (net_xmit_drop_count (ret)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1462/1518 dm-integrity: fix buffer overflow with keyed discard
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Cressey <[email protected]>
commit 59e6f919d77d72ec79cbf171256f2f7819737580 upstream.
Since commit 68c5c42567bc ("dm-integrity: replace forgeable discard filler with a keyed sector marker"), integrity_metadata computes a checksum for every discarded block into the "checksums" buffer. integrity_sector_checksum always writes the whole digest. So if the tag size is smaller than the digest size, the checksum of the last block that fits into the buffer is written past the end of it. For example, with hmac(sha256) and tag size 16, a 4MiB discard writes 16 bytes past the kmalloc'ed page.
Fix this by subtracting extra_space from the buffer size when computing max_blocks, like we do for writes.
--- drivers/md/dm-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-integrity.c +1 -1
@@ -1979,7 +1979,7 @@ static void integrity_metadata(struct woif (unlikely (dio->op ==REQ_OP_DISCARD )) {unsigned int bi_size = dio->bio_details.bi_iter.bi_size;unsigned int max_size =likely (checksums != checksums_onstack) ?PAGE_SIZE :HASH_MAX_DIGESTSIZE ; -unsigned int max_blocks = max_size / ic->tag_size; +unsigned int max_blocks = (max_size - extra_space) / ic->tag_size;sector_t sector = dio->range.logical_sector;if (!ic->discard_keyed)
Greg Kroah-Hartman
maintainerPATCH 1463/1518 mtd: rawnand: pl353: Fix debug prints
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal (DAVE) <[email protected]>
[ Upstream commit 2b7baaddf1bc3e39206a0354449fdc349945b86b ]
They are partially incorrect since "software" engine does not mean hamming, the "none" cae is also falling into this print, and on-die means there is some kind of hardware support; we prefer to use the wording on-host vs. on-die.
Fix all those prints.
--- drivers/mtd/nand/raw/pl35x-nand-controller.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/pl35x-nand-controller.c +5 -3
@@ -972,17 +972,19 @@ static int pl35x_nand_attach_chip(struct nand_chip *chip)switch (chip->ecc.engine_type) {case NAND_ECC_ENGINE_TYPE_ON_DIE : -dev_dbg (nfc->dev,"Using on-die ECC\n" ); +dev_dbg (nfc->dev,"Using on-die hardware ECC\n" );/* Keep these legacy BBT descriptors for ON_DIE situations */ chip->bbt_td = &bbt_main_descr; chip->bbt_md = &bbt_mirror_descr; fallthrough;case NAND_ECC_ENGINE_TYPE_NONE : +dev_dbg (nfc->dev,"Using no ECC engine\n" ); +break ;case NAND_ECC_ENGINE_TYPE_SOFT : -dev_dbg (nfc->dev,"Using software ECC (Hamming 1-bit/512B)\n" ); +dev_dbg (nfc->dev,"Using software ECC\n" );break ;case NAND_ECC_ENGINE_TYPE_ON_HOST : -dev_dbg (nfc->dev,"Using hardware ECC\n" ); +dev_dbg (nfc->dev,"Using on-host hardware ECC\n" ); ret =pl35x_nand_init_hw_ecc_controller (nfc, chip);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1464/1518 tracing: Move d_max_latency out of CONFIG_FSNOTIFY protection
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit b4bade506b18eb2e5e34ac84f915d7ee6156d4e2 ]
The tracing_max_latency shouldn't be limited if CONFIG_FSNOTIFY is defined or not and it was moved out of that protection to be always available with CONFIG_TRACER_MAX_TRACE. All was moved out except the dentry descriptor for it (d_max_latency) and it failed to build on some configs.
Move that out of the CONFIG_FSNOTIFY protection too.
--- kernel/trace/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.h +1 -1
@@ -346,8 +346,8 @@ struct trace_array {spinlock_t snapshot_trigger_lock;unsigned int snapshot;unsigned long max_latency; -#ifdef CONFIG_FSNOTIFY struct dentry *d_max_latency; +#ifdef CONFIG_FSNOTIFY struct work_struct fsnotify_work;struct irq_work fsnotify_irqwork;#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1465/1518 perf tests kvm: Avoid leaving perf.data.guest file around
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit b3d1dcd02c8cc1da723c1e9a6b74849ed94b6d30 ]
Ensure the perf.data output when checking permissions is written to /dev/null so that it isn't left in the directory the test is run.
--- tools/perf/tests/shell/kvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/kvm.sh +1 -1
@@ -133,7 +133,7 @@ setup_qemu() { skip "/dev/kvm not accessible" fi - if ! perf kvm stat record -a sleep 0.01 >/dev/null 2>&1; then + if ! perf kvm stat record -o /dev/null -a sleep 0.01 >/dev/null 2>&1; then skip "No permission to record kvm events" fi
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1466/1518 platform/x86: lg-laptop: Check ACPI_COMPANION() against NULL
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 7e169326c2263ebc4878baae536c956fa3118eff ]
Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.
Accordingly, add a requisite ACPI_COMPANION() check against NULL to the platform/x86 lg-laptop driver.
--- drivers/platform/x86/lg-laptop.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/platform/x86/lg-laptop.c +7 -2
@@ -755,12 +755,11 @@ static void lg_laptop_remove_address_space_handler(void *data)static int acpi_probe (struct platform_device *pdev) { -struct acpi_device *device =ACPI_COMPANION (&pdev->dev);struct platform_device_info pdev_info = { - .fwnode =acpi_fwnode_handle (device), .name =PLATFORM_NAME , .id =PLATFORM_DEVID_NONE , }; +struct acpi_device *device;acpi_status status;int ret;const char *product;
@@ -769,6 +768,12 @@ static int acpi_probe(struct platform_device *pdev)if (pf_device)return 0 ; + device =ACPI_COMPANION (&pdev->dev); +if (!device) +return -ENODEV ; + + pdev_info.fwnode =acpi_fwnode_handle (device), + status =acpi_install_address_space_handler (device->handle,LG_ADDRESS_SPACE_ID , &lg_laptop_address_space_handler,NULL , &pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1467/1518 serial: 8250: Ignore flow control on suspend/resume with no_console_suspend
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 302fbbb4fcbdeac2dc8c63a56c1c4e38c4781958 ]
If no_console_suspend is specified, on suspend the 8250 console driver uses a scratch register (UART_SCR) to store a special canary value. This is used during the resume path to identify a printk() call before the driver's own ->resume() callback. In this case, serial8250_console_restore() is called to quickly re-init the 8250 for console printing.
See commit 4516d50aabed ("serial: 8250: Use canary to restart console after suspend") for the original motivation.
Unfortunately, this canary workaround does not work in all cases (such as suspend to mem) because the scratch register will not reset. This has not been a real issue until now because it could simply lead to some garbage characters upon resume. However, with the introduction of console flow control it becomes a real problem because a failed suspend/resume detection when flow control is enabled leads to all characters hitting the flow control timeout.
Workaround this issue by temporarily ignoring console flow control when the debug canary suspend/resume detection is active.
--- drivers/tty/serial/8250/8250_port.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_port.c +8 -2
@@ -1990,8 +1990,14 @@ static void wait_for_xmitr(struct uart_8250_port *up, int bits)wait_for_lsr (up, bits); -/* Wait up to 1s for flow control if necessary */ -if (uart_console_hwflow_active (&up->port)) { +/* +* Wait up to 1s for flow control if necessary. +* When 'no_console_suspend' is active (in the window between +* suspend() and resume()), flow control is temporarily ignored +* because the canary workaround is not reliable in all situations, +* leading to flow control timeouts for every character. +*/ +if (uart_console_hwflow_active (&up->port) && !up->canary) {for (tmout =1000000 ; tmout; tmout--) {unsigned int msr =serial_in (up,UART_MSR ); up->msr_saved_flags |= msr &MSR_SAVE_FLAGS ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1468/1518 usb: ucsi: huawei_gaokun: move typec_altmode off stack
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit c7eaea5c6eeb391d445583fa6419c957ca74a86b ]
The typec_altmode structure contains a 'struct device' object that cannot be allocated on the stack because of its size, even when ignoring the lifetime rules:
drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c:326:13: error: stack frame size (1456) exceeds limit (1280) in 'gaokun_ucsi_usb_notify_ind' [-Werror,-Wframe-larger-than]
326 | static void gaokun_ucsi_usb_notify_ind(struct gaokun_ucsi *uec)
Since the altmode is always associated with a port here, move it into the port object and avoid at least the stack allocation issue.
--- drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c +6 -6
@@ -84,6 +84,8 @@ struct gaokun_ucsi_port {struct auxiliary_device *bridge;struct typec_mux *typec_mux; +struct typec_mux_state state; +struct typec_altmode dp_alt;int idx;enum gaokun_ucsi_ccx ccx;
@@ -293,24 +295,22 @@ static int gaokun_ucsi_refresh(struct gaokun_ucsi *uec)static void gaokun_ucsi_handle_usb_mode (struct gaokun_ucsi_port *port) {struct gaokun_ucsi *uec = port->ucsi; -struct typec_mux_state state = {}; -struct typec_altmode dp_alt = {};int idx = port->idx, ret;/* * For every typec port on this platform, the only mode-switch is * controlled by its qmp combo phy which consumes svid and mode only. */ - dp_alt.svid = port->svid; - state.mode = port->mode; - state.alt = &dp_alt; + port->dp_alt.svid = port->svid; + port->state.mode = port->mode; + port->state.alt = &port->dp_alt;if (idx >= uec->num_ports) {dev_warn (uec->dev,"altmode port out of range: %d\n" , idx);return ; } - ret =typec_mux_set (port->typec_mux, &state); + ret =typec_mux_set (port->typec_mux, &port->state);if (ret)dev_err (uec->dev,"failed to set mux %d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1469/1518 cpufreq/amd-pstate: handle missing policy in dynamic EPP callbacks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: EDAMAMEX <[email protected]>
[ Upstream commit 39c0cf62fc7851a17782e7efe8dfb2948739c681 ]
cpufreq_cpu_get() returns NULL when no cpufreq policy is associated with the requested CPU, for example because the CPU is offline or the policy has already been torn down. Both amd_pstate_power_supply_notifier() and amd_pstate_profile_set() acquire a policy via cpufreq_cpu_get() and then pass that pointer to amd_pstate_get_balanced_epp() and amd_pstate_set_epp(), which dereference it unconditionally. A racing CPU hotplug or driver teardown can therefore lead to a NULL pointer dereference on either of these dynamic EPP paths.
The third cpufreq_cpu_get() caller in this file, amd_pstate_verify(), already handles the NULL case. Bring the two new callers in line with that pattern: return NOTIFY_OK from the power-supply notifier (matching the other "nothing to do" exits) and -ENODEV from amd_pstate_profile_set() (the usual cpufreq error for a missing CPU policy).
Found by code inspection; not tested on hardware.
--- drivers/cpufreq/amd-pstate.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cpufreq/amd-pstate.c +6 -0
@@ -1113,6 +1113,9 @@ static int amd_pstate_power_supply_notifier(struct notifier_block *nb,if (cpudata->current_profile !=PLATFORM_PROFILE_BALANCED )return 0 ; +if (!policy) +return NOTIFY_OK ; + epp =amd_pstate_get_balanced_epp (policy); ret =amd_pstate_set_epp (policy, epp);
@@ -1148,6 +1151,9 @@ static int amd_pstate_profile_set(struct device *dev, struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpudata->cpu);int ret; +if (!policy) +return -ENODEV ; +switch (profile) {case PLATFORM_PROFILE_LOW_POWER : ret =amd_pstate_set_epp (policy,AMD_CPPC_EPP_POWERSAVE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1470/1518 cpufreq/amd-pstate: Reorder notifier unregistration and floor perf reset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit f3acf7ff113007557538b278ccb0e4ab7ae513ea ]
An active power supply notifier can race with amd_pstate_epp_cpu_exit() trying to reset the floor perf and can overwrite the floor perf set in MSR_AMD_CPPC_REQ.
Unregister the notifier before setting the floor perf to prevent the rare race.
--- drivers/cpufreq/amd-pstate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +3 -2
@@ -1841,11 +1841,12 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy)if (cpudata) {union perf_cached perf =READ_ONCE (cpudata->perf); +if (cpudata->dynamic_epp) +amd_pstate_clear_dynamic_epp (policy); +/* Reset CPPC_REQ MSR to the BIOS value */ amd_pstate_update_perf (policy, perf.bios_min_perf,0U ,0U ,0U , false); -if (cpudata->dynamic_epp) -amd_pstate_clear_dynamic_epp (policy);kfree (cpudata); policy->driver_data =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1471/1518 cpufreq/amd-pstate: Return -ENOMEM on failure to allocate profile_name
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit 87d2a8dec0f02b200eb3527da0ab11ba4d4e7deb ]
Failure to allocate profile name will return -EINVAL from platform_profile_register() while in fact, it is a failure to allocate memory for the profile_name string.
Return -ENOMEM when kasprintf() fails to allocate profile_name string.
--- drivers/cpufreq/amd-pstate.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/cpufreq/amd-pstate.c +2 -0
@@ -1226,6 +1226,8 @@ static int amd_pstate_set_dynamic_epp(struct cpufreq_policy *policy)return ret; cpudata->profile_name =kasprintf (GFP_KERNEL ,"amd-pstate-epp-cpu%d" , cpudata->cpu); +if (!cpudata->profile_name) +return -ENOMEM ; cpudata->ppdev = platform_profile_register(get_cpu_device(policy->cpu), cpudata->profile_name,
Signature · 1 line
2.53.0