6.6.158-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 575/1193 ppp_synctty: ensure a writeable skb header
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 8aaeb56aff2a557a88f83ae866da2c91ad247e59 ]
ppp_sync_txmunge() checks headroom before prepending the address and control bytes, but does not ensure that the skb header is writable. A received skb can reach this function through PPP channel bridging without passing through ppp_start_xmit(), which calls skb_cow_head().
For example, a PPPoE frame may share its buffer with a clone queued to an AF_PACKET socket. If it is bridged to a synchronous tty channel, the address/control bytes can overwrite data still visible to that socket.
Use skb_cow_head() to ensure both sufficient headroom and a writable header.
--- drivers/net/ppp/ppp_synctty.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/net/ppp/ppp_synctty.c +3 -11
@@ -526,17 +526,9 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)/* prepend address/control fields if necessary */ if ((ap->flags &SC_COMP_AC ) ==0 || islcp) { -if (skb_headroom (skb) <2 ) { -struct sk_buff *npkt =dev_alloc_skb (skb->len +2 ); -if (npkt ==NULL ) { -kfree_skb (skb); -return NULL ; - } -skb_reserve (npkt,2 ); -skb_copy_from_linear_data (skb, -skb_put (npkt, skb->len), skb->len); -consume_skb (skb); - skb = npkt; +if (skb_cow_head (skb,2 )) { +kfree_skb (skb); +return NULL ; }skb_push (skb,2 ); skb->data[0 ] =PPP_ALLSTATIONS ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 576/1193 net: stmmac: initialize ptp_lock at probe time
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 0338c68e22abd2ee509ec2e32508a50896618c32 ]
priv->ptp_lock is only initialized in stmmac_ptp_register(), which runs during __stmmac_open(). However, the lock is also used while the interface is down and has never been opened: tc_taprio_configure() invokes the PTP gettime64() callback to compute the EST base time when offloading a TAPRIO schedule, and stmmac_get_time() takes priv->ptp_lock. Using an uninitialized rwlock is undefined behaviour. Move the rwlock_init() to __stmmac_dvr_probe(), together with the other private locks, so that ptp_lock is always valid regardless of the interface state.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
@@ -7588,6 +7588,7 @@ int stmmac_dvr_probe(struct device *device,stmmac_napi_add (ndev);mutex_init (&priv->lock); +rwlock_init (&priv->ptp_lock);/* If a specific clk_csr value is passed from the platform * this means that the CSR Clock Range selection cannot be
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +0 -1
@@ -301,7 +301,6 @@ void stmmac_ptp_register(struct stmmac_priv *priv) stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; -rwlock_init (&priv->ptp_lock);mutex_init (&priv->aux_ts_lock); priv->ptp_clock_ops = stmmac_ptp_clock_ops;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 577/1193 selftests/powerpc/tm: Fix tcheck() reading uninitialised CR value
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thibault Ferrante <[email protected]>
[ Upstream commit ed28b16eab705071d28edaace47189c2eb3aa108 ]
tcheck() is used to check the current transaction state (active, suspended, doomed) via the "tcheck" instruction, which writes its result into CR field 0. The inline asm declared a GPR output operand for this result but never actually moved the CR into it.
Every caller (tcheck_doomed(), tcheck_active(), tcheck_suspended(), tcheck_transactional()) has effectively been testing bits of an unrelated, arbitrary register value since this helper was introduced.
The "& 4" mask discards the TDOOMED and TS_lsb (suspended) bits before they ever reach the callers, so tcheck_doomed() and tcheck_suspended() can never return true, and tcheck_transactional() degrades to being equivalent to tcheck_active().
Fix tcheck() to actually move CR into the output register with mfcr, and widen the mask from "& 4" to "& 0xf" so the full CR0 nibble (TDOOMED | TS_msb | TS_lsb | reserved) is preserved for the callers.
This bug has been present since tcheck() was introduced.
--- tools/testing/selftests/powerpc/tm/tm.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/powerpc/tm/tm.h +6 -2
@@ -105,8 +105,12 @@ static inline bool failure_is_nesting(void)static inline int tcheck (void ) {long cr; - asmvolatile ("tcheck 0" :"=r" (cr) : :"cr0" ); -return (cr >>28 ) &4 ; + asmvolatile ("tcheck 0;" +"mfcr %0;" + :"=r" (cr) + : + :"cr0" ); +return (cr >>28 ) &0xf ; }static inline bool tcheck_doomed (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 578/1193 perf/core: Check sample_type in perf_sample_save_callchain
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yabin Cui <[email protected]>
[ Upstream commit f226805bc5f60adf03783d8e4cbfe303ccecd64e ]
Check sample_type in perf_sample_save_callchain() to prevent saving callchain data when it isn't required.
Stable-dep-of: 88aa1223bfff ("perf/x86/intel: Correct pt_regs->flags update for PEBS path")
--- arch/x86/events/amd/ibs.c | 3 +-- arch/x86/events/intel/ds.c | 6 ++---- include/linux/perf_event.h | 5 +++++ 3 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/events/amd/ibs.c +1 -2
@@ -1135,8 +1135,7 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)* recorded as part of interrupt regs. Thus we need to use rip from * interrupt regs while unwinding call stack. */ -if (event->attr.sample_type &PERF_SAMPLE_CALLCHAIN ) -perf_sample_save_callchain (&data, event, iregs); +perf_sample_save_callchain (&data, event, iregs); throttle =perf_event_overflow (event, &data, ®s); out:
arch/x86/events/intel/ds.c +2 -4
@@ -1656,8 +1656,7 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event,* previous PMI context or an (I)RET happened between the record and * PMI. */ -if (sample_type &PERF_SAMPLE_CALLCHAIN ) -perf_sample_save_callchain (data, event, iregs); +perf_sample_save_callchain (data, event, iregs);/* * We use the interrupt regs as a base because the PEBS record does not
@@ -1824,8 +1823,7 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,* previous PMI context or an (I)RET happened between the record and * PMI. */ -if (sample_type &PERF_SAMPLE_CALLCHAIN ) -perf_sample_save_callchain (data, event, iregs); +perf_sample_save_callchain (data, event, iregs); *regs = *iregs;/* The ip in basic is EventingIP */
include/linux/perf_event.h +5 -0
@@ -1229,6 +1229,11 @@ static inline void perf_sample_save_callchain(struct perf_sample_data *data, {int size =1 ; +if (!(event->attr.sample_type &PERF_SAMPLE_CALLCHAIN )) +return ; +if (WARN_ON_ONCE (data->sample_flags &PERF_SAMPLE_CALLCHAIN )) +return ; + data->callchain =perf_callchain (event, regs); size += data->callchain->nr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 579/1193 perf/x86/intel/ds: Clarify adaptive PEBS processing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
[ Upstream commit 7087bfb0adc9a12ec3b463b1d38072c5efce5d6c ]
Modify the pebs_basic and pebs_meminfo structs to make the bitfields more explicit to ease readability of the code.
Stable-dep-of: 88aa1223bfff ("perf/x86/intel: Correct pt_regs->flags update for PEBS path")
--- arch/x86/events/intel/ds.c | 43 ++++++++++++++----------------- arch/x86/include/asm/perf_event.h | 16 ++++++++++-- 2 files changed, 34 insertions(+), 25 deletions(-)
arch/x86/events/intel/ds.c +20 -23
@@ -1783,8 +1783,6 @@ static void adaptive_pebs_save_regs(struct pt_regs *regs, }#define PEBS_LATENCY_MASK 0xffff -#define PEBS_CACHE_LATENCY_OFFSET 32 -#define PEBS_RETIRE_LATENCY_OFFSET 32/* * With adaptive PEBS the layout depends on what fields are configured.
@@ -1798,8 +1796,7 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);struct pebs_basic *basic = __pebs;void *next_record = basic +1 ; -u64 sample_type; -u64 format_size; +u64 sample_type, format_group;struct pebs_meminfo *meminfo =NULL ;struct pebs_gprs *gprs =NULL ;struct x86_perf_regs *perf_regs;
@@ -1811,7 +1808,7 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, perf_regs->xmm_regs =NULL ; sample_type = event->attr.sample_type; - format_size = basic->format_size; + format_group = basic->format_group;perf_sample_data_init (data,0 , event->hw.last_period); data->period = event->hw.last_period;
@@ -1832,7 +1829,7 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,if (sample_type &PERF_SAMPLE_WEIGHT_STRUCT ) {if (x86_pmu.flags &PMU_FL_RETIRE_LATENCY ) - data->weight.var3_w = format_size >>PEBS_RETIRE_LATENCY_OFFSET &PEBS_LATENCY_MASK ; + data->weight.var3_w = basic->retire_latency;else data->weight.var3_w =0 ; }
@@ -1842,12 +1839,12 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,* But PERF_SAMPLE_TRANSACTION needs gprs->ax. * Save the pointer here but process later. */ -if (format_size &PEBS_DATACFG_MEMINFO ) { +if (format_group &PEBS_DATACFG_MEMINFO ) { meminfo = next_record; next_record = meminfo +1 ; } -if (format_size &PEBS_DATACFG_GP ) { +if (format_group &PEBS_DATACFG_GP ) { gprs = next_record; next_record = gprs +1 ;
@@ -1860,14 +1857,13 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,adaptive_pebs_save_regs (regs, gprs); } -if (format_size &PEBS_DATACFG_MEMINFO ) { +if (format_group &PEBS_DATACFG_MEMINFO ) {if (sample_type &PERF_SAMPLE_WEIGHT_TYPE ) { -u64 weight = meminfo->latency; +u64 latency = x86_pmu.flags &PMU_FL_INSTR_LATENCY ? + meminfo->cache_latency : meminfo->mem_latency; -if (x86_pmu.flags &PMU_FL_INSTR_LATENCY ) { - data->weight.var2_w = weight &PEBS_LATENCY_MASK ; - weight >>=PEBS_CACHE_LATENCY_OFFSET ; - } +if (x86_pmu.flags &PMU_FL_INSTR_LATENCY ) + data->weight.var2_w = meminfo->instr_latency;/* * Although meminfo::latency is defined as a u64,
@@ -1875,12 +1871,13 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,* in practice on Ice Lake and earlier platforms. */ if (sample_type &PERF_SAMPLE_WEIGHT ) { - data->weight.full = weight ?: + data->weight.full = latency ?:intel_get_tsx_weight (meminfo->tsx_tuning); }else { - data->weight.var1_dw = (u32)(weight &PEBS_LATENCY_MASK ) ?: + data->weight.var1_dw = (u32 )latency ?:intel_get_tsx_weight (meminfo->tsx_tuning); } + data->sample_flags |=PERF_SAMPLE_WEIGHT_TYPE ; }
@@ -1901,16 +1898,16 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, } } -if (format_size &PEBS_DATACFG_XMMS ) { +if (format_group &PEBS_DATACFG_XMMS ) {struct pebs_xmm *xmm = next_record; next_record = xmm +1 ; perf_regs->xmm_regs = xmm->xmm; } -if (format_size &PEBS_DATACFG_LBRS ) { +if (format_group &PEBS_DATACFG_LBRS ) {struct lbr_entry *lbr = next_record; -int num_lbr = ((format_size >>PEBS_DATACFG_LBR_SHIFT ) +int num_lbr = ((format_group >>PEBS_DATACFG_LBR_SHIFT ) &0xff ) +1 ; next_record = next_record + num_lbr *sizeof (struct lbr_entry );
@@ -1920,11 +1917,11 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, } } -WARN_ONCE (next_record != __pebs + (format_size >>48 ), -"PEBS record size %llu, expected %llu, config %llx\n" , - format_size >>48 , +WARN_ONCE (next_record != __pebs + basic->format_size, +"PEBS record size %u, expected %llu, config %llx\n" , + basic->format_size, (u64)(next_record - __pebs), - basic->format_size); + format_group); } static inline void *
arch/x86/include/asm/perf_event.h +14 -2
@@ -425,7 +425,9 @@ static inline bool is_topdown_idx(int idx)*/ struct pebs_basic { -u64 format_size; +u64 format_group:32 , + retire_latency:16 , + format_size:16 ;u64 ip;u64 applicable_counters;u64 tsc;
@@ -434,7 +436,17 @@ struct pebs_basic {struct pebs_meminfo {u64 address;u64 aux; -u64 latency; +union { +/* pre Alder Lake */ +u64 mem_latency; +/* Alder Lake and later */ +struct { +u64 instr_latency:16 ; +u64 pad2:16 ; +u64 cache_latency:16 ; +u64 pad3:16 ; + }; + };u64 tsx_tuning; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 580/1193 perf/x86/intel/ds: Remove redundant assignments to sample.period
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Changbin Du <[email protected]>
[ Upstream commit 75a9001bab36f0456f6aae1ab0aa487db456464a ]
The perf_sample_data_init() has already set the period of sample, so no need to do it again.
Stable-dep-of: 88aa1223bfff ("perf/x86/intel: Correct pt_regs->flags update for PEBS path")
--- arch/x86/events/intel/ds.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/events/intel/ds.c +0 -3
@@ -1632,8 +1632,6 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event,perf_sample_data_init (data,0 , event->hw.last_period); - data->period = event->hw.last_period; -/* * Use latency for weight (only avail with PEBS-LL) */
@@ -1810,7 +1808,6 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, sample_type = event->attr.sample_type; format_group = basic->format_group;perf_sample_data_init (data,0 , event->hw.last_period); - data->period = event->hw.last_period;setup_pebs_time (event, data, basic->tsc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 581/1193 perf/x86/intel/ds: Factor out PEBS group processing code to functions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
[ Upstream commit 167cde7dc9b36b7a88f3c29d836fabce13023327 ]
Adaptive PEBS and arch-PEBS share lots of same code to process these PEBS groups, like basic, GPR and meminfo groups. Extract these shared code to generic functions to avoid duplicated code.
Stable-dep-of: 88aa1223bfff ("perf/x86/intel: Correct pt_regs->flags update for PEBS path")
--- arch/x86/events/intel/ds.c | 170 +++++++++++++++++++++++-------------- 1 file changed, 104 insertions(+), 66 deletions(-)
arch/x86/events/intel/ds.c +104 -66
@@ -1782,6 +1782,90 @@ static void adaptive_pebs_save_regs(struct pt_regs *regs,#define PEBS_LATENCY_MASK 0xffff +static inline void __setup_perf_sample_data (struct perf_event *event, +struct pt_regs *iregs, +struct perf_sample_data *data) +{ +perf_sample_data_init (data,0 , event->hw.last_period); + +/* +* We must however always use iregs for the unwinder to stay sane; the +* record BP,SP,IP can point into thin air when the record is from a +* previous PMI context or an (I)RET happened between the record and +* PMI. +*/ +perf_sample_save_callchain (data, event, iregs); +} + +static inline void __setup_pebs_basic_group (struct perf_event *event, +struct pt_regs *regs, +struct perf_sample_data *data, +u64 sample_type,u64 ip, +u64 tsc,u16 retire) +{ +/* The ip in basic is EventingIP */ +set_linear_ip (regs, ip); + regs->flags =PERF_EFLAGS_EXACT ; +setup_pebs_time (event, data, tsc); + +if (sample_type &PERF_SAMPLE_WEIGHT_STRUCT ) + data->weight.var3_w = retire; +} + +static inline void __setup_pebs_gpr_group (struct perf_event *event, +struct pt_regs *regs, +struct pebs_gprs *gprs, +u64 sample_type) +{ +if (event->attr.precise_ip <2 ) { +set_linear_ip (regs, gprs->ip); + regs->flags &= ~PERF_EFLAGS_EXACT ; + } + +if (sample_type & (PERF_SAMPLE_REGS_INTR |PERF_SAMPLE_REGS_USER )) +adaptive_pebs_save_regs (regs, gprs); +} + +static inline void __setup_pebs_meminfo_group (struct perf_event *event, +struct perf_sample_data *data, +u64 sample_type,u64 latency, +u16 instr_latency,u64 address, +u64 aux,u64 tsx_tuning,u64 ax) +{ +if (sample_type &PERF_SAMPLE_WEIGHT_TYPE ) { +u64 tsx_latency =intel_get_tsx_weight (tsx_tuning); + + data->weight.var2_w = instr_latency; + +/* +* Although meminfo::latency is defined as a u64, +* only the lower 32 bits include the valid data +* in practice on Ice Lake and earlier platforms. +*/ +if (sample_type &PERF_SAMPLE_WEIGHT ) + data->weight.full = latency ?: tsx_latency; +else + data->weight.var1_dw = (u32 )latency ?: tsx_latency; + + data->sample_flags |=PERF_SAMPLE_WEIGHT_TYPE ; + } + +if (sample_type &PERF_SAMPLE_DATA_SRC ) { + data->data_src.val =get_data_src (event, aux); + data->sample_flags |=PERF_SAMPLE_DATA_SRC ; + } + +if (sample_type &PERF_SAMPLE_ADDR_TYPE ) { + data->addr = address; + data->sample_flags |=PERF_SAMPLE_ADDR ; + } + +if (sample_type &PERF_SAMPLE_TRANSACTION ) { + data->txn =intel_get_tsx_transaction (tsx_tuning, ax); + data->sample_flags |=PERF_SAMPLE_TRANSACTION ; + } +} +/* * With adaptive PEBS the layout depends on what fields are configured. */
@@ -1792,12 +1876,14 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, struct pt_regs *regs) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events); +u64 sample_type = event->attr.sample_type;struct pebs_basic *basic = __pebs;void *next_record = basic +1 ; -u64 sample_type, format_group;struct pebs_meminfo *meminfo =NULL ;struct pebs_gprs *gprs =NULL ;struct x86_perf_regs *perf_regs; +u64 format_group; +u16 retire;if (basic ==NULL )return ;
@@ -1805,31 +1891,17 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, perf_regs = container_of(regs, struct x86_perf_regs, regs); perf_regs->xmm_regs =NULL ; - sample_type = event->attr.sample_type; format_group = basic->format_group; -perf_sample_data_init (data,0 , event->hw.last_period); -setup_pebs_time (event, data, basic->tsc); - -/* -* We must however always use iregs for the unwinder to stay sane; the -* record BP,SP,IP can point into thin air when the record is from a -* previous PMI context or an (I)RET happened between the record and -* PMI. -*/ -perf_sample_save_callchain (data, event, iregs); +__setup_perf_sample_data (event, iregs, data); *regs = *iregs; -/* The ip in basic is EventingIP */ -set_linear_ip (regs, basic->ip); - regs->flags =PERF_EFLAGS_EXACT ; -if (sample_type &PERF_SAMPLE_WEIGHT_STRUCT ) { -if (x86_pmu.flags &PMU_FL_RETIRE_LATENCY ) - data->weight.var3_w = basic->retire_latency; -else - data->weight.var3_w =0 ; - } +/* basic group */ + retire = x86_pmu.flags &PMU_FL_RETIRE_LATENCY ? + basic->retire_latency :0 ; +__setup_pebs_basic_group (event, regs, data, sample_type, + basic->ip, basic->tsc, retire);/* * The record for MEMINFO is in front of GP
@@ -1845,54 +1917,20 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, gprs = next_record; next_record = gprs +1 ; -if (event->attr.precise_ip <2 ) { -set_linear_ip (regs, gprs->ip); - regs->flags &= ~PERF_EFLAGS_EXACT ; - } - -if (sample_type & (PERF_SAMPLE_REGS_INTR |PERF_SAMPLE_REGS_USER )) -adaptive_pebs_save_regs (regs, gprs); +__setup_pebs_gpr_group (event, regs, gprs, sample_type); }if (format_group &PEBS_DATACFG_MEMINFO ) { -if (sample_type &PERF_SAMPLE_WEIGHT_TYPE ) { -u64 latency = x86_pmu.flags &PMU_FL_INSTR_LATENCY ? - meminfo->cache_latency : meminfo->mem_latency; - -if (x86_pmu.flags &PMU_FL_INSTR_LATENCY ) - data->weight.var2_w = meminfo->instr_latency; - -/* -* Although meminfo::latency is defined as a u64, -* only the lower 32 bits include the valid data -* in practice on Ice Lake and earlier platforms. -*/ -if (sample_type &PERF_SAMPLE_WEIGHT ) { - data->weight.full = latency ?: -intel_get_tsx_weight (meminfo->tsx_tuning); - }else { - data->weight.var1_dw = (u32 )latency ?: -intel_get_tsx_weight (meminfo->tsx_tuning); - } - - data->sample_flags |=PERF_SAMPLE_WEIGHT_TYPE ; - } - -if (sample_type &PERF_SAMPLE_DATA_SRC ) { - data->data_src.val =get_data_src (event, meminfo->aux); - data->sample_flags |=PERF_SAMPLE_DATA_SRC ; - } - -if (sample_type &PERF_SAMPLE_ADDR_TYPE ) { - data->addr = meminfo->address; - data->sample_flags |=PERF_SAMPLE_ADDR ; - } - -if (sample_type &PERF_SAMPLE_TRANSACTION ) { - data->txn =intel_get_tsx_transaction (meminfo->tsx_tuning, - gprs ? gprs->ax :0 ); - data->sample_flags |=PERF_SAMPLE_TRANSACTION ; - } +u64 latency = x86_pmu.flags &PMU_FL_INSTR_LATENCY ? + meminfo->cache_latency : meminfo->mem_latency; +u64 instr_latency = x86_pmu.flags &PMU_FL_INSTR_LATENCY ? + meminfo->instr_latency :0 ; +u64 ax = gprs ? gprs->ax :0 ; + +__setup_pebs_meminfo_group (event, data, sample_type, latency, + instr_latency, meminfo->address, + meminfo->aux, meminfo->tsx_tuning, + ax); }if (format_group &PEBS_DATACFG_XMMS ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 582/1193 perf/x86/intel: Correct pt_regs->flags update for PEBS path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
[ Upstream commit 88aa1223bfffb1a0a98c639e9e1f71058f0d9178 ]
pt_regs->flags holds the saved CPU FLAGS register. In the PEBS path, it was incorrectly set to PERF_EFLAGS_EXACT instead of being populated from the PEBS flags snapshot.
Update pt_regs->flags from PEBS GPR flags if GPRs group is present.
--- arch/x86/events/intel/ds.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/x86/events/intel/ds.c +9 -1
@@ -1805,7 +1805,7 @@ static inline void __setup_pebs_basic_group(struct perf_event *event, {/* The ip in basic is EventingIP */ set_linear_ip (regs, ip); - regs->flags =PERF_EFLAGS_EXACT ; + regs->flags |=PERF_EFLAGS_EXACT ;setup_pebs_time (event, data, tsc);if (sample_type &PERF_SAMPLE_WEIGHT_STRUCT )
@@ -1817,9 +1817,17 @@ static inline void __setup_pebs_gpr_group(struct perf_event *event, struct pebs_gprs *gprs, u64 sample_type) { +/* +* Update flags with PEBS data. PERF_EFLAGS_EXACT must be set +* in previous basic group handling. +*/ + regs->flags = gprs->flags |PERF_EFLAGS_EXACT ; +if (event->attr.precise_ip <2 ) {set_linear_ip (regs, gprs->ip); regs->flags &= ~PERF_EFLAGS_EXACT ; + }else if (regs->flags &X86_VM_MASK ) { + regs->flags ^= (PERF_EFLAGS_VM |X86_VM_MASK ); }if (sample_type & (PERF_SAMPLE_REGS_INTR |PERF_SAMPLE_REGS_USER ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/1193 net: ks8851: Fix receiver error in 100BASE-TX mode following software power-down
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 66ef5adb75446627f8b6c26cd04f2adc86d4de56 ]
KSZ8851 errata sheet DS80000716D-page 4 Module 3 [1] states that, when issuing a software power-down (PMECR[1:0] = 10) followed by a power-on (PMECR[1:0] = 00), the receiver circuit can fail to start properly preventing communication. The Transmitter will still send data, but no data will be received.
The errata sheet also includes a workaround, which states that, it is recommended that the software power-down feature not be used.
Implement that workaround and drop the entry into software power-down mode. The ks8851_write_mac_addr() calls entry into normal power-on mode at the very beginning of the function, therefore dropping the second call to enter software power-down mode is sufficient here. The ks8851_net_stop() can only be called after ks8851_net_start() was already called, and ks8851_net_start() also makes the MAC enter normal power-on mode, therefore it is also fine to drop the call to enter software power-down mode from ks8851_net_stop().
This will lead to a slight increase in power consumption, but it also fixes a sporadic reliability problem on at least KSZ8851-16MLL, which is where the problem was reported and this fix was tested.
[1] https://ww1.microchip.com/downloads/en/DeviceDoc/80000716D.pdf
--- drivers/net/ethernet/micrel/ks8851_common.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/ethernet/micrel/ks8851_common.c +1 -7
@@ -143,9 +143,6 @@ static int ks8851_write_mac_addr(struct net_device *dev)ks8851_wrreg16 (ks,KS_MAR (i), val); } -if (!netif_running (dev)) -ks8851_set_powermode (ks,PMECR_PM_SOFTDOWN ); -ks8851_unlock (ks);return 0 ;
@@ -494,8 +491,7 @@ static int ks8851_net_open(struct net_device *dev)* @dev: The device being closed. * * Called to close down a network device which has been active. Cancel any -* work, shutdown the RX and TX process and then place the chip into a low -* power state whilst it is not being used. +* work and shutdown the RX and TX process. */ static int ks8851_net_stop (struct net_device *dev) {
@@ -522,8 +518,6 @@ static int ks8851_net_stop(struct net_device *dev)/* shutdown TX process */ ks8851_wrreg16 (ks,KS_TXCR ,0x0000 ); -/* set powermode to soft power down to save power */ -ks8851_set_powermode (ks,PMECR_PM_SOFTDOWN );ks8851_unlock (ks);/* ensure any queued tx buffers are dumped */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 583/1193 net/sched: cls_route: free emptied bucket on filter move
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 1853f30cf5c84971f99788a76207c6f745380896 ]
route4_change can move an existing filter to a different top-level
bucket: route4_set_parms recomputes the handle from TCA_ROUTE4_TO/ FROM/IIF, and the handle-mismatch check is gated on the 'new' flag, so for an existing filter the new handle may differ from the old one and land in a different bucket. When this happens, the filter is unlinked from the old bucket, but the bucket itself is never freed once it goes empty. The stale empty bucket remains in head->table[], causing route4_delete to report *last=false even after the last live filter is gone. That pins the empty tcf_proto and causes a leak.
Fix this by refcounting the filters linked to a bucket and freeing the bucket when the count drops to zero. The existing scan in route4_delete goes away with it.
The count is updated at all sites that link or unlink a filter during add, change and delete, and the bucket is dropped from head->table[] as soon as it reaches zero.
Conditions to recreate the bug:
CONFIG_NET_CLS_ROUTE4=y, CONFIG_NET_SCH_INGRESS=y, CONFIG_NET_CLS_ACT=y.
tc qdisc replace dev lo clsact
tc filter add dev lo ingress protocol ip pref 100 route from 1 to 1 tc filter change dev lo ingress protocol ip pref 100 handle 0x10001 \
route from 1 to 2
tc filter del dev lo ingress protocol ip pref 100 handle 0x10002 \
route from 1 to 2
tc filter show dev lo ingress | grep -c 'pref 100 route chain 0 '
--- net/sched/cls_route.c | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-)
net/sched/cls_route.c +22 -23
@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/string.h> #include <linux/errno.h> +#include <linux/refcount.h> #include <linux/skbuff.h> #include <net/dst.h> #include <net/route.h>
@@ -41,6 +42,7 @@ struct route4_head {struct route4_bucket {/* 16 FROM buckets + 16 IIF buckets + 1 wildcard bucket */ struct route4_filter __rcu *ht[16 +16 +1 ]; +refcount_t filters_ref;struct rcu_head rcu; };
@@ -336,7 +338,7 @@ static int route4_delete(struct tcf_proto *tp, void *arg, bool *last,struct route4_filter *nf;struct route4_bucket *b;unsigned int h =0 ; -int i, h1; +int h1;if (!head || !f)return -EINVAL ;
@@ -362,23 +364,14 @@ static int route4_delete(struct tcf_proto *tp, void *arg, bool *last,tcf_exts_get_net (&f->exts);tcf_queue_work (&f->rwork, route4_delete_filter_work); -/* Strip RTNL protected tree */ -for (i =0 ; i <=32 ; i++) { -struct route4_filter *rt; - - rt =rtnl_dereference (b->ht[i]); -if (rt) - goto out; +if (refcount_dec_and_test (&b->filters_ref)) { +RCU_INIT_POINTER (head->table[to_hash (h)],NULL ); +kfree_rcu (b, rcu); } - -/* OK, session has no flows */ -RCU_INIT_POINTER (head->table[to_hash (h)],NULL ); -kfree_rcu (b, rcu);break ; } } -out: *last = true;for (h1 =0 ; h1 <=256 ; h1++) {if (rcu_access_pointer (head->table[h1])) {
@@ -455,6 +448,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,if (b ==NULL )return -ENOBUFS ; +refcount_set (&b->filters_ref,1 );rcu_assign_pointer (head->table[h1], b); }else {unsigned int h2 =from_hash (nhandle >>16 );
@@ -464,6 +458,8 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, fp = rtnl_dereference(fp->next))if (fp->handle == f->handle)return -EEXIST ; + +refcount_inc (&b->filters_ref); }if (tb[TCA_ROUTE4_TO ])
@@ -497,7 +493,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,struct route4_bucket *b;struct nlattr *opt = tca[TCA_OPTIONS ];struct nlattr *tb[TCA_ROUTE4_MAX +1 ]; -unsigned int h, th; +unsigned int h;int err;bool new = true;
@@ -555,17 +551,20 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,rcu_assign_pointer (*fp, f);if (fold) { - th =to_hash (fold->handle); + b = fold->bkt; h =from_hash (fold->handle >>16 ); - b =rtnl_dereference (head->table[th]); -if (b) { - fp = &b->ht[h]; -for (pfp =rtnl_dereference (*fp); pfp; - fp = &pfp->next, pfp =rtnl_dereference (*fp)) { -if (pfp == fold) { -rcu_assign_pointer (*fp, fold->next); -break ; + fp = &b->ht[h]; +for (pfp =rtnl_dereference (*fp); pfp; + fp = &pfp->next, pfp =rtnl_dereference (*fp)) { +if (pfp == fold) { +rcu_assign_pointer (*fp, fold->next); +if (refcount_dec_and_test (&b->filters_ref)) { +unsigned int th =to_hash (fold->handle); + +RCU_INIT_POINTER (head->table[th],NULL ); +kfree_rcu (b, rcu); } +break ; } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 584/1193 net/sched: cls_route: Reject handle aliasing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit b74a8455a2f271f54695b6a8ec1f113824a46c0e ]
route4_set_parms() rejects a duplicate by scanning the destination chain for f->handle, but f->handle is the handle the filter has before the update, not the one it is about to be linked under. The comparison and the insertion therefore use different handles, which causes breakage.
When a change moves the filter to a chain that already holds nhandle, the scan looks for the old handle instead, misses the collision and links a second filter with the same handle:
tc filter add dev lo ingress protocol ip pref 100 \
route from 1 to 1 classid 1:1 action ok
tc filter add dev lo ingress protocol ip pref 100 \
route from 2 to 2 classid 1:2 action drop
tc filter change dev lo ingress protocol ip pref 100 handle 0x10001 \
route from 2 to 2 classid 1:1 action ok
tc filter show dev lo ingress
... fh 0x00020002 flowid 1:2 to 2 from 2
... fh 0x00020002 flowid 1:1 to 2 from 2
The newcomer is appended after the incumbent, and both end up with the same f->id. route4_get() returns the first match, so the second filter can no longer be addressed by handle, and route4_classify() stops at the first filter whose f->id matches. The second filter is dumped but is effectively dead.
Fix this by comparing against nhandle.
--- net/sched/cls_route.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sched/cls_route.c +5 -1
@@ -456,8 +456,12 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,for (fp =rtnl_dereference (b->ht[h2]); fp; fp =rtnl_dereference (fp->next)) -if (fp->handle == f->handle) +if (fp->handle == nhandle) { +NL_SET_ERR_MSG_FMT (extack, +"Handle %x is already in use" , + nhandle);return -EEXIST ; + }refcount_inc (&b->filters_ref); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 585/1193 net/sched: cls_route: make netlink errors meaningful
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pedro Tammela <[email protected]>
[ Upstream commit ef765c25875941564edf447302ff339363441e58 ]
Use netlink extended ack and parsing policies to return more meaningful errors instead of the relying solely on errnos.
Stable-dep-of: 41e85e54e564 ("net/sched: cls_route: Fix in-place replace")
--- net/sched/cls_route.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-)
net/sched/cls_route.c +21 -16
@@ -385,9 +385,9 @@ static int route4_delete(struct tcf_proto *tp, void *arg, bool *last,static const struct nla_policy route4_policy[TCA_ROUTE4_MAX +1 ] = { [TCA_ROUTE4_CLASSID ] = { .type =NLA_U32 }, - [TCA_ROUTE4_TO ] = { .type =NLA_U32 }, - [TCA_ROUTE4_FROM ] = { .type =NLA_U32 }, - [TCA_ROUTE4_IIF ] = { .type =NLA_U32 }, + [TCA_ROUTE4_TO ] =NLA_POLICY_MAX (NLA_U32 ,0xFF ), + [TCA_ROUTE4_FROM ] =NLA_POLICY_MAX (NLA_U32 ,0xFF ), + [TCA_ROUTE4_IIF ] =NLA_POLICY_MAX (NLA_U32 ,0x7FFF ), }; static int route4_set_parms(struct net *net, struct tcf_proto *tp,
@@ -407,33 +407,37 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,return err;if (tb[TCA_ROUTE4_TO ]) { -if (new && handle &0x8000 ) +if (new && handle &0x8000 ) { +NL_SET_ERR_MSG (extack,"Invalid handle" );return -EINVAL ; + } to =nla_get_u32 (tb[TCA_ROUTE4_TO ]); -if (to >0xFF ) -return -EINVAL ; nhandle = to; } +if (tb[TCA_ROUTE4_FROM ] && tb[TCA_ROUTE4_IIF ]) { +NL_SET_ERR_MSG_ATTR (extack, tb[TCA_ROUTE4_FROM ], +"'from' and 'fromif' are mutually exclusive" ); +return -EINVAL ; + } +if (tb[TCA_ROUTE4_FROM ]) { -if (tb[TCA_ROUTE4_IIF ]) -return -EINVAL ; id =nla_get_u32 (tb[TCA_ROUTE4_FROM ]); -if (id >0xFF ) -return -EINVAL ; nhandle |= id <<16 ; }else if (tb[TCA_ROUTE4_IIF ]) { id =nla_get_u32 (tb[TCA_ROUTE4_IIF ]); -if (id >0x7FFF ) -return -EINVAL ; nhandle |= (id |0x8000 ) <<16 ; }else nhandle |=0xFFFF <<16 ;if (handle && new) { nhandle |= handle &0x7F00 ; -if (nhandle != handle) +if (nhandle != handle) { +NL_SET_ERR_MSG_FMT (extack, +"Handle mismatch constructed: %x (expected: %x)" , + handle, nhandle);return -EINVAL ; + } }if (!nhandle) {
@@ -495,7 +499,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,struct route4_filter __rcu **fp;struct route4_filter *fold, *f1, *pfp, *f =NULL ;struct route4_bucket *b; -struct nlattr *opt = tca[TCA_OPTIONS ];struct nlattr *tb[TCA_ROUTE4_MAX +1 ];unsigned int h;int err;
@@ -506,10 +509,12 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; } -if (opt ==NULL ) +if (NL_REQ_ATTR_CHECK (extack,NULL , tca,TCA_OPTIONS )) { +NL_SET_ERR_MSG_MOD (extack,"Missing options" );return -EINVAL ; + } - err =nla_parse_nested_deprecated (tb,TCA_ROUTE4_MAX , opt, + err =nla_parse_nested_deprecated (tb,TCA_ROUTE4_MAX , tca[TCA_OPTIONS ], route4_policy,NULL );if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 586/1193 net/sched: cls_route: Fix in-place replace
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 41e85e54e5649a1617698438b0ce64c6f9d83d69 ]
Building on the previous patch, route4_set_parms rejects a duplicate by scanning the destination chain for nhandle, but the scan doesn't exclude the older version it is replacing, so an in-place replace will match the older version's handle and fail.
Fix this by passing the older filter as a parameter to route4_set_parms (replacing "new") and skipping it in the scan.
Excluding the older version is not enough on its own. nhandle is built out of TCA_ROUTE4_TO, TCA_ROUTE4_FROM and TCA_ROUTE4_IIF alone, while the 0x7F00 bits, which only tell apart filters sharing one key, are folded in on the create path. Letting the replace through would therefore rename the filter it replaces: replacing handle 0x10101 stored it back as 0x10001, and a sibling at 0x10201 could then no longer be replaced at all, since its own nhandle collided with the renamed filter.
tc filter add ... handle 0x10101 route from 1 to 1 classid 1:1 tc filter add ... handle 0x10201 route from 1 to 1 classid 1:2 tc filter replace ... handle 0x10101 route from 1 to 1 classid 1:9 ... fh 0x00010001 flowid 1:9 to 1 from 1 ... fh 0x00010201 flowid 1:2 to 1 from 1 tc filter replace ... handle 0x10201 route from 1 to 1 classid 1:8 Error: Handle 10001 is already in use.
So carry those bits over when the key the request builds is the key the older filter already has. An in-place replace then keeps the handle userspace named the filter by, while a request that does change the key still renames it, as it did before.
--- net/sched/cls_route.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
net/sched/cls_route.c +13 -14
@@ -393,8 +393,9 @@ static const struct nla_policy route4_policy[TCA_ROUTE4_MAX + 1] = {static int route4_set_parms (struct net *net,struct tcf_proto *tp,unsigned long base,struct route4_filter *f,u32 handle,struct route4_head *head, -struct nlattr **tb,struct nlattr *est,int new, -u32 flags,struct netlink_ext_ack *extack) +struct nlattr **tb,struct nlattr *est, +struct route4_filter *fold,u32 flags, +struct netlink_ext_ack *extack) {u32 id =0 , to =0 , nhandle =0x8000 ;struct route4_filter *fp;
@@ -407,7 +408,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,return err;if (tb[TCA_ROUTE4_TO ]) { -if (new && handle &0x8000 ) { +if (!fold && handle &0x8000 ) {NL_SET_ERR_MSG (extack,"Invalid handle" );return -EINVAL ; }
@@ -430,14 +431,14 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, }else nhandle |=0xFFFF <<16 ; -if (handle && new) { +if (handle && (!fold || nhandle == (handle & ~0x7F00 ))) nhandle |= handle &0x7F00 ; -if (nhandle != handle) { -NL_SET_ERR_MSG_FMT (extack, -"Handle mismatch constructed: %x (expected: %x)" , - handle, nhandle); -return -EINVAL ; - } + +if (handle && !fold && nhandle != handle) { +NL_SET_ERR_MSG_FMT (extack, +"Handle mismatch constructed: %x (expected: %x)" , + handle, nhandle); +return -EINVAL ; }if (!nhandle) {
@@ -460,7 +461,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,for (fp =rtnl_dereference (b->ht[h2]); fp; fp =rtnl_dereference (fp->next)) -if (fp->handle == nhandle) { +if (fp != fold && fp->handle == nhandle) {NL_SET_ERR_MSG_FMT (extack,"Handle %x is already in use" , nhandle);
@@ -502,7 +503,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,struct nlattr *tb[TCA_ROUTE4_MAX +1 ];unsigned int h;int err; -bool new = true;if (!handle) {NL_SET_ERR_MSG (extack,"Creating with handle of 0 is invalid" );
@@ -539,11 +539,10 @@ static int route4_change(struct net *net, struct sk_buff *in_skb, f->tp = fold->tp; f->bkt = fold->bkt; - new = false; } err =route4_set_parms (net, tp, base, f, handle, head, tb, - tca[TCA_RATE ], new, flags, extack); + tca[TCA_RATE ], fold, flags, extack);if (err <0 ) goto errout;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 587/1193 net/sched: cls_api: Dont replay RTM_GETCHAIN in tc_ctl_chain().
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit dff39930ad5e53d202bfdfb14687d1d2fd753b4d ]
If a netlink socket sends RTM_GETCHAIN requests repeatedly without recv()ing the responses, tc_ctl_chain() hogs CPU and triggers Hung Task splat. [0]
As caught in the stack trace, netlink_attachskb() could confuse tc_ctl_chain() by returning -EAGAIN when the userspace netlink socket's receive buffer is full.
The replay: label exists since commit 32a4f5ecd738 ("net: sched:
introduce chain object to uapi") but was not used initially.
Since commit 9f407f1768d3 ("net: sched: introduce chain templates"), the label is needed for RTM_NEWCHAIN because tcf_proto_lookup_ops() may release RTNL to call request_module().
However, the replay logic is unnecessary for RTM_GETCHAIN.
Let's apply the replay logic only for RTM_NEWCHAIN.
[0]:
INFO: task repro:1018 is blocked on a mutex likely owned by task repro:1022. task:repro state:R running task stack:14096 pid:1022 tgid:1014 ppid:961 task_flags:0x400040 flags:0x00080000 Call Trace: <TASK> ? clockevents_program_event (kernel/time/clockevents.c:372) ? pskb_expand_head (net/core/skbuff.c:615) ? skb_release_data (net/core/skbuff.c:1122) ? netlink_attachskb (./include/linux/skbuff.h:1323 ./include/linux/skbuff.h:1332 net/netlink/af_netlink.c:1232) ? __netlink_lookup (./include/linux/rcupdate.h:882 ./include/linux/rhashtable.h:711 net/netlink/af_netlink.c:499) ? tc_chain_notify (net/sched/cls_api.c:3045) ? tc_chain_notify (./include/linux/skbuff.h:1384 net/sched/cls_api.c:3041) ? netlink_unicast (net/netlink/af_netlink.c:1335) ? rtnl_unicast (./include/net/netlink.h:1198 net/core/rtnetlink.c:985) ? tc_ctl_chain (net/sched/cls_api.c:3242) ? rtnetlink_rcv_msg (net/core/rtnetlink.c:7146) ? netlink_unicast (net/netlink/af_netlink.c:1354) ? __pfx_rtnetlink_rcv_msg (net/core/rtnetlink.c:7177) ? netlink_rcv_skb (net/netlink/af_netlink.c:2556) ? netlink_unicast (net/netlink/af_netlink.c:1319) ? netlink_sendmsg (net/netlink/af_netlink.c:1900) ? __sock_sendmsg (net/socket.c:800) ? __sys_sendto (net/socket.c:2281) ? __x64_sys_sendto (net/socket.c:2288 net/socket.c:2284 net/socket.c:2284) ? do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:84) ? entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/cls_api.c +1 -1
@@ -3224,7 +3224,7 @@ static int tc_ctl_chain(struct sk_buff *skb, struct nlmsghdr *n,tcf_chain_put (chain); errout_block:tcf_block_release (q, block, true); -if (err == -EAGAIN ) +if (err == -EAGAIN && n->nlmsg_type ==RTM_NEWCHAIN )/* Replay the request. */ goto replay;return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 588/1193 net: sun4i-emac: fix missing of_node_put() for phy_node
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Youhong <[email protected]>
[ Upstream commit af406abfecad2f48d8f1fc646d3994f0982bac62 ]
of_parse_phandle() returns a node pointer with an elevated refcount. Add the missing of_node_put() on the probe error path after register_netdev() fails and in emac_remove().
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/allwinner/sun4i-emac.c +2 -0
@@ -1067,6 +1067,7 @@ static int emac_probe(struct platform_device *pdev)return 0 ; out_release_sram: +of_node_put (db->phy_node);sunxi_sram_release (&pdev->dev); out_clk_disable_unprepare:clk_disable_unprepare (db->clk);
@@ -1094,6 +1095,7 @@ static int emac_remove(struct platform_device *pdev) }unregister_netdev (ndev); +of_node_put (db->phy_node);sunxi_sram_release (&pdev->dev);clk_disable_unprepare (db->clk);irq_dispose_mapping (ndev->irq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 589/1193 net: hinic: fix mailbox segment buffer overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
[ Upstream commit 5d4d985957434867bbe85e4fa5e638f3e48ad522 ]
check_mbox_seq_id_and_seg_len() validates that seq_id does not exceed SEQ_ID_MAX_VAL (42) and seg_len does not exceed MBOX_SEG_LEN (48). However, this allows the last segment (seq_id=42) to carry a full 48-byte payload, writing to offset 42*48=2016 for 48 bytes (ending at byte 2064). The receive buffer is only MBOX_MAX_BUF_SZ (2048) bytes, resulting in a 16-byte heap buffer overflow.
The hinic3 driver already handles this correctly by defining MBOX_LAST_SEG_MAX_LEN and rejecting the last segment when it exceeds the remaining buffer space. Apply the same fix to the hinic driver.
--- drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c +3 -1
@@ -128,6 +128,7 @@ enum hinic_mbox_tx_status {#define SEQ_ID_START_VAL 0#define SEQ_ID_MAX_VAL 42 +#define MBOX_LAST_SEG_MAX_LEN (MBOX_MAX_BUF_SZ - SEQ_ID_MAX_VAL * MBOX_SEG_LEN)#define NO_DMA_ATTRIBUTE_VAL 0
@@ -372,7 +373,8 @@ recv_pf_from_vf_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,static bool check_mbox_seq_id_and_seg_len (struct hinic_recv_mbox *recv_mbox,u8 seq_id,u8 seg_len) { -if (seq_id >SEQ_ID_MAX_VAL || seg_len >MBOX_SEG_LEN ) +if (seq_id >SEQ_ID_MAX_VAL || seg_len >MBOX_SEG_LEN || + (seq_id ==SEQ_ID_MAX_VAL && seg_len >MBOX_LAST_SEG_MAX_LEN ))return false;if (seq_id ==0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 590/1193 octeontx2-af: fix PF/CGX debugfs PCI bus lookup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ratheesh Kannoth <[email protected]>
[ Upstream commit 4f4b743c2d2bbc336cb164d9d3d2ed6956ad8437 ]
rvu_dbg_rvu_pf_cgx_map_display() locates each RVU PF PCI device via pci_get_domain_bus_and_slot() when printing the PF-to-CGX map. It assumed PF0 always sits on PCI bus 1 and derived other PF bus numbers as pf + 1, but the AF device can be enumerated on a different bus.
Use rvu->pdev->bus->number as the base bus instead, so each PF lookup uses pf + start on systems where RVU functions are on contiguous buses but do not start at bus 1.
--- .../net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +8 -2
@@ -852,19 +852,25 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused)int pf, domain, blkid;u8 cgx_id, lmac_id;u16 pcifunc; +u8 start; - domain =2 ; + domain =pci_domain_nr (rvu->pdev->bus); mac_ops =get_mac_ops (rvu_first_cgx_pdata (rvu));/* There can be no CGX devices at all */ if (!mac_ops)return 0 ;seq_printf (filp,"PCI dev\t\tRVU PF Func\tNIX block\t%s\tLMAC\n" , mac_ops->name); + +/* All the PF devices are on contiguous PCI bus numbers, but the PF0(AF) +* may not start from 1 always. Hence get domain and bus from PCI device. +*/ + start = rvu->pdev->bus->number;for (pf =0 ; pf < rvu->hw->total_pfs; pf++) {if (!is_pf_cgxmapped (rvu, pf))continue ; - pdev =pci_get_domain_bus_and_slot (domain, pf +1 ,0 ); + pdev =pci_get_domain_bus_and_slot (domain, pf + start,0 );if (!pdev)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 591/1193 net/rds: fix tcp stream corruption with large pages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Marsden <[email protected]>
[ Upstream commit 2ac09b5353fe6858411fdc8c6efa60d832e20f13 ]
rds_message_map_pages() assigns PAGE_SIZE bytes to every scatterlist entry, even when total_len ends in a partial page. The RDS congestion map is defined as 8192 bytes, so on systems with PAGE_SIZE greater than 8192 the scatterlist maps bytes beyond the end of the congestion map. RDS-TCP transmits the SG contents according to those lengths, so the extra bytes become part of the TCP RDS stream and are interpreted as subsequent RDS message headers, corrupting the stream.
Limit the final scatterlist mapping to the number of bytes remaining. This has no effect on systems with a 4K page size and allows RDS-TCP to be used on systems with 16K and larger page sizes.
The RDS selftest, which previously hung on 16K pages, now passes.
--- net/rds/message.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/rds/message.c +3 -1
@@ -365,7 +365,9 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned infor (i =0 ; i < rm->data.op_nents; ++i) {sg_set_page (&rm->data.op_sg[i],virt_to_page ((void *)page_addrs[i]), -PAGE_SIZE ,0 ); + i == rm->data.op_nents -1 + ? total_len - (i *PAGE_SIZE ) + :PAGE_SIZE ,0 ); }return rm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 592/1193 openvswitch: fix wrong flag value in get_ipv6_ext_hdrs()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eelco Chaudron <[email protected]>
[ Upstream commit e184a4a6f423550a25adce867036cdb1ff471745 ]
The ESP and AH cases in get_ipv6_ext_hdrs() used IPPROTO_FRAGMENT instead of OFPIEH12_FRAG when checking for out-of-order extension headers, causing the fragment header to not be recognised as a valid predecessor.
The original code used IPPROTO_FRAGMENT (44) as a bitmask constant where OFPIEH12_FRAG (1 << 4 = 16) was intended. IPPROTO_FRAGMENT encodes bits 2, 3 and 5 (OFPIEH12_AUTH | OFPIEH12_DEST | OFPIEH12_ROUTER), but not bit 4 (OFPIEH12_FRAG). This caused incorrect OFPIEH12_UNSEQ verdicts in both the ESP and AH arms: the ESP arm failed to whitelist OFPIEH12_FRAG, while the AH arm accidentally whitelisted OFPIEH12_AUTH.
With the fix, a packet with two AH headers now also gets OFPIEH12_UNSEQ in addition to OFPIEH12_UNREP, matching the ESP arm which already sets UNSEQ on a repeat, which is the intended behavior.
--- net/openvswitch/flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/openvswitch/flow.c +2 -2
@@ -292,7 +292,7 @@ static void get_ipv6_ext_hdrs(struct sk_buff *skb, struct ipv6hdr *nh,if (*ext_hdrs &OFPIEH12_ESP ) *ext_hdrs |=OFPIEH12_UNREP ;if ((*ext_hdrs & ~(OFPIEH12_HOP |OFPIEH12_DEST | -OFPIEH12_ROUTER |IPPROTO_FRAGMENT | +OFPIEH12_ROUTER |OFPIEH12_FRAG |OFPIEH12_AUTH |OFPIEH12_UNREP )) || dest_options_header_count >=2 ) { *ext_hdrs |=OFPIEH12_UNSEQ ;
@@ -305,7 +305,7 @@ static void get_ipv6_ext_hdrs(struct sk_buff *skb, struct ipv6hdr *nh, *ext_hdrs |=OFPIEH12_UNREP ;if ((*ext_hdrs & ~(OFPIEH12_HOP |OFPIEH12_DEST |OFPIEH12_ROUTER | -IPPROTO_FRAGMENT |OFPIEH12_UNREP )) || +OFPIEH12_FRAG |OFPIEH12_UNREP )) || dest_options_header_count >=2 ) { *ext_hdrs |=OFPIEH12_UNSEQ ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/1193 hwmon: (gpio-fan) take fan_data->lock in gpio_fan_shutdown()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit bb2424c3502cc72292eedade46960c331d5f28fb ]
set_fan_speed() writes the control GPIOs one bit at a time. Every other caller locks around it; gpio_fan_shutdown() doesn't. If it races a locked caller, the GPIO writes can interleave and leave the fan at a speed neither caller asked for.
--- drivers/hwmon/gpio-fan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/gpio-fan.c +4 -1
@@ -561,8 +561,11 @@ static void gpio_fan_shutdown(struct platform_device *pdev) {struct gpio_fan_data *fan_data =platform_get_drvdata (pdev); -if (fan_data->gpios) +if (fan_data->gpios) { +mutex_lock (&fan_data->lock);set_fan_speed (fan_data,0 ); +mutex_unlock (&fan_data->lock); + } }static int gpio_fan_suspend (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 593/1193 sunvdc: unmap LDC cookies when the descriptor send fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stian Halseth <[email protected]>
[ Upstream commit 0c6da21fa35e03fc74f09895433ccd6d4a9c3530 ]
__send_request() maps the request's pages into the LDC channel's map table (ldc_map_sg()), fills in the descriptor and marks it VIO_DESC_READY before ringing the doorbell via __vdc_tx_trigger(). When the trigger fails, the error path only prints a message: the descriptor stays READY and the cookies are never unmapped. The mapping is normally released in vdc_end_one() when the peer completes the descriptor - but a descriptor whose doorbell was never sent will never complete, and since dr->prod is not advanced on failure, the reset path (vdc_requeue_inflight(), which walks [cons, prod)) never visits it either. The map table entries are leaked permanently.
Since commit a11f6ca9aef9 ("sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN") trigger failures occur in practice under load, so every resulting I/O error also leaks one request's worth of entries from the fixed-size (8192 entries per channel) map table. Because the allocator hands out contiguous ranges, fragmentation makes large multi-segment requests fail first as the table drains, until ldc_map_sg() fails permanently and the disk is dead until reboot.
It also makes any retry-based recovery unusable: requeuing the request on -EAGAIN remaps the pages on every attempt, overwriting desc->cookies and orphaning the previous mapping, so the table drains at the retry rate. This is the memory exhaustion observed when the requeue approach was first tested in October 2025.
Roll back on failure: unmap the cookies, mark the descriptor FREE again and clear the request entry. If the trigger failed with -ENOTCONN, __vdc_tx_trigger() has already reset the port, which tears down and reallocates both the dring and the LDC channel including its map table - nothing to roll back, and the stale descriptor must not be touched.
--- drivers/block/sunvdc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/block/sunvdc.c +17 -0
@@ -526,6 +526,23 @@ static int __send_request(struct request *req) err =__vdc_tx_trigger (port);if (err <0 ) { printk(KERN_ERR PFX "vdc_tx_trigger() failure, err=%d\n", err); +/* +* If the port was reset (-ENOTCONN), the dring and the +* LDC channel including all of its mappings are already +* torn down and reallocated - there is nothing to undo +* and @desc must not be touched. +* +* For any other failure the descriptor was never handed +* to the peer: unmap the cookies and free the descriptor +* again, so that a later retry of the request does not +* leak LDC map table entries. +*/ +if (err != -ENOTCONN ) { +ldc_unmap (port->vio.lp, desc->cookies, + desc->ncookies); + desc->hdr.state =VIO_DESC_FREE ; + rqe->req =NULL ; + } }else { port->req_id++; dr->prod =vio_dring_next (dr, dr->prod);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 594/1193 scsi: target: iscsi: Fix hang for aborted WRITE_PENDING commands
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit d5869dae5080e976d4b03cc33eb7ceb527f242bf ]
When a LUN_RESET aborts a WRITE command that is in the TRANSPORT_WRITE_PENDING state, the target core sets CMD_T_ABORTED and waits for the frontend to finish processing.
If the initiator subsequently sends the remaining dataout PDUs, __iscsit_check_dataout_hdr() catches the payload, stops the dataout timer if the sequence is final and finally dumps the data. However, the iSCSI target doesn't trigger the completion process for these aborted commands. Because of this, the abort path hangs indefinitely in target_put_cmd_and_wait(), leading to a deadlocked target worker thread.
Fix this by explicitly calling target_complete_cmd() when the final dataout PDU is received for an aborted WRITE command. target_complete_cmd() detects the CMD_T_ABORTED flag and cleanly routes the command into target_abort_work, allowing the abort completion to successfully unblock.
--- drivers/target/iscsi/iscsi_target.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +3 -1
@@ -1567,8 +1567,10 @@ __iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf,*/ if (se_cmd->transport_state &CMD_T_ABORTED ) {if (hdr->flags &ISCSI_FLAG_CMD_FINAL && - --cmd->outstanding_r2ts <1 ) + --cmd->outstanding_r2ts <1 ) {iscsit_stop_dataout_timer (cmd); +target_complete_cmd (se_cmd,SAM_STAT_TASK_ABORTED ); + }return iscsit_dump_data_payload (conn, payload_length,1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 595/1193 ksmbd: prevent out-of-bounds reads in share config responses
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit f25e93768fcc5d8287e50b1ec52a42e4c276df34 ]
Validate IPC share configuration payload sizes before consuming variable-length fields. Bound veto list parsing and account for the separator byte when deriving the path length.
--- fs/smb/server/mgmt/share_config.c | 38 +++++++++++++++++++++++-------- fs/smb/server/transport_ipc.c | 21 +++++++++++------ 2 files changed, 42 insertions(+), 17 deletions(-)
fs/smb/server/mgmt/share_config.c +28 -10
@@ -88,9 +88,9 @@ static struct ksmbd_share_config *__share_lookup(const char *name)static int parse_veto_list (struct ksmbd_share_config *share,char *veto_list, -int veto_list_sz) +size_t veto_list_sz) { -int sz =0 ; +size_t sz;if (!veto_list_sz)return 0 ;
@@ -98,7 +98,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,while (veto_list_sz >0 ) {struct ksmbd_veto_pattern *p; - sz =strlen (veto_list); + sz =strnlen (veto_list, veto_list_sz);if (!sz)break ;
@@ -106,7 +106,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,if (!p)return -ENOMEM ; - p->pattern =kstrdup (veto_list,GFP_KERNEL ); + p->pattern =kstrndup (veto_list, sz,GFP_KERNEL );if (!p->pattern) {kfree (p);return -ENOMEM ;
@@ -114,6 +114,9 @@ static int parse_veto_list(struct ksmbd_share_config *share,list_add (&p->list, &share->veto_list); +if (sz == veto_list_sz) +break ; + veto_list += sz +1 ; veto_list_sz -= (sz +1 ); }
@@ -160,13 +163,27 @@ static struct ksmbd_share_config *share_config_request(struct ksmbd_work *work, share->name =kstrdup (name,GFP_KERNEL );if (!test_share_config_flag (share,KSMBD_SHARE_FLAG_PIPE )) { -int path_len =PATH_MAX ; +size_t path_len; -if (resp->payload_sz) +if (resp->payload_sz <= resp->veto_list_sz) { + ret = -EINVAL ; + }else { path_len = resp->payload_sz - resp->veto_list_sz; - - share->path =kstrndup (ksmbd_share_config_path (resp), path_len, -GFP_KERNEL ); +if (resp->veto_list_sz) + path_len--; + +if (!path_len) { + ret = -EINVAL ; + }else { + share->path =kstrndup ( +ksmbd_share_config_path (resp), + path_len,GFP_KERNEL ); +if (!share->path) + ret = -ENOMEM ; +else + ret =0 ; + } + }if (share->path) { share->path_sz =strlen (share->path); while (share->path_sz > 1 &&
@@ -179,7 +196,8 @@ static struct ksmbd_share_config *share_config_request(struct ksmbd_work *work, share->force_directory_mode = resp->force_directory_mode; share->force_uid = resp->force_uid; share->force_gid = resp->force_gid; - ret =parse_veto_list (share, +if (!ret) + ret =parse_veto_list (share,KSMBD_SHARE_CONFIG_VETO_LIST (resp), resp->veto_list_sz);if (!ret && share->path) {
fs/smb/server/transport_ipc.c +14 -7
@@ -524,14 +524,21 @@ static int ipc_validate_msg(struct ipc_msg_table_entry *entry)if (entry->msg_sz <sizeof (struct ksmbd_share_config_response ))return -EINVAL ; -if (resp->payload_sz) { -if (resp->payload_sz < resp->veto_list_sz) -return -EINVAL ; +if (strnlen (resp->share_name,sizeof (resp->share_name)) == +sizeof (resp->share_name)) +return -EINVAL ; -if (check_add_overflow (sizeof (struct ksmbd_share_config_response ), - resp->payload_sz, &msg_sz)) -return -EINVAL ; - } +if (resp->veto_list_sz > resp->payload_sz) +return -EINVAL ; + +if (resp->flags !=KSMBD_SHARE_FLAG_INVALID && + !(resp->flags &KSMBD_SHARE_FLAG_PIPE ) && + resp->payload_sz <= resp->veto_list_sz) +return -EINVAL ; + +if (check_add_overflow (sizeof (struct ksmbd_share_config_response ), + resp->payload_sz, &msg_sz)) +return -EINVAL ;break ; }case KSMBD_EVENT_LOGIN_REQUEST_EXT :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/1193 powerpc/ps3: Fix repository.c build failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 5ba79d37403d86082ab4083b0f51ec3008a942cb upstream.
GCC fails to build ps3_defconfig with the following errors:
arch/powerpc/platforms/ps3/repository.c: In function ‘make_first_field.constprop’:
arch/powerpc/platforms/ps3/repository.c:78:9: error: ‘strnlen’ specified bound 8 exceeds source size 3 [-Werror=stringop-overread]
78 | memcpy((char *)&n, text, strnlen(text, sizeof(n)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/platforms/ps3/repository.c: In function ‘make_first_field.constprop’:
arch/powerpc/platforms/ps3/repository.c:78:9: error: ‘strnlen’ specified bound 8 exceeds source size 4 [-Werror=stringop-overread]
78 | memcpy((char *)&n, text, strnlen(text, sizeof(n)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The current use of strnlen(text, sizeof(n)) triggers -Wstringop-overread when text is a short string literal that is smaller than sizeof(n), such as "bi" or "bus". Use strlen(text) instead and clamp the copy length to sizeof(n) before memcpy().
Drop the redundant char * cast while at it.
--- arch/powerpc/platforms/ps3/repository.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/platforms/ps3/repository.c +4 -1
@@ -6,6 +6,8 @@* Copyright 2006 Sony Corp. */ +#include <linux/minmax.h> +#include <asm/lv1call.h> #include "platform.h"
@@ -74,8 +76,9 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,static u64 make_first_field (const char *text,u64 index) {u64 n =0 ; +size_t len =min (strlen (text),sizeof (n)); -memcpy ((char *)&n, text,strnlen (text,sizeof (n))); +memcpy (&n, text, len);return PS3_VENDOR_ID_NONE + (n >>32 ) + index; }
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 597/1193 powerpc/eeh: Fix recursive locking on devices without EEH sensitive driver
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivaprasad G Bhat <[email protected]>
commit c5e68706527968282e49de205cc2b935823cb88a upstream.
The commit 1010b4c012b0 ("powerpc/eeh: Make EEH driver device hotplug safe") refactored the EEH code such that the pci_rescan_remove_lock is held at the beginning of eeh_handle_normal_event() and the eeh_reset_device() is called with that lock being held. Looks like the commit missed to remove the existing lock/unlock inside eeh_rmv_device() which is no longer necessary. This is causing the eehd to hang on the lock which it actually holds when that code path is taken.
[<0>] 0xc00000011c78f870
[<0>] __switch_to+0xfc/0x1a0 [<0>] pci_lock_rescan_remove+0x30/0x44 [<0>] eeh_rmv_device+0x290/0x2e0 [<0>] eeh_pe_dev_traverse+0x80/0x130 [<0>] eeh_reset_device+0xcc/0x23c [<0>] eeh_handle_normal_event+0x830/0xa80 [<0>] eeh_event_handler+0xf8/0x190 [<0>] kthread+0x194/0x1b0 [<0>] start_kernel_thread+0x14/0x18
The issue is seen for cases where the errors are detected on the PHB directly AND|OR for devices where the driver error_detected() returns PCI_ERS_RESULT_NEED_RESET, and driver being not EEH sensitive(i.e no error handlers like slot_reset(), resume() etc defined).
--- arch/powerpc/kernel/eeh_driver.c | 2 -- 1 file changed, 2 deletions(-)
arch/powerpc/kernel/eeh_driver.c +0 -2
@@ -533,9 +533,7 @@ static void eeh_rmv_device(struct eeh_deif (rmv_data)list_add (&edev->rmv_entry, &rmv_data->removed_vf_list); }else { -pci_lock_rescan_remove ();pci_stop_and_remove_bus_device (dev); -pci_unlock_rescan_remove (); } }
Greg Kroah-Hartman
maintainerPATCH 598/1193 crypto: x86/aria - add missing vzeroupper in AVX2 code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit ac53977611428db3bc0b4ac0225e19c3e08ae50b upstream.
Since the AVX2 optimized ARIA code uses YMM registers, execute vzeroupper before returning from it. This is needed to avoid degrading the performance of any later SSE code that may happen to be executed.
--- arch/x86/crypto/aria-aesni-avx2-asm_64.S | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/crypto/aria-aesni-avx2-asm_64.S +6 -0
@@ -988,6 +988,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_enc %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15, %rax); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_aesni_avx2_encrypt_32way)
@@ -1013,6 +1014,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_dec %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15, %rax); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_aesni_avx2_decrypt_32way)
@@ -1215,6 +1217,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_ctr %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15, %r10); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_aesni_avx2_ctr_crypt_32way)
@@ -1366,6 +1369,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfn %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15, %rax); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_aesni_avx2_gfni_encrypt_32way)
@@ -1391,6 +1395,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfn %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15, %rax); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_aesni_avx2_gfni_decrypt_32way)
@@ -1435,6 +1440,7 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfn %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15, %r10); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_aesni_avx2_gfni_ctr_crypt_32way)
Greg Kroah-Hartman
maintainerPATCH 599/1193 crypto: x86/aria - add missing vzeroupper in AVX-512 code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 60892a384aa1e65d0e703e1c513417bdf0c80777 upstream.
Since the AVX-512 optimized ARIA code uses ZMM registers, execute vzeroupper before returning from it. This is needed to avoid degrading the performance of any later SSE code that may happen to be executed.
--- arch/x86/crypto/aria-gfni-avx512-asm_64.S | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/crypto/aria-gfni-avx512-asm_64.S +3 -0
@@ -800,6 +800,7 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_en %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14, %zmm15, %rax); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_gfni_avx512_encrypt_64way)
@@ -825,6 +826,7 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_de %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14, %zmm15, %rax); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_gfni_avx512_decrypt_64way)
@@ -966,6 +968,7 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_ct %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14, %zmm15, %r10); + vzeroupper; FRAME_END RET; SYM_FUNC_END(aria_gfni_avx512_ctr_crypt_64way)
Greg Kroah-Hartman
maintainerPATCH 600/1193 x86/mm: Fix user-space data loss with MADV_FREE and THP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vernon Yang <[email protected]>
commit f7491d7c81db0e7c304a7bd757a76d2fbeaff80e upstream.
Some of users of Polars (a data analytics library) have lost production data from this bug. They seem to have just the right combination of huge pages, MADV_FREE and heavy reclaim pressure.
pmd_modify() masks the old value with (_HPAGE_CHG_MASK & ~_PAGE_DIRTY), silently discarding the hardware dirty bit. The subsequent pmd_mksaveddirty() call is supposed to transfer _PAGE_DIRTY into _PAGE_SAVED_DIRTY when write-protecting, but the dirty bit was already stripped from the value, so there is nothing left to transfer.
Contrast with pte_modify(), which keeps _PAGE_DIRTY_BITS in its mask, and pud_modify(), which keeps _HPAGE_CHG_MASK untouched: pmd_modify() is the odd one out. Any pmd_modify() on a writable, dirty PMD loses the dirty state.
One visible consequence is data loss with MADV_FREE on PMD-mapped THP:
memset(buf, 0x5A, size); // PMD-mapped THP, PMD dirty
madvise(buf, size, MADV_FREE); // PMD cleaned but left writable,
// folio marked lazyfree
memset(buf, 0x5A, size); // hardware sets _PAGE_DIRTY again
mprotect(buf, size, PROT_READ); // pmd_modify() drops the dirty bit
mprotect(buf, size, PROT_READ|PROT_WRITE);
// ... memory pressure ...Reclaim (e.g. under memcg pressure) then finds the lazyfree folio with no dirty bit set anywhere and frees it in __discard_anon_folio_pmd_locked(), even though the data was rewritten after MADV_FREE; subsequent reads fault in fresh zero pages. NUMA hinting alone can trigger the same loss, as do_huge_pmd_numa_page() restores the PMD through pmd_modify() as well.
PMD-mapped file THPs are affected too: mprotect()/NUMA hinting dropping the dirty bit means rewritten data is never written back.
Fix it by keeping _PAGE_DIRTY in the preserved mask, exactly like pte_modify() and pud_modify() do. The existing pmd_mksaveddirty()/pmd_clear_saveddirty() pair then performs the hardware-dirty <-> saved-dirty transition based on the write bit, preserving the shadow-stack encoding rules.
--- arch/x86/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/pgtable.h +1 -1
@@ -814,7 +814,7 @@ static inline pmd_t pmd_modify(pmd_t pmdpmdval_t val =pmd_val (pmd), oldval = val;pmd_t pmd_result; - val &= (_HPAGE_CHG_MASK & ~_PAGE_DIRTY); + val &= _HPAGE_CHG_MASK; val |=check_pgprot (newprot) & ~_HPAGE_CHG_MASK; val =flip_protnone_guard (oldval, val,PHYSICAL_PMD_PAGE_MASK );
Greg Kroah-Hartman
maintainerPATCH 601/1193 ipv6: fix fib6 walker UAF on seq stop
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
commit 19b4ed644d68098cc62ab612727f40d30f43476c upstream.
ipv6_route_iter_active() treats a walker in FWS_U at the table root as already unlinked. fib6_del_route() can move a still-linked walker into that same state when the current leaf is the last route at the root, so ipv6_route_native_seq_stop() skips fib6_walker_unlink(). The seq private object can then be freed while it remains on net->ipv6.fib6_walkers. A later route deletion walks the dangling list and uses the freed walker.
Use the list head as membership state and reinitialize it when unlinking. Keep the existing w->node check so a never-started iterator with a zeroed private object is not treated as linked.
The same stop helper is used by /proc/net/ipv6_route and by the BPF ipv6_route iterator. The BPF show path only widens the race.
--- net/ipv6/ip6_fib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_fib.c +2 -2
@@ -85,7 +85,7 @@ static void fib6_walker_link(struct netstatic void fib6_walker_unlink (struct net *net,struct fib6_walker *w) {write_lock_bh (&net->ipv6.fib6_walker_lock); -list_del (&w->lh); +list_del_init (&w->lh);write_unlock_bh (&net->ipv6.fib6_walker_lock); }
@@ -2715,7 +2715,7 @@ static void *ipv6_route_seq_start(structstatic bool ipv6_route_iter_active (struct ipv6_route_iter *iter) {struct fib6_walker *w = &iter->w; -return w->node && !(w->state ==FWS_U && w->node == w->root); +return w->node && !list_empty (&w->lh); }static void ipv6_route_native_seq_stop (struct seq_file *seq,void *v)
Greg Kroah-Hartman
maintainerPATCH 602/1193 tracing: Fix memory corruption from the histogram stacktrace modifier
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit a5e70ba87ca8ebc79b4e63de302d03b0625fe153 upstream.
parse_field() sets HIST_FIELD_FL_STACKTRACE from the ".stacktrace" modifier before it looks the field name up, and nothing afterwards checks that the name resolved to a field which holds a stacktrace. create_hist_field() picks HIST_FIELD_FN_STACK on the strength of the field pointer alone, which reads a __data_loc word from the record and follows its low 16 bits as an offset into the same record. event_hist_trigger() takes the first word there as an entry count and copies that many longs into a 31 entry array:
n_entries = *stack; memcpy(entries, ++stack, n_entries * sizeof(unsigned long));
Neither end of that copy is bounded, and the count is whatever the event holds at the offset, so any field will do:
# cd /sys/kernel/tracing/events/sched/sched_process_fork # echo 'hist:keys=parent_pid.stacktrace' > trigger # (true)
BUG: kernel NULL pointer dereference, address: 0000000000000008 RIP: 0010:rb_insert_color+0x18/0x130 timerqueue_linked_add+0x7e/0xd0 enqueue_hrtimer+0x39/0xb0 __hrtimer_run_queues+0x10f/0x1f0 </IRQ> RIP: 0010:memcpy+0xc/0x30 event_hist_trigger+0x165/0x690
The timer interrupt landed on the rbtree the copy had already run over. No debug options are needed for this; KASAN reports the same write as an out-of-bounds read of 13835058055416381440 bytes.
Documentation/trace/histogram.rst already states the rule, "must be a long[] type", so enforce it once the name has been resolved. Names which resolve to no field at all, "hitcount.stacktrace" and the common_* pseudo-fields, are refused for the same reason: they hold no stacktrace to read.
--- kernel/trace/trace_events_hist.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/trace/trace_events_hist.c +10 -2
@@ -2307,6 +2307,7 @@ parse_field(struct hist_trigger_data *histruct ftrace_event_field *field =NULL ;char *field_name, *modifier, *str;struct trace_array *tr = file->tr; +bool stack_modifier = false; modifier = str =kstrdup (field_str,GFP_KERNEL );if (!modifier)
@@ -2329,9 +2330,10 @@ parse_field(struct hist_trigger_data *hi *flags |=HIST_FIELD_FL_EXECNAME ; else if (strcmp(modifier, "syscall") == 0) *flags |= HIST_FIELD_FL_SYSCALL; - else if (strcmp(modifier, "stacktrace") == 0) + else if (strcmp(modifier, "stacktrace") == 0) { *flags |= HIST_FIELD_FL_STACKTRACE; - else if (strcmp(modifier, "log2") == 0) + stack_modifier = true; + } else if (strcmp(modifier, "log2") == 0) *flags |= HIST_FIELD_FL_LOG2; else if (strcmp(modifier, "usecs") == 0) *flags |= HIST_FIELD_FL_TIMESTAMP_USECS;
@@ -2398,6 +2400,12 @@ parse_field(struct hist_trigger_data *hi } } } + +if (stack_modifier && + (!field || field->filter_type !=FILTER_STACKTRACE )) { +hist_err (tr,HIST_ERR_BAD_FIELD_MODIFIER ,errpos (field_str)); + field =ERR_PTR (-EINVAL ); + } out:kfree (str);
Greg Kroah-Hartman
maintainerPATCH 567/1193 hwmon: (aspeed-pwm-tacho) Propagate reset deassert errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 09a9e1746a87845d7d8e2b4e23bb613306effdff ]
aspeed_pwm_tacho_probe() installs its reset cleanup action and configures the
controller after an unchecked reset deassertion.
Stop probing when the reset controller rejects the transition, before the hwmon device becomes visible.
--- drivers/hwmon/aspeed-pwm-tacho.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/aspeed-pwm-tacho.c +3 -1
@@ -921,7 +921,9 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) "missing or invalid reset controller device tree entry");return PTR_ERR (priv->rst); } -reset_control_deassert (priv->rst); + ret =reset_control_deassert (priv->rst); +if (ret) +return ret; ret =devm_add_action_or_reset (dev, aspeed_pwm_tacho_remove, priv);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/1193 ALSA: ctxfi: Fix CA20K2 S/PDIF passthrough
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Prucha <[email protected]>
commit b26a7a80e6bbf8dd17dacb127d12435d79375cf2 upstream.
dao_rsc_init() encodes the DAIO configuration as
conf = (desc->msr & 0x7) | (desc->passthru << 3);
S/PDIF passthrough uses msr=1 and passthru=1, resulting in conf=9.
daio_mgr_dao_init() masks conf with 0xf, but handles only values 1, 2, 4 and 8 when programming ATXCTL_NUC. As a result, conf=9 falls through to the default case and leaves NUC at its previous setting.
On a Creative X-Fi Titanium HD SB1270 (CA20K2), this breaks AC3 IEC61937 passthrough when snd_ctxfi runs with reference_rate=48000,multiple=2. The receiver detects a non-audio stream but cannot decode the AC3 payload.
With the unmodified driver, multiple=1 makes the same stream work. Handle conf=9 through the same NUC=0 path as conf=1.
The change was runtime tested on the SB1270 with multiple=2 using IEC958 stereo PCM, pre-encoded AC3 IEC61937 passthrough and ALSA A52 live 5.1 encoding.
--- sound/pci/ctxfi/cthw20k2.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/ctxfi/cthw20k2.c +1 -0
@@ -993,6 +993,7 @@ static int daio_mgr_dao_init(void *blk,/* S/PDIF output */ switch ((conf &0xf )) {case 1 : +case 9 :set_field (&ctl->txctl[idx],ATXCTL_NUC ,0 );break ;case 2 :
Greg Kroah-Hartman
maintainerPATCH 604/1193 ALSA: usbusx2y: fix in04_last array size mismatch with in04_buf
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
commit 861111a14740e12c36d363e9830f8daa734279c9 upstream.
The in04_last array in struct usx2ydev is declared as char[24], but in04_buf is allocated as sizeof(struct us428_ctls) which is 21 bytes. In i_usx2y_in04_int(), when ctl_snapshot_last == -2 (initialization path):
memcpy(usx2y->in04_last, usx2y->in04_buf, sizeof(usx2y->in04_last));
This copies 24 bytes from a 21-byte slab allocation, reading 3 bytes past the end of the source object.
Introduce a USX2Y_IN04_SIZE constant defined as sizeof(struct us428_ctls) and use it consistently for the in04_last array, the in04_buf allocation, the URB transfer length, and the comparison loop, replacing the bare 24 and 21 literals throughout.
--- sound/usb/usx2y/usbusx2y.c | 6 +++--- sound/usb/usx2y/usbusx2y.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-)
sound/usb/usx2y/usbusx2y.c +3 -3
@@ -197,7 +197,7 @@ static void i_usx2y_in04_int(struct urbmemcpy (usx2y->in04_last, usx2y->in04_buf,sizeof (usx2y->in04_last)); us428ctls->ctl_snapshot_last =-1 ; }else { -for (i =0 ; i <21 ; i++) { +for (i =0 ; i <USX2Y_IN04_SIZE ; i++) {if (usx2y->in04_last[i] != ((char *)usx2y->in04_buf)[i]) {if (diff <0 ) diff = i;
@@ -306,7 +306,7 @@ int usx2y_in04_init(struct usx2ydev *usx goto error; } - usx2y->in04_buf =kmalloc (21 ,GFP_KERNEL ); + usx2y->in04_buf =kmalloc (USX2Y_IN04_SIZE ,GFP_KERNEL );if (!usx2y->in04_buf) { err = -ENOMEM ; goto error;
@@ -314,7 +314,7 @@ int usx2y_in04_init(struct usx2ydev *usxinit_waitqueue_head (&usx2y->in04_wait_queue);usb_fill_int_urb (usx2y->in04_urb, usx2y->dev,usb_rcvintpipe (usx2y->dev,0x4 ), - usx2y->in04_buf,21 , + usx2y->in04_buf,USX2Y_IN04_SIZE , i_usx2y_in04_int, usx2y,10 );if (usb_urb_ep_type_check (usx2y->in04_urb)) {
sound/usb/usx2y/usbusx2y.h +3 -1
@@ -5,6 +5,8 @@#include "../midi.h" #include "usbus428ctldefs.h" +#define USX2Y_IN04_SIZE sizeof(struct us428_ctls) +#define NRURBS 2/* Default value used for nr of packs per urb.
@@ -55,7 +57,7 @@ struct usx2ydev {int stride;struct urb *in04_urb;void *in04_buf; -char in04_last[24 ]; +char in04_last[USX2Y_IN04_SIZE ];unsigned int in04_int_calls;struct snd_usx2y_urb_seq *us04;wait_queue_head_t in04_wait_queue;
Greg Kroah-Hartman
maintainerPATCH 605/1193 dm/amdgpu: fix malformed link_settings debugfs output
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit 622b4e8505aa7453a53d17fa3a288871f270fc8b upstream.
[Why]dp_link_settings_read() passed strlen() of each format string as the size argument to snprintf() and then advanced rd_buf_ptr by that same fixed amount. The format-string length has no relation to the formatted output length, so snprintf() truncated each field at a NUL it wrote inside the buffer while the pointer was advanced past it. The result is a buffer peppered with embedded NUL bytes and fields that are silently cut short, so the data read back from the debugfs node does not reflect the actual link settings.
[How]
Use scnprintf() with the real remaining buffer size (rd_buf_size - (rd_buf_ptr - rd_buf)) and advance rd_buf_ptr by its return value, which is the number of characters actually written. This both bounds each write to the space left in rd_buf and keeps the output a single, properly terminated string. The now-unused str_len local is removed.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 20 +++++--------- 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +8 -12
@@ -190,7 +190,6 @@ static ssize_t dp_link_settings_read(strchar *rd_buf_ptr =NULL ;const uint32_t rd_buf_size =100 ;uint32_t result =0 ; -uint8_t str_len =0 ;int r;if (*pos &3 || size &3 )
@@ -202,29 +201,26 @@ static ssize_t dp_link_settings_read(str rd_buf_ptr = rd_buf; - str_len =strlen ("Current: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Current: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Current: %d 0x%x %d " , link->cur_link_settings.lane_count, link->cur_link_settings.link_rate, link->cur_link_settings.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Verified: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Verified: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Verified: %d 0x%x %d " , link->verified_link_cap.lane_count, link->verified_link_cap.link_rate, link->verified_link_cap.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Reported: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Reported: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Reported: %d 0x%x %d " , link->reported_link_cap.lane_count, link->reported_link_cap.link_rate, link->reported_link_cap.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Preferred: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Preferred: %d 0x%x %d\n" , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Preferred: %d 0x%x %d\n" , link->preferred_link_setting.lane_count, link->preferred_link_setting.link_rate, link->preferred_link_setting.link_spread);
Greg Kroah-Hartman
maintainerPATCH 606/1193 watchdog: sunxi_wdt: preserve boot-enabled watchdog
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
commit aab55360fa11a2c054798a484ac67ad606f563e4 upstream.
sunxi_wdt_probe() unconditionally stops the watchdog even when firmware left it running. This opens an unprotected interval during boot and prevents CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED from taking over the active watchdog.
Detect an enabled watchdog and decode its programmed interval. Preserve representable timeouts, and round the 0.5-second interval up to the minimum representable one-second timeout. Use the configured timeout for reserved interval encodings. Set the Linux reset mode and ping the watchdog without clearing its enable bit, then mark it hardware-running before registration so the watchdog core services it until userspace takes control. Leave disabled watchdogs untouched.
--- drivers/watchdog/sunxi_wdt.c | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
drivers/watchdog/sunxi_wdt.c +44 -1
@@ -128,6 +128,38 @@ static int sunxi_wdt_ping(struct watchdoreturn 0 ; } +static bool sunxi_wdt_is_running (struct watchdog_device *wdt_dev) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; + +return readl (sunxi_wdt->wdt_base + regs->wdt_mode) &WDT_MODE_EN ; +} + +static unsigned int sunxi_wdt_get_timeout (struct watchdog_device *wdt_dev) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; +unsigned int timeout; +u32 interval; + + interval =readl (sunxi_wdt->wdt_base + regs->wdt_mode); + interval >>= regs->wdt_timeout_shift; + interval &=WDT_TIMEOUT_MASK ; +/* Round the 0.5-second interval up to the minimum representable timeout. */ +if (!interval) +return WDT_MIN_TIMEOUT ; + +for (timeout =WDT_MIN_TIMEOUT ; + timeout <ARRAY_SIZE (wdt_timeout_map); timeout++) { +if (wdt_timeout_map[timeout] == interval) +return timeout; + } + +/* Reserved interval encoding. */ +return 0 ; +} +static int sunxi_wdt_set_timeout (struct watchdog_device *wdt_dev,unsigned int timeout) {
@@ -248,6 +280,7 @@ static int sunxi_wdt_probe(struct platfo {struct device *dev = &pdev->dev;struct sunxi_wdt_dev *sunxi_wdt; +unsigned int running_timeout;int err; sunxi_wdt =devm_kzalloc (dev,sizeof (*sunxi_wdt),GFP_KERNEL );
@@ -275,7 +308,17 @@ static int sunxi_wdt_probe(struct platfowatchdog_set_drvdata (&sunxi_wdt->wdt_dev, sunxi_wdt); -sunxi_wdt_stop (&sunxi_wdt->wdt_dev); +if (sunxi_wdt_is_running (&sunxi_wdt->wdt_dev)) { + running_timeout =sunxi_wdt_get_timeout (&sunxi_wdt->wdt_dev); +if (running_timeout) + sunxi_wdt->wdt_dev.timeout = running_timeout; + + err =sunxi_wdt_start (&sunxi_wdt->wdt_dev); +if (err) +return err; + +set_bit (WDOG_HW_RUNNING , &sunxi_wdt->wdt_dev.status); + }watchdog_stop_on_reboot (&sunxi_wdt->wdt_dev); err =devm_watchdog_register_device (dev, &sunxi_wdt->wdt_dev);
Greg Kroah-Hartman
maintainerPATCH 607/1193 ufs: create the root dentry after loading cylinder metadata
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
commit 55a4c98abb9694b067c6a031d11501f06b6b523c upstream.
ufs_fill_super() installed sb->s_root before it loaded the cylinder group structures for a writable mount:
sb->s_root = d_make_root(inode); ... if (!sb_rdonly(sb)) if (!ufs_read_cylinder_structures(sb)) goto failed;
When ufs_read_cylinder_structures() failed, the error path freed the in-core superblock information and set sb->s_fs_info to NULL while sb->s_root stayed installed. get_tree_bdev() then reached deactivate_locked_super(), and because s_root was present, generic_shutdown_super() called sync_filesystem() and the put_super operation. Both dereference UFS_SB(sb), which is now NULL, so a mount that fails only while reading the cylinder groups oopses during teardown. A crafted image whose first cylinder group cannot be read reaches this path.
Load the cylinder group metadata first and create the root dentry last, so the superblock is published to the VFS only once it is fully set up. ufs_setup_cstotal() and ufs_read_cylinder_structures() take only the super_block and do not use the root inode, so the reordering is safe.
--- fs/ufs/super.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/ufs/super.c +9 -8
@@ -1268,6 +1268,15 @@ magic_found: sb->s_maxbytes =ufs_max_bytes (sb); sb->s_max_links =UFS_LINK_MAX ; +ufs_setup_cstotal (sb); +/* +* Read cylinder group structures +*/ +if (!sb_rdonly (sb)) +if (!ufs_read_cylinder_structures (sb)) + goto failed; + +/* create the root dentry last, once UFS_SB(sb) is fully set up */ inode =ufs_iget (sb,UFS_ROOTINO );if (IS_ERR (inode)) { ret =PTR_ERR (inode);
@@ -1279,14 +1288,6 @@ magic_found: goto failed; } -ufs_setup_cstotal (sb); -/* -* Read cylinder group structures -*/ -if (!sb_rdonly (sb)) -if (!ufs_read_cylinder_structures (sb)) - goto failed; -UFSD ("EXIT\n" );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 608/1193 ufs: validate cylinder group metadata before caching it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
commit c9d263be26806d388129fab8c6904bed197fc6af upstream.
ufs_read_cylinder() copies the cylinder group index and the rotor positions straight from the on-disk group and caches them without any check:
ucpi->c_cgx = fs32_to_cpu(sb, ucg->cg_cgx); ucpi->c_rotor = fs32_to_cpu(sb, ucg->cg_rotor); ucpi->c_frotor = fs32_to_cpu(sb, ucg->cg_frotor); ucpi->c_irotor = fs32_to_cpu(sb, ucg->cg_irotor);
They are then used as indices during allocation and free:
- c_cgx indexes the cylinder summary array as UFS_SB(sb)->fs_cs(ucpi->c_cgx), so a value past s_ncg writes a 32 bit count outside the s_csp allocation.
- c_frotor becomes a bitmap scan start, start = c_frotor >> 3, and then length = ((s_fpg + 7) >> 3) - start. A start beyond the block bitmap wraps the unsigned length to a huge value, so ubh_scanc() walks far past the cylinder group buffers. c_irotor drives the inode bitmap the same way.
A crafted image can set any of these freely, turning an ordinary allocation into an out of bounds access.
Reject a cylinder group whose recorded index does not match the group being read, or whose rotors fall outside the group, before the metadata is cached. Valid filesystems keep cg_cgx equal to the group number and the rotors within the group, so only malformed images are rejected.
--- fs/ufs/cylinder.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ufs/cylinder.c +10 -0
@@ -66,6 +66,16 @@ static void ufs_read_cylinder (struct su ucpi->c_clustersumoff =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_clustersumoff); ucpi->c_clusteroff =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_clusteroff); ucpi->c_nclusterblks =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_nclusterblks); + +/* these on-disk values become array and bitmap indices */ +if (ucpi->c_cgx != cgno || + ucpi->c_rotor >= uspi->s_fpg || + ucpi->c_frotor >= uspi->s_fpg || + ucpi->c_irotor >= uspi->s_ipg) { +ufs_error (sb, __func__, +"inconsistent metadata in cylinder group %u\n" , cgno); + goto failed; + }UFSD ("EXIT\n" );return ;
Greg Kroah-Hartman
maintainerPATCH 609/1193 tunnels: Drop stale dst when building an ICMP error for PMTUD
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
commit b58d749633203d92c265317b45fccee555090352 upstream.
Bridged UDP tunnels such as VXLAN and GENEVE build an ICMP error packet around an overlay packet if the packet is going to exceed the underlay path MTU. The ICMP error packet is then injected back into the Rx path with the source and destination addresses swapped, so that it will be delivered to the overlay source.
If the overlay packet was routed to the UDP tunnel or locally generated, then it is already carrying a valid dst entry and this entry is not dropped when transforming the packet to an ICMP error packet. This causes the IP layer to reuse the dst entry, leading to the ICMP error packet being dropped or routed out of the UDP tunnel interface in case of forwarding.
Prior to the blamed commit this could not happen, as skb_tunnel_check_pmtu() did not build ICMP errors for PACKET_HOST packets. Such packets were instead encapsulated and, unless the DF bit was set in the outer header, fragmented by the underlay.
Fix this by making sure that the ICMP error packet does not have a valid dst entry, thereby forcing the IP layer to perform a route lookup.
Adjust the bridged PMTU exception selftests accordingly. When the local sender in ns_a pings the overlay destination with a deadline (-w), ping exits on the first socket error before any reply is received and returns a non-zero exit code. The test therefore only passed because the ICMP error was never delivered. Use a packet count (-c) like the ns_c line above it, so that the ICMP error counts against the packet budget and the exit code depends on whether echo replies were received. This passes with and without the fix.
--- net/ipv4/ip_tunnel_core.c | 6 ++++++ tools/testing/selftests/net/pmtu.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ip_tunnel_core.c +6 -0
@@ -250,6 +250,9 @@ static int iptunnel_pmtud_build_icmp(streth_header (skb, skb->dev,ntohs (eh.h_proto), eh.h_source, eh.h_dest,0 );skb_reset_mac_header (skb); +if (skb_valid_dst (skb)) +skb_dst_drop (skb); +return skb->len; }
@@ -353,6 +356,9 @@ static int iptunnel_pmtud_build_icmpv6(seth_header (skb, skb->dev,ntohs (eh.h_proto), eh.h_source, eh.h_dest,0 );skb_reset_mac_header (skb); +if (skb_valid_dst (skb)) +skb_dst_drop (skb); +return skb->len; }
tools/testing/selftests/net/pmtu.sh +1 -1
@@ -1363,7 +1363,7 @@ test_pmtu_ipvX_over_bridged_vxlanY_or_ge mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000)) run_cmd ${ns_c} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1 - run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst} || return 1 + run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1 # Check that exceptions were created pmtu="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
Greg Kroah-Hartman
maintainerPATCH 610/1193 tick/broadcast: Plug clockevents replacement race
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 113a9796effe3376d2ec5aabcca1fef4fef4cd62 upstream.
朱恺乾 reported and decoded the following race condition when a broadcast device is replaced:
CPUA CPUB
__tick_broadcast_oneshot_control()
bc = tick_broadcast_device.evtdev;
tick_install_broadcast_device(dev)
clockevents_exchange_device(cur, dev)
shutdown(cur);
detach(cur);
cur->handler = noop;
tick_broadcast_device.evtdev = dev; tick_broadcast_set_event(bc, next_event); <- FAIL: arms a detached device.
If the original broadcast device has a restricted interrupt affinity mask and the last CPU in that mask goes offline then the BUG() in tick_cleanup_dead_cpu() triggers because the clockevent device is not in detached state.
The reason for this is that tick_install_broadcast_device() is not serialized vs. tick broadcast operations.
The obvious cure is to serialize tick_install_broadcast_device() with tick_broadcast_lock against a concurrent tick broadcast operation.
That requires to split clockevents_exchange_device() into two parts, one which does the exchange, shutdown and detach operation and the other which drops the module reference count. This is required because the module reference cannot be dropped while holding tick_broadcast_lock.
Let clockevents_exchange_device() do both operations as before, but let the broadcast device code take the two step approach and do the device exchange under tick_broadcast_lock and drop the module reference count after releasing it.
--- kernel/time/clockevents.c | 33 ++++++++++++++++++++------------- kernel/time/tick-broadcast.c | 36 ++++++++++++++++++++++-------------- kernel/time/tick-internal.h | 2 ++ 3 files changed, 44 insertions(+), 27 deletions(-)
kernel/time/clockevents.c +20 -13
@@ -557,34 +557,41 @@ void clockevents_handle_noop(struct cloc { } -/** -* clockevents_exchange_device - release and request clock devices -* @old: device to release (can be NULL) -* @new: device to request (can be NULL) -* -* Called from various tick functions with clockevents_lock held and -* interrupts disabled. -*/ -void clockevents_exchange_device (struct clock_event_device *old, -struct clock_event_device *new) +void __clockevents_exchange_device (struct clock_event_device *old, +struct clock_event_device *new) {/* * Caller releases a clock event device. We queue it into the * released list and do a notify add later. */ if (old) { -module_put (old->owner);clockevents_switch_state (old,CLOCK_EVT_STATE_DETACHED );list_move (&old->list, &clockevents_released); }if (new) { -BUG_ON (!clockevent_state_detached (new)); +WARN_ON (!clockevent_state_detached (new));clockevents_shutdown (new); } }/** +* clockevents_exchange_device - release and request clock devices +* @old: device to release (can be NULL) +* @new: device to request (can be NULL) +* +* Called from various tick functions with clockevents_lock held and +* interrupts disabled. +*/ +void clockevents_exchange_device (struct clock_event_device *old, +struct clock_event_device *new) +{ +__clockevents_exchange_device (old, new); +if (old) +module_put (old->owner); +} + +/** * clockevents_suspend - suspend clock devices */ void clockevents_suspend (void )
@@ -650,7 +657,7 @@ void tick_cleanup_dead_cpu(int cpu)if (cpumask_test_cpu (cpu, dev->cpumask) &&cpumask_weight (dev->cpumask) ==1 && !tick_is_broadcast_device (dev)) { -BUG_ON (!clockevent_state_detached (dev)); +WARN_ON (!clockevent_state_detached (dev));list_del (&dev->list); } }
kernel/time/tick-broadcast.c +22 -14
@@ -162,23 +162,31 @@ static bool tick_set_oneshot_wakeup_devi*/ void tick_install_broadcast_device (struct clock_event_device *dev,int cpu) { -struct clock_event_device *cur = tick_broadcast_device.evtdev; +struct clock_event_device *cur; -if (tick_set_oneshot_wakeup_device (dev, cpu)) -return ; + scoped_guard(raw_spinlock_irqsave, &tick_broadcast_lock) { -if (!tick_check_broadcast_device (cur, dev)) -return ; +if (tick_set_oneshot_wakeup_device (dev, cpu)) +return ; -if (!try_module_get (dev->owner)) -return ; + cur = tick_broadcast_device.evtdev; +if (!tick_check_broadcast_device (cur, dev)) +return ; -clockevents_exchange_device (cur, dev); +if (!try_module_get (dev->owner)) +return ; + +__clockevents_exchange_device (cur, dev); +if (cur) + cur->event_handler = clockevents_handle_noop; +WRITE_ONCE (tick_broadcast_device.evtdev, dev); +if (!cpumask_empty (tick_broadcast_mask)) +tick_broadcast_start_periodic (dev); + } + +/* Module release must be outside of the lock */ if (cur) - cur->event_handler = clockevents_handle_noop; - tick_broadcast_device.evtdev = dev; -if (!cpumask_empty (tick_broadcast_mask)) -tick_broadcast_start_periodic (dev); +module_put (cur->owner);if (!(dev->features &CLOCK_EVT_FEAT_ONESHOT ))return ;
@@ -1209,7 +1217,7 @@ int tick_broadcast_oneshot_active(void)*/ bool tick_broadcast_oneshot_available (void ) { -struct clock_event_device *bc = tick_broadcast_device.evtdev; +struct clock_event_device *bc =READ_ONCE (tick_broadcast_device.evtdev);return bc ? bc->features &CLOCK_EVT_FEAT_ONESHOT : false; }
@@ -1217,7 +1225,7 @@ bool tick_broadcast_oneshot_available(vo#else int __tick_broadcast_oneshot_control (enum tick_broadcast_state state) { -struct clock_event_device *bc = tick_broadcast_device.evtdev; +struct clock_event_device *bc =READ_ONCE (tick_broadcast_device.evtdev);if (!bc || (bc->features &CLOCK_EVT_FEAT_HRTIMER ))return -EBUSY ;
kernel/time/tick-internal.h +2 -0
@@ -48,6 +48,8 @@ static inline void clockevent_set_state( }extern void clockevents_shutdown (struct clock_event_device *dev); +extern void __clockevents_exchange_device (struct clock_event_device *old, +struct clock_event_device *new);extern void clockevents_exchange_device (struct clock_event_device *old,struct clock_event_device *new); extern void clockevents_switch_state(struct clock_event_device *dev,
Greg Kroah-Hartman
maintainerPATCH 568/1193 octeontx2-pf: reset HTB scheduler topology before freeing queues
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ratheesh Kannoth <[email protected]>
[ Upstream commit ef39fca8508597fa565cf2be72a884a712fb98af ]
HTB offload programs NIX_AF_TLxX_TOPOLOGY on QoS-allocated scheduler queues via otx2_qos_txschq_set_parent_topology(), but teardown freed those queues without clearing TOPOLOGY. The AF only restores PARENT and SCHEDULE on free, so PRIO_ANCHOR/RR_PRIO settings can survive in the shared scheduler pool and affect later allocations.
Add otx2_qos_reset_schq_topology() and otx2_qos_free_hw_schq() to zero TL4 through TL2 TOPOLOGY before each schq is returned to the AF during hierarchy teardown and cfg rollback. Skip the aggregation level (TL1):
it is a per-tx-link queue shared by the PF, default Tx hierarchy and VFs, and is not freed back to the AF by nix_txschq_free_one().
--- .../net/ethernet/marvell/octeontx2/nic/qos.c | 60 +++++++++++++++++-- 1 file changed, 55 insertions(+), 5 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/qos.c +55 -5
@@ -235,13 +235,63 @@ static int otx2_qos_txschq_set_parent_topology(struct otx2_nic *pfvf,return rc; } +static int otx2_qos_reset_schq_topology (struct otx2_nic *pfvf,u16 lvl, +u16 schq) +{ +struct mbox *mbox = &pfvf->mbox; +struct nix_txschq_config *cfg; +int rc; + +if (lvl <NIX_TXSCH_LVL_TL4 || lvl >=NIX_TXSCH_LVL_TL1 ) +return 0 ; + +mutex_lock (&mbox->lock); + + cfg =otx2_mbox_alloc_msg_nix_txschq_cfg (mbox); +if (!cfg) { +mutex_unlock (&mbox->lock); +return -ENOMEM ; + } + + cfg->lvl = lvl; + cfg->num_regs =1 ; + +if (lvl ==NIX_TXSCH_LVL_TL4 ) + cfg->reg[0 ] =NIX_AF_TL4X_TOPOLOGY (schq); +else if (lvl ==NIX_TXSCH_LVL_TL3 ) + cfg->reg[0 ] =NIX_AF_TL3X_TOPOLOGY (schq); +else if (lvl ==NIX_TXSCH_LVL_TL2 ) + cfg->reg[0 ] =NIX_AF_TL2X_TOPOLOGY (schq); + + cfg->regval[0 ] =0 ; + + rc =otx2_sync_mbox_msg (mbox); + +mutex_unlock (&mbox->lock); + +return rc; +} + +static void otx2_qos_free_hw_schq (struct otx2_nic *pfvf,u16 lvl,u16 schq) +{ +int err; + + err =otx2_qos_reset_schq_topology (pfvf, lvl, schq); +if (err) +netdev_warn (pfvf->netdev, +"QoS: failed to reset topology for schq %u at level %u: %d\n" , + schq, lvl, err); + +otx2_txschq_free_one (pfvf, lvl, schq); +} +static void otx2_qos_free_hw_node_schq (struct otx2_nic *pfvf,struct otx2_qos_node *parent) {struct otx2_qos_node *node;list_for_each_entry_reverse (node, &parent->child_schq_list, list) -otx2_txschq_free_one (pfvf, node->level, node->schq); +otx2_qos_free_hw_schq (pfvf, node->level, node->schq); } static void otx2_qos_free_hw_node(struct otx2_nic *pfvf,
@@ -252,7 +302,7 @@ static void otx2_qos_free_hw_node(struct otx2_nic *pfvf,list_for_each_entry_safe (node, tmp, &parent->child_list, list) {otx2_qos_free_hw_node (pfvf, node);otx2_qos_free_hw_node_schq (pfvf, node); -otx2_txschq_free_one (pfvf, node->level, node->schq); +otx2_qos_free_hw_schq (pfvf, node->level, node->schq); } }
@@ -266,7 +316,7 @@ static void otx2_qos_free_hw_cfg(struct otx2_nic *pfvf,otx2_qos_free_hw_node_schq (pfvf, node);/* free node hw mappings */ -otx2_txschq_free_one (pfvf, node->level, node->schq); +otx2_qos_free_hw_schq (pfvf, node->level, node->schq);mutex_unlock (&pfvf->qos.qos_lock); }
@@ -899,7 +949,7 @@ static void otx2_qos_free_cfg(struct otx2_nic *pfvf, struct otx2_qos_cfg *cfg)for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) {for (idx =0 ; idx < cfg->schq[lvl]; idx++) { schq = cfg->schq_list[lvl][idx]; -otx2_txschq_free_one (pfvf, lvl, schq); +otx2_qos_free_hw_schq (pfvf, lvl, schq); } }
@@ -907,7 +957,7 @@ static void otx2_qos_free_cfg(struct otx2_nic *pfvf, struct otx2_qos_cfg *cfg)for (idx =0 ; idx < cfg->schq_contig[lvl]; idx++) {if (cfg->schq_index_used[lvl][idx]) { schq = cfg->schq_contig_list[lvl][idx]; -otx2_txschq_free_one (pfvf, lvl, schq); +otx2_qos_free_hw_schq (pfvf, lvl, schq); } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/1193 vxlan: use generic function for tunnel IPv4 route lookup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit 6f19b2c136d98a84d79030b53e23d405edfdc783 ]
The route lookup can be done now via generic function udp_tunnel_dst_lookup() to replace the custom implementations in vxlan_get_route().
Note that this patch only touches IPv4, while IPv6 still uses vxlan6_get_route(). After IPv6 route lookup gets converted as well, vxlan_xmit_one() can be simplified by removing local variables that will be passed via "struct ip_tunnel_key", such as remote_ip, local_ip, flow_flags, label.
Stable-dep-of: be83178bfc44 ("vxlan: initialize _md in vxlan_xmit_one()")
--- drivers/net/vxlan/vxlan_core.c | 114 ++++++++++++--------------------- 1 file changed, 41 insertions(+), 73 deletions(-)
drivers/net/vxlan/vxlan_core.c +41 -73
@@ -2266,57 +2266,6 @@ static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,return 0 ; } -static struct rtable *vxlan_get_route (struct vxlan_dev *vxlan,struct net_device *dev, -struct vxlan_sock *sock4, -struct sk_buff *skb,int oif,u8 tos, -__be32 daddr,__be32 *saddr,__be16 dport,__be16 sport, -__u8 flow_flags,struct dst_cache *dst_cache, -const struct ip_tunnel_info *info) -{ -bool use_cache =ip_tunnel_dst_cache_usable (skb, info); -struct rtable *rt =NULL ; -struct flowi4 fl4; - -if (!sock4) -return ERR_PTR (-EIO ); - -if (tos && !info) - use_cache = false; -if (use_cache) { - rt =dst_cache_get_ip4 (dst_cache, saddr); -if (rt) -return rt; - } - -memset (&fl4,0 ,sizeof (fl4)); - fl4.flowi4_oif = oif; - fl4.flowi4_tos =RT_TOS (tos); - fl4.flowi4_mark = skb->mark; - fl4.flowi4_proto =IPPROTO_UDP ; - fl4.daddr = daddr; - fl4.saddr = *saddr; - fl4.fl4_dport = dport; - fl4.fl4_sport = sport; - fl4.flowi4_flags = flow_flags; - - rt =ip_route_output_key (vxlan->net, &fl4); -if (!IS_ERR (rt)) { -if (rt->dst.dev == dev) { -netdev_dbg (dev,"circular route to %pI4\n" , &daddr); -ip_rt_put (rt); -return ERR_PTR (-ELOOP ); - } - - *saddr = fl4.saddr; -if (use_cache) -dst_cache_set_ip4 (dst_cache, &rt->dst, fl4.saddr); - }else { -netdev_dbg (dev,"no route to %pI4\n" , &daddr); -return ERR_PTR (-ENETUNREACH ); - } -return rt; -} -#if IS_ENABLED (CONFIG_IPV6 ) static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, struct net_device *dev,
@@ -2469,30 +2418,38 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, {struct dst_cache *dst_cache;struct ip_tunnel_info *info; +struct ip_tunnel_key *pkey; +struct ip_tunnel_key key;struct vxlan_dev *vxlan =netdev_priv (dev);const struct iphdr *old_iph =ip_hdr (skb);union vxlan_addr *dst; -union vxlan_addr remote_ip, local_ip; +union vxlan_addr remote_ip;struct vxlan_metadata _md;struct vxlan_metadata *md = &_md;unsigned int pkt_len = skb->len;__be16 src_port =0 , dst_port;struct dst_entry *ndst =NULL ; -__u8 tos, ttl, flow_flags =0 ; +__u8 tos, ttl;int ifindex;int err;u32 flags = vxlan->cfg.flags; +bool use_cache;bool udp_sum = false;bool xnet = !net_eq (vxlan->net,dev_net (vxlan->dev));__be32 vni =0 ;#if IS_ENABLED (CONFIG_IPV6 ) +union vxlan_addr local_ip;__be32 label;#endif info =skb_tunnel_info (skb); + use_cache =ip_tunnel_dst_cache_usable (skb, info);if (rdst) { dst = &rdst->remote_ip; +memset (&key,0 ,sizeof (key)); + pkey = &key; +if (vxlan_addr_any (dst)) {if (did_rsc) {/* short-circuited back to local bridge */
@@ -2506,7 +2463,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port; vni = (rdst->remote_vni) ? : default_vni; ifindex = rdst->remote_ifindex; - local_ip = vxlan->cfg.saddr; + +if (dst->sa.sa_family ==AF_INET ) { + key.u.ipv4.src = vxlan->cfg.saddr.sin.sin_addr.s_addr; + key.u.ipv4.dst = rdst->remote_ip.sin.sin_addr.s_addr; + }else { + key.u.ipv6.src = vxlan->cfg.saddr.sin6.sin6_addr; + key.u.ipv6.dst = rdst->remote_ip.sin6.sin6_addr; + } + dst_cache = &rdst->dst_cache; md->gbp = skb->mark;if (flags &VXLAN_F_TTL_INHERIT ) {
@@ -2520,12 +2485,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, tos = vxlan->cfg.tos;if (tos ==1 ) tos =ip_tunnel_get_dsfield (old_iph, skb); +if (tos && !info) + use_cache = false;if (dst->sa.sa_family ==AF_INET ) udp_sum = !(flags &VXLAN_F_UDP_ZERO_CSUM_TX );else udp_sum = !(flags &VXLAN_F_UDP_ZERO_CSUM6_TX );#if IS_ENABLED (CONFIG_IPV6 ) + local_ip = vxlan->cfg.saddr; label = vxlan->cfg.label;#endif }else {
@@ -2537,14 +2505,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, remote_ip.sa.sa_family =ip_tunnel_info_af (info);if (remote_ip.sa.sa_family ==AF_INET ) { remote_ip.sin.sin_addr.s_addr = info->key.u.ipv4.dst; - local_ip.sin.sin_addr.s_addr = info->key.u.ipv4.src; }else { remote_ip.sin6.sin6_addr = info->key.u.ipv6.dst; +#if IS_ENABLED (CONFIG_IPV6 ) local_ip.sin6.sin6_addr = info->key.u.ipv6.src; +#endif } dst = &remote_ip; + pkey = &info->key; dst_port = info->key.tp_dst ? : vxlan->cfg.dst_port; - flow_flags = info->key.flow_flags; vni =tunnel_id_to_key32 (info->key.tun_id); ifindex =0 ; dst_cache = &info->dst_cache;
@@ -2568,15 +2537,14 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,struct vxlan_sock *sock4 =rcu_dereference (vxlan->vn4_sock);struct rtable *rt;__be16 df =0 ; +__be32 saddr;if (!ifindex) ifindex = sock4->sock->sk->sk_bound_dev_if; - rt =vxlan_get_route (vxlan, dev, sock4, skb, ifindex, tos, - dst->sin.sin_addr.s_addr, - &local_ip.sin.sin_addr.s_addr, - dst_port, src_port, flow_flags, - dst_cache, info); + rt =udp_tunnel_dst_lookup (skb, dev, vxlan->net, ifindex, + &saddr, pkey, src_port, dst_port, + tos, use_cache ? dst_cache :NULL );if (IS_ERR (rt)) { err =PTR_ERR (rt); goto tx_error;
@@ -2612,16 +2580,13 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, }else if (err) {if (info) {struct ip_tunnel_info *unclone; -struct in_addr src, dst; unclone =skb_tunnel_info_unclone (skb);if (unlikely (!unclone)) goto tx_error; - src = remote_ip.sin.sin_addr; - dst = local_ip.sin.sin_addr; - unclone->key.u.ipv4.src = src.s_addr; - unclone->key.u.ipv4.dst = dst.s_addr; + unclone->key.u.ipv4.src = pkey->u.ipv4.dst; + unclone->key.u.ipv4.dst = saddr; }vxlan_encap_bypass (skb, vxlan, vxlan, vni, false);dst_release (ndst);
@@ -2635,8 +2600,8 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,if (err <0 ) goto tx_error; -udp_tunnel_xmit_skb (rt, sock4->sock->sk, skb, local_ip.sin.sin_addr.s_addr, - dst->sin.sin_addr.s_addr, tos, ttl, df, +udp_tunnel_xmit_skb (rt, sock4->sock->sk, skb, saddr, + pkey->u.ipv4.dst, tos, ttl, df, src_port, dst_port, xnet, !udp_sum);#if IS_ENABLED (CONFIG_IPV6 ) } else {
@@ -3146,11 +3111,14 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)struct vxlan_sock *sock4 =rcu_dereference (vxlan->vn4_sock);struct rtable *rt; - rt =vxlan_get_route (vxlan, dev, sock4, skb,0 , info->key.tos, - info->key.u.ipv4.dst, - &info->key.u.ipv4.src, dport, sport, - info->key.flow_flags, &info->dst_cache, - info); +if (!sock4) +return -EIO ; + + rt =udp_tunnel_dst_lookup (skb, dev, vxlan->net,0 , + &info->key.u.ipv4.src, + &info->key, + sport, dport, info->key.tos, + &info->dst_cache);if (IS_ERR (rt))return PTR_ERR (rt);ip_rt_put (rt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/1193 ipv6: remove "proto" argument from udp_tunnel6_dst_lookup()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit 7e937dcf96d0489b3cdd1cff9dfd049617d28492 ]
The function is now UDP-specific, the protocol is always IPPROTO_UDP.
This is similar to what already done for IPv4 in commit 78f3655adcb5 ("ipv4: remove "proto" argument from udp_tunnel_dst_lookup()").
Stable-dep-of: be83178bfc44 ("vxlan: initialize _md in vxlan_xmit_one()")
--- drivers/net/bareudp.c | 5 ++--- include/net/udp_tunnel.h | 2 +- net/ipv6/ip6_udp_tunnel.c | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-)
drivers/net/bareudp.c +2 -3
@@ -394,7 +394,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,return -ESHUTDOWN ; dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock, &saddr, info, -IPPROTO_UDP , use_cache); + use_cache);if (IS_ERR (dst))return PTR_ERR (dst);
@@ -524,8 +524,7 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,return -ESHUTDOWN ; dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock, - &saddr, info,IPPROTO_UDP , - use_cache); + &saddr, info, use_cache);if (IS_ERR (dst))return PTR_ERR (dst);
include/net/udp_tunnel.h +1 -1
@@ -174,7 +174,7 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb,struct socket *sock, struct in6_addr *saddr, const struct ip_tunnel_info *info, - u8 protocol, bool use_cache); + bool use_cache); struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family, __be16 flags, __be64 tunnel_id,
net/ipv6/ip6_udp_tunnel.c +1 -3
@@ -120,7 +120,6 @@ EXPORT_SYMBOL_GPL(udp_tunnel6_xmit_skb);* @sock: Socket which provides route info * @saddr: Memory to store the src ip address * @info: Tunnel information -* @protocol: IP protocol * @use_cache: Flag to enable cache usage * This function performs a route lookup on a UDP tunnel *
@@ -134,7 +133,6 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb,struct socket *sock, struct in6_addr *saddr, const struct ip_tunnel_info *info, - u8 protocol, bool use_cache) { struct dst_entry *dst = NULL;
@@ -154,7 +152,7 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb,#endif memset (&fl6,0 ,sizeof (fl6)); fl6.flowi6_mark = skb->mark; - fl6.flowi6_proto = protocol; + fl6.flowi6_proto =IPPROTO_UDP ; fl6.daddr = info->key.u.ipv6.dst; fl6.saddr = info->key.u.ipv6.src; prio = info->key.tos;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/1193 ipv6: add new arguments to udp_tunnel6_dst_lookup()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit 946fcfdbc5b97e26d31339ebca2d9a51a4f975ff ]
We want to make the function more generic so that it can be used by other UDP tunnel implementations such as geneve and vxlan. To do that, add the following arguments:
- source and destination UDP port;
- ifindex of the output interface, needed by vxlan;
- the tos, because in some cases it is not taken from struct ip_tunnel_info (for example, when it's inherited from the inner packet);
- the dst cache, because not all tunnel types (e.g. vxlan) want to use the one from struct ip_tunnel_info.
With these parameters, the function no longer needs the full struct ip_tunnel_info as argument and we can pass only the relevant part of it (struct ip_tunnel_key).
This is similar to what already done for IPv4 in commit 72fc68c6356b ("ipv4: add new arguments to udp_tunnel_dst_lookup()").
Stable-dep-of: be83178bfc44 ("vxlan: initialize _md in vxlan_xmit_one()")
--- drivers/net/bareudp.c | 10 +++++++--- include/net/udp_tunnel.h | 7 ++++--- net/ipv6/ip6_udp_tunnel.c | 33 ++++++++++++++++++--------------- 3 files changed, 29 insertions(+), 21 deletions(-)
drivers/net/bareudp.c +7 -3
@@ -393,8 +393,10 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,if (!sock)return -ESHUTDOWN ; - dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock, &saddr, info, - use_cache); + dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock,0 , &saddr, + key,0 ,0 , key->tos, + use_cache ? + (struct dst_cache *) &info->dst_cache :NULL );if (IS_ERR (dst))return PTR_ERR (dst);
@@ -524,7 +526,9 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,return -ESHUTDOWN ; dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock, - &saddr, info, use_cache); +0 , &saddr, &info->key, +0 ,0 , info->key.tos, + use_cache ? &info->dst_cache :NULL );if (IS_ERR (dst))return PTR_ERR (dst);
include/net/udp_tunnel.h +4 -3
@@ -171,10 +171,11 @@ struct rtable *udp_tunnel_dst_lookup(struct sk_buff *skb,struct dst_entry *udp_tunnel6_dst_lookup (struct sk_buff *skb,struct net_device *dev,struct net *net, -struct socket *sock, +struct socket *sock,int oif,struct in6_addr *saddr, -const struct ip_tunnel_info *info, -bool use_cache); +const struct ip_tunnel_key *key, +__be16 sport,__be16 dport,u8 dsfield, +struct dst_cache *dst_cache); struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family, __be16 flags, __be64 tunnel_id,
net/ipv6/ip6_udp_tunnel.c +18 -15
@@ -118,9 +118,13 @@ EXPORT_SYMBOL_GPL(udp_tunnel6_xmit_skb);* @dev: Tunnel device * @net: Network namespace of tunnel device * @sock: Socket which provides route info +* @oif: Index of the output interface * @saddr: Memory to store the src ip address -* @info: Tunnel information -* @use_cache: Flag to enable cache usage +* @key: Tunnel information +* @sport: UDP source port +* @dport: UDP destination port +* @dsfield: The traffic class field +* @dst_cache: The dst cache to use for lookup * This function performs a route lookup on a UDP tunnel * * It returns a valid dst pointer and stores src address to be used in
@@ -131,20 +135,17 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb,struct net_device *dev, struct net *net, struct socket *sock, + int oif, struct in6_addr *saddr, - const struct ip_tunnel_info *info, - bool use_cache) + const struct ip_tunnel_key *key, + __be16 sport, __be16 dport, u8 dsfield, + struct dst_cache *dst_cache) { struct dst_entry *dst = NULL; -#ifdef CONFIG_DST_CACHE -struct dst_cache *dst_cache; -#endif struct flowi6 fl6; -__u8 prio; #ifdef CONFIG_DST_CACHE - dst_cache = (struct dst_cache *)&info->dst_cache; - if (use_cache) { + if (dst_cache) { dst = dst_cache_get_ip6(dst_cache, saddr); if (dst) return dst;
@@ -153,10 +154,12 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb,memset (&fl6,0 ,sizeof (fl6)); fl6.flowi6_mark = skb->mark; fl6.flowi6_proto =IPPROTO_UDP ; - fl6.daddr = info->key.u.ipv6.dst; - fl6.saddr = info->key.u.ipv6.src; - prio = info->key.tos; - fl6.flowlabel =ip6_make_flowinfo (prio, info->key.label); + fl6.flowi6_oif = oif; + fl6.daddr = key->u.ipv6.dst; + fl6.saddr = key->u.ipv6.src; + fl6.fl6_sport = sport; + fl6.fl6_dport = dport; + fl6.flowlabel =ip6_make_flowinfo (dsfield, key->label); dst = ipv6_stub->ipv6_dst_lookup_flow (net, sock->sk, &fl6,NULL );
@@ -170,7 +173,7 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb,return ERR_PTR (-ELOOP ); }#ifdef CONFIG_DST_CACHE -if (use_cache) +if (dst_cache)dst_cache_set_ip6 (dst_cache, dst, &fl6.saddr);#endif *saddr = fl6.saddr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/1193 vxlan: use generic function for tunnel IPv6 route lookup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit 2aceb896ee18ae35b21b14c978d8c2ef8c7b439d ]
The route lookup can be done now via generic function udp_tunnel6_dst_lookup() to replace the custom implementation in vxlan6_get_route().
This is similar to what already done for IPv4 in commit 6f19b2c136d9 ("vxlan: use generic function for tunnel IPv4 route lookup").
Stable-dep-of: be83178bfc44 ("vxlan: initialize _md in vxlan_xmit_one()")
--- drivers/net/vxlan/vxlan_core.c | 136 ++++++++------------------------- 1 file changed, 30 insertions(+), 106 deletions(-)
drivers/net/vxlan/vxlan_core.c +30 -106
@@ -2266,63 +2266,6 @@ static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,return 0 ; } -#if IS_ENABLED (CONFIG_IPV6 ) -static struct dst_entry *vxlan6_get_route (struct vxlan_dev *vxlan, -struct net_device *dev, -struct vxlan_sock *sock6, -struct sk_buff *skb,int oif,u8 tos, -__be32 label, -const struct in6_addr *daddr, -struct in6_addr *saddr, -__be16 dport,__be16 sport, -struct dst_cache *dst_cache, -const struct ip_tunnel_info *info) -{ -bool use_cache =ip_tunnel_dst_cache_usable (skb, info); -struct dst_entry *ndst; -struct flowi6 fl6; - -if (!sock6) -return ERR_PTR (-EIO ); - -if (tos && !info) - use_cache = false; -if (use_cache) { - ndst =dst_cache_get_ip6 (dst_cache, saddr); -if (ndst) -return ndst; - } - -memset (&fl6,0 ,sizeof (fl6)); - fl6.flowi6_oif = oif; - fl6.daddr = *daddr; - fl6.saddr = *saddr; - fl6.flowlabel =ip6_make_flowinfo (tos, label); - fl6.flowi6_mark = skb->mark; - fl6.flowi6_proto =IPPROTO_UDP ; - fl6.fl6_dport = dport; - fl6.fl6_sport = sport; - - ndst = ipv6_stub->ipv6_dst_lookup_flow (vxlan->net, sock6->sock->sk, - &fl6,NULL ); -if (IS_ERR (ndst)) { -netdev_dbg (dev,"no route to %pI6\n" , daddr); -return ERR_PTR (-ENETUNREACH ); - } - -if (unlikely (ndst->dev == dev)) { -netdev_dbg (dev,"circular route to %pI6\n" , daddr); -dst_release (ndst); -return ERR_PTR (-ELOOP ); - } - - *saddr = fl6.saddr; -if (use_cache) -dst_cache_set_ip6 (dst_cache, ndst, saddr); -return ndst; -} -#endif -/* Bypass encapsulation if the destination is local */ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, struct vxlan_dev *dst_vxlan, __be32 vni,
@@ -2376,7 +2319,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,static int encap_bypass_if_local (struct sk_buff *skb,struct net_device *dev,struct vxlan_dev *vxlan, -union vxlan_addr *daddr, +int addr_family,__be16 dst_port,int dst_ifindex,__be32 vni,struct dst_entry *dst,u32 rt_flags)
@@ -2396,7 +2339,7 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,dst_release (dst); dst_vxlan =vxlan_find_vni (vxlan->net, dst_ifindex, vni, - daddr->sa.sa_family, dst_port, + addr_family, dst_port, vxlan->cfg.flags);if (!dst_vxlan) {DEV_STATS_INC (dev, tx_errors);
@@ -2422,13 +2365,12 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,struct ip_tunnel_key key;struct vxlan_dev *vxlan =netdev_priv (dev);const struct iphdr *old_iph =ip_hdr (skb); -union vxlan_addr *dst; -union vxlan_addr remote_ip;struct vxlan_metadata _md;struct vxlan_metadata *md = &_md;unsigned int pkt_len = skb->len;__be16 src_port =0 , dst_port;struct dst_entry *ndst =NULL ; +int addr_family;__u8 tos, ttl;int ifindex;int err;
@@ -2437,20 +2379,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,bool udp_sum = false;bool xnet = !net_eq (vxlan->net,dev_net (vxlan->dev));__be32 vni =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -union vxlan_addr local_ip; -__be32 label; -#endif info =skb_tunnel_info (skb); use_cache =ip_tunnel_dst_cache_usable (skb, info);if (rdst) { - dst = &rdst->remote_ip;memset (&key,0 ,sizeof (key)); pkey = &key; -if (vxlan_addr_any (dst)) { +if (vxlan_addr_any (&rdst->remote_ip)) {if (did_rsc) {/* short-circuited back to local bridge */ vxlan_encap_bypass(skb, vxlan, vxlan,
@@ -2460,11 +2397,12 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, goto drop; } + addr_family = vxlan->cfg.saddr.sa.sa_family; dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port; vni = (rdst->remote_vni) ? : default_vni; ifindex = rdst->remote_ifindex; -if (dst->sa.sa_family ==AF_INET ) { +if (addr_family ==AF_INET ) { key.u.ipv4.src = vxlan->cfg.saddr.sin.sin_addr.s_addr; key.u.ipv4.dst = rdst->remote_ip.sin.sin_addr.s_addr; }else {
@@ -2478,23 +2416,21 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ttl =ip_tunnel_get_ttl (old_iph, skb); }else { ttl = vxlan->cfg.ttl; -if (!ttl &&vxlan_addr_multicast (dst)) +if (!ttl &&vxlan_addr_multicast (&rdst->remote_ip)) ttl =1 ; } - tos = vxlan->cfg.tos;if (tos ==1 ) tos =ip_tunnel_get_dsfield (old_iph, skb);if (tos && !info) use_cache = false; -if (dst->sa.sa_family ==AF_INET ) +if (addr_family ==AF_INET ) udp_sum = !(flags &VXLAN_F_UDP_ZERO_CSUM_TX );else udp_sum = !(flags &VXLAN_F_UDP_ZERO_CSUM6_TX );#if IS_ENABLED (CONFIG_IPV6 ) - local_ip = vxlan->cfg.saddr; - label = vxlan->cfg.label; + key.label = vxlan->cfg.label;#endif }else {if (!info) {
@@ -2502,17 +2438,8 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, dev->name); goto drop; } - remote_ip.sa.sa_family =ip_tunnel_info_af (info); -if (remote_ip.sa.sa_family ==AF_INET ) { - remote_ip.sin.sin_addr.s_addr = info->key.u.ipv4.dst; - }else { - remote_ip.sin6.sin6_addr = info->key.u.ipv6.dst; -#if IS_ENABLED (CONFIG_IPV6 ) - local_ip.sin6.sin6_addr = info->key.u.ipv6.src; -#endif - } - dst = &remote_ip; pkey = &info->key; + addr_family =ip_tunnel_info_af (info); dst_port = info->key.tp_dst ? : vxlan->cfg.dst_port; vni =tunnel_id_to_key32 (info->key.tun_id); ifindex =0 ;
@@ -2524,16 +2451,13 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, } ttl = info->key.ttl; tos = info->key.tos; -#if IS_ENABLED (CONFIG_IPV6 ) - label = info->key.label; -#endif udp_sum = !!(info->key.tun_flags &TUNNEL_CSUM ); } src_port =udp_flow_src_port (dev_net (dev), skb, vxlan->cfg.port_min, vxlan->cfg.port_max, true);rcu_read_lock (); -if (dst->sa.sa_family ==AF_INET ) { +if (addr_family ==AF_INET ) {struct vxlan_sock *sock4 =rcu_dereference (vxlan->vn4_sock);struct rtable *rt;__be16 df =0 ;
@@ -2552,7 +2476,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,if (!info) {/* Bypass encapsulation if the destination is local */ - err =encap_bypass_if_local (skb, dev, vxlan, dst, + err =encap_bypass_if_local (skb, dev, vxlan,AF_INET , dst_port, ifindex, vni, &rt->dst, rt->rt_flags);if (err)
@@ -2606,15 +2530,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,#if IS_ENABLED (CONFIG_IPV6 ) } else {struct vxlan_sock *sock6 =rcu_dereference (vxlan->vn6_sock); +struct in6_addr saddr;if (!ifindex) ifindex = sock6->sock->sk->sk_bound_dev_if; - ndst =vxlan6_get_route (vxlan, dev, sock6, skb, ifindex, tos, - label, &dst->sin6.sin6_addr, - &local_ip.sin6.sin6_addr, - dst_port, src_port, - dst_cache, info); + ndst =udp_tunnel6_dst_lookup (skb, dev, vxlan->net, sock6->sock, + ifindex, &saddr, pkey, + src_port, dst_port, tos, + use_cache ? dst_cache :NULL );if (IS_ERR (ndst)) { err =PTR_ERR (ndst); ndst =NULL ;
@@ -2624,7 +2548,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,if (!info) {u32 rt6i_flags =dst_rt6_info (ndst)->rt6i_flags; - err =encap_bypass_if_local (skb, dev, vxlan, dst, + err =encap_bypass_if_local (skb, dev, vxlan,AF_INET6 , dst_port, ifindex, vni, ndst, rt6i_flags);if (err)
@@ -2639,16 +2563,13 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, }else if (err) {if (info) {struct ip_tunnel_info *unclone; -struct in6_addr src, dst; unclone =skb_tunnel_info_unclone (skb);if (unlikely (!unclone)) goto tx_error; - src = remote_ip.sin6.sin6_addr; - dst = local_ip.sin6.sin6_addr; - unclone->key.u.ipv6.src = src; - unclone->key.u.ipv6.dst = dst; + unclone->key.u.ipv6.src = pkey->u.ipv6.dst; + unclone->key.u.ipv6.dst = saddr; }vxlan_encap_bypass (skb, vxlan, vxlan, vni, false);
@@ -2665,9 +2586,8 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, goto tx_error;udp_tunnel6_xmit_skb (ndst, sock6->sock->sk, skb, dev, - &local_ip.sin6.sin6_addr, - &dst->sin6.sin6_addr, tos, ttl, - label, src_port, dst_port, !udp_sum); + &saddr, &pkey->u.ipv6.dst, tos, ttl, + pkey->label, src_port, dst_port, !udp_sum);#endif }vxlan_vnifilter_count (vxlan, vni,NULL ,VXLAN_VNI_STATS_TX , pkt_len);
@@ -3127,10 +3047,14 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)struct vxlan_sock *sock6 =rcu_dereference (vxlan->vn6_sock);struct dst_entry *ndst; - ndst =vxlan6_get_route (vxlan, dev, sock6, skb,0 , info->key.tos, - info->key.label, &info->key.u.ipv6.dst, - &info->key.u.ipv6.src, dport, sport, - &info->dst_cache, info); +if (!sock6) +return -EIO ; + + ndst =udp_tunnel6_dst_lookup (skb, dev, vxlan->net, sock6->sock, +0 , &info->key.u.ipv6.src, + &info->key, + sport, dport, info->key.tos, + &info->dst_cache);if (IS_ERR (ndst))return PTR_ERR (ndst);dst_release (ndst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 563/1193 watchdog: msc313e: Sync timeout value if WDT was running at boot
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <[email protected]>
[ Upstream commit 01504d14e47b34779911250dd308a03f6ef681c2 ]
If WDT was running at boot, the hardware timeout might be set to values other than the final software timeout.
To be consistent, set the hardware timeout to match the final software timeout (i.e., after watchdog_init_timeout()) if WDT was running.
--- drivers/watchdog/msc313e_wdt.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/watchdog/msc313e_wdt.c +9 -8
@@ -145,12 +145,21 @@ static int msc313e_wdt_probe(struct platform_device *pdev) priv->wdev.max_timeout =U32_MAX / rate; priv->wdev.timeout =MSC313E_WDT_DEFAULT_TIMEOUT ; +watchdog_set_drvdata (&priv->wdev, priv); +platform_set_drvdata (pdev, priv); + +watchdog_init_timeout (&priv->wdev, timeout, dev); +watchdog_stop_on_reboot (&priv->wdev); +watchdog_stop_on_unregister (&priv->wdev); +watchdog_stop_ping_on_suspend (&priv->wdev); + ret =clk_prepare_enable (priv->clk);if (ret)return ret;/* If the period is non-zero the WDT is running */ if (msc313e_wdt_get_hw_timeout (priv)) { +msc313e_wdt_set_hw_timeout (priv, priv->wdev.timeout);set_bit (WDOG_HW_RUNNING , &priv->wdev.status);/* * Keep the clock enabled. The watchdog core will skip the next
@@ -161,14 +170,6 @@ static int msc313e_wdt_probe(struct platform_device *pdev)clk_disable_unprepare (priv->clk); } -watchdog_set_drvdata (&priv->wdev, priv); -platform_set_drvdata (pdev, priv); - -watchdog_init_timeout (&priv->wdev, timeout, dev); -watchdog_stop_on_reboot (&priv->wdev); -watchdog_stop_on_unregister (&priv->wdev); -watchdog_stop_ping_on_suspend (&priv->wdev); - ret =devm_watchdog_register_device (dev, &priv->wdev);/* If the WDT is running and anything goes wrong, disable the clock. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/1193 tracing: Free histogram the var ref when its initialization fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 516001d53e6b2ea95a251ee2ef54a1a689a3fd58 upstream.
create_var_ref() allocates a VAR_REF hist_field and then calls init_var_ref() to fill it in. When that fails the field is leaked.
commit 656fe2ba85e8 ("tracing: Use hist trigger's var_ref array to destroy var_refs") made destroy_hist_field() return early for HIST_FIELD_FL_VAR_REF, since var refs are freed by walking the trigger's var_refs[] array instead. create_var_ref() adds the field to that array only after init_var_ref() has succeeded, so on this path the field is in neither place and nothing frees it. The call was correct when it was written, before var refs were taken out of destroy_hist_field().
init_var_ref() cannot free it either. The caller owns the field, so init_var_ref() undoes only its own string allocations and leaves the field alone. Freeing it there would leave create_var_ref() passing freed memory to destroy_hist_field(), which reads its flags.
Call __destroy_hist_field(), which frees the field without consulting the flag.
--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -2211,7 +2211,7 @@ static struct hist_field *create_var_ref ref_field =create_hist_field (var_field->hist_data,NULL , flags,NULL );if (ref_field) {if (init_var_ref (ref_field, var_field, system, event_name)) { -destroy_hist_field (ref_field,0 ); +__destroy_hist_field (ref_field);return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 621/1193 cpufreq: initialize policy rwsem before sysfs publication
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 3e5d1bf4bd687beb2cb4e32a07af695455925588 upstream.
cpufreq_policy_alloc() initializes policy->rwsem after kobject_init_and_add() has created the policy sysfs directory and its default attributes. A sysfs access can therefore reach a policy callback before the semaphore has been initialized.
Initialize policy->rwsem before publishing the policy kobject so sysfs callbacks always see an initialized semaphore.
--- drivers/cpufreq/cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +2 -2
@@ -1273,6 +1273,8 @@ static struct cpufreq_policy *cpufreq_poif (!zalloc_cpumask_var (&policy->real_cpus,GFP_KERNEL )) goto err_free_rcpumask; +init_rwsem (&policy->rwsem); +init_completion (&policy->kobj_unregister); ret =kobject_init_and_add (&policy->kobj, &ktype_cpufreq, cpufreq_global_kobject,"policy%u" , cpu);
@@ -1287,8 +1289,6 @@ static struct cpufreq_policy *cpufreq_po goto err_free_real_cpus; } -init_rwsem (&policy->rwsem); -freq_constraints_init (&policy->constraints); policy->nb_min.notifier_call = cpufreq_notifier_min;
Greg Kroah-Hartman
maintainerPATCH 622/1193 exec: do_close_on_exec() before taking exec_update_lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit e780259b54e618ceb4763fbc21314acf3565e813 upstream.
do_close_on_exec() currently happens while holding the exec_update_lock, which is used in a lot of places that access process state to synchronize access checks.
I recently added another such use of exec_update_lock, causing a regression.
do_close_on_exec() can block waiting for a reply from a filesystem. That means a hung filesystem can block codepaths that use exec_update_lock; and it also means that a FUSE filesystem which attempts to inspect the calling process can deadlock.
To avoid such problems, move do_close_on_exec() before the exec_update_lock is taken, but after the FD table has been copied if necessary.
I have looked through all the calls between the old and new position of the do_close_on_exec() call; there seems to be no file descriptor table access in between.
--- fs/exec.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
fs/exec.c +14 -8
@@ -1274,6 +1274,20 @@ int begin_new_exec(struct linux_binprm * goto out;/* +* We have to apply CLOEXEC before we change whether the process is +* dumpable (in setup_new_exec) to avoid a race with a process in userspace +* trying to access the should-be-closed file descriptors of a process +* undergoing exec(2). +* +* This can block on filesystem ->flush() handlers, including waiting +* for FUSE daemons, so do it before exec_mmap takes the +* exec_update_lock. +* This must happen after the point of no return, and after unsharing +* the FD table. +*/ +do_close_on_exec (me->files); + +/* * Must be called _before_ exec_mmap() as bprm->mm is * not visible until then. Doing it here also ensures * we don't race against replace_mm_exe_file().
@@ -1323,14 +1337,6 @@ int begin_new_exec(struct linux_binprm *clear_syscall_work_syscall_user_dispatch (me); -/* -* We have to apply CLOEXEC before we change whether the process is -* dumpable (in setup_new_exec) to avoid a race with a process in userspace -* trying to access the should-be-closed file descriptors of a process -* undergoing exec(2). -*/ -do_close_on_exec (me->files); -if (bprm->secureexec) {/* Make sure parent cannot signal privileged process. */ me->pdeath_signal =0 ;
Greg Kroah-Hartman
maintainerPATCH 623/1193 drm/drm_exec: fix up contended obj when num_objects is 0
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sunil Khatri <[email protected]>
commit 159720704d9d652b64390c11fb971e15b0a78d23 upstream.
drm_exec_prepare_array() silently returns success without calling drm_exec_lock_contended() when num_objects is zero. This breaks the invariant upheld by drm_exec_lock_obj(), where every entry point into the locking sequence must first attempt to lock any previously contended object before proceeding.
Drivers that chain multiple drm_exec_prepare_array() calls per drm_exec_until_all_locked() iteration (e.g. amdgpu's userq signal/wait ioctls, which prepare separate read and write BO arrays) can pass an empty array for one of the two calls. If contention is hit while preparing the non-empty array, exec->contended is set and the loop retries; on retry, the empty-array call preceding it is a no-op that never clears exec->contended, so drm_exec_retry_on_contention() immediately jumps back to the top of the loop without ever reaching the call that would resolve the contention. This spins forever.
Fix it by having drm_exec_prepare_array() call drm_exec_lock_contended() directly when num_objects is zero, so a pending contended object dont loop infinitely.
--- drivers/gpu/drm/drm_exec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/drm_exec.c +13 -0
@@ -319,6 +319,19 @@ int drm_exec_prepare_array(struct drm_ex {int ret; +/* +* Make sure to lock a contended object even when no objects are +* given, otherwise drm_exec_retry_on_contention() would loop +* forever on patterns like: +* +* ret = drm_exec_prepare_array(exec, objs, num_objects, ...); +* drm_exec_retry_on_contention(exec); +* +* with num_objects == 0. +*/ +if (!num_objects) +return drm_exec_lock_contended (exec); +for (unsigned int i =0 ; i < num_objects; ++i) { ret =drm_exec_prepare_obj (exec, objects[i], num_fences);if (unlikely (ret))
Greg Kroah-Hartman
maintainerPATCH 624/1193 drm/i915: Fix memory leak in query_perf_config_list()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit cbd3dafc2003db679ccd2f6c6a2551db79657049 upstream.
When krealloc() fails, free the original oa_config_ids before returning to avoid a memory leak.
--- drivers/gpu/drm/i915/i915_query.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_query.c +3 -1
@@ -401,8 +401,10 @@ static int query_perf_config_list(struct ids =krealloc (oa_config_ids, n_configs *sizeof (*oa_config_ids),GFP_KERNEL ); -if (!ids) +if (!ids) { +kfree (oa_config_ids);return -ENOMEM ; + } alloc =fetch_and_zero (&n_configs);
Greg Kroah-Hartman
maintainerPATCH 625/1193 ring-buffer: Acquire the lock with irqsave in rb_wake_up_waiters()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 815e07c8fe885a87751c2496a30ae0dcd4118210 upstream.
rb_wake_up_waiters() is a irq_work callback which is initialized with init_irq_work(). As such it will be invoked in thread context on PREEMPT_RT. Invoking the callback in IRQ context on PREEMPT_RT is not an option due its usage of wake_up_all(). Since this callback may run in thread context, it needs to acquire ring_buffer_per_cpu::reader_lock with disabling interrupts and may not assume that they are disabled.
Use raw_spinlock_irqsave() to acquire ring_buffer_per_cpu::reader_lock.
--- kernel/trace/ring_buffer.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
kernel/trace/ring_buffer.c +6 -7
@@ -907,14 +907,13 @@ static void rb_wake_up_waiters(struct irstruct ring_buffer_per_cpu *cpu_buffer = container_of(rbwork, struct ring_buffer_per_cpu, irq_work); -/* Called from interrupt context */ -raw_spin_lock (&cpu_buffer->reader_lock); - rbwork->wakeup_full = false; - rbwork->full_waiters_pending = false; + scoped_guard(raw_spinlock_irqsave, &cpu_buffer->reader_lock) { + rbwork->wakeup_full = false; + rbwork->full_waiters_pending = false; -/* Waking up all waiters, they will reset the shortest full */ - cpu_buffer->shortest_full =0 ; -raw_spin_unlock (&cpu_buffer->reader_lock); +/* Waking up all waiters, they will reset the shortest full */ + cpu_buffer->shortest_full =0 ; + }wake_up_all (&rbwork->full_waiters); }
Greg Kroah-Hartman
maintainerPATCH 626/1193 net: hso: fix TIOCMIWAIT race
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 00f9fbc12320253bfc576fb7539d860029c82d0f upstream.
The task state must be updated before checking the wakeup condition to avoid missing a racing modem status update.
--- drivers/net/usb/hso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/hso.c +1 -1
@@ -1550,10 +1550,10 @@ hso_wait_modem_status(struct hso_serialspin_unlock_irq (&serial->serial_lock);add_wait_queue (&tiocmget->waitq, &wait);for (;;) { +set_current_state (TASK_INTERRUPTIBLE );spin_lock_irq (&serial->serial_lock);memcpy (&cnow, &tiocmget->icount,sizeof (struct uart_icount ));spin_unlock_irq (&serial->serial_lock); -set_current_state (TASK_INTERRUPTIBLE );if (((arg &TIOCM_RNG ) && (cnow.rng != cprev.rng)) || ((arg &TIOCM_DSR ) && (cnow.dsr != cprev.dsr)) || ((arg &TIOCM_CD ) && (cnow.dcd != cprev.dcd))) {
Greg Kroah-Hartman
maintainerPATCH 627/1193 net: mana: Reserve extra CQ slot for the fence completion CQE
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sahil Chandna <[email protected]>
commit 80dd7e754b3aa9637a0758ad93fa209f9650ec48 upstream.
The RX completion queue is sized to hold exactly one CQE per posted RX WQE. MANA_FENCE_RQ makes hardware post an additional CQE_RX_OBJECT_FENCE after the packet CQEs. The current sizing reserves no extra slot for it and in rare cases, CQ has no guaranteed slot for the fence CQE when it is full of packet CQEs. This can lead to dropping the fence completion while the driver waits holding RTNL lock throughout the timeout duration. Reserve one extra CQE slot for CQE_RX_OBJECT_FENCE. mana_gd_alloc_memory() requires queue_size to be a power-of-two and at least MANA_PAGE_SIZE; the reservation pushes cq_size past a power-of-two, so round up the CQ size in mana_create_rxq().
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +5 -1
@@ -2152,6 +2152,10 @@ static int mana_alloc_rx_wqe(struct mana *cq_size +=COMP_ENTRY_SIZE ; } +/* Reserve an extra slot for Fence completion +* event (CQE_RX_OBJECT_FENCE) in case RX CQ is full. +*/ + *cq_size +=COMP_ENTRY_SIZE ;return 0 ; }
@@ -2234,7 +2238,7 @@ static struct mana_rxq *mana_create_rxq( goto out; rq_size =MANA_PAGE_ALIGN (rq_size); - cq_size =MANA_PAGE_ALIGN (cq_size); + cq_size =MANA_PAGE_ALIGN (roundup_pow_of_two (cq_size));/* Create RQ */ memset (&spec,0 ,sizeof (spec));
Greg Kroah-Hartman
maintainerPATCH 628/1193 net: mpls: clear inner_protocol when the last label is popped
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fourie Zhang <[email protected]>
commit 78a86d75a70e1e227711c72865c59b1422d0a5ae upstream.
skb_mpls_push() records the pre-encapsulation network header once, gated on !skb->inner_protocol. skb_mpls_pop() never clears that record, so it outlives the encapsulation it describes.
Open vSwitch can then re-push MPLS onto a packet whose inner_network_header still points at the older, deeper offset: push a label, pop every label, recirculate (ovs_flow_key_update() re-derives key->eth.type and resets network_header, but leaves inner_*), then push again. ovs_fragment() trusts the record:
skb->network_header = skb->inner_network_header;
so skb_network_offset() goes negative. The bound check is signed:
if (skb_network_offset(skb) > MAX_L2_LEN)
a negative offset passes it, and prepare_frag() widens the value:
unsigned int hlen = skb_network_offset(skb); memcpy(&data->l2_data, skb->data, hlen);
which is a ~4GiB memcpy out of a 30-byte per-CPU buffer.
Reproduced on v7.3-rc1. RDX is the truncated length, (unsigned int)(-8):
BUG: unable to handle page fault for address: ffffe8ffffc16000 #PF: supervisor write access in kernel mode Oops: 0002 [#1] SMP KASAN NOPTI RIP: 0010:memcpy+0x8/0x20 RDX: 00000000fffffff8 RSI: ffff888105d732db RDI: ffffe8ffffc16000 prepare_frag+0x3df/0x4e0 ovs_fragment+0x589/0x7e0 do_output+0x4ce/0x5e0 do_execute_actions+0x55d2/0x7b30 ovs_execute_actions+0xea/0x450
Same root-cause shape as commit 975b5b067f52 ("ipv6: sr: restore network header before routing and forwarding"): a stale network header offset reaching a consumer that widens it. Here it originates in the MPLS push/pop path.
Clear inner_protocol once the packet is no longer MPLS, so a later push re-records the current header. net/sched/act_mpls.c is the only other skb_mpls_pop() caller and gets the same fix; sch_frag.c saves and restores inner_protocol around fragmentation in the same way OVS does.
--- net/core/skbuff.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/skbuff.c +7 -0
@@ -6256,6 +6256,13 @@ int skb_mpls_pop(struct sk_buff *skb, __ } skb->protocol = next_proto; +/* The last label is gone, so the inner header recorded by +* skb_mpls_push() no longer describes this packet. Drop it, or a +* later push keeps the stale offset. +*/ +if (!eth_p_mpls (next_proto)) + skb->inner_protocol =0 ; +return 0 ; }EXPORT_SYMBOL_GPL (skb_mpls_pop);
Greg Kroah-Hartman
maintainerPATCH 629/1193 net: openvswitch: fix use-after-free of the flow table mask array
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
commit ba4ba11ed6eb8972c69070417fc27b48deb002e8 upstream.
tbl_mask_array_realloc() retires the old mask_array before it stops being reachable:
old = ovsl_dereference(tbl->mask_array);
if (old) {
...
call_rcu(&old->rcu, mask_array_rcu_cb);
}
rcu_assign_pointer(tbl->mask_array, new);call_rcu() only waits for read-side critical sections already in flight. tbl->mask_array still points at old between the call_rcu() and the rcu_assign_pointer(), so a reader entering ovs_flow_tbl_lookup_stats() in that window picks up old in a fresh critical section that the pending grace period does not cover.
tbl_mask_array_realloc() runs in process context under ovs_mutex, so the window is preemptible and can outlast the grace period. Then mask_array_rcu_cb() frees old before the swap runs:
BUG: KASAN: slab-use-after-free in flow_lookup.constprop.0+0x2bf/0x2f0 Read of size 8 at addr ffff888020b3e018 by task poc/741 flow_lookup.constprop.0+0x2bf/0x2f0 ovs_flow_tbl_lookup_stats+0x4a3/0x5c0 ovs_dp_process_packet+0x19c/0x710 ovs_vport_receive+0x243/0x390 internal_dev_xmit+0x81/0x170 Freed by task 728: kfree+0x16a/0x4e0 rcu_core+0x853/0x1030
Publish the new array before retiring the old one. The kfree_rcu() that call_rcu() replaced ran after the swap.
--- net/openvswitch/flow_table.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/openvswitch/flow_table.c +3 -1
@@ -262,11 +262,13 @@ static int tbl_mask_array_realloc(structif (ovsl_dereference (old->masks[i])) new->masks[new->count++] = old->masks[i]; } -call_rcu (&old->rcu, mask_array_rcu_cb); }rcu_assign_pointer (tbl->mask_array, new); +if (old) +call_rcu (&old->rcu, mask_array_rcu_cb); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 630/1193 netfilter: nf_log: unregister loggers before per-net teardown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit 2c018cc4842c33f0c732962e2ab58635e8ae5823 upstream.
nf_log_syslog and nfnetlink_log unregister their per-network namespace operations before unregistering their global logger backends. This leaves a window where a sysctl or netlink writer can rebind the still- registered logger after the per-net pre-exit callback cleared the old selection.
The race looks like this:
CPU 0 CPU 1
---- ----
unregister_pernet_subsys()
nf_log_unset(net, logger)
net->nf.nf_loggers[pf] = NULL
lock nf_log_mutex
find logger in loggers[][]
net->nf.nf_loggers[pf] = logger
unlock nf_log_mutex nf_log_unregister(logger)
lock nf_log_mutex
loggers[pf][type] = NULL
unlock nf_log_mutex
synchronize_rcu()
module exit returns
module core frees backend memory
Later, a sysctl read or packet logging operation can dereference the stale per-net logger pointer.
Fix this by unregistering the global logger backends before tearing down per-net state. Once the global registrations are gone, later writers can no longer rebind the logger. unregister_pernet_subsys() already waits for an RCU grace period after the pre-exit callback clears the per-net selection, while nf_log_unregister() continues to cover readers of the global logger table.
Apply this ordering fix to both nf_log backends that combine per-net teardown with global logger registration.
--- net/netfilter/nf_log_syslog.c | 2 +- net/netfilter/nfnetlink_log.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_log_syslog.c +1 -1
@@ -1063,12 +1063,12 @@ err1: static void __exit nf_log_syslog_exit(void) { -unregister_pernet_subsys (&nf_log_syslog_net_ops);nf_log_unregister (&nf_ip_logger);nf_log_unregister (&nf_arp_logger);nf_log_unregister (&nf_ip6_logger);nf_log_unregister (&nf_netdev_logger);nf_log_unregister (&nf_bridge_logger); +unregister_pernet_subsys (&nf_log_syslog_net_ops); }module_init (nf_log_syslog_init);
net/netfilter/nfnetlink_log.c +1 -1
@@ -1205,8 +1205,8 @@ static void __exit nfnetlink_log_fini(vo {nfnetlink_subsys_unregister (&nfulnl_subsys);netlink_unregister_notifier (&nfulnl_rtnl_notifier); -unregister_pernet_subsys (&nfnl_log_net_ops);nf_log_unregister (&nfulnl_logger); +unregister_pernet_subsys (&nfnl_log_net_ops); }MODULE_DESCRIPTION ("netfilter userspace logging" );
Greg Kroah-Hartman
maintainerPATCH 613/1193 tracing: Free histogram var refs regardless of how often they are referenced
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 4bddcb346a6cf4615ca77f69a589623b877ca267 upstream.
Using the same variable three or more times in one hist trigger leaks the variable reference and its strings when the trigger is removed.
commit 656fe2ba85e8 ("tracing: Use hist trigger's var_ref array to destroy var_refs") made a trigger's var_refs[] array the only owner of a var ref:destroy_hist_field() returns early for HIST_FIELD_FL_VAR_REF, so the field expressions never destroy one. One entry, freed once, no count needed.
commit 8bcebc77e85f ("tracing: Fix histogram code when expression has same var as value") then made repeated references share one object and added a count of them. Only the increment side exists, since those expressions still return early and never drop a reference, so __destroy_hist_field() sees how many references were created rather than how many are left. It frees when the decremented count is 0 or 1, so two references work and three or more leak.
Sharing kept one array entry per object, and create_var_ref() searches and appends within a single trigger, so nothing outside it holds the object. Removing a trigger whose variables are still referenced is already refused by check_var_refs() with -EBUSY. Drop the count and free unconditionally.
--- kernel/trace/trace_events_hist.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
kernel/trace/trace_events_hist.c +1 -15
@@ -163,7 +163,6 @@ struct hist_field {struct hist_field *operands[HIST_FIELD_OPERANDS_MAX ];struct hist_trigger_data *hist_data;enum hist_field_fn fn_num; -unsigned int ref;unsigned int size;unsigned int offset;unsigned int is_signed;
@@ -1895,16 +1894,8 @@ out:return field_op; } -static void get_hist_field (struct hist_field *hist_field) -{ - hist_field->ref++; -} -static void __destroy_hist_field (struct hist_field *hist_field) { -if (--hist_field->ref >1 ) -return ; -kfree (hist_field->var.name);kfree (hist_field->name);
@@ -1951,8 +1942,6 @@ static struct hist_field *create_hist_fiif (!hist_field)return NULL ; - hist_field->ref =1 ; - hist_field->hist_data = hist_data;if (flags &HIST_FIELD_FL_EXPR || flags &HIST_FIELD_FL_ALIAS )
@@ -2200,10 +2189,8 @@ static struct hist_field *create_var_reffor (i =0 ; i < hist_data->n_var_refs; i++) { ref_field = hist_data->var_refs[i];if (ref_field->var.idx == var_field->var.idx && - ref_field->var.hist_data == var_field->hist_data) { -get_hist_field (ref_field); + ref_field->var.hist_data == var_field->hist_data)return ref_field; - } }/* Sanity check to avoid out-of-bound write on 'hist_data->var_refs' */ if (hist_data->n_var_refs >=TRACING_MAP_VARS_MAX )
@@ -3242,7 +3229,6 @@ static struct hist_field *create_var(str goto out; } - var->ref =1 ; var->flags =HIST_FIELD_FL_VAR ; var->var.idx = idx; var->var.hist_data = var->hist_data = hist_data;
Greg Kroah-Hartman
maintainerPATCH 631/1193 netfilter: report NLM_F_DUMP_FILTERED when all is filtered out
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
commit 7a099b347fef536a84068076e2d384f044e5cfc5 upstream.
NLM_F_DUMP_FILTERED is only set on data elements in the conntrack dump. But when everything is filtered out it is confusing for the user space, since the flag is not reported anymore and it looks like the table was empty, which may or may not be the case.
'answer_flags' were introduced precisely for this use case, and the conntrack dump should set the flag in there in case the filtering was applied.
This is important, for example, to be able to tell if the filters are supported or not by the kernel without modifying the kernel state.
With the proper reporting of NLM_F_DUMP_FILTERED on NLMSG_DONE, an application in user space can just try and dump with an arbitrary filter without worrying that there could be no matching entry. The reported flag will signal that the filtering was applied and therefore supported.
--- net/netfilter/nf_conntrack_netlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_conntrack_netlink.c +2 -0
@@ -1048,6 +1048,8 @@ static int ctnetlink_start(struct netlin } cb->data = filter; +if (filter) + cb->answer_flags =NLM_F_DUMP_FILTERED ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 632/1193 vdpa: ifcvf: Put device on unsupported feature error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiong Weimin <[email protected]>
commit 4d470be71196ca0ce302e6623454533dc31b465b upstream.
Route unsupported provisioned features through the common error path after vdpa_alloc_device() so the allocated device and adapter pointer are released consistently.
Message-ID: <[email protected]>
--- drivers/vdpa/ifcvf/ifcvf_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vdpa/ifcvf/ifcvf_main.c +2 -1
@@ -708,7 +708,8 @@ static int ifcvf_vdpa_dev_add(struct vdpif (config->device_features & ~device_features) {IFCVF_ERR (pdev,"The provisioned features 0x%llx are not supported by this device with features 0x%llx\n" , config->device_features, device_features); -return -EINVAL ; + ret = -EINVAL ; + goto err; } device_features &= config->device_features; }
Greg Kroah-Hartman
maintainerPATCH 633/1193 vdpa: solidrun: Free IRQs after request failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiong Weimin <[email protected]>
commit e847542ab0545c73354849126150206c29d83929 upstream.
Unwind IRQs already requested by snet_request_irqs() before returning a VQ IRQ request error so a later DRIVER_OK retry starts from a clean state. The IRQs are requested and freed while the PCI device remains bound, so the driver cannot wait for devres cleanup at detach time.
Message-ID: <[email protected]>
--- drivers/vdpa/solidrun/snet_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/vdpa/solidrun/snet_main.c +5 -1
@@ -418,11 +418,15 @@ static int snet_request_irqs(struct pci_ snet->vqs[i]->irq_name, snet->vqs[i]);if (ret) {SNET_ERR (pdev,"Failed to request IRQ\n" ); -return ret; + goto err_free_irqs; } snet->vqs[i]->irq = irq; }return 0 ; + +err_free_irqs: +snet_free_irqs (snet); +return ret; }static void snet_set_status (struct vdpa_device *vdev,u8 status)
Greg Kroah-Hartman
maintainerPATCH 634/1193 scripts/sorttable: Mark long_size as __maybe_unused
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 4f73462856576797b8f3c55564a9be99f76dc67b upstream.
When building in a kernel tree prior to commit b055f4c431e3 ("sorttable:
Move ELF parsing into scripts/elf-parse.[ch]") with clang-23 or newer, which implements a new warning under -Wunused-but-set-variable for static global variable, there is a warning from sorttable because long_size is unused when MCOUNT_SORT_ENABLED is not set:
scripts/sorttable.c:452:12: error: variable 'long_size' set but not used [-Werror,-Wunused-but-set-global]
452 | static int long_size;
| ^Mark long_size as __maybe_unused to avoid inserting more ugly #ifdef directives while insuring the warning does not reappear, as the aforementioned change does not alter the uses of long_size, so it appears to be coincidence that the warning disappears after this refactoring.
--- scripts/sorttable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/sorttable.c +1 -1
@@ -449,7 +449,7 @@ static inline void *get_index(void *star }static int extable_ent_size; -static int long_size; +static int long_size__maybe_unused ;#define ERRSTR_MAXSZ 256
Greg Kroah-Hartman
maintainerPATCH 635/1193 fbdev: vfb: defer cleanup until the last reference
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit a0a34a40ed299c9c7cff6af163a5b883ee9d6d73 upstream.
FBIOGETCMAP takes a shallow snapshot of info->cmap and performs the usercopy after dropping info->lock. vfb_remove() frees the colormap immediately after unregistering the framebuffer, even when an open file still holds a reference to fb_info. A concurrent driver unbind can therefore free the colormap while the ioctl copies it to userspace.
KASAN reports:
BUG: KASAN: slab-use-after-free in _copy_to_user Read of size 512 by task poc/125 _copy_to_user (./include/linux/instrumented.h:129 ./include/linux/uaccess.h:201 lib/usercopy.c:24) fb_cmap_to_user (./include/linux/uaccess.h:230 drivers/video/fbdev/core/fbcmap.c:211) do_fb_ioctl (drivers/video/fbdev/core/fb_chrdev.c:114) Allocated by task 1: fb_alloc_cmap_gfp (./include/linux/slab.h:973 ./include/linux/slab.h:1290 drivers/video/fbdev/core/fbcmap.c:108) vfb_probe (drivers/video/fbdev/vfb.c:459) Freed by task 124: fb_dealloc_cmap (drivers/video/fbdev/core/fbcmap.c:151) vfb_remove (drivers/video/fbdev/vfb.c:489)
unregister_framebuffer() drops the registration reference, and fbdev calls fb_destroy after the last put_fb_info(). Move the registered framebuffer's cleanup into an fb_destroy callback so its colormap and screen buffer stay alive until all file references have been released.
--- drivers/video/fbdev/vfb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/video/fbdev/vfb.c +8 -3
@@ -78,6 +78,13 @@ static int vfb_pan_display(struct fb_varstatic int vfb_mmap (struct fb_info *info,struct vm_area_struct *vma); +static void vfb_destroy (struct fb_info *info) +{ +vfree (info->screen_buffer); +fb_dealloc_cmap (&info->cmap); +framebuffer_release (info); +} +static const struct fb_ops vfb_ops = { .owner =THIS_MODULE , .fb_read = fb_sys_read,
@@ -90,6 +97,7 @@ static const struct fb_ops vfb_ops = { .fb_copyarea = sys_copyarea, .fb_imageblit = sys_imageblit, .fb_mmap = vfb_mmap, + .fb_destroy = vfb_destroy, };/*
@@ -485,9 +493,6 @@ static void vfb_remove(struct platform_dif (info) {unregister_framebuffer (info); -vfree (videomemory); -fb_dealloc_cmap (&info->cmap); -framebuffer_release (info); } }
Greg Kroah-Hartman
maintainerPATCH 636/1193 inet: frags: invalidate queues before flushing them
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yilin Zhang <[email protected]>
commit b824476c56a153934c67c9e0f873e1fd967743d6 upstream.
fqdir_pre_exit() flushes the skbs from incomplete queues without changing their completion state. A fragment which found a queue before high_thresh was cleared can then acquire the queue lock and reuse stale reassembly metadata. A queue concurrently killed after fqdir->dead is set can instead become INET_FRAG_COMPLETE|INET_FRAG_HASH_DEAD while still holding its old skbs; skipping it because it is complete leaves those references behind until asynchronous fqdir teardown.
For IPv6, stale metadata can make ip6_frag_reasm() use the old nhoffset with a new skb and access memory out of bounds. The resulting heap corruption can be leveraged for local privilege escalation when unprivileged network namespaces are available. Unflushed fragments can also keep conntrack references alive after the conntrack per-net cleanup point.
Kill each incomplete queue, then flush every queue still owned by the dying rhashtable. HASH_DEAD identifies that ownership, while complete queues without it are already owned by another destroy path and must be left alone. Releasing a timer reference removed by inet_frag_kill() is deferred to inet_frag_putn(), after the queue lock is dropped.
KASAN report:
BUG: KASAN: slab-out-of-bounds in ipv6_frag_rcv (net/ipv6/reassembly.c:289 (discriminator 2) net/ipv6/reassembly.c:229 (discriminator 2) net/ipv6/reassembly.c:391 (discriminator 2)) Write of size 1 at addr ff110001039c6e00 by task poc/771 Call Trace: ? ipv6_frag_rcv (net/ipv6/reassembly.c:289 (discriminator 2) net/ipv6/reassembly.c:229 (discriminator 2) net/ipv6/reassembly.c:391 (discriminator 2)) ipv6_frag_rcv (net/ipv6/reassembly.c:289 (discriminator 2) net/ipv6/reassembly.c:229 (discriminator 2) net/ipv6/reassembly.c:391 (discriminator 2)) ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:479 (discriminator 5)) ip6_input_finish (net/ipv6/ip6_input.c:534) ipv6_rcv (include/net/dst.h:480 (discriminator 3) net/ipv6/ip6_input.c:119 (discriminator 3) net/ipv6/ip6_input.c:109 (discriminator 3) include/linux/netfilter.h:325 (discriminator 3) include/linux/netfilter.h:319 (discriminator 3) net/ipv6/ip6_input.c:351 (discriminator 3)) packet_sendmsg (net/packet/af_packet.c:3110 net/packet/af_packet.c:3142) __x64_sys_sendmmsg (net/socket.c:2883 net/socket.c:2880 net/socket.c:2880) The buggy address belongs to the object at ff110001039c6b40 which belongs to the cache skbuff_small_head of size 704 The buggy address is located 0 bytes to the right of allocated 704-byte region [ff110001039c6b40, ff110001039c6e00) BUG: KASAN: slab-out-of-bounds in ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:423 (discriminator 1)) Read of size 1 at addr ff110001039c6e08 by task poc/771 Call Trace: ? ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:423 (discriminator 1)) ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:423 (discriminator 1)) ip6_input_finish (net/ipv6/ip6_input.c:534) ipv6_rcv (include/net/dst.h:480 (discriminator 3) net/ipv6/ip6_input.c:119 (discriminator 3) net/ipv6/ip6_input.c:109 (discriminator 3) include/linux/netfilter.h:325 (discriminator 3) include/linux/netfilter.h:319 (discriminator 3) net/ipv6/ip6_input.c:351 (discriminator 3)) packet_sendmsg (net/packet/af_packet.c:3110 net/packet/af_packet.c:3142) __x64_sys_sendmmsg (net/socket.c:2883 net/socket.c:2880 net/socket.c:2880) packet_sendmsg (net/packet/af_packet.c:2959 net/packet/af_packet.c:3053 net/packet/af_packet.c:3142) __x64_sys_sendmmsg (net/socket.c:2883 net/socket.c:2880 net/socket.c:2880) The buggy address belongs to the object at ff110001039c6b40 which belongs to the cache skbuff_small_head of size 704 The buggy address is located 8 bytes to the right of allocated 704-byte region [ff110001039c6b40, ff110001039c6e00)
--- net/ipv4/inet_fragment.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/inet_fragment.c +6 -0
@@ -237,6 +237,8 @@ void fqdir_pre_exit(struct fqdir *fqdir)rhashtable_walk_start (&hti);while ((fq =rhashtable_walk_next (&hti))) { +int refs =0 ; +if (IS_ERR (fq)) {if (PTR_ERR (fq) != -EAGAIN )break ;
@@ -244,8 +246,12 @@ void fqdir_pre_exit(struct fqdir *fqdir) }spin_lock_bh (&fq->lock);if (!(fq->flags &INET_FRAG_COMPLETE )) +inet_frag_kill (fq, &refs); + +if (fq->flags &INET_FRAG_HASH_DEAD )inet_frag_queue_flush (fq,0 );spin_unlock_bh (&fq->lock); +inet_frag_putn (fq, refs); }rhashtable_walk_stop (&hti);
Greg Kroah-Hartman
maintainerPATCH 637/1193 ieee802154: 6lowpan: fix NULL dereference in lowpan_newlink
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
commit bf79662bc85e820ac3b846e2f347da29fbf6ac95 upstream.
TUNSETLINK allows a TUN device to change its link-layer type to ARPHRD_IEEE802154 without initializing ieee802154_ptr. lowpan_newlink() checks only the device type before dereferencing the pointer, so an RTM_NEWLINK request can trigger a NULL pointer dereference.
Reject devices without ieee802154_ptr along with devices of the wrong type.
--- net/ieee802154/6lowpan/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ieee802154/6lowpan/core.c +1 -1
@@ -146,7 +146,7 @@ static int lowpan_newlink(struct net *sr wdev =dev_get_by_index (dev_net (ldev),nla_get_u32 (tb[IFLA_LINK ]));if (!wdev)return -ENODEV ; -if (wdev->type !=ARPHRD_IEEE802154 ) { +if (wdev->type !=ARPHRD_IEEE802154 || !wdev->ieee802154_ptr) {dev_put (wdev);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 638/1193 ieee802154: hwsim: serialize pib updates to fix double-free
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
commit 979d5b8de8ed4e1f997aef12da5694b99be7b871 upstream.
hwsim_update_pib() does an unserialized read-swap-free of phy->pib:
pib_old = rtnl_dereference(phy->pib); ... rcu_assign_pointer(phy->pib, pib); kfree_rcu(pib_old, rcu);
It assumes the RTNL is held, but ->set_channel is not always called under it: the mac802154 scan worker changes channels via drv_set_channel() without the RTNL. Such an update can race an RTNL-held one on the same phy; both read the same pib_old and both kfree_rcu() it, double-freeing the object. With SLUB percpu sheaves batching kfree_rcu(), this surfaces as a KASAN invalid-free in rcu_free_sheaf().
struct hwsim_phy has no lock for pib. Add one and make the swap atomic with rcu_replace_pointer() under it, dropping the misleading rtnl_dereference().
--- drivers/net/ieee802154/mac802154_hwsim.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ieee802154/mac802154_hwsim.c +7 -3
@@ -72,6 +72,8 @@ struct hwsim_phy {struct ieee802154_hw *hw;u32 idx; +/* Serializes phy->pib_updates. */ +spinlock_t pib_lock;struct hwsim_pib __rcu *pib;bool suspended;
@@ -102,8 +104,6 @@ static int hwsim_update_pib(struct ieee8if (!pib)return -ENOMEM ; - pib_old =rtnl_dereference (phy->pib); - pib->page = page; pib->channel = channel; pib->filt.short_addr = filt->short_addr;
@@ -112,7 +112,10 @@ static int hwsim_update_pib(struct ieee8 pib->filt.pan_coord = filt->pan_coord; pib->filt_level = filt_level; -rcu_assign_pointer (phy->pib, pib); +spin_lock_bh (&phy->pib_lock); + pib_old =rcu_replace_pointer (phy->pib, pib, +lockdep_is_held (&phy->pib_lock)); +spin_unlock_bh (&phy->pib_lock);kfree_rcu (pib_old, rcu);return 0 ; }
@@ -952,6 +955,7 @@ static int hwsim_add_one(struct genl_inf goto err_pib; } +spin_lock_init (&phy->pib_lock); pib->channel =13 ; pib->filt.short_addr =cpu_to_le16 (IEEE802154_ADDR_BROADCAST ); pib->filt.pan_id =cpu_to_le16 (IEEE802154_PANID_BROADCAST );
Greg Kroah-Hartman
maintainerPATCH 639/1193 ipv4: fib: bound automatic table ID allocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
commit efdfb1e27a3328085b79540dfe781d537b576ea1 upstream.
fib_empty_table() probes every table ID from 1 until it finds a free one. IPv4 tables are stored in a 256-bucket hash table, so a dense set of IDs makes each probe walk a growing hash chain while RTNL is held.
Automatic table assignment ("ip rule ... table 0") is an IPv4-only legacy path. Bound the automatically allocated ID to 4096 so the RTNL hold stays bounded, without changing lookups of explicitly specified table IDs.
This changes user-visible behavior. A table-0 rule previously received the lowest free ID in 1..RT_TABLE_MAX (0xFFFFFFFF). After this patch the search stops at 4096 and the rule add fails with ENOBUFS if that range is fully occupied. Explicit table IDs above 4096 remain usable.
The automatic path is unused in practice: it is IPv4-only, not documented by ip-rule, uncovered by kernel selftests, and both NetworkManager and systemd refuse table 0.
--- net/ipv4/fib_rules.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/fib_rules.c +3 -1
@@ -203,6 +203,8 @@ INDIRECT_CALLABLE_SCOPE int fib4_rule_mareturn 1 ; } +#define FIB_MAX_AUTO_TABLE_ID 4096 +static struct fib_table *fib_empty_table (struct net *net) {u32 id =1 ;
@@ -211,7 +213,7 @@ static struct fib_table *fib_empty_tableif (!fib_get_table (net, id))return fib_new_table (net, id); -if (id++ ==RT_TABLE_MAX ) +if (id++ ==FIB_MAX_AUTO_TABLE_ID )break ; }return NULL ;
Greg Kroah-Hartman
maintainerPATCH 640/1193 ipvs: reject invalid states in connection template sync records
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
commit 74cb39735b6cd0aff4b5584158f09376fd97aadf upstream.
IPVS sync receivers validate protocol states before creating or updating a connection. For connection templates, however, they only log states outside the template state range and still store the value in the connection.
A template can be returned by ordinary connection lookup. TCP and SCTP then use the invalid state as an index into their transition tables.
Reject invalid template states in both sync protocol versions before looking up or modifying a connection. The version 1 path handles both IPv4 and IPv6 records.
--- net/netfilter/ipvs/ip_vs_sync.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +8 -8
@@ -1000,10 +1000,10 @@ static void ip_vs_process_message_v0(str pp->name, state);continue ; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , + state); +continue ; } ip_vs_conn_fill_param(ipvs, AF_INET, s->protocol,
@@ -1160,10 +1160,10 @@ static inline int ip_vs_proc_sync_conn(s retc =40 ; goto out; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , state); + retc =40 ; + goto out; }if (ip_vs_conn_fill_param_sync (ipvs, af, s, ¶m, pe_data, pe_data_len, pe_name, pe_name_len)) {
Greg Kroah-Hartman
maintainerPATCH 614/1193 tracing: Free histogram the field rejected for a bad modifier
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 230234d12ce42ab04132a32c3a848f07a5d27a71 upstream.
Writing a hist trigger whose value or variable carries a modifier that is not allowed there leaks the fields that were built for it.
__create_val_field() takes the field from parse_expr() and stores it in hist_data->fields[] only after the modifier checks have run:
hist_field = parse_expr(hist_data, file, field_str, flags, var_name,
&n_subexprs);
...
if (hist_field->flags & HIST_FIELD_FL_VAR) {
if (hist_field->flags & (...))
goto err;
} else {
if (hist_field->flags & (...))
goto err;
}
hist_data->fields[val_idx] = hist_field;Both checks jump past that store, and the err label returns without freeing anything. The error unwinds to create_hist_data(), which calls destroy_hist_data() -> destroy_hist_fields(), and that reaches a field only by walking fields[]. A field that never got there is unreachable.
commit e0213434fe3e ("tracing: Do not let histogram values have some modifiers") set ret to -EINVAL and fell through to the store, which left the field owned by fields[] and freed along with the rest of hist_data. Splitting the check into a value case and a variable case replaced that fall-through with a goto that skips it.
With CONFIG_DEBUG_KMEMLEAK, 200 writes of
# echo 'hist:keys=prev_pid:vals=next_pid.log2' > \ events/sched/sched_switch/trigger
each correctly rejected with -EINVAL, leave 332 unreferenced objects (63744 bytes) reported at create_hist_field(); 200 install and remove cycles of a valid trigger leave none. A '.log2' field is two allocations, since create_hist_field() puts the plain field in operands[0] of the log2 field, and both are reported.
Use destroy_hist_field() rather than __destroy_hist_field() so that operands[0] is freed as well. It returns early for HIST_FIELD_FL_VAR_REF, which is what an operand owned by hist_data->var_refs[] needs; the rejected field itself is never a var ref, because a var ref never carries a modifier flag.
--- kernel/trace/trace_events_hist.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace_events_hist.c +1 -0
@@ -4283,6 +4283,7 @@ static int __create_val_field(struct hisreturn ret; err:hist_err (file->tr,HIST_ERR_BAD_FIELD_MODIFIER ,errpos (field_str)); +destroy_hist_field (hist_field,0 );return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 641/1193 mac802154: fix use-after-free of sdata via queued RX frames
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ibrahim Hashimov <[email protected]>
commit 2f37fba846c9fdff5fc15b6d93656057ccd13031 upstream.
The RX softirq producer ieee802154_subif_frame() queues received beacon and MAC-command frames onto local->rx_beacon_list / rx_mac_cmd_list and schedules a process-context worker, storing a raw mac_pkt->sdata (and skb->dev == sdata->dev) with neither a reference nor any locking:
- the lists have no lock: the softirq producer list_add_tail()s while the mac_wq worker list_del()s, so sibling interfaces on the same phy corrupt the list;
- the workers dereference the interface after it may have been freed. mac802154_rx_mac_cmd_worker() touches mac_pkt->sdata directly, and mac802154_rx_beacon_worker() -> mac802154_process_beacon() dereferences skb->dev (== sdata->dev). Removing an interface frees its sdata (netdev_priv) while a queued frame still points at it, so a later worker run is a use-after-free.
Reproduced under KASAN by flooding a victim interface with MAC command frames and removing it (the beacon path is the same class via skb->dev):
BUG: KASAN: slab-use-after-free in mac802154_rx_mac_cmd_worker+0x463/0x630 [mac802154] Read of size 4 at addr ffff888002f9ea18 by task kworker/u8:1/31 Workqueue: phy0-mac-cmds mac802154_rx_mac_cmd_worker [mac802154] Call Trace: mac802154_rx_mac_cmd_worker+0x463/0x630 [mac802154] process_one_work+0x611/0xe80 worker_thread+0x52e/0xdc0 kthread+0x30c/0x630 ret_from_fork+0x2fd/0x3e0
Fix both lists together:
- add local->rx_lock and take it around every list access: the softirq producer (plain spin_lock, softirq context) and the workers and flush (spin_lock_bh, process context);
- pin the interface for the lifetime of a queued frame with netdev_hold()/netdev_put(), so the worker can safely dereference sdata / skb->dev even while the interface is being removed;
- dequeue under the lock at the head and loop-drain the whole list in the workers (they previously processed one frame per run and relied on a later enqueue to drain the rest);
- drop not-yet-started frames of an interface before it is unregistered, from ieee802154_if_remove() (after the RCU grace period) and from the ieee802154_remove_interfaces() loop -- the latter is the whole-phy teardown path, which does not go through ieee802154_if_remove().
An in-flight worker that already dequeued a frame keeps its own netdev reference; unregister_netdevice() then waits it out in netdev_run_todo(), which runs at rtnl_unlock() (rtnl released) and after the interface has been closed, so it does not pin rtnl. A worker blocked in an association TX only delays that one interface's unregister (the usual "waiting for %s to become free"), it does not hold rtnl. netdev_hold() is used for this reason instead of a cancel_work_sync() under rtnl, which would block on the worker's unbounded MLME TX wait via ieee802154_sync_queue().
The mac-command worker additionally skips processing for a stopped interface (ieee802154_sdata_running()), avoiding a needless association response during teardown.
--- include/net/cfg802154.h | 1 net/mac802154/ieee802154_i.h | 8 ++ net/mac802154/iface.c | 6 ++ net/mac802154/main.c | 1 net/mac802154/rx.c | 120 +++++++++++++++++++++++++++++++++++-------- net/mac802154/scan.c | 10 +-- 6 files changed, 117 insertions(+), 29 deletions(-)
include/net/cfg802154.h +1 -0
@@ -353,6 +353,7 @@ struct cfg802154_mac_pkt {struct list_head node;struct sk_buff *skb;struct ieee802154_sub_if_data *sdata; +netdevice_tracker dev_tracker;u8 page;u8 channel; };
net/mac802154/ieee802154_i.h +8 -0
@@ -73,6 +73,10 @@ struct ieee802154_local {struct work_struct rx_beacon_work;struct list_head rx_mac_cmd_list;struct work_struct rx_mac_cmd_work; +/* Serializes rx_beacon_list and rx_mac_cmd_list against the RX +* softirq producer, the mac_wq workers and the teardown flush. +*/ +spinlock_t rx_lock;bool started;bool suspended;
@@ -295,6 +299,10 @@ static inline bool mac802154_is_beaconin }void mac802154_rx_mac_cmd_worker (struct work_struct *work); +void mac802154_flush_list (struct list_head *list, +struct ieee802154_sub_if_data *sdata); +void mac802154_flush_queued_pkts (struct ieee802154_local *local, +struct ieee802154_sub_if_data *sdata);/* interface handling */ int ieee802154_iface_init (void );
net/mac802154/iface.c +6 -0
@@ -694,6 +694,7 @@ void ieee802154_if_remove(struct ieee802mutex_unlock (&sdata->local->iflist_mtx);synchronize_rcu (); +mac802154_flush_queued_pkts (sdata->local, sdata);unregister_netdevice (sdata->dev); }
@@ -705,6 +706,11 @@ void ieee802154_remove_interfaces(structlist_for_each_entry_safe (sdata, tmp, &local->interfaces, list) {list_del_rcu (&sdata->list); +/* Best-effort: a frame the RX softirq queues for this sdata +* after the flush still pins the netdev, so the +* unregister_netdevice() below waits it out. +*/ +mac802154_flush_queued_pkts (local, sdata);unregister_netdevice (sdata->dev); }mutex_unlock (&local->iflist_mtx);
net/mac802154/main.c +1 -0
@@ -91,6 +91,7 @@ ieee802154_alloc_hw(size_t priv_data_lenINIT_LIST_HEAD (&local->interfaces);INIT_LIST_HEAD (&local->rx_beacon_list);INIT_LIST_HEAD (&local->rx_mac_cmd_list); +spin_lock_init (&local->rx_lock);mutex_init (&local->iflist_mtx);tasklet_setup (&local->tasklet, ieee802154_tasklet_handler);
net/mac802154/rx.c +98 -22
161 lines not on this page · raw message
net/mac802154/scan.c +3 -7
@@ -104,13 +104,9 @@ static unsigned int mac802154_scan_get_cstatic void mac802154_flush_queued_beacons (struct ieee802154_local *local) { -struct cfg802154_mac_pkt *mac_pkt, *tmp; - -list_for_each_entry_safe (mac_pkt, tmp, &local->rx_beacon_list, node) { -list_del (&mac_pkt->node); -kfree_skb (mac_pkt->skb); -kfree (mac_pkt); - } +spin_lock_bh (&local->rx_lock); +mac802154_flush_list (&local->rx_beacon_list,NULL ); +spin_unlock_bh (&local->rx_lock); } static void
Greg Kroah-Hartman
maintainerPATCH 642/1193 KVM: PPC: Book3S HV: Set irqfd->producer only on success
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: leixiang <[email protected]>
commit 1144454ea22290d7c6998a2af6239e5995476afc upstream.
Set irqfd->producer only after kvmppc_set_passthru_irq() succeeds to avoid leaving a dangling pointer on failure. The bypass manager does not register a failed producer, so the pointer is never cleared.
--- arch/powerpc/kvm/book3s_hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_hv.c +2 -2
@@ -5790,12 +5790,12 @@ static int kvmppc_irq_bypass_add_producestruct kvm_kernel_irqfd *irqfd = container_of(cons, struct kvm_kernel_irqfd, consumer); - irqfd->producer = prod; - ret =kvmppc_set_passthru_irq (irqfd->kvm, prod->irq, irqfd->gsi);if (ret)pr_info ("kvmppc_set_passthru_irq (irq %d, gsi %d) fails: %d\n" , prod->irq, irqfd->gsi, ret); +else + irqfd->producer = prod;return ret; }
Greg Kroah-Hartman
maintainerPATCH 643/1193 s390/qeth: allow bridgeport queries despite OS_MISMATCH
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nagamani PV <[email protected]>
commit 74f27fc8642b7e8d139796f8c18ee46df393c2b2 upstream.
When HiperSockets interfaces on the same VCHID span different OS families, reads of the sysfs attributes bridge_role and bridge_state fail with -EPERM if bridge port ownership belongs to another OS family.
As a result, userspace tools such as 'lszdev -ii' cannot retrieve bridge_role and bridge_state, even though firmware returns valid bridge port data for QUERY_BRIDGE_PORTS requests.
The firmware reports IPA_RC_SBP_IQD_OS_MISMATCH (0x0010) to indicate that bridge port ownership belongs to a different OS family. For QUERY_BRIDGE_PORTS operations, firmware still returns valid bridge port data (role=none, state=inactive) together with a primary return code of 0x0000 (success).
Allow QUERY_BRIDGE_PORTS requests to return the bridge port data provided by the firmware despite OS_MISMATCH. To make the OS family mismatch visible to userspace, represent the firmware-reported role "none" as "none (OS family mismatch)" while preserving the reported bridge_state.
The behavior for non-QUERY bridge port commands is unchanged; SET operations continue to return -EPERM when another OS family owns the bridge port.
This restores readability of bridge_role and bridge_state.
--- drivers/s390/net/qeth_l2.h | 3 ++- drivers/s390/net/qeth_l2_main.c | 26 ++++++++++++++++++++++---- drivers/s390/net/qeth_l2_sys.c | 7 ++++++- 3 files changed, 30 insertions(+), 6 deletions(-)
drivers/s390/net/qeth_l2.h +2 -1
@@ -13,7 +13,8 @@ extern const struct attribute_group *qetint qeth_bridgeport_query_ports (struct qeth_card *card,enum qeth_sbp_roles *role, -enum qeth_sbp_states *state); +enum qeth_sbp_states *state, +bool *os_mismatch);int qeth_bridgeport_setrole (struct qeth_card *card,enum qeth_sbp_roles role);int qeth_bridgeport_an_set (struct qeth_card *card,int enable);
drivers/s390/net/qeth_l2_main.c +22 -4
@@ -1157,7 +1157,7 @@ static void qeth_l2_setup_bridgeport_attqeth_bridgeport_setrole (card, card->options.sbp.role);/* Let the callback function refresh the stored role value. */ qeth_bridgeport_query_ports (card, &card->options.sbp.role, -NULL ); +NULL ,NULL ); }if (card->options.sbp.hostnotification) {if (qeth_bridgeport_an_set (card,1 ))
@@ -1544,6 +1544,7 @@ struct _qeth_sbp_cbctl {struct {enum qeth_sbp_roles *role;enum qeth_sbp_states *state; +bool *os_mismatch; } qports; } data; };
@@ -1720,10 +1721,19 @@ static int qeth_bridgeport_query_ports_cstruct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;struct qeth_sbp_port_data *qports; +u16 sbp_rc;int rc;QETH_CARD_TEXT (card,2 ,"brqprtcb" ); - rc =qeth_bridgeport_makerc (card, cmd); + sbp_rc = cmd->data.sbp.hdr.return_code; + +/* on OS family mismatch, query still returns valid port data; +* treat as success +*/ +if (sbp_rc ==IPA_RC_SBP_IQD_OS_MISMATCH && !cmd->hdr.return_code) + rc =0 ; +else + rc =qeth_bridgeport_makerc (card, cmd);if (rc)return rc;
@@ -1739,6 +1749,9 @@ static int qeth_bridgeport_query_ports_cif (cbctl->data.qports.state) *cbctl->data.qports.state = qports->entry[0 ].state; } +if (cbctl->data.qports.os_mismatch) + *cbctl->data.qports.os_mismatch = + (sbp_rc ==IPA_RC_SBP_IQD_OS_MISMATCH );return 0 ; }
@@ -1747,13 +1760,17 @@ static int qeth_bridgeport_query_ports_c* @card: qeth_card structure pointer. * @role: Role of the port: 0-none, 1-primary, 2-secondary. * @state: State of the port: 0-inactive, 1-standby, 2-active. +* @os_mismatch: if non-NULL, set to true when firmware reports +* OS family mismatch. * * Returns negative errno-compatible error indication or 0 on success. * -* 'role' and 'state' are not updated in case of hardware operation failure. +* 'role', 'state' and 'os_mismatch' are not updated in case of +* hardware operation failure. */ int qeth_bridgeport_query_ports (struct qeth_card *card, -enum qeth_sbp_roles *role,enum qeth_sbp_states *state) +enum qeth_sbp_roles *role,enum qeth_sbp_states *state, +bool *os_mismatch) {struct qeth_cmd_buffer *iob;struct _qeth_sbp_cbctl cbctl = {
@@ -1761,6 +1778,7 @@ int qeth_bridgeport_query_ports(struct q .qports = { .role = role, .state = state, + .os_mismatch = os_mismatch, }, }, };
drivers/s390/net/qeth_l2_sys.c +6 -1
@@ -15,6 +15,7 @@ static ssize_t qeth_bridge_port_role_sta {struct qeth_card *card =dev_get_drvdata (dev);enum qeth_sbp_states state =QETH_SBP_STATE_INACTIVE ; +bool os_mismatch = false;int rc =0 ;char *word;
@@ -25,7 +26,7 @@ static ssize_t qeth_bridge_port_role_staif (qeth_card_hw_is_reachable (card) && card->options.sbp.supported_funcs) rc =qeth_bridgeport_query_ports (card, - &card->options.sbp.role, &state); + &card->options.sbp.role, &state, &os_mismatch);if (!rc) {if (show_state)switch (state) {
@@ -52,6 +53,10 @@ static ssize_t qeth_bridge_port_role_staif (rc)QETH_CARD_TEXT_ (card,2 ,"SBP%02x:%02x" , card->options.sbp.role, state); +else if (!show_state && + card->options.sbp.role ==QETH_SBP_ROLE_NONE && + os_mismatch) + rc =sysfs_emit (buf,"%s (OS family mismatch)\n" , word);else rc =sysfs_emit (buf,"%s\n" , word); }
Greg Kroah-Hartman
maintainerPATCH 644/1193 s390/crypto: Fix missing scrub of temp buffers with AES ctr and gcm algorithm
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
commit 8b7c3b6914f19caf648d05726a86af6326d3c2c6 upstream.
In function ctr_aes_crypt() there is a buffer used to process remaining bytes < AES_BLOCK_SIZE. This buffer was not scrubbed and thus could lead to expose of unwanted data. When the buffer is used explicitly scrub it at the end of the code block to avoid exposure of maybe sensitive data.
In a similar way the function gcm_aes_crypt() hat an error path where the CPACF param block was not scrubbed. Instead of return early now these error paths go to end of function where explicit scrubbing is done. Similar with the buffers which are part of the gcm_sg_walk structs from the variables gw_in and gw_out.
--- arch/s390/crypto/aes_s390.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
arch/s390/crypto/aes_s390.c +12 -4
@@ -604,6 +604,7 @@ static int ctr_aes_crypt(struct skciphermemcpy (walk.dst.virt.addr, buf, nbytes);crypto_inc (walk.iv,AES_BLOCK_SIZE ); ret =skcipher_walk_done (&walk,0 ); +memzero_explicit (buf,sizeof (buf)); }return ret;
@@ -905,10 +906,14 @@ static int gcm_aes_crypt(struct aead_req gw_in.ptr, aad_bytes); n = aad_bytes + pc_bytes; -if (gcm_in_walk_done (&gw_in, n) != n) -return -ENOMEM ; -if (gcm_out_walk_done (&gw_out, n) != n) -return -ENOMEM ; +if (gcm_in_walk_done (&gw_in, n) != n) { + ret = -ENOMEM ; + goto out; + } +if (gcm_out_walk_done (&gw_out, n) != n) { + ret = -ENOMEM ; + goto out; + } aadlen -= aad_bytes; pclen -= pc_bytes; }while (aadlen + pclen >0 );
@@ -920,7 +925,10 @@ static int gcm_aes_crypt(struct aead_req }else scatterwalk_map_and_copy (param.t, req->dst, len, taglen,1 ); +out:memzero_explicit (¶m,sizeof (param)); +memzero_explicit (gw_in.buf,sizeof (gw_in.buf)); +memzero_explicit (gw_out.buf,sizeof (gw_out.buf));return ret; }
Greg Kroah-Hartman
maintainerPATCH 645/1193 hwmon: (applesmc) fix key backlight workqueue leak on register failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
commit 5a0aacaa2d593d7582ecfe289529b937b6dc5d3c upstream.
applesmc_create_key_backlight() allocates applesmc_led_wq before calling led_classdev_register(). When register fails, the error is returned to applesmc_init(), which jumps to out_light_sysfs and skips applesmc_release_key_backlight(), leaking the workqueue.
Destroy the workqueue on the register failure path. The bug was introduced when the inline init block was refactored into a helper that returns errors directly, dropping the old out_light_wq unwind label.
--- drivers/hwmon/applesmc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hwmon/applesmc.c +6 -1
@@ -1249,12 +1249,17 @@ static void applesmc_release_light_sensostatic int applesmc_create_key_backlight (void ) { +int ret; +if (!smcreg.has_key_backlight)return 0 ; applesmc_led_wq =create_singlethread_workqueue ("applesmc-led" );if (!applesmc_led_wq)return -ENOMEM ; -return led_classdev_register (&pdev->dev, &applesmc_backlight); + ret =led_classdev_register (&pdev->dev, &applesmc_backlight); +if (ret) +destroy_workqueue (applesmc_led_wq); +return ret; }static void applesmc_release_key_backlight (void )
Greg Kroah-Hartman
maintainerPATCH 646/1193 hwmon: (gpio-fan) Fix use-after-free in alarm work
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit a2471ed17b0e6ff7bfb6b2ea8e6e5b04c309d293 upstream.
fan_alarm_irq_handler() queues fan_data->alarm_work, but nothing cancels it. fan_alarm_notify() dereferences fan_data and its hwmon device. On unbind, devres frees the interrupt, which only waits for the handler itself, and then releases the hwmon device and fan_data, so a pending fan_alarm_notify() can run after those frees.
Replace INIT_WORK() with devm_work_autocancel(), registered before devm_request_irq(). The devres cleanup then frees the interrupt first, so no new work can be queued, and cancels the work while fan_data and the hwmon device are still alive.
This issue was found by an in-house static analysis tool.
--- drivers/hwmon/gpio-fan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/hwmon/gpio-fan.c +7 -1
@@ -12,6 +12,7 @@#include <linux/slab.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <linux/devm-helpers.h> #include <linux/platform_device.h> #include <linux/err.h> #include <linux/kstrtox.h>
@@ -80,6 +81,7 @@ static DEVICE_ATTR_RO(fan1_alarm);static int fan_alarm_init (struct gpio_fan_data *fan_data) {int alarm_irq; +int err;struct device *dev = fan_data->dev;/*
@@ -90,7 +92,11 @@ static int fan_alarm_init(struct gpio_faif (alarm_irq <=0 )return 0 ; -INIT_WORK (&fan_data->alarm_work, fan_alarm_notify); + err =devm_work_autocancel (dev, &fan_data->alarm_work, + fan_alarm_notify); +if (err) +return err; +irq_set_irq_type (alarm_irq,IRQ_TYPE_EDGE_BOTH );return devm_request_irq (dev, alarm_irq, fan_alarm_irq_handler,IRQF_SHARED ,"GPIO fan alarm" , fan_data);
Greg Kroah-Hartman
maintainerPATCH 647/1193 hwmon: (pmbus) Clear generic status alarms with CLEAR_FAULTS
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Razdan <[email protected]>
commit 6d760f8b41aed74de4402440e4db663d261478bd upstream.
Some hwmon alarms fall back to STATUS_WORD summary bits when no individual limit alarm is available. On PMBus 1.2 and newer devices, pmbus_get_boolean() acknowledges these alarms with the same byte-data write used for detailed status registers. For example, PB_STATUS_INPUT is 0x2000, so it is truncated to zero when passed to _pmbus_write_byte_data(). The resulting write cannot acknowledge the input alarm.
PMBus 1.3 Part II, sections 10.2.4 and 10.2.5, excludes ordinary STATUS_BYTE and STATUS_WORD summary bits from individual clearing. Their summary bits clear when the underlying status bits clear, so changing this to a word-data write would not fix the generic input alarm either.
Use the existing page CLEAR_FAULTS path for generic STATUS_WORD alarms, including devices whose status accessor uses STATUS_BYTE. Keep individual byte writes for detailed status registers on PMBus 1.2 and newer devices. As with the existing older-device fallback, CLEAR_FAULTS can clear other latched status; an active condition can reassert its status.
--- drivers/hwmon/pmbus/pmbus_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/pmbus/pmbus_core.c +3 -1
@@ -1103,7 +1103,9 @@ static int pmbus_get_boolean(struct i2c_ regval = status & mask;if (regval) { -if (data->revision >=PMBUS_REV_12 ) { +/* Generic STATUS_WORD alarms are not individually clearable. */ +if (data->revision >=PMBUS_REV_12 && + reg !=PMBUS_STATUS_WORD ) { ret =_pmbus_write_byte_data (client, page, reg, regval);if (ret) goto unlock;
Greg Kroah-Hartman
maintainerPATCH 648/1193 media: hevc: add bounded tile-count helpers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 592dd4f8442a13bed6e946d73d3164ba38b33bbd upstream.
The stateless HEVC decoders compute the number of tile columns and rows from num_tile_columns_minus1 / num_tile_rows_minus1 and clamp it to the column_width_minus1[] / row_height_minus1[] capacity before using it as a loop bound. Add shared helpers in a new <media/v4l2-hevc.h> so the rkvdec and hantro drivers do not each open-code the min_t() clamp.
--- include/media/v4l2-hevc.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/media/v4l2-hevc.h
include/media/v4l2-hevc.h new file +41 -0
@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Helper functions for HEVC stateless codecs. +*/ + +#ifndef _MEDIA_V4L2_HEVC_H +#define _MEDIA_V4L2_HEVC_H + +#include <linux/minmax.h> +#include <media/v4l2-ctrls.h> + +/** +* v4l2_hevc_pps_num_tile_columns - number of HEVC tile columns, bounded +* @pps: the V4L2 HEVC PPS control +* +* Return the number of tile columns (num_tile_columns_minus1 + 1) clamped to +* the capacity of column_width_minus1[]. The control validation already +* rejects out-of-range counts; this keeps the consuming drivers bounded too. +*/ +static inline unsigned int +v4l2_hevc_pps_num_tile_columns (const struct v4l2_ctrl_hevc_pps *pps) +{ + return min_t(unsigned int, pps->num_tile_columns_minus1 + 1, +ARRAY_SIZE (pps->column_width_minus1)); +} + +/** +* v4l2_hevc_pps_num_tile_rows - number of HEVC tile rows, bounded +* @pps: the V4L2 HEVC PPS control +* +* Return the number of tile rows (num_tile_rows_minus1 + 1) clamped to the +* capacity of row_height_minus1[]. +*/ +static inline unsigned int +v4l2_hevc_pps_num_tile_rows (const struct v4l2_ctrl_hevc_pps *pps) +{ + return min_t(unsigned int, pps->num_tile_rows_minus1 + 1, +ARRAY_SIZE (pps->row_height_minus1)); +} + +#endif /* _MEDIA_V4L2_HEVC_H */
Greg Kroah-Hartman
maintainerPATCH 649/1193 media: verisilicon: hantro: bound G2 HEVC tile loop to the buffer capacity
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 06236b094c899c22c12ac5097935eb6719293de8 upstream.
prepare_tile_info_buffer() writes one entry per tile into the tile_sizes DMA buffer, sized for a grid equal to the PPS uAPI array capacity. Use the bounded v4l2_hevc_pps_num_tile_columns() / v4l2_hevc_pps_num_tile_rows() helpers so the loops stay inside the buffer.
--- drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c +4 -2
@@ -5,6 +5,8 @@* Copyright (C) 2020 Safran Passenger Innovations LLC */ +#include <media/v4l2-hevc.h> +#include "hantro_hw.h" #include "hantro_g2_regs.h"
@@ -15,8 +17,8 @@ static void prepare_tile_info_buffer(strconst struct v4l2_ctrl_hevc_pps *pps = ctrls->pps;const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps;u16 *p = (u16 *)((u8 *)ctx->hevc_dec.tile_sizes.cpu); -unsigned int num_tile_rows = pps->num_tile_rows_minus1 +1 ; -unsigned int num_tile_cols = pps->num_tile_columns_minus1 +1 ; +unsigned int num_tile_rows =v4l2_hevc_pps_num_tile_rows (pps); +unsigned int num_tile_cols =v4l2_hevc_pps_num_tile_columns (pps);unsigned int pic_width_in_ctbs, pic_height_in_ctbs;unsigned int max_log2_ctb_size, ctb_size;bool tiles_enabled, uniform_spacing;
Greg Kroah-Hartman
maintainerPATCH 650/1193 media: mediatek: vcodec: bound AV1 tile-start copy to the array capacity
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 37bef2170d4c88fc3d708eecf3ef0f4032bc1372 upstream.
vdec_av1_slice_setup_tile() copies tile_cols + 1 / tile_rows + 1 entries into mi_col_starts[] / mi_row_starts[] from the bitstream tile_info. Bound the copy to the array capacity.
--- .../mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c +3 -2
@@ -1299,11 +1299,12 @@ static void vdec_av1_slice_setup_tile(struct vdec_av1_slice_frame *frame, tile->uniform_tile_spacing_flag =BIT_FLAG (ctrl_tile,V4L2_AV1_TILE_INFO_FLAG_UNIFORM_TILE_SPACING ); -for (i =0 ; i < tile->tile_cols +1 ; i++) +/* Bound the copy to the mi_col_starts[]/mi_row_starts[] capacity. */ +for (i =0 ; i < tile->tile_cols +1 && i <V4L2_AV1_MAX_TILE_COLS +1 ; i++) tile->mi_col_starts[i] =ALIGN (ctrl_tile->mi_col_starts[i],BIT (mib_size_log2)) >> mib_size_log2; -for (i =0 ; i < tile->tile_rows +1 ; i++) +for (i =0 ; i < tile->tile_rows +1 && i <V4L2_AV1_MAX_TILE_ROWS +1 ; i++) tile->mi_row_starts[i] =ALIGN (ctrl_tile->mi_row_starts[i],BIT (mib_size_log2)) >> mib_size_log2; }
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 615/1193 tracing: Let histogram values keep the percent and graph modifiers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 3d617bfd79330ae3acf94862c18bb3ccf5f5a0f9 upstream.
The .percent and .graph modifiers exist only for histogram values, but a value carrying either of them has been rejected since v6.3. The example in Documentation/trace/histogram.rst,
# echo 'hist:keys=prev_comm:vals=hitcount.percent:nohitcount' > \ events/sched/sched_switch/trigger
returns -EINVAL.
parse_field() sets the two flags only when the field is neither a key nor a variable, that is, only on a value:
} else if (strncmp(modifier, "percent", 7) == 0) {
if (*flags & (HIST_FIELD_FL_VAR | HIST_FIELD_FL_KEY))
goto error;
*flags |= HIST_FIELD_FL_PERCENT;__create_val_field() then rejects a value for carrying them, so no field can reach hist_trigger_print_val(), where both are implemented.
commit e0213434fe3e ("tracing: Do not let histogram values have some modifiers") added the check after a value with .buckets oopsed in hist_field_name(). That happens because .buckets and .log2 make create_hist_field() build a nested field in operands[0] which hist_field_name() then walks into. The percent and graph flags do not create an operand and are not read by hist_field_name(); they are only used when printing a value.
Stop rejecting the two flags on a value. The check for variables is left alone, where they are unreachable anyway because parse_field() rejects a variable carrying them first.
With the two flags removed, the trigger above installs and prints as documented:
{ prev_comm: rcu_preempt } hitcount (%): 0.00
{ prev_comm: init } hitcount (%): 99.98
Totals:
Hits: 237896--- kernel/trace/trace_events_hist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/trace/trace_events_hist.c +1 -2
@@ -4265,8 +4265,7 @@ static int __create_val_field(struct his goto err; }else {/* Value */ -if (hist_field->flags & (HIST_FIELD_FL_GRAPH |HIST_FIELD_FL_PERCENT | -HIST_FIELD_FL_BUCKET |HIST_FIELD_FL_LOG2 | +if (hist_field->flags & (HIST_FIELD_FL_BUCKET |HIST_FIELD_FL_LOG2 |HIST_FIELD_FL_SYM |HIST_FIELD_FL_SYM_OFFSET |HIST_FIELD_FL_SYSCALL |HIST_FIELD_FL_STACKTRACE )) goto err;
Greg Kroah-Hartman
maintainerPATCH 651/1193 media: v4l2-h264: Fix memcmp() size in B1 reference list comparison
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
commit 10e59fbdef13597836bd6459095caa02c80af3d7 upstream.
In v4l2_h264_build_b_ref_lists(), the B0/B1 list equality check passes the entry count builder->num_valid to memcmp() instead of a byte size. Since struct v4l2_h264_reference is two bytes (fields and index), only half of each list is compared, so distinct lists can be wrongly treated as equal and trigger an incorrect swap(b1_reflist[0], b1_reflist[1]).
Change the memcmp() size argument to sizeof(b1_reflist[0]) * builder->num_valid so that the full byte length of both reference lists is compared.
--- drivers/media/v4l2-core/v4l2-h264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-h264.c +2 -1
@@ -440,7 +440,8 @@ v4l2_h264_build_b_ref_lists(const struct }if (builder->num_valid >1 && - !memcmp (b1_reflist, b0_reflist, builder->num_valid)) + !memcmp (b1_reflist, b0_reflist, +sizeof (b1_reflist[0 ]) * builder->num_valid))swap (b1_reflist[0 ], b1_reflist[1 ]);print_ref_list_b (builder, b0_reflist,0 );
Greg Kroah-Hartman
maintainerPATCH 652/1193 media: verisilicon: rockchip: guard VPU981 AV1 divisor and tile buffer
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit b84f6533a8ed2fd7b282fc7ab4b8efadc745a89c upstream.
rockchip_vpu981_av1_dec_set_tile_info() divides context_update_tile_id by tile_info->tile_cols and writes one descriptor per tile into the tile_info DMA buffer, which holds AV1_MAX_TILES entries; tile_cols and tile_rows come from the bitstream. Guard the division against a zero tile_cols by initialising the context-update values to zero and computing them only when tile_cols is non-zero, and stop the descriptor writes once the tile_info buffer is full. The tile geometry written to the hardware registers is left unmodified; the per-dimension and total tile bounds are enforced by the control validation.
--- drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 32 ++++++++-- 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +26 -6
@@ -577,16 +577,30 @@ static void rockchip_vpu981_av1_dec_set_const struct v4l2_av1_tile_info *tile_info = &ctrls->frame->tile_info;const struct v4l2_ctrl_av1_tile_group_entry *group_entry = ctrls->tile_group_entry; -int context_update_y = - tile_info->context_update_tile_id / tile_info->tile_cols; -int context_update_x = - tile_info->context_update_tile_id % tile_info->tile_cols; -int context_update_tile_id = - context_update_x * tile_info->tile_rows + context_update_y; +int context_update_y =0 ; +int context_update_x =0 ; +int context_update_tile_id =0 ;u8 *dst = av1_dec->tile_info.cpu; +u8 *dst_end = dst + av1_dec->tile_info.size;struct hantro_dev *vpu = ctx->dev;int tile0, tile1; +/* +* tile_cols and tile_rows are bounded by the V4L2 control validation +* (V4L2_AV1_MAX_TILE_{COLS,ROWS} and V4L2_AV1_MAX_TILE_COUNT). Guard +* the divisor here, and keep the descriptor writes within the +* AV1_MAX_TILES tile_info buffer below; the register values use the +* unmodified tile geometry. +*/ +if (tile_info->tile_cols) { + context_update_y = + tile_info->context_update_tile_id / tile_info->tile_cols; + context_update_x = + tile_info->context_update_tile_id % tile_info->tile_cols; + context_update_tile_id = + context_update_x * tile_info->tile_rows + context_update_y; + } +memset (dst,0 , av1_dec->tile_info.size);for (tile0 =0 ; tile0 < tile_info->tile_cols; tile0++) {
@@ -597,6 +611,10 @@ static void rockchip_vpu981_av1_dec_set_ tile_info->height_in_sbs_minus_1[tile1] +1 ;u32 x0 = tile_info->width_in_sbs_minus_1[tile0] +1 ; +/* Stop once the tile_info descriptor buffer is full. */ +if (dst +16 > dst_end) +break ; +/* tile size in SB units (width,height) */ *dst++ = x0; *dst++ =0 ;
@@ -621,6 +639,8 @@ static void rockchip_vpu981_av1_dec_set_ *dst++ = (end >>16 ) &255 ; *dst++ = (end >>24 ) &255 ; } +if (dst +16 > dst_end) +break ; }hantro_reg_write (vpu, &av1_multicore_expect_context_update, !!(context_update_x ==0 ));
Greg Kroah-Hartman
maintainerPATCH 653/1193 media: verisilicon: rockchip: reject AV1 frames exceeding the tile capacity
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 367db8b23c26a913d76ed70457bbcd781c422b49 upstream.
rockchip_vpu981_av1_dec_set_tile_info() indexes the tile group entry array by tile1 * tile_cols + tile0, reading up to tile_cols * tile_rows entries, lays out one descriptor per tile in the AV1_MAX_TILES tile_info buffer, and programs the real tile_cols / tile_rows into the hardware.
The tile group entry control is a dynamic array sized to the number of entries userspace submitted, independent of tile_cols / tile_rows, so a frame that claims more tiles than entries reads past the array. A frame that claims more than AV1_MAX_TILES tiles also leaves the hardware programmed for more tiles than the descriptor buffer holds.
Reject both in prepare_run(): tile_cols * tile_rows must not exceed the submitted entry count or AV1_MAX_TILES. The entry count is read via v4l2_ctrl_find() (ctrl->elems). This mirrors the bound the mediatek AV1 decoder already enforces.
--- drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 25 ++++++++-- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +22 -3
@@ -430,20 +430,39 @@ static int rockchip_vpu981_av1_dec_prepa {struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;struct hantro_av1_dec_ctrls *ctrls = &av1_dec->ctrls; +const struct v4l2_av1_tile_info *tile_info; +struct v4l2_ctrl *tge; +u32 num_tiles; ctrls->sequence =hantro_get_ctrl (ctx,V4L2_CID_STATELESS_AV1_SEQUENCE );if (WARN_ON (!ctrls->sequence))return -EINVAL ; - ctrls->tile_group_entry = -hantro_get_ctrl (ctx,V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY ); -if (WARN_ON (!ctrls->tile_group_entry)) + tge =v4l2_ctrl_find (&ctx->ctrl_handler, +V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY ); +if (WARN_ON (!tge))return -EINVAL ; + ctrls->tile_group_entry = tge->p_cur.p; ctrls->frame =hantro_get_ctrl (ctx,V4L2_CID_STATELESS_AV1_FRAME );if (WARN_ON (!ctrls->frame))return -EINVAL ; +/* +* rockchip_vpu981_av1_dec_set_tile_info() indexes the tile group +* entry array by tile1 * tile_cols + tile0, so it reads up to +* tile_cols * tile_rows entries, and lays out one descriptor per tile +* in the AV1_MAX_TILES tile_info buffer while programming the real +* tile geometry into the hardware. Reject a frame that claims more +* tiles than userspace submitted, or more than the hardware tile +* buffer holds, so the read stays in bounds and the programmed +* geometry matches the descriptors written. +*/ + tile_info = &ctrls->frame->tile_info; + num_tiles = (u32 )tile_info->tile_cols * tile_info->tile_rows; +if (num_tiles > tge->elems || num_tiles >AV1_MAX_TILES ) +return -EINVAL ; + ctrls->film_grain =hantro_get_ctrl (ctx,V4L2_CID_STATELESS_AV1_FILM_GRAIN );
Greg Kroah-Hartman
maintainerPATCH 654/1193 media: v4l2-ctrls: validate HEVC tile counts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit dc694a9929f7cb9c88ef91e45eb982b7bbe5a477 upstream.
The stateless HEVC decoders read num_tile_columns_minus1 + 1 entries from column_width_minus1[] and num_tile_rows_minus1 + 1 from row_height_minus1[] and use them as tile-loop bounds, but std_validate_compound() does not bound these u8 counts. Reject a V4L2_CTRL_TYPE_HEVC_PPS with tiling enabled whose tile counts exceed the uAPI array capacity, mirroring the existing compound-control range checks.
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls-core.c +12 -0
@@ -1080,6 +1080,18 @@ static int std_validate_compound(const s p_hevc_pps->flags &= ~V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED ; + }else { +/* +* These count the entries the stateless HEVC drivers +* read from column_width_minus1[] / row_height_minus1[] +* and use as tile-loop bounds. +*/ +if (p_hevc_pps->num_tile_columns_minus1 >= +ARRAY_SIZE (p_hevc_pps->column_width_minus1)) +return -EINVAL ; +if (p_hevc_pps->num_tile_rows_minus1 >= +ARRAY_SIZE (p_hevc_pps->row_height_minus1)) +return -EINVAL ; } if (p_hevc_pps->flags &
Greg Kroah-Hartman
maintainerPATCH 655/1193 media: v4l2-ctrls: validate AV1 tile counts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 439058ced617fbb3febc017b9e93bb7387f309e0 upstream.
The stateless AV1 decoders use tile_info.tile_cols and tile_rows as loop bounds and as indices into the mi_*_starts[] and *_in_sbs_minus_1[] arrays, as the divisor for context_update_tile_id, and their product bounds the per-tile descriptor buffers, but std_validate_compound() does not bound these u8 fields. Reject a V4L2_CTRL_TYPE_AV1_FRAME whose tile_cols or tile_rows exceeds V4L2_AV1_MAX_TILE_COLS / _ROWS, or whose product exceeds V4L2_AV1_MAX_TILE_COUNT. A zero tile count is left to the consuming driver so the zero-initialised control that existing userspace submits is still accepted.
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls-core.c +20 -0
@@ -705,10 +705,30 @@ static int validate_av1_film_grain(strucreturn 0 ; } +static int validate_av1_tile_info (struct v4l2_av1_tile_info *t) +{ +/* +* tile_cols and tile_rows index the per-tile descriptor arrays and +* bound the tile loops in the stateless AV1 drivers; the product +* bounds the total tile descriptor count. +*/ +if (t->tile_cols >V4L2_AV1_MAX_TILE_COLS || + t->tile_rows >V4L2_AV1_MAX_TILE_ROWS ) +return -EINVAL ; + +if ((u32 )t->tile_cols * t->tile_rows >V4L2_AV1_MAX_TILE_COUNT ) +return -EINVAL ; + +return 0 ; +} +static int validate_av1_frame (struct v4l2_ctrl_av1_frame *f) {int ret =0 ; + ret =validate_av1_tile_info (&f->tile_info); +if (ret) +return ret; ret =validate_av1_quantization (&f->quantization);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 656/1193 bnxt_en: Only restore LRO if the device supports TPA
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
commit 4e17b5007b6664559cdad2b2fe270526cf786b5b upstream.
With a P5+ device with firmware that reports max_aggs_supported == 0, it is possible to make LRO settable by attaching and detaching an XDP program even though the device does not support TPA.
Fix this by testing BNXT_SUPPORTS_TPA before restoring the feature bit.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -1
@@ -4045,7 +4045,8 @@ void bnxt_set_rx_skb_mode(struct bnxt *bbnxt_get_max_rings (bp, &rx, &tx, true);if (rx >1 ) { bp->flags &= ~BNXT_FLAG_NO_AGG_RINGS ; - bp->dev->hw_features |=NETIF_F_LRO ; +if (BNXT_SUPPORTS_TPA (bp)) + bp->dev->hw_features |=NETIF_F_LRO ; } }
Greg Kroah-Hartman
maintainerPATCH 657/1193 bnxt_en: Handle buffer allocation failure in bnxt_rx_ring_reset()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
commit 961e2a17c5e3559b3f8654d2daabdd25a42e770a upstream.
bnxt_rx_ring_reset() frees the ring buffers and then reallocates them, ignoring the result.
bnxt_alloc_one_rx_ring() can fail in bnxt_alloc_one_tpa_info_data(), which returns -ENOMEM on the first failed allocation and leaves the remaining rxr->rx_tpa[] entries zeroed.
The error isn't propagated up, so the loop in bnxt_rx_ring_reset continues and at the end the code re-enables TPA with partially unallocated rx_tpa array.
This means that when the agg_id from hardware is mapped to a SW index in rxr->rx_tpa[], an uninitialized slot can be chosen which would hand a zero DMA address to the device.
Fix this by falling back to a global reset, which is what the existing code already does when other functions fail, but unlike the other failure cases this particular failure has to return because TPA can't be re-enabled since the allocation failed.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -1
@@ -11827,7 +11827,14 @@ static void bnxt_rx_ring_reset(struct bn rxr->rx_sw_agg_prod =0 ; rxr->rx_next_cons =0 ; rxr->bnapi->in_reset = false; -bnxt_alloc_one_rx_ring (bp, i); + rc =bnxt_alloc_one_rx_ring (bp, i); +if (rc) { +netdev_warn (bp->dev,"RX ring reset failed to allocate buffers, rc = %d, falling back to global reset\n" , + rc); +bnxt_reset_task (bp, true); +bnxt_rtnl_unlock_sp (bp); +return ; + } cpr = &rxr->bnapi->cp_ring; cpr->sw_stats.rx.rx_resets++;if (bp->flags &BNXT_FLAG_AGG_RINGS )
Greg Kroah-Hartman
maintainerPATCH 658/1193 bnxt_en: Propagate RX ring init failures in bnxt_init_nic()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
commit 8e6a850c0746bb4be167aedf1ee57469fcda09a9 upstream.
bnxt_init_rx_rings() returns an error when bnxt_alloc_one_rx_ring() fails, but bnxt_init_nic() discards that return value and calls bnxt_init_chip(), which enables TPA.
If an allocation fails, this could leave rxr->rx_tpa[] partially zeroed and TPA would be enabled over an array with zeroed entries. This would lead to a zeroed DMA address being handed out if the agg_idx is translated to a SW index at a zeroed entry.
Fix this by propagating the error out of bnxt_init_nic(). Both callers already check its return value and unwind with bnxt_free_skbs() and bnxt_free_mem(), which tolerate a partially initialized RX ring.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -1
@@ -8946,8 +8946,13 @@ static int bnxt_shutdown_nic(struct bnxtstatic int bnxt_init_nic (struct bnxt *bp,bool irq_re_init) { +int rc; +bnxt_init_cp_rings (bp); -bnxt_init_rx_rings (bp); + rc =bnxt_init_rx_rings (bp); +if (rc) +return rc; +bnxt_init_tx_rings (bp);bnxt_init_ring_grps (bp, irq_re_init);bnxt_init_vnics (bp);
Greg Kroah-Hartman
maintainerPATCH 659/1193 mptcp: options: handle MPC data + csum reqd + no csum
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit ab36b1a80942c78ddb04d006ff38aa7ed3ec0e5e upstream.
Before this modification, a remote peer could send an MP_CAPABLE with data, with the checksum flag set, but without adding the actual 2 bytes of checksum. As a result, uninitialised bytes could be used for the 'csum' field.
That was not a critical issue, because this 'csum' field is only used to compare with the expected one, if previously negotiated in the 3WHS. Worst case, the checksum is likely wrong, a fallback is done without a reject if the negotiation was done earlier. That's OK.
Yet, better to take the expected path with this case: only look at the checksum flag for MP_CAPABLEs not carrying a data-len.
Such packet can be seen as a 3rd or 4th ACK. The RFC8684 mentions [1] that the 3rd packet should have the checksum flag set. When an MPC + ACK contains data, the checksum flag is redundant with the checksum field. It is not clear what should be done for the 4th ACK, nor if the flag has to be set if the checksum field is set.
Therefore, it seems fine to only look at the presence of the checksum field, not to break the interaction with stacks that were not setting both.
Note that linked to this checksum flag on the 3rd ACK, with the current implementation, we can have a situation where the SYN packets have no checksum flag, but the 3rd ACK has one, and this is the one that will be taken into account. First, that's clearly not directly linked to this patch, but Clashiko forced us to look at that. At the end, that seems fine to act like that: yes that's not how the negotiation should work, but being flexible without introducing side effects is also fine: fixing this would mean increasing the complexity, and that's not worth it.
--- net/mptcp/options.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mptcp/options.c +2 -1
@@ -93,7 +93,8 @@ static void mptcp_parse_option(const str* In other words, the only way for checksums not to be used * is if both hosts in their SYNs set A=0." */ -if (flags &MPTCP_CAP_CHECKSUM_REQD ) +if ((flags &MPTCP_CAP_CHECKSUM_REQD ) && + opsize <TCPOLEN_MPTCP_MPC_ACK_DATA ) mp_opt->suboptions |=OPTION_MPTCP_CSUMREQD ; mp_opt->deny_join_id0 = !!(flags &MPTCP_CAP_DENY_JOIN_ID0 );
Greg Kroah-Hartman
maintainerPATCH 616/1193 tracing: Keep the entry count when the histogram stats allocation fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 06f5634ec5584954177f9a22e36b3bfb398a971b upstream.
print_entries() uses n_entries both as the number of sort entries and as its own return value, so the -ENOMEM it stores when the stats allocation fails overwrites the count that the cleanup still needs:
n_entries = tracing_map_sort_entries(map, ...);
if (n_entries < 0)
return n_entries;
...
if (!stats) {
n_entries = -ENOMEM;
goto out;
}
...
out:
tracing_map_destroy_sort_entries(sort_entries, n_entries);tracing_map_destroy_sort_entries() takes an unsigned int and loops up to it, so -ENOMEM arrives as 4294967284. It walks an array of at most map->max_elts pointers and calls destroy_sort_entry(), which dereferences and frees, on whatever lies past the end.
Reading the hist file of a trigger with a .percent value, with that allocation forced to fail:
BUG: KASAN: vmalloc-out-of-bounds in tracing_map_destroy_sort_entries+0xa0/0xb0 Read of size 8 at addr ffffc90000045000 by task init/1 tracing_map_destroy_sort_entries+0xa0/0xb0 hist_show+0x6f7/0x1df0 seq_read_iter+0x2b8/0x1190 vfs_read+0x176/0xa40 The buggy address belongs to a 4-page vmalloc region starting at ffffc90000041000 allocated at tracing_map_sort_entries+0x5c/0xd50
A few pages further the fault is fatal. The registers at the oops confirm the bound: the loop's end pointer less the array start, over the pointer size, is 4294967284.
Return the error in a separate variable and leave n_entries holding the count, the way tracing_map_sort_entries() does on its own error path.
The stats block is only entered for a value carrying .percent or .graph, which __create_val_field() has rejected since v6.3, so this cannot be reached in mainline as it stands. It becomes reachable again with "tracing: hist: let values keep the percent and graph modifiers", so it should be applied first.
--- kernel/trace/trace_events_hist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/trace/trace_events_hist.c +5 -3
@@ -5638,7 +5638,7 @@ static int print_entries(struct seq_file {struct tracing_map_sort_entry **sort_entries =NULL ;struct tracing_map *map = hist_data->map; -int i, j, n_entries; +int i, j, n_entries, ret;struct hist_val_stat *stats =NULL ;u64 val;
@@ -5648,6 +5648,8 @@ static int print_entries(struct seq_fileif (n_entries <0 )return n_entries; + ret = n_entries; +/* Calculate the max and the total for each field if needed. */ for (j =0 ; j < hist_data->n_vals; j++) { if (!(hist_data->fields[j]->flags &
@@ -5657,7 +5659,7 @@ static int print_entries(struct seq_file stats =kcalloc (hist_data->n_vals,sizeof (*stats),GFP_KERNEL );if (!stats) { - n_entries = -ENOMEM ; + ret = -ENOMEM ; goto out; } }
@@ -5678,7 +5680,7 @@ static int print_entries(struct seq_file out:tracing_map_destroy_sort_entries (sort_entries, n_entries); -return n_entries; +return ret; } static void hist_trigger_show(struct seq_file *m,
Greg Kroah-Hartman
maintainerPATCH 617/1193 ASoC: sprd: validate compress buffer sizes against fixed allocations
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
commit 7a4ce92d150b9e7ecf1a710a34d8cdeb590d3751 upstream.
sprd_platform_compr_open() allocates the stage 0 IRAM buffer (32K data area) and the stage 1 DDR buffer (2M data area) with fixed sizes, but sprd_platform_compr_copy() derives all copy lengths from the user controlled runtime->fragment_size and the write() count, never comparing them against the physical buffer sizes. The compress core only checks fragment_size * fragments for an u32 overflow in snd_compress_check_input(), so a local user can configure a logical buffer of up to ~4GB via SNDRV_COMPRESS_SET_PARAMS, far exceeding the fixed allocations.
A fragment_size larger than the 32K IRAM data area makes the stage 0 copy_from_user() overflow past the IRAM allocation, and a buffer_size larger than the 2M DDR buffer makes the wrapping copy at the end of sprd_platform_compr_copy() write fully user controlled data past the buffer. No SNDRV_PCM_TRIGGER_START is needed, a write() in SETUP state reaches the copy callback directly.
Reject parameters that do not fit into the fixed buffers in set_params(), and fix the advertised max fragment size: 128K never fitted into the 32K IRAM buffer. The caps values may have been carried over from the qdsp6 driver, which allocates its buffers according to the advertised maxima, unlike this driver. With 32K as max fragment size the advertised limits are self-consistent: 32K * 64 = 2M equals the DDR buffer size.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- sound/soc/sprd/sprd-pcm-compress.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
sound/soc/sprd/sprd-pcm-compress.c +14 -1
@@ -17,7 +17,7 @@/* Default values if userspace does not set */ #define SPRD_COMPR_MIN_FRAGMENT_SIZE SZ_8K -#define SPRD_COMPR_MAX_FRAGMENT_SIZE SZ_128K +#define SPRD_COMPR_MAX_FRAGMENT_SIZE SZ_32K#define SPRD_COMPR_MIN_NUM_FRAGMENTS 4#define SPRD_COMPR_MAX_NUM_FRAGMENTS 64
@@ -272,6 +272,19 @@ static int sprd_platform_compr_set_paramint ret;/* +* The stage 0 IRAM buffer and the stage 1 DDR buffer are allocated +* with fixed sizes at open time, so the requested fragment size and +* fragments must fit into them, otherwise sprd_platform_compr_copy() +* would overflow the buffers. Note the compress core only checks the +* fragment size and fragments against an u32 overflow, not against +* the buffer sizes advertised by get_caps. +*/ +if (params->buffer.fragment_size >SPRD_COMPR_IRAM_BUF_SIZE || + (u64 )params->buffer.fragment_size * params->buffer.fragments > +SPRD_COMPR_AREA_BUF_SIZE ) +return -EINVAL ; + +/* * Configure the DMA engine 2-stage transfer mode. Channel 1 set as the * destination channel, and channel 0 set as the source channel, that * means once the source channel's transaction is done, it will trigger
Greg Kroah-Hartman
maintainerPATCH 618/1193 ASoC: sti: initialize IRQ lock before requesting IRQ
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 04405aeef4f8d7bcac6dcb1947acafdb4420c2c3 upstream.
uni_reader_init() registers the shared IRQ before initializing reader->irq_lock. A pending interrupt can invoke the handler while the lock is still uninitialized.
Initialize the lock before registering the IRQ so the interrupt path always sees valid lock state.
--- sound/soc/sti/uniperif_reader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sti/uniperif_reader.c +2 -2
@@ -422,6 +422,8 @@ int uni_reader_init(struct platform_devielse reader->hw = &uni_reader_pcm_hw; +spin_lock_init (&reader->irq_lock); + ret =devm_request_irq (&pdev->dev, reader->irq, uni_reader_irq_handler,IRQF_SHARED ,dev_name (&pdev->dev), reader);
@@ -430,8 +432,6 @@ int uni_reader_init(struct platform_devireturn -EBUSY ; } -spin_lock_init (&reader->irq_lock); -return 0 ; }EXPORT_SYMBOL_GPL (uni_reader_init);
Greg Kroah-Hartman
maintainerPATCH 619/1193 Bluetooth: btrtl: Dont leak return code when parsing firmware format v2
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Zhang <[email protected]>
commit 83e3e515fd261600ed8491fb0a8bcdfb115c904e upstream.
When key_id from chip is zero, rtlbt_parse_firmware_v2() intentionally ignores all security headers. However, the implementation simply breaks from a switch statement and leaks uninitialized return code rc' (if the first section is a security one) or the previous section's rc'.
Fix it by really skipping a loop with `continue'. For consistency and readability, also do the same for the default case.
--- drivers/bluetooth/btrtl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/bluetooth/btrtl.c +2 -3
@@ -560,7 +560,7 @@ static int rtlbt_parse_firmware_v2(struc* headers. */ if (!key_id) -break ; +continue ; rc =btrtl_parse_section (hdev, btrtl_dev, opcode, ptr, section_len);break ;
@@ -569,8 +569,7 @@ static int rtlbt_parse_firmware_v2(struc ptr, section_len);break ;default : - rc =0 ; -break ; +continue ; }if (rc <0 ) { rtl_dev_err(hdev, "RTL: Parse section (%u) err %d",
Greg Kroah-Hartman
maintainerPATCH 620/1193 cpufreq: zero-initialize policy cpumask before sysfs publication
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhongqiu Han <[email protected]>
commit 54d37bcf2f497140b9207968557ddb484058e749 upstream.
cpufreq_policy_alloc() allocates policy->cpus with alloc_cpumask_var(), i.e. without __GFP_ZERO, unlike the sibling related_cpus and real_cpus masks. With CONFIG_CPUMASK_OFFSTACK=y the mask is a separate kmalloc_node() allocation, so its bitmap holds whatever the slab allocator left behind:
cpufreq_online()
cpufreq_policy_alloc()
alloc_cpumask_var(&policy->cpus) /* bitmap is uninitialized */
kobject_init_and_add() /* policy%u/ appears in sysfs */
cpufreq_policy_online()
cpumask_copy(policy->cpus, cpumask_of(cpu)) /* first valid value */This leaves a window in which the sysfs attributes are already reachable while policy->cpus is still garbage. show()/store() gate on policy_is_inactive(), i.e. cpumask_empty(policy->cpus), so a non-zero bitmap makes them run the attribute callbacks on a policy that is not initialized yet.
Fix this by using zalloc_cpumask_var() for policy->cpus.
--- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
@@ -1264,7 +1264,7 @@ static struct cpufreq_policy *cpufreq_poif (!policy)return NULL ; -if (!alloc_cpumask_var (&policy->cpus,GFP_KERNEL )) +if (!zalloc_cpumask_var (&policy->cpus,GFP_KERNEL )) goto err_free_policy;if (!zalloc_cpumask_var (&policy->related_cpus,GFP_KERNEL ))
Greg Kroah-Hartman
maintainerPATCH 611/1193 tracing/user_events: Dont destroy fields when event removal fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
commit 2deb753127d7b7035e893955c5e91875e767d1f8 upstream.
destroy_user_event() destroys the event's fields before attempting to remove the trace event call. If user_event_set_call_visible() fails, e.g. because the event is still enabled and trace_remove_event_call() returns -EBUSY, the event is left registered with an irreversibly destroyed field list. Any subsequent interaction with the event then operates on an empty field list while it is still fully visible in tracefs.
Move the field destruction after the call removal, and splice the field list back onto the event when the removal fails so the event remains in a consistent state.
--- kernel/trace/trace_events_user.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
kernel/trace/trace_events_user.c +20 -6
@@ -1104,10 +1104,9 @@ static void user_event_destroy_validator } } -static void user_event_destroy_fields (struct user_event *user) +static void user_event_destroy_fields (struct list_head *head) {struct ftrace_event_field *field, *next; -struct list_head *head = &user->fields;list_for_each_entry_safe (field, next, head, link) {list_del (&field->link);
@@ -1494,17 +1493,32 @@ static int user_event_set_call_visible(sstatic int destroy_user_event (struct user_event *user) { +LIST_HEAD (fields);int ret =0 ;lockdep_assert_held (&event_mutex); -/* Must destroy fields before call removal */ -user_event_destroy_fields (user); +/* +* Detach the fields before removing the call. Removing the event +* frees the field list memory (trace_destroy_fields() is run on +* successful removal and kmem_cache_free()s the fields), but the +* fields here are allocated and owned by user_events. Destroy +* them separately once removal has succeeded. +*/ +list_splice_init (&user->fields, &fields); ret =user_event_set_call_visible (user, false); -if (ret) +if (ret) { +/* +* Removal failed and the event stays registered, recover +* the fields so it is left in a consistent state. +*/ +list_splice (&fields, &user->fields);return ret; + } + +user_event_destroy_fields (&fields);dyn_event_remove (&user->devent);hash_del (&user->node);
@@ -2149,7 +2163,7 @@ static int user_event_parse(struct user_ put_user_lock:mutex_unlock (&event_mutex); put_user: -user_event_destroy_fields (user); +user_event_destroy_fields (&user->fields);user_event_destroy_validators (user);kfree (user->call.print_fmt);kfree (user);
Greg Kroah-Hartman
maintainerPATCH 661/1193 mptcp: syncookies: remember the request backup flag
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit b76c0e28b392620dfbaf92cdeedbf115820b44cb upstream.
Instead of using an uninitialised bit when copying the info in subflow_ulp_clone().
To fix this, no need to extend the join_entry structure: backup is coming from struct mptcp_subflow_request_sock, only one bit. Do the same here by using one bit for both.
--- net/mptcp/syncookies.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/mptcp/syncookies.c +4 -1
@@ -26,7 +26,8 @@ struct join_entry {u32 local_nonce;u8 join_id;u8 local_id; -u8 backup; + u8 backup:1, + request_bkup:1;u8 valid; };
@@ -63,6 +64,7 @@ static void mptcp_join_store_state(struc entry->remote_nonce = subflow_req->remote_nonce; entry->local_nonce = subflow_req->local_nonce; entry->backup = subflow_req->backup; + entry->request_bkup = subflow_req->request_bkup; entry->join_id = subflow_req->remote_id; entry->local_id = subflow_req->local_id; entry->valid =1 ;
@@ -117,6 +119,7 @@ bool mptcp_token_join_cookie_init_state( subflow_req->remote_nonce = e->remote_nonce; subflow_req->local_nonce = e->local_nonce; subflow_req->backup = e->backup; + subflow_req->request_bkup = e->request_bkup; subflow_req->remote_id = e->join_id; subflow_req->local_id = e->local_id; subflow_req->token = e->token;
Greg Kroah-Hartman
maintainerPATCH 670/1193 smb: client: fix heap overflow in DACL owner/group rewrite
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjoern Doebel <[email protected]>
commit 0ee150794c75bcd0be0e24ff3394f433cbae18cc upstream.
When id_mode_to_cifs_acl rewrites an existing DACL, it allocates a buffer sized according to the on-disk DACL length reported by dacl_ptr->size. However, replace_sids_and_copy_aces may rewrite each ACE with a new owner/group SID obtained from the cifs.idmap upcall. Those SIDs can have up to SID_MAX_SUB_AUTHORITIES (15) sub-authorities, making each ACE up to 76 bytes (sizeof(struct smb_ace)).
If the original DACL contains short SIDs (e.g., 1 sub-authority) while the replacement SIDs are long, the rewritten ACEs overflow the allocation.
Fix this by always budgeting for worst-case SID expansion: allocate sizeof(struct smb_acl) plus num_aces * sizeof(struct smb_ace), which covers the smb_acl header and room for every ACE at maximum SID size. This replaces the previous split logic that used dacl_ptr->size for cifsacl mounts but num_aces * sizeof(struct smb_ace) for mode_from_sid
mounts: both paths can trigger the same rewrite and need the same headroom.
KASAN reports this as:
BUG: KASAN: slab-out-of-bounds in build_sec_desc+0x1e8a/0x2680 [cifs] Write of size 4 at addr ffff8881a5e25374 by task chown/5298 ... The buggy address is located 0 bytes to the right of allocated 884-byte region [ffff8881a5e25000, ffff8881a5e25374)
--- fs/smb/client/cifsacl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/smb/client/cifsacl.c +7 -5
@@ -1769,11 +1769,13 @@ id_mode_to_cifs_acl(struct inode *inode,cifs_put_tlink (tlink);return rc; } -if (mode_from_sid) - nsecdesclen += -le16_to_cpu (dacl_ptr->num_aces) *sizeof (struct smb_ace ); -else /* cifsacl */ - nsecdesclen +=le16_to_cpu (dacl_ptr->size); +/* +* Worst case: every ACE is rewritten with a new SID of +* SID_MAX_SUB_AUTHORITIES sub-auths -> sizeof(smb_ace) each, +* plus the smb_acl header replace_sids_and_copy_aces() emits. +*/ + nsecdesclen +=sizeof (struct smb_acl ) + +le16_to_cpu (dacl_ptr->num_aces) *sizeof (struct smb_ace ); } }
Greg Kroah-Hartman
maintainerPATCH 671/1193 xfs: snapshot scrub stats when rendering them
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit 568a1588b906780dc3e9be56a61217afb4f7800e upstream.
LOLLM complains about concurrency problems in the scrub stats code because xchk_stats_format doesn't synchronize in any way with updates. These stats are only reported through debugfs so I don't think it really matters, but I guess I exist to make bots happy now.
Note: We snapshot the entire stats object with a spinlock so that we don't have to worry about users seeing slightly weird numbers (e.g. invocations has incremented but none of the outcomes have been yet) if we race with xchk_stats_merge_one. This isn't a hot path.
--- fs/xfs/scrub/stats.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
fs/xfs/scrub/stats.c +19 -13
@@ -92,25 +92,31 @@ xchk_stats_format(int ret =0 ;for (i =0 ; i <XFS_SCRUB_TYPE_NR ; i++, css++) { +struct xchk_scrub_stats fss; +if (!name_map[i])continue ; +spin_lock (&css->css_lock); +memcpy (&fss, css, offsetof(struct xchk_scrub_stats , css_lock)); +spin_unlock (&css->css_lock); + ret =scnprintf (buf, remaining,"%s %u %u %u %u %u %u %u %u %u %llu %u %u %llu\n" , name_map[i], - (unsigned int )css->invocations, - (unsigned int )css->clean, - (unsigned int )css->corrupt, - (unsigned int )css->preen, - (unsigned int )css->xfail, - (unsigned int )css->xcorrupt, - (unsigned int )css->incomplete, - (unsigned int )css->warning, - (unsigned int )css->retries, - (unsigned long long )css->checktime_us, - (unsigned int )css->repair_invocations, - (unsigned int )css->repair_success, - (unsigned long long )css->repairtime_us); + (unsigned int )fss.invocations, + (unsigned int )fss.clean, + (unsigned int )fss.corrupt, + (unsigned int )fss.preen, + (unsigned int )fss.xfail, + (unsigned int )fss.xcorrupt, + (unsigned int )fss.incomplete, + (unsigned int )fss.warning, + (unsigned int )fss.retries, + (unsigned long long )fss.checktime_us, + (unsigned int )fss.repair_invocations, + (unsigned int )fss.repair_success, + (unsigned long long )fss.repairtime_us);if (ret <=0 )break ;
Greg Kroah-Hartman
maintainerPATCH 672/1193 xfs: snapshot old AGFL before rewriting it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit 3466dfef0a20f842363958deea55be9f1d26818a upstream.
LOLLM complains that we can't undo an attempt at fixing the AGFL if anything goes wrong during the rewrite, so take a snapshot of the whole buffer so that we can restore it. Move the xrep_agfl_update_agf call so that we only update the AGF if the AGFL update is 100% successful.
While we're at it, fix leaking the used_extents bitmap if the disunion operation fails.
--- fs/xfs/scrub/agheader_repair.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
fs/xfs/scrub/agheader_repair.c +25 -10
@@ -677,14 +677,16 @@ xrep_agfl_init_header(struct xfs_scrub *sc, struct xfs_buf *agfl_bp, struct xagb_bitmap *agfl_extents, - xfs_agblock_t flcount) + xfs_agblock_t flcount, + struct xfs_agfl *old_agfl) { struct xrep_agfl_fill af = { .sc = sc, .flcount = flcount, };struct xfs_mount *mp = sc->mp; -struct xfs_agfl *agfl; +struct xfs_agfl *agfl =XFS_BUF_TO_AGFL (agfl_bp); +const size_t agfl_sz =BBTOB (agfl_bp->b_length);int error;ASSERT (flcount <=xfs_agfl_size (mp));
@@ -693,8 +695,8 @@ xrep_agfl_init_header(* Start rewriting the header by setting the bno[] array to * NULLAGBLOCK, then setting AGFL header fields. */ - agfl =XFS_BUF_TO_AGFL (agfl_bp); -memset (agfl,0xFF ,BBTOB (agfl_bp->b_length)); +memcpy (old_agfl, agfl, agfl_sz); +memset (agfl,0xFF , agfl_sz); agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (sc->sa.pag->pag_agno);uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);
@@ -709,13 +711,18 @@ xrep_agfl_init_header(xagb_bitmap_walk (agfl_extents, xrep_agfl_fill, &af); error =xagb_bitmap_disunion (agfl_extents, &af.used_extents);if (error) -return error; + goto err_undo;/* Write new AGFL to disk. */ xfs_trans_buf_set_type (sc->tp, agfl_bp,XFS_BLFT_AGFL_BUF ); -xfs_trans_log_buf (sc->tp, agfl_bp,0 ,BBTOB (agfl_bp->b_length) -1 ); +xfs_trans_log_buf (sc->tp, agfl_bp,0 , agfl_sz -1 );xagb_bitmap_destroy (&af.used_extents);return 0 ; + +err_undo: +xagb_bitmap_destroy (&af.used_extents); +memcpy (agfl, old_agfl, agfl_sz); +return error; }/* Repair the AGFL. */
@@ -727,6 +734,7 @@ xrep_agfl(struct xfs_mount *mp = sc->mp;struct xfs_buf *agf_bp;struct xfs_buf *agfl_bp; +struct xfs_agfl *old_agfl;xfs_agblock_t flcount;int error;
@@ -734,6 +742,10 @@ xrep_agfl(if (!xfs_has_rmapbt (mp))return -EOPNOTSUPP ; + old_agfl =kzalloc (BBTOB (XFS_FSS_TO_BB (mp,1 )),XCHK_GFP_FLAGS ); +if (!old_agfl) +return -ENOMEM ; +xagb_bitmap_init (&agfl_extents);/*
@@ -743,7 +755,7 @@ xrep_agfl(*/ error =xfs_alloc_read_agf (sc->sa.pag, sc->tp,0 , &agf_bp);if (error) -return error; + goto err_old_agfl;/* * Make sure we have the AGFL buffer, as scrub might have decided it
@@ -754,7 +766,7 @@ xrep_agfl( XFS_AGFL_DADDR(mp)), XFS_FSS_TO_BB(mp, 1), 0, &agfl_bp, NULL);if (error) -return error; + goto err_old_agfl; agfl_bp->b_ops = &xfs_agfl_buf_ops;/* Gather all the extents we're going to put on the new AGFL. */
@@ -771,10 +783,11 @@ xrep_agfl(* we adjust the AGF flcount (which can fail) so avoid updating any * buffers until we know that part works. */ -xrep_agfl_update_agf (sc, agf_bp, flcount); - error =xrep_agfl_init_header (sc, agfl_bp, &agfl_extents, flcount); + error =xrep_agfl_init_header (sc, agfl_bp, &agfl_extents, flcount, + old_agfl);if (error) goto err; +xrep_agfl_update_agf (sc, agf_bp, flcount);/* * Ok, the AGFL should be ready to go now. Roll the transaction to
@@ -791,6 +804,8 @@ xrep_agfl( XFS_AG_RESV_AGFL); err:xagb_bitmap_destroy (&agfl_extents); +err_old_agfl: +kfree (old_agfl);return error; }
Greg Kroah-Hartman
maintainerPATCH 673/1193 xfs: signal inode btree xref error if get_rec returns an error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit 8c71ad4d4f3e20c30b663bd292526fcbc4d3913f upstream.
LOLLM points out that xchk_finobt_xref_inobt and xchk_inobt_xref_finobt both ignore errors being returned from the xfs_btree_get_rec function and proceed with a (possibly stale) "true" value for has_record. If the *simple* btree record checks fail during cross-referencing, we can immediately conclude that there's a cross-referncing error in the other btree. On those grounds, we can bubble up the returned error instead of wasting time cross-referencing with garbage.
--- fs/xfs/scrub/ialloc.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/xfs/scrub/ialloc.c +4 -0
@@ -85,6 +85,8 @@ xchk_inobt_xref_finobt( goto no_record; error =xfs_inobt_get_rec (cur, &frec, &has_record); +if (error) +return error;if (!has_record)return -EFSCORRUPTED ;
@@ -188,6 +190,8 @@ xchk_finobt_xref_inobt( goto no_record; error =xfs_inobt_get_rec (cur, &irec, &has_record); +if (error) +return error;if (!has_record)return -EFSCORRUPTED ;
Greg Kroah-Hartman
maintainerPATCH 674/1193 xfs: count escaped corruption errors in scrub stats
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit 4d0624679ae29b469016f1ce4714be58582ed06a upstream.
The main scrub code will quietly turn bubbled-up EFSCORRUPTED and EFSBADCRC errors into corruption errors. These aren't recorded in the scrub stats code (says LOLLM) so do that now.
--- fs/xfs/scrub/scrub.c | 3 +-- fs/xfs/scrub/stats.c | 28 +++++++++++++++++++--------- fs/xfs/scrub/stats.h | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-)
fs/xfs/scrub/scrub.c +1 -2
@@ -588,8 +588,7 @@ out_nofix: out_teardown: error =xchk_teardown (sc, error); out_sc: -if (error != -ENOENT ) -xchk_stats_merge (mp, sm, &run); +xchk_stats_merge (mp, sm, error, &run);kfree (sc); out:trace_xchk_done (XFS_I (file_inode (file)), sm, error);
fs/xfs/scrub/stats.c +19 -9
@@ -187,31 +187,37 @@ STATIC voidxchk_stats_merge_one ( struct xchk_stats *cs, const struct xfs_scrub_metadata *sm, + int error, const struct xchk_stats_run *run) { struct xchk_scrub_stats *css; +unsigned int sm_flags = sm->sm_flags;if (sm->sm_type >=XFS_SCRUB_TYPE_NR ) {ASSERT (sm->sm_type <XFS_SCRUB_TYPE_NR );return ; } +/* caller applies this same transformation after we return */ +if (error == -EFSCORRUPTED || error == -EFSBADCRC ) + sm_flags |=XFS_SCRUB_OFLAG_CORRUPT ; + css = &cs->cs_stats[sm->sm_type];spin_lock (&css->css_lock); css->invocations++; -if (!(sm->sm_flags &XFS_SCRUB_OFLAG_UNCLEAN )) +if (!(sm_flags &XFS_SCRUB_OFLAG_UNCLEAN )) css->clean++; -if (sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT ) +if (sm_flags &XFS_SCRUB_OFLAG_CORRUPT ) css->corrupt++; -if (sm->sm_flags &XFS_SCRUB_OFLAG_PREEN ) +if (sm_flags &XFS_SCRUB_OFLAG_PREEN ) css->preen++; -if (sm->sm_flags &XFS_SCRUB_OFLAG_XFAIL ) +if (sm_flags &XFS_SCRUB_OFLAG_XFAIL ) css->xfail++; -if (sm->sm_flags &XFS_SCRUB_OFLAG_XCORRUPT ) +if (sm_flags &XFS_SCRUB_OFLAG_XCORRUPT ) css->xcorrupt++; -if (sm->sm_flags &XFS_SCRUB_OFLAG_INCOMPLETE ) +if (sm_flags &XFS_SCRUB_OFLAG_INCOMPLETE ) css->incomplete++; -if (sm->sm_flags &XFS_SCRUB_OFLAG_WARNING ) +if (sm_flags &XFS_SCRUB_OFLAG_WARNING ) css->warning++; css->retries += run->retries; css->checktime_us +=howmany_64 (run->scrub_ns,NSEC_PER_USEC );
@@ -229,10 +235,14 @@ voidxchk_stats_merge ( struct xfs_mount *mp, const struct xfs_scrub_metadata *sm, + int error, const struct xchk_stats_run *run) { - xchk_stats_merge_one(&global_stats, sm, run); -xchk_stats_merge_one (mp->m_scrub_stats, sm, run); + if (error == -ENOENT) + return; + + xchk_stats_merge_one(&global_stats, sm, error, run); +xchk_stats_merge_one (mp->m_scrub_stats, sm, error, run); }/* debugfs boilerplate */
fs/xfs/scrub/stats.h +2 -2
@@ -27,7 +27,7 @@ void xchk_stats_register(struct xchk_stavoid xchk_stats_unregister (struct xchk_stats *cs);void xchk_stats_merge (struct xfs_mount *mp,const struct xfs_scrub_metadata *sm, -const struct xchk_stats_run *run); +int error,const struct xchk_stats_run *run);static inline u64 xchk_stats_now (void ) {return ktime_get_ns (); }static inline u64 xchk_stats_elapsed_ns (u64 since)
@@ -53,7 +53,7 @@ static inline u64 xchk_stats_elapsed_ns(# define xchk_stats_unregister (cs) ((void)0)# define xchk_stats_now () (0)# define xchk_stats_elapsed_ns (x) (0 * (x)) -# define xchk_stats_merge (mp, sm, run) ((void)0) +# define xchk_stats_merge (mp, sm, error, run) ((void)0)#endif /* CONFIG_XFS_ONLINE_SCRUB_STATS */ #endif /* __XFS_SCRUB_STATS_H__ */
Greg Kroah-Hartman
maintainerPATCH 675/1193 xfs: bail out on bitmap errors in xrep_agfl_fill
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit eaf580538eb1be3d162400d04c4b7dc4c627296b upstream.
LOLLM also points out that the xagb_bitmap_set call in xrep_agfl_fill can fail, but we don't check the result of xagb_bitmap_walk, so we silently drop the error and proceed with inconsistent incore data. That shouldn't be allowed.
--- fs/xfs/scrub/agheader_repair.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/xfs/scrub/agheader_repair.c +3 -1
@@ -708,7 +708,9 @@ xrep_agfl_init_header(*/ xagb_bitmap_init (&af.used_extents); af.agfl_bno =xfs_buf_to_agfl_bno (agfl_bp); -xagb_bitmap_walk (agfl_extents, xrep_agfl_fill, &af); + error =xagb_bitmap_walk (agfl_extents, xrep_agfl_fill, &af); +if (error && error != -ECANCELED ) + goto err_undo; error =xagb_bitmap_disunion (agfl_extents, &af.used_extents);if (error) goto err_undo;
Greg Kroah-Hartman
maintainerPATCH 676/1193 Revert "arm64: dts: qcom: sm8550: Fix the PCIe iommu-map entries"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 76c695d6e923614e9490a3cb4f8538742f7493b8.
--- arch/arm64/boot/dts/qcom/sm8550.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/sm8550.dtsi +4 -4
@@ -1736,8 +1736,8 @@ pcie0: pci@1c00000 { msi-map = <0x0 &gic_its 0x1400 0x1>, <0x100 &gic_its 0x1401 0x1>; - iommu-map = <0x0 &apps_smmu 0x1400 0x0 0x1>, - <0x100 &apps_smmu 0x1401 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1400 0x1>, + <0x100 &apps_smmu 0x1401 0x1>; resets = <&gcc GCC_PCIE_0_BCR>; reset-names = "pci";
@@ -1834,8 +1834,8 @@ pcie1: pci@1c08000 { msi-map = <0x0 &gic_its 0x1480 0x1>, <0x100 &gic_its 0x1481 0x1>; - iommu-map = <0x0 &apps_smmu 0x1480 0x0 0x1>, - <0x100 &apps_smmu 0x1481 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1480 0x1>, + <0x100 &apps_smmu 0x1481 0x1>; resets = <&gcc GCC_PCIE_1_BCR>, <&gcc GCC_PCIE_1_LINK_DOWN_BCR>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 677/1193 Revert "arm64: dts: qcom: sm8450: Fix the PCIe iommu-map entries"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit de01d783368c5e11d384af51345b5745c82f352e.
--- arch/arm64/boot/dts/qcom/sm8450.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/sm8450.dtsi +4 -4
@@ -1811,8 +1811,8 @@ pcie0: pci@1c00000 { "aggre0", "aggre1"; - iommu-map = <0x0 &apps_smmu 0x1c00 0x0 0x1>, - <0x100 &apps_smmu 0x1c01 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c00 0x1>, + <0x100 &apps_smmu 0x1c01 0x1>; resets = <&gcc GCC_PCIE_0_BCR>; reset-names = "pci";
@@ -1919,8 +1919,8 @@ pcie1: pci@1c08000 { "ddrss_sf_tbu", "aggre1"; - iommu-map = <0x0 &apps_smmu 0x1c80 0x0 0x1>, - <0x100 &apps_smmu 0x1c81 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c80 0x1>, + <0x100 &apps_smmu 0x1c81 0x1>; resets = <&gcc GCC_PCIE_1_BCR>; reset-names = "pci";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 678/1193 Revert "arm64: dts: qcom: sm8350: Fix the PCIe iommu-map entries"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 4a2efff1ebdbeb8dfd765154ee1d975e786c6942.
--- arch/arm64/boot/dts/qcom/sm8350.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/sm8350.dtsi +4 -4
@@ -1552,8 +1552,8 @@ pcie0: pci@1c00000 { "aggre1", "aggre0"; - iommu-map = <0x0 &apps_smmu 0x1c00 0x0 0x1>, - <0x100 &apps_smmu 0x1c01 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c00 0x1>, + <0x100 &apps_smmu 0x1c01 0x1>; resets = <&gcc GCC_PCIE_0_BCR>; reset-names = "pci";
@@ -1635,8 +1635,8 @@ pcie1: pci@1c08000 { "ddrss_sf_tbu", "aggre1"; - iommu-map = <0x0 &apps_smmu 0x1c80 0x0 0x1>, - <0x100 &apps_smmu 0x1c81 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c80 0x1>, + <0x100 &apps_smmu 0x1c81 0x1>; resets = <&gcc GCC_PCIE_1_BCR>; reset-names = "pci";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 679/1193 Revert "arm64: dts: qcom: sm8250: Fix the PCIe iommu-map entries"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 9dedefe9d949ad0ba21c3d30998623223aafc7dd.
--- arch/arm64/boot/dts/qcom/sm8250.dtsi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/qcom/sm8250.dtsi +6 -6
@@ -1895,8 +1895,8 @@ pcie0: pci@1c00000 { "tbu", "ddrss_sf_tbu"; - iommu-map = <0x0 &apps_smmu 0x1c00 0x0 0x1>, - <0x100 &apps_smmu 0x1c01 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c00 0x1>, + <0x100 &apps_smmu 0x1c01 0x1>; resets = <&gcc GCC_PCIE_0_BCR>; reset-names = "pci";
@@ -2002,8 +2002,8 @@ pcie1: pci@1c08000 { assigned-clocks = <&gcc GCC_PCIE_1_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1c80 0x0 0x1>, - <0x100 &apps_smmu 0x1c81 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c80 0x1>, + <0x100 &apps_smmu 0x1c81 0x1>; resets = <&gcc GCC_PCIE_1_BCR>; reset-names = "pci";
@@ -2111,8 +2111,8 @@ pcie2: pci@1c10000 { assigned-clocks = <&gcc GCC_PCIE_2_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1d00 0x0 0x1>, - <0x100 &apps_smmu 0x1d01 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1d00 0x1>, + <0x100 &apps_smmu 0x1d01 0x1>; resets = <&gcc GCC_PCIE_2_BCR>; reset-names = "pci";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 662/1193 selftests: mptcp: fix an UAF in mptcp_connect.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gang Yan <[email protected]>
commit 730444f094b12052916ebd7e14fe57bc3d47bf38 upstream.
At the end of 'sock_connect_mptcp()', it calls 'freeaddrinfo(addr)', the 'peer' pointer (which points into 'addr') remains. Later, the main loop uses this peer pointer for reconnection attempts. If the memory has been freed and reused, the address data could be overwritten, resulting in an invalid remote address.
This patch keeps the addrinfo list allocated for the whole process lifetime so "peer" remains valid across reconnects; the memory will be released at exit() time.
--- tools/testing/selftests/net/mptcp/mptcp_connect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +3 -1
@@ -365,6 +365,9 @@ static int sock_connect_mptcp(const char hints.ai_family = pf; +/* Keep the resolved address alive for the whole execution: it is +* used again when reconnecting, and will be released at exit time. +*/ xgetaddrinfo (remoteaddr, port, &hints, &addr);for (a = addr; a; a = a->ai_next) { sock =socket (a->ai_family, a->ai_socktype, proto);
@@ -408,7 +411,6 @@ static int sock_connect_mptcp(const char } } -freeaddrinfo (addr);if (sock !=-1 )SOCK_TEST_TCPULP (sock, proto);return sock;
Greg Kroah-Hartman
maintainerPATCH 680/1193 Revert "arm64: dts: qcom: sm8150: Fix the PCIe iommu-map entries"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 796fcf46d75515f920d3efe4a33540fc6523d940.
--- arch/arm64/boot/dts/qcom/sm8150.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/sm8150.dtsi +4 -4
@@ -1865,8 +1865,8 @@ pcie0: pci@1c00000 { "slave_q2a", "tbu"; - iommu-map = <0x0 &apps_smmu 0x1d80 0x0 0x1>, - <0x100 &apps_smmu 0x1d81 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1d80 0x1>, + <0x100 &apps_smmu 0x1d81 0x1>; resets = <&gcc GCC_PCIE_0_BCR>; reset-names = "pci";
@@ -1967,8 +1967,8 @@ pcie1: pci@1c08000 { assigned-clocks = <&gcc GCC_PCIE_1_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1e00 0x0 0x1>, - <0x100 &apps_smmu 0x1e01 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1e00 0x1>, + <0x100 &apps_smmu 0x1e01 0x1>; resets = <&gcc GCC_PCIE_1_BCR>; reset-names = "pci";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 681/1193 Revert "arm64: dts: qcom: sdm845: Fix the PCIe iommu-map entries"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 3c9cbf39055faf75b588f30aac5e409555075295.
--- arch/arm64/boot/dts/qcom/sdm845.dtsi | 64 ++++++++++++++-------------- 1 file changed, 32 insertions(+), 32 deletions(-)
arch/arm64/boot/dts/qcom/sdm845.dtsi +32 -32
@@ -2349,22 +2349,22 @@ pcie0: pci@1c00000 { "slave_q2a", "tbu"; - iommu-map = <0x0 &apps_smmu 0x1c10 0x0 0x1>, - <0x100 &apps_smmu 0x1c11 0x0 0x1>, - <0x200 &apps_smmu 0x1c12 0x0 0x1>, - <0x300 &apps_smmu 0x1c13 0x0 0x1>, - <0x400 &apps_smmu 0x1c14 0x0 0x1>, - <0x500 &apps_smmu 0x1c15 0x0 0x1>, - <0x600 &apps_smmu 0x1c16 0x0 0x1>, - <0x700 &apps_smmu 0x1c17 0x0 0x1>, - <0x800 &apps_smmu 0x1c18 0x0 0x1>, - <0x900 &apps_smmu 0x1c19 0x0 0x1>, - <0xa00 &apps_smmu 0x1c1a 0x0 0x1>, - <0xb00 &apps_smmu 0x1c1b 0x0 0x1>, - <0xc00 &apps_smmu 0x1c1c 0x0 0x1>, - <0xd00 &apps_smmu 0x1c1d 0x0 0x1>, - <0xe00 &apps_smmu 0x1c1e 0x0 0x1>, - <0xf00 &apps_smmu 0x1c1f 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c10 0x1>, + <0x100 &apps_smmu 0x1c11 0x1>, + <0x200 &apps_smmu 0x1c12 0x1>, + <0x300 &apps_smmu 0x1c13 0x1>, + <0x400 &apps_smmu 0x1c14 0x1>, + <0x500 &apps_smmu 0x1c15 0x1>, + <0x600 &apps_smmu 0x1c16 0x1>, + <0x700 &apps_smmu 0x1c17 0x1>, + <0x800 &apps_smmu 0x1c18 0x1>, + <0x900 &apps_smmu 0x1c19 0x1>, + <0xa00 &apps_smmu 0x1c1a 0x1>, + <0xb00 &apps_smmu 0x1c1b 0x1>, + <0xc00 &apps_smmu 0x1c1c 0x1>, + <0xd00 &apps_smmu 0x1c1d 0x1>, + <0xe00 &apps_smmu 0x1c1e 0x1>, + <0xf00 &apps_smmu 0x1c1f 0x1>; resets = <&gcc GCC_PCIE_0_BCR>; reset-names = "pci";
@@ -2459,22 +2459,22 @@ pcie1: pci@1c08000 { assigned-clocks = <&gcc GCC_PCIE_1_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1c00 0x0 0x1>, - <0x100 &apps_smmu 0x1c01 0x0 0x1>, - <0x200 &apps_smmu 0x1c02 0x0 0x1>, - <0x300 &apps_smmu 0x1c03 0x0 0x1>, - <0x400 &apps_smmu 0x1c04 0x0 0x1>, - <0x500 &apps_smmu 0x1c05 0x0 0x1>, - <0x600 &apps_smmu 0x1c06 0x0 0x1>, - <0x700 &apps_smmu 0x1c07 0x0 0x1>, - <0x800 &apps_smmu 0x1c08 0x0 0x1>, - <0x900 &apps_smmu 0x1c09 0x0 0x1>, - <0xa00 &apps_smmu 0x1c0a 0x0 0x1>, - <0xb00 &apps_smmu 0x1c0b 0x0 0x1>, - <0xc00 &apps_smmu 0x1c0c 0x0 0x1>, - <0xd00 &apps_smmu 0x1c0d 0x0 0x1>, - <0xe00 &apps_smmu 0x1c0e 0x0 0x1>, - <0xf00 &apps_smmu 0x1c0f 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c00 0x1>, + <0x100 &apps_smmu 0x1c01 0x1>, + <0x200 &apps_smmu 0x1c02 0x1>, + <0x300 &apps_smmu 0x1c03 0x1>, + <0x400 &apps_smmu 0x1c04 0x1>, + <0x500 &apps_smmu 0x1c05 0x1>, + <0x600 &apps_smmu 0x1c06 0x1>, + <0x700 &apps_smmu 0x1c07 0x1>, + <0x800 &apps_smmu 0x1c08 0x1>, + <0x900 &apps_smmu 0x1c09 0x1>, + <0xa00 &apps_smmu 0x1c0a 0x1>, + <0xb00 &apps_smmu 0x1c0b 0x1>, + <0xc00 &apps_smmu 0x1c0c 0x1>, + <0xd00 &apps_smmu 0x1c0d 0x1>, + <0xe00 &apps_smmu 0x1c0e 0x1>, + <0xf00 &apps_smmu 0x1c0f 0x1>; resets = <&gcc GCC_PCIE_1_BCR>; reset-names = "pci";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 682/1193 Revert "arm64: dts: qcom: sc8180x: Fix the PCIe iommu-map entries"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 31db9b8610e3fe6367cca8e5aca23953ecaf1efa.
--- arch/arm64/boot/dts/qcom/sc8180x.dtsi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/arm64/boot/dts/qcom/sc8180x.dtsi +8 -8
@@ -1745,8 +1745,8 @@ pcie0: pci@1c00000 { assigned-clocks = <&gcc GCC_PCIE_0_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1d80 0x0 0x1>, - <0x100 &apps_smmu 0x1d81 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1d80 0x1>, + <0x100 &apps_smmu 0x1d81 0x1>; resets = <&gcc GCC_PCIE_0_BCR>; reset-names = "pci";
@@ -1842,8 +1842,8 @@ pcie3: pci@1c08000 { assigned-clocks = <&gcc GCC_PCIE_3_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1e00 0x0 0x1>, - <0x100 &apps_smmu 0x1e01 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1e00 0x1>, + <0x100 &apps_smmu 0x1e01 0x1>; resets = <&gcc GCC_PCIE_3_BCR>; reset-names = "pci";
@@ -1940,8 +1940,8 @@ pcie1: pci@1c10000 { assigned-clocks = <&gcc GCC_PCIE_1_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1c80 0x0 0x1>, - <0x100 &apps_smmu 0x1c81 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1c80 0x1>, + <0x100 &apps_smmu 0x1c81 0x1>; resets = <&gcc GCC_PCIE_1_BCR>; reset-names = "pci";
@@ -2038,8 +2038,8 @@ pcie2: pci@1c18000 { assigned-clocks = <&gcc GCC_PCIE_2_AUX_CLK>; assigned-clock-rates = <19200000>; - iommu-map = <0x0 &apps_smmu 0x1d00 0x0 0x1>, - <0x100 &apps_smmu 0x1d01 0x0 0x1>; + iommu-map = <0x0 &apps_smmu 0x1d00 0x1>, + <0x100 &apps_smmu 0x1d01 0x1>; resets = <&gcc GCC_PCIE_2_BCR>; reset-names = "pci";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 683/1193 Revert "nvme-apple: Reset q->sq_tail during queue init"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 85316d624f56573a6e278e1d8c10309f4fb6d2ae.
--- drivers/nvme/host/apple.c | 1 - 1 file changed, 1 deletion(-)
drivers/nvme/host/apple.c +0 -1
@@ -1023,7 +1023,6 @@ static void apple_nvme_init_queue(struct apple_nvme_queue *q)unsigned int depth =apple_nvme_queue_depth (q);struct apple_nvme *anv =queue_to_apple_nvme (q); - q->sq_tail =0 ; q->cq_head =0 ; q->cq_phase =1 ;if (anv->hw->has_lsq_nvmmu)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 684/1193 Revert "nvme-apple: Prevent shared tags across queues on Apple A11"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 073b9238fac4d1c7727c1d05e3fafad0fd40d451.
--- drivers/nvme/host/apple.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/nvme/host/apple.c +8 -4
@@ -239,7 +239,7 @@ static unsigned int apple_nvme_queue_depth(struct apple_nvme_queue *q) {struct apple_nvme *anv =queue_to_apple_nvme (q); -if (q->is_adminq) +if (q->is_adminq && anv->hw->has_lsq_nvmmu)return APPLE_NVME_AQ_DEPTH ;return anv->hw->max_queue_depth;
@@ -317,7 +317,7 @@ static void apple_nvme_submit_cmd_t8015(struct apple_nvme_queue *q,memcpy ((void *)q->sqes + (q->sq_tail <<APPLE_NVME_IOSQES ), cmd,sizeof (*cmd)); -if (++q->sq_tail ==apple_nvme_queue_depth (q)) +if (++q->sq_tail == anv->hw->max_queue_depth) q->sq_tail =0 ;writel (q->sq_tail, q->sq_db);
@@ -1128,7 +1128,10 @@ static void apple_nvme_reset_work(struct work_struct *work) }/* Setup the admin queue */ - aqa =APPLE_NVME_AQ_DEPTH -1 ; +if (anv->hw->has_lsq_nvmmu) + aqa =APPLE_NVME_AQ_DEPTH -1 ; +else + aqa = anv->hw->max_queue_depth -1 ; aqa |= aqa <<16 ;writel (aqa, anv->mmio_nvme +NVME_REG_AQA );writeq (anv->adminq.sq_dma_addr, anv->mmio_nvme +NVME_REG_ASQ );
@@ -1311,7 +1314,8 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)* both queues. The admin queue gets the first APPLE_NVME_AQ_DEPTH which * must be marked as reserved in the IO queue. */ - anv->tagset.reserved_tags =APPLE_NVME_AQ_DEPTH ; +if (anv->hw->has_lsq_nvmmu) + anv->tagset.reserved_tags =APPLE_NVME_AQ_DEPTH ; anv->tagset.queue_depth = anv->hw->max_queue_depth -1 ; anv->tagset.timeout =NVME_IO_TIMEOUT ; anv->tagset.numa_node =NUMA_NO_NODE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 685/1193 Revert "nvme-apple: Drop the PRP null check chicken bit"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit ca6b14f01d0993992d2c4bfd972c1f5c46284745.
--- drivers/nvme/host/apple.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/nvme/host/apple.c +14 -0
@@ -47,6 +47,9 @@#define APPLE_ANS_BOOT_STATUS 0x1300#define APPLE_ANS_BOOT_STATUS_OK 0xde71ce55 +#define APPLE_ANS_UNKNOWN_CTRL 0x24008 +#define APPLE_ANS_PRP_NULL_CHECK BIT(11) +#define APPLE_ANS_LINEAR_SQ_CTRL 0x24908#define APPLE_ANS_LINEAR_SQ_EN BIT(0)
@@ -1125,6 +1128,17 @@ static void apple_nvme_reset_work(struct work_struct *work)/* Setup the NVMMU for the maximum admin and IO queue depth */ writel (anv->hw->max_queue_depth -1 , anv->mmio_nvme +APPLE_NVMMU_NUM_TCBS ); + +/* +* This is probably a chicken bit: without it all commands +* where any PRP is set to zero (including those that don't use +* that field) fail and the co-processor complains about +* "completed with err BAD_CMD-" or a "NULL_PRP_PTR_ERR" in the +* syslog +*/ +writel (readl (anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL ) & + ~APPLE_ANS_PRP_NULL_CHECK , + anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL ); }/* Setup the admin queue */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 686/1193 Revert "nvme: apple: Add Apple A11 support"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 7256eed48ce7d78ab9689d84135b77a15454de55.
--- drivers/nvme/host/apple.c | 197 ++++++++++++-------------------------- 1 file changed, 60 insertions(+), 137 deletions(-)
drivers/nvme/host/apple.c +60 -137
@@ -35,6 +35,7 @@#include "nvme.h" #define APPLE_ANS_BOOT_TIMEOUT USEC_PER_SEC +#define APPLE_ANS_MAX_QUEUE_DEPTH 64#define APPLE_ANS_COPROC_CPU_CONTROL 0x44#define APPLE_ANS_COPROC_CPU_CONTROL_RUN BIT(4)
@@ -74,8 +75,6 @@#define APPLE_NVME_AQ_DEPTH 2#define APPLE_NVME_AQ_MQ_TAG_DEPTH (APPLE_NVME_AQ_DEPTH - 1) -#define APPLE_NVME_IOSQES 7 -/* * These can be higher, but we need to ensure that any command doesn't * require an sg allocation that needs more than a page of data.
@@ -143,7 +142,6 @@ struct apple_nvme_queue {u32 __iomem *sq_db;u32 __iomem *cq_db; -u16 sq_tail;u16 cq_head;u8 cq_phase;
@@ -185,17 +183,11 @@ struct apple_nvme_iod {struct scatterlist *sg; }; -struct apple_nvme_hw { -bool has_lsq_nvmmu; -u32 max_queue_depth; -}; -struct apple_nvme {struct device *dev;void __iomem *mmio_coproc;void __iomem *mmio_nvme; -const struct apple_nvme_hw *hw;struct device **pd_dev;struct device_link **pd_link;
@@ -240,12 +232,10 @@ static inline struct apple_nvme *queue_to_apple_nvme(struct apple_nvme_queue *q)static unsigned int apple_nvme_queue_depth (struct apple_nvme_queue *q) { -struct apple_nvme *anv =queue_to_apple_nvme (q); - -if (q->is_adminq && anv->hw->has_lsq_nvmmu) +if (q->is_adminq)return APPLE_NVME_AQ_DEPTH ; -return anv->hw->max_queue_depth; +return APPLE_ANS_MAX_QUEUE_DEPTH ; }static void apple_nvme_rtkit_crashed (void *cookie)
@@ -307,28 +297,7 @@ static void apple_nvmmu_inval(struct apple_nvme_queue *q, unsigned int tag) "NVMMU TCB invalidation failed\n"); } -static void apple_nvme_submit_cmd_t8015 (struct apple_nvme_queue *q, -struct nvme_command *cmd) -{ -struct apple_nvme *anv =queue_to_apple_nvme (q); - -spin_lock_irq (&anv->lock); - -if (q->is_adminq) -memcpy (&q->sqes[q->sq_tail], cmd,sizeof (*cmd)); -else -memcpy ((void *)q->sqes + (q->sq_tail <<APPLE_NVME_IOSQES ), - cmd,sizeof (*cmd)); - -if (++q->sq_tail == anv->hw->max_queue_depth) - q->sq_tail =0 ; - -writel (q->sq_tail, q->sq_db); -spin_unlock_irq (&anv->lock); -} - - -static void apple_nvme_submit_cmd_t8103 (struct apple_nvme_queue *q, +static void apple_nvme_submit_cmd (struct apple_nvme_queue *q,struct nvme_command *cmd) {struct apple_nvme *anv =queue_to_apple_nvme (q);
@@ -640,8 +609,7 @@ static inline void apple_nvme_handle_cqe(struct apple_nvme_queue *q,__u16 command_id =READ_ONCE (cqe->command_id);struct request *req; -if (anv->hw->has_lsq_nvmmu) -apple_nvmmu_inval (q, command_id); +apple_nvmmu_inval (q, command_id); req =nvme_find_rq (apple_nvme_queue_tagset (anv, q), command_id);if (unlikely (!req)) {
@@ -735,7 +703,7 @@ static int apple_nvme_create_cq(struct apple_nvme *anv) c.create_cq.opcode = nvme_admin_create_cq; c.create_cq.prp1 =cpu_to_le64 (anv->ioq.cq_dma_addr); c.create_cq.cqid =cpu_to_le16 (1 ); - c.create_cq.qsize =cpu_to_le16 (anv->hw->max_queue_depth -1 ); + c.create_cq.qsize =cpu_to_le16 (APPLE_ANS_MAX_QUEUE_DEPTH -1 ); c.create_cq.cq_flags =cpu_to_le16 (NVME_QUEUE_PHYS_CONTIG |NVME_CQ_IRQ_ENABLED ); c.create_cq.irq_vector =cpu_to_le16 (0 );
@@ -763,7 +731,7 @@ static int apple_nvme_create_sq(struct apple_nvme *anv) c.create_sq.opcode = nvme_admin_create_sq; c.create_sq.prp1 =cpu_to_le64 (anv->ioq.sq_dma_addr); c.create_sq.sqid =cpu_to_le16 (1 ); - c.create_sq.qsize =cpu_to_le16 (anv->hw->max_queue_depth -1 ); + c.create_sq.qsize =cpu_to_le16 (APPLE_ANS_MAX_QUEUE_DEPTH -1 ); c.create_sq.sq_flags =cpu_to_le16 (NVME_QUEUE_PHYS_CONTIG ); c.create_sq.cqid =cpu_to_le16 (1 );
@@ -815,12 +783,7 @@ static blk_status_t apple_nvme_queue_rq(struct blk_mq_hw_ctx *hctx, }nvme_start_request (req); - -if (anv->hw->has_lsq_nvmmu) -apple_nvme_submit_cmd_t8103 (q, cmnd); -else -apple_nvme_submit_cmd_t8015 (q, cmnd); - +apple_nvme_submit_cmd (q, cmnd);return BLK_STS_OK ; out_free_cmd:
@@ -1024,13 +987,11 @@ static const struct blk_mq_ops apple_nvme_mq_ops = {static void apple_nvme_init_queue (struct apple_nvme_queue *q) {unsigned int depth =apple_nvme_queue_depth (q); -struct apple_nvme *anv =queue_to_apple_nvme (q); q->cq_head =0 ; q->cq_phase =1 ; -if (anv->hw->has_lsq_nvmmu) -memset (q->tcbs,0 , anv->hw->max_queue_depth - *sizeof (struct apple_nvmmu_tcb )); +memset (q->tcbs,0 , +APPLE_ANS_MAX_QUEUE_DEPTH *sizeof (struct apple_nvmmu_tcb ));memset (q->cqes,0 , depth *sizeof (struct nvme_completion ));apple_nvme_enable_queue (q); }
@@ -1112,55 +1073,49 @@ static void apple_nvme_reset_work(struct work_struct *work)dma_set_max_seg_size (anv->dev,0xffffffff ); -if (anv->hw->has_lsq_nvmmu) { -/* -* Enable NVMMU and linear submission queues which is required -* since T6000. -*/ -writel (APPLE_ANS_LINEAR_SQ_EN , - anv->mmio_nvme +APPLE_ANS_LINEAR_SQ_CTRL ); +/* +* Enable NVMMU and linear submission queues. +* While we could keep those disabled and pretend this is slightly +* more common NVMe controller we'd still need some quirks (e.g. +* sq entries will be 128 bytes) and Apple might drop support for +* that mode in the future. +*/ +writel (APPLE_ANS_LINEAR_SQ_EN , + anv->mmio_nvme +APPLE_ANS_LINEAR_SQ_CTRL ); -/* Allow as many pending command as possible for both queues */ -writel (anv->hw->max_queue_depth - | (anv->hw->max_queue_depth <<16 ), anv->mmio_nvme - +APPLE_ANS_MAX_PEND_CMDS_CTRL ); +/* Allow as many pending command as possible for both queues */ +writel (APPLE_ANS_MAX_QUEUE_DEPTH | (APPLE_ANS_MAX_QUEUE_DEPTH <<16 ), + anv->mmio_nvme +APPLE_ANS_MAX_PEND_CMDS_CTRL ); -/* Setup the NVMMU for the maximum admin and IO queue depth */ -writel (anv->hw->max_queue_depth -1 , - anv->mmio_nvme +APPLE_NVMMU_NUM_TCBS ); +/* Setup the NVMMU for the maximum admin and IO queue depth */ +writel (APPLE_ANS_MAX_QUEUE_DEPTH -1 , + anv->mmio_nvme +APPLE_NVMMU_NUM_TCBS ); -/* -* This is probably a chicken bit: without it all commands -* where any PRP is set to zero (including those that don't use -* that field) fail and the co-processor complains about -* "completed with err BAD_CMD-" or a "NULL_PRP_PTR_ERR" in the -* syslog -*/ -writel (readl (anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL ) & - ~APPLE_ANS_PRP_NULL_CHECK , - anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL ); - } +/* +* This is probably a chicken bit: without it all commands where any PRP +* is set to zero (including those that don't use that field) fail and +* the co-processor complains about "completed with err BAD_CMD-" or +* a "NULL_PRP_PTR_ERR" in the syslog +*/ +writel (readl (anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL ) & + ~APPLE_ANS_PRP_NULL_CHECK , + anv->mmio_nvme +APPLE_ANS_UNKNOWN_CTRL );/* Setup the admin queue */ -if (anv->hw->has_lsq_nvmmu) - aqa =APPLE_NVME_AQ_DEPTH -1 ; -else - aqa = anv->hw->max_queue_depth -1 ; + aqa =APPLE_NVME_AQ_DEPTH -1 ; aqa |= aqa <<16 ;writel (aqa, anv->mmio_nvme +NVME_REG_AQA );writeq (anv->adminq.sq_dma_addr, anv->mmio_nvme +NVME_REG_ASQ );writeq (anv->adminq.cq_dma_addr, anv->mmio_nvme +NVME_REG_ACQ ); -if (anv->hw->has_lsq_nvmmu) { -/* Setup NVMMU for both queues */ -writeq (anv->adminq.tcb_dma_addr, - anv->mmio_nvme +APPLE_NVMMU_ASQ_TCB_BASE ); -writeq (anv->ioq.tcb_dma_addr, - anv->mmio_nvme +APPLE_NVMMU_IOSQ_TCB_BASE ); - } +/* Setup NVMMU for both queues */ +writeq (anv->adminq.tcb_dma_addr, + anv->mmio_nvme +APPLE_NVMMU_ASQ_TCB_BASE ); +writeq (anv->ioq.tcb_dma_addr, + anv->mmio_nvme +APPLE_NVMMU_IOSQ_TCB_BASE ); anv->ctrl.sqsize = - anv->hw->max_queue_depth -1 ;/* 0's based queue depth */ +APPLE_ANS_MAX_QUEUE_DEPTH -1 ;/* 0's based queue depth */ anv->ctrl.cap =readq (anv->mmio_nvme +NVME_REG_CAP );dev_dbg (anv->dev,"Enabling controller now" );
@@ -1328,9 +1283,8 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)* both queues. The admin queue gets the first APPLE_NVME_AQ_DEPTH which * must be marked as reserved in the IO queue. */ -if (anv->hw->has_lsq_nvmmu) - anv->tagset.reserved_tags =APPLE_NVME_AQ_DEPTH ; - anv->tagset.queue_depth = anv->hw->max_queue_depth -1 ; + anv->tagset.reserved_tags =APPLE_NVME_AQ_DEPTH ; + anv->tagset.queue_depth =APPLE_ANS_MAX_QUEUE_DEPTH -1 ; anv->tagset.timeout =NVME_IO_TIMEOUT ; anv->tagset.numa_node =NUMA_NO_NODE ; anv->tagset.cmd_size =sizeof (struct apple_nvme_iod );
@@ -1355,7 +1309,6 @@ static int apple_nvme_queue_alloc(struct apple_nvme *anv, struct apple_nvme_queue *q) {unsigned int depth =apple_nvme_queue_depth (q); -size_t iosq_size; q->cqes = dmam_alloc_coherent(anv->dev, depth * sizeof(struct nvme_completion),
@@ -1363,28 +1316,22 @@ static int apple_nvme_queue_alloc(struct apple_nvme *anv,if (!q->cqes)return -ENOMEM ; -if (anv->hw->has_lsq_nvmmu) - iosq_size = depth *sizeof (struct nvme_command ); -else - iosq_size = depth <<APPLE_NVME_IOSQES ; - - q->sqes =dmam_alloc_coherent (anv->dev, iosq_size, + q->sqes =dmam_alloc_coherent (anv->dev, + depth *sizeof (struct nvme_command ), &q->sq_dma_addr,GFP_KERNEL );if (!q->sqes)return -ENOMEM ; -if (anv->hw->has_lsq_nvmmu) { -/* -* We need the maximum queue depth here because the NVMMU only -* has a single depth configuration shared between both queues. -*/ - q->tcbs =dmam_alloc_coherent (anv->dev, - anv->hw->max_queue_depth * -sizeof (struct apple_nvmmu_tcb ), - &q->tcb_dma_addr,GFP_KERNEL ); -if (!q->tcbs) -return -ENOMEM ; - } +/* +* We need the maximum queue depth here because the NVMMU only has a +* single depth configuration shared between both queues. +*/ + q->tcbs =dmam_alloc_coherent (anv->dev, +APPLE_ANS_MAX_QUEUE_DEPTH * +sizeof (struct apple_nvmmu_tcb ), + &q->tcb_dma_addr,GFP_KERNEL ); +if (!q->tcbs) +return -ENOMEM ;/* * initialize phase to make sure the allocated and empty memory
@@ -1468,12 +1415,6 @@ static struct apple_nvme *apple_nvme_alloc(struct platform_device *pdev) anv->adminq.is_adminq = true;platform_set_drvdata (pdev, anv); - anv->hw =of_device_get_match_data (&pdev->dev); -if (!anv->hw) { - ret = -ENODEV ; - goto put_dev; - } - ret =apple_nvme_attach_genpd (anv);if (ret <0 ) {dev_err_probe (dev, ret,"Failed to attach power domains" );
@@ -1505,17 +1446,10 @@ static struct apple_nvme *apple_nvme_alloc(struct platform_device *pdev) goto put_dev; } -if (anv->hw->has_lsq_nvmmu) { - anv->adminq.sq_db = anv->mmio_nvme +APPLE_ANS_LINEAR_ASQ_DB ; - anv->adminq.cq_db = anv->mmio_nvme +APPLE_ANS_ACQ_DB ; - anv->ioq.sq_db = anv->mmio_nvme +APPLE_ANS_LINEAR_IOSQ_DB ; - anv->ioq.cq_db = anv->mmio_nvme +APPLE_ANS_IOCQ_DB ; - }else { - anv->adminq.sq_db = anv->mmio_nvme +NVME_REG_DBS ; - anv->adminq.cq_db = anv->mmio_nvme +APPLE_ANS_ACQ_DB ; - anv->ioq.sq_db = anv->mmio_nvme +NVME_REG_DBS +8 ; - anv->ioq.cq_db = anv->mmio_nvme +APPLE_ANS_IOCQ_DB ; - } + anv->adminq.sq_db = anv->mmio_nvme +APPLE_ANS_LINEAR_ASQ_DB ; + anv->adminq.cq_db = anv->mmio_nvme +APPLE_ANS_ACQ_DB ; + anv->ioq.sq_db = anv->mmio_nvme +APPLE_ANS_LINEAR_IOSQ_DB ; + anv->ioq.cq_db = anv->mmio_nvme +APPLE_ANS_IOCQ_DB ; anv->sart =devm_apple_sart_get (dev);if (IS_ERR (anv->sart)) {
@@ -1692,19 +1626,8 @@ static int apple_nvme_suspend(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(apple_nvme_pm_ops, apple_nvme_suspend, apple_nvme_resume); -static const struct apple_nvme_hw apple_nvme_t8015_hw = { - .has_lsq_nvmmu = false, - .max_queue_depth =16 , -}; - -static const struct apple_nvme_hw apple_nvme_t8103_hw = { - .has_lsq_nvmmu = true, - .max_queue_depth =64 , -}; -static const struct of_device_id apple_nvme_of_match[] = { - { .compatible ="apple,t8015-nvme-ans2" , .data = &apple_nvme_t8015_hw }, - { .compatible ="apple,nvme-ans2" , .data = &apple_nvme_t8103_hw }, + { .compatible ="apple,nvme-ans2" }, {}, };MODULE_DEVICE_TABLE (of, apple_nvme_of_match);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 687/1193 Revert "selftests/mm: skip COW tmpfile cases when fallocate() is unsupported"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit bc8be70fdeb94a15a3cd534ac8eea69574b8149c.
--- tools/testing/selftests/mm/cow.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
tools/testing/selftests/mm/cow.c +2 -7
@@ -1670,13 +1670,8 @@ 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)) { -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 ); - } +ksft_perror ("fallocate() failed" ); +log_test_result (KSFT_FAIL ); goto close; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 688/1193 Revert "selftests/mm: report unique test names for each cow test"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 4498f617a4948e6dd8a8bf5e94c1920acafbe70b.
--- tools/testing/selftests/mm/cow.c | 333 +++++++++++-------------------- 1 file changed, 116 insertions(+), 217 deletions(-)
tools/testing/selftests/mm/cow.c +116 -217
@@ -78,12 +78,9 @@ struct comm_pipes {static int setup_comm_pipes (struct comm_pipes *comm_pipes) { -if (pipe (comm_pipes->child_ready) <0 ) { -ksft_perror ("pipe()" ); +if (pipe (comm_pipes->child_ready) <0 )return -errno; - }if (pipe (comm_pipes->parent_ready) <0 ) { -ksft_perror ("pipe()" );close (comm_pipes->child_ready[0 ]);close (comm_pipes->child_ready[1 ]);return -errno;
@@ -176,14 +173,13 @@ static void do_test_cow_in_parent(char *mem, size_t size, bool do_mprotect, ret =setup_comm_pipes (&comm_pipes);if (ret) { -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("pipe() failed\n" );return ; } ret =fork ();if (ret <0 ) { -ksft_perror ("fork() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fork() failed\n" ); goto close_comm_pipes; }else if (!ret) {exit (fn (mem, size, &comm_pipes));
@@ -198,18 +194,9 @@ static void do_test_cow_in_parent(char *mem, size_t size, bool do_mprotect,* write-faults by directly mapping pages writable. */ ret =mprotect (mem, size,PROT_READ ); + ret |=mprotect (mem, size,PROT_READ |PROT_WRITE );if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); -write (comm_pipes.parent_ready[1 ],"0" ,1 ); -wait (&ret); - goto close_comm_pipes; - } - - ret =mprotect (mem, size,PROT_READ |PROT_WRITE ); -if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mprotect() failed\n" );write (comm_pipes.parent_ready[1 ],"0" ,1 );wait (&ret); goto close_comm_pipes;
@@ -227,16 +214,16 @@ static void do_test_cow_in_parent(char *mem, size_t size, bool do_mprotect, ret = -EINVAL ;if (!ret) { -log_test_result (KSFT_PASS ); +ksft_test_result_pass ("No leak from parent into child\n" ); }else if (xfail) {/* * With hugetlb, some vmsplice() tests are currently expected to * fail because (a) harder to fix and (b) nobody really cares. * Flag them as expected failure for now. */ -log_test_result (KSFT_XFAIL ); +ksft_test_result_xfail ("Leak from parent into child\n" ); }else { -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("Leak from parent into child\n" ); } close_comm_pipes:close_comm_pipes (&comm_pipes);
@@ -285,29 +272,26 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size, ret =setup_comm_pipes (&comm_pipes);if (ret) { -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("pipe() failed\n" ); goto free; }if (pipe (fds) <0 ) { -ksft_perror ("pipe() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("pipe() failed\n" ); goto close_comm_pipes; }if (before_fork) { transferred =vmsplice (fds[1 ], &iov,1 ,0 );if (transferred <=0 ) { -ksft_print_msg ("vmsplice() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("vmsplice() failed\n" ); goto close_pipe; } } ret =fork ();if (ret <0 ) { -ksft_perror ("fork() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fork() failed\n" ); goto close_pipe; }else if (!ret) {write (comm_pipes.child_ready[1 ],"0" ,1 );
@@ -321,8 +305,7 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size,if (!before_fork) { transferred =vmsplice (fds[1 ], &iov,1 ,0 );if (transferred <=0 ) { -ksft_perror ("vmsplice() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("vmsplice() failed\n" );wait (&ret); goto close_pipe; }
@@ -331,8 +314,7 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size,while (read (comm_pipes.child_ready[0 ], &buf,1 ) !=1 ) ;if (munmap (mem, size) <0 ) { -ksft_perror ("munmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("munmap() failed\n" ); goto close_pipe; }write (comm_pipes.parent_ready[1 ],"0" ,1 );
@@ -340,8 +322,7 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size,/* Wait until the child is done writing. */ wait (&ret);if (!WIFEXITED (ret)) { -ksft_perror ("wait() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("wait() failed\n" ); goto close_pipe; }
@@ -349,23 +330,22 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size,for (total =0 ; total < transferred; total += cur) { cur =read (fds[0 ], new + total, transferred - total);if (cur <0 ) { -ksft_perror ("read() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("read() failed\n" ); goto close_pipe; } }if (!memcmp (old, new, transferred)) { -log_test_result (KSFT_PASS ); +ksft_test_result_pass ("No leak from child into parent\n" ); }else if (xfail) {/* * With hugetlb, some vmsplice() tests are currently expected to * fail because (a) harder to fix and (b) nobody really cares. * Flag them as expected failure for now. */ -log_test_result (KSFT_XFAIL ); +ksft_test_result_xfail ("Leak from child into parent\n" ); }else { -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("Leak from child into parent\n" ); } close_pipe:close (fds[0 ]);
@@ -402,14 +382,13 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork) ret =setup_comm_pipes (&comm_pipes);if (ret) { -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("pipe() failed\n" );return ; } file =tmpfile ();if (!file) { -ksft_perror ("tmpfile() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("tmpfile() failed\n" ); goto close_comm_pipes; } fd =fileno (file);
@@ -417,16 +396,14 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork) tmp =malloc (size);if (!tmp) { -ksft_print_msg ("malloc() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("malloc() failed\n" ); goto close_file; }/* Skip on errors, as we might just lack kernel support. */ ret =io_uring_queue_init (1 , &ring,0 );if (ret <0 ) { -ksft_print_msg ("io_uring_queue_init() failed\n" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("io_uring_queue_init() failed\n" ); goto free_tmp; }
@@ -441,8 +418,7 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork) iov.iov_len = size; ret =io_uring_register_buffers (&ring, &iov,1 );if (ret) { -ksft_print_msg ("io_uring_register_buffers() failed\n" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("io_uring_register_buffers() failed\n" ); goto queue_exit; }
@@ -453,8 +429,7 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)*/ ret =fork ();if (ret <0 ) { -ksft_perror ("fork() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fork() failed\n" ); goto unregister_buffers; }else if (!ret) {write (comm_pipes.child_ready[1 ],"0" ,1 );
@@ -474,17 +449,10 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)* if the page is mapped R/O vs. R/W). */ ret =mprotect (mem, size,PROT_READ ); -if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); - goto unregister_buffers; - } -clear_softdirty (); - ret =mprotect (mem, size,PROT_READ |PROT_WRITE ); + ret |=mprotect (mem, size,PROT_READ |PROT_WRITE );if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mprotect() failed\n" ); goto unregister_buffers; } }
@@ -496,29 +464,25 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)memset (mem,0xff , size); sqe =io_uring_get_sqe (&ring);if (!sqe) { -ksft_print_msg ("io_uring_get_sqe() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("io_uring_get_sqe() failed\n" ); goto quit_child; }io_uring_prep_write_fixed (sqe, fd, mem, size,0 ,0 ); ret =io_uring_submit (&ring);if (ret <0 ) { -ksft_print_msg ("io_uring_submit() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("io_uring_submit() failed\n" ); goto quit_child; } ret =io_uring_wait_cqe (&ring, &cqe);if (ret <0 ) { -ksft_print_msg ("io_uring_wait_cqe() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("io_uring_wait_cqe() failed\n" ); goto quit_child; }if (cqe->res != size) { -ksft_print_msg ("write_fixed failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("write_fixed failed\n" ); goto quit_child; }io_uring_cqe_seen (&ring, cqe);
@@ -528,18 +492,15 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)while (total < size) { cur =pread (fd, tmp + total, size - total, total);if (cur <0 ) { -ksft_print_msg ("pread() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("pread() failed\n" ); goto quit_child; } total += cur; }/* Finally, check if we read what we expected. */ -if (!memcmp (mem, tmp, size)) -log_test_result (KSFT_PASS ); -else -log_test_result (KSFT_FAIL ); +ksft_test_result (!memcmp (mem, tmp, size), +"Longterm R/W pin is reliable\n" ); quit_child:if (use_fork) {
@@ -587,21 +548,19 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,int ret;if (gup_fd <0 ) { -ksft_print_msg ("gup_test not available\n" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("gup_test not available\n" );return ; } tmp =malloc (size);if (!tmp) { -ksft_print_msg ("malloc() failed\n" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("malloc() failed\n" );return ; } ret =setup_comm_pipes (&comm_pipes);if (ret) { -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("pipe() failed\n" ); goto free_tmp; }
@@ -616,8 +575,7 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,*/ ret =fork ();if (ret <0 ) { -ksft_perror ("fork() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fork() failed\n" ); goto close_comm_pipes; }else if (!ret) {write (comm_pipes.child_ready[1 ],"0" ,1 );
@@ -654,8 +612,7 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,clear_softdirty (); ret |=mprotect (mem, size,PROT_READ |PROT_WRITE );if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mprotect() failed\n" ); goto close_comm_pipes; }break ;
@@ -670,11 +627,9 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test, ret =ioctl (gup_fd,PIN_LONGTERM_TEST_START , &args);if (ret) {if (errno ==EINVAL ) - ret =KSFT_SKIP ; +ksft_test_result_skip ("PIN_LONGTERM_TEST_START failed\n" );else - ret =KSFT_FAIL ; -ksft_perror ("PIN_LONGTERM_TEST_START failed" ); -log_test_result (ret); +ksft_test_result_fail ("PIN_LONGTERM_TEST_START failed\n" ); goto wait; }
@@ -687,26 +642,22 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,*/ tmp_val = (__u64 )(uintptr_t )tmp; ret =ioctl (gup_fd,PIN_LONGTERM_TEST_READ , &tmp_val); -if (ret) { -ksft_perror ("PIN_LONGTERM_TEST_READ failed" ); -log_test_result (KSFT_FAIL ); - }else { -if (!memcmp (mem, tmp, size)) -log_test_result (KSFT_PASS ); -else -log_test_result (KSFT_FAIL ); - } +if (ret) +ksft_test_result_fail ("PIN_LONGTERM_TEST_READ failed\n" ); +else +ksft_test_result (!memcmp (mem, tmp, size), +"Longterm R/O pin is reliable\n" ); ret =ioctl (gup_fd,PIN_LONGTERM_TEST_STOP );if (ret) -ksft_perror ("PIN_LONGTERM_TEST_STOP failed" ); +ksft_print_msg ("[INFO] PIN_LONGTERM_TEST_STOP failed\n" ); wait:switch (test) {case RO_PIN_TEST_SHARED :write (comm_pipes.parent_ready[1 ],"0" ,1 );wait (&ret);if (!WIFEXITED (ret)) -ksft_perror ("wait() failed" ); +ksft_print_msg ("[INFO] wait() failed\n" );break ;default :break ;
@@ -761,16 +712,14 @@ static void do_run_with_base_page(test_fn fn, bool swapout) mem =mmap (NULL , pagesize,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (mem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" );return ; } ret =madvise (mem, pagesize,MADV_NOHUGEPAGE );/* Ignore if not around on a kernel. */ if (ret && errno !=EINVAL ) { -ksft_perror ("MADV_NOHUGEPAGE failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_NOHUGEPAGE failed\n" ); goto munmap; }
@@ -780,8 +729,7 @@ static void do_run_with_base_page(test_fn fn, bool swapout)if (swapout) {madvise (mem, pagesize,MADV_PAGEOUT );if (!pagemap_is_swapped (pagemap_fd, mem)) { -ksft_print_msg ("MADV_PAGEOUT did not work, is swap enabled?\n" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("MADV_PAGEOUT did not work, is swap enabled?\n" ); goto munmap; } }
@@ -793,13 +741,13 @@ static void do_run_with_base_page(test_fn fn, bool swapout)static void run_with_base_page (test_fn fn,const char *desc) { -log_test_start ("%s ... with base page" , desc); +ksft_print_msg ("[RUN] %s ... with base page\n" , desc);do_run_with_base_page (fn, false); }static void run_with_base_page_swap (test_fn fn,const char *desc) { -log_test_start ("%s ... with swapped out base page" , desc); +ksft_print_msg ("[RUN] %s ... with swapped out base page\n" , desc);do_run_with_base_page (fn, true); }
@@ -825,8 +773,7 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize) mmap_mem =mmap (NULL , mmap_size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (mmap_mem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" );return ; }
@@ -835,8 +782,7 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize) ret =madvise (mem, thpsize,MADV_HUGEPAGE );if (ret) { -ksft_perror ("MADV_HUGEPAGE failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_HUGEPAGE failed\n" ); goto munmap; }
@@ -846,8 +792,7 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)*/ mem[0 ] =0 ;if (!pagemap_is_populated (pagemap_fd, mem + thpsize - pagesize)) { -ksft_print_msg ("Did not get a THP populated\n" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("Did not get a THP populated\n" ); goto munmap; }memset (mem,0 , thpsize);
@@ -867,14 +812,12 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)*/ ret =mprotect (mem + pagesize, pagesize,PROT_READ );if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mprotect() failed\n" ); goto munmap; } ret =mprotect (mem + pagesize, pagesize,PROT_READ |PROT_WRITE );if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mprotect() failed\n" ); goto munmap; }break ;
@@ -886,8 +829,7 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)*/ ret =madvise (mem + pagesize, thpsize - pagesize,MADV_DONTNEED );if (ret) { -ksft_perror ("MADV_DONTNEED failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_DONTNEED failed\n" ); goto munmap; } size = pagesize;
@@ -901,15 +843,13 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize) mremap_mem =mmap (NULL , mremap_size,PROT_NONE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (mremap_mem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto munmap; } tmp =mremap (mem + mremap_size, mremap_size, mremap_size,MREMAP_MAYMOVE |MREMAP_FIXED , mremap_mem);if (tmp != mremap_mem) { -ksft_perror ("mremap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mremap() failed\n" ); goto munmap; } size = mremap_size;
@@ -922,14 +862,12 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)*/ ret =madvise (mem + pagesize, thpsize - pagesize,MADV_DONTFORK );if (ret) { -ksft_perror ("MADV_DONTFORK failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_DONTFORK failed\n" ); goto munmap; } ret =fork ();if (ret <0 ) { -ksft_perror ("fork() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fork() failed\n" ); goto munmap; }else if (!ret) {exit (0 );
@@ -938,8 +876,7 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)/* Allow for sharing all pages again. */ ret =madvise (mem + pagesize, thpsize - pagesize,MADV_DOFORK );if (ret) { -ksft_perror ("MADV_DOFORK failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_DOFORK failed\n" ); goto munmap; }break ;
@@ -953,8 +890,7 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)case THP_RUN_SINGLE_PTE_SWAPOUT :madvise (mem, size,MADV_PAGEOUT );if (!range_is_swapped (mem, size)) { -ksft_print_msg ("MADV_PAGEOUT did not work, is swap enabled?\n" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("MADV_PAGEOUT did not work, is swap enabled?\n" ); goto munmap; }break ;
@@ -971,56 +907,56 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)static void run_with_thp (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_PMD , size); }static void run_with_thp_swap (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with swapped-out THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with swapped-out THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_PMD_SWAPOUT , size); }static void run_with_pte_mapped_thp (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with PTE-mapped THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with PTE-mapped THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_PTE , size); }static void run_with_pte_mapped_thp_swap (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with swapped-out, PTE-mapped THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with swapped-out, PTE-mapped THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_PTE_SWAPOUT , size); }static void run_with_single_pte_of_thp (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with single PTE of THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with single PTE of THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_SINGLE_PTE , size); }static void run_with_single_pte_of_thp_swap (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with single PTE of swapped-out THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with single PTE of swapped-out THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_SINGLE_PTE_SWAPOUT , size); }static void run_with_partial_mremap_thp (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with partially mremap()'ed THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with partially mremap()'ed THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_PARTIAL_MREMAP , size); }static void run_with_partial_shared_thp (test_fn fn,const char *desc,size_t size) { -log_test_start ("%s ... with partially shared THP (%zu kB)" , +ksft_print_msg ("[RUN] %s ... with partially shared THP (%zu kB)\n" , desc, size /1024 );do_run_with_thp (fn,THP_RUN_PARTIAL_SHARED , size); }
@@ -1030,15 +966,14 @@ static void run_with_hugetlb(test_fn fn, const char *desc, size_t hugetlbsize)int flags =MAP_PRIVATE |MAP_ANONYMOUS |MAP_HUGETLB ;char *mem, *dummy; -log_test_start ("%s ... with hugetlb (%zu kB)" , desc, +ksft_print_msg ("[RUN] %s ... with hugetlb (%zu kB)\n" , desc, hugetlbsize /1024 ); flags |=__builtin_ctzll (hugetlbsize) <<MAP_HUGE_SHIFT ; mem =mmap (NULL , hugetlbsize,PROT_READ |PROT_WRITE , flags,-1 ,0 );if (mem ==MAP_FAILED ) { -ksft_perror ("need more free huge pages" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("need more free huge pages\n" );return ; }
@@ -1051,8 +986,7 @@ static void run_with_hugetlb(test_fn fn, const char *desc, size_t hugetlbsize)*/ dummy =mmap (NULL , hugetlbsize,PROT_READ |PROT_WRITE , flags,-1 ,0 );if (dummy ==MAP_FAILED ) { -ksft_perror ("need more free huge pages" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("need more free huge pages\n" ); goto munmap; }munmap (dummy, hugetlbsize);
@@ -1245,7 +1179,7 @@ static void do_test_anon_thp_collapse(char *mem, size_t size, ret =setup_comm_pipes (&comm_pipes);if (ret) { -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("pipe() failed\n" );return ; }
@@ -1255,14 +1189,12 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,*/ ret =mprotect (mem + pagesize, pagesize,PROT_READ );if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mprotect() failed\n" ); goto close_comm_pipes; } ret =mprotect (mem + pagesize, pagesize,PROT_READ |PROT_WRITE );if (ret) { -ksft_perror ("mprotect() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mprotect() failed\n" ); goto close_comm_pipes; }
@@ -1271,8 +1203,8 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,/* Collapse before actually COW-sharing the page. */ ret =madvise (mem, size,MADV_COLLAPSE );if (ret) { -ksft_perror ("MADV_COLLAPSE failed" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("MADV_COLLAPSE failed: %s\n" , +strerror (errno)); goto close_comm_pipes; }break ;
@@ -1283,8 +1215,7 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,/* Don't COW-share the upper part of the THP. */ ret =madvise (mem + size /2 , size /2 ,MADV_DONTFORK );if (ret) { -ksft_perror ("MADV_DONTFORK failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_DONTFORK failed\n" ); goto close_comm_pipes; }break ;
@@ -1292,8 +1223,7 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,/* Don't COW-share the lower part of the THP. */ ret =madvise (mem, size /2 ,MADV_DONTFORK );if (ret) { -ksft_perror ("MADV_DONTFORK failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_DONTFORK failed\n" ); goto close_comm_pipes; }break ;
@@ -1303,8 +1233,7 @@ static void do_test_anon_thp_collapse(char *mem, size_t size, ret =fork ();if (ret <0 ) { -ksft_perror ("fork() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fork() failed\n" ); goto close_comm_pipes; }else if (!ret) {switch (test) {
@@ -1338,8 +1267,7 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,*/ ret =madvise (mem, size,MADV_DOFORK );if (ret) { -ksft_perror ("MADV_DOFORK failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("MADV_DOFORK failed\n" );write (comm_pipes.parent_ready[1 ],"0" ,1 );wait (&ret); goto close_comm_pipes;
@@ -1349,8 +1277,8 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,/* Collapse before anyone modified the COW-shared page. */ ret =madvise (mem, size,MADV_COLLAPSE );if (ret) { -ksft_perror ("MADV_COLLAPSE failed" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("MADV_COLLAPSE failed: %s\n" , +strerror (errno));write (comm_pipes.parent_ready[1 ],"0" ,1 );wait (&ret); goto close_comm_pipes;
@@ -1370,10 +1298,7 @@ static void do_test_anon_thp_collapse(char *mem, size_t size,else ret = -EINVAL ; -if (!ret) -log_test_result (KSFT_PASS ); -else -log_test_result (KSFT_FAIL ); +ksft_test_result (!ret,"No leak from parent into child\n" ); close_comm_pipes:close_comm_pipes (&comm_pipes); }
@@ -1458,7 +1383,7 @@ static void run_anon_thp_test_cases(void)for (i =0 ; i <ARRAY_SIZE (anon_thp_test_cases); i++) {struct test_case const *test_case = &anon_thp_test_cases[i]; -log_test_start ("%s" , test_case->desc); +ksft_print_msg ("[RUN] %s\n" , test_case->desc);do_run_with_thp (test_case->fn,THP_RUN_PMD , pmdsize); } }
@@ -1481,10 +1406,8 @@ static void test_cow(char *mem, const char *smem, size_t size)memset (mem,0xff , size);/* See if we still read the old values via the other mapping. */ -if (!memcmp (smem, old, size)) -log_test_result (KSFT_PASS ); -else -log_test_result (KSFT_FAIL ); +ksft_test_result (!memcmp (smem, old, size), +"Other mapping not modified\n" );free (old); }
@@ -1502,20 +1425,18 @@ static void run_with_zeropage(non_anon_test_fn fn, const char *desc) {char *mem, *smem, tmp; -log_test_start ("%s ... with shared zeropage" , desc); +ksft_print_msg ("[RUN] %s ... with shared zeropage\n" , desc); mem =mmap (NULL , pagesize,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANON ,-1 ,0 );if (mem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" );return ; } smem =mmap (NULL , pagesize,PROT_READ ,MAP_PRIVATE |MAP_ANON ,-1 ,0 );if (smem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto munmap; }
@@ -1536,11 +1457,10 @@ static void run_with_huge_zeropage(non_anon_test_fn fn, const char *desc)size_t mmap_size;int ret; -log_test_start ("%s ... with huge zeropage" , desc); +ksft_print_msg ("[RUN] %s ... with huge zeropage\n" , desc);if (!has_huge_zeropage) { -ksft_print_msg ("Huge zeropage not enabled\n" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("Huge zeropage not enabled\n" );return ; }
@@ -1549,15 +1469,13 @@ static void run_with_huge_zeropage(non_anon_test_fn fn, const char *desc) mmap_mem =mmap (NULL , mmap_size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (mmap_mem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" );return ; } mmap_smem =mmap (NULL , mmap_size,PROT_READ ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (mmap_smem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto munmap; }
@@ -1566,15 +1484,9 @@ static void run_with_huge_zeropage(non_anon_test_fn fn, const char *desc) smem = (char *)(((uintptr_t )mmap_smem + pmdsize) & ~(pmdsize -1 )); ret =madvise (mem, pmdsize,MADV_HUGEPAGE ); -if (ret !=0 ) { -ksft_perror ("madvise()" ); -log_test_result (KSFT_FAIL ); - goto munmap; - } ret |=madvise (smem, pmdsize,MADV_HUGEPAGE ); -if (ret !=0 ) { -ksft_perror ("madvise()" ); -log_test_result (KSFT_FAIL ); +if (ret) { +ksft_test_result_fail ("MADV_HUGEPAGE failed\n" ); goto munmap; }
@@ -1603,33 +1515,29 @@ static void run_with_memfd(non_anon_test_fn fn, const char *desc)char *mem, *smem, tmp;int fd; -log_test_start ("%s ... with memfd" , desc); +ksft_print_msg ("[RUN] %s ... with memfd\n" , desc); fd =memfd_create ("test" ,0 );if (fd <0 ) { -ksft_perror ("memfd_create() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("memfd_create() failed\n" );return ; }/* File consists of a single page filled with zeroes. */ if (fallocate (fd,0 ,0 , pagesize)) { -ksft_perror ("fallocate() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fallocate() failed\n" ); goto close; }/* Create a private mapping of the memfd. */ mem =mmap (NULL , pagesize,PROT_READ |PROT_WRITE ,MAP_PRIVATE , fd,0 );if (mem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto close; } smem =mmap (NULL , pagesize,PROT_READ ,MAP_SHARED , fd,0 );if (smem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto munmap; }
@@ -1652,40 +1560,35 @@ static void run_with_tmpfile(non_anon_test_fn fn, const char *desc)FILE *file;int fd; -log_test_start ("%s ... with tmpfile" , desc); +ksft_print_msg ("[RUN] %s ... with tmpfile\n" , desc); file =tmpfile ();if (!file) { -ksft_perror ("tmpfile() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("tmpfile() failed\n" );return ; } fd =fileno (file);if (fd <0 ) { -ksft_perror ("fileno() failed" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("fileno() failed\n" );return ; }/* File consists of a single page filled with zeroes. */ if (fallocate (fd,0 ,0 , pagesize)) { -ksft_perror ("fallocate() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("fallocate() failed\n" ); goto close; }/* Create a private mapping of the memfd. */ mem =mmap (NULL , pagesize,PROT_READ |PROT_WRITE ,MAP_PRIVATE , fd,0 );if (mem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto close; } smem =mmap (NULL , pagesize,PROT_READ ,MAP_SHARED , fd,0 );if (smem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto munmap; }
@@ -1709,22 +1612,20 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,char *mem, *smem, tmp;int fd; -log_test_start ("%s ... with memfd hugetlb (%zu kB)" , desc, +ksft_print_msg ("[RUN] %s ... with memfd hugetlb (%zu kB)\n" , desc, hugetlbsize /1024 ); flags |=__builtin_ctzll (hugetlbsize) <<MFD_HUGE_SHIFT ; fd =memfd_create ("test" , flags);if (fd <0 ) { -ksft_perror ("memfd_create() failed" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("memfd_create() failed\n" );return ; }/* File consists of a single page filled with zeroes. */ if (fallocate (fd,0 ,0 , hugetlbsize)) { -ksft_perror ("need more free huge pages" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("need more free huge pages\n" ); goto close; }
@@ -1732,14 +1633,12 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc, mem =mmap (NULL , hugetlbsize,PROT_READ |PROT_WRITE ,MAP_PRIVATE , fd,0 );if (mem ==MAP_FAILED ) { -ksft_perror ("need more free huge pages" ); -log_test_result (KSFT_SKIP ); +ksft_test_result_skip ("need more free huge pages\n" ); goto close; } smem =mmap (NULL , hugetlbsize,PROT_READ ,MAP_SHARED , fd,0 );if (smem ==MAP_FAILED ) { -ksft_perror ("mmap() failed" ); -log_test_result (KSFT_FAIL ); +ksft_test_result_fail ("mmap() failed\n" ); goto munmap; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 689/1193 Revert "perf tests: Fix flakiness in BPF counters test on hybrid systems"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 1f27602b20119ae9261eb5c608bd1374af630f00.
--- tools/perf/tests/shell/stat_bpf_counters.sh | 28 ++++++++------------- 1 file changed, 10 insertions(+), 18 deletions(-)
tools/perf/tests/shell/stat_bpf_counters.sh +10 -18
@@ -4,26 +4,21 @@ set -e -# Get the first allowed CPU -CPU=$(taskset -c -p $$ | awk -F': ' '{print $2}' | awk -F'[,-]' '{print $1}') -if [ -z "$CPU" ]; then - CPU=0 -fi -workload=(taskset -c "$CPU" awk 'BEGIN { for (i=0; i<10000000; i++) sum+=i }') +workload="perf test -w sqrtloop" -# check whether $2 is within +/- 15% of $1 +# check whether $2 is within +/- 20% of $1 compare_number() { first_num=$1 second_num=$2 - # upper bound is first_num * 115% - upper=$(expr $first_num + $first_num / 20 \* 3 ) - # lower bound is first_num * 85% - lower=$(expr $first_num - $first_num / 20 \* 3 ) + # upper bound is first_num * 120% + upper=$(expr $first_num + $first_num / 5 ) + # lower bound is first_num * 80% + lower=$(expr $first_num - $first_num / 5 ) if [ $second_num -gt $upper ] || [ $second_num -lt $lower ]; then - echo "The difference between $first_num and $second_num are greater than 15%." + echo "The difference between $first_num and $second_num are greater than 20%." exit 1 fi }
@@ -46,12 +41,11 @@ check_counts() test_bpf_counters() { printf "Testing --bpf-counters " - base_instructions=$(perf stat --no-big-num -e instructions:u -- "${workload[@]}" 2>&1 | \ + base_instructions=$(perf stat --no-big-num -e instructions -- $workload 2>&1 | \ awk -v i=0 -v c=0 '/instructions/ { \ if ($1 != "<not") { i++; c += $1 } \ } END { if (i > 0) printf "%.0f", c; else print "<not" }') - bpf_instructions=$(perf stat --no-big-num --bpf-counters -e instructions:u \ - -- "${workload[@]}" 2>&1 | \ + bpf_instructions=$(perf stat --no-big-num --bpf-counters -e instructions -- $workload 2>&1 | \ awk -v i=0 -v c=0 '/instructions/ { \ if ($1 != "<not") { i++; c += $1 } \ } END { if (i > 0) printf "%.0f", c; else print "<not" }')
@@ -63,9 +57,7 @@ test_bpf_counters() test_bpf_modifier() { printf "Testing bpf event modifier " - stat_output=$(perf stat --no-big-num \ - -e instructions/name=base_instructions/u,instructions/name=bpf_instructions/bu \ - -- "${workload[@]}" 2>&1) + stat_output=$(perf stat --no-big-num -e instructions/name=base_instructions/,instructions/name=bpf_instructions/b -- $workload 2>&1) base_instructions=$(echo "$stat_output"| \ awk -v i=0 -v c=0 '/base_instructions/ { \ if ($1 != "<not") { i++; c += $1 } \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 663/1193 smb: client: reject userspace cifs.idmap descriptions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
commit d9d7eeb0cea5b55b82888f443622fd8d4ee064f3 upstream.
cifs.idmap key descriptions carry authority-bearing fields (owner and group SIDs and uid/gid values in "os:"/"gs:"/"oi:"/"gi:" form) that the cifs.idmap upcall helper treats as kernel-originating inputs. Unlike its sibling cifs.spnego, the cifs.idmap key type has no vet_description hook, so userspace can create keys of this type through request_key(2)/add_key(2) and supply those fields without CIFS origin. A request_key(2) call with a non-NULL callout then drives a root usermodehelper upcall (/sbin/request-key -> cifs.idmap) that consumes the unvetted description in root context.
Only accept cifs.idmap descriptions while CIFS is using its private root_cred to request the key. id_to_sid()/sid_to_id() already run under override_creds(root_cred), so the kernel-originated path is unaffected.
This mirrors commit 3da1fdf4efbc ("smb: client: reject userspace cifs.spnego descriptions"), which applied the same restriction to cifs.spnego.
--- fs/smb/client/cifsacl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/smb/client/cifsacl.c +15 -0
@@ -101,8 +101,23 @@ cifs_idmap_key_destroy(struct key *key)kfree (key->payload.data[0 ]); } +static int +cifs_idmap_key_vet_description (const char *description) +{ +/* +* cifs.idmap descriptions are authority-bearing inputs to the +* cifs.idmap upcall helper. Only allow the kernel to create this +* type of key using the private root_cred installed in +* init_cifs_idmap; reject userspace request_key(2)/add_key(2). +*/ +if (current_cred () != root_cred) +return -EPERM ; +return 0 ; +} +static struct key_type cifs_idmap_key_type = { .name ="cifs.idmap" , + .vet_description = cifs_idmap_key_vet_description, .instantiate = cifs_idmap_key_instantiate, .destroy = cifs_idmap_key_destroy, .describe = user_describe,
Greg Kroah-Hartman
maintainerPATCH 690/1193 perf evsel: Add per-thread warning for EOPNOTSUPP open failues
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit f0869f31562bde2ed9131665f8f76ef7a3983383 ]
The mrvl_ddr_pmu will return EOPNOTSUPP if opened in per-thread mode. Give a warning for this similar to EINVAL.
Doing this better supports metric testing with limited permissions when the mrvl_ddr_pmu is present, as the failure to open causes the test to skip and not fail.
--- tools/perf/util/evsel.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/util/evsel.c +4 -0
@@ -3047,6 +3047,10 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,return scnprintf (msg, size,"%s" ,"No hardware sampling interrupt available.\n" );#endif +if (!target__has_cpu (target)) +return scnprintf (msg, size, +"Unsupported event (%s) in per-thread mode, enable system wide with '-a'." , +evsel__name (evsel));break ;case EBUSY :if (find_process ("oprofiled" ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 691/1193 usb: xusbatm: dont rely on id table pointer arithmetic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit eb6cd6d3d8abeac5d7e8251b898067184afdad8a ]
The current code is broken when dynamic ID is involved; in such cases usb_device_id parameter of probe lives on the heap and the pointer arithmetic will get an index that is wildly out of bound. xusbatm initialize the USB device IDs dynamically so it can just use driver_info too.
Even with conversion, xusbatm still cannot support dynamic IDs, so also set no_dynamic_id.
--- drivers/usb/atm/xusbatm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/atm/xusbatm.c +4 -2
@@ -79,7 +79,7 @@ static int xusbatm_bind(struct usbatm_data *usbatm, struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *usb_dev = interface_to_usbdev(intf); -int drv_ix = id - xusbatm_usb_ids; +int drv_ix = id->driver_info;int rx_alt = rx_altsetting[drv_ix];int tx_alt = tx_altsetting[drv_ix];struct usb_interface *rx_intf =xusbatm_find_intf (usb_dev, rx_alt, rx_endpoint[drv_ix]);
@@ -168,7 +168,8 @@ static struct usb_driver xusbatm_usb_driver = { .name = xusbatm_driver_name, .probe = xusbatm_usb_probe, .disconnect = usbatm_usb_disconnect, - .id_table = xusbatm_usb_ids + .id_table = xusbatm_usb_ids, + .no_dynamic_id = 1, };static int __init xusbatm_init (void )
@@ -190,6 +191,7 @@ static int __init xusbatm_init(void) xusbatm_usb_ids[i].match_flags =USB_DEVICE_ID_MATCH_DEVICE ; xusbatm_usb_ids[i].idVendor = vendor[i]; xusbatm_usb_ids[i].idProduct = product[i]; + xusbatm_usb_ids[i].driver_info = i; xusbatm_drivers[i].driver_name = xusbatm_driver_name; xusbatm_drivers[i].bind = xusbatm_bind;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 692/1193 wifi: ath9k_htc: dont store usb_device_id
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit 14d2ac442d660e112efc0ce87ad10085013ed2b1 ]
usb_device_id is not guaranteed to live longer than probe due to presence of dynamic ID. All information apart from driver_data can be easily retrieved from usb_device, so just store driver_data.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 12 ++++++------ drivers/net/wireless/ath/ath9k/hif_usb.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +6 -6
@@ -1097,7 +1097,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) }kfree (buf); -if (IS_AR7010_DEVICE (hif_dev->usb_device_id->driver_info)) +if (IS_AR7010_DEVICE (hif_dev->id_info)) firm_offset =AR7010_FIRMWARE_TEXT ;else firm_offset =AR9271_FIRMWARE_TEXT ;
@@ -1192,7 +1192,7 @@ static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,if (MAJOR_VERSION_REQ ==1 && hif_dev->fw_minor_index ==3 ) {const char *filename; -if (IS_AR7010_DEVICE (hif_dev->usb_device_id->driver_info)) +if (IS_AR7010_DEVICE (hif_dev->id_info)) filename =FIRMWARE_AR7010_1_1 ;else filename =FIRMWARE_AR9271 ;
@@ -1208,7 +1208,7 @@ static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,return -ENOENT ; }else { -if (IS_AR7010_DEVICE (hif_dev->usb_device_id->driver_info)) +if (IS_AR7010_DEVICE (hif_dev->id_info)) chip ="7010" ;else chip ="9271" ;
@@ -1265,9 +1265,9 @@ static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context) ret =ath9k_htc_hw_init (hif_dev->htc_handle, &hif_dev->interface->dev, - hif_dev->usb_device_id->idProduct, +le16_to_cpu (hif_dev->udev->descriptor.idProduct), hif_dev->udev->product, - hif_dev->usb_device_id->driver_info); + hif_dev->id_info);if (ret) { ret = -EINVAL ; goto err_htc_hw_init;
@@ -1381,7 +1381,7 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface, hif_dev->udev = udev; hif_dev->interface = interface; - hif_dev->usb_device_id = id; + hif_dev->id_info = id->driver_info;#ifdef CONFIG_PM udev->reset_resume =1 ;#endif
drivers/net/wireless/ath/ath9k/hif_usb.h +1 -1
@@ -115,7 +115,7 @@ struct cmd_buf {struct hif_device_usb {struct usb_device *udev;struct usb_interface *interface; -const struct usb_device_id *usb_device_id; +int id_info;const void *fw_data;size_t fw_size;struct completion fw_done;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 693/1193 usb: usbtmc: dont store usb_device_id
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit fc045acec1a501c97f84ae184aadce9dae4ba9b2 ]
usb_device_id is not guaranteed to live longer than probe due to presence of dynamic ID. This stored ID is unused so remove it.
--- drivers/usb/class/usbtmc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/class/usbtmc.c +0 -2
@@ -71,7 +71,6 @@ struct usbtmc_dev_capabilities {* allocated for each USBTMC device in the driver's probe function. */ struct usbtmc_device_data { -const struct usb_device_id *id;struct usb_device *usb_dev;struct usb_interface *intf;struct list_head file_list;
@@ -2398,7 +2397,6 @@ static int usbtmc_probe(struct usb_interface *intf,return -ENOMEM ; data->intf = intf; - data->id = id; data->usb_dev =usb_get_dev (interface_to_usbdev (intf));usb_set_intfdata (intf, data);kref_init (&data->kref);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 694/1193 usb: serial: spcp8x5: dont store usb_device_id
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit 934e1322f18c1b58bca431c0d5d01e002060c990 ]
USB probe functions should not keep usb_device_id for longer than probe due to presence of dynamic ID removal. USB serial does not support ID removal, however in this case only driver_data is ever needed, there is no reason keeping the usb_device_id in the first place, so convert it as well.
--- drivers/usb/serial/spcp8x5.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/serial/spcp8x5.c +3 -3
@@ -145,14 +145,14 @@ struct spcp8x5_private {static int spcp8x5_probe (struct usb_serial *serial,const struct usb_device_id *id) { -usb_set_serial_data (serial, (void *)id); +usb_set_serial_data (serial, (void *)id->driver_info);return 0 ; }static int spcp8x5_port_probe (struct usb_serial_port *port) { -const struct usb_device_id *id =usb_get_serial_data (port->serial); +unsigned int quirks = (unsigned int )(unsigned long )usb_get_serial_data (port->serial);struct spcp8x5_private *priv; priv =kzalloc (sizeof (*priv),GFP_KERNEL );
@@ -160,7 +160,7 @@ static int spcp8x5_port_probe(struct usb_serial_port *port)return -ENOMEM ;spin_lock_init (&priv->lock); - priv->quirks = id->driver_info; + priv->quirks = quirks;usb_set_serial_port_data (port, priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 695/1193 media: as102: do not rely on id table address comparison
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit 91a8c8c718889fc8ccf5c38b750d790e9f36f92d ]
The driver info should be retrieved using the driver_info field, not by address comparison.
--- drivers/media/usb/as102/as102_usb_drv.c | 73 ++++++++++--------------- 1 file changed, 30 insertions(+), 43 deletions(-)
drivers/media/usb/as102/as102_usb_drv.c +30 -43
@@ -24,35 +24,33 @@ static void as102_usb_stop_stream(struct as102_dev_t *dev);static int as102_open (struct inode *inode,struct file *file);static int as102_release (struct inode *inode,struct file *file); -static const struct usb_device_id as102_usb_id_table[] = { - {USB_DEVICE (AS102_USB_DEVICE_VENDOR_ID ,AS102_USB_DEVICE_PID_0001 ) }, - {USB_DEVICE (PCTV_74E_USB_VID ,PCTV_74E_USB_PID ) }, - {USB_DEVICE (ELGATO_EYETV_DTT_USB_VID ,ELGATO_EYETV_DTT_USB_PID ) }, - {USB_DEVICE (NBOX_DVBT_DONGLE_USB_VID ,NBOX_DVBT_DONGLE_USB_PID ) }, - {USB_DEVICE (SKY_IT_DIGITAL_KEY_USB_VID ,SKY_IT_DIGITAL_KEY_USB_PID ) }, - { }/* Terminating entry */ +struct as102_dev_info { +const char *name; +/* +* eLNA configuration: devices built on the reference design work best +* with 0xA0, while custom designs seem to require 0xC0 +*/ +uint8_t elna_cfg; }; -/* Note that this table must always have the same number of entries as the -as102_usb_id_table struct */ -static const char *const as102_device_names[] = { -AS102_REFERENCE_DESIGN , -AS102_PCTV_74E , -AS102_ELGATO_EYETV_DTT_NAME , -AS102_NBOX_DVBT_DONGLE_NAME , -AS102_SKY_IT_DIGITAL_KEY_NAME , -NULL /* Terminating entry */ -}; +#define DRIVER_INFO (dev_name, dev_elna_cfg) \ + .driver_info = (kernel_ulong_t)&(const struct as102_dev_info){ \ + .name = (dev_name), \ + .elna_cfg = (dev_elna_cfg), \ + } -/* eLNA configuration: devices built on the reference design work best -with 0xA0, while custom designs seem to require 0xC0 */ -static uint8_t const as102_elna_cfg[] = { -0xA0 , -0xC0 , -0xC0 , -0xA0 , -0xA0 , -0x00 /* Terminating entry */ +static const struct usb_device_id as102_usb_id_table[] = { + {USB_DEVICE (AS102_USB_DEVICE_VENDOR_ID ,AS102_USB_DEVICE_PID_0001 ), +DRIVER_INFO (AS102_REFERENCE_DESIGN ,0xA0 ) }, + {USB_DEVICE (PCTV_74E_USB_VID ,PCTV_74E_USB_PID ), +DRIVER_INFO (AS102_PCTV_74E ,0xC0 ) }, + {USB_DEVICE (ELGATO_EYETV_DTT_USB_VID ,ELGATO_EYETV_DTT_USB_PID ), +DRIVER_INFO (AS102_ELGATO_EYETV_DTT_NAME ,0xC0 ) }, + {USB_DEVICE (NBOX_DVBT_DONGLE_USB_VID ,NBOX_DVBT_DONGLE_USB_PID ), +DRIVER_INFO (AS102_NBOX_DVBT_DONGLE_NAME ,0xA0 ) }, + {USB_DEVICE (SKY_IT_DIGITAL_KEY_USB_VID ,SKY_IT_DIGITAL_KEY_USB_PID ), +DRIVER_INFO (AS102_SKY_IT_DIGITAL_KEY_NAME ,0xA0 ) }, + { }/* Terminating entry */ };struct usb_driver as102_usb_driver = {
@@ -336,29 +334,18 @@ static int as102_usb_probe(struct usb_interface *intf, {int ret;struct as102_dev_t *as102_dev; -int i; - -/* This should never actually happen */ -if (ARRAY_SIZE (as102_usb_id_table) != - (sizeof (as102_device_names) /sizeof (const char *))) { -pr_err ("Device names table invalid size" ); -return -EINVAL ; - } +const struct as102_dev_info *info = (const struct as102_dev_info *)id->driver_info; as102_dev =kzalloc (sizeof (struct as102_dev_t ),GFP_KERNEL );if (as102_dev ==NULL )return -ENOMEM ; -/* Assign the user-friendly device name */ -for (i =0 ; i <ARRAY_SIZE (as102_usb_id_table); i++) { -if (id == &as102_usb_id_table[i]) { - as102_dev->name = as102_device_names[i]; - as102_dev->elna_cfg = as102_elna_cfg[i]; - } - } - -if (as102_dev->name ==NULL ) +if (info) { + as102_dev->name = info->name; + as102_dev->elna_cfg = info->elna_cfg; + }else { as102_dev->name ="Unknown AS102 device" ; + }/* set private callback functions */ as102_dev->bus_adap.ops = &as102_priv_ops;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 696/1193 net: usb: pegasus: dont rely on id table pointer arithmetic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit ce8101c331956bbd3e20681331dfd22eb7c1c1ea ]
The current code is broken when dynamic ID is involved; in such cases usb_device_id parameter of probe lives on the heap and the pointer arithmetic will get an index that is wildly out of bound. Instead of keeping a side table for additional information, use driver_info field of the usb_device_id.
The dynamic ID parsing code needs to be updated for this; convert it to just write to the reserved entry for dynamic ID and remove the weird loop.
--- drivers/net/usb/pegasus.c | 54 ++++++++++++++++----------------------- drivers/net/usb/pegasus.h | 3 --- 2 files changed, 22 insertions(+), 35 deletions(-)
drivers/net/usb/pegasus.c +22 -32
@@ -46,21 +46,12 @@ static bool loopback;static bool mii_mode;static char *devid; -static struct usb_eth_dev usb_dev_id[] = { -#define PEGASUS_DEV(pn, vid, pid, flags) \ - {.name = pn, .vendor = vid, .device = pid, .private = flags}, -#define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \ - PEGASUS_DEV(pn, vid, pid, flags) -#include "pegasus.h" -#undef PEGASUS_DEV -#undef PEGASUS_DEV_CLASS - {NULL ,0 ,0 ,0 }, - {NULL ,0 ,0 ,0 } -}; +static struct usb_eth_dev dynamic_id_info = {};static struct usb_device_id pegasus_ids[] = { #define PEGASUS_DEV(pn, vid, pid, flags) \ - {.match_flags =USB_DEVICE_ID_MATCH_DEVICE , .idVendor = vid, .idProduct = pid}, + {.match_flags =USB_DEVICE_ID_MATCH_DEVICE , .idVendor = vid, .idProduct = pid, \ + .driver_info = (kernel_ulong_t)&(const struct usb_eth_dev ) {.name = pn, .private = flags}},/* * The Belkin F8T012xx1 bluetooth adaptor has the same vendor and product * IDs as the Belkin F5D5050, so we need to teach the pegasus driver to
@@ -69,7 +60,8 @@ static struct usb_device_id pegasus_ids[] = {*/ #define PEGASUS_DEV_CLASS (pn, vid, pid, dclass, flags) \ {.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS), \ - .idVendor = vid, .idProduct = pid, .bDeviceClass = dclass}, + .idVendor = vid, .idProduct = pid, .bDeviceClass = dclass, \ + .driver_info = (kernel_ulong_t)&(const struct usb_eth_dev) {.name = pn, .private = flags}},#include "pegasus.h" #undef PEGASUS_DEV#undef PEGASUS_DEV_CLASS
@@ -405,12 +397,12 @@ static inline int reset_mac(pegasus_t *pegasus)if (i ==REG_TIMEOUT )return -ETIMEDOUT ; -if (usb_dev_id[pegasus->dev_index].vendor ==VENDOR_LINKSYS || - usb_dev_id[pegasus->dev_index].vendor ==VENDOR_DLINK ) { +if (le16_to_cpu (pegasus->usb->descriptor.idVendor) ==VENDOR_LINKSYS || +le16_to_cpu (pegasus->usb->descriptor.idVendor) ==VENDOR_DLINK ) {set_register (pegasus, Gpio0,0x24 );set_register (pegasus, Gpio0,0x26 ); } -if (usb_dev_id[pegasus->dev_index].vendor ==VENDOR_ELCON ) { +if (le16_to_cpu (pegasus->usb->descriptor.idVendor) ==VENDOR_ELCON ) {__u16 auxmode; ret =read_mii_word (pegasus,3 ,0x1b , &auxmode);if (ret <0 )
@@ -448,9 +440,9 @@ static int enable_net_traffic(struct net_device *dev, struct usb_device *usb)memcpy (pegasus->eth_regs, data,sizeof (data)); ret =set_registers (pegasus, EthCtrl0,3 , data); -if (usb_dev_id[pegasus->dev_index].vendor ==VENDOR_LINKSYS || - usb_dev_id[pegasus->dev_index].vendor ==VENDOR_LINKSYS2 || - usb_dev_id[pegasus->dev_index].vendor ==VENDOR_DLINK ) { +if (le16_to_cpu (pegasus->usb->descriptor.idVendor) ==VENDOR_LINKSYS || +le16_to_cpu (pegasus->usb->descriptor.idVendor) ==VENDOR_LINKSYS2 || +le16_to_cpu (pegasus->usb->descriptor.idVendor) ==VENDOR_DLINK ) {u16 auxmode; ret =read_mii_word (pegasus,0 ,0x1b , &auxmode);if (ret <0 )
@@ -1156,7 +1148,7 @@ static int pegasus_probe(struct usb_interface *intf,struct usb_device *dev =interface_to_usbdev (intf);struct net_device *net;pegasus_t *pegasus; -int dev_index = id - pegasus_ids; +const struct usb_eth_dev *info = (const struct usb_eth_dev *)id->driver_info;int res = -ENOMEM ;static const u8 bulk_ep_addr[] = {PEGASUS_USB_EP_BULK_IN |USB_DIR_IN ,
@@ -1181,7 +1173,6 @@ static int pegasus_probe(struct usb_interface *intf, goto out; pegasus =netdev_priv (net); - pegasus->dev_index = dev_index; pegasus->intf = intf; res =alloc_urbs (pegasus);
@@ -1209,7 +1200,7 @@ static int pegasus_probe(struct usb_interface *intf, pegasus->msg_enable =netif_msg_init (msg_level,NETIF_MSG_DRV |NETIF_MSG_PROBE |NETIF_MSG_LINK ); - pegasus->features = usb_dev_id[dev_index].private; + pegasus->features = info ? info->private :DEFAULT_GPIO_RESET ; res =get_interrupt_interval (pegasus);if (res) goto out2;
@@ -1238,7 +1229,7 @@ static int pegasus_probe(struct usb_interface *intf,queue_delayed_work (system_long_wq, &pegasus->carrier_check,CARRIER_CHECK_DELAY );dev_info (&intf->dev,"%s, %s, %pM\n" , net->name, - usb_dev_id[dev_index].name, net->dev_addr); + info ? info->name :"(unknown)" , net->dev_addr);return 0 ; out3:
@@ -1328,8 +1319,9 @@ static struct usb_driver pegasus_driver = {static void __init parse_id (char *id) { -unsigned int vendor_id =0 , device_id =0 , flags =0 , i =0 ; +unsigned int vendor_id =0 , device_id =0 , flags =0 ;char *token, *name =NULL ; +int dyn_id_index =ARRAY_SIZE (pegasus_ids) -2 ;if ((token =strsep (&id,":" )) !=NULL ) name = token;
@@ -1347,14 +1339,12 @@ static void __init parse_id(char *id)if (device_id >0x10000 || device_id ==0 )return ; -for (i =0 ; usb_dev_id[i].name; i++); - usb_dev_id[i].name = name; - usb_dev_id[i].vendor = vendor_id; - usb_dev_id[i].device = device_id; - usb_dev_id[i].private = flags; - pegasus_ids[i].match_flags =USB_DEVICE_ID_MATCH_DEVICE ; - pegasus_ids[i].idVendor = vendor_id; - pegasus_ids[i].idProduct = device_id; + dynamic_id_info.name = name; + dynamic_id_info.private = flags; + pegasus_ids[dyn_id_index].match_flags =USB_DEVICE_ID_MATCH_DEVICE ; + pegasus_ids[dyn_id_index].idVendor = vendor_id; + pegasus_ids[dyn_id_index].idProduct = device_id; + pegasus_ids[dyn_id_index].driver_info = (kernel_ulong_t)&dynamic_id_info; }static int __init pegasus_init (void )
drivers/net/usb/pegasus.h +0 -3
@@ -85,7 +85,6 @@ typedef struct pegasus {unsigned features;u32 msg_enable;u32 wolopts; -int dev_index;int intr_interval;struct tasklet_struct rx_tl;struct delayed_work carrier_check;
@@ -102,8 +101,6 @@ typedef struct pegasus {struct usb_eth_dev {char *name; -__u16 vendor; -__u16 device;__u32 private;/* LSB is gpio reset value */ };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 697/1193 ALSA: us122l: Prevent write upgrades for read mappings
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kazuki Hanai <[email protected]>
[ Upstream commit 71c610aeb1770302ac9c9e0b9a4ecd37f1311928 ]
The hwdep mmap callback rejects read-buffer mappings that are initially writable, but leaves VM_MAYWRITE set on mappings created with PROT_READ. A process that can open the hwdep node O_RDWR can later use mprotect() to make the mapping writable.
The read allocation begins with struct usb_stream. Its read_size member is used by the fault handler to decide which pages belong to the read buffer. The read VMA intentionally remains expandable because pcm_usb_stream uses mremap() after reading that size. Changing read_size first can therefore map and access pages beyond the allocation. The same member is also consumed by usb_stream_free(), where changing it can make free_pages_exact() release pages outside the allocation.
Clear VM_MAYWRITE for read-buffer mappings after rejecting an initially writable VMA. This keeps the separate output-buffer mapping writable while preventing later permission upgrades.
--- sound/usb/usx2y/us122l.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/usb/usx2y/us122l.c +6 -3
@@ -209,9 +209,12 @@ static int usb_stream_hwdep_mmap(struct snd_hwdep *hw,mutex_lock (&us122l->mutex); s = us122l->sk.s; read = offset < s->read_size; -if (read && area->vm_flags &VM_WRITE ) { - err = -EPERM ; - goto out; +if (read) { +if (area->vm_flags &VM_WRITE ) { + err = -EPERM ; + goto out; + } +vm_flags_clear (area,VM_MAYWRITE ); }snd_printdd (KERN_DEBUG "%lu %u\n" , size, read ? s->read_size : s->write_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 698/1193 i2c: smbus: reject oversized block transfers in the common path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit 3051cd060fa496df42954291fa2306ed2eab4ecc upstream.
The SMBus block transfer length data->block[0] is validated in i2c_smbus_xfer_emulated() but that check runs too late for tracepoints and is skipped entirely when the adapter provides a native smbus_xfer implementation. This allows user-controlled oversized block lengths to reach tracepoint memcpy calls and driver callbacks unchecked.
Add an early validation in __i2c_smbus_xfer() that rejects block transfers whose caller-supplied length is zero or exceeds I2C_SMBUS_BLOCK_MAX before any tracepoint fires or driver callback runs. data->block[0] is filled in by the device on SMBus block reads, so the check is scoped to operations where the length is actually supplied by the caller. This is consistent with the existing -EINVAL convention in the emulated path and protects all downstream consumers at once: the smbus_write tracepoint, all native smbus_xfer driver implementations, and the emulated path.
Two distinct bugs are fixed by this change:
Bug 1: smbus_write tracepoint OOB (include/trace/events/smbus.h)
trace_smbus_write() fires before any validation and copies data->block[0]+1 bytes into a 34-byte event buffer. With block[0]=0xfe the tracepoint copies 255 bytes, overflowing by 221.
BUG: KASAN: stack-out-of-bounds in trace_event_raw_event_smbus_write+0x27c/0x530 Read of size 255 at addr ffff88800d98fcf8 by task poc_smbus/91 Call Trace: <TASK> __asan_memcpy+0x23/0x80 trace_event_raw_event_smbus_write+0x27c/0x530 __i2c_smbus_xfer+0x43a/0xa40 i2c_smbus_xfer+0x19e/0x340 i2cdev_ioctl_smbus+0x38f/0x7f0 i2cdev_ioctl+0x35e/0x680 __x64_sys_ioctl+0x147/0x1e0 do_syscall_64+0xcf/0x15a0 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
Bug 2: i2c-stub I2C_SMBUS_I2C_BLOCK_DATA OOB (drivers/i2c/i2c-stub.c)
stub_xfer() implements .smbus_xfer directly and only clamps block[0] against 256-command, not I2C_SMBUS_BLOCK_MAX. With block[0]=0xff and command=0 the loop accesses block[1+i] for i up to 254, far past the 34-byte union.
UBSAN: array-index-out-of-bounds in drivers/i2c/i2c-stub.c:223:44 index 34 is out of range for type '__u8 [34]' Call Trace: <TASK> __ubsan_handle_out_of_bounds+0xd7/0x120 stub_xfer+0x1971/0x198f [i2c_stub] __i2c_smbus_xfer+0x306/0xa40 i2c_smbus_xfer+0x19e/0x340 i2cdev_ioctl_smbus+0x38f/0x7f0 i2cdev_ioctl+0x35e/0x680 __x64_sys_ioctl+0x147/0x1e0 do_syscall_64+0xcf/0x15a0 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
Both traces reproduced on v7.0-rc6+i2c/for-current with KASAN+UBSAN.
--- drivers/i2c/i2c-core-smbus.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/i2c/i2c-core-smbus.c +12 -0
@@ -565,6 +565,18 @@ s32 __i2c_smbus_xfer(struct i2c_adapterif (res)return res; +/* Reject invalid caller-supplied block lengths before any +* tracepoint or native smbus_xfer callback runs. +*/ +if (data && + (protocol ==I2C_SMBUS_I2C_BLOCK_DATA || + protocol ==I2C_SMBUS_BLOCK_PROC_CALL || + (protocol ==I2C_SMBUS_BLOCK_DATA && + read_write ==I2C_SMBUS_WRITE )) && + (data->block[0 ] ==0 || + data->block[0 ] >I2C_SMBUS_BLOCK_MAX )) +return -EINVAL ; +/* If enabled, the following two tracepoints are conditional on * read_write and protocol. */
Greg Kroah-Hartman
maintainerPATCH 699/1193 net: appletalk: fix NULL pointer dereference in aarp_send_ddp()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit 9e7f36ab5b7bf68463faa5f7b926fea8f35597bb upstream.
aarp_send_ddp() calls atalk_find_dev_addr(dev) in the LocalTalk fast path without checking for NULL. When the device has no AppleTalk interface configured (dev->atalk_ptr == NULL), this leads to a NULL pointer dereference at the at->s_net access.
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:aarp_send_ddp (net/appletalk/aarp.c:552 (discriminator 2)) Call Trace: <TASK> atalk_sendmsg (net/appletalk/ddp.c:1715) __sys_sendto (net/socket.c:2265 (discriminator 1)) __x64_sys_sendto (net/socket.c:2272) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
Add a NULL check consistent with the other callers of atalk_find_dev_addr().
--- net/appletalk/aarp.c | 5 +++++ 1 file changed, 5 insertions(+)
net/appletalk/aarp.c +5 -0
@@ -573,6 +573,11 @@ int aarp_send_ddp(struct net_device *devstruct ddpehdr *ddp = (struct ddpehdr *)skb->data;int ft =2 ; +if (!at) { +kfree_skb (skb); +return NET_XMIT_DROP ; + } +/* * Compressible ? *
Greg Kroah-Hartman
maintainerPATCH 664/1193 smb: client: pin DFS superblock in iterator callback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
commit d806d5a85dcbe2a0f181b2f0f9f61ddfbefa1818 upstream.
tcon_super_cb() stores a raw superblock pointer, but __cifs_get_super() takes its active reference only after iterate_supers_type() has dropped s_umount and its passive reference. Concurrent DFS automount expiry can therefore free the superblock before cifs_sb_active() uses it.
A deterministic KASAN test reproduces the race as:
BUG: KASAN: slab-use-after-free in cifs_sb_active+0x77/0x80
The same test passes with this change applied.
Take the active reference in the callback while iterate_supers_type() still holds s_umount shared. cifs_put_tcp_super() remains the matching release.
--- fs/smb/client/misc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
fs/smb/client/misc.c +8 -9
@@ -1269,8 +1269,14 @@ static void tcon_super_cb(struct super_bif (t1->ses == t2->ses && t1->ses->server == t2->ses->server && t2->origin_fullpath && -dfs_src_pathname_equal (t2->origin_fullpath, t1->origin_fullpath)) +dfs_src_pathname_equal (t2->origin_fullpath, t1->origin_fullpath)) { +/* +* Take the active reference while iterate_supers_type() still +* holds s_umount shared. +*/ +cifs_sb_active (sb); sd->sb = sb; + }spin_unlock (&t2->tc_lock); }
@@ -1287,15 +1293,8 @@ static struct super_block *__cifs_get_sufor (; *fs_type; fs_type++) {iterate_supers_type (*fs_type, f, &sd); -if (sd.sb) { -/* -* Grab an active reference in order to prevent automounts (DFS links) -* of expiring and then freeing up our cifs superblock pointer while -* we're doing failover. -*/ -cifs_sb_active (sd.sb); +if (sd.sb)return sd.sb; - } }pr_warn_once ("%s: could not find dfs superblock\n" , __func__);return ERR_PTR (-EINVAL );
Greg Kroah-Hartman
maintainerPATCH 700/1193 fou: Fix use-after-free in fou_create()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <[email protected]>
commit b14361aca6350ff7907b0e9903c7b94dc7d5d4a0 upstream.
fou_create() publishes struct fou through sk_user_data before adding the new FOU port to the per-netns list. If fou_add_to_port_list() fails, the error path frees fou while it is still reachable through sk_user_data. A concurrent receive can then dereference the freed object in fou_from_sock().
This ordering issue was previously noted in the linked discussion.
The failure is reachable when local port 0 is requested. Each socket binds to a different ephemeral port, but fou_cfg_cmp() compares the requested port 0 and reports -EALREADY once an entry already exists.
Release the tunnel socket before freeing fou so sk_user_data is cleared first, and defer reclamation with kfree_rcu() to protect concurrent RCU readers. This matches the lifetime handling in fou_release().
--- net/ipv4/fou_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/fou_core.c +1 -1
@@ -636,9 +636,9 @@ static int fou_create(struct net *net, sreturn 0 ; error: -kfree (fou);if (sock)udp_tunnel_sock_release (sock); +kfree_rcu (fou, rcu);return err; }
Greg Kroah-Hartman
maintainerPATCH 701/1193 crypto: sun8i-ss - Remove crypto_rng interface
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit a78446ee6fae86ac8733f120e3ffce2e5d9384f5 upstream.
Since the crypto_rng interface for hardware PRNGs is unused and is redundant with hwrng and the actual Linux RNG, it's being phased out. Most drivers for it were already removed. Go ahead and remove the sun8i-ss support which is one of the only remaining ones.
As usual for crypto_rng, this driver was also buggy: its ->generate() function had a use-after-free vulnerability due to using wait_for_completion_interruptible_timeout() without handling shutting down the DMA operation if a signal is sent. Also, it had a buffer overread bug in the line 'memcpy(ctx->seed, d + dlen, ctx->slen);'. There's no point in fixing these bugs separately only to remove the code anyway, so this commit is marked with Fixes and Cc stable.
--- drivers/crypto/allwinner/Kconfig | 8 drivers/crypto/allwinner/sun8i-ss/Makefile | 1 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 39 ---- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c | 177 ---------------------- drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h | 23 -- 5 files changed, 248 deletions(-) delete mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c
drivers/crypto/allwinner/Kconfig +0 -8
@@ -113,14 +113,6 @@ config CRYPTO_DEV_SUN8I_SS_DEBUG This will create /sys/kernel/debug/sun8i-ss/stats for displaying the number of requests per flow and per algorithm. -config CRYPTO_DEV_SUN8I_SS_PRNG - bool "Support for Allwinner Security System PRNG" - depends on CRYPTO_DEV_SUN8I_SS - select CRYPTO_RNG - help - Select this option if you want to provide kernel-side support for - the Pseudo-Random Number Generator found in the Security System. - config CRYPTO_DEV_SUN8I_SS_HASH bool "Enable support for hash on sun8i-ss" depends on CRYPTO_DEV_SUN8I_SS
drivers/crypto/allwinner/sun8i-ss/Makefile +0 -1
@@ -1,4 +1,3 @@ obj-$(CONFIG_CRYPTO_DEV_SUN8I_SS) += sun8i-ss.o sun8i-ss-y += sun8i-ss-core.o sun8i-ss-cipher.o -sun8i-ss-$(CONFIG_CRYPTO_DEV_SUN8I_SS_PRNG) += sun8i-ss-prng.o sun8i-ss-$(CONFIG_CRYPTO_DEV_SUN8I_SS_HASH) += sun8i-ss-hash.o
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c +0 -39
@@ -11,7 +11,6 @@*/ #include <crypto/engine.h> -#include <crypto/internal/rng.h> #include <crypto/internal/skcipher.h> #include <linux/clk.h> #include <linux/delay.h>
@@ -283,25 +282,6 @@ static struct sun8i_ss_alg_template ss_a .do_one_request = sun8i_ss_handle_cipher_request, }, }, -#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_PRNG -{ - .type = CRYPTO_ALG_TYPE_RNG, - .alg.rng = { - .base = { - .cra_name = "stdrng", - .cra_driver_name = "sun8i-ss-prng", - .cra_priority = 300, - .cra_ctxsize = sizeof(struct sun8i_ss_rng_tfm_ctx), - .cra_module = THIS_MODULE, - .cra_init = sun8i_ss_prng_init, - .cra_exit = sun8i_ss_prng_exit, - }, - .generate = sun8i_ss_prng_generate, - .seed = sun8i_ss_prng_seed, - .seedsize =PRNG_SEED_SIZE , - } -}, -#endif#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_HASH { .type = CRYPTO_ALG_TYPE_AHASH, .ss_algo_id = SS_ID_HASH_MD5,
@@ -506,12 +486,6 @@ static int sun8i_ss_debugfs_show(structseq_printf (seq,"\tFallback due to SG numbers: %lu\n" , ss_algs[i].stat_fb_sgnum);break ; -case CRYPTO_ALG_TYPE_RNG : -seq_printf (seq,"%s %s reqs=%lu tsize=%lu\n" , - ss_algs[i].alg.rng.base.cra_driver_name, - ss_algs[i].alg.rng.base.cra_name, - ss_algs[i].stat_req, ss_algs[i].stat_bytes); -break ;case CRYPTO_ALG_TYPE_AHASH : seq_printf(seq, "%s %s reqs=%lu fallback=%lu\n", ss_algs[i].alg.hash.base.halg.base.cra_driver_name,
@@ -712,14 +686,6 @@ static int sun8i_ss_register_algs(structreturn err; }break ; -case CRYPTO_ALG_TYPE_RNG : - err =crypto_register_rng (&ss_algs[i].alg.rng); -if (err) { -dev_err (ss->dev,"Fail to register %s\n" , - ss_algs[i].alg.rng.base.cra_name); - ss_algs[i].ss =NULL ; - } -break ;case CRYPTO_ALG_TYPE_AHASH : id = ss_algs[i].ss_algo_id; ss_method = ss->variant->alg_hash[id];
@@ -761,11 +727,6 @@ static void sun8i_ss_unregister_algs(str ss_algs[i].alg.skcipher.base.base.cra_name);crypto_engine_unregister_skcipher (&ss_algs[i].alg.skcipher);break ; -case CRYPTO_ALG_TYPE_RNG : -dev_info (ss->dev,"Unregister %d %s\n" , i, - ss_algs[i].alg.rng.base.cra_name); -crypto_unregister_rng (&ss_algs[i].alg.rng); -break ;case CRYPTO_ALG_TYPE_AHASH :dev_info (ss->dev,"Unregister %d %s\n" , i, ss_algs[i].alg.hash.base.halg.base.cra_name);
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c deleted +0 -177
177 lines not on this page · raw message
drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h +0 -23
@@ -8,7 +8,6 @@#include <crypto/aes.h> #include <crypto/des.h> #include <crypto/engine.h> -#include <crypto/rng.h> #include <crypto/skcipher.h> #include <linux/atomic.h> #include <linux/debugfs.h>
@@ -27,7 +26,6 @@#define SS_ALG_DES (1 << 2)#define SS_ALG_3DES (2 << 2)#define SS_ALG_MD5 (3 << 2) -#define SS_ALG_PRNG (4 << 2)#define SS_ALG_SHA1 (6 << 2)#define SS_ALG_SHA224 (7 << 2)#define SS_ALG_SHA256 (8 << 2)
@@ -68,8 +66,6 @@#define SS_FLOW0 BIT(30)#define SS_FLOW1 BIT(31) -#define SS_PRNG_CONTINUE BIT(18) -#define MAX_SG 8#define MAXFLOW 2
@@ -79,9 +75,6 @@#define SS_DIE_ID_SHIFT 20#define SS_DIE_ID_MASK 0x07 -#define PRNG_DATA_SIZE (160 / 8) -#define PRNG_SEED_SIZE DIV_ROUND_UP(175, 8) -#define MAX_PAD_SIZE 4096/*
@@ -214,16 +207,6 @@ struct sun8i_cipher_tfm_ctx { };/* -* struct sun8i_ss_prng_ctx - context for PRNG TFM -* @seed: The seed to use -* @slen: The size of the seed -*/ -struct sun8i_ss_rng_tfm_ctx { -void *seed; -unsigned int slen; -}; - -/* * struct sun8i_ss_hash_tfm_ctx - context for an ahash TFM * @fallback_tfm: pointer to the fallback TFM * @ss: pointer to the private data of driver handling this TFM
@@ -272,7 +255,6 @@ struct sun8i_ss_alg_template {struct sun8i_ss_dev *ss;union {struct skcipher_engine_alg skcipher; -struct rng_alg rng;struct ahash_engine_alg hash; } alg;unsigned long stat_req;
@@ -298,11 +280,6 @@ int sun8i_ss_skencrypt(struct skcipher_rint sun8i_ss_get_engine_number (struct sun8i_ss_dev *ss);int sun8i_ss_run_task (struct sun8i_ss_dev *ss,struct sun8i_cipher_req_ctx *rctx,const char *name); -int sun8i_ss_prng_generate (struct crypto_rng *tfm,const u8 *src, -unsigned int slen,u8 *dst,unsigned int dlen); -int sun8i_ss_prng_seed (struct crypto_rng *tfm,const u8 *seed,unsigned int slen); -int sun8i_ss_prng_init (struct crypto_tfm *tfm); -void sun8i_ss_prng_exit (struct crypto_tfm *tfm);int sun8i_ss_hash_init_tfm (struct crypto_ahash *tfm);void sun8i_ss_hash_exit_tfm (struct crypto_ahash *tfm);
Greg Kroah-Hartman
maintainerPATCH 702/1193 crypto: sun8i-ce - Remove crypto_rng interface
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 011556f71d094da61379ae3672692cae2795304e upstream.
Since the crypto_rng interface for hardware PRNGs is unused and is redundant with hwrng and the actual Linux RNG, it's being phased out. Most drivers for it were already removed. Go ahead and remove the sun8i-ce support which is one of the only remaining ones.
Note that the sun8i-ce support for hwrng remains in place. That is the interface that actually matters.
As usual for crypto_rng, this driver was also buggy: its ->generate() function had a use-after-free vulnerability due to using wait_for_completion_interruptible_timeout() without handling shutting down the DMA operation if a signal is sent. There's no point in fixing this separately only to remove the code anyway, so this commit is marked with Fixes and Cc stable.
--- drivers/crypto/allwinner/Kconfig | 8 - drivers/crypto/allwinner/sun8i-ce/Makefile | 1 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 55 ------- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c | 159 ---------------------- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 29 ---- 5 files changed, 252 deletions(-) delete mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c
drivers/crypto/allwinner/Kconfig +0 -8
@@ -70,14 +70,6 @@ config CRYPTO_DEV_SUN8I_CE_HASH help Say y to enable support for hash algorithms. -config CRYPTO_DEV_SUN8I_CE_PRNG - bool "Support for Allwinner Crypto Engine PRNG" - depends on CRYPTO_DEV_SUN8I_CE - select CRYPTO_RNG - help - Select this option if you want to provide kernel-side support for - the Pseudo-Random Number Generator found in the Crypto Engine. - config CRYPTO_DEV_SUN8I_CE_TRNG bool "Support for Allwinner Crypto Engine TRNG" depends on CRYPTO_DEV_SUN8I_CE
drivers/crypto/allwinner/sun8i-ce/Makefile +0 -1
@@ -1,5 +1,4 @@ obj-$(CONFIG_CRYPTO_DEV_SUN8I_CE) += sun8i-ce.o sun8i-ce-y += sun8i-ce-core.o sun8i-ce-cipher.o sun8i-ce-$(CONFIG_CRYPTO_DEV_SUN8I_CE_HASH) += sun8i-ce-hash.o -sun8i-ce-$(CONFIG_CRYPTO_DEV_SUN8I_CE_PRNG) += sun8i-ce-prng.o sun8i-ce-$(CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG) += sun8i-ce-trng.o
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +0 -55
127 lines not on this page · raw message
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c deleted +0 -159
159 lines not on this page · raw message
drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +0 -29
@@ -15,7 +15,6 @@#include <linux/hw_random.h> #include <crypto/internal/hash.h> #include <crypto/md5.h> -#include <crypto/rng.h> #include <crypto/sha1.h> #include <crypto/sha2.h>
@@ -58,9 +57,7 @@#define CE_ALG_SHA384 20#define CE_ALG_SHA512 21#define CE_ALG_TRNG 48 -#define CE_ALG_PRNG 49#define CE_ALG_TRNG_V2 0x1c -#define CE_ALG_PRNG_V2 0x1d/* Used in ce_variant */ #define CE_ID_NOTSUPP 0xFF
@@ -96,10 +93,6 @@#define ESR_H6 4#define ESR_D1 5 -#define PRNG_DATA_SIZE (160 / 8) -#define PRNG_SEED_SIZE DIV_ROUND_UP(175, 8) -#define PRNG_LD BIT(17) -#define CE_DIE_ID_SHIFT 16#define CE_DIE_ID_MASK 0x07
@@ -133,13 +126,10 @@ struct ce_clock {* bytes or words * @hash_t_dlen_in_bytes: Does the request size for hash is in * bits or words -* @prng_t_dlen_in_bytes: Does the request size for PRNG is in -* bytes or words * @trng_t_dlen_in_bytes: Does the request size for TRNG is in * bytes or words * @ce_clks: list of clocks needed by this variant * @esr: The type of error register -* @prng: The CE_ALG_XXX value for the PRNG * @trng: The CE_ALG_XXX value for the TRNG */ struct ce_variant {
@@ -148,11 +138,9 @@ struct ce_variant {u32 op_mode[CE_ID_OP_MAX ];bool cipher_t_dlen_in_bytes;bool hash_t_dlen_in_bits; -bool prng_t_dlen_in_bytes;bool trng_t_dlen_in_bytes;struct ce_clock ce_clks[CE_MAX_CLOCKS ];int esr; -unsigned char prng;unsigned char trng; };
@@ -298,16 +286,6 @@ struct sun8i_ce_hash_reqctx { };/* -* struct sun8i_ce_prng_ctx - context for PRNG TFM -* @seed: The seed to use -* @slen: The size of the seed -*/ -struct sun8i_ce_rng_tfm_ctx { -void *seed; -unsigned int slen; -}; - -/* * struct sun8i_ce_alg_template - crypto_alg template * @type: the CRYPTO_ALG_TYPE for this template * @ce_algo_id: the CE_ID for this template
@@ -327,7 +305,6 @@ struct sun8i_ce_alg_template {union {struct skcipher_engine_alg skcipher;struct ahash_engine_alg hash; -struct rng_alg rng; } alg;unsigned long stat_req;unsigned long stat_fb;
@@ -368,11 +345,5 @@ int sun8i_ce_hash_finup(struct ahash_reqint sun8i_ce_hash_digest (struct ahash_request *areq);int sun8i_ce_hash_run (struct crypto_engine *engine,void *breq); -int sun8i_ce_prng_generate (struct crypto_rng *tfm,const u8 *src, -unsigned int slen,u8 *dst,unsigned int dlen); -int sun8i_ce_prng_seed (struct crypto_rng *tfm,const u8 *seed,unsigned int slen); -void sun8i_ce_prng_exit (struct crypto_tfm *tfm); -int sun8i_ce_prng_init (struct crypto_tfm *tfm); -int sun8i_ce_hwrng_register (struct sun8i_ce_dev *ce);void sun8i_ce_hwrng_unregister (struct sun8i_ce_dev *ce);
Greg Kroah-Hartman
maintainerPATCH 703/1193 netfilter: nft_set_pipapo_avx2: add missing vzeroupper
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 55dd20f0f4b1be5c9c8a0275d8d763c86563eac2 upstream.
Since pipapo_get_avx2() uses YMM registers, execute vzeroupper before returning from it. This is needed to avoid degrading the performance of any later SSE code that may happen to be executed.
--- net/netfilter/nft_set_pipapo_avx2.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nft_set_pipapo_avx2.c +1 -0
@@ -1261,6 +1261,7 @@ next_match: out:if (i %2 ) scratch->map_index = !map_index; + asmvolatile ("vzeroupper" );kernel_fpu_end ();local_bh_enable ();