6.4.4-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 639/800 misc: fastrpc: check return value of devm_kasprintf()
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit af2e19d82a116bc622eea84c9faadd5f7e20bec4 ]
devm_kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script).
--- drivers/misc/fastrpc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/fastrpc.c +3 -0
@@ -2225,6 +2225,9 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct fdev->miscdev.fops = &fastrpc_fops; fdev->miscdev.name =devm_kasprintf (dev,GFP_KERNEL ,"fastrpc-%s%s" , domain, is_secured ?"-secure" :"" ); +if (!fdev->miscdev.name) +return -ENOMEM ; + err =misc_register (&fdev->miscdev);if (!err) {if (is_secured)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 640/800 clk: qcom: mmcc-msm8974: fix MDSS_GDSC power flags
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 4e13c7a55cf752887f2b8d8008711dbbc64ea796 ]
Using PWRSTS_RET on msm8974's MDSS_GDSC causes display to stop working. The gdsc doesn't fully come out of retention mode. Change it's pwrsts flags to PWRSTS_OFF_ON.
--- drivers/clk/qcom/mmcc-msm8974.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/mmcc-msm8974.c +1 -1
@@ -2384,7 +2384,7 @@ static struct gdsc mdss_gdsc = { .pd = { .name = "mdss", }, - .pwrsts = PWRSTS_RET_ON, + .pwrsts = PWRSTS_OFF_ON, };static struct gdsc camss_jpeg_gdsc = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 641/800 hwtracing: hisi_ptt: Fix potential sleep in atomic context
In reply to Greg Kroah-HartmanFrom: Yicong Yang <[email protected]>
[ Upstream commit 6c50384ef8b94a527445e3694ae6549e1f15d859 ]
We're using pci_irq_vector() to obtain the interrupt number and then bind it to the CPU start perf under the protection of spinlock in pmu::start(). pci_irq_vector() might sleep since [1] because it will call msi_domain_get_virq() to get the MSI interrupt number and it needs to acquire dev->msi.data->mutex. Getting a mutex will sleep on contention. So use pci_irq_vector() in an atomic context is problematic.
This patch cached the interrupt number in the probe() and uses the cached data instead to avoid potential sleep.
[1] commit 82ff8e6b78fc ("PCI/MSI: Use msi_get_virq() in pci_get_vector()")
--- drivers/hwtracing/ptt/hisi_ptt.c | 12 +++++------- drivers/hwtracing/ptt/hisi_ptt.h | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/hwtracing/ptt/hisi_ptt.c +5 -7
@@ -341,13 +341,13 @@ static int hisi_ptt_register_irq(struct hisi_ptt *hisi_ptt)if (ret <0 )return ret; - ret =devm_request_threaded_irq (&pdev->dev, -pci_irq_vector (pdev,HISI_PTT_TRACE_DMA_IRQ ), + hisi_ptt->trace_irq =pci_irq_vector (pdev,HISI_PTT_TRACE_DMA_IRQ ); + ret =devm_request_threaded_irq (&pdev->dev, hisi_ptt->trace_irq,NULL , hisi_ptt_isr,0 ,DRV_NAME , hisi_ptt);if (ret) {pci_err (pdev,"failed to request irq %d, ret = %d\n" , -pci_irq_vector (pdev,HISI_PTT_TRACE_DMA_IRQ ), ret); + hisi_ptt->trace_irq, ret);return ret; }
@@ -757,8 +757,7 @@ static void hisi_ptt_pmu_start(struct perf_event *event, int flags)* core in event_function_local(). If CPU passed is offline we'll fail * here, just log it since we can do nothing here. */ - ret =irq_set_affinity (pci_irq_vector (hisi_ptt->pdev,HISI_PTT_TRACE_DMA_IRQ ), -cpumask_of (cpu)); + ret =irq_set_affinity (hisi_ptt->trace_irq,cpumask_of (cpu));if (ret)dev_warn (dev,"failed to set the affinity of trace interrupt\n" );
@@ -1018,8 +1017,7 @@ static int hisi_ptt_cpu_teardown(unsigned int cpu, struct hlist_node *node)* Also make sure the interrupt bind to the migrated CPU as well. Warn * the user on failure here. */ -if (irq_set_affinity (pci_irq_vector (hisi_ptt->pdev,HISI_PTT_TRACE_DMA_IRQ ), -cpumask_of (target))) +if (irq_set_affinity (hisi_ptt->trace_irq,cpumask_of (target)))dev_warn (dev,"failed to set the affinity of trace interrupt\n" ); hisi_ptt->trace_ctrl.on_cpu = target;
drivers/hwtracing/ptt/hisi_ptt.h +2 -0
@@ -166,6 +166,7 @@ struct hisi_ptt_pmu_buf {* @pdev: pci_dev of this PTT device * @tune_lock: lock to serialize the tune process * @pmu_lock: lock to serialize the perf process +* @trace_irq: interrupt number used by trace * @upper_bdf: the upper BDF range of the PCI devices managed by this PTT device * @lower_bdf: the lower BDF range of the PCI devices managed by this PTT device * @port_filters: the filter list of root ports
@@ -180,6 +181,7 @@ struct hisi_ptt {struct pci_dev *pdev;struct mutex tune_lock;spinlock_t pmu_lock; +int trace_irq;u32 upper_bdf;u32 lower_bdf;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 642/800 phy: qcom: qmp-combo: fix Display Port PHY configuration for SM8550
In reply to Greg Kroah-HartmanFrom: Neil Armstrong <[email protected]>
[ Upstream commit 6cd52a2a06774c6c454ffef084c3d9b17618ca23 ]
The SM8550 PHY also uses a different offset for the CMN_STATUS reg, use the right one for the v6 Display Port configuration.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +6 -2
@@ -2142,6 +2142,7 @@ static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp)static int qmp_v456_configure_dp_phy (struct qmp_combo *qmp,unsigned int com_resetm_ctrl_reg,unsigned int com_c_ready_status_reg, +unsigned int com_cmn_status_reg,unsigned int dp_phy_status_reg) {const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
@@ -2198,14 +2199,14 @@ static int qmp_v456_configure_dp_phy(struct qmp_combo *qmp, 10000))return -ETIMEDOUT ; -if (readl_poll_timeout (qmp->dp_serdes +QSERDES_V4_COM_CMN_STATUS , +if (readl_poll_timeout (qmp->dp_serdes + com_cmn_status_reg, status, ((status &BIT (0 )) >0 ),500 ,10000 ))return -ETIMEDOUT ; - if (readl_poll_timeout(qmp->dp_serdes + QSERDES_V4_COM_CMN_STATUS, + if (readl_poll_timeout(qmp->dp_serdes + com_cmn_status_reg, status, ((status & BIT(1)) > 0), 500,
@@ -2241,6 +2242,7 @@ static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp) ret =qmp_v456_configure_dp_phy (qmp,QSERDES_V4_COM_RESETSM_CNTRL ,QSERDES_V4_COM_C_READY_STATUS , +QSERDES_V4_COM_CMN_STATUS ,QSERDES_V4_DP_PHY_STATUS );if (ret <0 )return ret;
@@ -2305,6 +2307,7 @@ static int qmp_v5_configure_dp_phy(struct qmp_combo *qmp) ret =qmp_v456_configure_dp_phy (qmp,QSERDES_V4_COM_RESETSM_CNTRL ,QSERDES_V4_COM_C_READY_STATUS , +QSERDES_V4_COM_CMN_STATUS ,QSERDES_V4_DP_PHY_STATUS );if (ret <0 )return ret;
@@ -2364,6 +2367,7 @@ static int qmp_v6_configure_dp_phy(struct qmp_combo *qmp) ret =qmp_v456_configure_dp_phy (qmp,QSERDES_V6_COM_RESETSM_CNTRL ,QSERDES_V6_COM_C_READY_STATUS , +QSERDES_V6_COM_CMN_STATUS ,QSERDES_V6_DP_PHY_STATUS );if (ret <0 )return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 643/800 mfd: stmpe: Only disable the regulators if they are enabled
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 104d32bd81f620bb9f67fbf7d1159c414e89f05f ]
In stmpe_probe(), if some regulator_enable() calls fail, probing continues and there is only a dev_warn().
So, if stmpe_probe() is called the regulator may not be enabled. It is cleaner to test it before calling regulator_disable() in the remove function.
--- drivers/mfd/stmpe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/stmpe.c +2 -2
@@ -1485,9 +1485,9 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)void stmpe_remove (struct stmpe *stmpe) { -if (!IS_ERR (stmpe->vio)) +if (!IS_ERR (stmpe->vio) &®ulator_is_enabled (stmpe->vio))regulator_disable (stmpe->vio); -if (!IS_ERR (stmpe->vcc)) +if (!IS_ERR (stmpe->vcc) &®ulator_is_enabled (stmpe->vcc))regulator_disable (stmpe->vcc);__stmpe_disable (stmpe,STMPE_BLOCK_ADC );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 644/800 phy: tegra: xusb: check return value of devm_kzalloc()
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 44faada0f38fc333d392af04c343b0e23f8f5d81 ]
devm_kzalloc() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script).
--- drivers/phy/tegra/xusb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/tegra/xusb.c +3 -0
@@ -676,6 +676,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port) port->dev.driver =devm_kzalloc (&port->dev,sizeof (struct device_driver ),GFP_KERNEL ); +if (!port->dev.driver) +return -ENOMEM ; + port->dev.driver->owner =THIS_MODULE ; port->usb_role_sw = usb_role_switch_register(&port->dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 645/800 lib/bitmap: drop optimization of bitmap_{from,to}_arr64
In reply to Greg Kroah-HartmanFrom: Yury Norov <[email protected]>
[ Upstream commit c1d2ba10f594046831d14b03f194e8d05e78abad ]
bitmap_{from,to}_arr64() optimization is overly optimistic on 32-bit LE architectures when it's wired to bitmap_copy_clear_tail().
bitmap_copy_clear_tail() takes care of unused bits in the bitmap up to the next word boundary. But on 32-bit machines when copying bits from bitmap to array of 64-bit words, it's expected that the unused part of a recipient array must be cleared up to 64-bit boundary, so the last 4 bytes may stay untouched when nbits % 64 <= 32.
While the copying part of the optimization works correct, that clear-tail trick makes corresponding tests reasonably fail:
test_bitmap: bitmap_to_arr64(nbits == 1): tail is not safely cleared: 0xa5a5a5a500000001 (must be 0x0000000000000001)
Fix it by removing bitmap_{from,to}_arr64() optimization for 32-bit LE arches.
--- include/linux/bitmap.h | 8 +++----- lib/bitmap.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-)
include/linux/bitmap.h +3 -5
@@ -302,12 +302,10 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap,#endif /* -* On 64-bit systems bitmaps are represented as u64 arrays internally. On LE32 -* machines the order of hi and lo parts of numbers match the bitmap structure. -* In both cases conversion is not needed when copying data from/to arrays of -* u64. +* On 64-bit systems bitmaps are represented as u64 arrays internally. So, +* the conversion is not needed when copying data from/to arrays of u64. */ -#if (BITS_PER_LONG ==32 ) && defined(__BIG_ENDIAN) +#if BITS_PER_LONG ==32 void bitmap_from_arr64 (unsigned long *bitmap,const u64 *buf,unsigned int nbits);void bitmap_to_arr64 (u64 *buf,const unsigned long *bitmap,unsigned int nbits);#else
lib/bitmap.c +1 -1
@@ -1495,7 +1495,7 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)EXPORT_SYMBOL (bitmap_to_arr32);#endif -#if (BITS_PER_LONG ==32 ) && defined(__BIG_ENDIAN) +#if BITS_PER_LONG ==32 /** * bitmap_from_arr64 - copy the contents of u64 array of bits to bitmap * @bitmap: array of unsigned longs, the destination bitmap
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 646/800 pwm: imx-tpm: force real_period to be zero in suspend
In reply to Greg Kroah-HartmanFrom: Fancy Fang <[email protected]>
[ Upstream commit 661dfb7f46298e53f6c3deaa772fa527aae86193 ]
During suspend, all the tpm registers will lose values. So the 'real_period' value of struct 'imx_tpm_pwm_chip' should be forced to be zero to force the period update code can be executed after system resume back.
--- drivers/pwm/pwm-imx-tpm.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pwm/pwm-imx-tpm.c +7 -0
@@ -397,6 +397,13 @@ static int __maybe_unused pwm_imx_tpm_suspend(struct device *dev)if (tpm->enable_count >0 )return -EBUSY ; +/* +* Force 'real_period' to be zero to force period update code +* can be executed after system resume back, since suspend causes +* the period related registers to become their reset values. +*/ + tpm->real_period =0 ; +clk_disable_unprepare (tpm->clk);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 647/800 pwm: sysfs: Do not apply state to already disabled PWMs
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 38ba83598633373f47951384cfc389181c8d1bed ]
If the PWM is exported but not enabled, do not call pwm_class_apply_state(). First of all, in this case, period may still be unconfigured and this would make pwm_class_apply_state() return -EINVAL, and then suspend would fail. Second, it makes little sense to apply state onto PWM that is not enabled before suspend.
Failing case:
"
$ echo 1 > /sys/class/pwm/pwmchip4/export $ echo mem > /sys/power/state ... pwm pwmchip4: PM: dpm_run_callback(): pwm_class_suspend+0x1/0xa8 returns -22 pwm pwmchip4: PM: failed to suspend: error -22 PM: Some devices failed to suspend, or early wake event detected "
Working case:
"
$ echo 1 > /sys/class/pwm/pwmchip4/export $ echo 100 > /sys/class/pwm/pwmchip4/pwm1/period $ echo 10 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle $ echo mem > /sys/power/state ... "
Do not call pwm_class_apply_state() in case the PWM is disabled to fix this issue.
--- drivers/pwm/sysfs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/pwm/sysfs.c +17 -0
@@ -424,6 +424,13 @@ static int pwm_class_resume_npwm(struct device *parent, unsigned int npwm)if (!export)continue ; +/* If pwmchip was not enabled before suspend, do nothing. */ +if (!export->suspend.enabled) { +/* release lock taken in pwm_class_get_state */ +mutex_unlock (&export->lock); +continue ; + } + state.enabled = export->suspend.enabled; ret =pwm_class_apply_state (export, pwm, &state);if (ret <0 )
@@ -448,7 +455,17 @@ static int pwm_class_suspend(struct device *parent)if (!export)continue ; +/* +* If pwmchip was not enabled before suspend, save +* state for resume time and do nothing else. +*/ export->suspend = state; +if (!state.enabled) { +/* release lock taken in pwm_class_get_state */ +mutex_unlock (&export->lock); +continue ; + } + state.enabled = false; ret =pwm_class_apply_state (export, pwm, &state);if (ret <0 ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 648/800 pwm: ab8500: Fix error code in probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit cdcffafc4d845cc0c6392cba168c7a942734cce7 ]
This code accidentally return positive EINVAL instead of negative -EINVAL.
--- drivers/pwm/pwm-ab8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-ab8500.c +1 -1
@@ -190,7 +190,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev)int err;if (pdev->id <1 || pdev->id >31 ) -return dev_err_probe (&pdev->dev,EINVAL ,"Invalid device id %d\n" , pdev->id); +return dev_err_probe (&pdev->dev, -EINVAL ,"Invalid device id %d\n" , pdev->id);/* * Nothing to be done in probe, this is required to get the
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 649/800 pwm: mtk_disp: Fix the disable flow of disp_pwm
In reply to Greg Kroah-HartmanFrom: Shuijing Li <[email protected]>
[ Upstream commit bc13d60e4e1e945b34769a4a4c2b172e8552abe5 ]
There is a flow error in the original mtk_disp_pwm_apply() function. If this function is called when the clock is disabled, there will be a chance to operate the disp_pwm register, resulting in disp_pwm exception. Fix this accordingly.
--- drivers/pwm/pwm-mtk-disp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/pwm/pwm-mtk-disp.c +5 -8
@@ -79,14 +79,11 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,if (state->polarity !=PWM_POLARITY_NORMAL )return -EINVAL ; -if (!state->enabled) { -mtk_disp_pwm_update_bits (mdp,DISP_PWM_EN , mdp->data->enable_mask, -0x0 ); - -if (mdp->enabled) { -clk_disable_unprepare (mdp->clk_mm); -clk_disable_unprepare (mdp->clk_main); - } +if (!state->enabled && mdp->enabled) { +mtk_disp_pwm_update_bits (mdp,DISP_PWM_EN , + mdp->data->enable_mask,0x0 ); +clk_disable_unprepare (mdp->clk_mm); +clk_disable_unprepare (mdp->clk_main); mdp->enabled = false;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 650/800 md/raid10: fix the condition to call bio_end_io_acct()
In reply to Greg Kroah-HartmanFrom: Li Nan <[email protected]>
[ Upstream commit 125bfc7cd750e68c99f1d446e2c22abea08c237f ]
/sys/block/[device]/queue/iostats is used to control whether to count io stat. Write 0 to it will clear queue_flags QUEUE_FLAG_IO_STAT which means iostats is disabled. If we disable iostats and later endable it, the io issued during this period will be counted incorrectly, inflight will be decreased to -1.
//T1 set iostats
echo 0 > /sys/block/md0/queue/iostats
clear QUEUE_FLAG_IO_STAT
//T2 issue io if (QUEUE_FLAG_IO_STAT) -> false bio_start_io_acct inflight++
echo 1 > /sys/block/md0/queue/iostats
set QUEUE_FLAG_IO_STAT
//T3 io end if (QUEUE_FLAG_IO_STAT) -> true bio_end_io_acct inflight-- -> -1
Also, if iostats is enabled while issuing io but disabled while io end, inflight will never be decreased.
Fix it by checking start_time when io end. If start_time is not 0, call bio_end_io_acct().
--- drivers/md/raid10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid10.c +1 -1
@@ -325,7 +325,7 @@ static void raid_end_bio_io(struct r10bio *r10_bio)if (!test_bit (R10BIO_Uptodate, &r10_bio->state)) bio->bi_status =BLK_STS_IOERR ; -if (blk_queue_io_stat (bio->bi_bdev->bd_disk->queue)) +if (r10_bio->start_time)bio_end_io_acct (bio, r10_bio->start_time);bio_endio (bio);/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 651/800 perf bpf: Move the declaration of struct rq
In reply to Greg Kroah-HartmanFrom: Ian Rogers <[email protected]>
[ Upstream commit 5c45b210479bffe068d38902fcdcb52c4c60a264 ]
struct rq is defined in vmlinux.h when the vmlinux.h is generated, this causes a redefinition failure if it is declared in lock_contention.bpf.c. Move the definition to vmlinux.h for consistency with the generated version.
--- tools/perf/util/bpf_skel/lock_contention.bpf.c | 2 -- tools/perf/util/bpf_skel/vmlinux.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-)
tools/perf/util/bpf_skel/lock_contention.bpf.c +0 -2
@@ -416,8 +416,6 @@ int contention_end(u64 *ctx)return 0 ; } -struct rq {}; - extern struct rq runqueues __ksym;struct rq___old {
tools/perf/util/bpf_skel/vmlinux.h +10 -0
@@ -171,4 +171,14 @@ struct bpf_perf_event_data_kern {struct perf_sample_data *data;struct perf_event *event; } __attribute__((preserve_access_index)); + +/* +* If 'struct rq' isn't defined for lock_contention.bpf.c, for the sake of +* rq___old and rq___new, then the type for the 'runqueue' variable ends up +* being a forward declaration (BTF_KIND_FWD) while the kernel has it defined +* (BTF_KIND_STRUCT). The definition appears in vmlinux.h rather than +* lock_contention.bpf.c for consistency with a generated vmlinux.h. +*/ +struct rq {}; +#endif // __VMLINUX_H
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 652/800 blk-throttle: Fix io statistics for cgroup v1
In reply to Greg Kroah-HartmanFrom: Jinke Han <[email protected]>
[ Upstream commit ad7c3b41e86b59943a903d23c7b037d820e6270c ]
After commit f382fb0bcef4 ("block: remove legacy IO schedulers"), blkio.throttle.io_serviced and blkio.throttle.io_service_bytes become the only stable io stats interface of cgroup v1, and these statistics are done in the blk-throttle code. But the current code only counts the bios that are actually throttled. When the user does not add the throttle limit, the io stats for cgroup v1 has nothing. I fix it according to the statistical method of v2, and made it count all ios accurately.
--- block/blk-cgroup.c | 6 ++++-- block/blk-throttle.c | 6 ------ block/blk-throttle.h | 9 +++++++++ 3 files changed, 13 insertions(+), 8 deletions(-)
block/blk-cgroup.c +4 -2
@@ -2086,6 +2086,9 @@ void blk_cgroup_bio_start(struct bio *bio)struct blkg_iostat_set *bis;unsigned long flags; +if (!cgroup_subsys_on_dfl (io_cgrp_subsys)) +return ; +/* Root-level stats are sourced from system-wide IO stats */ if (!cgroup_parent (blkcg->css.cgroup))return ;
@@ -2116,8 +2119,7 @@ void blk_cgroup_bio_start(struct bio *bio) }u64_stats_update_end_irqrestore (&bis->sync, flags); -if (cgroup_subsys_on_dfl (io_cgrp_subsys)) -cgroup_rstat_updated (blkcg->css.cgroup, cpu); +cgroup_rstat_updated (blkcg->css.cgroup, cpu);put_cpu (); }
block/blk-throttle.c +0 -6
@@ -2178,12 +2178,6 @@ bool __blk_throtl_bio(struct bio *bio)rcu_read_lock (); -if (!cgroup_subsys_on_dfl (io_cgrp_subsys)) { -blkg_rwstat_add (&tg->stat_bytes, bio->bi_opf, - bio->bi_iter.bi_size); -blkg_rwstat_add (&tg->stat_ios, bio->bi_opf,1 ); - } -spin_lock_irq (&q->queue_lock);throtl_update_latency_buckets (td);
block/blk-throttle.h +9 -0
@@ -185,6 +185,15 @@ static inline bool blk_should_throtl(struct bio *bio)struct throtl_grp *tg =blkg_to_tg (bio->bi_blkg);int rw =bio_data_dir (bio); +if (!cgroup_subsys_on_dfl (io_cgrp_subsys)) { +if (!bio_flagged (bio,BIO_CGROUP_ACCT )) { +bio_set_flag (bio,BIO_CGROUP_ACCT ); +blkg_rwstat_add (&tg->stat_bytes, bio->bi_opf, + bio->bi_iter.bi_size); + } +blkg_rwstat_add (&tg->stat_ios, bio->bi_opf,1 ); + } +/* iops limit is always counted */ if (tg->has_rules_iops[rw])return true;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 653/800 rtc: st-lpc: Release some resources in st_rtc_probe() in case of error
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 06c6e1b01d9261f03629cefd1f3553503291e6cf ]
If an error occurs after clk_get(), the corresponding resources should be released.
Use devm_clk_get() to fix it.
--- drivers/rtc/rtc-st-lpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-st-lpc.c +1 -1
@@ -228,7 +228,7 @@ static int st_rtc_probe(struct platform_device *pdev)enable_irq_wake (rtc->irq);disable_irq (rtc->irq); - rtc->clk =clk_get (&pdev->dev,NULL ); + rtc->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (rtc->clk)) {dev_err (&pdev->dev,"Unable to request clock\n" );return PTR_ERR (rtc->clk);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 654/800 drm/i915/psr: Use hw.adjusted mode when calculating io/fast wake times
In reply to Greg Kroah-HartmanFrom: Jouni Högander <[email protected]>
[ Upstream commit 5311892a0ad1d301aafd53ca0154091b3eb407ea ]
Encoder compute config is changing hw.adjusted mode. Uapi.adjusted mode doesn't get updated before psr compute config gets called. This causes io and fast wake line calculation using adjusted mode containing values before encoder adjustments. Fix this by using hw.adjusted mode instead of uapi.adjusted mode.
--- drivers/gpu/drm/i915/display/intel_psr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_psr.c +2 -2
@@ -851,9 +851,9 @@ static bool _compute_psr2_wake_times(struct intel_dp *intel_dp, } io_wake_lines =intel_usecs_to_scanlines ( - &crtc_state->uapi.adjusted_mode, io_wake_time); + &crtc_state->hw.adjusted_mode, io_wake_time); fast_wake_lines =intel_usecs_to_scanlines ( - &crtc_state->uapi.adjusted_mode, fast_wake_time); + &crtc_state->hw.adjusted_mode, fast_wake_time);if (io_wake_lines > max_wake_lines || fast_wake_lines > max_wake_lines)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 655/800 drm/i915/guc/slpc: Apply min softlimit correctly
In reply to Greg Kroah-HartmanFrom: Vinay Belgaumkar <[email protected]>
[ Upstream commit 3e49de73fb89272dea01ba420c7ccbcf6b96aed7 ]
The scenario being fixed here is depicted in the following sequence-
modprobe i915
echo 1 > /sys/class/drm/card0/gt/gt0/slpc_ignore_eff_freq echo 300 > /sys/class/drm/card0/gt_min_freq_mhz (RPn)
cat /sys/class/drm/card0/gt_cur_freq_mhz --> cur == RPn as expected echo 1 > /sys/kernel/debug/dri/0/gt0/reset --> reset
cat /sys/class/drm/card0/gt_min_freq_mhz --> cached freq is RPn cat /sys/class/drm/card0/gt_cur_freq_mhz --> it's not RPn, but RPe!!
When SLPC reinitializes, it sets SLPC min freq to efficient frequency. Even if we disable efficient freq post that, we should restore the cached min freq (via H2G) for it to take effect.
v2: Clarify commit message (Ashutosh)
--- drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c +1 -1
@@ -606,7 +606,7 @@ static int slpc_set_softlimits(struct intel_guc_slpc *slpc)if (unlikely (ret))return ret;slpc_to_gt (slpc)->defaults.min_freq = slpc->min_freq_softlimit; - }else if (slpc->min_freq_softlimit != slpc->min_freq) { + }else {return intel_guc_slpc_set_min_freq (slpc, slpc->min_freq_softlimit); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 656/800 f2fs: check return value of freeze_super()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 8bec7dd1b3f7d7769d433d67bde404de948a2d95 ]
freeze_super() can fail, it needs to check its return value and do error handling in f2fs_resize_fs().
--- fs/f2fs/gc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +3 -1
@@ -2175,7 +2175,9 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)if (err)return err; -freeze_super (sbi->sb); + err =freeze_super (sbi->sb); +if (err) +return err;if (f2fs_readonly (sbi->sb)) {thaw_super (sbi->sb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 657/800 virtio-vdpa: Fix unchecked call to NULL set_vq_affinity
In reply to Greg Kroah-HartmanFrom: Dragos Tatulea <[email protected]>
[ Upstream commit fe37efba475375caa2dbc71cb06f53f7086277ef ]
The referenced patch calls set_vq_affinity without checking if the op is valid. This patch adds the check.
Message-Id: <[email protected]>
--- drivers/virtio/virtio_vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/virtio/virtio_vdpa.c +3 -1
@@ -385,7 +385,9 @@ static int virtio_vdpa_find_vqs(struct virtio_device *vdev, unsigned int nvqs, err =PTR_ERR (vqs[i]); goto err_setup_vq; } - ops->set_vq_affinity (vdpa, i, &masks[i]); + +if (ops->set_vq_affinity) + ops->set_vq_affinity (vdpa, i, &masks[i]); } cb.callback = virtio_vdpa_config_cb;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 658/800 tools/virtio: fix build break for aarch64
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
[ Upstream commit 77b894f220cbd04301b3d941df8247106e67f8e4 ]
"-mfunction-return=thunk -mindirect-branch-register" are only valid for x86. So introduce compiler operation check to avoid such issues
Message-Id: <[email protected]>
--- tools/virtio/Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
tools/virtio/Makefile +12 -1
@@ -4,7 +4,18 @@ test: virtio_test vringh_test virtio_test: virtio_ring.o virtio_test.o vringh_test: vringh_test.o vringh.o virtio_ring.o -CFLAGS += -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h -mfunction-return=thunk -fcf-protection=none -mindirect-branch-register +try-run = $(shell set -e; \ + if ($(1)) >/dev/null 2>&1; \ + then echo "$(2)"; \ + else echo "$(3)"; \ + fi) + +__cc-option = $(call try-run,\ + $(1) -Werror $(2) -c -x c /dev/null -o /dev/null,$(2),) +cc-option = $(call __cc-option, $(CC),$(1)) + +CFLAGS += -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h $(call cc-option,-mfunction-return=thunk) $(call cc-option,-fcf-protection=none) $(call cc-option,-mindirect-branch-register) + CFLAGS += -pthread LDFLAGS += -pthread vpath %.c ../../drivers/virtio ../../drivers/vhost
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 659/800 media: tc358746: select CONFIG_GENERIC_PHY
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 582d4ad468cbc6ef2db4689ff3bd5868d95402c9 ]
The tc358746 driver selects CONFIG_GENERIC_PHY_MIPI_DPHY and links to that, but this fails when CONFIG_GENERIC_PHY is disabled, because Kbuild then never enters the drivers/phy directory for building object files:
ERROR: modpost: "phy_mipi_dphy_get_default_config_for_hsclk" [drivers/media/i2c/tc358746.ko] undefined!
Add an explicit 'select GENERIC_PHY' here to ensure that the directory is entered, and add another dependency on that symbol so make it more obvious what is going on if another driver has the same problem, as this will produce a Kconfig warning.
--- drivers/media/i2c/Kconfig | 1 + drivers/phy/Kconfig | 1 + 2 files changed, 2 insertions(+)
drivers/media/i2c/Kconfig +1 -0
@@ -1292,6 +1292,7 @@ config VIDEO_TC358746 select VIDEO_V4L2_SUBDEV_API select MEDIA_CONTROLLER select V4L2_FWNODE + select GENERIC_PHY select GENERIC_PHY_MIPI_DPHY select REGMAP_I2C help
drivers/phy/Kconfig +1 -0
@@ -18,6 +18,7 @@ config GENERIC_PHY config GENERIC_PHY_MIPI_DPHY bool + depends on GENERIC_PHY help Generic MIPI D-PHY support.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 660/800 media: cec: i2c: ch7322: also select REGMAP
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 29f96ac23648b2259f42d40703c47dd18fd172ca ]
Selecting only REGMAP_I2C can leave REGMAP unset, causing build errors, so also select REGMAP to prevent the build errors.
../drivers/media/cec/i2c/ch7322.c:158:21: error: variable 'ch7322_regmap' has initializer but incomplete type
158 | static const struct regmap_config ch7322_regmap = {../drivers/media/cec/i2c/ch7322.c:159:10: error: 'const struct regmap_config' has no member named 'reg_bits'
159 | .reg_bits = 8,../drivers/media/cec/i2c/ch7322.c:159:21: warning: excess elements in struct initializer
159 | .reg_bits = 8,../drivers/media/cec/i2c/ch7322.c:160:10: error: 'const struct regmap_config' has no member named 'val_bits'
160 | .val_bits = 8,../drivers/media/cec/i2c/ch7322.c:160:21: warning: excess elements in struct initializer
160 | .val_bits = 8,../drivers/media/cec/i2c/ch7322.c:161:10: error: 'const struct regmap_config' has no member named 'max_register'
161 | .max_register = 0x7f,../drivers/media/cec/i2c/ch7322.c:161:25: warning: excess elements in struct initializer
161 | .max_register = 0x7f,../drivers/media/cec/i2c/ch7322.c:162:10: error: 'const struct regmap_config' has no member named 'disable_locking'
162 | .disable_locking = true,../drivers/media/cec/i2c/ch7322.c:162:28: warning: excess elements in struct initializer
162 | .disable_locking = true,../drivers/media/cec/i2c/ch7322.c: In function 'ch7322_probe':../drivers/media/cec/i2c/ch7322.c:468:26: error: implicit declaration of function 'devm_regmap_init_i2c' [-Werror=implicit-function-declaration]
468 | ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);../drivers/media/cec/i2c/ch7322.c:468:24: warning: assignment to 'struct regmap *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
468 | ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);../drivers/media/cec/i2c/ch7322.c: At top level:../drivers/media/cec/i2c/ch7322.c:158:35: error: storage size of 'ch7322_regmap' isn't known
158 | static const struct regmap_config ch7322_regmap = {
--- drivers/media/cec/i2c/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/cec/i2c/Kconfig +1 -0
@@ -5,6 +5,7 @@ config CEC_CH7322 tristate "Chrontel CH7322 CEC controller" depends on I2C + select REGMAP select REGMAP_I2C select CEC_CORE help
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 661/800 sctp: fix potential deadlock on &net->sctp.addr_wq_lock
In reply to Greg Kroah-HartmanFrom: Chengfeng Ye <[email protected]>
[ Upstream commit 6feb37b3b06e9049e20dcf7e23998f92c9c5be9a ]
As &net->sctp.addr_wq_lock is also acquired by the timer sctp_addr_wq_timeout_handler() in protocal.c, the same lock acquisition at sctp_auto_asconf_init() seems should disable irq since it is called from sctp_accept() under process context.
Possible deadlock scenario:sctp_accept()
-> sctp_sock_migrate()
-> sctp_auto_asconf_init()
-> spin_lock(&net->sctp.addr_wq_lock)
<timer interrupt>
-> sctp_addr_wq_timeout_handler()
-> spin_lock_bh(&net->sctp.addr_wq_lock); (deadlock here)This flaw was found using an experimental static analysis tool we are developing for irq-related deadlock.
The tentative patch fix the potential deadlock by spin_lock_bh().
--- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sctp/socket.c +2 -2
@@ -364,9 +364,9 @@ static void sctp_auto_asconf_init(struct sctp_sock *sp)struct net *net =sock_net (&sp->inet.sk);if (net->sctp.default_auto_asconf) { -spin_lock (&net->sctp.addr_wq_lock); +spin_lock_bh (&net->sctp.addr_wq_lock);list_add_tail (&sp->auto_asconf_list, &net->sctp.auto_asconf_splist); -spin_unlock (&net->sctp.addr_wq_lock); +spin_unlock_bh (&net->sctp.addr_wq_lock); sp->do_auto_asconf =1 ; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 662/800 net/sched: act_ipt: add sanity checks on table name and hook locations
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit b4ee93380b3c891fea996af8d1d3ca0e36ad31f0 ]
Looks like "tc" hard-codes "mangle" as the only supported table name, but on kernel side there are no checks.
This is wrong. Not all xtables targets are safe to call from tc. E.g. "nat" targets assume skb has a conntrack object assigned to it. Normally those get called from netfilter nat core which consults the nat table to obtain the address mapping.
"tc" userspace either sets PRE or POSTROUTING as hook number, but there is no validation of this on kernel side, so update netlink policy to reject bogus numbers. Some targets may assume skb_dst is set for input/forward hooks, so prevent those from being used.
act_ipt uses the hook number in two places:
1. the state hook number, this is fine as-is
2. to set par.hook_mask
The latter is a bit mask, so update the assignment to make xt_check_target() to the right thing.
Followup patch adds required checks for the skb/packet headers before calling the targets evaluation function.
--- net/sched/act_ipt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
net/sched/act_ipt.c +20 -7
@@ -48,7 +48,7 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t, par.entryinfo = &e; par.target = target; par.targinfo = t->data; - par.hook_mask = hook; + par.hook_mask =1 << hook; par.family =NFPROTO_IPV4 ; ret =xt_check_target (&par, t->u.target_size -sizeof (*t),0 , false);
@@ -85,7 +85,8 @@ static void tcf_ipt_release(struct tc_action *a)static const struct nla_policy ipt_policy[TCA_IPT_MAX +1 ] = { [TCA_IPT_TABLE ] = { .type =NLA_STRING , .len =IFNAMSIZ }, - [TCA_IPT_HOOK ] = { .type =NLA_U32 }, + [TCA_IPT_HOOK ] =NLA_POLICY_RANGE (NLA_U32 ,NF_INET_PRE_ROUTING , +NF_INET_NUMHOOKS ), [TCA_IPT_INDEX ] = { .type =NLA_U32 }, [TCA_IPT_TARG ] = { .len =sizeof (struct xt_entry_target ) }, };
@@ -158,15 +159,27 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla,return -EEXIST ; } } + + err = -EINVAL ; hook =nla_get_u32 (tb[TCA_IPT_HOOK ]); +switch (hook) { +case NF_INET_PRE_ROUTING : +break ; +case NF_INET_POST_ROUTING : +break ; +default : + goto err1; + } + +if (tb[TCA_IPT_TABLE ]) { +/* mangle only for now */ +if (nla_strcmp (tb[TCA_IPT_TABLE ],"mangle" )) + goto err1; + } - err = -ENOMEM ; - tname =kmalloc (IFNAMSIZ ,GFP_KERNEL ); + tname =kstrdup ("mangle" ,GFP_KERNEL );if (unlikely (!tname)) goto err1; -if (tb[TCA_IPT_TABLE ] ==NULL || -nla_strscpy (tname, tb[TCA_IPT_TABLE ],IFNAMSIZ ) >=IFNAMSIZ ) -strcpy (tname,"mangle" ); t =kmemdup (td, td->u.target_size,GFP_KERNEL );if (unlikely (!t))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 663/800 net/sched: act_ipt: add sanity checks on skb before calling target
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit b2dc32dcba08bf55cec600caa76f4afd2e3614df ]
Netfilter targets make assumptions on the skb state, for example iphdr is supposed to be in the linear area.
This is normally done by IP stack, but in act_ipt case no such checks are made.
Some targets can even assume that skb_dst will be valid. Make a minimum effort to check for this:
- Don't call the targets eval function for non-ipv4 skbs.
- Don't call the targets eval function for POSTROUTING emulation when the skb has no dst set.
v3: use skb_protocol helper (Davide Caratti)
--- net/sched/act_ipt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
net/sched/act_ipt.c +33 -0
@@ -230,6 +230,26 @@ static int tcf_xt_init(struct net *net, struct nlattr *nla, a, &act_xt_ops, tp, flags); } +static bool tcf_ipt_act_check (struct sk_buff *skb) +{ +const struct iphdr *iph; +unsigned int nhoff, len; + +if (!pskb_may_pull (skb,sizeof (struct iphdr ))) +return false; + + nhoff =skb_network_offset (skb); + iph =ip_hdr (skb); +if (iph->ihl <5 || iph->version !=4 ) +return false; + + len =skb_ip_totlen (skb); +if (skb->len < nhoff + len || len < (iph->ihl *4u )) +return false; + +return pskb_may_pull (skb, iph->ihl *4u ); +} + TC_INDIRECT_SCOPE int tcf_ipt_act(struct sk_buff *skb,const struct tc_action *a,struct tcf_result *res)
@@ -244,9 +264,22 @@ TC_INDIRECT_SCOPE int tcf_ipt_act(struct sk_buff *skb, .pf = NFPROTO_IPV4, }; +if (skb_protocol (skb, false) !=htons (ETH_P_IP )) +return TC_ACT_UNSPEC ; +if (skb_unclone (skb,GFP_ATOMIC ))return TC_ACT_UNSPEC ; +if (!tcf_ipt_act_check (skb)) +return TC_ACT_UNSPEC ; + +if (state.hook ==NF_INET_POST_ROUTING ) { +if (!skb_dst (skb)) +return TC_ACT_UNSPEC ; + + state.out = skb->dev; + } +spin_lock (&ipt->tcf_lock);tcf_lastuse_update (&ipt->tcf_tm);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 664/800 net/sched: act_ipt: zero skb->cb before calling target
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 93d75d475c5dc3404292976147d063ee4d808592 ]
xtables relies on skb being owned by ip stack, i.e. with ipv4 check in place skb->cb is supposed to be IPCB.
I don't see an immediate problem (REJECT target cannot be used anymore now that PRE/POSTROUTING hook validation has been fixed), but better be safe than sorry.
A much better patch would be to either mark act_ipt as "depends on BROKEN" or remove it altogether. I plan to do this for -next in the near future.
This tc extension is broken in the sense that tc lacks an equivalent of NF_STOLEN verdict.
With NF_STOLEN, target function takes complete ownership of skb, caller cannot dereference it anymore.
ACT_STOLEN cannot be used for this: it has a different meaning, caller is allowed to dereference the skb.
At this time NF_STOLEN won't be returned by any targets as far as I can see, but this may change in the future.
It might be possible to work around this via list of allowed target extensions known to only return DROP or ACCEPT verdicts, but this is error prone/fragile.
Existing selftest only validates xt_LOG and act_ipt is restricted to ipv4 so I don't think this action is used widely.
--- net/sched/act_ipt.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/sched/act_ipt.c +10 -0
@@ -21,6 +21,7 @@#include <linux/tc_act/tc_ipt.h> #include <net/tc_act/tc_ipt.h> #include <net/tc_wrapper.h> +#include <net/ip.h> #include <linux/netfilter_ipv4/ip_tables.h>
@@ -254,6 +255,7 @@ TC_INDIRECT_SCOPE int tcf_ipt_act(struct sk_buff *skb,const struct tc_action *a, struct tcf_result *res) { + char saved_cb[sizeof_field(struct sk_buff, cb)];int ret =0 , result =0 ;struct tcf_ipt *ipt =to_ipt (a);struct xt_action_param par;
@@ -280,6 +282,8 @@ TC_INDIRECT_SCOPE int tcf_ipt_act(struct sk_buff *skb, state.out = skb->dev; } +memcpy (saved_cb, skb->cb,sizeof (saved_cb)); +spin_lock (&ipt->tcf_lock);tcf_lastuse_update (&ipt->tcf_tm);
@@ -292,6 +296,9 @@ TC_INDIRECT_SCOPE int tcf_ipt_act(struct sk_buff *skb, par.state = &state; par.target = ipt->tcfi_t->u.kernel.target; par.targinfo = ipt->tcfi_t->data; + +memset (IPCB (skb),0 ,sizeof (struct inet_skb_parm )); + ret = par.target->target (skb, &par);switch (ret) {
@@ -312,6 +319,9 @@ TC_INDIRECT_SCOPE int tcf_ipt_act(struct sk_buff *skb,break ; }spin_unlock (&ipt->tcf_lock); + +memcpy (skb->cb, saved_cb,sizeof (skb->cb)); +return result; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 665/800 spi: spi-geni-qcom: enable SPI_CONTROLLER_MUST_TX for GPI DMA mode
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit d10005837be83906bbd2078c3b4f9dfcbd6c95b6 ]
The GPI DMA mode requires for TX DMA to be prepared. Force SPI core to provide TX buffer even if the caller didn't provide one by setting the SPI_CONTROLLER_MUST_TX flag.
--- drivers/spi/spi-geni-qcom.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-geni-qcom.c +6 -0
@@ -1097,6 +1097,12 @@ static int spi_geni_probe(struct platform_device *pdev)if (mas->cur_xfer_mode ==GENI_SE_FIFO ) spi->set_cs = spi_geni_set_cs; +/* +* TX is required per GSI spec, see setup_gsi_xfer(). +*/ +if (mas->cur_xfer_mode ==GENI_GPI_DMA ) + spi->flags =SPI_CONTROLLER_MUST_TX ; + ret =request_irq (mas->irq, geni_spi_isr,0 ,dev_name (dev), spi);if (ret) goto spi_geni_release_dma;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 666/800 net: mscc: ocelot: dont report that RX timestamping is enabled by default
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 4fd44b82b7aceaa35c2901c6546d2c4198e0799d ]
PTP RX timestamping should be enabled when the user requests it, not by default. If it is enabled by default, it can be problematic when the ocelot driver is a DSA master, and it sidesteps what DSA tries to avoid through __dsa_master_hwtstamp_validate().
Additionally, after the change which made ocelot trap PTP packets only to the CPU at ocelot_hwtstamp_set() time, it is no longer even true that RX timestamping is enabled by default, because until ocelot_hwtstamp_set() is called, the PTP traps are actually not set up. So the rx_filter field of ocelot->hwtstamp_config reflects an incorrect reality.
--- drivers/net/ethernet/mscc/ocelot_ptp.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ethernet/mscc/ocelot_ptp.c +0 -5
@@ -824,11 +824,6 @@ int ocelot_init_timestamp(struct ocelot *ocelot,ocelot_write (ocelot,PTP_CFG_MISC_PTP_EN ,PTP_CFG_MISC ); -/* There is no device reconfiguration, PTP Rx stamping is always -* enabled. -*/ - ocelot->hwtstamp_config.rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT ; -return 0 ; }EXPORT_SYMBOL (ocelot_init_timestamp);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 667/800 net: mscc: ocelot: dont keep PTP configuration of all ports in single structure
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 45d0fcb5bc9558d0bf3d2fa7fabc5d8a88d35439 ]
In a future change, the driver will need to determine whether PTP RX timestamping is enabled on a port (including whether traps were set up on that port in particular) and that is currently not possible.
The driver supports different RX filters (L2, L4) and kinds of TX timestamping (one-step, two-step) on its ports, but it saves all configuration in a single struct hwtstamp_config that is global to the switch. So, the latest timestamping configuration on one port (including a request to disable timestamping) affects what gets reported for all ports, even though the configuration itself is still individual to each port.
The port timestamping configurations are only coupled because of the common structure, so replace the hwtstamp_config with a mask of trapped protocols saved per port. We also have the ptp_cmd to distinguish between one-step and two-step PTP timestamping, so with those 2 bits of information we can fully reconstruct a descriptive struct hwtstamp_config for each port, during the SIOCGHWTSTAMP ioctl.
--- drivers/net/ethernet/mscc/ocelot.c | 1 - drivers/net/ethernet/mscc/ocelot_ptp.c | 61 +++++++++++++++++--------- include/soc/mscc/ocelot.h | 10 +++-- 3 files changed, 48 insertions(+), 24 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +0 -1
@@ -2925,7 +2925,6 @@ int ocelot_init(struct ocelot *ocelot) } } -mutex_init (&ocelot->ptp_lock);mutex_init (&ocelot->mact_lock);mutex_init (&ocelot->fwd_domain_lock);mutex_init (&ocelot->tas_lock);
drivers/net/ethernet/mscc/ocelot_ptp.c +41 -20
101 lines not on this page · raw message
include/soc/mscc/ocelot.h +7 -3
@@ -730,6 +730,11 @@ enum macaccess_entry_type { ENTRYTYPE_MACv6, }; +enum ocelot_proto { +OCELOT_PROTO_PTP_L2 =BIT (0 ), +OCELOT_PROTO_PTP_L4 =BIT (1 ), +}; +#define OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION BIT(0)#define OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP BIT(1)
@@ -775,6 +780,8 @@ struct ocelot_port {unsigned int ptp_skbs_in_flight;struct sk_buff_head tx_skbs; +unsigned int trap_proto; +u16 mrp_ring_id;u8 ptp_cmd;
@@ -868,12 +875,9 @@ struct ocelot { u8 mm_supported:1;struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_info; -struct hwtstamp_config hwtstamp_config;unsigned int ptp_skbs_in_flight;/* Protects the 2-step TX timestamp ID logic */ spinlock_t ts_id_lock; -/* Protects the PTP interface state */ -struct mutex ptp_lock;/* Protects the PTP clock */ spinlock_t ptp_clock_lock;struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM ];
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 668/800 net: dsa: felix: dont drop PTP frames with tag_8021q when RX timestamping is disabled
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 2edcfcbb3c5946609be1d8875473a240b170673b ]
The driver implements a workaround for the fact that it doesn't have an IRQ source to tell it whether PTP frames are available through the extraction registers, for those frames to be processed and passed towards the network stack. That workaround is to configure the switch, through felix_hwtstamp_set() -> felix_update_trapping_destinations(), to create two copies of PTP packets: one sent over Ethernet to the DSA master, and one to be consumed through the aforementioned CPU extraction queue registers.
The reason why we want PTP packets to be consumed through the CPU extraction registers in the first place is because we want to see their hardware RX timestamp. With tag_8021q, that is only visible that way, and it isn't visible with the copy of the packet that's transmitted over Ethernet.
The problem with the workaround implementation is that it drops the packet received over Ethernet, in expectation of its copy being present in the CPU extraction registers. However, if felix_hwtstamp_set() hasn't run (aka PTP RX timestamping is disabled), the driver will drop the original PTP frame and there will be no copy of it in the CPU extraction registers. So, the network stack will simply not see any PTP frame.
Look at the port's trapping configuration to see whether the driver has previously enabled the CPU extraction registers. If it hasn't, just don't RX timestamp the frame and let it be passed up the stack by DSA, which is perfectly fine.
--- drivers/net/dsa/ocelot/felix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/dsa/ocelot/felix.c +12 -0
@@ -1725,6 +1725,18 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port,u32 tstamp_hi;u64 tstamp; +switch (type &PTP_CLASS_PMASK ) { +case PTP_CLASS_L2 : +if (!(ocelot->ports[port]->trap_proto &OCELOT_PROTO_PTP_L2 )) +return false; +break ; +case PTP_CLASS_IPV4 : +case PTP_CLASS_IPV6 : +if (!(ocelot->ports[port]->trap_proto &OCELOT_PROTO_PTP_L4 )) +return false; +break ; + } +/* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb * for RX timestamping. Then free it, and poll for its copy through * MMIO in the CPU port module, and inject that into the stack from
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 669/800 net: dsa: sja1105: always enable the INCL_SRCPT option
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit b4638af8885af93cd70351081da1909c59342440 ]
Link-local traffic on bridged SJA1105 ports is sometimes tagged by the hardware with source port information (when the port is under a VLAN aware bridge).
The tag_8021q source port identification has become more loose ("imprecise") and will report a plausible rather than exact bridge port, when under a bridge (be it VLAN-aware or VLAN-unaware). But link-local traffic always needs to know the precise source port.
Modify the driver logic (and therefore: the tagging protocol itself) to always include the source port information with link-local packets, regardless of whether the port is standalone, under a VLAN-aware or VLAN-unaware bridge. This makes it possible for the tagging driver to give priority to that information over the tag_8021q VLAN header.
The big drawback with INCL_SRCPT is that it makes it impossible to distinguish between an original MAC DA of 01:80:C2:XX:YY:ZZ and 01:80:C2:AA:BB:ZZ, because the tagger just patches MAC DA bytes 3 and 4 with zeroes. Only if PTP RX timestamping is enabled, the switch will generate a META follow-up frame containing the RX timestamp and the original bytes 3 and 4 of the MAC DA. Those will be used to patch up the original packet. Nonetheless, in the absence of PTP RX timestamping, we have to live with this limitation, since it is more important to have the more precise source port information for link-local traffic.
--- drivers/net/dsa/sja1105/sja1105_main.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/dsa/sja1105/sja1105_main.c +2 -7
@@ -866,11 +866,11 @@ static int sja1105_init_general_params(struct sja1105_private *priv) .hostprio = 7, .mac_fltres1 = SJA1105_LINKLOCAL_FILTER_A, .mac_flt1 = SJA1105_LINKLOCAL_FILTER_A_MASK, - .incl_srcpt1 = false, + .incl_srcpt1 = true, .send_meta1 = false, .mac_fltres0 = SJA1105_LINKLOCAL_FILTER_B, .mac_flt0 = SJA1105_LINKLOCAL_FILTER_B_MASK, - .incl_srcpt0 = false, + .incl_srcpt0 = true, .send_meta0 = false,/* Default to an invalid value */ .mirr_port = priv->ds->num_ports,
@@ -2407,11 +2407,6 @@ int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, general_params->tpid = tpid;/* EtherType used to identify outer tagged (S-tag) VLAN traffic */ general_params->tpid2 = tpid2; -/* When VLAN filtering is on, we need to at least be able to -* decode management traffic through the "backup plan". -*/ - general_params->incl_srcpt1 = enabled; - general_params->incl_srcpt0 = enabled;for (port =0 ; port < ds->num_ports; port++) {if (dsa_is_unused_port (ds, port))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 670/800 net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit c1ae02d876898b1b8ca1e12c6f84d7b406263800 ]
Currently the sja1105 tagging protocol prefers using the source port information from the VLAN header if that is available, falling back to the INCL_SRCPT option if it isn't. The VLAN header is available for all frames except for META frames initiated by the switch (containing RX timestamps), and thus, the "if (is_link_local)" branch is practically dead.
The tag_8021q source port identification has become more loose ("imprecise") and will report a plausible rather than exact bridge port, when under a bridge (be it VLAN-aware or VLAN-unaware). But link-local traffic always needs to know the precise source port. With incorrect source port reporting, for example PTP traffic over 2 bridged ports will all be seen on sockets opened on the first such port, which is incorrect.
Now that the tagging protocol has been changed to make link-local frames always contain source port information, we can reverse the order of the checks so that we always give precedence to that information (which is always precise) in lieu of the tag_8021q VID which is only precise for a standalone port.
--- net/dsa/tag_sja1105.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-)
net/dsa/tag_sja1105.c +29 -9
@@ -545,10 +545,7 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, is_link_local =sja1105_is_link_local (skb); is_meta =sja1105_is_meta_frame (skb); -if (sja1105_skb_has_tag_8021q (skb)) { -/* Normal traffic path. */ -sja1105_vlan_rcv (skb, &source_port, &switch_id, &vbid, &vid); - }else if (is_link_local) { +if (is_link_local) {/* Management traffic path. Switch embeds the switch ID and * port ID into bytes of the destination MAC, courtesy of * the incl_srcpt options.
@@ -562,16 +559,39 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb,sja1105_meta_unpack (skb, &meta); source_port = meta.source_port; switch_id = meta.switch_id; - }else { + } + +/* Normal data plane traffic and link-local frames are tagged with +* a tag_8021q VLAN which we have to strip +*/ +if (sja1105_skb_has_tag_8021q (skb)) { +int tmp_source_port =-1 , tmp_switch_id =-1 ; + +sja1105_vlan_rcv (skb, &tmp_source_port, &tmp_switch_id, &vbid, + &vid); +/* Preserve the source information from the INCL_SRCPT option, +* if available. This allows us to not overwrite a valid source +* port and switch ID with zeroes when receiving link-local +* frames from a VLAN-unaware bridged port (non-zero vbid) or a +* VLAN-aware bridged port (non-zero vid). +*/ +if (source_port ==-1 ) + source_port = tmp_source_port; +if (switch_id ==-1 ) + switch_id = tmp_switch_id; + }else if (source_port ==-1 && switch_id ==-1 ) { +/* Packets with no source information have no chance of +* getting accepted, drop them straight away. +*/ return NULL ; } -if (vbid >=1 ) +if (source_port !=-1 && switch_id !=-1 ) + skb->dev =dsa_master_find_slave (netdev, switch_id, source_port); +else if (vbid >=1 ) skb->dev =dsa_tag_8021q_find_port_by_vbid (netdev, vbid); -else if (source_port ==-1 || switch_id ==-1 ) - skb->dev =dsa_find_designated_bridge_port_by_vid (netdev, vid);else - skb->dev =dsa_master_find_slave (netdev, switch_id, source_port); + skb->dev =dsa_find_designated_bridge_port_by_vid (netdev, vid);if (!skb->dev) {netdev_warn (netdev,"Couldn't decode source port\n" );return NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 671/800 Add MODULE_FIRMWARE() for FIRMWARE_TG357766.
In reply to Greg Kroah-HartmanFrom: Tobias Heider <[email protected]>
[ Upstream commit 046f753da6143ee16452966915087ec8b0de3c70 ]
Fixes a bug where on the M1 mac mini initramfs-tools fails to include the necessary firmware into the initrd.
--- drivers/net/ethernet/broadcom/tg3.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/tg3.c +1 -0
@@ -224,6 +224,7 @@ MODULE_AUTHOR("David S. Miller ([email protected]) and Jeff Garzik (jgarzik@poboxMODULE_DESCRIPTION ("Broadcom Tigon3 ethernet driver" );MODULE_LICENSE ("GPL" );MODULE_FIRMWARE (FIRMWARE_TG3 ); +MODULE_FIRMWARE (FIRMWARE_TG357766 );MODULE_FIRMWARE (FIRMWARE_TG3TSO );MODULE_FIRMWARE (FIRMWARE_TG3TSO5 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 672/800 Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 0cb7365850bacb8c2a9975cae672d65714d8daa1 ]
Devices that lack persistent storage for the device address can indicate this by setting the HCI_QUIRK_INVALID_BDADDR which causes the controller to be marked as unconfigured until user space has set a valid address.
Once configured, the device address must be set on every setup for controllers with HCI_QUIRK_NON_PERSISTENT_SETUP to avoid marking the controller as unconfigured and requiring the address to be set again.
--- net/bluetooth/hci_sync.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
net/bluetooth/hci_sync.c +11 -17
@@ -4626,23 +4626,17 @@ static int hci_dev_setup_sync(struct hci_dev *hdev) invalid_bdaddr =test_bit (HCI_QUIRK_INVALID_BDADDR , &hdev->quirks);if (!ret) { -if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) { -if (!bacmp (&hdev->public_addr,BDADDR_ANY )) -hci_dev_get_bd_addr_from_property (hdev); - -if (bacmp (&hdev->public_addr,BDADDR_ANY ) && - hdev->set_bdaddr) { - ret = hdev->set_bdaddr (hdev, - &hdev->public_addr); - -/* If setting of the BD_ADDR from the device -* property succeeds, then treat the address -* as valid even if the invalid BD_ADDR -* quirk indicates otherwise. -*/ -if (!ret) - invalid_bdaddr = false; - } +if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks) && + !bacmp (&hdev->public_addr,BDADDR_ANY )) +hci_dev_get_bd_addr_from_property (hdev); + +if ((invalid_bdaddr || +test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) && +bacmp (&hdev->public_addr,BDADDR_ANY ) && + hdev->set_bdaddr) { + ret = hdev->set_bdaddr (hdev, &hdev->public_addr); +if (!ret) + invalid_bdaddr = false; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 673/800 Bluetooth: ISO: use hci_sync for setting CIG parameters
In reply to Greg Kroah-HartmanFrom: Pauli Virtanen <[email protected]>
[ Upstream commit 6b9545dc9f8ff01d8bc1229103960d9cd265343f ]
When reconfiguring CIG after disconnection of the last CIS, LE Remove CIG shall be sent before LE Set CIG Parameters. Otherwise, it fails because CIG is in the inactive state and not configurable (Core v5.3 Vol 6 Part B Sec. 4.5.14.3). This ordering is currently wrong under suitable timing conditions, because LE Remove CIG is sent via the hci_sync queue and may be delayed, but Set CIG Parameters is via hci_send_cmd.
Make the ordering well-defined by sending also Set CIG Parameters via hci_sync.
--- net/bluetooth/hci_conn.c | 47 +++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-)
net/bluetooth/hci_conn.c +39 -8
@@ -775,6 +775,11 @@ static void le_conn_timeout(struct work_struct *work)hci_abort_conn (conn,HCI_ERROR_REMOTE_USER_TERM ); } +struct iso_cig_params { +struct hci_cp_le_set_cig_params cp; +struct hci_cis_params cis[0x1f ]; +}; + struct iso_list_data { union { u8 cig;
@@ -786,10 +791,7 @@ struct iso_list_data {u16 sync_handle; };int count; -struct { -struct hci_cp_le_set_cig_params cp; -struct hci_cis_params cis[0x11 ]; - } pdu; +struct iso_cig_params pdu; };static void bis_list (struct hci_conn *conn,void *data)
@@ -1764,10 +1766,33 @@ static int hci_le_create_big(struct hci_conn *conn, struct bt_iso_qos *qos)return hci_send_cmd (hdev,HCI_OP_LE_CREATE_BIG ,sizeof (cp), &cp); } +static void set_cig_params_complete (struct hci_dev *hdev,void *data,int err) +{ +struct iso_cig_params *pdu = data; + +bt_dev_dbg (hdev,"" ); + +if (err) +bt_dev_err (hdev,"Unable to set CIG parameters: %d" , err); + +kfree (pdu); +} + +static int set_cig_params_sync (struct hci_dev *hdev,void *data) +{ +struct iso_cig_params *pdu = data; +u32 plen; + + plen =sizeof (pdu->cp) + pdu->cp.num_cis *sizeof (pdu->cis[0 ]); +return __hci_cmd_sync_status (hdev,HCI_OP_LE_SET_CIG_PARAMS , plen, pdu, +HCI_CMD_TIMEOUT ); +} +static bool hci_le_set_cig_params (struct hci_conn *conn,struct bt_iso_qos *qos) {struct hci_dev *hdev = conn->hdev;struct iso_list_data data; +struct iso_cig_params *pdu;memset (&data,0 ,sizeof (data));
@@ -1837,12 +1862,18 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos)if (qos->ucast.cis ==BT_ISO_QOS_CIS_UNSET || !data.pdu.cp.num_cis)return false; -if (hci_send_cmd (hdev,HCI_OP_LE_SET_CIG_PARAMS , -sizeof (data.pdu.cp) + - (data.pdu.cp.num_cis *sizeof (*data.pdu.cis)), - &data.pdu) <0 ) + pdu =kzalloc (sizeof (*pdu),GFP_KERNEL ); +if (!pdu)return false; +memcpy (pdu, &data.pdu,sizeof (*pdu)); + +if (hci_cmd_sync_queue (hdev, set_cig_params_sync, pdu, + set_cig_params_complete) <0 ) { +kfree (pdu); +return false; + } +return true; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 674/800 Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 73f55453ea5236a586a7f1b3d5e2ee051d655351 ]
When receiving a scan response there is no way to know if the remote device is connectable or not, so when it cannot be merged don't make any assumption and instead just mark it with a new flag defined as MGMT_DEV_FOUND_SCAN_RSP so userspace can tell it is a standalone SCAN_RSP.
--- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/hci_event.c | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-)
include/net/bluetooth/mgmt.h +1 -0
@@ -979,6 +979,7 @@ struct mgmt_ev_auth_failed {#define MGMT_DEV_FOUND_NOT_CONNECTABLE BIT(2)#define MGMT_DEV_FOUND_INITIATED_CONN BIT(3)#define MGMT_DEV_FOUND_NAME_REQUEST_FAILED BIT(4) +#define MGMT_DEV_FOUND_SCAN_RSP BIT(5)#define MGMT_EV_DEVICE_FOUND 0x0012struct mgmt_ev_device_found {
net/bluetooth/hci_event.c +5 -10
@@ -6316,23 +6316,18 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,return ; } -/* When receiving non-connectable or scannable undirected -* advertising reports, this means that the remote device is -* not connectable and then clearly indicate this in the -* device found event. -* -* When receiving a scan response, then there is no way to +/* When receiving a scan response, then there is no way to * know if the remote device is connectable or not. However * since scan responses are merged with a previously seen * advertising report, the flags field from that report * will be used. * -* In the really unlikely case that a controller get confused -* and just sends a scan response event, then it is marked as -* not connectable as well. +* In the unlikely case that a controller just sends a scan +* response event that doesn't match the pending report, then +* it is marked as a standalone SCAN_RSP. */ if (type ==LE_ADV_SCAN_RSP ) - flags =MGMT_DEV_FOUND_NOT_CONNECTABLE ; + flags =MGMT_DEV_FOUND_SCAN_RSP ;/* If there's nothing pending either store the data from this * event or send an immediate device found event if the data
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 675/800 sfc: support for devlink port requires MAE access
In reply to Greg Kroah-HartmanFrom: Martin Habets <[email protected]>
[ Upstream commit 915057ae79692d47f9fb3504785855be49abaea4 ]
On systems without MAE permission efx->mae is not initialised, and trying to lookup an mport results in a NULL pointer dereference.
--- drivers/net/ethernet/sfc/efx_devlink.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/sfc/efx_devlink.c +3 -0
@@ -622,6 +622,9 @@ static struct devlink_port *ef100_set_devlink_port(struct efx_nic *efx, u32 idx)u32 id;int rc; +if (!efx->mae) +return NULL ; +if (efx_mae_lookup_mport (efx, idx, &id)) {/* This should not happen. */ if (idx ==MAE_MPORT_DESC_VF_IDX_NULL )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 676/800 ibmvnic: Do not reset dql stats on NON_FATAL err
In reply to Greg Kroah-HartmanFrom: Nick Child <[email protected]>
[ Upstream commit 48538ccb825b05544ec308a509e2cc9c013402db ]
All ibmvnic resets, make a call to netdev_tx_reset_queue() when re-opening the device. netdev_tx_reset_queue() resets the num_queued and num_completed byte counters. These stats are used in Byte Queue Limit (BQL) algorithms. The difference between these two stats tracks the number of bytes currently sitting on the physical NIC. ibmvnic increases the number of queued bytes though calls to netdev_tx_sent_queue() in the drivers xmit function. When, VIOS reports that it is done transmitting bytes, the ibmvnic device increases the number of completed bytes through calls to netdev_tx_completed_queue(). It is important to note that the driver batches its transmit calls and num_queued is increased every time that an skb is added to the next batch, not necessarily when the batch is sent to VIOS for transmission.
Unlike other reset types, a NON FATAL reset will not flush the sub crq tx buffers. Therefore, it is possible for the batched skb array to be partially full. So if there is call to netdev_tx_reset_queue() when re-opening the device, the value of num_queued (0) would not account for the skb's that are currently batched. Eventually, when the batch is sent to VIOS, the call to netdev_tx_completed_queue() would increase num_completed to a value greater than the num_queued. This causes a BUG_ON crash:
ibmvnic 30000002: Firmware reports error, cause: adapter problem. Starting recovery...
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
------------[ cut here ]------------ kernel BUG at lib/dynamic_queue_limits.c:27! Oops: Exception in kernel mode, sig: 5 [....] NIP dql_completed+0x28/0x1c0 LR ibmvnic_complete_tx.isra.0+0x23c/0x420 [ibmvnic] Call Trace: ibmvnic_complete_tx.isra.0+0x3f8/0x420 [ibmvnic] (unreliable) ibmvnic_interrupt_tx+0x40/0x70 [ibmvnic] __handle_irq_event_percpu+0x98/0x270 ---[ end trace ]---
Therefore, do not reset the dql stats when performing a NON_FATAL reset.
--- drivers/net/ethernet/ibm/ibmvnic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +8 -1
@@ -1816,7 +1816,14 @@ static int __ibmvnic_open(struct net_device *netdev)if (prev_state ==VNIC_CLOSED )enable_irq (adapter->tx_scrq[i]->irq);enable_scrq_irq (adapter, adapter->tx_scrq[i]); -netdev_tx_reset_queue (netdev_get_tx_queue (netdev, i)); +/* netdev_tx_reset_queue will reset dql stats. During NON_FATAL +* resets, don't reset the stats because there could be batched +* skb's waiting to be sent. If we reset dql stats, we risk +* num_completed being greater than num_queued. This will cause +* a BUG_ON in dql_completed(). +*/ +if (adapter->reset_reason !=VNIC_RESET_NON_FATAL ) +netdev_tx_reset_queue (netdev_get_tx_queue (netdev, i)); } rc =set_link_state (adapter,IBMVNIC_LOGICAL_LNK_UP );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 677/800 net: dsa: vsc73xx: fix MTU configuration
In reply to Greg Kroah-HartmanFrom: Pawel Dembicki <[email protected]>
[ Upstream commit 3cf62c8177adb0db9e15c8b898c44f997acf3ebf ]
Switch in MAXLEN register stores the maximum size of a data frame. The MTU size is 18 bytes smaller than the frame size.
The current settings are causing problems with packet forwarding. This patch fixes the MTU settings to proper values.
--- drivers/net/dsa/vitesse-vsc73xx-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dsa/vitesse-vsc73xx-core.c +3 -3
@@ -1025,17 +1025,17 @@ static int vsc73xx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)struct vsc73xx *vsc = ds->priv;return vsc73xx_write (vsc,VSC73XX_BLOCK_MAC , port, -VSC73XX_MAXLEN , new_mtu); +VSC73XX_MAXLEN , new_mtu +ETH_HLEN +ETH_FCS_LEN ); }/* According to application not "VSC7398 Jumbo Frames" setting -* up the MTU to 9.6 KB does not affect the performance on standard +* up the frame size to 9.6 KB does not affect the performance on standard * frames. It is clear from the application note that * "9.6 kilobytes" == 9600 bytes. */ static int vsc73xx_get_max_mtu (struct dsa_switch *ds,int port) { -return 9600 ; +return 9600 -ETH_HLEN -ETH_FCS_LEN ; }static const struct dsa_switch_ops vsc73xx_ds_ops = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 678/800 mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 08fc75735fda3be97194bfbf3c899c87abb3d0fe ]
The line cards array is not freed in the error path of mlxsw_m_linecards_init(), which can lead to a memory leak. Fix by freeing the array in the error path, thereby making the error path identical to mlxsw_m_linecards_fini().
--- drivers/net/ethernet/mellanox/mlxsw/minimal.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlxsw/minimal.c +1 -0
@@ -417,6 +417,7 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m) err_kmalloc_array:for (i--; i >=0 ; i--)kfree (mlxsw_m->line_cards[i]); +kfree (mlxsw_m->line_cards); err_kcalloc:kfree (mlxsw_m->ports);return err;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 679/800 spi: bcm-qspi: return error if neither hif_mspi nor mspi is available
In reply to Greg Kroah-HartmanFrom: Jonas Gorski <[email protected]>
[ Upstream commit 7c1f23ad34fcdace50275a6aa1e1969b41c6233f ]
If neither a "hif_mspi" nor "mspi" resource is present, the driver will just early exit in probe but still return success. Apart from not doing anything meaningful, this would then also lead to a null pointer access on removal, as platform_get_drvdata() would return NULL, which it would then try to dereference when trying to unregister the spi master.
Fix this by unconditionally calling devm_ioremap_resource(), as it can handle a NULL res and will then return a viable ERR_PTR() if we get one.
The "return 0;" was previously a "goto qspi_resource_err;" where then ret was returned, but since ret was still initialized to 0 at this place this was a valid conversion in 63c5395bb7a9 ("spi: bcm-qspi: Fix use-after-free on unbind"). The issue was not introduced by this commit, only made more obvious.
--- drivers/spi/spi-bcm-qspi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/spi/spi-bcm-qspi.c +3 -7
@@ -1543,13 +1543,9 @@ int bcm_qspi_probe(struct platform_device *pdev, res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"mspi" ); -if (res) { - qspi->base[MSPI ] =devm_ioremap_resource (dev, res); -if (IS_ERR (qspi->base[MSPI ])) -return PTR_ERR (qspi->base[MSPI ]); - }else { -return 0 ; - } + qspi->base[MSPI ] =devm_ioremap_resource (dev, res); +if (IS_ERR (qspi->base[MSPI ])) +return PTR_ERR (qspi->base[MSPI ]); res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"bspi" );if (res) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 680/800 drm/amdgpu: fix number of fence calculations
In reply to Greg Kroah-HartmanFrom: Christian König <[email protected]>
[ Upstream commit 570b295248b00c3cf4cf59e397de5cb2361e10c2 ]
Since adding gang submit we need to take the gang size into account while reserving fences.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -5
@@ -133,9 +133,6 @@ static int amdgpu_cs_p1_user_fence(struct amdgpu_cs_parser *p, bo =amdgpu_bo_ref (gem_to_amdgpu_bo (gobj)); p->uf_entry.priority =0 ; p->uf_entry.tv.bo = &bo->tbo; -/* One for TTM and two for the CS job */ - p->uf_entry.tv.num_shared =3 ; -drm_gem_object_put (gobj); size =amdgpu_bo_size (bo);
@@ -882,15 +879,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,mutex_lock (&p->bo_list->bo_list_mutex); -/* One for TTM and one for the CS job */ +/* One for TTM and one for each CS job */ amdgpu_bo_list_for_each_entry (e, p->bo_list) - e->tv.num_shared =2 ; + e->tv.num_shared =1 + p->gang_size; + p->uf_entry.tv.num_shared =1 + p->gang_size;amdgpu_bo_list_get_list (p->bo_list, &p->validated);INIT_LIST_HEAD (&duplicates);amdgpu_vm_get_pd_bo (&fpriv->vm, &p->validated, &p->vm_pd); +/* Two for VM updates, one for TTM and one for each CS job */ + p->vm_pd.tv.num_shared =3 + p->gang_size; +if (p->uf_entry.tv.bo && !ttm_to_amdgpu_bo (p->uf_entry.tv.bo)->parent)list_add (&p->uf_entry.tv.head, &p->validated);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 681/800 drm/amd: Dont try to enable secure display TA multiple times
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
[ Upstream commit 5c6d52ff4b61e5267b25be714eb5a9ba2a338199 ]
If the securedisplay TA failed to load the first time, it's unlikely to work again after a suspend/resume cycle or reset cycle and it appears to be causing problems in futher attempts.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -0
@@ -1947,6 +1947,8 @@ static int psp_securedisplay_initialize(struct psp_context *psp)psp_securedisplay_parse_resp_status (psp, securedisplay_cmd->status);dev_err (psp->adev->dev,"SECUREDISPLAY: query securedisplay TA failed. ret 0x%x\n" , securedisplay_cmd->securedisplay_out_message.query_ta.query_cmd_ret); +/* don't try again */ + psp->securedisplay_context.context.bin_desc.size_bytes =0 ; }return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 682/800 mailbox: ti-msgmgr: Fill non-message tx data fields with 0x0
In reply to Greg Kroah-HartmanFrom: Nishanth Menon <[email protected]>
[ Upstream commit 1b712f18c461bd75f018033a15cf381e712806b5 ]
Sec proxy/message manager data buffer is 60 bytes with the last of the registers indicating transmission completion. This however poses a bit of a challenge.
The backing memory for sec_proxy / message manager is regular memory, and all sec proxy does is to trigger a burst of all 60 bytes of data over to the target thread backing ring accelerator. It doesn't do a memory scrub when it moves data out in the burst. When we transmit multiple messages, remnants of previous message is also transmitted which results in some random data being set in TISCI fields of messages that have been expanded forward.
The entire concept of backward compatibility hinges on the fact that the unused message fields remain 0x0 allowing for 0x0 value to be specially considered when backward compatibility of message extension is done.
So, instead of just writing the completion register, we continue to fill the message buffer up with 0x0 (note: for partial message involving completion, we already do this).
This allows us to scale and introduce ABI changes back also work with other boot stages that may have left data in the internal memory.
While at this, be consistent and explicit with the data_reg pointer increment.
--- drivers/mailbox/ti-msgmgr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mailbox/ti-msgmgr.c +9 -3
@@ -430,14 +430,20 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data)/* Ensure all unused data is 0 */ data_trail &=0xFFFFFFFF >> (8 * (sizeof (u32) - trail_bytes));writel (data_trail, data_reg); - data_reg++; + data_reg +=sizeof (u32); } +/* * 'data_reg' indicates next register to write. If we did not already * write on tx complete reg(last reg), we must do so for transmit +* In addition, we also need to make sure all intermediate data +* registers(if any required), are reset to 0 for TISCI backward +* compatibility to be maintained. */ -if (data_reg <= qinst->queue_buff_end) -writel (0 , qinst->queue_buff_end); +while (data_reg <= qinst->queue_buff_end) { +writel (0 , data_reg); + data_reg +=sizeof (u32); + }/* If we are in polled mode, wait for a response before proceeding */ if (ti_msgmgr_chan_has_polled_queue_rx (message->chan_rx))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 683/800 f2fs: fix error path handling in truncate_dnode()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 0135c482fa97e2fd8245cb462784112a00ed1211 ]
If truncate_node() fails in truncate_dnode(), it missed to call f2fs_put_page(), fix it.
--- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/node.c +3 -1
@@ -943,8 +943,10 @@ static int truncate_dnode(struct dnode_of_data *dn) dn->ofs_in_node =0 ;f2fs_truncate_data_blocks (dn); err =truncate_node (dn); -if (err) +if (err) { +f2fs_put_page (page,1 );return err; + }return 1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 684/800 octeontx2-af: cn10kb: fix interrupt csr addresses
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 4c5a331cacda995e995a7857f0e44e8937d98d2c ]
The current design is that, for asynchronous events like link_up and link_down firmware raises the interrupt to kernel. The previous patch which added RPM_USX driver has a bug where it uses old csr addresses for configuring interrupts. Which is resulting in losing interrupts from source firmware.
This patch fixes the issue by correcting csr addresses.
--- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 2 +- drivers/net/ethernet/marvell/octeontx2/af/rpm.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +1 -1
@@ -47,7 +47,7 @@ static struct mac_ops rpm2_mac_ops = { .int_set_reg = RPM2_CMRX_SW_INT_ENA_W1S, .irq_offset = 1, .int_ena_bit = BIT_ULL(0), - .lmac_fwi = RPM_LMAC_FWI, + .lmac_fwi = RPM2_LMAC_FWI, .non_contiguous_serdes_lane = true, .rx_stats_cnt = 43, .tx_stats_cnt = 34,
drivers/net/ethernet/marvell/octeontx2/af/rpm.h +2 -1
@@ -94,7 +94,8 @@/* CN10KB CSR Declaration */ #define RPM2_CMRX_SW_INT 0x1b0 -#define RPM2_CMRX_SW_INT_ENA_W1S 0x1b8 +#define RPM2_CMRX_SW_INT_ENA_W1S 0x1c8 +#define RPM2_LMAC_FWI 0x12#define RPM2_CMR_CHAN_MSK_OR 0x3120#define RPM2_CMR_RX_OVR_BP_EN BIT_ULL(2)#define RPM2_CMR_RX_OVR_BP_BP BIT_ULL(1)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 685/800 octeontx2-af: Fix mapping for NIX block from CGX connection
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 2e7bc57b976bb016c6569a54d95c1b8d88f9450a ]
Firmware configures NIX block mapping for all MAC blocks. The current implementation reads the configuration and creates the mapping between RVU PF and NIX blocks. But this configuration is only valid for silicons that support multiple blocks. For all other silicons, all MAC blocks map to NIX0.
This patch corrects the mapping by adding a check for the same.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 11 +++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +11 -0
@@ -23,6 +23,7 @@#define PCI_DEVID_OCTEONTX2_LBK 0xA061/* Subsystem Device ID */ +#define PCI_SUBSYS_DEVID_98XX 0xB100#define PCI_SUBSYS_DEVID_96XX 0xB200#define PCI_SUBSYS_DEVID_CN10K_A 0xB900#define PCI_SUBSYS_DEVID_CNF10K_B 0xBC00
@@ -669,6 +670,16 @@ static inline u16 rvu_nix_chan_cpt(struct rvu *rvu, u8 chan)return rvu->hw->cpt_chan_base + chan; } +static inline bool is_rvu_supports_nix1 (struct rvu *rvu) +{ +struct pci_dev *pdev = rvu->pdev; + +if (pdev->subsystem_device ==PCI_SUBSYS_DEVID_98XX ) +return true; + +return false; +} +/* Function Prototypes * RVU */
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +1 -1
@@ -114,7 +114,7 @@ static void rvu_map_cgx_nix_block(struct rvu *rvu, int pf, p2x =cgx_lmac_get_p2x (cgx_id, lmac_id);/* Firmware sets P2X_SELECT as either NIX0 or NIX1 */ pfvf->nix_blkaddr =BLKADDR_NIX0 ; -if (p2x ==CMR_P2X_SEL_NIX1 ) +if (is_rvu_supports_nix1 (rvu) && p2x ==CMR_P2X_SEL_NIX1 ) pfvf->nix_blkaddr =BLKADDR_NIX1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 686/800 octeontx2-af: Add validation before accessing cgx and lmac
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 79ebb53772c95d3a6ae51b3c65f9985fdd430df6 ]
with the addition of new MAC blocks like CN10K RPM and CN10KB RPM_USX, LMACs are noncontiguous and CGX blocks are also noncontiguous. But during RVU driver initialization, the driver is assuming they are contiguous and trying to access cgx or lmac with their id which is resulting in kernel panic.
This patch fixes the issue by adding proper checks.
[ 23.219150] pc : cgx_lmac_read+0x38/0x70 [ 23.219154] lr : rvu_program_channels+0x3f0/0x498 [ 23.223852] sp : ffff000100d6fc80 [ 23.227158] x29: ffff000100d6fc80 x28: ffff00010009f880 x27: 000000000000005a [ 23.234288] x26: ffff000102586768 x25: 0000000000002500 x24:
fffffffffff0f000
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +7 -0
@@ -169,6 +169,9 @@ void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val) {struct cgx *cgx_dev =cgx_get_pdata (cgx_id); +/* Software must not access disabled LMAC registers */ +if (!is_lmac_valid (cgx_dev, lmac_id)) +return ;cgx_write (cgx_dev, lmac_id, offset, val); }
@@ -176,6 +179,10 @@ u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset) {struct cgx *cgx_dev =cgx_get_pdata (cgx_id); +/* Software must not access disabled LMAC registers */ +if (!is_lmac_valid (cgx_dev, lmac_id)) +return 0 ; +return cgx_read (cgx_dev, lmac_id, offset); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 687/800 octeontx2-af: Reset MAC features in FLR
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 2e3e94c2f5dc98a8a0e93850407064bc5389c306 ]
AF driver configures MAC features like internal loopback and PFC upon receiving the request from PF and its VF netdev. But these features are not getting reset in FLR. This patch fixes the issue by resetting the same.
--- .../net/ethernet/marvell/octeontx2/af/cgx.c | 26 ++++++++++++++-- .../net/ethernet/marvell/octeontx2/af/cgx.h | 2 ++ .../marvell/octeontx2/af/lmac_common.h | 3 ++ .../net/ethernet/marvell/octeontx2/af/rpm.c | 30 +++++++++++++++++-- .../net/ethernet/marvell/octeontx2/af/rpm.h | 2 ++ .../net/ethernet/marvell/octeontx2/af/rvu.c | 1 + .../net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 18 +++++++++++ 8 files changed, 77 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +23 -3
@@ -537,14 +537,15 @@ static u32 cgx_get_lmac_fifo_len(void *cgxd, int lmac_id)int cgx_lmac_internal_loopback (void *cgxd,int lmac_id,bool enable) {struct cgx *cgx = cgxd; -u8 lmac_type; +struct lmac *lmac;u64 cfg;if (!is_lmac_valid (cgx, lmac_id))return -ENODEV ; - lmac_type = cgx->mac_ops->get_lmac_type (cgx, lmac_id); -if (lmac_type ==LMAC_MODE_SGMII || lmac_type ==LMAC_MODE_QSGMII ) { + lmac =lmac_pdata (lmac_id, cgx); +if (lmac->lmac_type ==LMAC_MODE_SGMII || + lmac->lmac_type ==LMAC_MODE_QSGMII ) { cfg =cgx_read (cgx, lmac_id,CGXX_GMP_PCS_MRX_CTL );if (enable) cfg |=CGXX_GMP_PCS_MRX_CTL_LBK ;
@@ -1563,6 +1564,23 @@ int cgx_lmac_linkup_start(void *cgxd)return 0 ; } +int cgx_lmac_reset (void *cgxd,int lmac_id,u8 pf_req_flr) +{ +struct cgx *cgx = cgxd; +u64 cfg; + +if (!is_lmac_valid (cgx, lmac_id)) +return -ENODEV ; + +/* Resetting PFC related CSRs */ + cfg =0xff ; +cgx_write (cgxd, lmac_id,CGXX_CMRX_RX_LOGL_XON , cfg); + +if (pf_req_flr) +cgx_lmac_internal_loopback (cgxd, lmac_id, false); +return 0 ; +} +static int cgx_configure_interrupt (struct cgx *cgx,struct lmac *lmac,int cnt,bool req_free) {
@@ -1682,6 +1700,7 @@ static int cgx_lmac_init(struct cgx *cgx) cgx->lmac_idmap[lmac->lmac_id] = lmac;set_bit (lmac->lmac_id, &cgx->lmac_bmap); cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, true); + lmac->lmac_type = cgx->mac_ops->get_lmac_type (cgx, lmac->lmac_id); }return cgx_lmac_verify_fwi_version (cgx);
@@ -1778,6 +1797,7 @@ static struct mac_ops cgx_mac_ops = { .mac_tx_enable = cgx_lmac_tx_enable, .pfc_config = cgx_lmac_pfc_config, .mac_get_pfc_frm_cfg = cgx_lmac_get_pfc_frm_cfg, + .mac_reset = cgx_lmac_reset, };static int cgx_probe (struct pci_dev *pdev,const struct pci_device_id *id)
drivers/net/ethernet/marvell/octeontx2/af/cgx.h +2 -0
@@ -35,6 +35,7 @@#define CGXX_CMRX_INT_ENA_W1S 0x058#define CGXX_CMRX_RX_ID_MAP 0x060#define CGXX_CMRX_RX_STAT0 0x070 +#define CGXX_CMRX_RX_LOGL_XON 0x100#define CGXX_CMRX_RX_LMACS 0x128#define CGXX_CMRX_RX_DMAC_CTL0 (0x1F8 + mac_ops->csr_offset)#define CGX_DMAC_CTL0_CAM_ENABLE BIT_ULL(3)
@@ -181,4 +182,5 @@ int cgx_lmac_get_pfc_frm_cfg(void *cgxd, int lmac_id, u8 *tx_pause, u8 *rx_pause);int verify_lmac_fc_cfg (void *cgxd,int lmac_id,u8 tx_pause,u8 rx_pause,int pfvf_idx); +int cgx_lmac_reset (void *cgxd,int lmac_id,u8 pf_req_flr);#endif /* CGX_H */
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h +3 -0
@@ -24,6 +24,7 @@* @cgx: parent cgx port * @mcast_filters_count: Number of multicast filters installed * @lmac_id: lmac port id +* @lmac_type: lmac type like SGMII/XAUI * @cmd_pend: flag set before new command is started * flag cleared after command response is received * @name: lmac port name
@@ -43,6 +44,7 @@ struct lmac {struct cgx *cgx;u8 mcast_filters_count;u8 lmac_id; +u8 lmac_type;bool cmd_pend;char *name; };
@@ -125,6 +127,7 @@ struct mac_ops {int (*mac_get_pfc_frm_cfg)(void *cgxd,int lmac_id,u8 *tx_pause,u8 *rx_pause); +int (*mac_reset)(void *cgxd,int lmac_id,u8 pf_req_flr);/* FEC stats */ int (*get_fec_stats)(void *cgxd, int lmac_id,
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +27 -3
@@ -37,6 +37,7 @@ static struct mac_ops rpm_mac_ops = { .mac_tx_enable = rpm_lmac_tx_enable, .pfc_config = rpm_lmac_pfc_config, .mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg, + .mac_reset = rpm_lmac_reset, };static struct mac_ops rpm2_mac_ops = {
@@ -68,6 +69,7 @@ static struct mac_ops rpm2_mac_ops = { .mac_tx_enable = rpm_lmac_tx_enable, .pfc_config = rpm_lmac_pfc_config, .mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg, + .mac_reset = rpm_lmac_reset, };bool is_dev_rpm2 (void *rpmd)
@@ -537,14 +539,15 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)int rpm_lmac_internal_loopback (void *rpmd,int lmac_id,bool enable) {rpm_t *rpm = rpmd; -u8 lmac_type; +struct lmac *lmac;u64 cfg;if (!is_lmac_valid (rpm, lmac_id))return -ENODEV ; - lmac_type = rpm->mac_ops->get_lmac_type (rpm, lmac_id); -if (lmac_type ==LMAC_MODE_QSGMII || lmac_type ==LMAC_MODE_SGMII ) { + lmac =lmac_pdata (lmac_id, rpm); +if (lmac->lmac_type ==LMAC_MODE_QSGMII || + lmac->lmac_type ==LMAC_MODE_SGMII ) {dev_err (&rpm->pdev->dev,"loopback not supported for LPC mode\n" );return 0 ; }
@@ -713,3 +716,24 @@ int rpm_get_fec_stats(void *rpmd, int lmac_id, struct cgx_fec_stats_rsp *rsp)return 0 ; } + +int rpm_lmac_reset (void *rpmd,int lmac_id,u8 pf_req_flr) +{ +u64 rx_logl_xon, cfg; +rpm_t *rpm = rpmd; + +if (!is_lmac_valid (rpm, lmac_id)) +return -ENODEV ; + +/* Resetting PFC related CSRs */ + rx_logl_xon =is_dev_rpm2 (rpm) ?RPM2_CMRX_RX_LOGL_XON : +RPMX_CMRX_RX_LOGL_XON ; + cfg =0xff ; + +rpm_write (rpm, lmac_id, rx_logl_xon, cfg); + +if (pf_req_flr) +rpm_lmac_internal_loopback (rpm, lmac_id, false); + +return 0 ; +}
drivers/net/ethernet/marvell/octeontx2/af/rpm.h +2 -0
@@ -74,6 +74,7 @@#define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA 0x80A8#define RPMX_MTI_MAC100X_CL89_PAUSE_QUANTA 0x8108#define RPM_DEFAULT_PAUSE_TIME 0x7FF +#define RPMX_CMRX_RX_LOGL_XON 0x4100#define RPMX_MTI_MAC100X_XIF_MODE 0x8100#define RPMX_ONESTEP_ENABLE BIT_ULL(5)
@@ -132,4 +133,5 @@ int rpm_lmac_get_pfc_frm_cfg(void *rpmd, int lmac_id, u8 *tx_pause,int rpm2_get_nr_lmacs (void *rpmd);bool is_dev_rpm2 (void *rpmd);int rpm_get_fec_stats (void *cgxd,int lmac_id,struct cgx_fec_stats_rsp *rsp); +int rpm_lmac_reset (void *rpmd,int lmac_id,u8 pf_req_flr);#endif /* RPM_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +1 -0
@@ -2629,6 +2629,7 @@ static void __rvu_flr_handler(struct rvu *rvu, u16 pcifunc)* Since LF is detached use LF number as -1. */ rvu_npc_free_mcam_entries (rvu, pcifunc,-1 ); +rvu_mac_reset (rvu, pcifunc);mutex_unlock (&rvu->flr_lock); }
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
@@ -875,6 +875,7 @@ int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable);int rvu_cgx_prio_flow_ctrl_cfg (struct rvu *rvu,u16 pcifunc,u8 tx_pause,u8 rx_pause,u16 pfc_en);int rvu_cgx_cfg_pause_frm (struct rvu *rvu,u16 pcifunc,u8 tx_pause,u8 rx_pause); +void rvu_mac_reset (struct rvu *rvu,u16 pcifunc);u32 rvu_cgx_get_lmac_fifolen (struct rvu *rvu,int cgx,int lmac);int npc_get_nixlf_mcam_index (struct npc_mcam *mcam,u16 pcifunc,int nixlf,int type);
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +18 -0
@@ -1250,3 +1250,21 @@ int rvu_mbox_handler_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, mac_ops->mac_get_pfc_frm_cfg (cgxd, lmac_id, &rsp->tx_pause, &rsp->rx_pause);return err; } + +void rvu_mac_reset (struct rvu *rvu,u16 pcifunc) +{ +int pf =rvu_get_pf (pcifunc); +struct mac_ops *mac_ops; +struct cgx *cgxd; +u8 cgx, lmac; + +if (!is_pf_cgxmapped (rvu, pf)) +return ; + +rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx, &lmac); + cgxd =rvu_cgx_pdata (cgx, rvu); + mac_ops =get_mac_ops (cgxd); + +if (mac_ops->mac_reset (cgxd, lmac, !is_vf (pcifunc))) +dev_err (rvu->dev,"Failed to reset MAC\n" ); +}
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 688/800 ntfs: Fix panic about slab-out-of-bounds caused by ntfs_listxattr()
In reply to Greg Kroah-HartmanFrom: Zeng Heng <[email protected]>
[ Upstream commit 3c675ddffb17a8b1e32efad5c983254af18b12c2 ]
Here is a BUG report from syzbot:
BUG: KASAN: slab-out-of-bounds in ntfs_list_ea fs/ntfs3/xattr.c:191 [inline] BUG: KASAN: slab-out-of-bounds in ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710 Read of size 1 at addr ffff888021acaf3d by task syz-executor128/3632 Call Trace: ntfs_list_ea fs/ntfs3/xattr.c:191 [inline] ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710 vfs_listxattr fs/xattr.c:457 [inline] listxattr+0x293/0x2d0 fs/xattr.c:804
Fix the logic of ea_all iteration. When the ea->name_len is 0, return immediately, or Add2Ptr() would visit invalid memory in the next loop.
--- fs/ntfs3/xattr.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/xattr.c +3 -0
@@ -214,6 +214,9 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer, ea =Add2Ptr (ea_all, off); ea_size =unpacked_ea_size (ea); +if (!ea->name_len) +break ; +if (buffer) {if (ret + ea->name_len +1 > bytes_per_buffer) { err = -ERANGE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 689/800 powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 39f49684036d24af800ff194c33c7b2653c591d7 ]
In a randconfig with CONFIG_SERIAL_CPM=m and CONFIG_PPC_EARLY_DEBUG_CPM=y, there is a build error:
ERROR: modpost: "udbg_putc" [drivers/tty/serial/cpm_uart/cpm_uart.ko] undefined!
Prevent the build error by allowing PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y.
--- arch/powerpc/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig.debug +1 -1
@@ -240,7 +240,7 @@ config PPC_EARLY_DEBUG_40x config PPC_EARLY_DEBUG_CPM bool "Early serial debugging for Freescale CPM-based serial ports" - depends on SERIAL_CPM + depends on SERIAL_CPM=y help Select this to enable early debugging for Freescale chips using a CPM-based serial port. This assumes that the bootwrapper
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 690/800 powerpc: dts: turris1x.dts: Fix PCIe MEM size for pci2 node
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit abaa02fc944f2f9f2c2e1925ddaceaf35c48528c ]
Freescale PCIe controllers on their PCIe Root Ports do not have any mappable PCI BAR allocate from PCIe MEM.
Information about 1MB window on BAR0 of PCIe Root Port was misleading because Freescale PCIe controllers have at BAR0 position different register PEXCSRBAR, and kernel correctly skipts BAR0 for these Freescale PCIe Root Ports.
So update comment about P2020 PCIe Root Port and decrease PCIe MEM size required for PCIe controller (pci2 node) on which is on-board xHCI controller.
lspci confirms that on P2020 PCIe Root Port is no PCI BAR and /proc/iomem sees that only c0000000-c000ffff and c0010000-c0011fff ranges are used.
--- arch/powerpc/boot/dts/turris1x.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/boot/dts/turris1x.dts +3 -3
@@ -476,12 +476,12 @@ pci2: pcie@ffe08000 { * channel 1 (but only USB 2.0 subset) to USB 2.0 pins on mPCIe * slot 1 (CN5), channels 2 and 3 to connector P600. * - * P2020 PCIe Root Port uses 1MB of PCIe MEM and xHCI controller + * P2020 PCIe Root Port does not use PCIe MEM and xHCI controller * uses 64kB + 8kB of PCIe MEM. No PCIe IO is used or required. - * So allocate 2MB of PCIe MEM for this PCIe bus. + * So allocate 128kB of PCIe MEM for this PCIe bus. */ reg = <0 0xffe08000 0 0x1000>; - ranges = <0x02000000 0x0 0xc0000000 0 0xc0000000 0x0 0x00200000>, /* MEM */ + ranges = <0x02000000 0x0 0xc0000000 0 0xc0000000 0x0 0x00020000>, /* MEM */ <0x01000000 0x0 0x00000000 0 0xffc20000 0x0 0x00010000>; /* IO */ pcie@0 {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 691/800 net: bridge: keep ports without IFF_UNICAST_FLT in BR_PROMISC mode
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 6ca3c005d0604e8d2b439366e3923ea58db99641 ]
According to the synchronization rules for .ndo_get_stats() as seen in Documentation/networking/netdevices.rst, acquiring a plain spin_lock() should not be illegal, but the bridge driver implementation makes it so.
After running these commands, I am being faced with the following lockdep splat:
$ ip link add link swp0 name macsec0 type macsec encrypt on && ip link set swp0 up $ ip link add dev br0 type bridge vlan_filtering 1 && ip link set br0 up $ ip link set macsec0 master br0 && ip link set macsec0 up
========================================================
WARNING: possible irq lock inversion dependency detected 6.4.0-04295-g31b577b4bd4a #603 Not tainted
--------------------------------------------------------
swapper/1/0 just changed the state of lock:
ffff6bd348724cd8 (&br->lock){+.-.}-{3:3}, at: br_forward_delay_timer_expired+0x34/0x198 but this lock took another, SOFTIRQ-unsafe lock in the past:
(&ocelot->stats_lock){+.+.}-{3:3}
and interrupts could create inverse lock ordering between them.
other info that might help us debug this:
Chain exists of:
&br->lock --> &br->hash_lock --> &ocelot->stats_lockPossible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&ocelot->stats_lock);
local_irq_disable();
lock(&br->lock);
lock(&br->hash_lock);
<Interrupt>
lock(&br->lock);*** DEADLOCK ***
(details about the 3 locks skipped)
swp0 is instantiated by drivers/net/dsa/ocelot/felix.c, and this only matters to the extent that its .ndo_get_stats64() method calls spin_lock(&ocelot->stats_lock).
Documentation/locking/lockdep-design.rst says:
| A lock is irq-safe means it was ever used in an irq context, while a lock | is irq-unsafe means it was ever acquired with irq enabled.
(...)
| Furthermore, the following usage based lock dependencies are not allowed | between any two lock-classes:: | | <hardirq-safe> -> <hardirq-unsafe> | <softirq-safe> -> <softirq-unsafe>
Lockdep marks br->hash_lock as softirq-safe, because it is sometimes taken in softirq context (for example br_fdb_update() which runs in NET_RX softirq), and when it's not in softirq context it blocks softirqs by using spin_lock_bh().
Lockdep marks ocelot->stats_lock as softirq-unsafe, because it never blocks softirqs from running, and it is never taken from softirq context. So it can always be interrupted by softirqs.
There is a call path through which a function that holds br->hash_lock:fdb_add_hw_addr() will call a function that acquires ocelot->stats_lock:ocelot_port_get_stats64(). This can be seen below:
ocelot_port_get_stats64+0x3c/0x1e0 felix_get_stats64+0x20/0x38 dsa_slave_get_stats64+0x3c/0x60 dev_get_stats+0x74/0x2c8 rtnl_fill_stats+0x4c/0x150 rtnl_fill_ifinfo+0x5cc/0x7b8 rtmsg_ifinfo_build_skb+0xe4/0x150 rtmsg_ifinfo+0x5c/0xb0 __dev_notify_flags+0x58/0x200 __dev_set_promiscuity+0xa0/0x1f8 dev_set_promiscuity+0x30/0x70 macsec_dev_change_rx_flags+0x68/0x88 __dev_set_promiscuity+0x1a8/0x1f8 __dev_set_rx_mode+0x74/0xa8 dev_uc_add+0x74/0xa0 fdb_add_hw_addr+0x68/0xd8 fdb_add_local+0xc4/0x110 br_fdb_add_local+0x54/0x88 br_add_if+0x338/0x4a0 br_add_slave+0x20/0x38 do_setlink+0x3a4/0xcb8 rtnl_newlink+0x758/0x9d0 rtnetlink_rcv_msg+0x2f0/0x550 netlink_rcv_skb+0x128/0x148 rtnetlink_rcv+0x24/0x38
the plain English explanation for it is:
The macsec0 bridge port is created without p->flags & BR_PROMISC, because it is what br_manage_promisc() decides for a VLAN filtering bridge with a single auto port.
As part of the br_add_if() procedure, br_fdb_add_local() is called for the MAC address of the device, and this results in a call to dev_uc_add() for macsec0 while the softirq-safe br->hash_lock is taken.
Because macsec0 does not have IFF_UNICAST_FLT, dev_uc_add() ends up calling __dev_set_promiscuity() for macsec0, which is propagated by its implementation, macsec_dev_change_rx_flags(), to the lower device: swp0. This triggers the call path:
dev_set_promiscuity(swp0)
-> rtmsg_ifinfo()
-> dev_get_stats()
-> ocelot_port_get_stats64()
with a calling context that lockdep doesn't like (br->hash_lock held).
Normally we don't see this, because even though many drivers that can be bridge ports don't support IFF_UNICAST_FLT, we need a driver that
(a) doesn't support IFF_UNICAST_FLT, *and*
(b) it forwards the IFF_PROMISC flag to another driver, and
(c) *that* driver implements ndo_get_stats64() using a softirq-unsafe spinlock.
Condition (b) is necessary because the first __dev_set_rx_mode() calls __dev_set_promiscuity() with "bool notify=false", and thus, the rtmsg_ifinfo() code path won't be entered.
The same criteria also hold true for DSA switches which don't report IFF_UNICAST_FLT. When the DSA master uses a spin_lock() in its ndo_get_stats64() method, the same lockdep splat can be seen.
I think the deadlock possibility is real, even though I didn't reproduce it, and I'm thinking of the following situation to support that claim:
fdb_add_hw_addr() runs on a CPU A, in a context with softirqs locally disabled and br->hash_lock held, and may end up attempting to acquire ocelot->stats_lock.
In parallel, ocelot->stats_lock is currently held by a thread B (say, ocelot_check_stats_work()), which is interrupted while holding it by a softirq which attempts to lock br->hash_lock.
Thread B cannot make progress because br->hash_lock is held by A. Whereas thread A cannot make progress because ocelot->stats_lock is held by B.
When taking the issue at face value, the bridge can avoid that problem by simply making the ports promiscuous from a code path with a saner calling context (br->hash_lock not held). A bridge port without IFF_UNICAST_FLT is going to become promiscuous as soon as we call dev_uc_add() on it (which we do unconditionally), so why not be preemptive and make it promiscuous right from the beginning, so as to not be taken by surprise.
With this, we've broken the links between code that holds br->hash_lock or br->lock and code that calls into the ndo_change_rx_flags() or ndo_get_stats64() ops of the bridge port.
--- net/bridge/br_if.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/bridge/br_if.c +3 -2
@@ -166,8 +166,9 @@ void br_manage_promisc(struct net_bridge *br)* This lets us disable promiscuous mode and write * this config to hw. */ -if (br->auto_cnt ==0 || - (br->auto_cnt ==1 &&br_auto_port (p))) +if ((p->dev->priv_flags &IFF_UNICAST_FLT ) && + (br->auto_cnt ==0 || + (br->auto_cnt ==1 &&br_auto_port (p))))br_port_clear_promisc (p);else br_port_set_promisc (p);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 692/800 net: dsa: tag_sja1105: fix source port decoding in vlan_filtering=0 bridge mode
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit a398b9ea0c3b791b7a0f4c6029a62cf628f97f22 ]
There was a regression introduced by the blamed commit, where pinging to a VLAN-unaware bridge would fail with the repeated message "Couldn't decode source port" coming from the tagging protocol driver.
When receiving packets with a bridge_vid as determined by dsa_tag_8021q_bridge_join(), dsa_8021q_rcv() will decode:
- source_port = 0 (which isn't really valid, more like "don't know")
- switch_id = 0 (which isn't really valid, more like "don't know")
- vbid = value in range 1-7
Since the blamed patch has reversed the order of the checks, we are now going to believe that source_port != -1 and switch_id != -1, so they're valid, but they aren't.
The minimal solution to the problem is to only populate source_port and switch_id with what dsa_8021q_rcv() came up with, if the vbid is zero, i.e. the source port information is trustworthy.
--- net/dsa/tag_sja1105.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/dsa/tag_sja1105.c +6 -3
@@ -573,11 +573,14 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb,* if available. This allows us to not overwrite a valid source * port and switch ID with zeroes when receiving link-local * frames from a VLAN-unaware bridged port (non-zero vbid) or a -* VLAN-aware bridged port (non-zero vid). +* VLAN-aware bridged port (non-zero vid). Furthermore, the +* tag_8021q source port information is only of trust when the +* vbid is 0 (precise port). Otherwise, tmp_source_port and +* tmp_switch_id will be zeroes. */ -if (source_port ==-1 ) +if (vbid ==0 && source_port ==-1 ) source_port = tmp_source_port; -if (switch_id ==-1 ) +if (vbid ==0 && switch_id ==-1 ) switch_id = tmp_switch_id; }else if (source_port ==-1 && switch_id ==-1 ) {/* Packets with no source information have no chance of
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 693/800 net: fix net_dev_start_xmit trace event vs skb_transport_offset()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit f88fcb1d7d961b4b402d675109726f94db87571c ]
After blamed commit, we must be more careful about using skb_transport_offset(), as reminded us by syzbot:
WARNING: CPU: 0 PID: 10 at include/linux/skbuff.h:2868 skb_transport_offset include/linux/skbuff.h:2977 [inline] WARNING: CPU: 0 PID: 10 at include/linux/skbuff.h:2868 perf_trace_net_dev_start_xmit+0x89a/0xce0 include/trace/events/net.h:14 Modules linked in: CPU: 0 PID: 10 Comm: kworker/u4:1 Not tainted 6.1.30-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023 Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet RIP: 0010:skb_transport_header include/linux/skbuff.h:2868 [inline] RIP: 0010:skb_transport_offset include/linux/skbuff.h:2977 [inline] RIP: 0010:perf_trace_net_dev_start_xmit+0x89a/0xce0 include/trace/events/net.h:14 Code: 8b 04 25 28 00 00 00 48 3b 84 24 c0 00 00 00 0f 85 4e 04 00 00 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc e8 56 22 01 fd <0f> 0b e9 f6 fc ff ff 89 f9 80 e1 07 80 c1 03 38 c1 0f 8c 86 f9 ff RSP: 0018:ffffc900002bf700 EFLAGS: 00010293 RAX: ffffffff8485d8ca RBX: 000000000000ffff RCX: ffff888100914280 RDX: 0000000000000000 RSI: 000000000000ffff RDI: 000000000000ffff RBP: ffffc900002bf818 R08: ffffffff8485d5b6 R09: fffffbfff0f8fb5e R10: 0000000000000000 R11: dffffc0000000001 R12: 1ffff110217d8f67 R13: ffff88810bec7b3a R14: dffffc0000000000 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8881f6a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f96cf6d52f0 CR3: 000000012224c000 CR4: 0000000000350ef0 Call Trace: <TASK> [<ffffffff84715e35>] trace_net_dev_start_xmit include/trace/events/net.h:14 [inline] [<ffffffff84715e35>] xmit_one net/core/dev.c:3643 [inline] [<ffffffff84715e35>] dev_hard_start_xmit+0x705/0x980 net/core/dev.c:3660 [<ffffffff8471a232>] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324 [<ffffffff85416493>] dev_queue_xmit include/linux/netdevice.h:3030 [inline] [<ffffffff85416493>] batadv_send_skb_packet+0x3f3/0x680 net/batman-adv/send.c:108 [<ffffffff85416744>] batadv_send_broadcast_skb+0x24/0x30 net/batman-adv/send.c:127 [<ffffffff853bc52a>] batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:393 [inline] [<ffffffff853bc52a>] batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:421 [inline] [<ffffffff853bc52a>] batadv_iv_send_outstanding_bat_ogm_packet+0x69a/0x840 net/batman-adv/bat_iv_ogm.c:1701 [<ffffffff8151023c>] process_one_work+0x8ac/0x1170 kernel/workqueue.c:2289 [<ffffffff81511938>] worker_thread+0xaa8/0x12d0 kernel/workqueue.c:2436
--- include/trace/events/net.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/trace/events/net.h +2 -1
@@ -51,7 +51,8 @@ TRACE_EVENT(net_dev_start_xmit, __entry->network_offset =skb_network_offset (skb); __entry->transport_offset_valid =skb_transport_header_was_set (skb); - __entry->transport_offset =skb_transport_offset (skb); + __entry->transport_offset =skb_transport_header_was_set (skb) ? +skb_transport_offset (skb) :0 ; __entry->tx_flags =skb_shinfo (skb)->tx_flags; __entry->gso_size =skb_shinfo (skb)->gso_size; __entry->gso_segs =skb_shinfo (skb)->gso_segs;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 694/800 tcp: annotate data races in __tcp_oow_rate_limited()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 998127cdb4699b9d470a9348ffe9f1154346be5f ]
request sockets are lockless, __tcp_oow_rate_limited() could be called on the same object from different cpus. This is harmless.
Add READ_ONCE()/WRITE_ONCE() annotations to avoid a KCSAN report.
--- net/ipv4/tcp_input.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/ipv4/tcp_input.c +9 -3
@@ -3590,8 +3590,11 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32static bool __tcp_oow_rate_limited (struct net *net,int mib_idx,u32 *last_oow_ack_time) { -if (*last_oow_ack_time) { -s32 elapsed = (s32)(tcp_jiffies32 - *last_oow_ack_time); +/* Paired with the WRITE_ONCE() in this function. */ +u32 val =READ_ONCE (*last_oow_ack_time); + +if (val) { +s32 elapsed = (s32)(tcp_jiffies32 - val);if (0 <= elapsed && elapsed <READ_ONCE (net->ipv4.sysctl_tcp_invalid_ratelimit)) {
@@ -3600,7 +3603,10 @@ static bool __tcp_oow_rate_limited(struct net *net, int mib_idx, } } - *last_oow_ack_time = tcp_jiffies32; +/* Paired with the prior READ_ONCE() and with itself, +* as we might be lockless. +*/ +WRITE_ONCE (*last_oow_ack_time, tcp_jiffies32);return false;/* not rate-limited: go ahead, send dupack now! */ }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 695/800 vduse: fix NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Maxime Coquelin <[email protected]>
[ Upstream commit f06cf1e1a503169280467d12d2ec89bf2c30ace7 ]
vduse_vdpa_set_vq_affinity callback can be called with NULL value as cpu_mask when deleting the vduse device.
This patch resets virtqueue's IRQ affinity mask value to set all CPUs instead of dereferencing NULL cpu_mask.
[ 4760.952149] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 4760.959110] #PF: supervisor read access in kernel mode [ 4760.964247] #PF: error_code(0x0000) - not-present page [ 4760.969385] PGD 0 P4D 0 [ 4760.971927] Oops: 0000 [#1] PREEMPT SMP PTI [ 4760.976112] CPU: 13 PID: 2346 Comm: vdpa Not tainted 6.4.0-rc6+ #4 [ 4760.982291] Hardware name: Dell Inc. PowerEdge R640/0W23H8, BIOS 2.8.1 06/26/2020 [ 4760.989769] RIP: 0010:memcpy_orig+0xc5/0x130 [ 4760.994049] Code: 16 f8 4c 89 07 4c 89 4f 08 4c 89 54 17 f0 4c 89 5c 17 f8 c3 cc cc cc cc 66 66 2e 0f 1f 84 00 00 00 00 00 66 90 83 fa 08 72 1b <4c> 8b 06 4c 8b 4c 16 f8 4c 89 07 4c 89 4c 17 f8 c3 cc cc cc cc 66 [ 4761.012793] RSP: 0018:ffffb1d565abb830 EFLAGS: 00010246 [ 4761.018020] RAX: ffff9f4bf6b27898 RBX: ffff9f4be23969c0 RCX: ffff9f4bcadf6400 [ 4761.025152] RDX: 0000000000000008 RSI: 0000000000000000 RDI: ffff9f4bf6b27898 [ 4761.032286] RBP: 0000000000000000 R08: 0000000000000008 R09: 0000000000000000 [ 4761.039416] R10: 0000000000000000 R11: 0000000000000600 R12: 0000000000000000 [ 4761.046549] R13: 0000000000000000 R14: 0000000000000080 R15: ffffb1d565abbb10 [ 4761.053680] FS: 00007f64c2ec2740(0000) GS:ffff9f635f980000(0000) knlGS:0000000000000000 [ 4761.061765] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4761.067513] CR2: 0000000000000000 CR3: 0000001875270006 CR4: 00000000007706e0 [ 4761.074645] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 4761.081775] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 4761.088909] PKRU: 55555554 [ 4761.091620] Call Trace: [ 4761.094074] <TASK> [ 4761.096180] ? __die+0x1f/0x70 [ 4761.099238] ? page_fault_oops+0x171/0x4f0 [ 4761.103340] ? exc_page_fault+0x7b/0x180 [ 4761.107265] ? asm_exc_page_fault+0x22/0x30 [ 4761.111460] ? memcpy_orig+0xc5/0x130 [ 4761.115126] vduse_vdpa_set_vq_affinity+0x3e/0x50 [vduse] [ 4761.120533] virtnet_clean_affinity.part.0+0x3d/0x90 [virtio_net] [ 4761.126635] remove_vq_common+0x1a4/0x250 [virtio_net] [ 4761.131781] virtnet_remove+0x5d/0x70 [virtio_net] [ 4761.136580] virtio_dev_remove+0x3a/0x90 [ 4761.140509] device_release_driver_internal+0x19b/0x200 [ 4761.145742] bus_remove_device+0xc2/0x130 [ 4761.149755] device_del+0x158/0x3e0 [ 4761.153245] ? kernfs_find_ns+0x35/0xc0 [ 4761.157086] device_unregister+0x13/0x60 [ 4761.161010] unregister_virtio_device+0x11/0x20 [ 4761.165543] device_release_driver_internal+0x19b/0x200 [ 4761.170770] bus_remove_device+0xc2/0x130 [ 4761.174782] device_del+0x158/0x3e0 [ 4761.178276] ? __pfx_vdpa_name_match+0x10/0x10 [vdpa] [ 4761.183336] device_unregister+0x13/0x60 [ 4761.187260] vdpa_nl_cmd_dev_del_set_doit+0x63/0xe0 [vdpa]
Message-Id: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_user/vduse_dev.c +5 -1
@@ -726,7 +726,11 @@ static int vduse_vdpa_set_vq_affinity(struct vdpa_device *vdpa, u16 idx, {struct vduse_dev *dev =vdpa_to_vduse (vdpa); -cpumask_copy (&dev->vqs[idx]->irq_affinity, cpu_mask); +if (cpu_mask) +cpumask_copy (&dev->vqs[idx]->irq_affinity, cpu_mask); +else +cpumask_setall (&dev->vqs[idx]->irq_affinity); +return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 696/800 bpf, btf: Warn but return no error for NULL btf from __register_btf_kfunc_id_set()
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
[ Upstream commit 3de4d22cc9ac7c9f38e10edcf54f9a8891a9c2aa ]
__register_btf_kfunc_id_set() assumes .BTF to be part of the module's .ko file if CONFIG_DEBUG_INFO_BTF is enabled. If that's not the case, the function prints an error message and return an error. As a result, such modules cannot be loaded.
However, the section could be stripped out during a build process. It would be better to let the modules loaded, because their basic functionalities have no problem [0], though the BTF functionalities will not be supported. Make the function to lower the level of the message from error to warn, and return no error.
[0] https://lore.kernel.org/bpf/[email protected]
--- kernel/bpf/btf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/bpf/btf.c +2 -4
@@ -7848,10 +7848,8 @@ static int __register_btf_kfunc_id_set(enum btf_kfunc_hook hook,pr_err ("missing vmlinux BTF, cannot register kfuncs\n" );return -ENOENT ; } -if (kset->owner &&IS_ENABLED (CONFIG_DEBUG_INFO_BTF_MODULES )) { -pr_err ("missing module BTF, cannot register kfuncs\n" ); -return -ENOENT ; - } +if (kset->owner &&IS_ENABLED (CONFIG_DEBUG_INFO_BTF_MODULES )) +pr_warn ("missing module BTF, cannot register kfuncs\n" );return 0 ; }if (IS_ERR (btf))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 697/800 xsk: Honor SO_BINDTODEVICE on bind
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit f7306acec9aae9893d15e745c8791124d42ab10a ]
Initial creation of an AF_XDP socket requires CAP_NET_RAW capability. A privileged process might create the socket and pass it to a non-privileged process for later use. However, that process will be able to bind the socket to any network interface. Even though it will not be able to receive any traffic without modification of the BPF map, the situation is not ideal.
Sockets already have a mechanism that can be used to restrict what interface they can be attached to. That is SO_BINDTODEVICE.
To change the SO_BINDTODEVICE binding the process will need CAP_NET_RAW.
Make xsk_bind() honor the SO_BINDTODEVICE in order to allow safer workflow when non-privileged process is using AF_XDP.
The intended workflow is following:
1. First process creates a bare socket with socket(AF_XDP, ...).
2. First process loads the XSK program to the interface.
3. First process adds the socket fd to a BPF map.
4. First process ties socket fd to a particular interface using SO_BINDTODEVICE.
5. First process sends socket fd to a second process.
6. Second process allocates UMEM.
7. Second process binds socket to the interface with bind(...).
8. Second process sends/receives the traffic.
All the steps above are possible today if the first process is privileged and the second one has sufficient RLIMIT_MEMLOCK and no capabilities. However, the second process will be able to bind the socket to any interface it wants on step 7 and send traffic from it. With the proposed change, the second process will be able to bind the socket only to a specific interface chosen by the first process at step 4.
--- Documentation/networking/af_xdp.rst | 9 +++++++++ net/xdp/xsk.c | 5 +++++ 2 files changed, 14 insertions(+)
Documentation/networking/af_xdp.rst +9 -0
@@ -433,6 +433,15 @@ start N bytes into the buffer leaving the first N bytes for the application to use. The final option is the flags field, but it will be dealt with in separate sections for each UMEM flag. +SO_BINDTODEVICE setsockopt +-------------------------- + +This is a generic SOL_SOCKET option that can be used to tie AF_XDP +socket to a particular network interface. It is useful when a socket +is created by a privileged process and passed to a non-privileged one. +Once the option is set, kernel will refuse attempts to bind that socket +to a different interface. Updating the value requires CAP_NET_RAW. + XDP_STATISTICS getsockopt -------------------------
net/xdp/xsk.c +5 -0
@@ -886,6 +886,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)struct sock *sk = sock->sk;struct xdp_sock *xs =xdp_sk (sk);struct net_device *dev; +int bound_dev_if;u32 flags, qid;int err =0 ;
@@ -899,6 +900,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) XDP_USE_NEED_WAKEUP))return -EINVAL ; + bound_dev_if =READ_ONCE (sk->sk_bound_dev_if); +if (bound_dev_if && bound_dev_if != sxdp->sxdp_ifindex) +return -EINVAL ; +rtnl_lock ();mutex_lock (&xs->mutex);if (xs->state !=XSK_READY ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 698/800 net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
[ Upstream commit 30c45b5361d39b4b793780ffac5538090b9e2eb1 ]
The attribute TCA_PEDIT_PARMS_EX is not be included in pedit_policy and one malicious user could fake a TCA_PEDIT_PARMS_EX whose length is smaller than the intended sizeof(struct tc_pedit). Hence, the dereference in tcf_pedit_init() could access dirty heap data.
static int tcf_pedit_init(...)
{
// ...
pattr = tb[TCA_PEDIT_PARMS]; // TCA_PEDIT_PARMS is included if (!pattr)
pattr = tb[TCA_PEDIT_PARMS_EX]; // but this is not
// ... parm = nla_data(pattr);
index = parm->index; // parm is able to be smaller than 4 bytes
// and this dereference gets dirty skb_buff
// data created in netlink_sendmsg
}This commit adds TCA_PEDIT_PARMS_EX length in pedit_policy which avoid the above case, just like the TCA_PEDIT_PARMS.
--- net/sched/act_pedit.c | 1 + 1 file changed, 1 insertion(+)
net/sched/act_pedit.c +1 -0
@@ -29,6 +29,7 @@ static struct tc_action_ops act_pedit_ops;static const struct nla_policy pedit_policy[TCA_PEDIT_MAX +1 ] = { [TCA_PEDIT_PARMS ] = { .len =sizeof (struct tc_pedit ) }, + [TCA_PEDIT_PARMS_EX ] = { .len =sizeof (struct tc_pedit ) }, [TCA_PEDIT_KEYS_EX ] = { .type =NLA_NESTED }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 699/800 drm/i915/psr: Fix BDW PSR AUX CH data register offsets
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
[ Upstream commit fdffb7dbc74f48cb1d404d9ab0c9fd769a59caf0 ]
The multiplication got replaced by an addition in some cleanup. This means we never write the correct data to some of the BDW PSR data registers and thus we fail to actually wake up the panel from PSR.
--- drivers/gpu/drm/i915/display/intel_psr_regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_psr_regs.h +1 -1
@@ -75,7 +75,7 @@#define _SRD_AUX_DATA_A 0x60814#define _SRD_AUX_DATA_EDP 0x6f814 -#define EDP_PSR_AUX_DATA (tran, i) _MMIO_TRANS2(tran, _SRD_AUX_DATA_A + (i) + 4)/* 5 registers */ +#define EDP_PSR_AUX_DATA (tran, i) _MMIO_TRANS2(tran, _SRD_AUX_DATA_A + (i) * 4)/* 5 registers */ #define _SRD_STATUS_A 0x60840#define _SRD_STATUS_EDP 0x6f840
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 700/800 fanotify: disallow mount/sb marks on kernel internal pseudo fs
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
[ Upstream commit 69562eb0bd3e6bb8e522a7b254334e0fb30dff0c ]
Hopefully, nobody is trying to abuse mount/sb marks for watching all anonymous pipes/inodes.
I cannot think of a good reason to allow this - it looks like an oversight that dated back to the original fanotify API.
Message-Id: <[email protected]>
--- fs/notify/fanotify/fanotify_user.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/notify/fanotify/fanotify_user.c +14 -0
@@ -1623,6 +1623,20 @@ static int fanotify_events_supported(struct fsnotify_group *group, path->mnt->mnt_sb->s_type->fs_flags & FS_DISALLOW_NOTIFY_PERM)return -EINVAL ; +/* +* mount and sb marks are not allowed on kernel internal pseudo fs, +* like pipe_mnt, because that would subscribe to events on all the +* anonynous pipes in the system. +* +* SB_NOUSER covers all of the internal pseudo fs whose objects are not +* exposed to user's mount namespace, but there are other SB_KERNMOUNT +* fs, like nsfs, debugfs, for which the value of allowing sb and mount +* mark is questionable. For now we leave them alone. +*/ +if (mark_type !=FAN_MARK_INODE && + path->mnt->mnt_sb->s_flags &SB_NOUSER ) +return -EINVAL ; +/* * We shouldn't have allowed setting dirent events and the directory * flags FAN_ONDIR and FAN_EVENT_ON_CHILD in mask of non-dir inode,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 701/800 riscv: move memblock_allow_resize() after linear mapping is ready
In reply to Greg Kroah-HartmanFrom: Woody Zhang <[email protected]>
[ Upstream commit 85fadc0d04119c2fe4a20287767ab904c6d21ba1 ]
The initial memblock metadata is accessed from kernel image mapping. The regions arrays need to "reallocated" from memblock and accessed through linear mapping to cover more memblock regions. So the resizing should not be allowed until linear mapping is ready. Note that there are memblock allocations when building linear mapping.
This patch is similar to 24cc61d8cb5a ("arm64: memblock: don't permit memblock resizing until linear mapping is up").
In following log, many memblock regions are reserved before create_linear_mapping_page_table(). And then it triggered reallocation of memblock.reserved.regions and memcpy the old array in kernel image mapping to the new array in linear mapping which caused a page fault.
[ 0.000000] memblock_reserve: [0x00000000bf01f000-0x00000000bf01ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf021000-0x00000000bf021fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf023000-0x00000000bf023fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf025000-0x00000000bf025fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf027000-0x00000000bf027fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf029000-0x00000000bf029fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02b000-0x00000000bf02bfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02d000-0x00000000bf02dfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02f000-0x00000000bf02ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf030000-0x00000000bf030fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] OF: reserved mem: 0x0000000080000000..0x000000008007ffff (512 KiB) map non-reusable mmode_resv0@80000000 [ 0.000000] memblock_reserve: [0x00000000bf000000-0x00000000bf001fed] paging_init+0x19a/0x5ae [ 0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c [ 0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128 [ 0.000000] memblock: reserved is doubled to 256 at [0x000000017fffd000-0x000000017fffe7ff] [ 0.000000] Unable to handle kernel paging request at virtual address ff600000ffffd000 [ 0.000000] Oops [#1] [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.4.0-rc1-00011-g99a670b2069c #66 [ 0.000000] Hardware name: riscv-virtio,qemu (DT) [ 0.000000] epc : __memcpy+0x60/0xf8 [ 0.000000] ra : memblock_double_array+0x192/0x248 [ 0.000000] epc : ffffffff8081d214 ra : ffffffff80a3dfc0 sp : ffffffff81403bd0 [ 0.000000] gp : ffffffff814fbb38 tp : ffffffff8140dac0 t0 : 0000000001600000 [ 0.000000] t1 : 0000000000000000 t2 : 000000008f001000 s0 : ffffffff81403c60 [ 0.000000] s1 : ffffffff80c0bc98 a0 : ff600000ffffd000 a1 : ffffffff80c0bcd8 [ 0.000000] a2 : 0000000000000c00 a3 : ffffffff80c0c8d8 a4 : 0000000080000000 [ 0.000000] a5 : 0000000000080000 a6 : 0000000000000000 a7 : 0000000080200000 [ 0.000000] s2 : ff600000ffffd000 s3 : 0000000000002000 s4 : 0000000000000c00 [ 0.000000] s5 : ffffffff80c0bc60 s6 : ffffffff80c0bcc8 s7 : 0000000000000000 [ 0.000000] s8 : ffffffff814fd0a8 s9 : 000000017fffe7ff s10: 0000000000000000 [ 0.000000] s11: 0000000000001000 t3 : 0000000000001000 t4 : 0000000000000000 [ 0.000000] t5 : 000000008f003000 t6 : ff600000ffffd000 [ 0.000000] status: 0000000200000100 badaddr: ff600000ffffd000 cause: 000000000000000f [ 0.000000] [<ffffffff8081d214>] __memcpy+0x60/0xf8 [ 0.000000] [<ffffffff80a3e1a2>] memblock_add_range.isra.14+0x12c/0x162 [ 0.000000] [<ffffffff80a3e36a>] memblock_reserve+0x6e/0x8c [ 0.000000] [<ffffffff80a123fc>] memblock_alloc_range_nid+0xb8/0x128 [ 0.000000] [<ffffffff80a1256a>] memblock_phys_alloc_range+0x5e/0x6a [ 0.000000] [<ffffffff80a04732>] alloc_pmd_fixmap+0x14/0x1c [ 0.000000] [<ffffffff80a0475a>] alloc_p4d_fixmap+0xc/0x14 [ 0.000000] [<ffffffff80a04a36>] create_pgd_mapping+0x98/0x17c [ 0.000000] [<ffffffff80a04e9e>] create_linear_mapping_range.constprop.10+0xe4/0x112 [ 0.000000] [<ffffffff80a05bb8>] paging_init+0x3ec/0x5ae [ 0.000000] [<ffffffff80a03354>] setup_arch+0xb2/0x576 [ 0.000000] [<ffffffff80a00726>] start_kernel+0x72/0x57e [ 0.000000] Code: b303 0285 b383 0305 be03 0385 be83 0405 bf03 0485 (b023) 00ef [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! [ 0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
--- arch/riscv/mm/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/mm/init.c +3 -1
@@ -267,7 +267,6 @@ static void __init setup_bootmem(void)dma_contiguous_reserve (dma32_phys_limit);if (IS_ENABLED (CONFIG_64BIT ))hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT ); -memblock_allow_resize (); }#ifdef CONFIG_MMU
@@ -1370,6 +1369,9 @@ void __init paging_init(void) {setup_bootmem ();setup_vm_final (); + +/* Depend on that Linear Mapping is ready */ +memblock_allow_resize (); }void __init misc_mem_init (void )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 702/800 pptp: Fix fib lookup calls.
In reply to Greg Kroah-HartmanFrom: Guillaume Nault <[email protected]>
[ Upstream commit 84bef5b6037c15180ef88ac4216dc621d16df1a6 ]
PPTP uses pppox sockets (struct pppox_sock). These sockets don't embed an inet_sock structure, so it's invalid to call inet_sk() on them.
Therefore, the ip_route_output_ports() call in pptp_connect() has two problems:
* The tos variable is set with RT_CONN_FLAGS(sk), which calls inet_sk() on the pppox socket.
* ip_route_output_ports() tries to retrieve routing flags using inet_sk_flowi_flags(), which is also going to call inet_sk() on the pppox socket.
While PPTP doesn't use inet sockets, it's actually really layered on top of IP and therefore needs a proper way to do fib lookups. So let's define pptp_route_output() to get a struct rtable from a pptp socket. Let's also replace the ip_route_output_ports() call of pptp_xmit() for consistency.
In practice, this means that:
* pptp_connect() sets ->flowi4_tos and ->flowi4_flags to zero instead of using bits of unrelated struct pppox_sock fields.
* pptp_xmit() now respects ->sk_mark and ->sk_uid.
* pptp_xmit() now calls the security_sk_classify_flow() security
hook, thus allowing to set ->flowic_secid.
* pptp_xmit() now passes the pppox socket to xfrm_lookup_route().
Found by code inspection.
--- drivers/net/ppp/pptp.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/net/ppp/pptp.c +20 -11
@@ -24,6 +24,7 @@#include <linux/in.h> #include <linux/ip.h> #include <linux/rcupdate.h> +#include <linux/security.h> #include <linux/spinlock.h> #include <net/sock.h>
@@ -128,6 +129,23 @@ static void del_chan(struct pppox_sock *sock)spin_unlock (&chan_lock); } +static struct rtable *pptp_route_output (struct pppox_sock *po, +struct flowi4 *fl4) +{ +struct sock *sk = &po->sk; +struct net *net; + + net =sock_net (sk); +flowi4_init_output (fl4, sk->sk_bound_dev_if, sk->sk_mark,0 , +RT_SCOPE_UNIVERSE ,IPPROTO_GRE ,0 , + po->proto.pptp.dst_addr.sin_addr.s_addr, + po->proto.pptp.src_addr.sin_addr.s_addr, +0 ,0 ,sock_net_uid (net, sk)); +security_sk_classify_flow (sk,flowi4_to_flowi_common (fl4)); + +return ip_route_output_flow (net, fl4, sk); +} +static int pptp_xmit (struct ppp_channel *chan,struct sk_buff *skb) {struct sock *sk = (struct sock *) chan->private;
@@ -151,11 +169,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)if (sk_pppox (po)->sk_state &PPPOX_DEAD ) goto tx_error; - rt =ip_route_output_ports (net, &fl4,NULL , - opt->dst_addr.sin_addr.s_addr, - opt->src_addr.sin_addr.s_addr, -0 ,0 ,IPPROTO_GRE , -RT_TOS (0 ), sk->sk_bound_dev_if); + rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) goto tx_error;
@@ -438,12 +452,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr, po->chan.private = sk; po->chan.ops = &pptp_chan_ops; - rt =ip_route_output_ports (sock_net (sk), &fl4, sk, - opt->dst_addr.sin_addr.s_addr, - opt->src_addr.sin_addr.s_addr, -0 ,0 , -IPPROTO_GRE ,RT_CONN_FLAGS (sk), - sk->sk_bound_dev_if); + rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) { error = -EHOSTUNREACH ; goto end;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 703/800 net: dsa: tag_sja1105: fix MAC DA patching from meta frames
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 1dcf6efd5f0c1f4496b3ef7ec5a7db104a53b38c ]
The SJA1105 manual says that at offset 4 into the meta frame payload we have "MAC destination byte 2" and at offset 5 we have "MAC destination byte 1". These are counted from the LSB, so byte 1 is h_dest[ETH_HLEN-2] aka h_dest[4] and byte 2 is h_dest[ETH_HLEN-3] aka h_dest[3].
The sja1105_meta_unpack() function decodes these the other way around, so a frame with MAC DA 01:80:c2:11:22:33 is received by the network stack as having 01:80:c2:22:11:33.
--- net/dsa/tag_sja1105.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/tag_sja1105.c +2 -2
@@ -118,8 +118,8 @@ static void sja1105_meta_unpack(const struct sk_buff *skb,* a unified unpacking command for both device series. */ packing (buf, &meta->tstamp,31 ,0 ,4 ,UNPACK ,0 ); -packing (buf +4 , &meta->dmac_byte_4,7 ,0 ,1 ,UNPACK ,0 ); -packing (buf +5 , &meta->dmac_byte_3,7 ,0 ,1 ,UNPACK ,0 ); +packing (buf +4 , &meta->dmac_byte_3,7 ,0 ,1 ,UNPACK ,0 ); +packing (buf +5 , &meta->dmac_byte_4,7 ,0 ,1 ,UNPACK ,0 );packing (buf +6 , &meta->source_port,7 ,0 ,1 ,UNPACK ,0 );packing (buf +7 , &meta->switch_id,7 ,0 ,1 ,UNPACK ,0 ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 704/800 net: dsa: sja1105: always enable the send_meta options
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit a372d66af48506d9f7aaae2a474cd18f14d98cb8 ]
incl_srcpt has the limitation, mentioned in commit b4638af8885a ("net:
dsa: sja1105: always enable the INCL_SRCPT option"), that frames with a MAC DA of 01:80:c2:xx:yy:zz will be received as 01:80:c2:00:00:zz unless PTP RX timestamping is enabled.
The incl_srcpt option was initially unconditionally enabled, then that changed with commit 42824463d38d ("net: dsa: sja1105: Limit use of incl_srcpt to bridge+vlan mode"), then again with b4638af8885a ("net:
dsa: sja1105: always enable the INCL_SRCPT option"). Bottom line is that it now needs to be always enabled, otherwise the driver does not have a reliable source of information regarding source_port and switch_id for link-local traffic (tag_8021q VLANs may be imprecise since now they identify an entire bridging domain when ports are not standalone).
If we accept that PTP RX timestamping (and therefore, meta frame generation) is always enabled in hardware, then that limitation could be avoided and packets with any MAC DA can be properly received, because meta frames do contain the original bytes from the MAC DA of their associated link-local packet.
This change enables meta frame generation unconditionally, which also has the nice side effects of simplifying the switch control path (a switch reset is no longer required on hwtstamping settings change) and the tagger data path (it no longer needs to be informed whether to expect meta frames or not - it always does).
--- drivers/net/dsa/sja1105/sja1105.h | 2 +- drivers/net/dsa/sja1105/sja1105_main.c | 5 ++- drivers/net/dsa/sja1105/sja1105_ptp.c | 48 +++----------------------- include/linux/dsa/sja1105.h | 4 --- net/dsa/tag_sja1105.c | 45 ------------------------ 5 files changed, 7 insertions(+), 97 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +1 -1
@@ -252,6 +252,7 @@ struct sja1105_private {unsigned long ucast_egress_floods;unsigned long bcast_egress_floods;unsigned long hwts_tx_en; +unsigned long hwts_rx_en;const struct sja1105_info *info;size_t max_xfer_len;struct spi_device *spidev;
@@ -289,7 +290,6 @@ struct sja1105_spi_message {/* From sja1105_main.c */ enum sja1105_reset_reason {SJA1105_VLAN_FILTERING =0 , -SJA1105_RX_HWTSTAMPING ,SJA1105_AGEING_TIME ,SJA1105_SCHEDULING ,SJA1105_BEST_EFFORT_POLICING ,
drivers/net/dsa/sja1105/sja1105_main.c +2 -3
@@ -867,11 +867,11 @@ static int sja1105_init_general_params(struct sja1105_private *priv) .mac_fltres1 = SJA1105_LINKLOCAL_FILTER_A, .mac_flt1 = SJA1105_LINKLOCAL_FILTER_A_MASK, .incl_srcpt1 = true, - .send_meta1 = false, + .send_meta1 = true, .mac_fltres0 = SJA1105_LINKLOCAL_FILTER_B, .mac_flt0 = SJA1105_LINKLOCAL_FILTER_B_MASK, .incl_srcpt0 = true, - .send_meta0 = false, + .send_meta0 = true,/* Default to an invalid value */ .mirr_port = priv->ds->num_ports,/* No TTEthernet */
@@ -2215,7 +2215,6 @@ static int sja1105_reload_cbs(struct sja1105_private *priv)static const char *const sja1105_reset_reasons[] = { [SJA1105_VLAN_FILTERING ] ="VLAN filtering" , - [SJA1105_RX_HWTSTAMPING ] ="RX timestamping" , [SJA1105_AGEING_TIME ] ="Ageing time" , [SJA1105_SCHEDULING ] ="Time-aware scheduling" , [SJA1105_BEST_EFFORT_POLICING ] ="Best-effort policing" ,
drivers/net/dsa/sja1105/sja1105_ptp.c +4 -44
90 lines not on this page · raw message
include/linux/dsa/sja1105.h +0 -4
@@ -48,13 +48,9 @@ struct sja1105_deferred_xmit_work {/* Global tagger data */ struct sja1105_tagger_data { -/* Tagger to switch */ void (*xmit_work_fn)(struct kthread_work *work);void (*meta_tstamp_handler)(struct dsa_switch *ds,int port,u8 ts_id,enum sja1110_meta_tstamp dir,u64 tstamp); -/* Switch to tagger */ -bool (*rxtstamp_get_state)(struct dsa_switch *ds); -void (*rxtstamp_set_state)(struct dsa_switch *ds,bool on); };struct sja1105_skb_cb {
net/dsa/tag_sja1105.c +0 -45
89 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 705/800 octeontx-af: fix hardware timestamp configuration
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 14bb236b29922c4f57d8c05bfdbcb82677f917c9 ]
MAC block on CN10K (RPM) supports hardware timestamp configuration. The previous patch which added timestamp configuration support has a bug. Though the netdev driver requests to disable timestamp configuration, the driver is always enabling it.
This patch fixes the same.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +1 -1
@@ -763,7 +763,7 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcifunc, bool enable) cgxd =rvu_cgx_pdata (cgx_id, rvu); mac_ops =get_mac_ops (cgxd); - mac_ops->mac_enadis_ptp_config (cgxd, lmac_id, true); + mac_ops->mac_enadis_ptp_config (cgxd, lmac_id, enable);/* If PTP is enabled then inform NPC that packets to be * parsed by this PF will have their data shifted by 8 bytes * and if PTP is disabled then no shift is required
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 706/800 afs: Fix accidental truncation when storing data
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 03275585cabd0240944f19f33d7584a1b099a3a8 ]
When an AFS FS.StoreData RPC call is made, amongst other things it is given the resultant file size to be. On the server, this is processed by truncating the file to new size and then writing the data.
Now, kafs has a lock (vnode->io_lock) that serves to serialise operations against a specific vnode (ie. inode), but the parameters for the op are set before the lock is taken. This allows two writebacks (say sync and kswapd) to race - and if writes are ongoing the writeback for a later write could occur before the writeback for an earlier one if the latter gets interrupted.
Note that afs_writepages() cannot take i_mutex and only takes a shared lock on vnode->validate_lock.
Also note that the server does the truncation and the write inside a lock, so there's no problem at that end.
Fix this by moving the calculation for the proposed new i_size inside the vnode->io_lock. Also reset the iterator (which we might have read from) and update the mtime setting there.
--- fs/afs/write.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/afs/write.c +5 -3
@@ -413,17 +413,19 @@ static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter, loff_tafs_op_set_vnode (op,0 , vnode); op->file[0 ].dv_delta =1 ; op->file[0 ].modification = true; - op->store.write_iter = iter; op->store.pos = pos; op->store.size = size; - op->store.i_size =max (pos + size, vnode->netfs.remote_i_size); op->store.laundering = laundering; - op->mtime = vnode->netfs.inode.i_mtime; op->flags |=AFS_OPERATION_UNINTR ; op->ops = &afs_store_data_operation; try_next_key:afs_begin_vnode_operation (op); + + op->store.write_iter = iter; + op->store.i_size =max (pos + size, vnode->netfs.remote_i_size); + op->mtime = vnode->netfs.inode.i_mtime; +afs_wait_for_operation (op);switch (op->error) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 707/800 s390/qeth: Fix vipa deletion
In reply to Greg Kroah-HartmanFrom: Thorsten Winkler <[email protected]>
[ Upstream commit 80de809bd35e2a8999edf9f5aaa2d8de18921f11 ]
Change boolean parameter of function "qeth_l3_vipa_store" inside the "qeth_l3_dev_vipa_del4_store" function from "true" to "false" because "true" is used for adding a virtual ip address and "false" for deleting.
--- drivers/s390/net/qeth_l3_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_l3_sys.c +1 -1
@@ -625,7 +625,7 @@ static QETH_DEVICE_ATTR(vipa_add4, add4, 0644,static ssize_t qeth_l3_dev_vipa_del4_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -return qeth_l3_vipa_store (dev, buf, true, count,QETH_PROT_IPV4 ); +return qeth_l3_vipa_store (dev, buf, false, count,QETH_PROT_IPV4 ); } static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 708/800 risc-v: Fix order of IPI enablement vs RCU startup
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
[ Upstream commit 6259f3443c6a376aa077816ac92e9ddeb0817d09 ]
Conor reports that risc-v tries to enable IPIs before telling the core code to enable RCU. With the introduction of the mapple tree as a backing store for the irq descriptors, this results in a very shouty boot sequence, as RCU is legitimately upset.
Restore some sanity by moving the risc_ipi_enable() call after notify_cpu_starting(), which explicitly enables RCU on the calling CPU.
--- arch/riscv/kernel/smpboot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/riscv/kernel/smpboot.c +3 -2
@@ -161,10 +161,11 @@ asmlinkage __visible void smp_callin(void)mmgrab (mm); current->active_mm = mm; -riscv_ipi_enable (); -store_cpu_topology (curr_cpuid);notify_cpu_starting (curr_cpuid); + +riscv_ipi_enable (); +numa_add_cpu (curr_cpuid);set_cpu_online (curr_cpuid,1 );probe_vendor_features (curr_cpuid);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 709/800 sh: dma: Fix DMA channel offset calculation
In reply to Greg Kroah-HartmanFrom: Artur Rojek <[email protected]>
[ Upstream commit e82e47584847129a20b8c9f4a1dcde09374fb0e0 ]
Various SoCs of the SH3, SH4 and SH4A family, which use this driver, feature a differing number of DMA channels, which can be distributed between up to two DMAC modules. The existing implementation fails to correctly accommodate for all those variations, resulting in wrong channel offset calculations and leading to kernel panics.
Rewrite dma_base_addr() in order to properly calculate channel offsets in a DMAC module. Fix dmaor_read_reg() and dmaor_write_reg(), so that the correct DMAC module base is selected for the DMAOR register.
--- arch/sh/drivers/dma/dma-sh.c | 37 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)
arch/sh/drivers/dma/dma-sh.c +24 -13
@@ -18,6 +18,18 @@#include <cpu/dma-register.h> #include <cpu/dma.h> +/* +* Some of the SoCs feature two DMAC modules. In such a case, the channels are +* distributed equally among them. +*/ +#ifdef SH_DMAC_BASE1 +#define SH_DMAC_NR_MD_CH (CONFIG_NR_ONCHIP_DMA_CHANNELS / 2) +#else +#define SH_DMAC_NR_MD_CH CONFIG_NR_ONCHIP_DMA_CHANNELS +#endif + +#define SH_DMAC_CH_SZ 0x10 +/* * Define the default configuration for dual address memory-memory transfer. * The 0x400 value represents auto-request, external->external.
@@ -29,7 +41,7 @@ static unsigned long dma_find_base(unsigned int chan)unsigned long base =SH_DMAC_BASE0 ;#ifdef SH_DMAC_BASE1 -if (chan >=6 ) +if (chan >=SH_DMAC_NR_MD_CH ) base =SH_DMAC_BASE1 ;#endif
@@ -40,13 +52,13 @@ static unsigned long dma_base_addr(unsigned int chan) {unsigned long base =dma_find_base (chan); -/* Normalize offset calculation */ -if (chan >=9 ) - chan -=6 ; -if (chan >=4 ) - base +=0x10 ; + chan = (chan %SH_DMAC_NR_MD_CH ) *SH_DMAC_CH_SZ ; + +/* DMAOR is placed inside the channel register space. Step over it. */ +if (chan >=DMAOR ) + base +=SH_DMAC_CH_SZ ; -return base + (chan *0x10 ); +return base + chan; }#ifdef CONFIG_SH_DMA_IRQ_MULTI
@@ -250,12 +262,11 @@ static int sh_dmac_get_dma_residue(struct dma_channel *chan)#define NR_DMAOR 1#endif -/* -* DMAOR bases are broken out amongst channel groups. DMAOR0 manages -* channels 0 - 5, DMAOR1 6 - 11 (optional). -*/ -#define dmaor_read_reg (n) __raw_readw(dma_find_base((n)*6)) -#define dmaor_write_reg (n, data) __raw_writew(data, dma_find_base(n)*6) +#define dmaor_read_reg (n) __raw_readw(dma_find_base((n) * \ + SH_DMAC_NR_MD_CH) + DMAOR) +#define dmaor_write_reg (n, data) __raw_writew(data, \ + dma_find_base((n) * \ + SH_DMAC_NR_MD_CH) + DMAOR)static inline int dmaor_reset (int no) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 710/800 apparmor: fix missing error check for rhashtable_insert_fast
In reply to Greg Kroah-HartmanFrom: Danila Chernetsov <[email protected]>
[ Upstream commit 000518bc5aef25d3f703592a0296d578c98b1517 ]
rhashtable_insert_fast() could return err value when memory allocation is failed. but unpack_profile() do not check values and this always returns success value. This patch just adds error check code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- security/apparmor/policy_unpack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
security/apparmor/policy_unpack.c +7 -2
@@ -1064,8 +1064,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) goto fail; } -rhashtable_insert_fast (profile->data, &data->head, - profile->data->p); +if (rhashtable_insert_fast (profile->data, &data->head, + profile->data->p)) { +kfree_sensitive (data->key); +kfree_sensitive (data); + info ="failed to insert data to table" ; + goto fail; + } }if (!aa_unpack_nameX (e,AA_STRUCTEND ,NULL )) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 711/800 apparmor: add missing failure check in compute_xmatch_perms
In reply to Greg Kroah-HartmanFrom: John Johansen <[email protected]>
[ Upstream commit 6600e9f692e36e265ef0828f08337fa294bb330f ]
Add check for failure to allocate the permission table.
--- security/apparmor/policy_compat.c | 2 ++ 1 file changed, 2 insertions(+)
security/apparmor/policy_compat.c +2 -0
@@ -179,6 +179,8 @@ static struct aa_perms *compute_xmatch_perms(struct aa_dfa *xmatch) state_count = xmatch->tables[YYTD_ID_BASE ]->td_lolen;/* DFAs are restricted from having a state_count of less than 2 */ perms =kvcalloc (state_count,sizeof (struct aa_perms ),GFP_KERNEL ); +if (!perms) +return NULL ;/* zero init so skip the trap state (state == 0) */ for (state =1 ; state < state_count; state++)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 712/800 apparmor: fix policy_compat permission remap with extended permissions
In reply to Greg Kroah-HartmanFrom: John Johansen <[email protected]>
[ Upstream commit 0bac2002b397fda7c9ea81ee0b06a02242958107 ]
If the extended permission table is present we should not be attempting to do a compat_permission remap as the compat_permissions are not stored in the dfa accept states.
--- security/apparmor/policy_unpack.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
security/apparmor/policy_unpack.c +19 -12
@@ -860,10 +860,12 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) } profile->attach.xmatch_len = tmp; profile->attach.xmatch.start[AA_CLASS_XMATCH ] =DFA_START ; - error =aa_compat_map_xmatch (&profile->attach.xmatch); -if (error) { - info ="failed to convert xmatch permission table" ; - goto fail; +if (!profile->attach.xmatch.perms) { + error =aa_compat_map_xmatch (&profile->attach.xmatch); +if (error) { + info ="failed to convert xmatch permission table" ; + goto fail; + } } }
@@ -983,10 +985,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) AA_CLASS_FILE);if (!aa_unpack_nameX (e,AA_STRUCTEND ,NULL )) goto fail; - error =aa_compat_map_policy (&rules->policy, e->version); -if (error) { - info ="failed to remap policydb permission table" ; - goto fail; +if (!rules->policy.perms) { + error =aa_compat_map_policy (&rules->policy, + e->version); +if (error) { + info ="failed to remap policydb permission table" ; + goto fail; + } } }else { rules->policy.dfa =aa_get_dfa (nulldfa);
@@ -1001,10 +1006,12 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)if (error) { goto fail; }else if (rules->file.dfa) { - error =aa_compat_map_file (&rules->file); -if (error) { - info ="failed to remap file permission table" ; - goto fail; +if (!rules->file.perms) { + error =aa_compat_map_file (&rules->file); +if (error) { + info ="failed to remap file permission table" ; + goto fail; + } } }else if (rules->policy.dfa && rules->policy.start[AA_CLASS_FILE ]) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 713/800 apparmor: fix profile verification and enable it
In reply to Greg Kroah-HartmanFrom: John Johansen <[email protected]>
[ Upstream commit 6f442d42c0d89876994a4a135eadf82b0e6ff6e4 ]
The transition table size was not being set by compat mappings resulting in the profile verification code not being run. Unfortunately the checks were also buggy not being correctly updated from the old accept perms, to the new layout.
Also indicate to userspace that the kernel has the permstable verification fixes.
--- security/apparmor/policy_compat.c | 18 ++++++++++------ security/apparmor/policy_unpack.c | 34 ++++++++++++++----------------- 2 files changed, 27 insertions(+), 25 deletions(-)
security/apparmor/policy_compat.c +12 -6
@@ -146,7 +146,8 @@ static struct aa_perms compute_fperms_other(struct aa_dfa *dfa,* * Returns: remapped perm table */ -static struct aa_perms *compute_fperms (struct aa_dfa *dfa) +static struct aa_perms *compute_fperms (struct aa_dfa *dfa, +u32 *size) {aa_state_t state;unsigned int state_count;
@@ -159,6 +160,7 @@ static struct aa_perms *compute_fperms(struct aa_dfa *dfa) table =kvcalloc (state_count *2 ,sizeof (struct aa_perms ),GFP_KERNEL );if (!table)return NULL ; + *size = state_count *2 ;for (state =0 ; state < state_count; state++) { table[state *2 ] =compute_fperms_user (dfa, state);
@@ -168,7 +170,8 @@ static struct aa_perms *compute_fperms(struct aa_dfa *dfa)return table; } -static struct aa_perms *compute_xmatch_perms (struct aa_dfa *xmatch) +static struct aa_perms *compute_xmatch_perms (struct aa_dfa *xmatch, +u32 *size) {struct aa_perms *perms;int state;
@@ -181,6 +184,7 @@ static struct aa_perms *compute_xmatch_perms(struct aa_dfa *xmatch) perms =kvcalloc (state_count,sizeof (struct aa_perms ),GFP_KERNEL );if (!perms)return NULL ; + *size = state_count;/* zero init so skip the trap state (state == 0) */ for (state =1 ; state < state_count; state++)
@@ -241,7 +245,8 @@ static struct aa_perms compute_perms_entry(struct aa_dfa *dfa,return perms; } -static struct aa_perms *compute_perms (struct aa_dfa *dfa,u32 version) +static struct aa_perms *compute_perms (struct aa_dfa *dfa,u32 version, +u32 *size) {unsigned int state;unsigned int state_count;
@@ -254,6 +259,7 @@ static struct aa_perms *compute_perms(struct aa_dfa *dfa, u32 version) table =kvcalloc (state_count,sizeof (struct aa_perms ),GFP_KERNEL );if (!table)return NULL ; + *size = state_count;/* zero init so skip the trap state (state == 0) */ for (state =1 ; state < state_count; state++)
@@ -288,7 +294,7 @@ static void remap_dfa_accept(struct aa_dfa *dfa, unsigned int factor)/* TODO: merge different dfa mappings into single map_policy fn */ int aa_compat_map_xmatch (struct aa_policydb *policy) { - policy->perms =compute_xmatch_perms (policy->dfa); + policy->perms =compute_xmatch_perms (policy->dfa, &policy->size);if (!policy->perms)return -ENOMEM ;
@@ -299,7 +305,7 @@ int aa_compat_map_xmatch(struct aa_policydb *policy)int aa_compat_map_policy (struct aa_policydb *policy,u32 version) { - policy->perms =compute_perms (policy->dfa, version); + policy->perms =compute_perms (policy->dfa, version, &policy->size);if (!policy->perms)return -ENOMEM ;
@@ -310,7 +316,7 @@ int aa_compat_map_policy(struct aa_policydb *policy, u32 version)int aa_compat_map_file (struct aa_policydb *policy) { - policy->perms =compute_fperms (policy->dfa); + policy->perms =compute_fperms (policy->dfa, &policy->size);if (!policy->perms)return -ENOMEM ;
security/apparmor/policy_unpack.c +15 -19
@@ -1164,22 +1164,16 @@ static int verify_header(struct aa_ext *e, int required, const char **ns)return 0 ; } -static bool verify_xindex (int xindex,int table_size) -{ -int index, xtype; - xtype = xindex &AA_X_TYPE_MASK ; - index = xindex &AA_X_INDEX_MASK ; -if (xtype ==AA_X_TABLE && index >= table_size) -return false; -return true; -} - -/* verify dfa xindexes are in range of transition tables */ -static bool verify_dfa_xindex (struct aa_dfa *dfa,int table_size) +/** +* verify_dfa_accept_xindex - verify accept indexes are in range of perms table +* @dfa: the dfa to check accept indexes are in range +* table_size: the permission table size the indexes should be within +*/ +static bool verify_dfa_accept_index (struct aa_dfa *dfa,int table_size) {int i;for (i =0 ; i < dfa->tables[YYTD_ID_ACCEPT ]->td_lolen; i++) { -if (!verify_xindex (ACCEPT_TABLE (dfa)[i], table_size)) +if (ACCEPT_TABLE (dfa)[i] >= table_size)return false; }return true;
@@ -1216,11 +1210,13 @@ static bool verify_perms(struct aa_policydb *pdb)if (!verify_perm (&pdb->perms[i]))return false;/* verify indexes into str table */ -if (pdb->perms[i].xindex >= pdb->trans.size) +if ((pdb->perms[i].xindex &AA_X_TYPE_MASK ) ==AA_X_TABLE && + (pdb->perms[i].xindex &AA_X_INDEX_MASK ) >= pdb->trans.size)return false; -if (pdb->perms[i].tag >= pdb->trans.size) +if (pdb->perms[i].tag && pdb->perms[i].tag >= pdb->trans.size)return false; -if (pdb->perms[i].label >= pdb->trans.size) +if (pdb->perms[i].label && + pdb->perms[i].label >= pdb->trans.size)return false; }
@@ -1242,10 +1238,10 @@ static int verify_profile(struct aa_profile *profile)if (!rules)return 0 ; -if ((rules->file.dfa && !verify_dfa_xindex (rules->file.dfa, - rules->file.trans.size)) || +if ((rules->file.dfa && !verify_dfa_accept_index (rules->file.dfa, + rules->file.size)) || (rules->policy.dfa && - !verify_dfa_xindex (rules->policy.dfa, rules->policy.trans.size))) { + !verify_dfa_accept_index (rules->policy.dfa, rules->policy.size))) {audit_iface (profile,NULL ,NULL ,"Unpack: Invalid named transition" ,NULL , -EPROTO );return -EPROTO ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 714/800 i2c: xiic: Dont try to handle more interrupt events after error
In reply to Greg Kroah-HartmanFrom: Robert Hancock <[email protected]>
[ Upstream commit cb6e45c9a0ad9e0f8664fd06db0227d185dc76ab ]
In xiic_process, it is possible that error events such as arbitration lost or TX error can be raised in conjunction with other interrupt flags such as TX FIFO empty or bus not busy. Error events result in the controller being reset and the error returned to the calling request, but the function could potentially try to keep handling the other events, such as by writing more messages into the TX FIFO. Since the transaction has already failed, this is not helpful and will just cause issues.
This problem has been present ever since:
commit 7f9906bd7f72 ("i2c: xiic: Service all interrupts in isr")
which allowed non-error events to be handled after errors, but became more obvious after:
commit 743e227a8959 ("i2c: xiic: Defer xiic_wakeup() and __xiic_start_xfer() in xiic_process()")
which reworked the code to add a WARN_ON which triggers if both the xfer_more and wakeup_req flags were set, since this combination is not supposed to happen, but was occurring in this scenario.
Skip further interrupt handling after error flags are detected to avoid this problem.
--- drivers/i2c/busses/i2c-xiic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-xiic.c +2 -0
@@ -721,6 +721,8 @@ static irqreturn_t xiic_process(int irq, void *dev_id) wakeup_req =1 ; wakeup_code =STATE_ERROR ; } +/* don't try to handle other events */ + goto out; }if (pend &XIIC_INTR_RX_FULL_MASK ) {/* Receive register/FIFO is full */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 715/800 writeback: account the number of pages written back
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 8344a3d44be3d18671e18c4ba23bb03dd21e14ad ]
nr_to_write is a count of pages, so we need to decrease it by the number of pages in the folio we just wrote, not by 1. Most callers specify either LONG_MAX or 1, so are unaffected, but writeback_sb_inodes() might end up writing 512x as many pages as it asked for.
Dave added:
: XFS is the only filesystem this would affect, right? AFAIA, nothing : else enables large folios and uses writeback through
: write_cache_pages() at this point...
:
: In which case, I'd be surprised if much difference, if any, gets : noticed by anyone.
--- mm/page-writeback.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
mm/page-writeback.c +5 -3
@@ -2434,6 +2434,7 @@ int write_cache_pages(struct address_space *mapping,for (i =0 ; i < nr_folios; i++) {struct folio *folio = fbatch.folios[i]; +unsigned long nr; done_index = folio->index;
@@ -2471,6 +2472,7 @@ int write_cache_pages(struct address_space *mapping,trace_wbc_writepage (wbc,inode_to_bdi (mapping->host)); error =writepage (folio, wbc, data); + nr =folio_nr_pages (folio);if (unlikely (error)) {/* * Handle errors according to the type of
@@ -2489,8 +2491,7 @@ int write_cache_pages(struct address_space *mapping, error =0 ; }else if (wbc->sync_mode !=WB_SYNC_ALL ) { ret = error; - done_index = folio->index + -folio_nr_pages (folio); + done_index = folio->index + nr; done =1 ;break ; }
@@ -2504,7 +2505,8 @@ int write_cache_pages(struct address_space *mapping,* keep going until we have written all the pages * we tagged for writeback prior to entering this loop. */ -if (--wbc->nr_to_write <=0 && + wbc->nr_to_write -= nr; +if (wbc->nr_to_write <=0 && wbc->sync_mode ==WB_SYNC_NONE ) { done =1 ;break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 716/800 lib: dhry: fix sleeping allocations inside non-preemptable section
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 8ba388c06bc8056935ec1814b2689bfb42f3b89a ]
The Smatch static checker reports the following warnings:
lib/dhry_run.c:38 dhry_benchmark() warn: sleeping in atomic context lib/dhry_run.c:43 dhry_benchmark() warn: sleeping in atomic context
Indeed, dhry() does sleeping allocations inside the non-preemptable section delimited by get_cpu()/put_cpu().
Fix this by using atomic allocations instead. Add error handling, as atomic these allocations may fail.
--- lib/dhry_1.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
lib/dhry_1.c +9 -2
@@ -139,8 +139,15 @@ int dhry(int n)/* Initializations */ - Next_Ptr_Glob = (Rec_Pointer )kzalloc (sizeof (Rec_Type),GFP_KERNEL ); - Ptr_Glob = (Rec_Pointer )kzalloc (sizeof (Rec_Type),GFP_KERNEL ); + Next_Ptr_Glob = (Rec_Pointer )kzalloc (sizeof (Rec_Type),GFP_ATOMIC ); +if (!Next_Ptr_Glob) +return -ENOMEM ; + + Ptr_Glob = (Rec_Pointer )kzalloc (sizeof (Rec_Type),GFP_ATOMIC ); +if (!Ptr_Glob) { +kfree (Next_Ptr_Glob); +return -ENOMEM ; + } Ptr_Glob->Ptr_Comp = Next_Ptr_Glob; Ptr_Glob->Discr = Ident_1;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 717/800 Revert "drm/amd/display: Move DCN314 DOMAIN power control to DMCUB"
In reply to Greg Kroah-HartmanFrom: Daniel Miess <[email protected]>
[ Upstream commit bf0097c5c9aec528da75e2b5fcede472165322bb ]
This reverts commit e383b12709e32d6494c948422070c2464b637e44.
Controling hubp power gating using the DMCUB isn't stable so we are reverting this change to move control back into the driver.
--- .../drm/amd/display/dc/dcn314/dcn314_hwseq.c | 23 ------------------- .../drm/amd/display/dc/dcn314/dcn314_hwseq.h | 2 -- .../drm/amd/display/dc/dcn314/dcn314_init.c | 2 +- 3 files changed, 1 insertion(+), 26 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_hwseq.c +0 -23
@@ -400,29 +400,6 @@ void dcn314_dpp_root_clock_control(struct dce_hwseq *hws, unsigned int dpp_inst, hws->ctx->dc->res_pool->dccg, dpp_inst, clock_on); } -void dcn314_hubp_pg_control (struct dce_hwseq *hws,unsigned int hubp_inst,bool power_on) -{ -struct dc_context *ctx = hws->ctx; -union dmub_rb_cmd cmd; - -if (hws->ctx->dc->debug.disable_hubp_power_gate) -return ; - -PERF_TRACE (); - -memset (&cmd,0 ,sizeof (cmd)); - cmd.domain_control.header.type =DMUB_CMD__VBIOS ; - cmd.domain_control.header.sub_type =DMUB_CMD__VBIOS_DOMAIN_CONTROL ; - cmd.domain_control.header.payload_bytes =sizeof (cmd.domain_control.data); - cmd.domain_control.data.inst = hubp_inst; - cmd.domain_control.data.power_gate = !power_on; - -dc_dmub_srv_cmd_queue (ctx->dmub_srv, &cmd); -dc_dmub_srv_cmd_execute (ctx->dmub_srv); -dc_dmub_srv_wait_idle (ctx->dmub_srv); - -PERF_TRACE (); -}static void apply_symclk_on_tx_off_wa (struct dc_link *link) {/* There are use cases where SYMCLK is referenced by OTG. For instance
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_hwseq.h +0 -2
@@ -41,8 +41,6 @@ unsigned int dcn314_calculate_dccg_k1_k2_values(struct pipe_ctx *pipe_ctx, unsigvoid dcn314_set_pixels_per_cycle (struct pipe_ctx *pipe_ctx); -void dcn314_hubp_pg_control (struct dce_hwseq *hws,unsigned int hubp_inst,bool power_on); -void dcn314_dpp_root_clock_control (struct dce_hwseq *hws,unsigned int dpp_inst,bool clock_on);void dcn314_disable_link_output (struct dc_link *link,const struct link_resource *link_res,enum signal_type signal);
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_init.c +1 -1
@@ -138,7 +138,7 @@ static const struct hwseq_private_funcs dcn314_private_funcs = { .plane_atomic_power_down = dcn10_plane_atomic_power_down, .enable_power_gating_plane = dcn314_enable_power_gating_plane, .dpp_root_clock_control = dcn314_dpp_root_clock_control, - .hubp_pg_control = dcn314_hubp_pg_control, + .hubp_pg_control = dcn31_hubp_pg_control, .program_all_writeback_pipes_in_tree = dcn30_program_all_writeback_pipes_in_tree, .update_odm = dcn314_update_odm, .dsc_pg_control = dcn314_dsc_pg_control,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 718/800 arm64/signal: Restore TPIDR2 register rather than memory state
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
commit 616cb2f4b141852cac3dfffe8354c8bf19e9999d upstream.
Currently when restoring the TPIDR2 signal context we set the new value from the signal frame in the thread data structure but not the register, following the pattern for the rest of the data we are restoring. This does not work in the case of TPIDR2, the register always has the value for the current task. This means that either we return to userspace and ignore the new value or we context switch and save the register value on top of the newly restored value.
Load the value from the signal context into the register instead.
--- arch/arm64/kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/signal.c +1 -1
@@ -398,7 +398,7 @@ static int restore_tpidr2_context(struct__get_user_error (tpidr2_el0, &user->tpidr2->tpidr2, err);if (!err) - current->thread.tpidr2_el0 = tpidr2_el0; +write_sysreg_s (tpidr2_el0,SYS_TPIDR2_EL0 );return err; }
Greg Kroah-Hartman
maintainerPATCH 719/800 irqchip/loongson-liointc: Fix IRQ trigger polarity
In reply to Greg Kroah-HartmanFrom: Jianmin Lv <[email protected]>
commit 1d7471b4e0ebba5a4bf9db4ade43619e8f2d333d upstream.
For the INT_POLARITY register of Loongson-2K series IRQ controller, '0' indicates high level or rising edge triggered, '1' indicates low level or falling edge triggered, and we can find out the information from the Loongson 2K1000LA User Manual v1.0, Table 9-2, Section 9.3 (中断寄存器描述 / Description of the Interrupt Registers).
For Loongson-3 CPU series, setting INT_POLARITY register is not supported and writting it has no effect.
So trigger polarity setting shouled be fixed for Loongson-2K CPU series.
--- drivers/irqchip/irq-loongson-liointc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/irqchip/irq-loongson-liointc.c +8 -4
@@ -32,6 +32,10 @@#define LIOINTC_REG_INTC_EN_STATUS (LIOINTC_INTC_CHIP_START + 0x04)#define LIOINTC_REG_INTC_ENABLE (LIOINTC_INTC_CHIP_START + 0x08)#define LIOINTC_REG_INTC_DISABLE (LIOINTC_INTC_CHIP_START + 0x0c) +/* +* LIOINTC_REG_INTC_POL register is only valid for Loongson-2K series, and +* Loongson-3 series behave as noops. +*/ #define LIOINTC_REG_INTC_POL (LIOINTC_INTC_CHIP_START + 0x10)#define LIOINTC_REG_INTC_EDGE (LIOINTC_INTC_CHIP_START + 0x14)
@@ -116,19 +120,19 @@ static int liointc_set_type(struct irq_data *data, unsigned int type)switch (type) {case IRQ_TYPE_LEVEL_HIGH :liointc_set_bit (gc,LIOINTC_REG_INTC_EDGE , mask, false); -liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, true); +liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, false);break ;case IRQ_TYPE_LEVEL_LOW :liointc_set_bit (gc,LIOINTC_REG_INTC_EDGE , mask, false); -liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, false); +liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, true);break ;case IRQ_TYPE_EDGE_RISING :liointc_set_bit (gc,LIOINTC_REG_INTC_EDGE , mask, true); -liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, true); +liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, false);break ;case IRQ_TYPE_EDGE_FALLING :liointc_set_bit (gc,LIOINTC_REG_INTC_EDGE , mask, true); -liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, false); +liointc_set_bit (gc,LIOINTC_REG_INTC_POL , mask, true);break ;default :irq_gc_unlock_irqrestore (gc, flags);
Signature · 1 line
2.41.0
Greg Kroah-Hartman
maintainerPATCH 720/800 nfsd: move init of percpu reply_cache_stats counters back to nfsd_init_net
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
commit ed9ab7346e908496816cffdecd46932035f66e2e upstream.
Commit f5f9d4a314da ("nfsd: move reply cache initialization into nfsd startup") moved the initialization of the reply cache into nfsd startup, but didn't account for the stats counters, which can be accessed before nfsd is ever started. The result can be a NULL pointer dereference when someone accesses /proc/fs/nfsd/reply_cache_stats while nfsd is still shut down.
This is a regression and a user-triggerable oops in the right situation:
- non-x86_64 arch
- /proc/fs/nfsd is mounted in the namespace
- nfsd is not started in the namespace
- unprivileged user calls "cat /proc/fs/nfsd/reply_cache_stats"
Although this is easy to trigger on some arches (like aarch64), on x86_64, calling this_cpu_ptr(NULL) evidently returns a pointer to the fixed_percpu_data. That struct looks just enough like a newly initialized percpu var to allow nfsd_reply_cache_stats_show to access it without Oopsing.
Move the initialization of the per-net+per-cpu reply-cache counters back into nfsd_init_net, while leaving the rest of the reply cache allocations to be done at nfsd startup time.
Kudos to Eirik who did most of the legwork to track this down.
--- fs/nfsd/cache.h | 2 ++ fs/nfsd/nfscache.c | 25 ++++++++++++++----------- fs/nfsd/nfsctl.c | 10 +++++++++- 3 files changed, 25 insertions(+), 12 deletions(-)
fs/nfsd/cache.h +2 -0
@@ -80,6 +80,8 @@ enum {int nfsd_drc_slab_create (void );void nfsd_drc_slab_free (void ); +int nfsd_net_reply_cache_init (struct nfsd_net *nn); +void nfsd_net_reply_cache_destroy (struct nfsd_net *nn);int nfsd_reply_cache_init (struct nfsd_net *);void nfsd_reply_cache_shutdown (struct nfsd_net *);int nfsd_cache_lookup (struct svc_rqst *);
fs/nfsd/nfscache.c +14 -11
@@ -148,12 +148,23 @@ void nfsd_drc_slab_free(void)kmem_cache_destroy (drc_slab); } -static int nfsd_reply_cache_stats_init (struct nfsd_net *nn) +/** +* nfsd_net_reply_cache_init - per net namespace reply cache set-up +* @nn: nfsd_net being initialized +* +* Returns zero on succes; otherwise a negative errno is returned. +*/ +int nfsd_net_reply_cache_init (struct nfsd_net *nn) {return nfsd_percpu_counters_init (nn->counter,NFSD_NET_COUNTERS_NUM ); } -static void nfsd_reply_cache_stats_destroy (struct nfsd_net *nn) +/** +* nfsd_net_reply_cache_destroy - per net namespace reply cache tear-down +* @nn: nfsd_net being freed +* +*/ +void nfsd_net_reply_cache_destroy (struct nfsd_net *nn) {nfsd_percpu_counters_destroy (nn->counter,NFSD_NET_COUNTERS_NUM ); }
@@ -169,17 +180,13 @@ int nfsd_reply_cache_init(struct nfsd_ne hashsize =nfsd_hashsize (nn->max_drc_entries); nn->maskbits =ilog2 (hashsize); - status =nfsd_reply_cache_stats_init (nn); -if (status) - goto out_nomem; - nn->nfsd_reply_cache_shrinker.scan_objects = nfsd_reply_cache_scan; nn->nfsd_reply_cache_shrinker.count_objects = nfsd_reply_cache_count; nn->nfsd_reply_cache_shrinker.seeks =1 ; status =register_shrinker (&nn->nfsd_reply_cache_shrinker,"nfsd-reply:%s" , nn->nfsd_name);if (status) - goto out_stats_destroy; +return status; nn->drc_hashtbl =kvzalloc (array_size (hashsize,sizeof (*nn->drc_hashtbl)),GFP_KERNEL );
@@ -195,9 +202,6 @@ int nfsd_reply_cache_init(struct nfsd_nereturn 0 ; out_shrinker:unregister_shrinker (&nn->nfsd_reply_cache_shrinker); -out_stats_destroy: -nfsd_reply_cache_stats_destroy (nn); -out_nomem:printk (KERN_ERR "nfsd: failed to allocate reply cache\n" );return -ENOMEM ; }
@@ -217,7 +221,6 @@ void nfsd_reply_cache_shutdown(struct nf rp, nn); } } -nfsd_reply_cache_stats_destroy (nn);kvfree (nn->drc_hashtbl); nn->drc_hashtbl =NULL ;
fs/nfsd/nfsctl.c +9 -1
@@ -1488,6 +1488,9 @@ static __net_init int nfsd_init_net(stru retval =nfsd_idmap_init (net);if (retval) goto out_idmap_error; + retval =nfsd_net_reply_cache_init (nn); +if (retval) + goto out_repcache_error; nn->nfsd_versions =NULL ; nn->nfsd4_minorversions =NULL ;nfsd4_init_leases_net (nn);
@@ -1496,6 +1499,8 @@ static __net_init int nfsd_init_net(strureturn 0 ; +out_repcache_error: +nfsd_idmap_shutdown (net); out_idmap_error:nfsd_export_shutdown (net); out_export_error:
@@ -1504,9 +1509,12 @@ out_export_error: static __net_exit void nfsd_exit_net(struct net *net) { +struct nfsd_net *nn =net_generic (net, nfsd_net_id); + +nfsd_net_reply_cache_destroy (nn);nfsd_idmap_shutdown (net);nfsd_export_shutdown (net); -nfsd_netns_free_versions (net_generic (net, nfsd_net_id)); +nfsd_netns_free_versions (nn); }static struct pernet_operations nfsd_net_ops = {
Greg Kroah-Hartman
maintainerPATCH 721/800 irqchip/loongson-pch-pic: Fix potential incorrect hwirq assignment
In reply to Greg Kroah-HartmanFrom: Liu Peibao <[email protected]>
commit 783422e704ca0fa41cb2fe9ed79e46b6fe7eae29 upstream.
In DeviceTree path, when ht_vec_base is not zero, the hwirq of PCH PIC will be assigned incorrectly. Because when pch_pic_domain_translate() adds the ht_vec_base to hwirq, the hwirq does not have the ht_vec_base subtracted when calling irq_domain_set_info().
The ht_vec_base is designed for the parent irq chip/domain of the PCH PIC. It seems not proper to deal this in callbacks of the PCH PIC domain and let's put this back like the initial commit ef8c01eb64ca ("irqchip: Add Loongson PCH PIC controller").
--- drivers/irqchip/irq-loongson-pch-pic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-loongson-pch-pic.c +2 -2
@@ -164,7 +164,7 @@ static int pch_pic_domain_translate(struif (fwspec->param_count <2 )return -EINVAL ; - *hwirq = fwspec->param[0 ] + priv->ht_vec_base; + *hwirq = fwspec->param[0 ]; *type = fwspec->param[1 ] &IRQ_TYPE_SENSE_MASK ; }else {if (fwspec->param_count <1 )
@@ -196,7 +196,7 @@ static int pch_pic_alloc(struct irq_doma parent_fwspec.fwnode = domain->parent->fwnode; parent_fwspec.param_count =1 ; - parent_fwspec.param[0 ] = hwirq; + parent_fwspec.param[0 ] = hwirq + priv->ht_vec_base; err =irq_domain_alloc_irqs_parent (domain, virq,1 , &parent_fwspec);if (err)
Greg Kroah-Hartman
maintainerPATCH 722/800 NFSD: add encoding of op_recall flag for write delegation
In reply to Greg Kroah-HartmanFrom: Dai Ngo <[email protected]>
commit 58f5d894006d82ed7335e1c37182fbc5f08c2f51 upstream.
Modified nfsd4_encode_open to encode the op_recall flag properly for OPEN result with write delegation granted.
--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +1 -1
@@ -3956,7 +3956,7 @@ nfsd4_encode_open(struct nfsd4_compoundr p =xdr_reserve_space (xdr,32 );if (!p)return nfserr_resource; - *p++ =cpu_to_be32 (0 ); + *p++ =cpu_to_be32 (open->op_recall);/* * TODO: space_limit's in delegations
Greg Kroah-Hartman
maintainerPATCH 723/800 irqchip/loongson-pch-pic: Fix initialization of HT vector register
In reply to Greg Kroah-HartmanFrom: Jianmin Lv <[email protected]>
commit f679616565f1cf1a4acb245dbc0032dafcd40637 upstream.
In an ACPI-based dual-bridge system, IRQ of each bridge's PCH PIC sent to CPU is always a zero-based number, which means that the IRQ on PCH PIC of each bridge is mapped into vector range from 0 to 63 of upstream irqchip(e.g. EIOINTC).
EIOINTC N: [0 ... 63 | 64 ... 255]
-------- ----------
^ ^
| |
PCH PIC N |
PCH MSI N
For example, the IRQ vector number of sata controller on PCH PIC of each bridge is 16, which is sent to upstream irqchip of EIOINTC when an interrupt occurs, which will set bit 16 of EIOINTC. Since hwirq of 16 on EIOINTC has been mapped to a irq_desc for sata controller during hierarchy irq allocation, the related mapped IRQ will be found through irq_resolve_mapping() in the IRQ domain of EIOINTC.
So, the IRQ number set in HT vector register should be fixed to be a zero-based number.
--- drivers/irqchip/irq-loongson-pch-pic.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/irqchip/irq-loongson-pch-pic.c +2 -4
@@ -401,14 +401,12 @@ static int __init acpi_cascade_irqdomainint __init pch_pic_acpi_init (struct irq_domain *parent,struct acpi_madt_bio_pic *acpi_pchpic) { -int ret, vec_base; +int ret;struct fwnode_handle *domain_handle;if (find_pch_pic (acpi_pchpic->gsi_base) >=0 )return 0 ; - vec_base = acpi_pchpic->gsi_base -GSI_MIN_PCH_IRQ ; - domain_handle =irq_domain_alloc_fwnode (&acpi_pchpic->address);if (!domain_handle) {pr_err ("Unable to allocate domain handle\n" );
@@ -416,7 +414,7 @@ int __init pch_pic_acpi_init(struct irq_ } ret =pch_pic_init (acpi_pchpic->address, acpi_pchpic->size, - vec_base, parent, domain_handle, acpi_pchpic->gsi_base); +0 , parent, domain_handle, acpi_pchpic->gsi_base);if (ret <0 ) {irq_domain_free_fwnode (domain_handle);
Greg Kroah-Hartman
maintainerPATCH 724/800 io_uring: wait interruptibly for request completions on exit
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 4826c59453b3b4677d6bf72814e7ababdea86949 upstream.
WHen the ring exits, cleanup is done and the final cancelation and waiting on completions is done by io_ring_exit_work. That function is invoked by kworker, which doesn't take any signals. Because of that, it doesn't really matter if we wait for completions in TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE state. However, it does matter to the hung task detection checker!
Normally we expect cancelations and completions to happen rather quickly. Some test cases, however, will exit the ring and park the owning task stopped (eg via SIGSTOP). If the owning task needs to run task_work to complete requests, then io_ring_exit_work won't make any progress until the task is runnable again. Hence io_ring_exit_work can trigger the hung task detection, which is particularly problematic if panic-on-hung-task is enabled.
As the ring exit doesn't take signals to begin with, have it wait interruptibly rather than uninterruptibly. io_uring has a separate stuck-exit warning that triggers independently anyway, so we're not really missing anything by making this switch.
--- io_uring/io_uring.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
io_uring/io_uring.c +18 -2
@@ -3050,7 +3050,18 @@ static __cold void io_ring_exit_work(str/* there is little hope left, don't run it too often */ interval =HZ *60 ; } - }while (!wait_for_completion_timeout (&ctx->ref_comp, interval)); +/* +* This is really an uninterruptible wait, as it has to be +* complete. But it's also run from a kworker, which doesn't +* take signals, so it's fine to make it interruptible. This +* avoids scenarios where we knowingly can wait much longer +* on completions, for example if someone does a SIGSTOP on +* a task that needs to finish task_work to make this loop +* complete. That's a synthetic situation that should not +* cause a stuck task backtrace, and hence a potential panic +* on stuck tasks if that is enabled. +*/ + }while (!wait_for_completion_interruptible_timeout (&ctx->ref_comp, interval));init_completion (&exit.completion);init_task_work (&exit.task_work, io_tctx_exit_cb);
@@ -3074,7 +3085,12 @@ static __cold void io_ring_exit_work(strcontinue ;mutex_unlock (&ctx->uring_lock); -wait_for_completion (&exit.completion); +/* +* See comment above for +* wait_for_completion_interruptible_timeout() on why this +* wait is marked as interruptible. +*/ +wait_for_completion_interruptible (&exit.completion);mutex_lock (&ctx->uring_lock); }mutex_unlock (&ctx->uring_lock);
Greg Kroah-Hartman
maintainerPATCH 725/800 mm/mglru: make memcg_lru->lock irq safe
In reply to Greg Kroah-HartmanFrom: Yu Zhao <[email protected]>
commit 814bc1de03ea4361101408e63a68e4b82aef22cb upstream.
lru_gen_rotate_memcg() can happen in softirq if memory.soft_limit_in_bytes is set. This requires memcg_lru->lock to be irq safe. Lockdep warns on this.
This problem only affects memcg v1.
--- mm/vmscan.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
mm/vmscan.c +7 -6
@@ -4728,10 +4728,11 @@ static void lru_gen_rotate_memcg(struct lruvec *lruvec, int op) {int seg;int old, new; +unsigned long flags;int bin =get_random_u32_below (MEMCG_NR_BINS );struct pglist_data *pgdat =lruvec_pgdat (lruvec); -spin_lock (&pgdat->memcg_lru.lock); +spin_lock_irqsave (&pgdat->memcg_lru.lock, flags);VM_WARN_ON_ONCE (hlist_nulls_unhashed (&lruvec->lrugen.list));
@@ -4766,7 +4767,7 @@ static void lru_gen_rotate_memcg(struct lruvec *lruvec, int op)if (!pgdat->memcg_lru.nr_memcgs[old] && old ==get_memcg_gen (pgdat->memcg_lru.seq))WRITE_ONCE (pgdat->memcg_lru.seq, pgdat->memcg_lru.seq +1 ); -spin_unlock (&pgdat->memcg_lru.lock); +spin_unlock_irqrestore (&pgdat->memcg_lru.lock, flags); }void lru_gen_online_memcg (struct mem_cgroup *memcg)
@@ -4779,7 +4780,7 @@ void lru_gen_online_memcg(struct mem_cgroup *memcg)struct pglist_data *pgdat =NODE_DATA (nid);struct lruvec *lruvec =get_lruvec (memcg, nid); -spin_lock (&pgdat->memcg_lru.lock); +spin_lock_irq (&pgdat->memcg_lru.lock);VM_WARN_ON_ONCE (!hlist_nulls_unhashed (&lruvec->lrugen.list));
@@ -4790,7 +4791,7 @@ void lru_gen_online_memcg(struct mem_cgroup *memcg) lruvec->lrugen.gen = gen; -spin_unlock (&pgdat->memcg_lru.lock); +spin_unlock_irq (&pgdat->memcg_lru.lock); } }
@@ -4814,7 +4815,7 @@ void lru_gen_release_memcg(struct mem_cgroup *memcg)struct pglist_data *pgdat =NODE_DATA (nid);struct lruvec *lruvec =get_lruvec (memcg, nid); -spin_lock (&pgdat->memcg_lru.lock); +spin_lock_irq (&pgdat->memcg_lru.lock);VM_WARN_ON_ONCE (hlist_nulls_unhashed (&lruvec->lrugen.list));
@@ -4826,7 +4827,7 @@ void lru_gen_release_memcg(struct mem_cgroup *memcg)if (!pgdat->memcg_lru.nr_memcgs[gen] && gen ==get_memcg_gen (pgdat->memcg_lru.seq))WRITE_ONCE (pgdat->memcg_lru.seq, pgdat->memcg_lru.seq +1 ); -spin_unlock (&pgdat->memcg_lru.lock); +spin_unlock_irq (&pgdat->memcg_lru.lock); } }
Signature · 1 line
2.41.0
Greg Kroah-Hartman
maintainerPATCH 726/800 mmc: core: disable TRIM on Kingston EMMC04G-M627
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
commit f1738a1f816233e6dfc2407f24a31d596643fd90 upstream.
It seems that Kingston EMMC04G-M627 despite advertising TRIM support does not work when the core is trying to use REQ_OP_WRITE_ZEROES.
We are seeing I/O errors in OpenWrt under 6.1 on Zyxel NBG7815 that we did not previously have and tracked it down to REQ_OP_WRITE_ZEROES.
Trying to use fstrim seems to also throw errors like:
[93010.835112] I/O error, dev loop0, sector 16902 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 2
Disabling TRIM makes the error go away, so lets add a quirk for this eMMC to disable TRIM.
--- drivers/mmc/core/quirks.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/quirks.h +7 -0
@@ -110,6 +110,13 @@ static const struct mmc_fixup __maybe_un MMC_QUIRK_TRIM_BROKEN),/* +* Kingston EMMC04G-M627 advertises TRIM but it does not seems to +* support being used to offload WRITE_ZEROES. +*/ +MMC_FIXUP ("M62704" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc, +MMC_QUIRK_TRIM_BROKEN ), + +/* * Some SD cards reports discard support while they don't */ MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
Greg Kroah-Hartman
maintainerPATCH 727/800 mmc: core: disable TRIM on Micron MTFC4GACAJCN-1M
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
commit dbfbddcddcebc9ce8a08757708d4e4a99d238e44 upstream.
It seems that Micron MTFC4GACAJCN-1M despite advertising TRIM support does not work when the core is trying to use REQ_OP_WRITE_ZEROES.
We are seeing the following errors in OpenWrt under 6.1 on Qnap Qhora 301W that we did not previously have and tracked it down to REQ_OP_WRITE_ZEROES:
[ 18.085950] I/O error, dev loop0, sector 596 op 0x9:(WRITE_ZEROES) flags 0x800 phys_seg 0 prio class 2
Disabling TRIM makes the error go away, so lets add a quirk for this eMMC to disable TRIM.
--- drivers/mmc/core/quirks.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/quirks.h +7 -0
@@ -117,6 +117,13 @@ static const struct mmc_fixup __maybe_un MMC_QUIRK_TRIM_BROKEN),/* +* Micron MTFC4GACAJCN-1M advertises TRIM but it does not seems to +* support being used to offload WRITE_ZEROES. +*/ +MMC_FIXUP ("Q2J54A" ,CID_MANFID_MICRON ,0x014e , add_quirk_mmc, +MMC_QUIRK_TRIM_BROKEN ), + +/* * Some SD cards reports discard support while they don't */ MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
Greg Kroah-Hartman
maintainerPATCH 728/800 mmc: mmci: Set PROBE_PREFER_ASYNCHRONOUS
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit 3108eb2e8aa7e955a9dd3a4c1bf19a7898961822 upstream.
All mmc host drivers should have the asynchronous probe option enabled, but it seems like we failed to set it for mmci, so let's do that now.
--- drivers/mmc/host/mmci.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/mmci.c +1 -0
@@ -2456,6 +2456,7 @@ static struct amba_driver mmci_driver = .drv = { .name = DRIVER_NAME, .pm = &mmci_dev_pm_ops, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, .probe = mmci_probe, .remove = mmci_remove,
Greg Kroah-Hartman
maintainerPATCH 729/800 mmc: sdhci: fix DMA configure compatibility issue when 64bit DMA mode is used.
In reply to Greg Kroah-HartmanFrom: Chevron Li <[email protected]>
commit 20dbd07ef0a8bc29eb03d6a95258ac8934cbe52d upstream.
Bayhub SD host has hardware limitation:
1.The upper 32bit address is inhibited to be written at SD Host Register
[03E][13]=0 (32bits addressing) mode, is admitted to be written only at SD Host Register [03E][13]=1 (64bits addressing) mode.
2.Because of above item#1, need to configure SD Host Register [03E][13] to
1(64bits addressing mode) before set 64bit ADMA system address's higher 32bits SD Host Register [05F~05C] if 64 bits addressing mode is used.
The hardware limitation is reasonable for below reasons:
1.Normal flow should set DMA working mode first, then do
DMA-transfer-related configuration, such as system address.
2.The hardware limitation may avoid the software to configure wrong higher
32bit address at 32bits addressing mode although it is redundant.
The change that set 32bits/64bits addressing mode before set ADMA address,
has no side-effect to other host IPs for below reason:
The setting order is reasonable and standard: DMA Mode setting first and
then DMA address setting. It meets all DMA setting sequence.
--- drivers/mmc/host/sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +2 -2
@@ -1167,6 +1167,8 @@ static void sdhci_prepare_data(struct sd } } +sdhci_config_dma (host); +if (host->flags &SDHCI_REQ_USE_DMA ) {int sg_cnt =sdhci_pre_dma_transfer (host, data,COOKIE_MAPPED );
@@ -1186,8 +1188,6 @@ static void sdhci_prepare_data(struct sd } } -sdhci_config_dma (host); -if (!(host->flags &SDHCI_REQ_USE_DMA )) {int flags;
Greg Kroah-Hartman
maintainerPATCH 730/800 wifi: cfg80211: fix regulatory disconnect for non-MLO
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit b22552fcaf1970360005c805d7fba4046cf2ab4a upstream.
The multi-link loop here broke disconnect when multi-link operation (MLO) isn't active for a given interface, since in that case valid_links is 0 (indicating no links, i.e. no MLO.)
Fix this by taking that into account properly and skipping the link only if there are valid_links in the first place.
--- net/wireless/reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/reg.c +1 -1
@@ -2352,7 +2352,7 @@ static bool reg_wdev_chan_valid(struct wif (!wdev->valid_links && link >0 )break ; -if (!(wdev->valid_links &BIT (link))) +if (wdev->valid_links && !(wdev->valid_links &BIT (link)))continue ;switch (iftype) {case NL80211_IFTYPE_AP :
Greg Kroah-Hartman
maintainerPATCH 731/800 wifi: ath10k: Serialize wake_tx_queue ops
In reply to Greg Kroah-HartmanFrom: Alexander Wetzel <[email protected]>
commit b719ebc37a1eacd4fd4f1264f731b016e5ec0c6e upstream.
Serialize the ath10k implementation of the wake_tx_queue ops. ath10k_mac_op_wake_tx_queue() must not run concurrent since it's using ieee80211_txq_schedule_start().
The intend of this patch is to sort out an issue discovered in the discussion referred to by the Link tag.
I can't test it with real hardware and thus just implemented the per-ac queue lock Felix suggested. One obvious alternative to the per-ac lock would be to bring back the txqs_lock commit bb2edb733586 ("ath10k: migrate to mac80211 txq scheduling") dropped.
--- drivers/net/wireless/ath/ath10k/core.c | 3 +++ drivers/net/wireless/ath/ath10k/core.h | 3 +++ drivers/net/wireless/ath/ath10k/mac.c | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +3 -0
@@ -3634,6 +3634,9 @@ struct ath10k *ath10k_core_create(size_tmutex_init (&ar->dump_mutex);spin_lock_init (&ar->data_lock); +for (int ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) +spin_lock_init (&ar->queue_lock[ac]); +INIT_LIST_HEAD (&ar->peers);init_waitqueue_head (&ar->peer_mapping_wq);init_waitqueue_head (&ar->htt.empty_tx_wq);
drivers/net/wireless/ath/ath10k/core.h +3 -0
@@ -1170,6 +1170,9 @@ struct ath10k {/* protects shared structure data */ spinlock_t data_lock; +/* serialize wake_tx_queue calls per ac */ +spinlock_t queue_lock[IEEE80211_NUM_ACS ]; +struct list_head arvifs;struct list_head peers;struct ath10k_peer *peer_map[ATH10K_MAX_NUM_PEER_IDS ];
drivers/net/wireless/ath/ath10k/mac.c +4 -2
@@ -4732,13 +4732,14 @@ static void ath10k_mac_op_wake_tx_queue( {struct ath10k *ar = hw->priv;int ret; -u8 ac; +u8 ac = txq->ac;ath10k_htt_tx_txq_update (hw, txq);if (ar->htt.tx_q_state.mode !=HTT_TX_MODE_SWITCH_PUSH )return ; - ac = txq->ac; +spin_lock_bh (&ar->queue_lock[ac]); +ieee80211_txq_schedule_start (hw, ac); txq =ieee80211_next_txq (hw, ac);if (!txq)
@@ -4753,6 +4754,7 @@ static void ath10k_mac_op_wake_tx_queue(ath10k_htt_tx_txq_update (hw, txq); out:ieee80211_txq_schedule_end (hw, ac); +spin_unlock_bh (&ar->queue_lock[ac]); }/* Must not be called with conf_mutex held as workers can use that also. */
Greg Kroah-Hartman
maintainerPATCH 732/800 wifi: cfg80211: fix receiving mesh packets without RFC1042 header
In reply to Greg Kroah-HartmanFrom: Felix Fietkau <[email protected]>
commit fec3ebb5ed299ac3a998f011c380f2ded47f4866 upstream.
Fix ethernet header length field after stripping the mesh header
--- net/wireless/util.c | 2 ++ 1 file changed, 2 insertions(+)
net/wireless/util.c +2 -0
@@ -580,6 +580,8 @@ int ieee80211_strip_8023_mesh_hdr(struct sk_buff *skb) hdrlen +=ETH_ALEN +2 ; else if (!pskb_may_pull(skb, hdrlen)) return -EINVAL; + else + payload.eth.h_proto = htons(skb->len - hdrlen); mesh_addr = skb->data +sizeof (payload.eth) +ETH_ALEN ;switch (payload.flags &MESH_FLAGS_AE ) {
Signature · 1 line
2.41.0
Greg Kroah-Hartman
maintainerPATCH 733/800 wifi: mt76: mt7921e: fix init command fail with enabled device
In reply to Greg Kroah-HartmanFrom: Quan Zhou <[email protected]>
commit 525c469e5de9bf7e53574396196e80fc716ac9eb upstream.
For some cases as below, we may encounter the unpreditable chip stats in driver probe()
* The system reboot flow do not work properly, such as kernel oops while rebooting, and then the driver do not go back to default status at this moment.
* Similar to the flow above. If the device was enabled in BIOS or UEFI, the system may switch to Linux without driver fully shutdown.
To avoid the problem, force push the device back to default in probe()
* mt7921e_mcu_fw_pmctrl() : return control privilege to chip side.
* mt7921_wfsys_reset() : cleanup chip config before resource init.
Error log
[59007.600714] mt7921e 0000:02:00.0: ASIC revision: 79220010 [59010.889773] mt7921e 0000:02:00.0: Message 00000010 (seq 1) timeout [59010.889786] mt7921e 0000:02:00.0: Failed to get patch semaphore [59014.217839] mt7921e 0000:02:00.0: Message 00000010 (seq 2) timeout [59014.217852] mt7921e 0000:02:00.0: Failed to get patch semaphore [59017.545880] mt7921e 0000:02:00.0: Message 00000010 (seq 3) timeout [59017.545893] mt7921e 0000:02:00.0: Failed to get patch semaphore [59020.874086] mt7921e 0000:02:00.0: Message 00000010 (seq 4) timeout [59020.874099] mt7921e 0000:02:00.0: Failed to get patch semaphore [59024.202019] mt7921e 0000:02:00.0: Message 00000010 (seq 5) timeout [59024.202033] mt7921e 0000:02:00.0: Failed to get patch semaphore [59027.530082] mt7921e 0000:02:00.0: Message 00000010 (seq 6) timeout [59027.530096] mt7921e 0000:02:00.0: Failed to get patch semaphore [59030.857888] mt7921e 0000:02:00.0: Message 00000010 (seq 7) timeout [59030.857904] mt7921e 0000:02:00.0: Failed to get patch semaphore [59034.185946] mt7921e 0000:02:00.0: Message 00000010 (seq 8) timeout [59034.185961] mt7921e 0000:02:00.0: Failed to get patch semaphore [59037.514249] mt7921e 0000:02:00.0: Message 00000010 (seq 9) timeout [59037.514262] mt7921e 0000:02:00.0: Failed to get patch semaphore [59040.842362] mt7921e 0000:02:00.0: Message 00000010 (seq 10) timeout [59040.842375] mt7921e 0000:02:00.0: Failed to get patch semaphore [59040.923845] mt7921e 0000:02:00.0: hardware init failed
Message-ID: <39fcb7cee08d4ab940d38d82f21897483212483f.1688569385.git.deren.wu@mediatek.com>
--- drivers/net/wireless/mediatek/mt76/mt7921/dma.c | 4 ---- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 8 -------- drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 8 ++++++++ 3 files changed, 8 insertions(+), 12 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/dma.c +0 -4
@@ -231,10 +231,6 @@ int mt7921_dma_init(struct mt7921_dev *dif (ret)return ret; - ret =mt7921_wfsys_reset (dev); -if (ret) -return ret; -/* init tx queue */ ret = mt76_connac_init_tx_queues(dev->phy.mt76, MT7921_TXQ_BAND0, MT7921_TX_RING_SIZE,
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +0 -8
@@ -476,12 +476,6 @@ static int mt7921_load_firmware(struct m {int ret; - ret =mt76_get_field (dev,MT_CONN_ON_MISC ,MT_TOP_MISC2_FW_N9_RDY ); -if (ret &&mt76_is_mmio (&dev->mt76)) { -dev_dbg (dev->mt76.dev,"Firmware is already download\n" ); - goto fw_loaded; - } - ret =mt76_connac2_load_patch (&dev->mt76,mt7921_patch_name (dev));if (ret)return ret;
@@ -504,8 +498,6 @@ static int mt7921_load_firmware(struct mreturn -EIO ; } -fw_loaded: -#ifdef CONFIG_PM dev->mt76.hw->wiphy->wowlan = &mt76_connac_wowlan_support;#endif /* CONFIG_PM */
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +8 -0
@@ -325,6 +325,10 @@ static int mt7921_pci_probe(struct pci_d bus_ops->rmw = mt7921_rmw; dev->mt76.bus = bus_ops; + ret =mt7921e_mcu_fw_pmctrl (dev); +if (ret) + goto err_free_dev; + ret =__mt7921e_mcu_drv_pmctrl (dev);if (ret) goto err_free_dev;
@@ -333,6 +337,10 @@ static int mt7921_pci_probe(struct pci_d (mt7921_l1_rr (dev,MT_HW_REV ) &0xff );dev_info (mdev->dev,"ASIC revision: %04x\n" , mdev->rev); + ret =mt7921_wfsys_reset (dev); +if (ret) + goto err_free_dev; +mt76_wr (dev,MT_WFDMA0_HOST_INT_ENA ,0 );mt76_wr (dev,MT_PCIE_MAC_INT_ENABLE ,0xff );
Greg Kroah-Hartman
maintainerPATCH 734/800 bcache: fixup btree_cache_wait list damage
In reply to Greg Kroah-HartmanFrom: Mingzhe Zou <[email protected]>
commit f0854489fc07d2456f7cc71a63f4faf9c716ffbe upstream.
We get a kernel crash about "list_add corruption. next->prev should be prev (ffff9c801bc01210), but was ffff9c77b688237c. (next=ffffae586d8afe68)."
crash> struct list_head 0xffff9c801bc01210
struct list_head {
next = 0xffffae586d8afe68,
prev = 0xffffae586d8afe68
}
crash> struct list_head 0xffff9c77b688237c
struct list_head {
next = 0x0,
prev = 0x0
}
crash> struct list_head 0xffffae586d8afe68
struct list_head struct: invalid kernel virtual address: ffffae586d8afe68 type: "gdb_readmem_callback" Cannot access memory at address 0xffffae586d8afe68
[230469.019492] Call Trace: [230469.032041] prepare_to_wait+0x8a/0xb0 [230469.044363] ? bch_btree_keys_free+0x6c/0xc0 [escache] [230469.056533] mca_cannibalize_lock+0x72/0x90 [escache] [230469.068788] mca_alloc+0x2ae/0x450 [escache] [230469.080790] bch_btree_node_get+0x136/0x2d0 [escache] [230469.092681] bch_btree_check_thread+0x1e1/0x260 [escache] [230469.104382] ? finish_wait+0x80/0x80 [230469.115884] ? bch_btree_check_recurse+0x1a0/0x1a0 [escache] [230469.127259] kthread+0x112/0x130 [230469.138448] ? kthread_flush_work_fn+0x10/0x10 [230469.149477] ret_from_fork+0x35/0x40
bch_btree_check_thread() and bch_dirty_init_thread() may call mca_cannibalize() to cannibalize other cached btree nodes. Only one thread can do it at a time, so the op of other threads will be added to the btree_cache_wait list.
We must call finish_wait() to remove op from btree_cache_wait before free it's memory address. Otherwise, the list will be damaged. Also should call bch_cannibalize_unlock() to release the btree_cache_alloc_lock and wake_up other waiters.
--- drivers/md/bcache/btree.c | 11 ++++++++++- drivers/md/bcache/btree.h | 1 + drivers/md/bcache/writeback.c | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +10 -1
@@ -885,7 +885,7 @@ static struct btree *mca_cannibalize(str* cannibalize_bucket() will take. This means every time we unlock the root of * the btree, we need to release this lock if we have it held. */ -static void bch_cannibalize_unlock (struct cache_set *c) +void bch_cannibalize_unlock (struct cache_set *c) {spin_lock (&c->btree_cannibalize_lock);if (c->btree_cache_alloc_lock == current) {
@@ -1968,6 +1968,15 @@ static int bch_btree_check_thread(void * c->gc_stats.nodes++;bch_btree_op_init (&op,0 ); ret =bcache_btree (check_recurse, p, c->root, &op); +/* +* The op may be added to cache_set's btree_cache_wait +* in mca_cannibalize(), must ensure it is removed from +* the list and release btree_cache_alloc_lock before +* free op memory. +* Otherwise, the btree_cache_wait will be damaged. +*/ +bch_cannibalize_unlock (c); +finish_wait (&c->btree_cache_wait, &(&op)->wait);if (ret) goto out; }
drivers/md/bcache/btree.h +1 -0
@@ -282,6 +282,7 @@ void bch_initial_gc_finish(struct cache_void bch_moving_gc (struct cache_set *c);int bch_btree_check (struct cache_set *c);void bch_initial_mark_key (struct cache_set *c,int level,struct bkey *k); +void bch_cannibalize_unlock (struct cache_set *c);static inline void wake_up_gc (struct cache_set *c) {
drivers/md/bcache/writeback.c +10 -0
@@ -890,6 +890,16 @@ static int bch_root_node_dirty_init(struif (ret <0 )pr_warn ("sectors dirty init failed, ret=%d!\n" , ret); +/* +* The op may be added to cache_set's btree_cache_wait +* in mca_cannibalize(), must ensure it is removed from +* the list and release btree_cache_alloc_lock before +* free op memory. +* Otherwise, the btree_cache_wait will be damaged. +*/ +bch_cannibalize_unlock (c); +finish_wait (&c->btree_cache_wait, &(&op.op)->wait); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 735/800 bcache: Remove unnecessary NULL point check in node allocations
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
commit 028ddcac477b691dd9205c92f991cc15259d033e upstream.
Due to the previous fix of __bch_btree_node_alloc, the return value will never be a NULL pointer. So IS_ERR is enough to handle the failure situation. Fix it by replacing IS_ERR_OR_NULL check by an IS_ERR check.
--- drivers/md/bcache/btree.c | 10 +++++----- drivers/md/bcache/super.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/md/bcache/btree.c +5 -5
@@ -1138,7 +1138,7 @@ static struct btree *btree_node_alloc_re {struct btree *n =bch_btree_node_alloc (b->c, op, b->level, b->parent); -if (!IS_ERR_OR_NULL (n)) { +if (!IS_ERR (n)) {mutex_lock (&n->write_lock);bch_btree_sort_into (&b->keys, &n->keys, &b->c->sort);bkey_copy_key (&n->key, &b->key);
@@ -1340,7 +1340,7 @@ static int btree_gc_coalesce(struct btrememset (new_nodes,0 ,sizeof (new_nodes));closure_init_stack (&cl); -while (nodes <GC_MERGE_NODES && !IS_ERR_OR_NULL (r[nodes].b)) +while (nodes <GC_MERGE_NODES && !IS_ERR (r[nodes].b)) keys += r[nodes++].keys; blocks =btree_default_blocks (b->c) *2 /3 ;
@@ -1352,7 +1352,7 @@ static int btree_gc_coalesce(struct btrefor (i =0 ; i < nodes; i++) { new_nodes[i] =btree_node_alloc_replacement (r[i].b,NULL ); -if (IS_ERR_OR_NULL (new_nodes[i])) +if (IS_ERR (new_nodes[i])) goto out_nocoalesce; }
@@ -1487,7 +1487,7 @@ out_nocoalesce:bch_keylist_free (&keylist);for (i =0 ; i < nodes; i++) -if (!IS_ERR_OR_NULL (new_nodes[i])) { +if (!IS_ERR (new_nodes[i])) {btree_node_free (new_nodes[i]);rw_unlock (true, new_nodes[i]); }
@@ -1669,7 +1669,7 @@ static int bch_btree_gc_root(struct btreif (should_rewrite) { n =btree_node_alloc_replacement (b,NULL ); -if (!IS_ERR_OR_NULL (n)) { +if (!IS_ERR (n)) {bch_btree_node_write_sync (n);bch_btree_set_root (n);
drivers/md/bcache/super.c +2 -2
@@ -1723,7 +1723,7 @@ static void cache_set_flush(struct closuif (!IS_ERR_OR_NULL (c->gc_thread))kthread_stop (c->gc_thread); -if (!IS_ERR_OR_NULL (c->root)) +if (!IS_ERR (c->root))list_add (&c->root->list, &c->btree_cache);/*
@@ -2087,7 +2087,7 @@ static int run_cache_set(struct cache_se err ="cannot allocate new btree root" ; c->root =__bch_btree_node_alloc (c,NULL ,0 , true,NULL ); -if (IS_ERR_OR_NULL (c->root)) +if (IS_ERR (c->root)) goto err;mutex_lock (&c->root->write_lock);
Greg Kroah-Hartman
maintainerPATCH 736/800 bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
commit 80fca8a10b604afad6c14213fdfd816c4eda3ee4 upstream.
In some specific situations, the return value of __bch_btree_node_alloc may be NULL. This may lead to a potential NULL pointer dereference in caller function like a calling chain :btree_split->bch_btree_node_alloc->__bch_btree_node_alloc.
Fix it by initializing the return value in __bch_btree_node_alloc.
--- drivers/md/bcache/btree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +3 -1
@@ -1090,10 +1090,12 @@ struct btree *__bch_btree_node_alloc(str struct btree *parent) {BKEY_PADDED (key) k; -struct btree *b =ERR_PTR (-EAGAIN ); +struct btree *b;mutex_lock (&c->bucket_lock); retry: +/* return ERR_PTR(-EAGAIN) when it fails */ + b =ERR_PTR (-EAGAIN );if (__bch_bucket_alloc_set (c,RESERVE_BTREE , &k.key, wait)) goto err;
Greg Kroah-Hartman
maintainerPATCH 737/800 watch_queue: prevent dangling pipe pointer
In reply to Greg Kroah-HartmanFrom: Siddh Raman Pant <[email protected]>
commit 943211c87427f25bd22e0e63849fb486bb5f87fa upstream.
NULL the dangling pipe reference while clearing watch_queue.
If not done, a reference to a freed pipe remains in the watch_queue, as this function is called before freeing a pipe in free_pipe_info() (see line 834 of fs/pipe.c).
The sole use of wqueue->defunct is for checking if the watch queue has been cleared, but wqueue->pipe is also NULLed while clearing.
Thus, wqueue->defunct is superfluous, as wqueue->pipe can be checked for NULL. Hence, the former can be removed.
Tested with keyutils testsuite.
Message-Id: <[email protected]>
--- include/linux/watch_queue.h | 3 +-- kernel/watch_queue.c | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-)
include/linux/watch_queue.h +1 -2
@@ -38,7 +38,7 @@ struct watch_filter {struct watch_queue {struct rcu_head rcu;struct watch_filter __rcu *filter; -struct pipe_inode_info *pipe;/* The pipe we're using as a buffer */ +struct pipe_inode_info *pipe;/* Pipe we use as a buffer, NULL if queue closed */ struct hlist_head watches;/* Contributory watches */ struct page **notes;/* Preallocated notifications */ unsigned long *notes_bitmap;/* Allocation bitmap for notes */
@@ -46,7 +46,6 @@ struct watch_queue {spinlock_t lock;unsigned int nr_notes;/* Number of notes */ unsigned int nr_pages;/* Number of pages in notes[] */ -bool defunct;/* T when queues closed */ };/*
kernel/watch_queue.c +6 -6
@@ -42,7 +42,7 @@ MODULE_AUTHOR("Red Hat, Inc.");static inline bool lock_wqueue (struct watch_queue *wqueue) {spin_lock_bh (&wqueue->lock); -if (unlikely (wqueue->defunct)) { +if (unlikely (!wqueue->pipe)) {spin_unlock_bh (&wqueue->lock);return false; }
@@ -104,9 +104,6 @@ static bool post_one_notification(structunsigned int head, tail, mask, note, offset, len;bool done = false; -if (!pipe) -return false; -spin_lock_irq (&pipe->rd_wait.lock); mask = pipe->ring_size -1 ;
@@ -603,8 +600,11 @@ void watch_queue_clear(struct watch_queurcu_read_lock ();spin_lock_bh (&wqueue->lock); -/* Prevent new notifications from being stored. */ - wqueue->defunct = true; +/* +* This pipe can be freed by callers like free_pipe_info(). +* Removing this reference also prevents new notifications. +*/ + wqueue->pipe =NULL ;while (!hlist_empty (&wqueue->watches)) { watch = hlist_entry(wqueue->watches.first, struct watch, queue_node);
Greg Kroah-Hartman
maintainerPATCH 738/800 um: Use HOST_DIR for mrproper
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit a5a319ec2c2236bb96d147c16196d2f1f3799301 upstream.
When HEADER_ARCH was introduced, the MRPROPER_FILES (then MRPROPER_DIRS) list wasn't adjusted, leaving SUBARCH as part of the path argument. This resulted in the "mrproper" target not cleaning up arch/x86/... when SUBARCH was specified. Since HOST_DIR is arch/$(HEADER_ARCH), use it instead to get the correct path.
--- arch/um/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/Makefile +1 -1
@@ -149,7 +149,7 @@ export CFLAGS_vmlinux := $(LINK-y) $(LIN # When cleaning we don't include .config, so we don't include # TT or skas makefiles and don't clean skas_ptregs.h. CLEAN_FILES += linux x.i gmon.out -MRPROPER_FILES += arch/$(SUBARCH)/include/generated +MRPROPER_FILES += $(HOST_DIR)/include/generated archclean: @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
Greg Kroah-Hartman
maintainerPATCH 739/800 integrity: Fix possible multiple allocation in integrity_inode_get()
In reply to Greg Kroah-HartmanFrom: Tianjia Zhang <[email protected]>
commit 9df6a4870dc371136e90330cfbbc51464ee66993 upstream.
When integrity_inode_get() is querying and inserting the cache, there is a conditional race in the concurrent environment.
The race condition is the result of not properly implementing "double-checked locking". In this case, it first checks to see if the iint cache record exists before taking the lock, but doesn't check again after taking the integrity_iint_lock.
--- security/integrity/iint.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
security/integrity/iint.c +9 -6
@@ -43,12 +43,10 @@ static struct integrity_iint_cache *__inelse if (inode > iint->inode) n = n->rb_right;else -break ; +return iint; } -if (!n) -return NULL ; -return iint; +return NULL ; }/*
@@ -113,10 +111,15 @@ struct integrity_iint_cache *integrity_i parent = *p; test_iint = rb_entry(parent, struct integrity_iint_cache, rb_node); -if (inode < test_iint->inode) +if (inode < test_iint->inode) { p = &(*p)->rb_left; -else + }else if (inode > test_iint->inode) { p = &(*p)->rb_right; + }else { +write_unlock (&integrity_iint_lock); +kmem_cache_free (iint_cache, iint); +return test_iint; + } } iint->inode = inode;
Greg Kroah-Hartman
maintainerPATCH 740/800 autofs: use flexible array in ioctl structure
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit e910c8e3aa02dc456e2f4c32cb479523c326b534 upstream.
Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") introduced a warning for the autofs_dev_ioctl structure:
In function 'check_name',
inlined from 'validate_dev_ioctl' at fs/autofs/dev-ioctl.c:131:9,
inlined from '_autofs_dev_ioctl' at fs/autofs/dev-ioctl.c:624:8:fs/autofs/dev-ioctl.c:33:14: error: 'strchr' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
33 | if (!strchr(name, '/'))
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/auto_dev-ioctl.h:10,
from fs/autofs/autofs_i.h:10,
from fs/autofs/dev-ioctl.c:14:
include/uapi/linux/auto_dev-ioctl.h: In function '_autofs_dev_ioctl':
include/uapi/linux/auto_dev-ioctl.h:112:14: note: source object 'path' of size 0
112 | char path[0];
| ^~~~This is easily fixed by changing the gnu 0-length array into a c99 flexible array. Since this is a uapi structure, we have to be careful about possible regressions but this one should be fine as they are equivalent here. While it would break building with ancient gcc versions that predate c99, it helps building with --std=c99 and -Wpedantic builds in user space, as well as non-gnu compilers. This means we probably also want it fixed in stable kernels.
--- Documentation/filesystems/autofs-mount-control.rst | 2 +- Documentation/filesystems/autofs.rst | 2 +- include/uapi/linux/auto_dev-ioctl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Documentation/filesystems/autofs-mount-control.rst +1 -1
@@ -196,7 +196,7 @@ information and return operation results struct args_ismountpoint ismountpoint; }; - char path[0]; + char path[]; }; The ioctlfd field is a mount point file descriptor of an autofs mount
Documentation/filesystems/autofs.rst +1 -1
@@ -467,7 +467,7 @@ Each ioctl is passed a pointer to an `au struct args_ismountpoint ismountpoint; }; - char path[0]; + char path[]; }; For the **OPEN_MOUNT** and **IS_MOUNTPOINT** commands, the target
include/uapi/linux/auto_dev-ioctl.h +1 -1
@@ -109,7 +109,7 @@ struct autofs_dev_ioctl {struct args_ismountpoint ismountpoint; }; -char path[0 ]; +char path[]; };static inline void init_autofs_dev_ioctl (struct autofs_dev_ioctl *in)
Greg Kroah-Hartman
maintainerPATCH 741/800 mm/damon/ops-common: atomically test and clear young on ptes and pmds
In reply to Greg Kroah-HartmanFrom: Ryan Roberts <[email protected]>
commit c11d34fa139e4b0fb4249a30f37b178353533fa1 upstream.
It is racy to non-atomically read a pte, then clear the young bit, then write it back as this could discard dirty information. Further, it is bad practice to directly set a pte entry within a table. Instead clearing young must go through the arch-provided helper, ptep_test_and_clear_young() to ensure it is modified atomically and to give the arch code visibility and allow it to check (and potentially modify) the operation.
--- mm/damon/ops-common.c | 16 ++++++---------- mm/damon/ops-common.h | 4 ++-- mm/damon/paddr.c | 4 ++-- mm/damon/vaddr.c | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-)
mm/damon/ops-common.c +6 -10
@@ -37,7 +37,7 @@ struct folio *damon_get_folio(unsigned lreturn folio; } -void damon_ptep_mkold (pte_t *pte,struct mm_struct *mm,unsigned long addr) +void damon_ptep_mkold (pte_t *pte,struct vm_area_struct *vma,unsigned long addr) {bool referenced = false;struct folio *folio =damon_get_folio (pte_pfn (*pte));
@@ -45,13 +45,11 @@ void damon_ptep_mkold(pte_t *pte, structif (!folio)return ; -if (pte_young (*pte)) { +if (ptep_test_and_clear_young (vma, addr, pte)) referenced = true; - *pte =pte_mkold (*pte); - }#ifdef CONFIG_MMU_NOTIFIER -if (mmu_notifier_clear_young (mm, addr, addr +PAGE_SIZE )) +if (mmu_notifier_clear_young (vma->vm_mm, addr, addr +PAGE_SIZE )) referenced = true;#endif /* CONFIG_MMU_NOTIFIER */
@@ -62,7 +60,7 @@ void damon_ptep_mkold(pte_t *pte, structfolio_put (folio); } -void damon_pmdp_mkold (pmd_t *pmd,struct mm_struct *mm,unsigned long addr) +void damon_pmdp_mkold (pmd_t *pmd,struct vm_area_struct *vma,unsigned long addr) {#ifdef CONFIG_TRANSPARENT_HUGEPAGE bool referenced = false;
@@ -71,13 +69,11 @@ void damon_pmdp_mkold(pmd_t *pmd, structif (!folio)return ; -if (pmd_young (*pmd)) { +if (pmdp_test_and_clear_young (vma, addr, pmd)) referenced = true; - *pmd =pmd_mkold (*pmd); - }#ifdef CONFIG_MMU_NOTIFIER -if (mmu_notifier_clear_young (mm, addr, addr +HPAGE_PMD_SIZE )) +if (mmu_notifier_clear_young (vma->vm_mm, addr, addr +HPAGE_PMD_SIZE )) referenced = true;#endif /* CONFIG_MMU_NOTIFIER */
mm/damon/ops-common.h +2 -2
@@ -9,8 +9,8 @@struct folio *damon_get_folio (unsigned long pfn); -void damon_ptep_mkold (pte_t *pte,struct mm_struct *mm,unsigned long addr); -void damon_pmdp_mkold (pmd_t *pmd,struct mm_struct *mm,unsigned long addr); +void damon_ptep_mkold (pte_t *pte,struct vm_area_struct *vma,unsigned long addr); +void damon_pmdp_mkold (pmd_t *pmd,struct vm_area_struct *vma,unsigned long addr);int damon_cold_score (struct damon_ctx *c,struct damon_region *r,struct damos *s);
mm/damon/paddr.c +2 -2
@@ -24,9 +24,9 @@ static bool __damon_pa_mkold(struct foliwhile (page_vma_mapped_walk (&pvmw)) { addr = pvmw.address;if (pvmw.pte) -damon_ptep_mkold (pvmw.pte, vma->vm_mm, addr); +damon_ptep_mkold (pvmw.pte, vma, addr);else -damon_pmdp_mkold (pvmw.pmd, vma->vm_mm, addr); +damon_pmdp_mkold (pvmw.pmd, vma, addr); }return true; }
mm/damon/vaddr.c +2 -2
@@ -311,7 +311,7 @@ static int damon_mkold_pmd_entry(pmd_t * }if (pmd_trans_huge (*pmd)) { -damon_pmdp_mkold (pmd, walk->mm, addr); +damon_pmdp_mkold (pmd, walk->vma, addr);spin_unlock (ptl);return 0 ; }
@@ -323,7 +323,7 @@ static int damon_mkold_pmd_entry(pmd_t * pte =pte_offset_map_lock (walk->mm, pmd, addr, &ptl);if (!pte_present (*pte)) goto out; -damon_ptep_mkold (pte, walk->mm, addr); +damon_ptep_mkold (pte, walk->vma, addr); out:pte_unmap_unlock (pte, ptl);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 742/800 shmem: use ramfs_kill_sb() for kill_sb method of ramfs-based tmpfs
In reply to Greg Kroah-HartmanFrom: Roberto Sassu <[email protected]>
commit 36ce9d76b0a93bae799e27e4f5ac35478c676592 upstream.
As the ramfs-based tmpfs uses ramfs_init_fs_context() for the init_fs_context method, which allocates fc->s_fs_info, use ramfs_kill_sb() to free it and avoid a memory leak.
--- fs/ramfs/inode.c | 2 +- include/linux/ramfs.h | 1 + mm/shmem.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)
fs/ramfs/inode.c +1 -1
@@ -278,7 +278,7 @@ int ramfs_init_fs_context(struct fs_contreturn 0 ; } -static void ramfs_kill_sb (struct super_block *sb) +void ramfs_kill_sb (struct super_block *sb) {kfree (sb->s_fs_info);kill_litter_super (sb);
include/linux/ramfs.h +1 -0
@@ -7,6 +7,7 @@struct inode *ramfs_get_inode (struct super_block *sb,const struct inode *dir,umode_t mode,dev_t dev);extern int ramfs_init_fs_context (struct fs_context *fc); +extern void ramfs_kill_sb (struct super_block *sb);#ifdef CONFIG_MMU static inline int
mm/shmem.c +1 -1
@@ -4196,7 +4196,7 @@ static struct file_system_type shmem_fs_ .name = "tmpfs", .init_fs_context = ramfs_init_fs_context, .parameters = ramfs_fs_parameters, - .kill_sb = kill_litter_super, + .kill_sb = ramfs_kill_sb, .fs_flags = FS_USERNS_MOUNT, };
Greg Kroah-Hartman
maintainerPATCH 743/800 nfsd: use vfs setgid helper
In reply to Greg Kroah-HartmanFrom: Christian Brauner <[email protected]>
commit 2d8ae8c417db284f598dffb178cc01e7db0f1821 upstream.
We've aligned setgid behavior over multiple kernel releases. The details can be found in commit cf619f891971 ("Merge tag 'fs.ovl.setgid.v6.2' ofgit://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping") and commit 426b4ca2d6a5 ("Merge tag 'fs.setgid.v6.0' ofgit://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux").
Consistent setgid stripping behavior is now encapsulated in the setattr_should_drop_sgid() helper which is used by all filesystems that strip setgid bits outside of vfs proper. Usually ATTR_KILL_SGID is raised in e.g., chown_common() and is subject to the setattr_should_drop_sgid() check to determine whether the setgid bit can be retained. Since nfsd is raising ATTR_KILL_SGID unconditionally it will cause notify_change() to strip it even if the caller had the necessary privileges to retain it. Ensure that nfsd only raises ATR_KILL_SGID if the caller lacks the necessary privileges to retain the setgid bit.
Without this patch the setgid stripping tests in LTP will fail:
Quoted 2 lines
As you can see, the problem is
S_ISGID(0002000) was dropped on a non-group-executable file while chown was invoked by super-user, while
[...]
Quoted 1 line
fchown02.c:66: TFAIL: testfile2: wrong mode permissions 0100700, expected 0102700
[...]
Quoted 1 line
chown02.c:57: TFAIL: testfile2: wrong mode permissions 0100700, expected 0102700
With this patch all tests pass.
--- fs/nfsd/vfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/vfs.c +3 -1
@@ -388,7 +388,9 @@ nfsd_sanitize_attrs(struct inode *inode, iap->ia_mode &= ~S_ISGID ; }else {/* set ATTR_KILL_* bits and let VFS handle it */ - iap->ia_valid |= (ATTR_KILL_SUID |ATTR_KILL_SGID ); + iap->ia_valid |=ATTR_KILL_SUID ; + iap->ia_valid |= +setattr_should_drop_sgid (&nop_mnt_idmap, inode); } } }
Greg Kroah-Hartman
maintainerPATCH 744/800 jffs2: reduce stack usage in jffs2_build_xattr_subsystem()
In reply to Greg Kroah-HartmanFrom: Fabian Frederick <[email protected]>
commit 1168f095417643f663caa341211e117db552989f upstream.
Use kcalloc() for allocation/flush of 128 pointers table to reduce stack usage.
Function now returns -ENOMEM or 0 on success.
stackusage
Before:./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 1208
dynamic,bounded
After:./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 192
dynamic,bounded
Also update definition when CONFIG_JFFS2_FS_XATTR is not enabled
Tested with an MTD mount point and some user set/getfattr.
Many current target on OpenWRT also suffer from a compilation warning (that become an error with CONFIG_WERROR) with the following output:
fs/jffs2/xattr.c: In function 'jffs2_build_xattr_subsystem':fs/jffs2/xattr.c:887:1: error: the frame size of 1088 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
887 | }
| ^
Using dynamic allocation fix this compilation warning.
Message-Id: <[email protected]>
--- fs/jffs2/build.c | 5 ++++- fs/jffs2/xattr.c | 13 +++++++++---- fs/jffs2/xattr.h | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-)
fs/jffs2/build.c +4 -1
@@ -211,7 +211,10 @@ static int jffs2_build_filesystem(struct ic->scan_dents =NULL ;cond_resched (); } -jffs2_build_xattr_subsystem (c); + ret =jffs2_build_xattr_subsystem (c); +if (ret) + goto exit; + c->flags &= ~JFFS2_SB_FLAG_BUILDING ;dbg_fsbuild ("FS build complete\n" );
fs/jffs2/xattr.c +9 -4
@@ -772,10 +772,10 @@ void jffs2_clear_xattr_subsystem(struct }#define XREF_TMPHASH_SIZE (128) -void jffs2_build_xattr_subsystem (struct jffs2_sb_info *c) +int jffs2_build_xattr_subsystem (struct jffs2_sb_info *c) {struct jffs2_xattr_ref *ref, *_ref; -struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE ]; +struct jffs2_xattr_ref **xref_tmphash;struct jffs2_xattr_datum *xd, *_xd;struct jffs2_inode_cache *ic;struct jffs2_raw_node_ref *raw;
@@ -784,9 +784,12 @@ void jffs2_build_xattr_subsystem(structBUG_ON (!(c->flags &JFFS2_SB_FLAG_BUILDING )); + xref_tmphash =kcalloc (XREF_TMPHASH_SIZE , +sizeof (struct jffs2_xattr_ref *),GFP_KERNEL ); +if (!xref_tmphash) +return -ENOMEM ; +/* Phase.1 : Merge same xref */ -for (i=0 ; i <XREF_TMPHASH_SIZE ; i++) - xref_tmphash[i] =NULL ;for (ref=c->xref_temp; ref; ref=_ref) {struct jffs2_xattr_ref *tmp;
@@ -884,6 +887,8 @@ void jffs2_build_xattr_subsystem(struct"%u of xref (%u dead, %u orphan) found.\n" , xdatum_count, xdatum_unchecked_count, xdatum_orphan_count, xref_count, xref_dead_count, xref_orphan_count); +kfree (xref_tmphash); +return 0 ; } struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
fs/jffs2/xattr.h +2 -2
@@ -71,7 +71,7 @@ static inline int is_xattr_ref_dead(stru#ifdef CONFIG_JFFS2_FS_XATTR extern void jffs2_init_xattr_subsystem (struct jffs2_sb_info *c); -extern void jffs2_build_xattr_subsystem (struct jffs2_sb_info *c); +extern int jffs2_build_xattr_subsystem (struct jffs2_sb_info *c);extern void jffs2_clear_xattr_subsystem (struct jffs2_sb_info *c); extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
@@ -103,7 +103,7 @@ extern ssize_t jffs2_listxattr(struct de#else #define jffs2_init_xattr_subsystem (c) -#define jffs2_build_xattr_subsystem (c) +#define jffs2_build_xattr_subsystem (c) (0)#define jffs2_clear_xattr_subsystem (c)#define jffs2_xattr_do_crccheck_inode (c, ic)
Greg Kroah-Hartman
maintainerPATCH 745/800 fs: avoid empty option when generating legacy mount string
In reply to Greg Kroah-HartmanFrom: Thomas Weißschuh <[email protected]>
commit 62176420274db5b5127cd7a0083a9aeb461756ee upstream.
As each option string fragment is always prepended with a comma it would happen that the whole string always starts with a comma. This could be interpreted by filesystem drivers as an empty option and may produce errors.
For example the NTFS driver from ntfs.ko behaves like this and fails when mounted via the new API.
Message-Id: <[email protected]>
--- fs/fs_context.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/fs_context.c +2 -1
@@ -561,7 +561,8 @@ static int legacy_parse_param(struct fs_return -ENOMEM ; } - ctx->legacy_data[size++] =',' ; +if (size) + ctx->legacy_data[size++] =',' ; len =strlen (param->key);memcpy (ctx->legacy_data + size, param->key, len); size += len;
Greg Kroah-Hartman
maintainerPATCH 746/800 ext4: Remove ext4 locking of moved directory
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 3658840cd363f2be094f5dfd2f0b174a9055dd0f upstream.
Remove locking of moved directory in ext4_rename2(). We will take care of it in VFS instead. This effectively reverts commit 0813299c586b ("ext4: Fix possible corruption when moving a directory") and followup fixes.
Message-Id: <[email protected]>
--- fs/ext4/namei.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
fs/ext4/namei.c +2 -15
@@ -3834,19 +3834,10 @@ static int ext4_rename(struct mnt_idmapreturn retval; } -/* -* We need to protect against old.inode directory getting converted -* from inline directory format into a normal one. -*/ -if (S_ISDIR (old.inode->i_mode)) -inode_lock_nested (old.inode,I_MUTEX_NONDIR2 ); - old.bh =ext4_find_entry (old.dir, &old.dentry->d_name, &old.de, &old.inlined); -if (IS_ERR (old.bh)) { - retval =PTR_ERR (old.bh); - goto unlock_moved_dir; - } +if (IS_ERR (old.bh)) +return PTR_ERR (old.bh);/* * Check for inode number is _not_ due to possible IO errors.
@@ -4043,10 +4034,6 @@ release_bh:brelse (old.bh);brelse (new.bh); -unlock_moved_dir: -if (S_ISDIR (old.inode->i_mode)) -inode_unlock (old.inode); -return retval; }
Greg Kroah-Hartman
maintainerPATCH 747/800 Revert "f2fs: fix potential corruption when moving a directory"
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit cde3c9d7e2a359e337216855dcb333a19daaa436 upstream.
This reverts commit d94772154e524b329a168678836745d2773a6e02. The locking is going to be provided by VFS.
Message-Id: <[email protected]>
--- fs/f2fs/namei.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
fs/f2fs/namei.c +1 -15
@@ -995,20 +995,12 @@ static int f2fs_rename(struct mnt_idmap goto out; } -/* -* Copied from ext4_rename: we need to protect against old.inode -* directory getting converted from inline directory format into -* a normal one. -*/ -if (S_ISDIR (old_inode->i_mode)) -inode_lock_nested (old_inode,I_MUTEX_NONDIR2 ); - err = -ENOENT ; old_entry =f2fs_find_entry (old_dir, &old_dentry->d_name, &old_page);if (!old_entry) {if (IS_ERR (old_page)) err =PTR_ERR (old_page); - goto out_unlock_old; + goto out; }if (S_ISDIR (old_inode->i_mode)) {
@@ -1116,9 +1108,6 @@ static int f2fs_rename(struct mnt_idmapf2fs_unlock_op (sbi); -if (S_ISDIR (old_inode->i_mode)) -inode_unlock (old_inode); -if (IS_DIRSYNC (old_dir) ||IS_DIRSYNC (new_dir))f2fs_sync_fs (sbi->sb,1 );
@@ -1133,9 +1122,6 @@ out_dir:f2fs_put_page (old_dir_page,0 ); out_old:f2fs_put_page (old_page,0 ); -out_unlock_old: -if (S_ISDIR (old_inode->i_mode)) -inode_unlock (old_inode); out:iput (whiteout);return err;
Greg Kroah-Hartman
maintainerPATCH 748/800 Revert "udf: Protect rename against modification of moved directory"
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 7517ce5dc4d6963ef9ace2acb3f081ef8cd8a1e3 upstream.
This reverts commit f950fd0529130a617b3da526da9fb6a896ce87c2. The locking is going to be provided by vfs_rename() in the following patches.
Message-Id: <[email protected]>
--- fs/udf/namei.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
fs/udf/namei.c +2 -12
@@ -793,11 +793,6 @@ static int udf_rename(struct mnt_idmap *if (!empty_dir (new_inode)) goto out_oiter; } -/* -* We need to protect against old_inode getting converted from -* ICB to normal directory. -*/ -inode_lock_nested (old_inode,I_MUTEX_NONDIR2 ); retval =udf_fiiter_find_entry (old_inode, &dotdot_name, &diriter);if (retval == -ENOENT ) {
@@ -806,10 +801,8 @@ static int udf_rename(struct mnt_idmap * old_inode->i_ino); retval = -EFSCORRUPTED ; } -if (retval) { -inode_unlock (old_inode); +if (retval) goto out_oiter; - } has_diriter = true; tloc =lelb_to_cpu (diriter.fi.icb.extLocation); if (udf_get_lb_pblock(old_inode->i_sb, &tloc, 0) !=
@@ -889,7 +882,6 @@ static int udf_rename(struct mnt_idmap * udf_dir_entry_len(&diriter.fi));udf_fiiter_write_fi (&diriter,NULL );udf_fiiter_release (&diriter); -inode_unlock (old_inode);inode_dec_link_count (old_dir);if (new_inode)
@@ -901,10 +893,8 @@ static int udf_rename(struct mnt_idmap * }return 0 ; out_oiter: -if (has_diriter) { +if (has_diriter)udf_fiiter_release (&diriter); -inode_unlock (old_inode); - }udf_fiiter_release (&oiter);return retval;
Greg Kroah-Hartman
maintainerPATCH 749/800 fs: Establish locking order for unrelated directories
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit f23ce757185319886ca80c4864ce5f81ac6cc9e9 upstream.
Currently the locking order of inode locks for directories that are not in ancestor relationship is not defined because all operations that needed to lock two directories like this were serialized by sb->s_vfs_rename_mutex. However some filesystems need to lock two subdirectories for RENAME_EXCHANGE operations and for this we need the locking order established even for two tree-unrelated directories. Provide a helper function lock_two_inodes() that establishes lock ordering for any two inodes and use it in lock_two_directories().
Message-Id: <[email protected]>
--- fs/inode.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fs/internal.h | 2 ++ fs/namei.c | 4 ++-- 3 files changed, 46 insertions(+), 2 deletions(-)
fs/inode.c +42 -0
@@ -1104,6 +1104,48 @@ void discard_new_inode(struct inode *inoEXPORT_SYMBOL (discard_new_inode);/** +* lock_two_inodes - lock two inodes (may be regular files but also dirs) +* +* Lock any non-NULL argument. The caller must make sure that if he is passing +* in two directories, one is not ancestor of the other. Zero, one or two +* objects may be locked by this function. +* +* @inode1: first inode to lock +* @inode2: second inode to lock +* @subclass1: inode lock subclass for the first lock obtained +* @subclass2: inode lock subclass for the second lock obtained +*/ +void lock_two_inodes (struct inode *inode1,struct inode *inode2, +unsigned subclass1,unsigned subclass2) +{ +if (!inode1 || !inode2) { +/* +* Make sure @subclass1 will be used for the acquired lock. +* This is not strictly necessary (no current caller cares) but +* let's keep things consistent. +*/ +if (!inode1) +swap (inode1, inode2); + goto lock; + } + +/* +* If one object is directory and the other is not, we must make sure +* to lock directory first as the other object may be its child. +*/ +if (S_ISDIR (inode2->i_mode) ==S_ISDIR (inode1->i_mode)) { +if (inode1 > inode2) +swap (inode1, inode2); + }else if (!S_ISDIR (inode1->i_mode)) +swap (inode1, inode2); +lock: +if (inode1) +inode_lock_nested (inode1, subclass1); +if (inode2 && inode2 != inode1) +inode_lock_nested (inode2, subclass2); +} + +/** * lock_two_nondirectories - take two i_mutexes on non-directory objects * * Lock any non-NULL argument that is not a directory.
fs/internal.h +2 -0
@@ -152,6 +152,8 @@ extern long prune_icache_sb(struct superint dentry_needs_remove_privs (struct mnt_idmap *,struct dentry *dentry);bool in_group_or_capable (struct mnt_idmap *idmap,const struct inode *inode,vfsgid_t vfsgid); +void lock_two_inodes (struct inode *inode1,struct inode *inode2, +unsigned subclass1,unsigned subclass2);/* * fs-writeback.c
fs/namei.c +2 -2
@@ -3028,8 +3028,8 @@ static struct dentry *lock_two_directorireturn p; } -inode_lock_nested (p1->d_inode,I_MUTEX_PARENT ); -inode_lock_nested (p2->d_inode,I_MUTEX_PARENT2 ); +lock_two_inodes (p1->d_inode, p2->d_inode, +I_MUTEX_PARENT ,I_MUTEX_PARENT2 );return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 750/800 fs: Lock moved directories
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 28eceeda130f5058074dd007d9c59d2e8bc5af2e upstream.
When a directory is moved to a different directory, some filesystems (udf, ext4, ocfs2, f2fs, and likely gfs2, reiserfs, and others) need to update their pointer to the parent and this must not race with other operations on the directory. Lock the directories when they are moved. Although not all filesystems need this locking, we perform it in vfs_rename() because getting the lock ordering right is really difficult and we don't want to expose these locking details to filesystems.
Message-Id: <[email protected]>
--- Documentation/filesystems/directory-locking.rst | 26 ++++++++++++------------ fs/namei.c | 22 ++++++++++++-------- 2 files changed, 28 insertions(+), 20 deletions(-)
Documentation/filesystems/directory-locking.rst +14 -12
@@ -22,12 +22,11 @@ exclusive. 3) object removal. Locking rules: caller locks parent, finds victim, locks victim and calls the method. Locks are exclusive. -4) rename() that is _not_ cross-directory. Locking rules: caller locks -the parent and finds source and target. In case of exchange (with -RENAME_EXCHANGE in flags argument) lock both. In any case, -if the target already exists, lock it. If the source is a non-directory, -lock it. If we need to lock both, lock them in inode pointer order. -Then call the method. All locks are exclusive. +4) rename() that is _not_ cross-directory. Locking rules: caller locks the +parent and finds source and target. We lock both (provided they exist). If we +need to lock two inodes of different type (dir vs non-dir), we lock directory +first. If we need to lock two inodes of the same type, lock them in inode +pointer order. Then call the method. All locks are exclusive. NB: we might get away with locking the source (and target in exchange case) shared.
@@ -44,15 +43,17 @@ All locks are exclusive. rules: * lock the filesystem - * lock parents in "ancestors first" order. + * lock parents in "ancestors first" order. If one is not ancestor of + the other, lock them in inode pointer order. * find source and target. * if old parent is equal to or is a descendent of target fail with -ENOTEMPTY * if new parent is equal to or is a descendent of source fail with -ELOOP - * If it's an exchange, lock both the source and the target. - * If the target exists, lock it. If the source is a non-directory, - lock it. If we need to lock both, do so in inode pointer order. + * Lock both the source and the target provided they exist. If we + need to lock two inodes of different type (dir vs non-dir), we lock + the directory first. If we need to lock two inodes of the same type, + lock them in inode pointer order. * call the method. All ->i_rwsem are taken exclusive. Again, we might get away with locking
@@ -66,8 +67,9 @@ If no directory is its own ancestor, the Proof: - First of all, at any moment we have a partial ordering of the - objects - A < B iff A is an ancestor of B. + First of all, at any moment we have a linear ordering of the + objects - A < B iff (A is an ancestor of B) or (B is not an ancestor + of A and ptr(A) < ptr(B)). That ordering can change. However, the following is true:
fs/namei.c +14 -8
@@ -4731,7 +4731,7 @@ SYSCALL_DEFINE2(link, const char __user* sb->s_vfs_rename_mutex. We might be more accurate, but that's another * story. * c) we have to lock _four_ objects - parents and victim (if it exists), -* and source (if it is not a directory). +* and source. * And that - after we got ->i_mutex on parents (until then we don't know * whether the target exists). Solution: try to be smart with locking * order for inodes. We rely on the fact that tree topology may change
@@ -4815,10 +4815,16 @@ int vfs_rename(struct renamedata *rd)take_dentry_name_snapshot (&old_name, old_dentry);dget (new_dentry); -if (!is_dir || (flags &RENAME_EXCHANGE )) -lock_two_nondirectories (source, target); -else if (target) -inode_lock (target); +/* +* Lock all moved children. Moved directories may need to change parent +* pointer so they need the lock to prevent against concurrent +* directory changes moving parent pointer. For regular files we've +* historically always done this. The lockdep locking subclasses are +* somewhat arbitrary but RENAME_EXCHANGE in particular can swap +* regular files and directories so it's difficult to tell which +* subclasses to use. +*/ +lock_two_inodes (source, target,I_MUTEX_NORMAL ,I_MUTEX_NONDIR2 ); error = -EPERM ;if (IS_SWAPFILE (source) || (target &&IS_SWAPFILE (target)))
@@ -4866,9 +4872,9 @@ int vfs_rename(struct renamedata *rd)d_exchange (old_dentry, new_dentry); } out: -if (!is_dir || (flags &RENAME_EXCHANGE )) -unlock_two_nondirectories (source, target); -else if (target) +if (source) +inode_unlock (source); +if (target)inode_unlock (target);dput (new_dentry);if (!error) {
Greg Kroah-Hartman
maintainerPATCH 751/800 usb: typec: ucsi: Mark dGPUs as DEVICE scope
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit a7fbfd44c0204f0629288edfd0d77829edb4a2f8 upstream.
power_supply_is_system_supplied() checks whether any power supplies are present that aren't batteries to decide whether the system is running on DC or AC. Downstream drivers use this to make performance decisions.
Navi dGPUs include an UCSI function that has been exported since commit 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU").
This UCSI function registers a power supply since commit 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class") but this is not a system power supply.
As the power supply for a dGPU is only for powering devices connected to dGPU, create a device property to indicate that the UCSI endpoint is only for the scope of POWER_SUPPLY_SCOPE_DEVICE.
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 13 ++++++++++++- drivers/i2c/busses/i2c-nvidia-gpu.c | 3 +++ drivers/usb/typec/ucsi/psy.c | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +12 -1
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/pci.h> #include <linux/pm_runtime.h> +#include <linux/power_supply.h> #include <linux/sched.h> #include <linux/slab.h>
@@ -234,6 +235,16 @@ static const struct dev_pm_ops i2c_dw_pm SET_RUNTIME_PM_OPS(i2c_dw_pci_runtime_suspend, i2c_dw_pci_runtime_resume, NULL) }; +static const struct property_entry dgpu_properties[] = { +/* USB-C doesn't power the system */ +PROPERTY_ENTRY_U8 ("scope" ,POWER_SUPPLY_SCOPE_DEVICE ), + {} +}; + +static const struct software_node dgpu_node = { + .properties = dgpu_properties, +}; +static int i2c_dw_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {
@@ -325,7 +336,7 @@ static int i2c_dw_pci_probe(struct pci_d }if ((dev->flags &MODEL_MASK ) ==MODEL_AMD_NAVI_GPU ) { - dev->slave =i2c_new_ccgx_ucsi (&dev->adapter, dev->irq,NULL ); + dev->slave =i2c_new_ccgx_ucsi (&dev->adapter, dev->irq, &dgpu_node);if (IS_ERR (dev->slave))return dev_err_probe (dev->dev,PTR_ERR (dev->slave),"register UCSI failed\n" );
drivers/i2c/busses/i2c-nvidia-gpu.c +3 -0
@@ -14,6 +14,7 @@#include <linux/platform_device.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/power_supply.h> #include <asm/unaligned.h>
@@ -261,6 +262,8 @@ MODULE_DEVICE_TABLE(pci, gpu_i2c_ids);static const struct property_entry ccgx_props[] = {/* Use FW built for NVIDIA GPU only */ PROPERTY_ENTRY_STRING ("firmware-name" ,"nvidia,gpu" ), +/* USB-C doesn't power the system */ +PROPERTY_ENTRY_U8 ("scope" ,POWER_SUPPLY_SCOPE_DEVICE ), { } };
drivers/usb/typec/ucsi/psy.c +14 -0
@@ -27,8 +27,20 @@ static enum power_supply_property ucsi_pPOWER_SUPPLY_PROP_VOLTAGE_NOW ,POWER_SUPPLY_PROP_CURRENT_MAX ,POWER_SUPPLY_PROP_CURRENT_NOW , + POWER_SUPPLY_PROP_SCOPE, }; +static int ucsi_psy_get_scope (struct ucsi_connector *con, +union power_supply_propval *val) +{ +u8 scope =POWER_SUPPLY_SCOPE_UNKNOWN ; +struct device *dev = con->ucsi->dev; + +device_property_read_u8 (dev,"scope" , &scope); + val->intval = scope; +return 0 ; +} +static int ucsi_psy_get_online (struct ucsi_connector *con,union power_supply_propval *val) {
@@ -194,6 +206,8 @@ static int ucsi_psy_get_prop(struct powereturn ucsi_psy_get_current_max (con, val);case POWER_SUPPLY_PROP_CURRENT_NOW :return ucsi_psy_get_current_now (con, val); +case POWER_SUPPLY_PROP_SCOPE : +return ucsi_psy_get_scope (con, val);default :return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 752/800 ipvs: increase ip_vs_conn_tab_bits range for 64BIT
In reply to Greg Kroah-HartmanFrom: Abhijeet Rastogi <[email protected]>
commit 04292c695f82b6cf0d25dd5ae494f16ddbb621f6 upstream.
Current range [8, 20] is set purely due to historical reasons because at the time, ~1M (2^20) was considered sufficient. With this change, 27 is the upper limit for 64-bit, 20 otherwise.
Previous change regarding this limit is here.
--- net/netfilter/ipvs/Kconfig | 27 ++++++++++++++------------- net/netfilter/ipvs/ip_vs_conn.c | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-)
net/netfilter/ipvs/Kconfig +14 -13
@@ -44,7 +44,8 @@ config IP_VS_DEBUG config IP_VS_TAB_BITS int "IPVS connection table size (the Nth power of 2)" - range 8 20 + range 8 20 if !64BIT + range 8 27 if 64BIT default 12 help The IPVS connection hash table uses the chaining scheme to handle
@@ -54,24 +55,24 @@ config IP_VS_TAB_BITS Note the table size must be power of 2. The table size will be the value of 2 to the your input number power. The number to choose is - from 8 to 20, the default number is 12, which means the table size - is 4096. Don't input the number too small, otherwise you will lose - performance on it. You can adapt the table size yourself, according - to your virtual server application. It is good to set the table size - not far less than the number of connections per second multiplying - average lasting time of connection in the table. For example, your - virtual server gets 200 connections per second, the connection lasts - for 200 seconds in average in the connection table, the table size - should be not far less than 200x200, it is good to set the table - size 32768 (2**15). + from 8 to 27 for 64BIT(20 otherwise), the default number is 12, + which means the table size is 4096. Don't input the number too + small, otherwise you will lose performance on it. You can adapt the + table size yourself, according to your virtual server application. + It is good to set the table size not far less than the number of + connections per second multiplying average lasting time of + connection in the table. For example, your virtual server gets 200 + connections per second, the connection lasts for 200 seconds in + average in the connection table, the table size should be not far + less than 200x200, it is good to set the table size 32768 (2**15). Another note that each connection occupies 128 bytes effectively and each hash entry uses 8 bytes, so you can estimate how much memory is needed for your box. You can overwrite this number setting conn_tab_bits module parameter - or by appending ip_vs.conn_tab_bits=? to the kernel command line - if IP VS was compiled built-in. + or by appending ip_vs.conn_tab_bits=? to the kernel command line if + IP VS was compiled built-in. comment "IPVS transport protocol load balancing support"
net/netfilter/ipvs/ip_vs_conn.c +2 -2
@@ -1485,8 +1485,8 @@ int __init ip_vs_conn_init(void)int idx;/* Compute size and mask */ -if (ip_vs_conn_tab_bits <8 || ip_vs_conn_tab_bits >20 ) { -pr_info ("conn_tab_bits not in [8, 20]. Using default value\n" ); +if (ip_vs_conn_tab_bits <8 || ip_vs_conn_tab_bits >27 ) { +pr_info ("conn_tab_bits not in [8, 27]. Using default value\n" ); ip_vs_conn_tab_bits =CONFIG_IP_VS_TAB_BITS ; } ip_vs_conn_tab_size =1 << ip_vs_conn_tab_bits;
Greg Kroah-Hartman
maintainerPATCH 753/800 btrfs: add handling for RAID1C23/DUP to btrfs_reduce_alloc_profile
In reply to Greg Kroah-HartmanFrom: Matt Corallo <[email protected]>
commit 160fe8f6fdb13da6111677be6263e5d65e875987 upstream.
Callers of btrfs_reduce_alloc_profile expect it to return exactly one allocation profile flag, and failing to do so may ultimately result in a WARN_ON and remount-ro when allocating new blocks, like the below transaction abort on 6.1.
btrfs_reduce_alloc_profile has two ways of determining the profile, first it checks if a conversion balance is currently running and uses the profile we're converting to. If no balance is currently running, it returns the max-redundancy profile which at least one block in the selected block group has.
This works by simply checking each known allocation profile bit in redundancy order. However, btrfs_reduce_alloc_profile has not been updated as new flags have been added - first with the DUP profile and later with the RAID1C34 profiles.
Because of the way it checks, if we have blocks with different profiles and at least one is known, that profile will be selected. However, if none are known we may return a flag set with multiple allocation profiles set.
This is currently only possible when a balance from one of the three unhandled profiles to another of the unhandled profiles is canceled after allocating at least one block using the new profile.
In that case, a transaction abort like the below will occur and the filesystem will need to be mounted with -o skip_balance to get it mounted rw again (but the balance cannot be resumed without a similar abort).
[770.648] ------------[ cut here ]------------ [770.648] BTRFS: Transaction aborted (error -22) [770.648] WARNING: CPU: 43 PID: 1159593 at fs/btrfs/extent-tree.c:4122 find_free_extent+0x1d94/0x1e00 [btrfs] [770.648] CPU: 43 PID: 1159593 Comm: btrfs Tainted: G W 6.1.0-0.deb11.7-powerpc64le #1 Debian 6.1.20-2~bpo11+1a~test [770.648] Hardware name: T2P9D01 REV 1.00 POWER9 0x4e1202 opal:skiboot-bc106a0 PowerNV [770.648] NIP: c00800000f6784fc LR: c00800000f6784f8 CTR: c000000000d746c0 [770.648] REGS: c000200089afe9a0 TRAP: 0700 Tainted: G W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test) [770.648] MSR: 9000000002029033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 28848282 XER: 20040000 [770.648] CFAR: c000000000135110 IRQMASK: 0 GPR00: c00800000f6784f8 c000200089afec40 c00800000f7ea800 0000000000000026 GPR04: 00000001004820c2 c000200089afea00 c000200089afe9f8 0000000000000027 GPR08: c000200ffbfe7f98 c000000002127f90 ffffffffffffffd8 0000000026d6a6e8 GPR12: 0000000028848282 c000200fff7f3800 5deadbeef0000122 c00000002269d000 GPR16: c0002008c7797c40 c000200089afef17 0000000000000000 0000000000000000 GPR20: 0000000000000000 0000000000000001 c000200008bc5a98 0000000000000001 GPR24: 0000000000000000 c0000003c73088d0 c000200089afef17 c000000016d3a800 GPR28: c0000003c7308800 c00000002269d000 ffffffffffffffea 0000000000000001 [770.648] NIP [c00800000f6784fc] find_free_extent+0x1d94/0x1e00 [btrfs] [770.648] LR [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs] [770.648] Call Trace: [770.648] [c000200089afec40] [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs] (unreliable) [770.648] [c000200089afed30] [c00800000f681398] btrfs_reserve_extent+0x1a0/0x2f0 [btrfs] [770.648] [c000200089afeea0] [c00800000f681bf0] btrfs_alloc_tree_block+0x108/0x670 [btrfs] [770.648] [c000200089afeff0] [c00800000f66bd68] __btrfs_cow_block+0x170/0x850 [btrfs] [770.648] [c000200089aff100] [c00800000f66c58c] btrfs_cow_block+0x144/0x288 [btrfs] [770.648] [c000200089aff1b0] [c00800000f67113c] btrfs_search_slot+0x6b4/0xcb0 [btrfs] [770.648] [c000200089aff2a0] [c00800000f679f60] lookup_inline_extent_backref+0x128/0x7c0 [btrfs] [770.648] [c000200089aff3b0] [c00800000f67b338] lookup_extent_backref+0x70/0x190 [btrfs] [770.648] [c000200089aff470] [c00800000f67b54c] __btrfs_free_extent+0xf4/0x1490 [btrfs] [770.648] [c000200089aff5a0] [c00800000f67d770] __btrfs_run_delayed_refs+0x328/0x1530 [btrfs] [770.648] [c000200089aff740] [c00800000f67ea2c] btrfs_run_delayed_refs+0xb4/0x3e0 [btrfs] [770.648] [c000200089aff800] [c00800000f699aa4] btrfs_commit_transaction+0x8c/0x12b0 [btrfs] [770.648] [c000200089aff8f0] [c00800000f6dc628] reset_balance_state+0x1c0/0x290 [btrfs] [770.648] [c000200089aff9a0] [c00800000f6e2f7c] btrfs_balance+0x1164/0x1500 [btrfs] [770.648] [c000200089affb40] [c00800000f6f8e4c] btrfs_ioctl+0x2b54/0x3100 [btrfs] [770.648] [c000200089affc80] [c00000000053be14] sys_ioctl+0x794/0x1310 [770.648] [c000200089affd70] [c00000000002af98] system_call_exception+0x138/0x250 [770.648] [c000200089affe10] [c00000000000c654] system_call_common+0xf4/0x258 [770.648] --- interrupt: c00 at 0x7fff94126800 [770.648] NIP: 00007fff94126800 LR: 0000000107e0b594 CTR: 0000000000000000 [770.648] REGS: c000200089affe80 TRAP: 0c00 Tainted: G W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test) [770.648] MSR: 900000000000d033 <SF,HV,EE,PR,ME,IR,DR,RI,LE> CR: 24002848 XER: 00000000 [770.648] IRQMASK: 0 GPR00: 0000000000000036 00007fffc9439da0 00007fff94217100 0000000000000003 GPR04: 00000000c4009420 00007fffc9439ee8 0000000000000000 0000000000000000 GPR08: 00000000803c7416 0000000000000000 0000000000000000 0000000000000000 GPR12: 0000000000000000 00007fff9467d120 0000000107e64c9c 0000000107e64d0a GPR16: 0000000107e64d06 0000000107e64cf1 0000000107e64cc4 0000000107e64c73 GPR20: 0000000107e64c31 0000000107e64bf1 0000000107e64be7 0000000000000000 GPR24: 0000000000000000 00007fffc9439ee0 0000000000000003 0000000000000001 GPR28: 00007fffc943f713 0000000000000000 00007fffc9439ee8 0000000000000000 [770.648] NIP [00007fff94126800] 0x7fff94126800 [770.648] LR [0000000107e0b594] 0x107e0b594 [770.648] --- interrupt: c00 [770.648] Instruction dump: [770.648] 3b00ffe4 e8898828 481175f5 60000000 4bfff4fc 3be00000 4bfff570 3d220000 [770.648] 7fc4f378 e8698830 4811cd95 e8410018 <0fe00000> f9c10060 f9e10068 fa010070 [770.648] ---[ end trace 0000000000000000 ]--- [770.648] BTRFS: error (device dm-2: state A) in find_free_extent_update_loop:4122: errno=-22 unknown [770.648] BTRFS info (device dm-2: state EA): forced readonly [770.648] BTRFS: error (device dm-2: state EA) in __btrfs_free_extent:3070: errno=-22 unknown [770.648] BTRFS error (device dm-2: state EA): failed to run delayed ref for logical 17838685708288 num_bytes 24576 type 184 action 2 ref_mod 1: -22 [770.648] BTRFS: error (device dm-2: state EA) in btrfs_run_delayed_refs:2144: errno=-22 unknown [770.648] BTRFS: error (device dm-2: state EA) in reset_balance_state:3599: errno=-22 unknown
--- fs/btrfs/block-group.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +8 -1
@@ -95,14 +95,21 @@ static u64 btrfs_reduce_alloc_profile(st } allowed &= flags; -if (allowed &BTRFS_BLOCK_GROUP_RAID6 ) +/* Select the highest-redundancy RAID level. */ +if (allowed &BTRFS_BLOCK_GROUP_RAID1C4 ) + allowed =BTRFS_BLOCK_GROUP_RAID1C4 ; +else if (allowed &BTRFS_BLOCK_GROUP_RAID6 ) allowed =BTRFS_BLOCK_GROUP_RAID6 ; +else if (allowed &BTRFS_BLOCK_GROUP_RAID1C3 ) + allowed =BTRFS_BLOCK_GROUP_RAID1C3 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID5 ) allowed =BTRFS_BLOCK_GROUP_RAID5 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID10 ) allowed =BTRFS_BLOCK_GROUP_RAID10 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID1 ) allowed =BTRFS_BLOCK_GROUP_RAID1 ; +else if (allowed &BTRFS_BLOCK_GROUP_DUP ) + allowed =BTRFS_BLOCK_GROUP_DUP ;else if (allowed &BTRFS_BLOCK_GROUP_RAID0 ) allowed =BTRFS_BLOCK_GROUP_RAID0 ;
Greg Kroah-Hartman
maintainerPATCH 754/800 btrfs: fix dirty_metadata_bytes for redirtied buffers
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
commit f18cc97845aa4ae0e795c088c979fe1642b3b8e5 upstream.
dirty_metadata_bytes is decremented in both places that clear the dirty bit in a buffer, but only incremented in btrfs_mark_buffer_dirty, which means that a buffer that is redirtied using btrfs_redirty_list_add won't be added to dirty_metadata_bytes, but it will be subtracted when written out, leading an inconsistency in the counter.
Move the dirty_metadata_bytes from btrfs_mark_buffer_dirty into set_extent_buffer_dirty to also account for the redirty case, and remove the now unused set_extent_buffer_dirty return value.
--- fs/btrfs/disk-io.c | 7 +------ fs/btrfs/extent_io.c | 7 ++++--- fs/btrfs/extent_io.h | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-)
fs/btrfs/disk-io.c +1 -6
@@ -4683,7 +4683,6 @@ void btrfs_mark_buffer_dirty(struct exte {struct btrfs_fs_info *fs_info = buf->fs_info;u64 transid =btrfs_header_generation (buf); -int was_dirty;#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS /*
@@ -4698,11 +4697,7 @@ void btrfs_mark_buffer_dirty(struct exteif (transid != fs_info->generation)WARN (1 ,KERN_CRIT "btrfs transid mismatch buffer %llu, found %llu running %llu\n" , buf->start, transid, fs_info->generation); - was_dirty =set_extent_buffer_dirty (buf); -if (!was_dirty) -percpu_counter_add_batch (&fs_info->dirty_metadata_bytes, - buf->len, - fs_info->dirty_metadata_batch); +set_extent_buffer_dirty (buf);#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY /* * Since btrfs_mark_buffer_dirty() can be called with item pointer set
fs/btrfs/extent_io.c +4 -3
@@ -4064,7 +4064,7 @@ void btrfs_clear_buffer_dirty(struct btrWARN_ON (atomic_read (&eb->refs) ==0 ); } -bool set_extent_buffer_dirty (struct extent_buffer *eb) +void set_extent_buffer_dirty (struct extent_buffer *eb) {int i;int num_pages;
@@ -4099,13 +4099,14 @@ bool set_extent_buffer_dirty(struct exte eb->start, eb->len);if (subpage)unlock_page (eb->pages[0 ]); +percpu_counter_add_batch (&eb->fs_info->dirty_metadata_bytes, + eb->len, + eb->fs_info->dirty_metadata_batch); }#ifdef CONFIG_BTRFS_DEBUG for (i =0 ; i < num_pages; i++)ASSERT (PageDirty (eb->pages[i]));#endif - -return was_dirty; }void clear_extent_buffer_uptodate (struct extent_buffer *eb)
fs/btrfs/extent_io.h +1 -1
@@ -263,7 +263,7 @@ void extent_buffer_bitmap_set(const struvoid extent_buffer_bitmap_clear (const struct extent_buffer *eb,unsigned long start,unsigned long pos,unsigned long len); -bool set_extent_buffer_dirty (struct extent_buffer *eb); +void set_extent_buffer_dirty (struct extent_buffer *eb);void set_extent_buffer_uptodate (struct extent_buffer *eb);void clear_extent_buffer_uptodate (struct extent_buffer *eb);int extent_buffer_under_io (const struct extent_buffer *eb);
Greg Kroah-Hartman
maintainerPATCH 755/800 btrfs: insert tree mod log move in push_node_left
In reply to Greg Kroah-HartmanFrom: Boris Burkov <[email protected]>
commit 5cead5422a0e3d13b0bcee986c0f5c4ebb94100b upstream.
There is a fairly unlikely race condition in tree mod log rewind that can result in a kernel panic which has the following trace:
[530.569] BTRFS critical (device sda3): unable to find logical 0 length 4096 [530.585] BTRFS critical (device sda3): unable to find logical 0 length 4096 [530.602] BUG: kernel NULL pointer dereference, address: 0000000000000002 [530.618] #PF: supervisor read access in kernel mode [530.629] #PF: error_code(0x0000) - not-present page [530.641] PGD 0 P4D 0 [530.647] Oops: 0000 [#1] SMP [530.654] CPU: 30 PID: 398973 Comm: below Kdump: loaded Tainted: G S O K 5.12.0-0_fbk13_clang_7455_gb24de3bdb045 #1 [530.680] Hardware name: Quanta Mono Lake-M.2 SATA 1HY9U9Z001G/Mono Lake-M.2 SATA, BIOS F20_3A15 08/16/2017 [530.703] RIP: 0010:__btrfs_map_block+0xaa/0xd00 [530.755] RSP: 0018:ffffc9002c2f7600 EFLAGS: 00010246 [530.767] RAX: ffffffffffffffea RBX: ffff888292e41000 RCX: f2702d8b8be15100 [530.784] RDX: ffff88885fda6fb8 RSI: ffff88885fd973c8 RDI: ffff88885fd973c8 [530.800] RBP: ffff888292e410d0 R08: ffffffff82fd7fd0 R09: 00000000fffeffff [530.816] R10: ffffffff82e57fd0 R11: ffffffff82e57d70 R12: 0000000000000000 [530.832] R13: 0000000000001000 R14: 0000000000001000 R15: ffffc9002c2f76f0 [530.848] FS: 00007f38d64af000(0000) GS:ffff88885fd80000(0000) knlGS:0000000000000000 [530.866] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [530.880] CR2: 0000000000000002 CR3: 00000002b6770004 CR4: 00000000003706e0 [530.896] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [530.912] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [530.928] Call Trace: [530.934] ? btrfs_printk+0x13b/0x18c [530.943] ? btrfs_bio_counter_inc_blocked+0x3d/0x130 [530.955] btrfs_map_bio+0x75/0x330 [530.963] ? kmem_cache_alloc+0x12a/0x2d0 [530.973] ? btrfs_submit_metadata_bio+0x63/0x100 [530.984] btrfs_submit_metadata_bio+0xa4/0x100 [530.995] submit_extent_page+0x30f/0x360 [531.004] read_extent_buffer_pages+0x49e/0x6d0 [531.015] ? submit_extent_page+0x360/0x360 [531.025] btree_read_extent_buffer_pages+0x5f/0x150 [531.037] read_tree_block+0x37/0x60 [531.046] read_block_for_search+0x18b/0x410 [531.056] btrfs_search_old_slot+0x198/0x2f0 [531.066] resolve_indirect_ref+0xfe/0x6f0 [531.076] ? ulist_alloc+0x31/0x60 [531.084] ? kmem_cache_alloc_trace+0x12e/0x2b0 [531.095] find_parent_nodes+0x720/0x1830 [531.105] ? ulist_alloc+0x10/0x60 [531.113] iterate_extent_inodes+0xea/0x370 [531.123] ? btrfs_previous_extent_item+0x8f/0x110 [531.134] ? btrfs_search_path_in_tree+0x240/0x240 [531.146] iterate_inodes_from_logical+0x98/0xd0 [531.157] ? btrfs_search_path_in_tree+0x240/0x240 [531.168] btrfs_ioctl_logical_to_ino+0xd9/0x180 [531.179] btrfs_ioctl+0xe2/0x2eb0
This occurs when logical inode resolution takes a tree mod log sequence number, and then while backref walking hits a rewind on a busy node which has the following sequence of tree mod log operations (numbers filled in from a specific example, but they are somewhat arbitrary)
REMOVE_WHILE_FREEING slot 532
REMOVE_WHILE_FREEING slot 531
REMOVE_WHILE_FREEING slot 530
...
REMOVE_WHILE_FREEING slot 0
REMOVE slot 455
REMOVE slot 454
REMOVE slot 453
...
REMOVE slot 0
ADD slot 455
ADD slot 454
ADD slot 453
...
ADD slot 0
MOVE src slot 0 -> dst slot 456 nritems 533
REMOVE slot 455
REMOVE slot 454
REMOVE slot 453
...
REMOVE slot 0
When this sequence gets applied via btrfs_tree_mod_log_rewind, it allocates a fresh rewind eb, and first inserts the correct key info for the 533 elements, then overwrites the first 456 of them, then decrements the count by 456 via the add ops, then rewinds the move by doing a memmove from 456:988->0:532. We have never written anything past 532, so that memmove writes garbage into the 0:532 range. In practice, this results in a lot of fully 0 keys. The rewind then puts valid keys into slots 0:455 with the last removes, but 456:532 are still invalid.
When search_old_slot uses this eb, if it uses one of those invalid slots, it can then read the extent buffer and issue a bio for offset 0 which ultimately panics looking up extent mappings.
This bad tree mod log sequence gets generated when the node balancing code happens to do a balance_node_right followed by a push_node_left while logging in the tree mod log. Illustrated for ebs L and R (left and right):
L R
start:
[XXX|YYY|...] [ZZZ|...|...]
balance_node_right:
[XXX|YYY|...] [...|ZZZ|...] move Z to make room for Y [XXX|...|...] [YYY|ZZZ|...] copy Y from L to R push_node_left: [XXX|YYY|...] [...|ZZZ|...] copy Y from R to L [XXX|YYY|...] [ZZZ|...|...] move Z into emptied space (NOT LOGGED!)
This is because balance_node_right logs a move, but push_node_left explicitly doesn't. That is because logging the move would remove the overwritten src < dst range in the right eb, which was already logged when we called btrfs_tree_mod_log_eb_copy. The correct sequence would include a move from 456:988 to 0:532 after remove 0:455 and before removing 0:532. Reversing that sequence would entail creating keys for 0:532, then moving those keys out to 456:988, then creating more keys for 0:455.
i.e.,
REMOVE_WHILE_FREEING slot 532
REMOVE_WHILE_FREEING slot 531
REMOVE_WHILE_FREEING slot 530
...
REMOVE_WHILE_FREEING slot 0
MOVE src slot 456 -> dst slot 0 nritems 533
REMOVE slot 455
REMOVE slot 454
REMOVE slot 453
...
REMOVE slot 0
ADD slot 455
ADD slot 454
ADD slot 453
...
ADD slot 0
MOVE src slot 0 -> dst slot 456 nritems 533
REMOVE slot 455
REMOVE slot 454
REMOVE slot 453
...
REMOVE slot 0
Fix this to log the move but avoid the double remove by putting all the logging logic in btrfs_tree_mod_log_eb_copy which has enough information to detect these cases and properly log moves, removes, and adds. Leave btrfs_tree_mod_log_insert_move to handle insert_ptr and delete_ptr's tree mod logging.
(Un)fortunately, this is quite difficult to reproduce, and I was only able to reproduce it by adding sleeps in btrfs_search_old_slot that would encourage more log rewinding during ino_to_logical ioctls. I was able to hit the warning in the previous patch in the series without the fix quite quickly, but not after this patch.
--- fs/btrfs/ctree.c | 11 ++++--- fs/btrfs/tree-mod-log.c | 73 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 71 insertions(+), 13 deletions(-)
fs/btrfs/ctree.c +7 -4
@@ -2714,8 +2714,8 @@ static int push_node_left(struct btrfs_tif (push_items < src_nritems) {/* -* Don't call btrfs_tree_mod_log_insert_move() here, key removal -* was already fully logged by btrfs_tree_mod_log_eb_copy() above. +* btrfs_tree_mod_log_eb_copy handles logging the move, so we +* don't need to do an explicit tree mod log operation for it. */ memmove_extent_buffer(src, btrfs_node_key_ptr_offset(src, 0), btrfs_node_key_ptr_offset(src, push_items),
@@ -2776,8 +2776,11 @@ static int balance_node_right(struct btrbtrfs_abort_transaction (trans, ret);return ret; } - ret =btrfs_tree_mod_log_insert_move (dst, push_items,0 , dst_nritems); -BUG_ON (ret <0 ); + +/* +* btrfs_tree_mod_log_eb_copy handles logging the move, so we don't +* need to do an explicit tree mod log operation for it. +*/ memmove_extent_buffer(dst, btrfs_node_key_ptr_offset(dst, push_items), btrfs_node_key_ptr_offset(dst, 0), (dst_nritems) *
fs/btrfs/tree-mod-log.c +64 -9
118 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 756/800 btrfs: warn on invalid slot in tree mod log rewind
In reply to Greg Kroah-HartmanFrom: Boris Burkov <[email protected]>
commit 95c8e349d8e8f190e28854e7ca96de866d2dc5a4 upstream.
The way that tree mod log tracks the ultimate length of the eb, the variable 'n', eventually turns up the correct value, but at intermediate steps during the rewind, n can be inaccurate as a representation of the end of the eb. For example, it doesn't get updated on move rewinds, and it does get updated for add/remove in the middle of the eb.
To detect cases with invalid moves, introduce a separate variable called max_slot which tries to track the maximum valid slot in the rewind eb. We can then warn if we do a move whose src range goes beyond the max valid slot.
There is a commented caveat that it is possible to have this value be an overestimate due to the challenge of properly handling 'add' operations in the middle of the eb, but in practice it doesn't cause enough of a problem to throw out the max idea in favor of tracking every valid slot.
--- fs/btrfs/tree-mod-log.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
fs/btrfs/tree-mod-log.c +42 -0
@@ -719,10 +719,27 @@ static void tree_mod_log_rewind(struct bunsigned long o_dst;unsigned long o_src;unsigned long p_size =sizeof (struct btrfs_key_ptr ); +/* +* max_slot tracks the maximum valid slot of the rewind eb at every +* step of the rewind. This is in contrast with 'n' which eventually +* matches the number of items, but can be wrong during moves or if +* removes overlap on already valid slots (which is probably separately +* a bug). We do this to validate the offsets of memmoves for rewinding +* moves and detect invalid memmoves. +* +* Since a rewind eb can start empty, max_slot is a signed integer with +* a special meaning for -1, which is that no slot is valid to move out +* of. Any other negative value is invalid. +*/ +int max_slot; +int move_src_end_slot; +int move_dst_end_slot; n =btrfs_header_nritems (eb); + max_slot = n -1 ;read_lock (&fs_info->tree_mod_log_lock);while (tm && tm->seq >= time_seq) { +ASSERT (max_slot >=-1 );/* * All the operations are recorded with the operator used for * the modification. As we're going backwards, we do the
@@ -739,6 +756,8 @@ static void tree_mod_log_rewind(struct bbtrfs_set_node_ptr_generation (eb, tm->slot, tm->generation); n++; +if (tm->slot > max_slot) + max_slot = tm->slot;break ;case BTRFS_MOD_LOG_KEY_REPLACE :BUG_ON (tm->slot >= n);
@@ -748,14 +767,37 @@ static void tree_mod_log_rewind(struct b tm->generation);break ;case BTRFS_MOD_LOG_KEY_ADD : +/* +* It is possible we could have already removed keys +* behind the known max slot, so this will be an +* overestimate. In practice, the copy operation +* inserts them in increasing order, and overestimating +* just means we miss some warnings, so it's OK. It +* isn't worth carefully tracking the full array of +* valid slots to check against when moving. +*/ +if (tm->slot == max_slot) + max_slot--;/* if a move operation is needed it's in the log */ n--;break ;case BTRFS_MOD_LOG_MOVE_KEYS : +ASSERT (tm->move.nr_items >0 ); + move_src_end_slot = tm->move.dst_slot + tm->move.nr_items -1 ; + move_dst_end_slot = tm->slot + tm->move.nr_items -1 ; o_dst =btrfs_node_key_ptr_offset (eb, tm->slot); o_src =btrfs_node_key_ptr_offset (eb, tm->move.dst_slot); +if (WARN_ON (move_src_end_slot > max_slot || + tm->move.nr_items <=0 )) { +btrfs_warn (fs_info, +"move from invalid tree mod log slot eb %llu slot %d dst_slot %d nr_items %d seq %llu n %u max_slot %d" , + eb->start, tm->slot, + tm->move.dst_slot, tm->move.nr_items, + tm->seq, n, max_slot); + }memmove_extent_buffer (eb, o_dst, o_src, tm->move.nr_items * p_size); + max_slot = move_dst_end_slot;break ;case BTRFS_MOD_LOG_ROOT_REPLACE :/*
Greg Kroah-Hartman
maintainerPATCH 757/800 btrfs: delete unused BGs while reclaiming BGs
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 3ed01616bad6c7e3de196676b542ae3df8058592 upstream.
The reclaiming process only starts after the filesystem volumes are allocated to a certain level (75% by default). Thus, the list of reclaiming target block groups can build up so huge at the time the reclaim process kicks in. On a test run, there were over 1000 BGs in the reclaim list.
As the reclaim involves rewriting the data, it takes really long time to reclaim the BGs. While the reclaim is running, btrfs_delete_unused_bgs() won't proceed because the reclaim side is holding fs_info->reclaim_bgs_lock. As a result, we will have a large number of unused BGs kept in the unused list. On my test run, I got 1057 unused BGs.
Since deleting a block group is relatively easy and fast work, we can call btrfs_delete_unused_bgs() while it reclaims BGs, to avoid building up unused BGs.
--- fs/btrfs/block-group.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/btrfs/block-group.c +14 -0
@@ -1831,10 +1831,24 @@ void btrfs_reclaim_bgs_work(struct work_ next:btrfs_put_block_group (bg); + +mutex_unlock (&fs_info->reclaim_bgs_lock); +/* +* Reclaiming all the block groups in the list can take really +* long. Prioritize cleaning up unused block groups. +*/ +btrfs_delete_unused_bgs (fs_info); +/* +* If we are interrupted by a balance, we can just bail out. The +* cleaner thread restart again if necessary. +*/ +if (!mutex_trylock (&fs_info->reclaim_bgs_lock)) + goto end;spin_lock (&fs_info->unused_bgs_lock); }spin_unlock (&fs_info->unused_bgs_lock);mutex_unlock (&fs_info->reclaim_bgs_lock); +end:btrfs_exclop_finish (fs_info);sb_end_write (fs_info->sb); }
Greg Kroah-Hartman
maintainerPATCH 758/800 btrfs: bail out reclaim process if filesystem is read-only
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 93463ff7b54626f8276c0bd3d3f968fbf8d5d380 upstream.
When a filesystem is read-only, we cannot reclaim a block group as it cannot rewrite the data. Just bail out in that case.
Note that it can drop block groups in this case. As we did sb_start_write(), read-only filesystem means we got a fatal error and forced read-only. There is no chance to reclaim them again.
--- fs/btrfs/block-group.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/block-group.c +9 -2
@@ -1798,8 +1798,15 @@ void btrfs_reclaim_bgs_work(struct work_ }spin_unlock (&bg->lock); -/* Get out fast, in case we're unmounting the filesystem */ -if (btrfs_fs_closing (fs_info)) { +/* +* Get out fast, in case we're read-only or unmounting the +* filesystem. It is OK to drop block groups from the list even +* for the read-only case. As we did sb_start_write(), +* "mount -o remount,ro" won't happen and read-only filesystem +* means it is forced read-only due to a fatal error. So, it +* never gets back to read-write to let us reclaim again. +*/ +if (btrfs_need_cleaner_sleep (fs_info)) {up_write (&space_info->groups_sem); goto next; }
Greg Kroah-Hartman
maintainerPATCH 759/800 btrfs: add block-group tree to lockdep classes
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
commit 1a1b0e729d227f9f758f7b5f1c997e874e94156e upstream.
The block group tree was not present among the lockdep classes. We could get potentially lockdep warnings but so far none has been seen, also because block-group-tree is a relatively new feature.
--- fs/btrfs/locking.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/locking.c +3 -2
@@ -57,8 +57,8 @@static struct btrfs_lockdep_keyset {u64 id;/* root objectid */ -/* Longest entry: btrfs-free-space-00 */ -char names[BTRFS_MAX_LEVEL ][20 ]; +/* Longest entry: btrfs-block-group-00 */ +char names[BTRFS_MAX_LEVEL ][24 ];struct lock_class_key keys[BTRFS_MAX_LEVEL ]; } btrfs_lockdep_keysets[] = { { .id =BTRFS_ROOT_TREE_OBJECTID ,DEFINE_NAME ("root" ) },
@@ -72,6 +72,7 @@ static struct btrfs_lockdep_keyset { { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, DEFINE_NAME("dreloc") }, { .id = BTRFS_UUID_TREE_OBJECTID, DEFINE_NAME("uuid") }, { .id = BTRFS_FREE_SPACE_TREE_OBJECTID, DEFINE_NAME("free-space") }, + { .id = BTRFS_BLOCK_GROUP_TREE_OBJECTID, DEFINE_NAME("block-group") }, { .id = 0, DEFINE_NAME("tree") }, };
Greg Kroah-Hartman
maintainerPATCH 760/800 btrfs: reinsert BGs failed to reclaim
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 7e27180994383b7c741ad87749db01e4989a02ba upstream.
The reclaim process can temporarily fail. For example, if the space is getting tight, it fails to make the block group read-only. If there are no further writes on that block group, the block group will never get back to the reclaim list, and the BG never gets reclaimed. In a certain workload, we can leave many such block groups never reclaimed.
So, let's get it back to the list and give it a chance to be reclaimed.
--- fs/btrfs/block-group.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/block-group.c +2 -0
@@ -1837,6 +1837,8 @@ void btrfs_reclaim_bgs_work(struct work_ } next: +if (ret) +btrfs_mark_bg_to_reclaim (bg);btrfs_put_block_group (bg);mutex_unlock (&fs_info->reclaim_bgs_lock);
Greg Kroah-Hartman
maintainerPATCH 761/800 btrfs: move out now unused BG from the reclaim list
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit a9f189716cf15913c453299d72f69c51a9b0f86b upstream.
An unused block group is easy to remove to free up space and should be reclaimed fast. Such block group can often already be a target of the reclaim process. As we check list_empty(&bg->bg_list), we keep it in the reclaim list. That block group is never reclaimed until the file system is filled e.g. up to 75%.
Instead, we can move unused block group to the unused list and delete it fast.
--- fs/btrfs/block-group.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +4 -1
@@ -1640,11 +1640,14 @@ void btrfs_mark_bg_unused(struct btrfs_b {struct btrfs_fs_info *fs_info = bg->fs_info; +trace_btrfs_add_unused_block_group (bg);spin_lock (&fs_info->unused_bgs_lock);if (list_empty (&bg->bg_list)) {btrfs_get_block_group (bg); -trace_btrfs_add_unused_block_group (bg);list_add_tail (&bg->bg_list, &fs_info->unused_bgs); + }else { +/* Pull out the block group from the reclaim_bgs list. */ +list_move_tail (&bg->bg_list, &fs_info->unused_bgs); }spin_unlock (&fs_info->unused_bgs_lock); }
Greg Kroah-Hartman
maintainerPATCH 762/800 btrfs: fix race when deleting quota root from the dirty cow roots list
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit b31cb5a6eb7a48b0a7bfdf06832b1fd5088d8c79 upstream.
When disabling quotas we are deleting the quota root from the list fs_info->dirty_cowonly_roots without taking the lock that protects it, which is struct btrfs_fs_info::trans_lock. This unsynchronized list manipulation may cause chaos if there's another concurrent manipulation of this list, such as when adding a root to it with ctree.c:add_root_to_dirty_list().
This can result in all sorts of weird failures caused by a race, such as the following crash:
[337571.278245] general protection fault, probably for non-canonical address 0xdead000000000108: 0000 [#1] PREEMPT SMP PTI [337571.278933] CPU: 1 PID: 115447 Comm: btrfs Tainted: G W 6.4.0-rc6-btrfs-next-134+ #1 [337571.279153] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 [337571.279572] RIP: 0010:commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.279928] Code: 85 38 06 00 (...) [337571.280363] RSP: 0018:ffff9f63446efba0 EFLAGS: 00010206 [337571.280582] RAX: ffff942d98ec2638 RBX: ffff9430b82b4c30 RCX: 0000000449e1c000 [337571.280798] RDX: dead000000000100 RSI: ffff9430021e4900 RDI: 0000000000036070 [337571.281015] RBP: ffff942d98ec2000 R08: ffff942d98ec2000 R09: 000000000000015b [337571.281254] R10: 0000000000000009 R11: 0000000000000001 R12: ffff942fe8fbf600 [337571.281476] R13: ffff942dabe23040 R14: ffff942dabe20800 R15: ffff942d92cf3b48 [337571.281723] FS: 00007f478adb7340(0000) GS:ffff94349fa40000(0000) knlGS:0000000000000000 [337571.281950] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [337571.282184] CR2: 00007f478ab9a3d5 CR3: 000000001e02c001 CR4: 0000000000370ee0 [337571.282416] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [337571.282647] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [337571.282874] Call Trace: [337571.283101] <TASK> [337571.283327] ? __die_body+0x1b/0x60 [337571.283570] ? die_addr+0x39/0x60 [337571.283796] ? exc_general_protection+0x22e/0x430 [337571.284022] ? asm_exc_general_protection+0x22/0x30 [337571.284251] ? commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.284531] btrfs_commit_transaction+0x42e/0xf90 [btrfs] [337571.284803] ? _raw_spin_unlock+0x15/0x30 [337571.285031] ? release_extent_buffer+0x103/0x130 [btrfs] [337571.285305] reset_balance_state+0x152/0x1b0 [btrfs] [337571.285578] btrfs_balance+0xa50/0x11e0 [btrfs] [337571.285864] ? __kmem_cache_alloc_node+0x14a/0x410 [337571.286086] btrfs_ioctl+0x249a/0x3320 [btrfs] [337571.286358] ? mod_objcg_state+0xd2/0x360 [337571.286577] ? refill_obj_stock+0xb0/0x160 [337571.286798] ? seq_release+0x25/0x30 [337571.287016] ? __rseq_handle_notify_resume+0x3ba/0x4b0 [337571.287235] ? percpu_counter_add_batch+0x2e/0xa0 [337571.287455] ? __x64_sys_ioctl+0x88/0xc0 [337571.287675] __x64_sys_ioctl+0x88/0xc0 [337571.287901] do_syscall_64+0x38/0x90 [337571.288126] entry_SYSCALL_64_after_hwframe+0x72/0xdc [337571.288352] RIP: 0033:0x7f478aaffe9b
So fix this by locking struct btrfs_fs_info::trans_lock before deleting the quota root from that list.
--- fs/btrfs/qgroup.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/qgroup.c +2 -0
@@ -1301,7 +1301,9 @@ int btrfs_quota_disable(struct btrfs_fs_ goto out; } +spin_lock (&fs_info->trans_lock);list_del ("a_root->dirty_list); +spin_unlock (&fs_info->trans_lock);btrfs_tree_lock (quota_root->node);btrfs_clear_buffer_dirty (trans, quota_root->node);
Greg Kroah-Hartman
maintainerPATCH 763/800 btrfs: add missing error handling when logging operation while COWing extent buffer
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit d09c51521f22f9cbdfb1cf63e5c456077c622c84 upstream.
When COWing an extent buffer that is not the root node, we need to log in the tree mod log that we replaced a pointer in the parent node, otherwise a tree mod log user doing a search on the b+tree can return incorrect results (that miss something). We are doing the call to btrfs_tree_mod_log_insert_key() but we totally ignore its return value.
So fix this by adding the missing error handling, resulting in a transaction abort and freeing the COWed extent buffer.
--- fs/btrfs/ctree.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/ctree.c +8 -2
@@ -594,8 +594,14 @@ static noinline int __btrfs_cow_block(stadd_root_to_dirty_list (root); }else {WARN_ON (trans->transid !=btrfs_header_generation (parent)); -btrfs_tree_mod_log_insert_key (parent, parent_slot, -BTRFS_MOD_LOG_KEY_REPLACE ); + ret =btrfs_tree_mod_log_insert_key (parent, parent_slot, +BTRFS_MOD_LOG_KEY_REPLACE ); +if (ret) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow); +btrfs_abort_transaction (trans, ret); +return ret; + }btrfs_set_node_blockptr (parent, parent_slot, cow->start); btrfs_set_node_ptr_generation(parent, parent_slot,
Greg Kroah-Hartman
maintainerPATCH 764/800 btrfs: fix extent buffer leak after tree mod log failure at split_node()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit ede600e497b1461d06d22a7d17703d9096868bc3 upstream.
At split_node(), if we fail to log the tree mod log copy operation, we return without unlocking the split extent buffer we just allocated and without decrementing the reference we own on it. Fix this by unlocking it and decrementing the ref count before returning.
--- fs/btrfs/ctree.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/ctree.c +2 -0
@@ -2982,6 +2982,8 @@ static noinline int split_node(struct bt ret =btrfs_tree_mod_log_eb_copy (split, c,0 , mid, c_nritems - mid);if (ret) { +btrfs_tree_unlock (split); +free_extent_buffer (split);btrfs_abort_transaction (trans, ret);return ret; }
Greg Kroah-Hartman
maintainerPATCH 765/800 btrfs: do not BUG_ON() on tree mod log failure at __btrfs_cow_block()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 40b0a749388517de244643c09bdbb98f7dcb6ef1 upstream.
At __btrfs_cow_block(), instead of doing a BUG_ON() in case we fail to record a tree mod log root insertion operation, do a transaction abort instead. There's really no need for the BUG_ON(), we can properly release all resources in this context and turn the filesystem to RO mode and in an error state instead.
--- fs/btrfs/ctree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/btrfs/ctree.c +7 -2
@@ -583,9 +583,14 @@ static noinline int __btrfs_cow_block(st btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) parent_start = buf->start; -atomic_inc (&cow->refs); ret =btrfs_tree_mod_log_insert_root (root->node, cow, true); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow); +btrfs_abort_transaction (trans, ret); +return ret; + } +atomic_inc (&cow->refs);rcu_assign_pointer (root->node, cow); btrfs_free_tree_block(trans, btrfs_root_id(root), buf,
Greg Kroah-Hartman
maintainerPATCH 766/800 ASoC: mediatek: mt8173: Fix irq error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda Delgado <[email protected]>
commit f9c058d14f4fe23ef523a7ff73734d51c151683c upstream.
After reordering the irq probe, the error path was not properly done. Lets fix it.
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +5 -4
@@ -1070,6 +1070,10 @@ static int mt8173_afe_pcm_dev_probe(stru afe->dev = &pdev->dev; + irq_id =platform_get_irq (pdev,0 ); +if (irq_id <=0 ) +return irq_id <0 ? irq_id : -ENXIO ; + afe->base_addr =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (afe->base_addr))return PTR_ERR (afe->base_addr);
@@ -1175,14 +1179,11 @@ static int mt8173_afe_pcm_dev_probe(struif (ret) goto err_cleanup_components; - irq_id =platform_get_irq (pdev,0 ); -if (irq_id <=0 ) -return irq_id <0 ? irq_id : -ENXIO ; ret =devm_request_irq (afe->dev, irq_id, mt8173_afe_irq_handler,0 ,"Afe_ISR_Handle" , (void *)afe);if (ret) {dev_err (afe->dev,"could not request_irq\n" ); - goto err_pm_disable; + goto err_cleanup_components; }dev_info (&pdev->dev,"MT8173 AFE driver initialized.\n" );
Greg Kroah-Hartman
maintainerPATCH 767/800 ASoC: mediatek: mt8173: Fix snd_soc_component_initialize error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda Delgado <[email protected]>
commit a46d37012a5be1737393b8f82fd35665e4556eee upstream.
If the second component fails to initialize, cleanup the first on.
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +2 -2
@@ -1160,14 +1160,14 @@ static int mt8173_afe_pcm_dev_probe(stru comp_hdmi =devm_kzalloc (&pdev->dev,sizeof (*comp_hdmi),GFP_KERNEL );if (!comp_hdmi) { ret = -ENOMEM ; - goto err_pm_disable; + goto err_cleanup_components; } ret =snd_soc_component_initialize (comp_hdmi, &mt8173_afe_hdmi_dai_component, &pdev->dev);if (ret) - goto err_pm_disable; + goto err_cleanup_components;#ifdef CONFIG_DEBUG_FS comp_hdmi->debugfs_prefix ="hdmi" ;
Greg Kroah-Hartman
maintainerPATCH 768/800 regulator: tps65219: Fix matching interrupts for their regulators
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit f050e56de80591fee55bedbdf5b6b998c740cd0c upstream.
The driver's probe() first registers regulators in a loop and then in a second loop passes them as irq data to the interrupt handlers. However the function to get the regulator for given name tps65219_get_rdev_by_name() was a no-op due to argument passed by value, not pointer, thus the second loop assigned always same value - from previous loop. The interrupts, when fired, where executed with wrong data. Compiler also noticed it:
drivers/regulator/tps65219-regulator.c: In function ‘tps65219_get_rdev_by_name’:
drivers/regulator/tps65219-regulator.c:292:60: error: parameter ‘dev’ set but not used [-Werror=unused-but-set-parameter]
--- drivers/regulator/tps65219-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/tps65219-regulator.c +3 -3
@@ -289,13 +289,13 @@ static irqreturn_t tps65219_regulator_irstatic int tps65219_get_rdev_by_name (const char *regulator_name,struct regulator_dev *rdevtbl[7 ], -struct regulator_dev *dev) +struct regulator_dev **dev) {int i;for (i =0 ; i <ARRAY_SIZE (regulators); i++) {if (strcmp (regulator_name, regulators[i].name) ==0 ) { - dev = rdevtbl[i]; + *dev = rdevtbl[i];return 0 ; } }
@@ -348,7 +348,7 @@ static int tps65219_regulator_probe(stru irq_data[i].dev = tps->dev; irq_data[i].type = irq_type; -tps65219_get_rdev_by_name (irq_type->regulator_name, rdevtbl, rdev); +tps65219_get_rdev_by_name (irq_type->regulator_name, rdevtbl, &rdev);if (IS_ERR (rdev)) {dev_err (tps->dev,"Failed to get rdev for %s\n" , irq_type->regulator_name);
Greg Kroah-Hartman
maintainerPATCH 769/800 ARM: dts: qcom: msm8660: Fix regulator node names
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
commit a0f19091d4f5bbe97485592257b88007eb5b1998 upstream.
commit 04715461abf7 altered the node names in a DTSI file used by qcom-apq8060-dragonboard.dts breaking the board. Align the node names in the DTS file and the board boots again.
--- arch/arm/boot/dts/qcom-apq8060-dragonboard.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/qcom-apq8060-dragonboard.dts +2 -2
@@ -451,7 +451,7 @@ * PM8901 supplies "preliminary regulators" whatever * that means */ - pm8901-regulators { + regulators-0 { vdd_l0-supply = <&pm8901_s4>; vdd_l1-supply = <&vph>; vdd_l2-supply = <&vph>;
@@ -537,7 +537,7 @@ }; - pm8058-regulators { + regulators-1 { vdd_l0_l1_lvs-supply = <&pm8058_s3>; vdd_l2_l11_l12-supply = <&vph>; vdd_l3_l4_l5-supply = <&vph>;
Greg Kroah-Hartman
maintainerPATCH 770/800 ARM: dts: qcom: ipq4019: fix broken NAND controller properties override
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit edcbdd57de499305e2a3737d4a73fe387f71d84c upstream.
After renaming NAND controller node name from "qpic-nand" to "nand-controller", the board DTS/DTSI also have to be updated:
Warning (unit_address_vs_reg): /soc/qpic-nand@79b0000: node has a unit name, but no reg or ranges property
--- arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts | 8 ++++---- arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi | 10 +++++----- arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-)
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts +4 -4
@@ -11,9 +11,9 @@ dma-controller@7984000 { status = "okay"; }; - - qpic-nand@79b0000 { - status = "okay"; - }; }; }; + +&nand { + status = "okay"; +};
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi +5 -5
@@ -102,10 +102,10 @@ status = "okay"; perst-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; }; - - qpic-nand@79b0000 { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - }; }; }; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; +};
arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi +6 -6
@@ -65,11 +65,11 @@ dma-controller@7984000 { status = "okay"; }; - - qpic-nand@79b0000 { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - status = "okay"; - }; }; }; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; + status = "okay"; +};
Greg Kroah-Hartman
maintainerPATCH 771/800 ARM: orion5x: fix d2net gpio initialization
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit f8ef1233939495c405a9faa4bd1ae7d3f581bae4 upstream.
The DT version of this board has a custom file with the gpio device. However, it does nothing because the d2net_init() has no caller or prototype:
arch/arm/mach-orion5x/board-d2net.c:101:13: error: no previous prototype for 'd2net_init'
Call it from the board-dt file as intended.
--- arch/arm/mach-orion5x/board-dt.c | 3 +++ arch/arm/mach-orion5x/common.h | 6 ++++++ 2 files changed, 9 insertions(+)
arch/arm/mach-orion5x/board-dt.c +3 -0
@@ -60,6 +60,9 @@ static void __init orion5x_dt_init(void)if (of_machine_is_compatible ("maxtor,shared-storage-2" ))mss2_init (); +if (of_machine_is_compatible ("lacie,d2-network" )) +d2net_init (); +of_platform_default_populate (NULL , orion5x_auxdata_lookup,NULL ); }
arch/arm/mach-orion5x/common.h +6 -0
@@ -73,6 +73,12 @@ extern void mss2_init(void);static inline void mss2_init (void ) {}#endif +#ifdef CONFIG_MACH_D2NET_DT +void d2net_init (void ); +#else +static inline void d2net_init (void ) {} +#endif +/***************************************************************************** * Helpers to access Orion registers ****************************************************************************/
Greg Kroah-Hartman
maintainerPATCH 772/800 leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on dev rename
In reply to Greg Kroah-HartmanFrom: Christian Marangi <[email protected]>
commit cee4bd16c3195a701be683f7da9e88c6e11acb73 upstream.
Dev can be renamed also while up for supported device. We currently wrongly clear the NETDEV_LED_MODE_LINKUP flag on NETDEV_CHANGENAME event.
Fix this by rechecking if the carrier is ok on NETDEV_CHANGENAME and correctly set the NETDEV_LED_MODE_LINKUP bit.
--- drivers/leds/trigger/ledtrig-netdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/leds/trigger/ledtrig-netdev.c +3 -0
@@ -318,6 +318,9 @@ static int netdev_trig_notify(struct notclear_bit (NETDEV_LED_MODE_LINKUP , &trigger_data->mode);switch (evt) {case NETDEV_CHANGENAME : +if (netif_carrier_ok (dev)) +set_bit (NETDEV_LED_MODE_LINKUP , &trigger_data->mode); + fallthrough;case NETDEV_REGISTER :if (trigger_data->net_dev)dev_put (trigger_data->net_dev);
Greg Kroah-Hartman
maintainerPATCH 773/800 blktrace: use inline function for blk_trace_remove() while blktrace is disabled
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
commit cbe7cff4a76bc749dd70264ca5cf924e2adf9296 upstream.
If config is disabled, call blk_trace_remove() directly will trigger build warning, hence use inline function instead, prepare to fix blktrace debugfs entries leakage.
--- include/linux/blktrace_api.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/blktrace_api.h +5 -1
@@ -85,10 +85,14 @@ extern int blk_trace_remove(struct reque# define blk_add_driver_data (rq, data, len) do {} while (0)# define blk_trace_setup (q, name, dev, bdev, arg) (-ENOTTY)# define blk_trace_startstop (q, start) (-ENOTTY) -# define blk_trace_remove (q) (-ENOTTY)# define blk_add_trace_msg (q, fmt, ...) do { } while (0)# define blk_add_cgroup_trace_msg (q, cg, fmt, ...) do { } while (0)# define blk_trace_note_message_enabled (q) (false) + +static inline int blk_trace_remove (struct request_queue *q) +{ +return -ENOTTY ; +}#endif /* CONFIG_BLK_DEV_IO_TRACE */ #ifdef CONFIG_COMPAT
Greg Kroah-Hartman
maintainerPATCH 774/800 Input: ads7846 - Fix usage of match data
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
commit 8f7913c04f6a7b90bcf998ece17395d7090f6d44 upstream.
device_get_match_data() returns the match data directly, fix this up and fix the probe crash.
--- drivers/input/touchscreen/ads7846.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/input/touchscreen/ads7846.c +1 -8
@@ -1117,20 +1117,13 @@ MODULE_DEVICE_TABLE(of, ads7846_dt_ids);static const struct ads7846_platform_data *ads7846_get_props (struct device *dev) {struct ads7846_platform_data *pdata; -const struct platform_device_id *pdev_id;u32 value; - pdev_id =device_get_match_data (dev); -if (!pdev_id) { -dev_err (dev,"Unknown device model\n" ); -return ERR_PTR (-EINVAL ); - } - pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL );if (!pdata)return ERR_PTR (-ENOMEM ); - pdata->model = (unsigned long )pdev_id->driver_data; + pdata->model = (u32 )device_get_match_data (dev);device_property_read_u16 (dev,"ti,vref-delay-usecs" , &pdata->vref_delay_usecs);
Greg Kroah-Hartman
maintainerPATCH 775/800 md/raid1-10: fix casting from randomized structure in raid1_submit_write()
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
commit b5a99602b74bbfa655be509c615181dd95b0719e upstream.
Following build error triggered while build with clang version 17.0.0 with W=1(this can't be reporduced with gcc 13.1.0):
drivers/md/raid1-10.c:117:25: error: casting from randomized structure pointer type 'struct block_device *' to 'struct md_rdev *'
117 | struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev;
| ^Fix this by casting 'bio->bi_bdev' to 'void *', as it used to be.
--- drivers/md/raid1-10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid1-10.c +1 -1
@@ -113,7 +113,7 @@ static void md_bio_reset_resync_pages(ststatic inline void raid1_submit_write (struct bio *bio) { -struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev; +struct md_rdev *rdev = (void *)bio->bi_bdev; bio->bi_next =NULL ;bio_set_dev (bio, rdev->bdev);
Greg Kroah-Hartman
maintainerPATCH 776/800 fs: no need to check source
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 66d8fc0539b0d49941f313c9509a8384e4245ac1 upstream.
The @source inode must be valid. It is even checked via IS_SWAPFILE() above making it pretty clear. So no need to check it when we unlock.
What doesn't need to exist is the @target inode. The lock_two_inodes() helper currently swaps the @inode1 and @inode2 arguments if @inode1 is NULL to have consistent lock class usage. However, we know that at least for vfs_rename() that @inode1 is @source and thus is never NULL as per above. We also know that @source is a different inode than @target as that is checked right at the beginning of vfs_rename(). So we know that @source is valid and locked and that @target is locked. So drop the check whether @source is non-NULL.
Message-Id: <[email protected]>
--- fs/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/namei.c +1 -2
@@ -4872,8 +4872,7 @@ int vfs_rename(struct renamedata *rd)d_exchange (old_dentry, new_dentry); } out: -if (source) -inode_unlock (source); +inode_unlock (source);if (target)inode_unlock (target);dput (new_dentry);
Greg Kroah-Hartman
maintainerPATCH 777/800 Input: ads7846 - fix pointer cast warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 11ca605653480b2ddc70ec142a0a686796a7fc87 upstream.
The previous bugfix caused a warning on 64-bit builds:
drivers/input/touchscreen/ads7846.c:1126:17: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'const void *' [-Wvoid-pointer-to-int-cast]
Change the cast back to something that works on both 32-bit and 64-bit kernels.
--- drivers/input/touchscreen/ads7846.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/ads7846.c +1 -1
@@ -1123,7 +1123,7 @@ static const struct ads7846_platform_datif (!pdata)return ERR_PTR (-ENOMEM ); - pdata->model = (u32 )device_get_match_data (dev); + pdata->model = (uintptr_t )device_get_match_data (dev);device_property_read_u16 (dev,"ti,vref-delay-usecs" , &pdata->vref_delay_usecs);
Greg Kroah-Hartman
maintainerPATCH 778/800 mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 08f6554ff90ef189e6b8f0303e57005bddfdd6a7 upstream.
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following error appears when building ARCH=mips with clang (tip of tree error shown):
clang: error: unsupported option '-mabi=' for target 'x86_64-pc-linux-gnu'
Add KBUILD_CPPFLAGS in the CHECKFLAGS invocation to keep everything working after the move.
--- arch/mips/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Makefile +1 -1
@@ -346,7 +346,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwin KBUILD_LDFLAGS += -m $(ld-emul) ifdef CONFIG_MIPS -CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ +CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') endif
Greg Kroah-Hartman
maintainerPATCH 779/800 powerpc/vdso: Include CLANG_FLAGS explicitly in ldflags-y
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit a7e5eb53bf9b800d086e2ebcfebd9a3bb16bd1b0 upstream.
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following error appears when building the compat PowerPC vDSO:
clang: error: unsupported option '-mbig-endian' for target 'x86_64-pc-linux-gnu' make[3]: *** [.../arch/powerpc/kernel/vdso/Makefile:76: arch/powerpc/kernel/vdso/vdso32.so.dbg] Error 1
Explicitly add CLANG_FLAGS to ldflags-y, so that '--target' will always be present.
--- arch/powerpc/kernel/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/vdso/Makefile +1 -1
@@ -54,7 +54,7 @@ KASAN_SANITIZE := n KCSAN_SANITIZE := n ccflags-y := -fno-common -fno-builtin -ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack +ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) # Filter flags that clang will warn are unused for linking ldflags-y += $(filter-out $(CC_AUTO_VAR_INIT_ZERO_ENABLER) $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS))
Greg Kroah-Hartman
maintainerPATCH 780/800 kbuild: Add CLANG_FLAGS to as-instr
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit cff6e7f50bd315e5b39c4e46c704ac587ceb965f upstream.
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following errors appear multiple times when building ARCH=powerpc powernv_defconfig:
ld.lld: error: vmlinux.a(arch/powerpc/kernel/head_64.o):(.text+0x12d4): relocation R_PPC64_ADDR16_HI out of range: -4611686018409717520 is not in [-2147483648, 2147483647]; references '__start___soft_mask_table' ld.lld: error: vmlinux.a(arch/powerpc/kernel/head_64.o):(.text+0x12e8): relocation R_PPC64_ADDR16_HI out of range: -4611686018409717392 is not in [-2147483648, 2147483647]; references '__stop___soft_mask_table'
Diffing the .o.cmd files reveals that -DHAVE_AS_ATHIGH=1 is not present anymore, because as-instr only uses KBUILD_AFLAGS, which will no longer contain '--target'.
Mirror Kconfig's as-instr and add CLANG_FLAGS explicitly to the invocation to ensure the target information is always present.
--- scripts/Makefile.compiler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.compiler +1 -1
@@ -38,7 +38,7 @@ as-option = $(call try-run,\ # Usage: aflags-y += $(call as-instr,instr,option1,option2) as-instr = $(call try-run,\ - printf "%b\n" "$(1)" | $(CC) -Werror $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) + printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) # __cc-option # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
Greg Kroah-Hartman
maintainerPATCH 781/800 kbuild: Add KBUILD_CPPFLAGS to as-option invocation
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 43fc0a99906e04792786edf8534d8d58d1e9de0c upstream.
After commit feb843a469fb ("kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS"), there is an error while building certain PowerPC assembly files with clang:
arch/powerpc/lib/copypage_power7.S: Assembler messages:
arch/powerpc/lib/copypage_power7.S:34: Error: junk at end of line: 0b01000' arch/powerpc/lib/copypage_power7.S:35: Error: junk at end of line: 0b01010' arch/powerpc/lib/copypage_power7.S:37: Error: junk at end of line: 0b01000' arch/powerpc/lib/copypage_power7.S:38: Error: junk at end of line: 0b01010' arch/powerpc/lib/copypage_power7.S:40: Error: junk at end of line: `0b01010'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
as-option only uses KBUILD_AFLAGS, so after removing CLANG_FLAGS from KBUILD_AFLAGS, there is no more '--target=' or '--prefix=' flags. As a result of those missing flags, the host target
will be tested during as-option calls and likely fail, meaning necessary flags may not get added when building assembly files, resulting in errors like seen above.
Add KBUILD_CPPFLAGS to as-option invocations to clear up the errors. This should have been done in commit d5c8d6e0fa61 ("kbuild: Update assembler calls to use proper flags and language target"), which switched from using the assembler target to the assembler-with-cpp target, so flags that affect preprocessing are passed along in all relevant tests. as-option now mirrors cc-option.
--- scripts/Makefile.compiler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.compiler +1 -1
@@ -32,7 +32,7 @@ try-run = $(shell set -e; \ # Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,) as-option = $(call try-run,\ - $(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) + $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) # as-instr # Usage: aflags-y += $(call as-instr,instr,option1,option2)
Greg Kroah-Hartman
maintainerPATCH 782/800 kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit feb843a469fb0ab00d2d23cfb9bcc379791011bb upstream.
When preprocessing arch/*/kernel/vmlinux.lds.S, the target triple is not passed to $(CPP) because we add it only to KBUILD_{C,A}FLAGS.
As a result, the linker script is preprocessed with predefined macros for the build host instead of the target.
Assuming you use an x86 build machine, compare the following:
$ clang -dM -E -x c /dev/null $ clang -dM -E -x c /dev/null -target aarch64-linux-gnu
There is no actual problem presumably because our linker scripts do not rely on such predefined macros, but it is better to define correct ones.
Move $(CLANG_FLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *.lds.S will be processed with the proper target triple.
[Note]
After the patch submission, we got an actual problem that needs this commit. (CBL issue 1859)
--- scripts/Makefile.clang | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/Makefile.clang +1 -2
@@ -34,6 +34,5 @@ CLANG_FLAGS += -Werror=unknown-warning-o CLANG_FLAGS += -Werror=ignored-optimization-argument CLANG_FLAGS += -Werror=option-ignored CLANG_FLAGS += -Werror=unused-command-line-argument -KBUILD_CFLAGS += $(CLANG_FLAGS) -KBUILD_AFLAGS += $(CLANG_FLAGS) +KBUILD_CPPFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS
Greg Kroah-Hartman
maintainerPATCH 783/800 ovl: fix null pointer dereference in ovl_permission()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 1a73f5b8f079fd42a544c1600beface50c63af7c upstream.
Following process:
P1 P2
path_lookupat
link_path_walk
inode_permission
ovl_permission
ovl_i_path_real(inode, &realpath)
path->dentry = ovl_i_dentry_upper(inode)
drop_cache
__dentry_kill(ovl_dentry)
iput(ovl_inode)
ovl_destroy_inode(ovl_inode)
dput(oi->__upperdentry)
dentry_kill(upperdentry)
dentry_unlink_inode
upperdentry->d_inode = NULL
realinode = d_inode(realpath.dentry) // return NULL
inode_permission(realinode)
inode->i_sb // NULL pointer dereference
, will trigger an null pointer dereference at realinode:
[ 335.664979] BUG: kernel NULL pointer dereference,
address: 0000000000000002
[ 335.668032] CPU: 0 PID: 2592 Comm: ls Not tainted 6.3.0
[ 335.669956] RIP: 0010:inode_permission+0x33/0x2c0
[ 335.678939] Call Trace:
[ 335.679165] <TASK>
[ 335.679371] ovl_permission+0xde/0x320
[ 335.679723] inode_permission+0x15e/0x2c0
[ 335.680090] link_path_walk+0x115/0x550
[ 335.680771] path_lookupat.isra.0+0xb2/0x200
[ 335.681170] filename_lookup+0xda/0x240
[ 335.681922] vfs_statx+0xa6/0x1f0
[ 335.682233] vfs_fstatat+0x7b/0xb0Fetch a reproducer in [Link].
Use the helper ovl_i_path_realinode() to get realinode and then do non-nullptr checking.
--- fs/overlayfs/inode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/overlayfs/inode.c +2 -3
@@ -288,8 +288,8 @@ int ovl_permission(struct mnt_idmap *idmint err;/* Careful in RCU walk mode */ -ovl_i_path_real (inode, &realpath); -if (!realpath.dentry) { + realinode =ovl_i_path_real (inode, &realpath); +if (!realinode) {WARN_ON (!(mask &MAY_NOT_BLOCK ));return -ECHILD ; }
@@ -302,7 +302,6 @@ int ovl_permission(struct mnt_idmap *idmif (err)return err; - realinode =d_inode (realpath.dentry); old_cred =ovl_override_creds (inode->i_sb);if (!upperinode && !special_file (realinode->i_mode) && mask &MAY_WRITE ) {
Greg Kroah-Hartman
maintainerPATCH 784/800 ovl: let helper ovl_i_path_real() return the realinode
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit b2dd05f107b11966e26fe52a313b418364cf497b upstream.
Let helper ovl_i_path_real() return the realinode to prepare for checking non-null realinode in RCU walking path.
[msz] Use d_inode_rcu() since we are depending on the consitency between dentry and inode being non-NULL in an RCU setting.
--- fs/overlayfs/overlayfs.h | 2 +- fs/overlayfs/util.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
fs/overlayfs/overlayfs.h +1 -1
@@ -384,7 +384,7 @@ enum ovl_path_type ovl_path_type(structvoid ovl_path_upper (struct dentry *dentry,struct path *path);void ovl_path_lower (struct dentry *dentry,struct path *path);void ovl_path_lowerdata (struct dentry *dentry,struct path *path); -void ovl_i_path_real (struct inode *inode,struct path *path); +struct inode *ovl_i_path_real (struct inode *inode,struct path *path);enum ovl_path_type ovl_path_real (struct dentry *dentry,struct path *path);enum ovl_path_type ovl_path_realdata (struct dentry *dentry,struct path *path);struct dentry *ovl_dentry_upper (struct dentry *dentry);
fs/overlayfs/util.c +4 -3
@@ -266,7 +266,7 @@ struct dentry *ovl_i_dentry_upper(structreturn ovl_upperdentry_dereference (OVL_I (inode)); } -void ovl_i_path_real (struct inode *inode,struct path *path) +struct inode *ovl_i_path_real (struct inode *inode,struct path *path) { path->dentry =ovl_i_dentry_upper (inode);if (!path->dentry) {
@@ -275,6 +275,8 @@ void ovl_i_path_real(struct inode *inode }else { path->mnt =ovl_upper_mnt (OVL_FS (inode->i_sb)); } + +return path->dentry ?d_inode_rcu (path->dentry) :NULL ; }struct inode *ovl_inode_upper (struct inode *inode)
@@ -1121,8 +1123,7 @@ void ovl_copyattr(struct inode *inode)vfsuid_t vfsuid;vfsgid_t vfsgid; -ovl_i_path_real (inode, &realpath); - realinode =d_inode (realpath.dentry); + realinode =ovl_i_path_real (inode, &realpath); real_idmap =mnt_idmap (realpath.mnt); vfsuid =i_uid_into_vfsuid (real_idmap, realinode);
Greg Kroah-Hartman
maintainerPATCH 785/800 ovl: fix null pointer dereference in ovl_get_acl_rcu()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit f4e19e595cc2e76a8a58413eb19d3d9c51328b53 upstream.
Following process:
P1 P2
path_openat
link_path_walk
may_lookup
inode_permission(rcu)
ovl_permission
acl_permission_check
check_acl
get_cached_acl_rcu
ovl_get_inode_acl
realinode = ovl_inode_real(ovl_inode)
drop_cache
__dentry_kill(ovl_dentry)
iput(ovl_inode)
ovl_destroy_inode(ovl_inode)
dput(oi->__upperdentry)
dentry_kill(upperdentry)
dentry_unlink_inode
upperdentry->d_inode = NULL
ovl_inode_upper
upperdentry = ovl_i_dentry_upper(ovl_inode) d_inode(upperdentry) // returns NULL
IS_POSIXACL(realinode) // NULL pointer dereference
, will trigger an null pointer dereference at realinode:
[ 205.472797] BUG: kernel NULL pointer dereference, address:
0000000000000028
[ 205.476701] CPU: 2 PID: 2713 Comm: ls Not tainted
6.3.0-12064-g2edfa098e750-dirty #1216
[ 205.478754] RIP: 0010:do_ovl_get_acl+0x5d/0x300
[ 205.489584] Call Trace:
[ 205.489812] <TASK>
[ 205.490014] ovl_get_inode_acl+0x26/0x30
[ 205.490466] get_cached_acl_rcu+0x61/0xa0
[ 205.490908] generic_permission+0x1bf/0x4e0
[ 205.491447] ovl_permission+0x79/0x1b0
[ 205.491917] inode_permission+0x15e/0x2c0
[ 205.492425] link_path_walk+0x115/0x550
[ 205.493311] path_lookupat.isra.0+0xb2/0x200
[ 205.493803] filename_lookup+0xda/0x240
[ 205.495747] vfs_fstatat+0x7b/0xb0Fetch a reproducer in [Link].
Use the helper ovl_i_path_realinode() to get realinode and then do non-nullptr checking.
--- fs/overlayfs/inode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/overlayfs/inode.c +6 -6
@@ -558,20 +558,20 @@ struct posix_acl *do_ovl_get_acl(struct struct inode *inode, int type, bool rcu, bool noperm) { - struct inode *realinode = ovl_inode_real(inode); + struct inode *realinode;struct posix_acl *acl;struct path realpath; -if (!IS_POSIXACL (realinode)) -return NULL ; -/* Careful in RCU walk mode */ -ovl_i_path_real (inode, &realpath); -if (!realpath.dentry) { + realinode =ovl_i_path_real (inode, &realpath); +if (!realinode) {WARN_ON (!rcu);return ERR_PTR (-ECHILD ); } +if (!IS_POSIXACL (realinode)) +return NULL ; +if (rcu) {/* * If the layer is idmapped drop out of RCU path walk
Greg Kroah-Hartman
maintainerPATCH 786/800 LoongArch: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation
In reply to Greg Kroah-HartmanFrom: WANG Xuerui <[email protected]>
commit 5ddc7a3794ddd3470635ebd325fa1dffea5b18c0 upstream.
This is a port of commit 08f6554ff90e ("mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation of Linux/LoongArch with Clang, where previously the --target flag would no longer be present for the CHECKFLAGS cc invocation leading to build failure.
--- arch/loongarch/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/Makefile +1 -1
@@ -107,7 +107,7 @@ KBUILD_CFLAGS += -isystem $(shell $(CC) KBUILD_LDFLAGS += -m $(ld-emul) ifdef CONFIG_LOONGARCH -CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ +CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') endif
Greg Kroah-Hartman
maintainerPATCH 787/800 drm/amdgpu: make sure BOs are locked in amdgpu_vm_get_memory
In reply to Greg Kroah-HartmanFrom: Christian K�nig <[email protected]>
commit e2ad8e2df432498b1cee2af04df605723f4d75e6 upstream.
We need to grab the lock of the BO or otherwise can run into a crash when we try to inspect the current location.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 69 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +39 -30
@@ -920,42 +920,51 @@ error_unlock:return r; } +static void amdgpu_vm_bo_get_memory (struct amdgpu_bo_va *bo_va, +struct amdgpu_mem_stats *stats) +{ +struct amdgpu_vm *vm = bo_va->base.vm; +struct amdgpu_bo *bo = bo_va->base.bo; + +if (!bo) +return ; + +/* +* For now ignore BOs which are currently locked and potentially +* changing their location. +*/ +if (bo->tbo.base.resv != vm->root.bo->tbo.base.resv && + !dma_resv_trylock (bo->tbo.base.resv)) +return ; + +amdgpu_bo_get_memory (bo, stats); +if (bo->tbo.base.resv != vm->root.bo->tbo.base.resv) +dma_resv_unlock (bo->tbo.base.resv); +} +void amdgpu_vm_get_memory (struct amdgpu_vm *vm,struct amdgpu_mem_stats *stats) {struct amdgpu_bo_va *bo_va, *tmp;spin_lock (&vm->status_lock); -list_for_each_entry_safe (bo_va, tmp, &vm->idle, base.vm_status) { -if (!bo_va->base.bo) -continue ; -amdgpu_bo_get_memory (bo_va->base.bo, stats); - } -list_for_each_entry_safe (bo_va, tmp, &vm->evicted, base.vm_status) { -if (!bo_va->base.bo) -continue ; -amdgpu_bo_get_memory (bo_va->base.bo, stats); - } -list_for_each_entry_safe (bo_va, tmp, &vm->relocated, base.vm_status) { -if (!bo_va->base.bo) -continue ; -amdgpu_bo_get_memory (bo_va->base.bo, stats); - } -list_for_each_entry_safe (bo_va, tmp, &vm->moved, base.vm_status) { -if (!bo_va->base.bo) -continue ; -amdgpu_bo_get_memory (bo_va->base.bo, stats); - } -list_for_each_entry_safe (bo_va, tmp, &vm->invalidated, base.vm_status) { -if (!bo_va->base.bo) -continue ; -amdgpu_bo_get_memory (bo_va->base.bo, stats); - } -list_for_each_entry_safe (bo_va, tmp, &vm->done, base.vm_status) { -if (!bo_va->base.bo) -continue ; -amdgpu_bo_get_memory (bo_va->base.bo, stats); - } +list_for_each_entry_safe (bo_va, tmp, &vm->idle, base.vm_status) +amdgpu_vm_bo_get_memory (bo_va, stats); + +list_for_each_entry_safe (bo_va, tmp, &vm->evicted, base.vm_status) +amdgpu_vm_bo_get_memory (bo_va, stats); + +list_for_each_entry_safe (bo_va, tmp, &vm->relocated, base.vm_status) +amdgpu_vm_bo_get_memory (bo_va, stats); + +list_for_each_entry_safe (bo_va, tmp, &vm->moved, base.vm_status) +amdgpu_vm_bo_get_memory (bo_va, stats); + +list_for_each_entry_safe (bo_va, tmp, &vm->invalidated, base.vm_status) +amdgpu_vm_bo_get_memory (bo_va, stats); + +list_for_each_entry_safe (bo_va, tmp, &vm->done, base.vm_status) +amdgpu_vm_bo_get_memory (bo_va, stats);spin_unlock (&vm->status_lock); }