habanalabs: add validity check for event ID received from F/W
Subsystems (6)
Sasha Levin
maintainerPATCH 1/8 habanalabs: add validity check for event ID received from F/W
From: Ofir Bitton <[email protected]>
[ Upstream commit a6c849012b0f51c674f52384bd9a4f3dc0a33c31 ]
Currently there is no validity check for event ID received from F/W, Thus exposing driver to memory overrun.
--- drivers/misc/habanalabs/gaudi/gaudi.c | 6 ++++++ drivers/misc/habanalabs/goya/goya.c | 6 ++++++ 2 files changed, 12 insertions(+)
drivers/misc/habanalabs/gaudi/gaudi.c +6 -0
@@ -5723,6 +5723,12 @@ static void gaudi_handle_eqe(struct hl_device *hdev,u8 cause;bool reset_required; +if (event_type >=GAUDI_EVENT_SIZE ) { +dev_err (hdev->dev,"Event type %u exceeds maximum of %u" , + event_type,GAUDI_EVENT_SIZE -1 ); +return ; + } + gaudi->events_stat[event_type]++; gaudi->events_stat_aggregate[event_type]++;
drivers/misc/habanalabs/goya/goya.c +6 -0
@@ -4623,6 +4623,12 @@ void goya_handle_eqe(struct hl_device *hdev, struct hl_eq_entry *eq_entry) >> EQ_CTL_EVENT_TYPE_SHIFT);struct goya_device *goya = hdev->asic_specific; +if (event_type >=GOYA_ASYNC_EVENT_ID_SIZE ) { +dev_err (hdev->dev,"Event type %u exceeds maximum of %u" , + event_type,GOYA_ASYNC_EVENT_ID_SIZE -1 ); +return ; + } + goya->events_stat[event_type]++; goya->events_stat_aggregate[event_type]++;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 2/8 pwm: img: Don't modify HW state in .remove() callback
From: Uwe Kleine-König <[email protected]>
[ Upstream commit c68eb29c8e9067c08175dd0414f6984f236f719d ]
A consumer is expected to disable a PWM before calling pwm_put(). And if they didn't there is hopefully a good reason (or the consumer needs fixing). Also if disabling an enabled PWM was the right thing to do, this should better be done in the framework instead of in each low level driver.
--- drivers/pwm/pwm-img.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/pwm/pwm-img.c +0 -16
@@ -329,23 +329,7 @@ static int img_pwm_probe(struct platform_device *pdev)static int img_pwm_remove (struct platform_device *pdev) {struct img_pwm_chip *pwm_chip =platform_get_drvdata (pdev); -u32 val; -unsigned int i; -int ret; - - ret =pm_runtime_get_sync (&pdev->dev); -if (ret <0 ) { -pm_runtime_put (&pdev->dev); -return ret; - } - -for (i =0 ; i < pwm_chip->chip.npwm; i++) { - val =img_pwm_readl (pwm_chip,PWM_CTRL_CFG ); - val &= ~BIT (i); -img_pwm_writel (pwm_chip,PWM_CTRL_CFG , val); - } -pm_runtime_put (&pdev->dev);pm_runtime_disable (&pdev->dev);if (!pm_runtime_status_suspended (&pdev->dev))img_pwm_runtime_suspend (&pdev->dev);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 3/8 pwm: rockchip: Don't modify HW state in .remove() callback
In reply to Sasha LevinFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 9d768cd7fd42bb0be16f36aec48548fca5260759 ]
A consumer is expected to disable a PWM before calling pwm_put(). And if they didn't there is hopefully a good reason (or the consumer needs fixing). Also if disabling an enabled PWM was the right thing to do, this should better be done in the framework instead of in each low level driver.
--- drivers/pwm/pwm-rockchip.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/pwm/pwm-rockchip.c +0 -14
@@ -382,20 +382,6 @@ static int rockchip_pwm_remove(struct platform_device *pdev) {struct rockchip_pwm_chip *pc =platform_get_drvdata (pdev); -/* -* Disable the PWM clk before unpreparing it if the PWM device is still -* running. This should only happen when the last PWM user left it -* enabled, or when nobody requested a PWM that was previously enabled -* by the bootloader. -* -* FIXME: Maybe the core should disable all PWM devices in -* pwmchip_remove(). In this case we'd only have to call -* clk_unprepare() after pwmchip_remove(). -* -*/ -if (pwm_is_enabled (pc->chip.pwms)) -clk_disable (pc->clk); -clk_unprepare (pc->pclk);clk_unprepare (pc->clk);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 4/8 pwm: stm32-lp: Don't modify HW state in .remove() callback
In reply to Sasha LevinFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit d44084c93427bb0a9261432db1a8ca76a42d805e ]
A consumer is expected to disable a PWM before calling pwm_put(). And if they didn't there is hopefully a good reason (or the consumer needs fixing). Also if disabling an enabled PWM was the right thing to do, this should better be done in the framework instead of in each low level driver.
--- drivers/pwm/pwm-stm32-lp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/pwm/pwm-stm32-lp.c +0 -2
@@ -225,8 +225,6 @@ static int stm32_pwm_lp_remove(struct platform_device *pdev) {struct stm32_pwm_lp *priv =platform_get_drvdata (pdev); -pwm_disable (&priv->chip.pwms[0 ]); -return pwmchip_remove (&priv->chip); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 5/8 blk-throttle: fix UAF by deleteing timer in blk_throtl_exit()
In reply to Sasha LevinFrom: Li Jinlin <[email protected]>
[ Upstream commit 884f0e84f1e3195b801319c8ec3d5774e9bf2710 ]
The pending timer has been set up in blk_throtl_init(). However, the timer is not deleted in blk_throtl_exit(). This means that the timer handler may still be running after freeing the timer, which would result in a use-after-free.
Fix by calling del_timer_sync() to delete the timer in blk_throtl_exit().
--- block/blk-throttle.c | 1 + 1 file changed, 1 insertion(+)
block/blk-throttle.c +1 -0
@@ -2420,6 +2420,7 @@ int blk_throtl_init(struct request_queue *q)void blk_throtl_exit (struct request_queue *q) {BUG_ON (!q->td); +del_timer_sync (&q->td->service_queue.pending_timer);throtl_shutdown_wq (q);blkcg_deactivate_policy (q, &blkcg_policy_throtl);free_percpu (q->td->latency_buckets[READ ]);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 6/8 blk-mq: allow 4x BLK_MAX_REQUEST_COUNT at blk_plug for multiple_queues
In reply to Sasha LevinFrom: Song Liu <[email protected]>
[ Upstream commit 7f2a6a69f7ced6db8220298e0497cf60482a9d4b ]
Limiting number of request to BLK_MAX_REQUEST_COUNT at blk_plug hurts performance for large md arrays. [1] shows resync speed of md array drops for md array with more than 16 HDDs.
Fix this by allowing more request at plug queue. The multiple_queue flag is used to only apply higher limit to multiple queue cases.
--- block/blk-mq.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
block/blk-mq.c +13 -1
@@ -2109,6 +2109,18 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq) } } +/* +* Allow 4x BLK_MAX_REQUEST_COUNT requests on plug queue for multiple +* queues. This is important for md arrays to benefit from merging +* requests. +*/ +static inline unsigned short blk_plug_max_rq_count (struct blk_plug *plug) +{ +if (plug->multiple_queues) +return BLK_MAX_REQUEST_COUNT *4 ; +return BLK_MAX_REQUEST_COUNT ; +} +/** * blk_mq_submit_bio - Create and send a request to block device. * @bio: Bio pointer.
@@ -2202,7 +2214,7 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)else last =list_entry_rq (plug->mq_list.prev); -if (request_count >=BLK_MAX_REQUEST_COUNT || (last && +if (request_count >=blk_plug_max_rq_count (plug) || (last &&blk_rq_bytes (last) >=BLK_PLUG_FLUSH_SIZE )) {blk_flush_plug_list (plug, false);trace_block_plug (q);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 7/8 rtc: rx8010: select REGMAP_I2C
In reply to Sasha LevinFrom: Yu-Tung Chang <[email protected]>
[ Upstream commit 0c45d3e24ef3d3d87c5e0077b8f38d1372af7176 ]
The rtc-rx8010 uses the I2C regmap but doesn't select it in Kconfig so depending on the configuration the build may fail. Fix it.
--- drivers/rtc/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/Kconfig +1 -0
@@ -624,6 +624,7 @@ config RTC_DRV_FM3130 config RTC_DRV_RX8010 tristate "Epson RX8010SJ" + select REGMAP_I2C help If you say yes here you get support for the Epson RX8010SJ RTC chip.
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 8/8 sched/idle: Make the idle timer expire in hard interrupt context
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 9848417926353daa59d2b05eb26e185063dbac6e ]
The intel powerclamp driver will setup a per-CPU worker with RT priority. The worker will then invoke play_idle() in which it remains in the idle poll loop until it is stopped by the timer it started earlier.
That timer needs to expire in hard interrupt context on PREEMPT_RT. Otherwise the timer will expire in ksoftirqd as a SOFT timer but that task won't be scheduled on the CPU because its priority is lower than the priority of the worker which is in the idle loop.
Always expire the idle timer in hard interrupt context.
--- kernel/sched/idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/idle.c +2 -2
@@ -372,10 +372,10 @@ void play_idle_precise(u64 duration_ns, u64 latency_ns)cpuidle_use_deepest_state (latency_ns); it.done =0 ; -hrtimer_init_on_stack (&it.timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); +hrtimer_init_on_stack (&it.timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_HARD ); it.timer.function = idle_inject_timer_fn;hrtimer_start (&it.timer,ns_to_ktime (duration_ns), -HRTIMER_MODE_REL_PINNED ); +HRTIMER_MODE_REL_PINNED_HARD );while (!READ_ONCE (it.done))do_idle ();
Signature · 1 line
2.30.2