selftests/bpf: Verify copy_register_state() preserves parent/live fields
Subsystems (8)
Sasha Levin
maintainerPATCH 1/10 selftests/bpf: Verify copy_register_state() preserves parent/live fields
From: Eduard Zingerman <[email protected]>
[ Upstream commit b9fa9bc839291020b362ab5392e5f18ba79657ac ]
A testcase to check that verifier.c:copy_register_state() preserves register parentage chain and livness information.
--- .../selftests/bpf/verifier/search_pruning.c | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+)
tools/testing/selftests/bpf/verifier/search_pruning.c +36 -0
@@ -154,3 +154,39 @@ .result_unpriv = ACCEPT, .insn_processed = 15, }, +/* The test performs a conditional 64-bit write to a stack location +* fp[-8], this is followed by an unconditional 8-bit write to fp[-8], +* then data is read from fp[-8]. This sequence is unsafe. +* +* The test would be mistakenly marked as safe w/o dst register parent +* preservation in verifier.c:copy_register_state() function. +* +* Note the usage of BPF_F_TEST_STATE_FREQ to force creation of the +* checkpoint state after conditional 64-bit assignment. +*/ +{ + "write tracking and register parent chain bug", + .insns = { +/* r6 = ktime_get_ns() */ +BPF_EMIT_CALL (BPF_FUNC_ktime_get_ns), +BPF_MOV64_REG (BPF_REG_6 ,BPF_REG_0 ), +/* r0 = ktime_get_ns() */ +BPF_EMIT_CALL (BPF_FUNC_ktime_get_ns), +/* if r0 > r6 goto +1 */ +BPF_JMP_REG (BPF_JGT ,BPF_REG_0 ,BPF_REG_6 ,1 ), +/* *(u64 *)(r10 - 8) = 0xdeadbeef */ +BPF_ST_MEM (BPF_DW ,BPF_REG_FP ,-8 ,0xdeadbeef ), +/* r1 = 42 */ +BPF_MOV64_IMM (BPF_REG_1 ,42 ), +/* *(u8 *)(r10 - 8) = r1 */ +BPF_STX_MEM (BPF_B ,BPF_REG_FP ,BPF_REG_1 ,-8 ), +/* r2 = *(u64 *)(r10 - 8) */ +BPF_LDX_MEM (BPF_DW ,BPF_REG_2 ,BPF_REG_FP ,-8 ), +/* exit(0) */ +BPF_MOV64_IMM (BPF_REG_0 ,0 ), + BPF_EXIT_INSN(), + }, + .flags =BPF_F_TEST_STATE_FREQ , + .errstr = "invalid read from stack off -8+1 size 8", + .result = REJECT, +},
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 2/10 ASoC: cs42l56: fix DT probe
From: Arnd Bergmann <[email protected]>
[ Upstream commit e18c6da62edc780e4f4f3c9ce07bdacd69505182 ]
While looking through legacy platform data users, I noticed that the DT probing never uses data from the DT properties, as the platform_data structure gets overwritten directly after it is initialized.
There have never been any boards defining the platform_data in the mainline kernel either, so this driver so far only worked with patched kernels or with the default values.
For the benefit of possible downstream users, fix the DT probe by no longer overwriting the data.
--- sound/soc/codecs/cs42l56.c | 6 ------ 1 file changed, 6 deletions(-)
sound/soc/codecs/cs42l56.c +0 -6
@@ -1192,18 +1192,12 @@ static int cs42l56_i2c_probe(struct i2c_client *i2c_client,if (pdata) { cs42l56->pdata = *pdata; }else { - pdata =devm_kzalloc (&i2c_client->dev,sizeof (*pdata), -GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; -if (i2c_client->dev.of_node) { ret =cs42l56_handle_of_data (i2c_client, &cs42l56->pdata);if (ret !=0 )return ret; } - cs42l56->pdata = *pdata; }if (cs42l56->pdata.gpio_nreset) {
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 3/10 tools/virtio: fix the vringh test for virtio ring changes
In reply to Sasha LevinFrom: Shunsuke Mie <[email protected]>
[ Upstream commit 3f7b75abf41cc4143aa295f62acbb060a012868d ]
Fix the build caused by missing kmsan_handle_dma() and is_power_of_2() that are used in drivers/virtio/virtio_ring.c.
Message-Id: <[email protected]>
--- tools/virtio/linux/bug.h | 8 +++----- tools/virtio/linux/build_bug.h | 7 +++++++ tools/virtio/linux/cpumask.h | 7 +++++++ tools/virtio/linux/gfp.h | 7 +++++++ tools/virtio/linux/kernel.h | 1 + tools/virtio/linux/kmsan.h | 12 ++++++++++++ tools/virtio/linux/scatterlist.h | 1 + tools/virtio/linux/topology.h | 7 +++++++ 8 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 tools/virtio/linux/build_bug.h create mode 100644 tools/virtio/linux/cpumask.h create mode 100644 tools/virtio/linux/gfp.h create mode 100644 tools/virtio/linux/kmsan.h create mode 100644 tools/virtio/linux/topology.h
tools/virtio/linux/bug.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef BUG_H -#define BUG_H +#ifndef _LINUX_BUG_H +#define _LINUX_BUG_H#define BUG_ON (__BUG_ON_cond) assert(!(__BUG_ON_cond)) -#define BUILD_BUG_ON (x) -#define BUG () abort() -#endif /* BUG_H */ +#endif /* _LINUX_BUG_H */
tools/virtio/linux/build_bug.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_BUILD_BUG_H +#define _LINUX_BUILD_BUG_H + +#define BUILD_BUG_ON (x) + +#endif /* _LINUX_BUILD_BUG_H */
tools/virtio/linux/cpumask.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_CPUMASK_H +#define _LINUX_CPUMASK_H + +#include <linux/kernel.h> + +#endif /* _LINUX_CPUMASK_H */
tools/virtio/linux/gfp.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_GFP_H +#define __LINUX_GFP_H + +#include <linux/topology.h> + +#endif
tools/virtio/linux/kernel.h +1 -0
@@ -10,6 +10,7 @@#include <stdarg.h> #include <linux/compiler.h> +#include <linux/log2.h> #include <linux/types.h> #include <linux/printk.h> #include <linux/bug.h>
tools/virtio/linux/kmsan.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_KMSAN_H +#define _LINUX_KMSAN_H + +#include <linux/gfp.h> + +inline void kmsan_handle_dma (struct page *page,size_t offset,size_t size, +enum dma_data_direction dir) +{ +} + +#endif /* _LINUX_KMSAN_H */
tools/virtio/linux/scatterlist.h +1 -0
@@ -2,6 +2,7 @@ #ifndef SCATTERLIST_H #define SCATTERLIST_H #include <linux/kernel.h> +#include <linux/bug.h> struct scatterlist { unsigned long page_link;
tools/virtio/linux/topology.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TOPOLOGY_H +#define _LINUX_TOPOLOGY_H + +#include <linux/cpumask.h> + +#endif /* _LINUX_TOPOLOGY_H */
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Sasha Levin
maintainerPATCH 4/10 net/rose: Fix to not accept on connected socket
In reply to Sasha LevinFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit 14caefcf9837a2be765a566005ad82cd0d2a429f ]
If you call listen() and accept() on an already connect()ed rose socket, accept() can successfully connect. This is because when the peer socket sends data to sendmsg, the skb with its own sk stored in the connected socket's sk->sk_receive_queue is connected, and rose_accept() dequeues the skb waiting in the sk->sk_receive_queue.
This creates a child socket with the sk of the parent rose socket, which can cause confusion.
Fix rose_listen() to return -EINVAL if the socket has already been successfully connected, and add lock_sock to prevent this issue.
--- net/rose/af_rose.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/rose/af_rose.c +8 -0
@@ -465,6 +465,12 @@ static int rose_listen(struct socket *sock, int backlog) {struct sock *sk = sock->sk; +lock_sock (sk); +if (sock->state !=SS_UNCONNECTED ) { +release_sock (sk); +return -EINVAL ; + } +if (sk->sk_state !=TCP_LISTEN ) {struct rose_sock *rose =rose_sk (sk);
@@ -474,8 +480,10 @@ static int rose_listen(struct socket *sock, int backlog)memset (rose->dest_digis,0 ,AX25_ADDR_LEN *ROSE_MAX_DIGIS ); sk->sk_max_ack_backlog = backlog; sk->sk_state =TCP_LISTEN ; +release_sock (sk);return 0 ; } +release_sock (sk);return -EOPNOTSUPP ; }
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 5/10 powerpc/85xx: Fix unannotated intra-function call warning
In reply to Sasha LevinFrom: Sathvika Vasireddy <[email protected]>
[ Upstream commit 8afffce6aa3bddc940ac1909627ff1e772b6cbf1 ]
objtool throws the following warning:
arch/powerpc/kernel/head_85xx.o: warning: objtool: .head.text+0x1a6c:
unannotated intra-function call
Fix the warning by annotating KernelSPE symbol with SYM_FUNC_START_LOCAL and SYM_FUNC_END macros.
--- arch/powerpc/kernel/head_fsl_booke.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/kernel/head_fsl_booke.S +2 -1
@@ -880,7 +880,7 @@ _GLOBAL(load_up_spe) * SPE unavailable trap from kernel - print a message, but let * the task use SPE in the kernel until it returns to user mode. */ -KernelSPE: +SYM_FUNC_START_LOCAL(KernelSPE) lwz r3,_MSR(r1) oris r3,r3,MSR_SPE@h stw r3,_MSR(r1) /* enable use of SPE after return */
@@ -897,6 +897,7 @@ KernelSPE: #endif .align 4,0 +SYM_FUNC_END(KernelSPE) #endif /* CONFIG_SPE */ /*
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 6/10 powerpc/kvm: Fix unannotated intra-function call warning
In reply to Sasha LevinFrom: Sathvika Vasireddy <[email protected]>
[ Upstream commit fe6de81b610e5d0b9d2231acff2de74a35482e7d ]
objtool throws the following warning:
arch/powerpc/kvm/booke.o: warning: objtool: kvmppc_fill_pt_regs+0x30:
unannotated intra-function call
Fix the warning by setting the value of 'nip' using the _THIS_IP_ macro, without using an assembly bl/mflr sequence to save the instruction pointer.
--- arch/powerpc/kvm/booke.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/kvm/booke.c +2 -3
@@ -887,16 +887,15 @@ static int kvmppc_handle_debug(struct kvm_run *run, struct kvm_vcpu *vcpu)static void kvmppc_fill_pt_regs (struct pt_regs *regs) { -ulong r1, ip, msr, lr; +ulong r1, msr, lr; asm("mr %0, 1" :"=r" (r1)); asm("mflr %0" :"=r" (lr)); asm("mfmsr %0" :"=r" (msr)); - asm("bl 1f; 1: mflr %0" :"=r" (ip));memset (regs,0 ,sizeof (*regs)); regs->gpr[1 ] = r1; - regs->nip = ip; + regs->nip = _THIS_IP_; regs->msr = msr; regs->link = lr; }
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 7/10 net: stmmac: do not stop RX_CLK in Rx LPI state for qcs404 SoC
In reply to Sasha LevinFrom: Andrey Konovalov <[email protected]>
[ Upstream commit 54aa39a513dbf2164ca462a19f04519b2407a224 ]
Currently in phy_init_eee() the driver unconditionally configures the PHY to stop RX_CLK after entering Rx LPI state. This causes an LPI interrupt storm on my qcs404-base board.
Change the PHY initialization so that for "qcom,qcs404-ethqos" compatible device RX_CLK continues to run even in Rx LPI state.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- include/linux/stmmac.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +2 -0
@@ -505,6 +505,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) plat_dat->has_gmac4 =1 ; plat_dat->pmt =1 ; plat_dat->tso_en =of_property_read_bool (np,"snps,tso" ); +if (of_device_is_compatible (np,"qcom,qcs404-ethqos" )) + plat_dat->rx_clk_runs_in_lpi =1 ; ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
@@ -932,7 +932,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,stmmac_mac_set (priv, priv->ioaddr, true);if (phy && priv->dma_cap.eee) { - priv->eee_active =phy_init_eee (phy,1 ) >=0 ; + priv->eee_active = +phy_init_eee (phy, !priv->plat->rx_clk_runs_in_lpi) >=0 ; priv->eee_enabled =stmmac_eee_init (priv);stmmac_set_eee_pls (priv, priv->hw, true); }
include/linux/stmmac.h +1 -0
@@ -178,6 +178,7 @@ struct plat_stmmacenet_data {int rss_en;int mac_port_sel_speed;bool en_tx_lpi_clockgating; +bool rx_clk_runs_in_lpi;int has_xgmac;bool sph_disable; };
Signature · 7 lines
2.39.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 8/10 net: sched: sch: Bounds check priority
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit de5ca4c3852f896cacac2bf259597aab5e17d9e3 ]
Nothing was explicitly bounds checking the priority index used to access clpriop[]. WARN and bail out early if it's pathological. Seen with GCC 13:
../net/sched/sch_htb.c: In function 'htb_activate_prios':../net/sched/sch_htb.c:437:44: warning: array subscript [0, 31] is outside array bounds of 'struct htb_prio[8]' [-Warray-bounds=]
437 | if (p->inner.clprio[prio].feed.rb_node)
| ~~~~~~~~~~~~~~~^~~~~~
../net/sched/sch_htb.c:131:41: note: while referencing 'clprio'
131 | struct htb_prio clprio[TC_HTB_NUMPRIO];
| ^~~~~~
--- net/sched/sch_htb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/sched/sch_htb.c +4 -1
@@ -405,7 +405,10 @@ static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl)while (cl->cmode ==HTB_MAY_BORROW && p && mask) { m = mask;while (m) { -int prio =ffz (~m); +unsigned int prio =ffz (~m); + +if (WARN_ON_ONCE (prio >ARRAY_SIZE (p->inner.clprio))) +break ; m &= ~(1 << prio);if (p->inner.clprio[prio].feed.rb_node)
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 9/10 s390/decompressor: specify __decompress() buf len to avoid overflow
In reply to Sasha LevinFrom: Vasily Gorbik <[email protected]>
[ Upstream commit 7ab41c2c08a32132ba8c14624910e2fe8ce4ba4b ]
Historically calls to __decompress() didn't specify "out_len" parameter on many architectures including s390, expecting that no writes beyond uncompressed kernel image are performed. This has changed since commit 2aa14b1ab2c4 ("zstd: import usptream v1.5.2") which includes zstd library commit 6a7ede3dfccb ("Reduce size of dctx by reutilizing dst buffer (#2751)"). Now zstd decompression code might store literal buffer in the unwritten portion of the destination buffer. Since "out_len" is not set, it is considered to be unlimited and hence free to use for optimization needs. On s390 this might corrupt initrd or ipl report which are often placed right after the decompressor buffer. Luckily the size of uncompressed kernel image is already known to the decompressor, so to avoid the problem simply specify it in the "out_len" parameter.
--- arch/s390/boot/compressed/decompressor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/boot/compressed/decompressor.c +1 -1
@@ -80,6 +80,6 @@ void *decompress_kernel(void)void *output = (void *)decompress_offset;__decompress (_compressed_start, _compressed_end - _compressed_start, -NULL ,NULL , output,0 ,NULL , error); +NULL ,NULL , output, vmlinux.image_size,NULL , error);return output; }
Signature · 1 line
2.39.0
Re: [PATCH AUTOSEL 5.4 09/10] s390/decompressor: specify __decompress() buf len to avoid overflow
Quoted 13 lines · Sasha Levin
!-------------------------------------------------------------------|
This Message Is From an External Sender|-------------------------------------------------------------------!
From: Vasily Gorbik <[email protected]>
[ Upstream commit
7ab41c2c08a32132ba8c14624910e2fe8ce4ba4b]
Quoted 12 lines
Historically calls to
__decompress()didn't specify "out_len" parameter on many architectures including s390, expecting that no writes beyond uncompressed kernel image are performed. This has changed since commit2aa14b1ab2c4("zstd: import usptream v1.5.2") which includes zstd library commit6a7ede3dfccb("Reduce size of dctx by reutilizing dst buffer (#2751)"). Now zstd decompression code might store literal buffer in the unwritten portion of the destination buffer. Since "out_len" is not set, it is considered to be unlimited and hence free to use for optimization needs. On s390 this might corrupt initrd or ipl report which are often placed right after the decompressor buffer. Luckily the size of uncompressed kernel image is already known to the decompressor, so to avoid the problem simply specify it in the "out_len" parameter.
Thanks for the CC!
It looks like s390 doesn't use in-place decompression, but x86 does, and we'll need to backport upstream commit 5b266196a [0] to make sure we don't overwrite the input buffer.
Best,
Nick Terrell
[0] https://github.com/facebook/zstd/commit/5b266196a41e6a15e21bd4f0eeab43b938db1d90
Quoted 25 lines
Signed-off-by Vasily Gorbik <[email protected]>Tested-by Alexander Egorenkov <[email protected]>Link https://lore.kernel.org/r/patch-1.thread-41c676.git-41c676c2d153.your-ad-here.call-01675030179-ext-9637@work.hours open hereSigned-off-by Heiko Carstens <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
arch/s390/boot/compressed/decompressor.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/boot/compressed/decompressor.c +1
-1@@ -80,6 +80,6 @@ void *decompress_kernel(void)void *output = (void *)decompress_offset;__decompress (_compressed_start, _compressed_end - _compressed_start, -NULL ,NULL , output,0 ,NULL , error); +NULL ,NULL , output, vmlinux.image_size,NULL , error);return output; }Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 10/10 nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association
In reply to Sasha LevinFrom: Amit Engel <[email protected]>
[ Upstream commit 0cab4404874f2de52617de8400c844891c6ea1ce ]
As part of nvmet_fc_ls_create_association there is a case where nvmet_fc_alloc_target_queue fails right after a new association with an admin queue is created. In this case, no one releases the get taken in nvmet_fc_alloc_target_assoc. This fix is adding the missing put.
--- drivers/nvme/target/fc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/fc.c +3 -1
@@ -1362,8 +1362,10 @@ nvmet_fc_ls_create_association(struct nvmet_fc_tgtport *tgtport,else { queue =nvmet_fc_alloc_target_queue (iod->assoc,0 ,be16_to_cpu (rqst->assoc_cmd.sqsize)); -if (!queue) +if (!queue) { ret =VERR_QUEUE_ALLOC_FAIL ; +nvmet_fc_tgt_a_put (iod->assoc); + } } }
Signature · 1 line
2.39.0