5.13.2-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 128/800 Add a reference to ucounts for each cred
In reply to Greg Kroah-HartmanFrom: Alexey Gladkov <[email protected]>
[ Upstream commit 905ae01c4ae2ae3df05bb141801b1db4b7d83c61 ]
For RLIMIT_NPROC and some other rlimits the user_struct that holds the global limit is kept alive for the lifetime of a process by keeping it in struct cred. Adding a pointer to ucounts in the struct cred will allow to track RLIMIT_NPROC not only for user in the system, but for user in the user_namespace.
Updating ucounts may require memory allocation which may fail. So, we cannot change cred.ucounts in the commit_creds() because this function cannot fail and it should always return 0. For this reason, we modify cred.ucounts before calling the commit_creds().
Changelog
v6:
* Fix null-ptr-deref in is_ucounts_overlimit() detected by trinity. This error was caused by the fact that cred_alloc_blank() left the ucounts pointer empty.
--- fs/exec.c | 4 ++++ include/linux/cred.h | 2 ++ include/linux/user_namespace.h | 4 ++++ kernel/cred.c | 40 ++++++++++++++++++++++++++++++++++ kernel/fork.c | 6 +++++ kernel/sys.c | 12 ++++++++++ kernel/ucount.c | 40 +++++++++++++++++++++++++++++++--- kernel/user_namespace.c | 3 +++ 8 files changed, 108 insertions(+), 3 deletions(-)
fs/exec.c +4 -0
@@ -1360,6 +1360,10 @@ int begin_new_exec(struct linux_binprm * bprm)WRITE_ONCE (me->self_exec_id, me->self_exec_id +1 );flush_signal_handlers (me,0 ); + retval =set_cred_ucounts (bprm->cred); +if (retval <0 ) + goto out_unlock; +/* * install the new credentials for this executable */
include/linux/cred.h +2 -0
@@ -143,6 +143,7 @@ struct cred {#endif struct user_struct *user;/* real user ID subscription */ struct user_namespace *user_ns;/* user_ns the caps and keyrings are relative to. */ +struct ucounts *ucounts;struct group_info *group_info;/* supplementary groups for euid/fsgid */ /* RCU deletion */ union {
@@ -169,6 +170,7 @@ extern int set_security_override_from_ctx(struct cred *, const char *);extern int set_create_files_as (struct cred *,struct inode *);extern int cred_fscmp (const struct cred *,const struct cred *);extern void __init cred_init (void ); +extern int set_cred_ucounts (struct cred *);/* * check for validity of credentials
include/linux/user_namespace.h +4 -0
@@ -104,11 +104,15 @@ struct ucounts { };extern struct user_namespace init_user_ns; +extern struct ucounts init_ucounts;bool setup_userns_sysctls (struct user_namespace *ns);void retire_userns_sysctls (struct user_namespace *ns);struct ucounts *inc_ucount (struct user_namespace *ns,kuid_t uid,enum ucount_type type);void dec_ucount (struct ucounts *ucounts,enum ucount_type type); +struct ucounts *alloc_ucounts (struct user_namespace *ns,kuid_t uid); +struct ucounts *get_ucounts (struct ucounts *ucounts); +void put_ucounts (struct ucounts *ucounts);#ifdef CONFIG_USER_NS
kernel/cred.c +40 -0
@@ -60,6 +60,7 @@ struct cred init_cred = { .user = INIT_USER, .user_ns = &init_user_ns, .group_info = &init_groups, + .ucounts = &init_ucounts, };static inline void set_cred_subscribers (struct cred *cred,int n)
@@ -119,6 +120,8 @@ static void put_cred_rcu(struct rcu_head *rcu)if (cred->group_info)put_group_info (cred->group_info);free_uid (cred->user); +if (cred->ucounts) +put_ucounts (cred->ucounts);put_user_ns (cred->user_ns);kmem_cache_free (cred_jar, cred); }
@@ -222,6 +225,7 @@ struct cred *cred_alloc_blank(void)#ifdef CONFIG_DEBUG_CREDENTIALS new->magic =CRED_MAGIC ;#endif + new->ucounts =get_ucounts (&init_ucounts);if (security_cred_alloc_blank (new,GFP_KERNEL_ACCOUNT ) <0 ) goto error;
@@ -284,6 +288,11 @@ struct cred *prepare_creds(void)if (security_prepare_creds (new, old,GFP_KERNEL_ACCOUNT ) <0 ) goto error; + + new->ucounts =get_ucounts (new->ucounts); +if (!new->ucounts) + goto error; +validate_creds (new);return new;
@@ -363,6 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags) ret =create_user_ns (new);if (ret <0 ) goto error_put; +if (set_cred_ucounts (new) <0 ) + goto error_put; }#ifdef CONFIG_KEYS
@@ -653,6 +664,31 @@ int cred_fscmp(const struct cred *a, const struct cred *b) }EXPORT_SYMBOL (cred_fscmp); +int set_cred_ucounts (struct cred *new) +{ +struct task_struct *task = current; +const struct cred *old = task->real_cred; +struct ucounts *old_ucounts = new->ucounts; + +if (new->user == old->user && new->user_ns == old->user_ns) +return 0 ; + +/* +* This optimization is needed because alloc_ucounts() uses locks +* for table lookups. +*/ +if (old_ucounts && old_ucounts->ns == new->user_ns &&uid_eq (old_ucounts->uid, new->euid)) +return 0 ; + +if (!(new->ucounts =alloc_ucounts (new->user_ns, new->euid))) +return -EAGAIN ; + +if (old_ucounts) +put_ucounts (old_ucounts); + +return 0 ; +} +/* * initialise the credentials stuff */
@@ -719,6 +755,10 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)if (security_prepare_creds (new, old,GFP_KERNEL_ACCOUNT ) <0 ) goto error; + new->ucounts =get_ucounts (new->ucounts); +if (!new->ucounts) + goto error; +put_cred (old);validate_creds (new);return new;
kernel/fork.c +6 -0
@@ -2997,6 +2997,12 @@ int ksys_unshare(unsigned long unshare_flags)if (err) goto bad_unshare_cleanup_cred; +if (new_cred) { + err =set_cred_ucounts (new_cred); +if (err) + goto bad_unshare_cleanup_cred; + } +if (new_fs || new_fd || do_sysvsem || new_cred || new_nsproxy) {if (do_sysvsem) {/*
kernel/sys.c +12 -0
@@ -558,6 +558,10 @@ long __sys_setreuid(uid_t ruid, uid_t euid)if (retval <0 ) goto error; + retval =set_cred_ucounts (new); +if (retval <0 ) + goto error; +return commit_creds (new); error:
@@ -616,6 +620,10 @@ long __sys_setuid(uid_t uid)if (retval <0 ) goto error; + retval =set_cred_ucounts (new); +if (retval <0 ) + goto error; +return commit_creds (new); error:
@@ -691,6 +699,10 @@ long __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)if (retval <0 ) goto error; + retval =set_cred_ucounts (new); +if (retval <0 ) + goto error; +return commit_creds (new); error:
kernel/ucount.c +37 -3
@@ -8,6 +8,12 @@#include <linux/kmemleak.h> #include <linux/user_namespace.h> +struct ucounts init_ucounts = { + .ns = &init_user_ns, + .uid =GLOBAL_ROOT_UID , + .count =1 , +}; +#define UCOUNTS_HASHTABLE_BITS 10static struct hlist_head ucounts_hashtable[(1 <<UCOUNTS_HASHTABLE_BITS )];static DEFINE_SPINLOCK (ucounts_lock);
@@ -129,7 +135,15 @@ static struct ucounts *find_ucounts(struct user_namespace *ns, kuid_t uid, strucreturn NULL ; } -static struct ucounts *get_ucounts (struct user_namespace *ns,kuid_t uid) +static void hlist_add_ucounts (struct ucounts *ucounts) +{ +struct hlist_head *hashent =ucounts_hashentry (ucounts->ns, ucounts->uid); +spin_lock_irq (&ucounts_lock); +hlist_add_head (&ucounts->node, hashent); +spin_unlock_irq (&ucounts_lock); +} + +struct ucounts *alloc_ucounts (struct user_namespace *ns,kuid_t uid) {struct hlist_head *hashent =ucounts_hashentry (ns, uid);struct ucounts *ucounts, *new;
@@ -164,7 +178,26 @@ static struct ucounts *get_ucounts(struct user_namespace *ns, kuid_t uid)return ucounts; } -static void put_ucounts (struct ucounts *ucounts) +struct ucounts *get_ucounts (struct ucounts *ucounts) +{ +unsigned long flags; + +if (!ucounts) +return NULL ; + +spin_lock_irqsave (&ucounts_lock, flags); +if (ucounts->count ==INT_MAX ) { +WARN_ONCE (1 ,"ucounts: counter has reached its maximum value" ); + ucounts =NULL ; + }else { + ucounts->count +=1 ; + } +spin_unlock_irqrestore (&ucounts_lock, flags); + +return ucounts; +} + +void put_ucounts (struct ucounts *ucounts) {unsigned long flags;
@@ -198,7 +231,7 @@ struct ucounts *inc_ucount(struct user_namespace *ns, kuid_t uid, {struct ucounts *ucounts, *iter, *bad;struct user_namespace *tns; - ucounts =get_ucounts (ns, uid); + ucounts =alloc_ucounts (ns, uid);for (iter = ucounts; iter; iter = tns->ucounts) {int max; tns = iter->ns;
@@ -241,6 +274,7 @@ static __init int user_namespace_sysctl_init(void)BUG_ON (!user_header);BUG_ON (!setup_userns_sysctls (&init_user_ns));#endif +hlist_add_ucounts (&init_ucounts);return 0 ; }subsys_initcall (user_namespace_sysctl_init);
kernel/user_namespace.c +3 -0
@@ -1340,6 +1340,9 @@ static int userns_install(struct nsset *nsset, struct ns_common *ns)put_user_ns (cred->user_ns);set_cred_user_ns (cred,get_user_ns (user_ns)); +if (set_cred_ucounts (cred) <0 ) +return -EINVAL ; +return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 129/800 staging: media: rkvdec: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit e90812c47b958407b54d05780dc483fdc1b57a93 ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
--- drivers/staging/media/rkvdec/rkvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/rkvdec/rkvdec.c +1 -1
@@ -658,7 +658,7 @@ static void rkvdec_device_run(void *priv)if (WARN_ON (!desc))return ; - ret =pm_runtime_get_sync (rkvdec->dev); + ret =pm_runtime_resume_and_get (rkvdec->dev);if (ret <0 ) {rkvdec_job_finish_no_pm (ctx,VB2_BUF_STATE_ERROR );return ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 130/800 media: i2c: imx334: fix the pm runtime get logic
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 62c90446868b439929cb04395f04a709a64ae04b ]
The PM runtime get logic is currently broken, as it checks if ret is zero instead of checking if it is an error code, as reported by Dan Carpenter.
While here, use the pm_runtime_resume_and_get() as added by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") added pm_runtime_resume_and_get() in order to automatically handle dev->power.usage_count decrement on errors. As a bonus, such function
always return zero on success.
It should also be noticed that a fail of pm_runtime_get_sync() would potentially result in a spurious runtime_suspend(), instead of using pm_runtime_put_noidle().
--- drivers/media/i2c/imx334.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/i2c/imx334.c +4 -3
@@ -717,9 +717,9 @@ static int imx334_set_stream(struct v4l2_subdev *sd, int enable) }if (enable) { - ret =pm_runtime_get_sync (imx334->dev); -if (ret) - goto error_power_off; + ret =pm_runtime_resume_and_get (imx334->dev); +if (ret <0 ) + goto error_unlock; ret =imx334_start_streaming (imx334);if (ret)
@@ -737,6 +737,7 @@ static int imx334_set_stream(struct v4l2_subdev *sd, int enable) error_power_off:pm_runtime_put (imx334->dev); +error_unlock:mutex_unlock (&imx334->mutex);return ret;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 131/800 media: marvel-ccic: fix some issues when getting pm_runtime
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit e7c617cab7a522fba5b20f9033ee98565b6f3546 ]
Calling pm_runtime_get_sync() is bad, since even when it returns an error, pm_runtime_put*() should be called. So, use instead pm_runtime_resume_and_get().
While here, ensure that the error condition will be checked during clock enable an media open() calls.
--- drivers/media/platform/marvell-ccic/mcam-core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/platform/marvell-ccic/mcam-core.c +7 -2
@@ -918,6 +918,7 @@ static int mclk_enable(struct clk_hw *hw) struct mcam_camera *cam = container_of(hw, struct mcam_camera, mclk_hw);int mclk_src;int mclk_div; +int ret;/* * Clock the sensor appropriately. Controller clock should
@@ -931,7 +932,9 @@ static int mclk_enable(struct clk_hw *hw) mclk_div =2 ; } -pm_runtime_get_sync (cam->dev); + ret =pm_runtime_resume_and_get (cam->dev); +if (ret <0 ) +return ret;clk_enable (cam->clk[0 ]);mcam_reg_write (cam,REG_CLKCTRL , (mclk_src <<29 ) | mclk_div);mcam_ctlr_power_up (cam);
@@ -1611,7 +1614,9 @@ static int mcam_v4l_open(struct file *filp) ret =sensor_call (cam, core, s_power,1 );if (ret) goto out; -pm_runtime_get_sync (cam->dev); + ret =pm_runtime_resume_and_get (cam->dev); +if (ret <0 ) + goto out;__mcam_cam_reset (cam);mcam_set_config_needed (cam,1 ); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 132/800 media: mdk-mdp: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit d07bb9702cf5f5ccf3fb661e6cab54bbc33cd23f ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
While here, fix the return contition of mtk_mdp_m2m_start_streaming(), as it doesn't make any sense to return 0 if the PM runtime failed to resume.
--- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +3 -3
@@ -391,12 +391,12 @@ static int mtk_mdp_m2m_start_streaming(struct vb2_queue *q, unsigned int count)struct mtk_mdp_ctx *ctx = q->drv_priv;int ret; - ret =pm_runtime_get_sync (&ctx->mdp_dev->pdev->dev); + ret =pm_runtime_resume_and_get (&ctx->mdp_dev->pdev->dev);if (ret <0 ) -mtk_mdp_dbg (1 ,"[%d] pm_runtime_get_sync failed:%d" , +mtk_mdp_dbg (1 ,"[%d] pm_runtime_resume_and_get failed:%d" , ctx->id, ret); -return 0 ; +return ret; } static void *mtk_mdp_m2m_buf_remove(struct mtk_mdp_ctx *ctx,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 133/800 media: s5p: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit fdc34e82c0f968ac4c157bd3d8c299ebc24c9c63 ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
While here, check if the PM runtime error was caught at s5p_cec_adap_enable().
--- drivers/media/cec/platform/s5p/s5p_cec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/cec/platform/s5p/s5p_cec.c +4 -1
@@ -35,10 +35,13 @@ MODULE_PARM_DESC(debug, "debug level (0-2)");static int s5p_cec_adap_enable (struct cec_adapter *adap,bool enable) { +int ret;struct s5p_cec_dev *cec =cec_get_drvdata (adap);if (enable) { -pm_runtime_get_sync (cec->dev); + ret =pm_runtime_resume_and_get (cec->dev); +if (ret <0 ) +return ret;s5p_cec_reset (cec);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 134/800 media: am437x: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit c41e02493334985cca1a22efd5ca962ce3abb061 ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
While here, ensure that the driver will check if PM runtime resumed at vpfe_initialize_device().
--- drivers/media/platform/am437x/am437x-vpfe.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/media/platform/am437x/am437x-vpfe.c +13 -2
@@ -1021,7 +1021,9 @@ static int vpfe_initialize_device(struct vpfe_device *vpfe)if (ret)return ret; -pm_runtime_get_sync (vpfe->pdev); + ret =pm_runtime_resume_and_get (vpfe->pdev); +if (ret <0 ) +return ret;vpfe_config_enable (&vpfe->ccdc,1 );
@@ -2443,7 +2445,11 @@ static int vpfe_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev);/* for now just enable it here instead of waiting for the open */ -pm_runtime_get_sync (&pdev->dev); + ret =pm_runtime_resume_and_get (&pdev->dev); +if (ret <0 ) { +vpfe_err (vpfe,"Unable to resume device.\n" ); + goto probe_out_v4l2_unregister; + }vpfe_ccdc_config_defaults (ccdc);
@@ -2530,6 +2536,11 @@ static int vpfe_suspend(struct device *dev)/* only do full suspend if streaming has started */ if (vb2_start_streaming_called (&vpfe->buffer_queue)) { +/* +* ignore RPM resume errors here, as it is already too late. +* A check like that should happen earlier, either at +* open() or just before start streaming. +*/ pm_runtime_get_sync (dev);vpfe_config_enable (ccdc,1 );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 135/800 media: sh_vou: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 6e8b1526db164c9d4b9dacfb9bc48e365d7c4860 ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
While here, check if the PM runtime error was caught at open time.
--- drivers/media/platform/sh_vou.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/sh_vou.c +5 -1
@@ -1133,7 +1133,11 @@ static int sh_vou_open(struct file *file)if (v4l2_fh_is_singular_file (file) && vou_dev->status ==SH_VOU_INITIALISING ) {/* First open */ -pm_runtime_get_sync (vou_dev->v4l2_dev.dev); + err =pm_runtime_resume_and_get (vou_dev->v4l2_dev.dev); +if (err <0 ) { +v4l2_fh_release (file); + goto done_open; + } err =sh_vou_hw_init (vou_dev);if (err <0 ) {pm_runtime_put (vou_dev->v4l2_dev.dev);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 136/800 media: mtk-vcodec: fix PM runtime get logic
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 908711f542c17fe61e5d653da1beb8e5ab5c7b50 ]
Currently, the driver just assumes that PM runtime logic succeded resuming the device.
That may not be the case, as pm_runtime_get_sync() can fail (but keeping the usage count incremented).
Replace the code to use pm_runtime_resume_and_get(), and letting it return the error code.
This way, if mtk_vcodec_dec_pw_on() fails, the logic under fops_vcodec_open() will do the right thing and return an error, instead of just assuming that the device is ready to be used.
--- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 +++- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 8 +++++--- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +3 -1
@@ -126,7 +126,9 @@ static int fops_vcodec_open(struct file *file)mtk_vcodec_dec_set_default_params (ctx);if (v4l2_fh_is_singular (&ctx->fh)) { -mtk_vcodec_dec_pw_on (&dev->pm); + ret =mtk_vcodec_dec_pw_on (&dev->pm); +if (ret <0 ) + goto err_load_fw;/* * Does nothing if firmware was already loaded. */
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c +5 -3
@@ -88,13 +88,15 @@ void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev)put_device (dev->pm.larbvdec); } -void mtk_vcodec_dec_pw_on (struct mtk_vcodec_pm *pm) +int mtk_vcodec_dec_pw_on (struct mtk_vcodec_pm *pm) {int ret; - ret =pm_runtime_get_sync (pm->dev); + ret =pm_runtime_resume_and_get (pm->dev);if (ret) -mtk_v4l2_err ("pm_runtime_get_sync fail %d" , ret); +mtk_v4l2_err ("pm_runtime_resume_and_get fail %d" , ret); + +return ret; }void mtk_vcodec_dec_pw_off (struct mtk_vcodec_pm *pm)
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h +1 -1
@@ -12,7 +12,7 @@int mtk_vcodec_init_dec_pm (struct mtk_vcodec_dev *dev);void mtk_vcodec_release_dec_pm (struct mtk_vcodec_dev *dev); -void mtk_vcodec_dec_pw_on (struct mtk_vcodec_pm *pm); +int mtk_vcodec_dec_pw_on (struct mtk_vcodec_pm *pm);void mtk_vcodec_dec_pw_off (struct mtk_vcodec_pm *pm);void mtk_vcodec_dec_clock_on (struct mtk_vcodec_pm *pm);void mtk_vcodec_dec_clock_off (struct mtk_vcodec_pm *pm);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 137/800 media: s5p-jpeg: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 10343de268d10cf07b092b8b525e12ad558ead77 ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
As a plus, pm_runtime_resume_and_get() doesn't return positive numbers, so the return code validation can be removed.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -4
@@ -2566,11 +2566,8 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)static int s5p_jpeg_start_streaming (struct vb2_queue *q,unsigned int count) {struct s5p_jpeg_ctx *ctx =vb2_get_drv_priv (q); -int ret; - - ret =pm_runtime_get_sync (ctx->jpeg->dev); -return ret >0 ?0 : ret; +return pm_runtime_resume_and_get (ctx->jpeg->dev); }static void s5p_jpeg_stop_streaming (struct vb2_queue *q)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 138/800 media: sunxi: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 9c298f82d8392f799a0595f50076afa1d91e9092 ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
--- drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c +1 -1
@@ -494,7 +494,7 @@ static int rotate_start_streaming(struct vb2_queue *vq, unsigned int count)struct device *dev = ctx->dev->dev;int ret; - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret <0 ) {dev_err (dev,"Failed to enable module\n" );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 139/800 media: sti/bdisp: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit c44eac5b72e23c31eefc0e10a71d9650036b8341 ]
The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors.
The bdisp_start_streaming() doesn't take it into account, which would unbalance PM usage counter at bdisp_stop_streaming().
The logic at bdisp_probe() is correct, but the best is to use the same call along the driver.
So, replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
--- drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/sti/bdisp/bdisp-v4l2.c +4 -3
@@ -499,7 +499,7 @@ static int bdisp_start_streaming(struct vb2_queue *q, unsigned int count) {struct bdisp_ctx *ctx = q->drv_priv;struct vb2_v4l2_buffer *buf; -int ret =pm_runtime_get_sync (ctx->bdisp_dev->dev); +int ret =pm_runtime_resume_and_get (ctx->bdisp_dev->dev);if (ret <0 ) {dev_err (ctx->bdisp_dev->dev,"failed to set runtime PM\n" );
@@ -1364,10 +1364,10 @@ static int bdisp_probe(struct platform_device *pdev)/* Power management */ pm_runtime_enable (dev); - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret <0 ) {dev_err (dev,"failed to set PM\n" ); - goto err_pm; + goto err_remove; }/* Filters */
@@ -1395,6 +1395,7 @@ err_filter:bdisp_hw_free_filters (bdisp->dev); err_pm:pm_runtime_put (dev); +err_remove:bdisp_debugfs_remove (bdisp);v4l2_device_unregister (&bdisp->v4l2_dev); err_clk:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 140/800 media: exynos4-is: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 59f96244af9403ddf4810ec5c0fbe8920857634e ]
The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors.
On some places, this is ok, but on others the usage count ended being unbalanced on failures.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
As a bonus, such function always return zero on success. So, some code can be simplified.
--- drivers/media/platform/exynos4-is/fimc-capture.c | 6 ++---- drivers/media/platform/exynos4-is/fimc-is.c | 4 ++-- drivers/media/platform/exynos4-is/fimc-isp-video.c | 3 +-- drivers/media/platform/exynos4-is/fimc-isp.c | 7 +++---- drivers/media/platform/exynos4-is/fimc-lite.c | 5 +++-- drivers/media/platform/exynos4-is/fimc-m2m.c | 5 +---- drivers/media/platform/exynos4-is/media-dev.c | 9 +++------ drivers/media/platform/exynos4-is/mipi-csis.c | 10 ++++------ 8 files changed, 19 insertions(+), 30 deletions(-)
drivers/media/platform/exynos4-is/fimc-capture.c +2 -4
@@ -478,11 +478,9 @@ static int fimc_capture_open(struct file *file) goto unlock;set_bit (ST_CAPT_BUSY , &fimc->state); - ret =pm_runtime_get_sync (&fimc->pdev->dev); -if (ret <0 ) { -pm_runtime_put_sync (&fimc->pdev->dev); + ret =pm_runtime_resume_and_get (&fimc->pdev->dev); +if (ret <0 ) goto unlock; - } ret =v4l2_fh_open (file);if (ret) {
drivers/media/platform/exynos4-is/fimc-is.c +2 -2
@@ -828,9 +828,9 @@ static int fimc_is_probe(struct platform_device *pdev) goto err_irq; } - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret <0 ) - goto err_pm; + goto err_irq;vb2_dma_contig_set_max_seg_size (dev,DMA_BIT_MASK (32 ));
drivers/media/platform/exynos4-is/fimc-isp-video.c +1 -2
@@ -275,7 +275,7 @@ static int isp_video_open(struct file *file)if (ret <0 ) goto unlock; - ret =pm_runtime_get_sync (&isp->pdev->dev); + ret =pm_runtime_resume_and_get (&isp->pdev->dev);if (ret <0 ) goto rel_fh;
@@ -293,7 +293,6 @@ static int isp_video_open(struct file *file)if (!ret) goto unlock; rel_fh: -pm_runtime_put_noidle (&isp->pdev->dev);v4l2_fh_release (file); unlock:mutex_unlock (&isp->video_lock);
drivers/media/platform/exynos4-is/fimc-isp.c +3 -4
@@ -304,11 +304,10 @@ static int fimc_isp_subdev_s_power(struct v4l2_subdev *sd, int on)pr_debug ("on: %d\n" , on);if (on) { - ret =pm_runtime_get_sync (&is->pdev->dev); -if (ret <0 ) { -pm_runtime_put (&is->pdev->dev); + ret =pm_runtime_resume_and_get (&is->pdev->dev); +if (ret <0 )return ret; - } +set_bit (IS_ST_PWR_ON , &is->state); ret =fimc_is_start_firmware (is);
drivers/media/platform/exynos4-is/fimc-lite.c +3 -2
@@ -469,9 +469,9 @@ static int fimc_lite_open(struct file *file) }set_bit (ST_FLITE_IN_USE , &fimc->state); - ret =pm_runtime_get_sync (&fimc->pdev->dev); + ret =pm_runtime_resume_and_get (&fimc->pdev->dev);if (ret <0 ) - goto err_pm; + goto err_in_use; ret =v4l2_fh_open (file);if (ret <0 )
@@ -499,6 +499,7 @@ static int fimc_lite_open(struct file *file)v4l2_fh_release (file); err_pm:pm_runtime_put_sync (&fimc->pdev->dev); +err_in_use:clear_bit (ST_FLITE_IN_USE , &fimc->state); unlock:mutex_unlock (&fimc->lock);
drivers/media/platform/exynos4-is/fimc-m2m.c +1 -4
@@ -73,17 +73,14 @@ static void fimc_m2m_shutdown(struct fimc_ctx *ctx)static int start_streaming (struct vb2_queue *q,unsigned int count) {struct fimc_ctx *ctx = q->drv_priv; -int ret; - ret =pm_runtime_get_sync (&ctx->fimc_dev->pdev->dev); -return ret >0 ?0 : ret; +return pm_runtime_resume_and_get (&ctx->fimc_dev->pdev->dev); }static void stop_streaming (struct vb2_queue *q) {struct fimc_ctx *ctx = q->drv_priv; -fimc_m2m_shutdown (ctx);fimc_m2m_job_finish (ctx,VB2_BUF_STATE_ERROR );pm_runtime_put (&ctx->fimc_dev->pdev->dev);
drivers/media/platform/exynos4-is/media-dev.c +3 -6
@@ -512,11 +512,9 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)if (!fmd->pmf)return -ENXIO ; - ret =pm_runtime_get_sync (fmd->pmf); -if (ret <0 ) { -pm_runtime_put (fmd->pmf); + ret =pm_runtime_resume_and_get (fmd->pmf); +if (ret <0 )return ret; - } fmd->num_sensors =0 ;
@@ -1291,8 +1289,7 @@ static int cam_clk_prepare(struct clk_hw *hw)if (camclk->fmd->pmf ==NULL )return -ENODEV ; - ret =pm_runtime_get_sync (camclk->fmd->pmf); -return ret <0 ? ret :0 ; +return pm_runtime_resume_and_get (camclk->fmd->pmf); }static void cam_clk_unprepare (struct clk_hw *hw)
drivers/media/platform/exynos4-is/mipi-csis.c +4 -6
@@ -494,7 +494,7 @@ static int s5pcsis_s_power(struct v4l2_subdev *sd, int on)struct device *dev = &state->pdev->dev;if (on) -return pm_runtime_get_sync (dev); +return pm_runtime_resume_and_get (dev);return pm_runtime_put_sync (dev); }
@@ -509,11 +509,9 @@ static int s5pcsis_s_stream(struct v4l2_subdev *sd, int enable)if (enable) {s5pcsis_clear_counters (state); - ret =pm_runtime_get_sync (&state->pdev->dev); -if (ret && ret !=1 ) { -pm_runtime_put_noidle (&state->pdev->dev); + ret =pm_runtime_resume_and_get (&state->pdev->dev); +if (ret <0 )return ret; - } }mutex_lock (&state->lock);
@@ -535,7 +533,7 @@ unlock:if (!enable)pm_runtime_put (&state->pdev->dev); -return ret ==1 ?0 : ret; +return ret; } static int s5pcsis_enum_mbus_code(struct v4l2_subdev *sd,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 141/800 media: exynos-gsc: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 59087b66ea6730c130c57d23bd9fd139b78c1ba5 ]
The pm_runtime_get_sync() internally increments thedev->power.usage_count without decrementing it, even on errors.
Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.
As a bonus, as pm_runtime_get_sync() always return 0 on success, the logic can be simplified.
--- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/exynos-gsc/gsc-m2m.c +1 -3
@@ -56,10 +56,8 @@ static void __gsc_m2m_job_abort(struct gsc_ctx *ctx)static int gsc_m2m_start_streaming (struct vb2_queue *q,unsigned int count) {struct gsc_ctx *ctx = q->drv_priv; -int ret; - ret =pm_runtime_get_sync (&ctx->gsc_dev->pdev->dev); -return ret >0 ?0 : ret; +return pm_runtime_resume_and_get (&ctx->gsc_dev->pdev->dev); }static void __gsc_m2m_cleanup_queue (struct gsc_ctx *ctx)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 142/800 spi: spi-loopback-test: Fix tx_buf might be rx_buf
In reply to Greg Kroah-HartmanFrom: Jay Fang <[email protected]>
[ Upstream commit 9e37a3ab0627011fb63875e9a93094b6fc8ddf48 ]
In function 'spi_test_run_iter': Value 'tx_buf' might be 'rx_buf'.
--- drivers/spi/spi-loopback-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-loopback-test.c +1 -1
@@ -875,7 +875,7 @@ static int spi_test_run_iter(struct spi_device *spi, test.transfers[i].len = len;if (test.transfers[i].tx_buf) test.transfers[i].tx_buf += tx_off; -if (test.transfers[i].tx_buf) +if (test.transfers[i].rx_buf) test.transfers[i].rx_buf += rx_off; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 143/800 spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages()
In reply to Greg Kroah-HartmanFrom: Jay Fang <[email protected]>
[ Upstream commit 026a1dc1af52742c5897e64a3431445371a71871 ]
pch_spi_set_tx() frees data->pkt_tx_buff on failure of kzalloc() for data->pkt_rx_buff, but its caller, pch_spi_process_messages(), will free data->pkt_tx_buff again. Set data->pkt_tx_buff to NULL after kfree() to avoid double free.
--- drivers/spi/spi-topcliff-pch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-topcliff-pch.c +3 -1
@@ -580,8 +580,10 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw) data->pkt_tx_buff =kzalloc (size,GFP_KERNEL );if (data->pkt_tx_buff !=NULL ) { data->pkt_rx_buff =kzalloc (size,GFP_KERNEL ); -if (!data->pkt_rx_buff) +if (!data->pkt_rx_buff) {kfree (data->pkt_tx_buff); + data->pkt_tx_buff =NULL ; + } }if (!data->pkt_rx_buff) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 144/800 spi: omap-100k: Fix the length judgment problem
In reply to Greg Kroah-HartmanFrom: Tian Tao <[email protected]>
[ Upstream commit e7a1a3abea373e41ba7dfe0fbc93cb79b6a3a529 ]
word_len should be checked in the omap1_spi100k_setup_transfer function to see if it exceeds 32.
--- drivers/spi/spi-omap-100k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-omap-100k.c +1 -1
@@ -241,7 +241,7 @@ static int omap1_spi100k_setup_transfer(struct spi_device *spi,else word_len = spi->bits_per_word; -if (spi->bits_per_word >32 ) +if (word_len >32 )return -EINVAL ; cs->word_len = word_len;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 145/800 regulator: uniphier: Add missing MODULE_DEVICE_TABLE
In reply to Greg Kroah-HartmanFrom: Zou Wei <[email protected]>
[ Upstream commit d019f38a1af3c6015cde6a47951a3ec43beeed80 ]
This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module.
--- drivers/regulator/uniphier-regulator.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/uniphier-regulator.c +1 -0
@@ -201,6 +201,7 @@ static const struct of_device_id uniphier_regulator_match[] = { }, { /* Sentinel */ }, }; +MODULE_DEVICE_TABLE (of, uniphier_regulator_match);static struct platform_driver uniphier_regulator_driver = { .probe = uniphier_regulator_probe,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 146/800 sched/core: Initialize the idle task with preemption disabled
In reply to Greg Kroah-HartmanFrom: Valentin Schneider <[email protected]>
[ Upstream commit f1a0a376ca0c4ef1fc3d24e3e502acbb5b795674 ]
As pointed out by commit
de9b8f5dcbd9 ("sched: Fix crash trying to dequeue/enqueue the idle thread")
init_idle() can and will be invoked more than once on the same idle task. At boot time, it is invoked for the boot CPU thread by sched_init(). Then smp_init() creates the threads for all the secondary CPUs and invokes init_idle() on them.
As the hotplug machinery brings the secondaries to life, it will issue calls to idle_thread_get(), which itself invokes init_idle() yet again. In this case it's invoked twice more per secondary: at _cpu_up(), and at bringup_cpu().
Given smp_init() already initializes the idle tasks for all *possible* CPUs, no further initialization should be required. Now, removing init_idle() from idle_thread_get() exposes some interesting expectations with regards to the idle task's preempt_count: the secondary startup always issues a preempt_disable(), requiring some reset of the preempt count to 0 between hot-unplug and hotplug, which is currently served by idle_thread_get() -> idle_init().
Given the idle task is supposed to have preemption disabled once and never see it re-enabled, it seems that what we actually want is to initialize its preempt_count to PREEMPT_DISABLED and leave it there. Do that, and remove init_idle() from idle_thread_get().
Secondary startups were patched via coccinelle:
@begone@
@@
-preempt_disable(); ... cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
--- arch/alpha/kernel/smp.c | 1 - arch/arc/kernel/smp.c | 1 - arch/arm/kernel/smp.c | 1 - arch/arm64/include/asm/preempt.h | 2 +- arch/arm64/kernel/smp.c | 1 - arch/csky/kernel/smp.c | 1 - arch/ia64/kernel/smpboot.c | 1 - arch/mips/kernel/smp.c | 1 - arch/openrisc/kernel/smp.c | 2 -- arch/parisc/kernel/smp.c | 1 - arch/powerpc/kernel/smp.c | 1 - arch/riscv/kernel/smpboot.c | 1 - arch/s390/include/asm/preempt.h | 4 ++-- arch/s390/kernel/smp.c | 1 - arch/sh/kernel/smp.c | 2 -- arch/sparc/kernel/smp_32.c | 1 - arch/sparc/kernel/smp_64.c | 3 --- arch/x86/include/asm/preempt.h | 2 +- arch/x86/kernel/smpboot.c | 1 - arch/xtensa/kernel/smp.c | 1 - include/asm-generic/preempt.h | 2 +- init/main.c | 6 +----- kernel/fork.c | 2 +- kernel/sched/core.c | 2 +- kernel/smpboot.c | 1 - 25 files changed, 8 insertions(+), 34 deletions(-)
arch/alpha/kernel/smp.c +0 -1
@@ -166,7 +166,6 @@ smp_callin(void)DBGS (("smp_callin: commencing CPU %d current %p active_mm %p\n" , cpuid, current, current->active_mm)); -preempt_disable ();cpu_startup_entry (CPUHP_AP_ONLINE_IDLE ); }
arch/arc/kernel/smp.c +0 -1
@@ -189,7 +189,6 @@ void start_kernel_secondary(void)pr_info ("## CPU%u LIVE ##: Executing Code...\n" , cpu);local_irq_enable (); -preempt_disable ();cpu_startup_entry (CPUHP_AP_ONLINE_IDLE ); }
arch/arm/kernel/smp.c +0 -1
@@ -432,7 +432,6 @@ asmlinkage void secondary_start_kernel(void)#endif pr_debug ("CPU%u: Booted secondary processor\n" , cpu); -preempt_disable ();trace_hardirqs_off ();/*
arch/arm64/include/asm/preempt.h +1 -1
@@ -23,7 +23,7 @@ static inline void preempt_count_set(u64 pc) } while (0)#define init_idle_preempt_count (p, cpu) do { \ - task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \ + task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \ } while (0)static inline void set_preempt_need_resched (void )
arch/arm64/kernel/smp.c +0 -1
@@ -224,7 +224,6 @@ asmlinkage notrace void secondary_start_kernel(void)init_gic_priority_masking ();rcu_cpu_starting (cpu); -preempt_disable ();trace_hardirqs_off ();/*
arch/csky/kernel/smp.c +0 -1
@@ -281,7 +281,6 @@ void csky_start_secondary(void)pr_info ("CPU%u Online: %s...\n" , cpu, __func__);local_irq_enable (); -preempt_disable ();cpu_startup_entry (CPUHP_AP_ONLINE_IDLE ); }
arch/ia64/kernel/smpboot.c +0 -1
@@ -441,7 +441,6 @@ start_secondary (void *unused)#endif efi_map_pal_code ();cpu_init (); -preempt_disable ();smp_callin ();cpu_startup_entry (CPUHP_AP_ONLINE_IDLE );
arch/mips/kernel/smp.c +0 -1
@@ -348,7 +348,6 @@ asmlinkage void start_secondary(void)*/ calibrate_delay (); -preempt_disable (); cpu =smp_processor_id (); cpu_data[cpu].udelay_val = loops_per_jiffy;
arch/openrisc/kernel/smp.c +0 -2
@@ -145,8 +145,6 @@ asmlinkage __init void secondary_start_kernel(void)set_cpu_online (cpu, true);local_irq_enable (); - -preempt_disable ();/* * OK, it's off to the idle thread for us */
arch/parisc/kernel/smp.c +0 -1
@@ -302,7 +302,6 @@ void __init smp_callin(unsigned long pdce_proc)#endif smp_cpu_init (slave_id); -preempt_disable ();flush_cache_all_local ();/* start with known state */ flush_tlb_all_local (NULL );
arch/powerpc/kernel/smp.c +0 -1
@@ -1547,7 +1547,6 @@ void start_secondary(void *unused)smp_store_cpu_info (cpu);set_dec (tb_ticks_per_jiffy);rcu_cpu_starting (cpu); -preempt_disable (); cpu_callin_map[cpu] =1 ;if (smp_ops->setup_cpu)
arch/riscv/kernel/smpboot.c +0 -1
@@ -180,7 +180,6 @@ asmlinkage __visible void smp_callin(void)* Disable preemption before enabling interrupts, so we don't try to * schedule a CPU that hasn't actually started yet. */ -preempt_disable ();local_irq_enable ();cpu_startup_entry (CPUHP_AP_ONLINE_IDLE ); }
arch/s390/include/asm/preempt.h +2 -2
@@ -32,7 +32,7 @@ static inline void preempt_count_set(int pc)#define init_task_preempt_count (p) do { } while (0)#define init_idle_preempt_count (p, cpu) do { \ - S390_lowcore.preempt_count = PREEMPT_ENABLED; \ + S390_lowcore.preempt_count = PREEMPT_DISABLED; \ } while (0)static inline void set_preempt_need_resched (void )
@@ -91,7 +91,7 @@ static inline void preempt_count_set(int pc)#define init_task_preempt_count (p) do { } while (0)#define init_idle_preempt_count (p, cpu) do { \ - S390_lowcore.preempt_count = PREEMPT_ENABLED; \ + S390_lowcore.preempt_count = PREEMPT_DISABLED; \ } while (0)static inline void set_preempt_need_resched (void )
arch/s390/kernel/smp.c +0 -1
@@ -878,7 +878,6 @@ static void smp_init_secondary(void)restore_access_regs (S390_lowcore.access_regs_save_area);cpu_init ();rcu_cpu_starting (cpu); -preempt_disable ();init_cpu_timer ();vtime_init ();vdso_getcpu_init ();
arch/sh/kernel/smp.c +0 -2
@@ -186,8 +186,6 @@ asmlinkage void start_secondary(void)per_cpu_trap_init (); -preempt_disable (); -notify_cpu_starting (cpu);local_irq_enable ();
arch/sparc/kernel/smp_32.c +0 -1
@@ -348,7 +348,6 @@ static void sparc_start_secondary(void *arg)*/ arch_cpu_pre_starting (arg); -preempt_disable (); cpu =smp_processor_id ();notify_cpu_starting (cpu);
arch/sparc/kernel/smp_64.c +0 -3
@@ -138,9 +138,6 @@ void smp_callin(void)set_cpu_online (cpuid, true); -/* idle thread is expected to have preempt disabled */ -preempt_disable (); -local_irq_enable ();cpu_startup_entry (CPUHP_AP_ONLINE_IDLE );
arch/x86/include/asm/preempt.h +1 -1
@@ -44,7 +44,7 @@ static __always_inline void preempt_count_set(int pc)#define init_task_preempt_count (p) do { } while (0)#define init_idle_preempt_count (p, cpu) do { \ - per_cpu(__preempt_count, (cpu)) = PREEMPT_ENABLED; \ + per_cpu(__preempt_count, (cpu)) = PREEMPT_DISABLED; \ } while (0)/*
arch/x86/kernel/smpboot.c +0 -1
@@ -236,7 +236,6 @@ static void notrace start_secondary(void *unused)cpu_init ();rcu_cpu_starting (raw_smp_processor_id ()); x86_cpuinit.early_percpu_clock_init (); -preempt_disable ();smp_callin (); enable_start_cpu0 =0 ;
arch/xtensa/kernel/smp.c +0 -1
@@ -145,7 +145,6 @@ void secondary_start_kernel(void)cpumask_set_cpu (cpu,mm_cpumask (mm));enter_lazy_tlb (mm, current); -preempt_disable ();trace_hardirqs_off ();calibrate_delay ();
include/asm-generic/preempt.h +1 -1
@@ -29,7 +29,7 @@ static __always_inline void preempt_count_set(int pc) } while (0)#define init_idle_preempt_count (p, cpu) do { \ - task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \ + task_thread_info(p)->preempt_count = PREEMPT_DISABLED; \ } while (0) static __always_inline void set_preempt_need_resched(void)
init/main.c +1 -5
@@ -941,11 +941,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)* time - but meanwhile we still have a functioning scheduler. */ sched_init (); -/* -* Disable preemption - early bootup scheduling is extremely -* fragile until we cpu_idle() for the first time. -*/ -preempt_disable (); +if (WARN (!irqs_disabled (),"Interrupts were enabled *very* early, fixing it\n" ))local_irq_disable ();
kernel/fork.c +1 -1
@@ -2407,7 +2407,7 @@ static inline void init_idle_pids(struct task_struct *idle) } } -struct task_struct *fork_idle (int cpu) +struct task_struct *__init fork_idle (int cpu) {struct task_struct *task;struct kernel_clone_args args = {
kernel/sched/core.c +1 -1
@@ -7433,7 +7433,7 @@ void show_state_filter(unsigned long state_filter)* NOTE: this function does not set the idle thread's NEED_RESCHED * flag, to make booting more robust. */ -void init_idle (struct task_struct *idle,int cpu) +void __init init_idle (struct task_struct *idle,int cpu) {struct rq *rq =cpu_rq (cpu);unsigned long flags;
kernel/smpboot.c +0 -1
@@ -33,7 +33,6 @@ struct task_struct *idle_thread_get(unsigned int cpu)if (!tsk)return ERR_PTR (-ENOMEM ); -init_idle (tsk, cpu);return tsk; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 147/800 hwrng: exynos - Fix runtime PM imbalance on error
In reply to Greg Kroah-HartmanFrom: Łukasz Stelmach <[email protected]>
[ Upstream commit 0cdbabf8bb7a6147f5adf37dbc251e92a1bbc2c7 ]
pm_runtime_resume_and_get() wraps around pm_runtime_get_sync() and decrements the runtime PM usage counter in case the latter function fails and keeps the counter balanced.
--- drivers/char/hw_random/exynos-trng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/exynos-trng.c +2 -2
@@ -132,7 +132,7 @@ static int exynos_trng_probe(struct platform_device *pdev)return PTR_ERR (trng->mem);pm_runtime_enable (&pdev->dev); - ret =pm_runtime_get_sync (&pdev->dev); + ret =pm_runtime_resume_and_get (&pdev->dev);if (ret <0 ) {dev_err (&pdev->dev,"Could not get runtime PM.\n" ); goto err_pm_get;
@@ -165,7 +165,7 @@ err_register:clk_disable_unprepare (trng->clk); err_clock: -pm_runtime_put_sync (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); err_pm_get:pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 148/800 crypto: nx - add missing MODULE_DEVICE_TABLE
In reply to Greg Kroah-HartmanFrom: Bixuan Cui <[email protected]>
[ Upstream commit 06676aa1f455c74e3ad1624cea3acb9ed2ef71ae ]
This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module.
--- drivers/crypto/nx/nx-842-pseries.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/nx/nx-842-pseries.c +1 -0
@@ -1069,6 +1069,7 @@ static const struct vio_device_id nx842_vio_driver_ids[] = { {"ibm,compression-v1", "ibm,compression"}, {"", ""}, }; +MODULE_DEVICE_TABLE (vio, nx842_vio_driver_ids);static struct vio_driver nx842_vio_driver = { .name = KBUILD_MODNAME,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 149/800 media: sti: fix obj-$(config) targets
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 56c1f0876293888f686e31278d183d4af2cac3c3 ]
The right thing to do is to add a new object to the building system when a certain config option is selected, and *not* override them.
So, fix obj-$(config) logic at sti makefiles, using "+=", instead of ":=".
--- drivers/media/platform/sti/bdisp/Makefile | 2 +- drivers/media/platform/sti/delta/Makefile | 2 +- drivers/media/platform/sti/hva/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/sti/bdisp/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o +obj-$(CONFIG_VIDEO_STI_BDISP) += bdisp.o bdisp-objs := bdisp-v4l2.o bdisp-hw.o bdisp-debug.o
drivers/media/platform/sti/delta/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_VIDEO_STI_DELTA_DRIVER) := st-delta.o +obj-$(CONFIG_VIDEO_STI_DELTA_DRIVER) += st-delta.o st-delta-y := delta-v4l2.o delta-mem.o delta-ipc.o delta-debug.o # MJPEG support
drivers/media/platform/sti/hva/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_VIDEO_STI_HVA) := st-hva.o +obj-$(CONFIG_VIDEO_STI_HVA) += st-hva.o st-hva-y := hva-v4l2.o hva-hw.o hva-mem.o hva-h264.o st-hva-$(CONFIG_VIDEO_STI_HVA_DEBUGFS) += hva-debugfs.o
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 150/800 sched: Make the idle task quack like a per-CPU kthread
In reply to Greg Kroah-HartmanFrom: Valentin Schneider <[email protected]>
[ Upstream commit 00b89fe0197f0c55a045775c11553c0cdb7082fe ]
For all intents and purposes, the idle task is a per-CPU kthread. It isn't created via the same route as other pcpu kthreads however, and as a result it is missing a few bells and whistles: it fails kthread_is_per_cpu() and it doesn't have PF_NO_SETAFFINITY set.
Fix the former by giving the idle task a kthread struct along with the KTHREAD_IS_PER_CPU flag. This requires some extra iffery as init_idle() call be called more than once on the same idle task.
--- include/linux/kthread.h | 2 ++ kernel/kthread.c | 30 ++++++++++++++++++------------ kernel/sched/core.c | 21 +++++++++++++++------ 3 files changed, 35 insertions(+), 18 deletions(-)
include/linux/kthread.h +2 -0
@@ -33,6 +33,8 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),unsigned int cpu, const char *namefmt); +void set_kthread_struct (struct task_struct *p); +void kthread_set_per_cpu (struct task_struct *k,int cpu);bool kthread_is_per_cpu (struct task_struct *k);
kernel/kthread.c +18 -12
@@ -68,16 +68,6 @@ enum KTHREAD_BITS { KTHREAD_SHOULD_PARK, }; -static inline void set_kthread_struct (void *kthread) -{ -/* -* We abuse ->set_child_tid to avoid the new member and because it -* can't be wrongly copied by copy_process(). We also rely on fact -* that the caller can't exec, so PF_KTHREAD can't be cleared. -*/ - current->set_child_tid = (__force void __user *)kthread; -} -static inline struct kthread *to_kthread (struct task_struct *k) {WARN_ON (!(k->flags &PF_KTHREAD ));
@@ -103,6 +93,22 @@ static inline struct kthread *__to_kthread(struct task_struct *p)return kthread; } +void set_kthread_struct (struct task_struct *p) +{ +struct kthread *kthread; + +if (__to_kthread (p)) +return ; + + kthread =kzalloc (sizeof (*kthread),GFP_KERNEL ); +/* +* We abuse ->set_child_tid to avoid the new member and because it +* can't be wrongly copied by copy_process(). We also rely on fact +* that the caller can't exec, so PF_KTHREAD can't be cleared. +*/ + p->set_child_tid = (__force void __user *)kthread; +} +void free_kthread_struct (struct task_struct *k) {struct kthread *kthread;
@@ -272,8 +278,8 @@ static int kthread(void *_create)struct kthread *self;int ret; - self =kzalloc (sizeof (*self),GFP_KERNEL ); -set_kthread_struct (self); +set_kthread_struct (current); + self =to_kthread (current);/* If user was SIGKILLed, I release the structure. */ done =xchg (&create->done,NULL );
kernel/sched/core.c +15 -6
@@ -7440,12 +7440,25 @@ void __init init_idle(struct task_struct *idle, int cpu)__sched_fork (0 , idle); +/* +* The idle task doesn't need the kthread struct to function, but it +* is dressed up as a per-CPU kthread and thus needs to play the part +* if we want to avoid special-casing it in code that deals with per-CPU +* kthreads. +*/ +set_kthread_struct (idle); +raw_spin_lock_irqsave (&idle->pi_lock, flags);raw_spin_lock (&rq->lock); idle->state =TASK_RUNNING ; idle->se.exec_start =sched_clock (); - idle->flags |=PF_IDLE ; +/* +* PF_KTHREAD should already be set at this point; regardless, make it +* look like a proper per-CPU kthread. +*/ + idle->flags |=PF_IDLE |PF_KTHREAD |PF_NO_SETAFFINITY ; +kthread_set_per_cpu (idle, cpu);scs_task_reset (idle);kasan_unpoison_task_stack (idle);
@@ -7662,12 +7675,8 @@ static void balance_push(struct rq *rq)/* * Both the cpu-hotplug and stop task are in this case and are * required to complete the hotplug process. -* -* XXX: the idle task does not match kthread_is_per_cpu() due to -* histerical raisins. */ -if (rq->idle == push_task || -kthread_is_per_cpu (push_task) || +if (kthread_is_per_cpu (push_task) ||is_migration_disabled (push_task)) {/*
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 151/800 media: cpia2: fix memory leak in cpia2_usb_probe
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit be8656e62e9e791837b606a027802b504a945c97 ]
syzbot reported leak in cpia2 usb driver. The problem was in invalid error handling.
v4l2_device_register() is called in cpia2_init_camera_struct(), but all error cases after cpia2_init_camera_struct() did not call the v4l2_device_unregister()
--- drivers/media/usb/cpia2/cpia2.h | 1 + drivers/media/usb/cpia2/cpia2_core.c | 12 ++++++++++++ drivers/media/usb/cpia2/cpia2_usb.c | 13 +++++++------ 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/media/usb/cpia2/cpia2.h +1 -0
@@ -429,6 +429,7 @@ int cpia2_send_command(struct camera_data *cam, struct cpia2_command *cmd);int cpia2_do_command (struct camera_data *cam,unsigned int command,unsigned char direction,unsigned char param); +void cpia2_deinit_camera_struct (struct camera_data *cam,struct usb_interface *intf);struct camera_data *cpia2_init_camera_struct (struct usb_interface *intf);int cpia2_init_camera (struct camera_data *cam);int cpia2_allocate_buffers (struct camera_data *cam);
drivers/media/usb/cpia2/cpia2_core.c +12 -0
@@ -2163,6 +2163,18 @@ static void reset_camera_struct(struct camera_data *cam) cam->height = cam->params.roi.height; } +/****************************************************************************** +* +* cpia2_init_camera_struct +* +* Deinitialize camera struct +*****************************************************************************/ +void cpia2_deinit_camera_struct (struct camera_data *cam,struct usb_interface *intf) +{ +v4l2_device_unregister (&cam->v4l2_dev); +kfree (cam); +} +/****************************************************************************** * * cpia2_init_camera_struct
drivers/media/usb/cpia2/cpia2_usb.c +7 -6
@@ -844,15 +844,13 @@ static int cpia2_usb_probe(struct usb_interface *intf, ret =set_alternate (cam,USBIF_CMDONLY );if (ret <0 ) {ERR ("%s: usb_set_interface error (ret = %d)\n" , __func__, ret); -kfree (cam); -return ret; + goto alt_err; }if ((ret =cpia2_init_camera (cam)) <0 ) {ERR ("%s: failed to initialize cpia2 camera (ret = %d)\n" , __func__, ret); -kfree (cam); -return ret; + goto alt_err; } LOG(" CPiA Version: %d.%02d (%d.%d)\n", cam->params.version.firmware_revision_hi,
@@ -872,11 +870,14 @@ static int cpia2_usb_probe(struct usb_interface *intf, ret =cpia2_register_camera (cam);if (ret <0 ) {ERR ("%s: Failed to register cpia2 camera (ret = %d)\n" , __func__, ret); -kfree (cam); -return ret; + goto alt_err; }return 0 ; + +alt_err: +cpia2_deinit_camera_struct (cam, intf); +return ret; }/******************************************************************************
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 152/800 media: cobalt: fix race condition in setting HPD
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 3d37ef41bed0854805ab9af22c422267510e1344 ]
The cobalt_s_bit_sysctrl reads the old register value over PCI, then changes a bit and sets writes the new value to the register.
This is used among other things for setting the HPD output pin.
But if the HPD is changed for multiple inputs at the same time, then this causes a race condition where a stale value is read.
Serialize this function with a mutex.
--- drivers/media/pci/cobalt/cobalt-driver.c | 1 + drivers/media/pci/cobalt/cobalt-driver.h | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/media/pci/cobalt/cobalt-driver.c +1 -0
@@ -667,6 +667,7 @@ static int cobalt_probe(struct pci_dev *pci_dev,return -ENOMEM ; cobalt->pci_dev = pci_dev; cobalt->instance = i; +mutex_init (&cobalt->pci_lock); retval =v4l2_device_register (&pci_dev->dev, &cobalt->v4l2_dev);if (retval) {
drivers/media/pci/cobalt/cobalt-driver.h +6 -1
@@ -251,6 +251,8 @@ struct cobalt {int instance;struct pci_dev *pci_dev;struct v4l2_device v4l2_dev; +/* serialize PCI access in cobalt_s_bit_sysctrl() */ +struct mutex pci_lock;void __iomem *bar0, *bar1;
@@ -320,10 +322,13 @@ static inline u32 cobalt_g_sysctrl(struct cobalt *cobalt)static inline void cobalt_s_bit_sysctrl (struct cobalt *cobalt,int bit,int val) { -u32 ctrl =cobalt_read_bar1 (cobalt,COBALT_SYS_CTRL_BASE ); +u32 ctrl; +mutex_lock (&cobalt->pci_lock); + ctrl =cobalt_read_bar1 (cobalt,COBALT_SYS_CTRL_BASE );cobalt_write_bar1 (cobalt,COBALT_SYS_CTRL_BASE , (ctrl & ~(1UL << bit)) | (val << bit)); +mutex_unlock (&cobalt->pci_lock); }static inline u32 cobalt_g_sysstat (struct cobalt *cobalt)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 153/800 media: hevc: Fix dependent slice segment flags
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 67a7e53d5b21f3a84efc03a4e62db7caf97841ef ]
Dependent slice segment flag for PPS control is misnamed. It should have "enabled" at the end. It only tells if this flag is present in slice header or not and not the actual value.
Fix this by renaming the PPS flag and introduce another flag for slice control which tells actual value.
--- Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 5 ++++- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 4 ++-- include/media/hevc-ctrls.h | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +4 -1
@@ -3053,7 +3053,7 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - :stub-columns: 0 :widths: 1 1 2 - * - ``V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT`` + * - ``V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT_ENABLED`` - 0x00000001 - * - ``V4L2_HEVC_PPS_FLAG_OUTPUT_FLAG_PRESENT``
@@ -3277,6 +3277,9 @@ enum v4l2_mpeg_video_hevc_size_of_length_field - * - ``V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED`` - 0x00000100 - + * - ``V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT`` + - 0x00000200 + - .. raw:: latex
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +2 -2
@@ -477,8 +477,8 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx, slice_params->flags); reg |=VE_DEC_H265_FLAG (VE_DEC_H265_DEC_SLICE_HDR_INFO0_FLAG_DEPENDENT_SLICE_SEGMENT , -V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT , - pps->flags); +V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT , + slice_params->flags);/* FIXME: For multi-slice support. */ reg |=VE_DEC_H265_DEC_SLICE_HDR_INFO0_FLAG_FIRST_SLICE_SEGMENT_IN_PIC ;
include/media/hevc-ctrls.h +2 -1
@@ -81,7 +81,7 @@ struct v4l2_ctrl_hevc_sps {__u64 flags; }; -#define V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT (1ULL << 0) +#define V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT_ENABLED (1ULL << 0)#define V4L2_HEVC_PPS_FLAG_OUTPUT_FLAG_PRESENT (1ULL << 1)#define V4L2_HEVC_PPS_FLAG_SIGN_DATA_HIDING_ENABLED (1ULL << 2)#define V4L2_HEVC_PPS_FLAG_CABAC_INIT_PRESENT (1ULL << 3)
@@ -160,6 +160,7 @@ struct v4l2_hevc_pred_weight_table {#define V4L2_HEVC_SLICE_PARAMS_FLAG_USE_INTEGER_MV (1ULL << 6)#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_DEBLOCKING_FILTER_DISABLED (1ULL << 7)#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED (1ULL << 8) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT (1ULL << 9)struct v4l2_ctrl_hevc_slice_params {__u32 bit_size;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 154/800 media: pvrusb2: fix warning in pvr2_i2c_core_done
In reply to Greg Kroah-HartmanFrom: Anirudh Rayabharam <[email protected]>
[ Upstream commit f8194e5e63fdcb349e8da9eef9e574d5b1d687cb ]
syzbot has reported the following warning in pvr2_i2c_done:
sysfs group 'power' not found for kobject '1-0043'
When the device is disconnected (pvr_hdw_disconnect), the i2c adapter is not unregistered along with the USB and v4l2 teardown. As part of the USB device disconnect, the sysfs files of the subdevices are also deleted. So, by the time pvr_i2c_core_done is called by pvr_context_destroy, the sysfs files have been deleted.
To fix this, unregister the i2c adapter too in pvr_hdw_disconnect. Make the device deregistration code shared by calling pvr_hdw_disconnect from pvr2_hdw_destroy.
--- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +2 -2
@@ -2676,9 +2676,8 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)pvr2_stream_destroy (hdw->vid_stream); hdw->vid_stream =NULL ; } -pvr2_i2c_core_done (hdw);v4l2_device_unregister (&hdw->v4l2_dev); -pvr2_hdw_remove_usb_stuff (hdw); +pvr2_hdw_disconnect (hdw);mutex_lock (&pvr2_unit_mtx); do { if ((hdw->unit_number >= 0) &&
@@ -2705,6 +2704,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw) {pvr2_trace (PVR2_TRACE_INIT ,"pvr2_hdw_disconnect(hdw=%p)" ,hdw);LOCK_TAKE (hdw->big_lock); +pvr2_i2c_core_done (hdw);LOCK_TAKE (hdw->ctl_lock);pvr2_hdw_remove_usb_stuff (hdw);LOCK_GIVE (hdw->ctl_lock);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 155/800 media: imx: imx7_mipi_csis: Fix logging of only error event counters
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit d2fcc9c2de1191ea80366e3658711753738dd10a ]
The mipi_csis_events array ends with 6 non-error events, not 4. Update mipi_csis_log_counters() accordingly. While at it, log event counters in forward order, as there's no reason to log them backward.
--- drivers/staging/media/imx/imx7-mipi-csis.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +4 -2
@@ -666,13 +666,15 @@ static void mipi_csis_clear_counters(struct csi_state *state)static void mipi_csis_log_counters (struct csi_state *state,bool non_errors) { -int i = non_errors ?MIPI_CSIS_NUM_EVENTS :MIPI_CSIS_NUM_EVENTS -4 ; +unsigned int num_events = non_errors ?MIPI_CSIS_NUM_EVENTS + :MIPI_CSIS_NUM_EVENTS -6 ;struct device *dev = &state->pdev->dev;unsigned long flags; +unsigned int i;spin_lock_irqsave (&state->slock, flags); -for (i--; i >=0 ; i--) { +for (i =0 ; i < num_events; ++i) {if (state->events[i].counter >0 || state->debug)dev_info (dev,"%s events: %d\n" , state->events[i].name, state->events[i].counter);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 156/800 crypto: qat - check return code of qat_hal_rd_rel_reg()
In reply to Greg Kroah-HartmanFrom: Jack Xu <[email protected]>
[ Upstream commit 96b57229209490c8bca4335b01a426a96173dc56 ]
Check the return code of the function qat_hal_rd_rel_reg() and return it to the caller.
This is to fix the following warning when compiling the driver with clang scan-build:
drivers/crypto/qat/qat_common/qat_hal.c:1436:2: warning: 6th function call argument is an uninitialized value
--- drivers/crypto/qat/qat_common/qat_hal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/qat_hal.c +5 -1
@@ -1417,7 +1417,11 @@ static int qat_hal_put_rel_wr_xfer(struct icp_qat_fw_loader_handle *handle,pr_err ("QAT: bad xfrAddr=0x%x\n" , xfr_addr);return -EINVAL ; } -qat_hal_rd_rel_reg (handle, ae, ctx,ICP_GPB_REL , gprnum, &gprval); + status =qat_hal_rd_rel_reg (handle, ae, ctx,ICP_GPB_REL , gprnum, &gprval); +if (status) { +pr_err ("QAT: failed to read register" ); +return status; + } gpr_addr =qat_hal_get_reg_addr (ICP_GPB_REL , gprnum); data16low =0xffff & data; data16hi =0xffff & (data >>0x10 );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 157/800 crypto: qat - remove unused macro in FW loader
In reply to Greg Kroah-HartmanFrom: Jack Xu <[email protected]>
[ Upstream commit 9afe77cf25d9670e61b489fd52cc6f75fd7f6803 ]
Remove the unused macro ICP_DH895XCC_PESRAM_BAR_SIZE in the firmware loader.
This is to fix the following warning when compiling the driver using the clang compiler with CC=clang W=2:
drivers/crypto/qat/qat_common/qat_uclo.c:345:9: warning: macro is not used [-Wunused-macros]
--- drivers/crypto/qat/qat_common/qat_uclo.c | 1 - 1 file changed, 1 deletion(-)
drivers/crypto/qat/qat_common/qat_uclo.c +0 -1
@@ -342,7 +342,6 @@ static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,return 0 ; } -#define ICP_DH895XCC_PESRAM_BAR_SIZE 0x80000static int qat_uclo_init_ae_memory (struct icp_qat_fw_loader_handle *handle,struct icp_qat_uof_initmem *init_mem) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 158/800 crypto: qce: skcipher: Fix incorrect sg count for dma transfers
In reply to Greg Kroah-HartmanFrom: Thara Gopinath <[email protected]>
[ Upstream commit 1339a7c3ba05137a2d2fe75f602311bbfc6fab33 ]
Use the sg count returned by dma_map_sg to call into dmaengine_prep_slave_sg rather than using the original sg count. dma_map_sg can merge consecutive sglist entries, thus making the original sg count wrong. This is a fix for memory coruption issues observed while testing encryption/decryption of large messages using libkcapi framework.
Patch has been tested further by running full suite of tcrypt.ko tests including fuzz tests.
--- drivers/crypto/qce/skcipher.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/crypto/qce/skcipher.c +8 -7
@@ -72,7 +72,7 @@ qce_skcipher_async_req_handle(struct crypto_async_request *async_req)struct scatterlist *sg;bool diff_dst;gfp_t gfp; -int ret; +int dst_nents, src_nents, ret; rctx->iv = req->iv; rctx->ivsize =crypto_skcipher_ivsize (skcipher);
@@ -123,21 +123,22 @@ qce_skcipher_async_req_handle(struct crypto_async_request *async_req)sg_mark_end (sg); rctx->dst_sg = rctx->dst_tbl.sgl; - ret =dma_map_sg (qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst); -if (ret <0 ) + dst_nents =dma_map_sg (qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst); +if (dst_nents <0 ) goto error_free;if (diff_dst) { - ret =dma_map_sg (qce->dev, req->src, rctx->src_nents, dir_src); -if (ret <0 ) + src_nents =dma_map_sg (qce->dev, req->src, rctx->src_nents, dir_src); +if (src_nents <0 ) goto error_unmap_dst; rctx->src_sg = req->src; }else { rctx->src_sg = rctx->dst_sg; + src_nents = dst_nents -1 ; } - ret =qce_dma_prep_sgs (&qce->dma, rctx->src_sg, rctx->src_nents, - rctx->dst_sg, rctx->dst_nents, + ret =qce_dma_prep_sgs (&qce->dma, rctx->src_sg, src_nents, + rctx->dst_sg, dst_nents, qce_skcipher_done, async_req);if (ret) goto error_unmap_src;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 159/800 crypto: ecdh - fix ecdh-nist-p192s entry in testmgr
In reply to Greg Kroah-HartmanFrom: Hui Tang <[email protected]>
[ Upstream commit 6889fc2104e5d20899b91e61daf07a7524b2010d ]
Add a comment that p192 will fail to register in FIPS mode.
Fix ecdh-nist-p192's entry in testmgr by removing the ifdefs and not setting fips_allowed.
--- crypto/ecdh.c | 1 + crypto/testmgr.c | 3 --- crypto/testmgr.h | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-)
crypto/ecdh.c +1 -0
@@ -179,6 +179,7 @@ static int ecdh_init(void) {int ret; +/* NIST p192 will fail to register in FIPS mode */ ret =crypto_register_kpp (&ecdh_nist_p192); ecdh_nist_p192_registered = ret ==0 ;
crypto/testmgr.c +0 -3
@@ -4899,15 +4899,12 @@ static const struct alg_test_desc alg_test_descs[] = { } }, {#endif -#ifndef CONFIG_CRYPTO_FIPS .alg = "ecdh-nist-p192", .test = alg_test_kpp, - .fips_allowed = 1, .suite = { .kpp = __VECS(ecdh_p192_tv_template) } }, { -#endif .alg = "ecdh-nist-p256", .test = alg_test_kpp, .fips_allowed = 1,
crypto/testmgr.h +0 -2
@@ -2685,7 +2685,6 @@ static const struct kpp_testvec curve25519_tv_template[] = { } }; -#ifndef CONFIG_CRYPTO_FIPSstatic const struct kpp_testvec ecdh_p192_tv_template[] = { { .secret =
@@ -2725,7 +2724,6 @@ static const struct kpp_testvec ecdh_p192_tv_template[] = { .expected_ss_size = 24 } }; -#endif static const struct kpp_testvec ecdh_p256_tv_template[] = { {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 160/800 crypto: ecdh - fix ecdh_init
In reply to Greg Kroah-HartmanFrom: Hui Tang <[email protected]>
[ Upstream commit 8fd28fa5046b377039d5bbc0ab2f625dec703980 ]
NIST P192 is not unregistered if failed to register NIST P256, actually it need to unregister the algorithms already registered.
--- crypto/ecdh.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
crypto/ecdh.c +10 -1
@@ -183,7 +183,16 @@ static int ecdh_init(void) ret =crypto_register_kpp (&ecdh_nist_p192); ecdh_nist_p192_registered = ret ==0 ; -return crypto_register_kpp (&ecdh_nist_p256); + ret =crypto_register_kpp (&ecdh_nist_p256); +if (ret) + goto nist_p256_error; + +return 0 ; + +nist_p256_error: +if (ecdh_nist_p192_registered) +crypto_unregister_kpp (&ecdh_nist_p192); +return ret; }static void ecdh_exit (void )
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 161/800 arm64: perf: Convert snprintf to sysfs_emit
In reply to Greg Kroah-HartmanFrom: Tian Tao <[email protected]>
[ Upstream commit a5740e955540181f4ab8f076cc9795c6bbe4d730 ]
Use sysfs_emit instead of snprintf to avoid buf overrun,because in sysfs_emit it strictly checks whether buf is null or buf whether pagesize aligned, otherwise it returns an error.
--- arch/arm64/kernel/perf_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/perf_event.c +1 -1
@@ -312,7 +312,7 @@ static ssize_t slots_show(struct device *dev, struct device_attribute *attr, struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu);u32 slots = cpu_pmu->reg_pmmir &ARMV8_PMU_SLOTS_MASK ; -return snprintf (page,PAGE_SIZE ,"0x%08x\n" , slots); +return sysfs_emit (page,"0x%08x\n" , slots); }static DEVICE_ATTR_RO (slots);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 162/800 sched/fair: Fix ascii art by relpacing tabs
In reply to Greg Kroah-HartmanFrom: Odin Ugedal <[email protected]>
[ Upstream commit 08f7c2f4d0e9f4283f5796b8168044c034a1bfcb ]
When using something other than 8 spaces per tab, this ascii art makes not sense, and the reader might end up wondering what this advanced equation "is".
--- kernel/sched/fair.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sched/fair.c +4 -4
@@ -3139,7 +3139,7 @@ void reweight_task(struct task_struct *p, int prio)* * tg->weight * grq->load.weight * ge->load.weight = ----------------------------- (1) -* \Sum grq->load.weight +* \Sum grq->load.weight * * Now, because computing that sum is prohibitively expensive to compute (been * there, done that) we approximate it with this average stuff. The average
@@ -3153,7 +3153,7 @@ void reweight_task(struct task_struct *p, int prio)* * tg->weight * grq->avg.load_avg * ge->load.weight = ------------------------------ (3) -* tg->load_avg +* tg->load_avg * * Where: tg->load_avg ~= \Sum grq->avg.load_avg *
@@ -3169,7 +3169,7 @@ void reweight_task(struct task_struct *p, int prio)* * tg->weight * grq->load.weight * ge->load.weight = ----------------------------- = tg->weight (4) -* grp->load.weight +* grp->load.weight * * That is, the sum collapses because all other CPUs are idle; the UP scenario. *
@@ -3188,7 +3188,7 @@ void reweight_task(struct task_struct *p, int prio)* * tg->weight * grq->load.weight * ge->load.weight = ----------------------------- (6) -* tg_load_avg' +* tg_load_avg' * * Where: *
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 163/800 ima: Dont remove security.ima if file must not be appraised
In reply to Greg Kroah-HartmanFrom: Roberto Sassu <[email protected]>
[ Upstream commit ed1b472fc15aeaa20ddeeb93fd25190014e50d17 ]
Files might come from a remote source and might have xattrs, including security.ima. It should not be IMA task to decide whether security.ima should be kept or not. This patch removes the removexattr() system call in ima_inode_post_setattr().
--- security/integrity/ima/ima_appraise.c | 2 -- 1 file changed, 2 deletions(-)
security/integrity/ima/ima_appraise.c +0 -2
@@ -522,8 +522,6 @@ void ima_inode_post_setattr(struct user_namespace *mnt_userns,return ; action =ima_must_appraise (mnt_userns, inode,MAY_ACCESS ,POST_SETATTR ); -if (!action) -__vfs_removexattr (&init_user_ns, dentry,XATTR_NAME_IMA ); iint =integrity_iint_find (inode);if (iint) {set_bit (IMA_CHANGE_ATTR , &iint->atomic_flags);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 164/800 media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off
In reply to Greg Kroah-HartmanFrom: Dillon Min <[email protected]>
[ Upstream commit 24786ccd9c80fdb05494aa4d90fcb8f34295c193 ]
On some platform(imx6q), xvclk might not switch on in advance, also for power save purpose, xvclk should not be always on. so, add clk_prepare_enable(), clk_disable_unprepare() in driver side to set xvclk on/off at proper stage.
Add following changes:
- add 'struct clk *clk;' in 'struct ov2659 {}'
- enable xvclk in ov2659_power_on()
- disable xvclk in ov2659_power_off()
--- drivers/media/i2c/ov2659.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/media/i2c/ov2659.c +18 -6
@@ -204,6 +204,7 @@ struct ov2659 {struct i2c_client *client;struct v4l2_ctrl_handler ctrls;struct v4l2_ctrl *link_frequency; +struct clk *clk;const struct ov2659_framesize *frame_size;struct sensor_register *format_ctrl_regs;struct ov2659_pll_ctrl pll;
@@ -1270,6 +1271,8 @@ static int ov2659_power_off(struct device *dev)gpiod_set_value (ov2659->pwdn_gpio,1 ); +clk_disable_unprepare (ov2659->clk); +return 0 ; }
@@ -1278,9 +1281,17 @@ static int ov2659_power_on(struct device *dev)struct i2c_client *client =to_i2c_client (dev);struct v4l2_subdev *sd =i2c_get_clientdata (client);struct ov2659 *ov2659 =to_ov2659 (sd); +int ret;dev_dbg (&client->dev,"%s:\n" , __func__); + ret =clk_prepare_enable (ov2659->clk); +if (ret) { +dev_err (&client->dev,"%s: failed to enable clock\n" , + __func__); +return ret; + } +gpiod_set_value (ov2659->pwdn_gpio,0 );if (ov2659->resetb_gpio) {
@@ -1425,7 +1436,6 @@ static int ov2659_probe(struct i2c_client *client)const struct ov2659_platform_data *pdata =ov2659_get_pdata (client);struct v4l2_subdev *sd;struct ov2659 *ov2659; -struct clk *clk;int ret;if (!pdata) {
@@ -1440,11 +1450,11 @@ static int ov2659_probe(struct i2c_client *client) ov2659->pdata = pdata; ov2659->client = client; - clk =devm_clk_get (&client->dev,"xvclk" ); -if (IS_ERR (clk)) -return PTR_ERR (clk); + ov2659->clk =devm_clk_get (&client->dev,"xvclk" ); +if (IS_ERR (ov2659->clk)) +return PTR_ERR (ov2659->clk); - ov2659->xvclk_frequency =clk_get_rate (clk); + ov2659->xvclk_frequency =clk_get_rate (ov2659->clk);if (ov2659->xvclk_frequency <6000000 || ov2659->xvclk_frequency >27000000 )return -EINVAL ;
@@ -1506,7 +1516,9 @@ static int ov2659_probe(struct i2c_client *client) ov2659->frame_size = &ov2659_framesizes[2 ]; ov2659->format_ctrl_regs = ov2659_formats[0 ].format_ctrl_regs; -ov2659_power_on (&client->dev); + ret =ov2659_power_on (&client->dev); +if (ret <0 ) + goto error; ret =ov2659_detect (sd);if (ret <0 )
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 165/800 media: bt878: do not schedule tasklet when it is not setup
In reply to Greg Kroah-HartmanFrom: Tong Zhang <[email protected]>
[ Upstream commit a3a54bf4bddaecda8b5767209cfc703f0be2841d ]
There is a problem with the tasklet in bt878. bt->tasklet is set by dvb-bt8xx.ko, and bt878.ko can be loaded independently. In this case if interrupt comes it may cause null-ptr-dereference. To solve this issue, we check if the tasklet is actually set before calling tasklet_schedule.
[ 1.750438] bt878(0): irq FDSR FBUS risc_pc= [ 1.750728] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 1.752969] RIP: 0010:0x0 [ 1.757526] Call Trace: [ 1.757659] <IRQ> [ 1.757770] tasklet_action_common.isra.0+0x107/0x110 [ 1.758041] tasklet_action+0x22/0x30 [ 1.758237] __do_softirq+0xe0/0x29b [ 1.758430] irq_exit_rcu+0xa4/0xb0 [ 1.758618] common_interrupt+0x8d/0xa0 [ 1.758824] </IRQ>
--- drivers/media/pci/bt8xx/bt878.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/pci/bt8xx/bt878.c +2 -1
@@ -300,7 +300,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id) }if (astat &BT878_ARISCI ) { bt->finished_block = (stat &BT878_ARISCS ) >>28 ; -tasklet_schedule (&bt->tasklet); +if (bt->tasklet.callback) +tasklet_schedule (&bt->tasklet);break ; } count++;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 166/800 media: em28xx: Fix possible memory leak of em28xx struct
In reply to Greg Kroah-HartmanFrom: Igor Matheus Andrade Torrente <[email protected]>
[ Upstream commit ac5688637144644f06ed1f3c6d4dd8bb7db96020 ]
The em28xx struct kref isn't being decreased after an error in the em28xx_ir_init, leading to a possible memory leak.
A kref_put and em28xx_shutdown_buttons is added to the error handler code.
--- drivers/media/usb/em28xx/em28xx-input.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/media/usb/em28xx/em28xx-input.c +6 -2
@@ -720,7 +720,8 @@ static int em28xx_ir_init(struct em28xx *dev) dev->board.has_ir_i2c =0 ;dev_warn (&dev->intf->dev,"No i2c IR remote control device found.\n" ); -return -ENODEV ; + err = -ENODEV ; + goto ref_put; } }
@@ -735,7 +736,7 @@ static int em28xx_ir_init(struct em28xx *dev) ir =kzalloc (sizeof (*ir),GFP_KERNEL );if (!ir) -return -ENOMEM ; + goto ref_put; rc =rc_allocate_device (RC_DRIVER_SCANCODE );if (!rc) goto error;
@@ -839,6 +840,9 @@ error: dev->ir =NULL ;rc_free_device (rc);kfree (ir); +ref_put: +em28xx_shutdown_buttons (dev); +kref_put (&dev->ref, em28xx_free_device);return err; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 167/800 media: hantro: Fix .buf_prepare
In reply to Greg Kroah-HartmanFrom: Andrzej Pietrasiewicz <[email protected]>
[ Upstream commit 082aaecff35fbe1937531057911b1dd1fc6b496e ]
The driver should only set the payload on .buf_prepare if the buffer is CAPTURE type. If an OUTPUT buffer has a zero bytesused set by userspace then v4l2-core will set it to buffer length.
If we overwrite bytesused for OUTPUT buffers, too, then vb2_get_plane_payload() will return incorrect value which might be then written to hw registers by the driver in hantro_g1_h264_dec.c.
--- drivers/staging/media/hantro/hantro_v4l2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/staging/media/hantro/hantro_v4l2.c +8 -1
@@ -639,7 +639,14 @@ static int hantro_buf_prepare(struct vb2_buffer *vb) ret =hantro_buf_plane_check (vb, pix_fmt);if (ret)return ret; -vb2_set_plane_payload (vb,0 , pix_fmt->plane_fmt[0 ].sizeimage); +/* +* Buffer's bytesused must be written by driver for CAPTURE buffers. +* (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets +* it to buffer length). +*/ +if (V4L2_TYPE_IS_CAPTURE (vq->type)) +vb2_set_plane_payload (vb,0 , pix_fmt->plane_fmt[0 ].sizeimage); +return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 168/800 media: cedrus: Fix .buf_prepare
In reply to Greg Kroah-HartmanFrom: Andrzej Pietrasiewicz <[email protected]>
[ Upstream commit d84b9202d712309840f8b5abee0ed272506563bd ]
The driver should only set the payload on .buf_prepare if the buffer is CAPTURE type. If an OUTPUT buffer has a zero bytesused set by userspace then v4l2-core will set it to buffer length.
If we overwrite bytesused for OUTPUT buffers, too, then vb2_get_plane_payload() will return incorrect value which might be then written to hw registers by the driver in cedrus_h264.c or cedrus_vp8.c.
--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/staging/media/sunxi/cedrus/cedrus_video.c +7 -1
@@ -457,7 +457,13 @@ static int cedrus_buf_prepare(struct vb2_buffer *vb)if (vb2_plane_size (vb,0 ) < pix_fmt->sizeimage)return -EINVAL ; -vb2_set_plane_payload (vb,0 , pix_fmt->sizeimage); +/* +* Buffer's bytesused must be written by driver for CAPTURE buffers. +* (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets +* it to buffer length). +*/ +if (V4L2_TYPE_IS_CAPTURE (vq->type)) +vb2_set_plane_payload (vb,0 , pix_fmt->sizeimage);return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 169/800 media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release
In reply to Greg Kroah-HartmanFrom: Lv Yunlong <[email protected]>
[ Upstream commit 7dd0c9e547b6924e18712b6b51aa3cba1896ee2c ]
A use after free bug caused by the dangling pointer filp->privitate_data in v4l2_fh_release.
See https://lore.kernel.org/patchwork/patch/1419058/.
My patch sets the dangling pointer to NULL to provide robust.
--- drivers/media/v4l2-core/v4l2-fh.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/v4l2-core/v4l2-fh.c +1 -0
@@ -96,6 +96,7 @@ int v4l2_fh_release(struct file *filp)v4l2_fh_del (fh);v4l2_fh_exit (fh);kfree (fh); + filp->private_data =NULL ; }return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 170/800 media: bt8xx: Fix a missing check bug in bt878_probe
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 1a4520090681853e6b850cbe54b27247a013e0e5 ]
In 'bt878_irq', the driver calls 'tasklet_schedule', but this tasklet is set in 'dvb_bt8xx_load_card' of another driver 'dvb-bt8xx'. However, this two drivers are separate. The user may not load the 'dvb-bt8xx' driver when loading the 'bt8xx' driver, that is, the tasklet has not been initialized when 'tasklet_schedule' is called, so it is necessary to check whether the tasklet is initialized in 'bt878_probe'.
Fix this by adding a check at the end of bt878_probe.
The KASAN's report reveals it:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 PGD 800000006aab2067 P4D 800000006aab2067 PUD 6b2ea067 PMD 0 Oops: 0010 [#1] PREEMPT SMP KASAN PTI CPU: 2 PID: 8724 Comm: syz-executor.0 Not tainted 4.19.177- gdba4159c14ef-dirty #40 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59- gc9ba5276e321-prebuilt.qemu.org 04/01/2014 RIP: 0010: (null) Code: Bad RIP value. RSP: 0018:ffff88806c287ea0 EFLAGS: 00010246 RAX: fffffbfff1b01774 RBX: dffffc0000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 1ffffffff1b01775 RDI: 0000000000000000 RBP: ffff88806c287f00 R08: fffffbfff1b01774 R09: fffffbfff1b01774 R10: 0000000000000001 R11: fffffbfff1b01773 R12: 0000000000000000 R13: ffff88806c29f530 R14: ffffffff8d80bb88 R15: ffffffff8d80bb90 FS: 00007f6b550e6700(0000) GS:ffff88806c280000(0000) knlGS: 0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 000000005ec98000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <IRQ> tasklet_action_common.isra.17+0x141/0x420 kernel/softirq.c:522 tasklet_action+0x50/0x70 kernel/softirq.c:540 __do_softirq+0x224/0x92c kernel/softirq.c:292 invoke_softirq kernel/softirq.c:372 [inline] irq_exit+0x15a/0x180 kernel/softirq.c:412 exiting_irq arch/x86/include/asm/apic.h:535 [inline] do_IRQ+0x123/0x1e0 arch/x86/kernel/irq.c:260 common_interrupt+0xf/0xf arch/x86/entry/entry_64.S:670 </IRQ> RIP: 0010:__do_sys_interrupt kernel/sys.c:2593 [inline] RIP: 0010:__se_sys_interrupt kernel/sys.c:2584 [inline] RIP: 0010:__x64_sys_interrupt+0x5b/0x80 kernel/sys.c:2584 Code: ba 00 04 00 00 48 c7 c7 c0 99 31 8c e8 ae 76 5e 01 48 85 c0 75 21 e8
14 ae 24 00 48 c7 c3 c0 99 31 8c b8 0c 00 00 00 0f 01 c1 <31> db e8 fe ad 24 00 48 89 d8 5b 5d c3 48 c7 c3 ea ff ff ff eb ec
RSP: 0018:ffff888054167f10 EFLAGS: 00000212 ORIG_RAX: ffffffffffffffde
RAX: 000000000000000c RBX: ffffffff8c3199c0 RCX: ffffc90001ca6000
RDX: 000000000000001a RSI: ffffffff813478fc RDI: ffffffff8c319dc0
RBP: ffff888054167f18 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000080 R11: fffffbfff18633b7 R12: ffff888054167f58
R13: ffff88805f638000 R14: 0000000000000000 R15: 0000000000000000
do_syscall_64+0xb0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4692a9 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6b550e5c48 EFLAGS: 00000246 ORIG_RAX: 000000000000014f
RAX: ffffffffffffffda RBX: 000000000077bf60 RCX: 00000000004692a9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000140
RBP: 00000000004cf7eb R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000077bf60
R13: 0000000000000000 R14: 000000000077bf60 R15: 00007fff55a1dca0
Modules linked in: Dumping ftrace buffer: (ftrace buffer empty) CR2: 0000000000000000 ---[ end trace 68e5849c3f77cbb6 ]--- RIP: 0010: (null) Code: Bad RIP value. RSP: 0018:ffff88806c287ea0 EFLAGS: 00010246 RAX: fffffbfff1b01774 RBX: dffffc0000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 1ffffffff1b01775 RDI: 0000000000000000 RBP: ffff88806c287f00 R08: fffffbfff1b01774 R09: fffffbfff1b01774 R10: 0000000000000001 R11: fffffbfff1b01773 R12: 0000000000000000 R13: ffff88806c29f530 R14: ffffffff8d80bb88 R15: ffffffff8d80bb90 FS: 00007f6b550e6700(0000) GS:ffff88806c280000(0000) knlGS: 0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 000000005ec98000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
--- drivers/media/pci/bt8xx/bt878.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/pci/bt8xx/bt878.c +3 -0
@@ -478,6 +478,9 @@ static int bt878_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)btwrite (0 ,BT878_AINT_MASK ); bt878_num++; +if (!bt->tasklet.func) +tasklet_disable (&bt->tasklet); +return 0 ; fail2:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 171/800 media: st-hva: Fix potential NULL pointer dereferences
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit b7fdd208687ba59ebfb09b2199596471c63b69e3 ]
When ctx_id >= HVA_MAX_INSTANCES in hva_hw_its_irq_thread() it tries to access fields of ctx that is NULL at that point. The patch gets rid of these accesses.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/media/platform/sti/hva/hva-hw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/sti/hva/hva-hw.c +1 -2
@@ -130,8 +130,7 @@ static irqreturn_t hva_hw_its_irq_thread(int irq, void *arg) ctx_id = (hva->sts_reg &0xFF00 ) >>8 ;if (ctx_id >=HVA_MAX_INSTANCES ) {dev_err (dev,"%s %s: bad context identifier: %d\n" , - ctx->name, __func__, ctx_id); - ctx->hw_err = true; +HVA_PREFIX , __func__, ctx_id); goto out; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 172/800 crypto: hisilicon/sec - fixup 3des minimum key size declaration
In reply to Greg Kroah-HartmanFrom: Kai Ye <[email protected]>
[ Upstream commit 6161f40c630bd7ced5f236cd5fbabec06e47afae ]
Fixup the 3des algorithm minimum key size declaration.
--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/sec2/sec_crypto.c +2 -2
@@ -1541,11 +1541,11 @@ static struct skcipher_alg sec_skciphers[] = { AES_BLOCK_SIZE, AES_BLOCK_SIZE) SEC_SKCIPHER_ALG("ecb(des3_ede)", sec_setkey_3des_ecb, - SEC_DES3_2KEY_SIZE, SEC_DES3_3KEY_SIZE, + SEC_DES3_3KEY_SIZE, SEC_DES3_3KEY_SIZE, DES3_EDE_BLOCK_SIZE, 0) SEC_SKCIPHER_ALG("cbc(des3_ede)", sec_setkey_3des_cbc, - SEC_DES3_2KEY_SIZE, SEC_DES3_3KEY_SIZE, + SEC_DES3_3KEY_SIZE, SEC_DES3_3KEY_SIZE, DES3_EDE_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE) SEC_SKCIPHER_ALG("xts(sm4)", sec_setkey_sm4_xts,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 173/800 arm64: entry: dont instrument entry code with KCOV
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit bf6fa2c0dda751863c3446aa64d733013bec4a19 ]
The code in entry-common.c runs at exception entry and return boundaries, where portions of the kernel environment aren't available. For example, RCU may not be watching, and lockdep state may be out-of-sync with the hardware. Due to this, it is not sound to instrument this code.
We generally avoid instrumentation by marking the entry functions as noinstr, but currently this doesn't inhibit KCOV instrumentation. Prevent this by disabling KCOV for the entire compilation unit.
--- arch/arm64/kernel/Makefile | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/kernel/Makefile +5 -0
@@ -14,6 +14,11 @@ CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall.o = -fstack-protector -fstack-protector-strong CFLAGS_syscall.o += -fno-stack-protector +# It's not safe to invoke KCOV when portions of the kernel environment aren't +# available or are out-of-sync with HW state. Since `noinstr` doesn't always +# inhibit KCOV instrumentation, disable it for the entire compilation unit. +KCOV_INSTRUMENT_entry.o := n + # Object file lists. obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ entry-common.o entry-fpsimd.o process.o ptrace.o \
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 174/800 Makefile: fix GDB warning with CONFIG_RELR
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
[ Upstream commit 27f2a4db76e8d8a8b601fc1c6a7a17f88bd907ab ]
GDB produces the following warning when debugging kernels built with CONFIG_RELR:
BFD: /android0/linux-next/vmlinux: unknown type [0x13] section `.relr.dyn'
when loading a kernel built with CONFIG_RELR into GDB. It can also prevent debugging symbols using such relocations.
Peter sugguests:
[That flag] means that lld will use dynamic tags and section type numbers in the OS-specific range rather than the generic range. The kernel itself doesn't care about these numbers; it determines the location of the RELR section using symbols defined by a linker script.
--- Makefile | 2 +- scripts/tools-support-relr.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile +1 -1
@@ -1039,7 +1039,7 @@ LDFLAGS_vmlinux += $(call ld-option, -X,) endif ifeq ($(CONFIG_RELR),y) -LDFLAGS_vmlinux += --pack-dyn-relocs=relr +LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags endif # We never want expected sections to be placed heuristically by the
scripts/tools-support-relr.sh +2 -1
@@ -7,7 +7,8 @@ trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1 void *p = &p; END -$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file +$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \ + --use-android-relr-tags -o $tmp_file # Despite printing an error message, GNU nm still exits with exit code 0 if it # sees a relr section. So we need to check that nothing is printed to stderr.
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 175/800 media: dvd_usb: memory leak in cinergyt2_fe_attach
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 9ad1efee086e0e913914fa2b2173efb830bad68c ]
When the driver fails to talk with the hardware with dvb_usb_generic_rw, it will return an error to dvb_usb_adapter_frontend_init. However, the driver forgets to free the resource (e.g., struct cinergyt2_fe_state), which leads to a memory leak.
Fix this by freeing struct cinergyt2_fe_state when dvb_usb_generic_rw fails in cinergyt2_frontend_attach.
backtrace:
[<0000000056e17b1a>] kmalloc include/linux/slab.h:552 [inline] [<0000000056e17b1a>] kzalloc include/linux/slab.h:682 [inline] [<0000000056e17b1a>] cinergyt2_fe_attach+0x21/0x80 drivers/media/usb/dvb-usb/cinergyT2-fe.c:271 [<00000000ae0b1711>] cinergyt2_frontend_attach+0x21/0x70 drivers/media/usb/dvb-usb/cinergyT2-core.c:74 [<00000000d0254861>] dvb_usb_adapter_frontend_init+0x11b/0x1b0 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:290 [<0000000002e08ac6>] dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:84 [inline] [<0000000002e08ac6>] dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:173 [inline] [<0000000002e08ac6>] dvb_usb_device_init.cold+0x4d0/0x6ae drivers/media/usb/dvb-usb/dvb-usb-init.c:287
--- drivers/media/usb/dvb-usb/cinergyT2-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/dvb-usb/cinergyT2-core.c +2 -0
@@ -78,6 +78,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap) ret =dvb_usb_generic_rw (d, st->data,1 , st->data,3 ,0 );if (ret <0 ) { +if (adap->fe_adap[0 ].fe) + adap->fe_adap[0 ].fe->ops.release (adap->fe_adap[0 ].fe);deb_rc ("cinergyt2_power_ctrl() Failed to retrieve sleep state info\n" ); }mutex_unlock (&d->data_mutex);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 176/800 memstick: rtsx_usb_ms: fix UAF
In reply to Greg Kroah-HartmanFrom: Tong Zhang <[email protected]>
[ Upstream commit 42933c8aa14be1caa9eda41f65cde8a3a95d3e39 ]
This patch fixes the following issues:
1. memstick_free_host() will free the host, so the use of ms_dev(host) after it will be a problem. To fix this, move memstick_free_host() after when we are done with ms_dev(host).
2. In rtsx_usb_ms_drv_remove(), pm need to be disabled before we remove and free host otherwise memstick_check will be called and UAF will happen.
[ 11.351173] BUG: KASAN: use-after-free in rtsx_usb_ms_drv_remove+0x94/0x140 [rtsx_usb_ms] [ 11.357077] rtsx_usb_ms_drv_remove+0x94/0x140 [rtsx_usb_ms] [ 11.357376] platform_remove+0x2a/0x50 [ 11.367531] Freed by task 298: [ 11.368537] kfree+0xa4/0x2a0 [ 11.368711] device_release+0x51/0xe0 [ 11.368905] kobject_put+0xa2/0x120 [ 11.369090] rtsx_usb_ms_drv_remove+0x8c/0x140 [rtsx_usb_ms] [ 11.369386] platform_remove+0x2a/0x50
[ 12.038408] BUG: KASAN: use-after-free in __mutex_lock.isra.0+0x3ec/0x7c0 [ 12.045432] mutex_lock+0xc9/0xd0 [ 12.046080] memstick_check+0x6a/0x578 [memstick] [ 12.046509] process_one_work+0x46d/0x750 [ 12.052107] Freed by task 297: [ 12.053115] kfree+0xa4/0x2a0 [ 12.053272] device_release+0x51/0xe0 [ 12.053463] kobject_put+0xa2/0x120 [ 12.053647] rtsx_usb_ms_drv_remove+0xc4/0x140 [rtsx_usb_ms] [ 12.053939] platform_remove+0x2a/0x50
--- drivers/memstick/host/rtsx_usb_ms.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/memstick/host/rtsx_usb_ms.c +4 -6
@@ -799,9 +799,9 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)return 0 ; err_out: -memstick_free_host (msh);pm_runtime_disable (ms_dev (host));pm_runtime_put_noidle (ms_dev (host)); +memstick_free_host (msh);return err; }
@@ -828,9 +828,6 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev) }mutex_unlock (&host->host_mutex); -memstick_remove_host (msh); -memstick_free_host (msh); -/* Balance possible unbalanced usage count * e.g. unconditional module removal */
@@ -838,10 +835,11 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)pm_runtime_put (ms_dev (host));pm_runtime_disable (ms_dev (host)); -platform_set_drvdata (pdev,NULL ); - +memstick_remove_host (msh);dev_dbg (ms_dev (host),": Realtek USB Memstick controller has been removed\n" ); +memstick_free_host (msh); +platform_set_drvdata (pdev,NULL );return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 177/800 mmc: sdhci-sprd: use sdhci_sprd_writew
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 961470820021e6f9d74db4837bd6831a1a30341b ]
The sdhci_sprd_writew() was defined by never used in sdhci_ops:
drivers/mmc/host/sdhci-sprd.c:134:20: warning: unused function 'sdhci_sprd_writew'
--- drivers/mmc/host/sdhci-sprd.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-sprd.c +1 -0
@@ -393,6 +393,7 @@ static void sdhci_sprd_request_done(struct sdhci_host *host,static struct sdhci_ops sdhci_sprd_ops = { .read_l = sdhci_sprd_readl, .write_l = sdhci_sprd_writel, + .write_w = sdhci_sprd_writew, .write_b = sdhci_sprd_writeb, .set_clock = sdhci_sprd_set_clock, .get_max_clock = sdhci_sprd_get_max_clock,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 178/800 mmc: via-sdmmc: add a check against NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 45c8ddd06c4b729c56a6083ab311bfbd9643f4a6 ]
Before referencing 'host->data', the driver needs to check whether it is null pointer, otherwise it will cause a null pointer reference.
This log reveals it:
[ 29.355199] BUG: kernel NULL pointer dereference, address: 0000000000000014 [ 29.357323] #PF: supervisor write access in kernel mode [ 29.357706] #PF: error_code(0x0002) - not-present page [ 29.358088] PGD 0 P4D 0 [ 29.358280] Oops: 0002 [#1] PREEMPT SMP PTI [ 29.358595] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.12.4- g70e7f0549188-dirty #102 [ 29.359164] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 [ 29.359978] RIP: 0010:via_sdc_isr+0x21f/0x410 [ 29.360314] Code: ff ff e8 84 aa d0 fd 66 45 89 7e 28 66 41 f7 c4 00 10 75 56 e8 72 aa d0 fd 66 41 f7 c4 00 c0 74 10 e8 65 aa d0 fd 48 8b 43 18 <c7> 40 14 ac ff ff ff e8 55 aa d0 fd 48 89 df e8 ad fb ff ff e9 77 [ 29.361661] RSP: 0018:ffffc90000118e98 EFLAGS: 00010046 [ 29.362042] RAX: 0000000000000000 RBX: ffff888107d77880 RCX: 0000000000000000 [ 29.362564] RDX: 0000000000000000 RSI: ffffffff835d20bb RDI: 00000000ffffffff [ 29.363085] RBP: ffffc90000118ed8 R08: 0000000000000001 R09: 0000000000000001 [ 29.363604] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000008600 [ 29.364128] R13: ffff888107d779c8 R14: ffffc90009c00200 R15: 0000000000008000 [ 29.364651] FS: 0000000000000000(0000) GS:ffff88817bc80000(0000) knlGS:0000000000000000 [ 29.365235] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.365655] CR2: 0000000000000014 CR3: 0000000005a2e000 CR4: 00000000000006e0 [ 29.366170] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 29.366683] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 29.367197] Call Trace: [ 29.367381] <IRQ> [ 29.367537] __handle_irq_event_percpu+0x53/0x3e0 [ 29.367916] handle_irq_event_percpu+0x35/0x90 [ 29.368247] handle_irq_event+0x39/0x60 [ 29.368632] handle_fasteoi_irq+0xc2/0x1d0 [ 29.368950] __common_interrupt+0x7f/0x150 [ 29.369254] common_interrupt+0xb4/0xd0 [ 29.369547] </IRQ> [ 29.369708] asm_common_interrupt+0x1e/0x40 [ 29.370016] RIP: 0010:native_safe_halt+0x17/0x20 [ 29.370360] Code: 07 0f 00 2d db 80 43 00 f4 5d c3 0f 1f 84 00 00 00 00 00 8b 05 c2 37 e5 01 55 48 89 e5 85 c0 7e 07 0f 00 2d bb 80 43 00 fb f4 <5d> c3 cc cc cc cc cc cc cc 55 48 89 e5 e8 67 53 ff ff 8b 0d f9 91 [ 29.371696] RSP: 0018:ffffc9000008fe90 EFLAGS: 00000246 [ 29.372079] RAX: 0000000000000000 RBX: 0000000000000002 RCX: 0000000000000000 [ 29.372595] RDX: 0000000000000000 RSI: ffffffff854f67a4 RDI: ffffffff85403406 [ 29.373122] RBP: ffffc9000008fe90 R08: 0000000000000001 R09: 0000000000000001 [ 29.373646] R10: 0000000000000000 R11: 0000000000000001 R12: ffffffff86009188 [ 29.374160] R13: 0000000000000000 R14: 0000000000000000 R15: ffff888100258000 [ 29.374690] default_idle+0x9/0x10 [ 29.374944] arch_cpu_idle+0xa/0x10 [ 29.375198] default_idle_call+0x6e/0x250 [ 29.375491] do_idle+0x1f0/0x2d0 [ 29.375740] cpu_startup_entry+0x18/0x20 [ 29.376034] start_secondary+0x11f/0x160 [ 29.376328] secondary_startup_64_no_verify+0xb0/0xbb [ 29.376705] Modules linked in: [ 29.376939] Dumping ftrace buffer: [ 29.377187] (ftrace buffer empty) [ 29.377460] CR2: 0000000000000014 [ 29.377712] ---[ end trace 51a473dffb618c47 ]--- [ 29.378056] RIP: 0010:via_sdc_isr+0x21f/0x410 [ 29.378380] Code: ff ff e8 84 aa d0 fd 66 45 89 7e 28 66 41 f7 c4 00 10 75 56 e8 72 aa d0 fd 66 41 f7 c4 00 c0 74 10 e8 65 aa d0 fd 48 8b 43 18 <c7> 40 14 ac ff ff ff e8 55 aa d0 fd 48 89 df e8 ad fb ff ff e9 77 [ 29.379714] RSP: 0018:ffffc90000118e98 EFLAGS: 00010046 [ 29.380098] RAX: 0000000000000000 RBX: ffff888107d77880 RCX: 0000000000000000 [ 29.380614] RDX: 0000000000000000 RSI: ffffffff835d20bb RDI: 00000000ffffffff [ 29.381134] RBP: ffffc90000118ed8 R08: 0000000000000001 R09: 0000000000000001 [ 29.381653] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000008600 [ 29.382176] R13: ffff888107d779c8 R14: ffffc90009c00200 R15: 0000000000008000 [ 29.382697] FS: 0000000000000000(0000) GS:ffff88817bc80000(0000) knlGS:0000000000000000 [ 29.383277] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.383697] CR2: 0000000000000014 CR3: 0000000005a2e000 CR4: 00000000000006e0 [ 29.384223] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 29.384736] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 29.385260] Kernel panic - not syncing: Fatal exception in interrupt [ 29.385882] Dumping ftrace buffer: [ 29.386135] (ftrace buffer empty) [ 29.386401] Kernel Offset: disabled [ 29.386656] Rebooting in 1 seconds..
--- drivers/mmc/host/via-sdmmc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/via-sdmmc.c +3 -0
@@ -857,6 +857,9 @@ static void via_sdc_data_isr(struct via_crdr_mmc_host *host, u16 intmask) {BUG_ON (intmask ==0 ); +if (!host->data) +return ; +if (intmask &VIA_CRDR_SDSTS_DT ) host->data->error = -ETIMEDOUT ;else if (intmask & (VIA_CRDR_SDSTS_RC |VIA_CRDR_SDSTS_WC ))
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 179/800 mmc: sdhci-of-aspeed: Turn down a phase correction warning
In reply to Greg Kroah-HartmanFrom: Andrew Jeffery <[email protected]>
[ Upstream commit a7ab186f60785850b5af1be183867000485ad491 ]
The card timing and the bus frequency are not changed atomically with respect to calls to the set_clock() callback in the driver. The result is the driver sees a transient state where there's a mismatch between the two and thus the inputs to the phase correction calculation formula are garbage.
Switch from dev_warn() to dev_dbg() to avoid noise in the normal case, though the change does make bad configurations less likely to be noticed.
--- drivers/mmc/host/sdhci-of-aspeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-aspeed.c +1 -1
@@ -150,7 +150,7 @@ static int aspeed_sdhci_phase_to_tap(struct device *dev, unsigned long rate_hz, tap =div_u64 (phase_period_ps, prop_delay_ps);if (tap >ASPEED_SDHCI_NR_TAPS ) { -dev_warn (dev, +dev_dbg (dev,"Requested out of range phase tap %d for %d degrees of phase compensation at %luHz, clamping to tap %d\n" , tap, phase_deg, rate_hz,ASPEED_SDHCI_NR_TAPS ); tap =ASPEED_SDHCI_NR_TAPS ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 180/800 spi: meson-spicc: fix a wrong goto jump for avoiding memory leak.
In reply to Greg Kroah-HartmanFrom: zpershuai <[email protected]>
[ Upstream commit 95730d5eb73170a6d225a9998c478be273598634 ]
In meson_spifc_probe function, when enable the device pclk clock is error, it should use clk_disable_unprepare to release the core clock.
--- drivers/spi/spi-meson-spicc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/spi/spi-meson-spicc.c +4 -2
@@ -725,7 +725,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ret =clk_prepare_enable (spicc->pclk);if (ret) {dev_err (&pdev->dev,"pclk clock enable failed\n" ); - goto out_master; + goto out_core_clk; }device_reset_optional (&pdev->dev);
@@ -764,9 +764,11 @@ static int meson_spicc_probe(struct platform_device *pdev)return 0 ; out_clk: -clk_disable_unprepare (spicc->core);clk_disable_unprepare (spicc->pclk); +out_core_clk: +clk_disable_unprepare (spicc->core); + out_master:spi_master_put (master);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 181/800 spi: meson-spicc: fix memory leak in meson_spicc_probe
In reply to Greg Kroah-HartmanFrom: zpershuai <[email protected]>
[ Upstream commit b2d501c13470409ee7613855b17e5e5ec4111e1c ]
when meson_spicc_clk_init returns failed, it should goto the out_clk label.
--- drivers/spi/spi-meson-spicc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-meson-spicc.c +1 -1
@@ -752,7 +752,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ret =meson_spicc_clk_init (spicc);if (ret) {dev_err (&pdev->dev,"clock registration failed\n" ); - goto out_master; + goto out_clk; } ret =devm_spi_register_master (&pdev->dev, master);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 182/800 regulator: mt6315: Fix checking return value of devm_regmap_init_spmi_ext
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit 70d654ea3de937d7754c107bb8eeb20e30262c89 ]
devm_regmap_init_spmi_ext() returns ERR_PTR() on error.
--- drivers/regulator/mt6315-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/mt6315-regulator.c +2 -2
@@ -223,8 +223,8 @@ static int mt6315_regulator_probe(struct spmi_device *pdev)int i; regmap =devm_regmap_init_spmi_ext (pdev, &mt6315_regmap_config); -if (!regmap) -return -ENODEV ; +if (IS_ERR (regmap)) +return PTR_ERR (regmap); chip =devm_kzalloc (dev,sizeof (struct mt6315_chip ),GFP_KERNEL );if (!chip)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 183/800 crypto: shash - avoid comparing pointers to exported functions under CFI
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 22ca9f4aaf431a9413dcc115dd590123307f274f ]
crypto_shash_alg_has_setkey() is implemented by testing whether the .setkey() member of a struct shash_alg points to the default version, called shash_no_setkey(). As crypto_shash_alg_has_setkey() is a static inline, this requires shash_no_setkey() to be exported to modules.
Unfortunately, when building with CFI, function pointers are routed via CFI stubs which are private to each module (or to the kernel proper) and so this function pointer comparison may fail spuriously.
Let's fix this by turning crypto_shash_alg_has_setkey() into an out of line function.
--- crypto/shash.c | 18 +++++++++++++++--- include/crypto/internal/hash.h | 8 +------- 2 files changed, 16 insertions(+), 10 deletions(-)
crypto/shash.c +15 -3
@@ -20,12 +20,24 @@static const struct crypto_type crypto_shash_type; -int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, -unsigned int keylen) +static int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, +unsigned int keylen) {return -ENOSYS ; } -EXPORT_SYMBOL_GPL (shash_no_setkey); + +/* +* Check whether an shash algorithm has a setkey function. +* +* For CFI compatibility, this must not be an inline function. This is because +* when CFI is enabled, modules won't get the same address for shash_no_setkey +* (if it were exported, which inlining would require) as the core kernel will. +*/ +bool crypto_shash_alg_has_setkey (struct shash_alg *alg) +{ +return alg->setkey != shash_no_setkey; +} +EXPORT_SYMBOL_GPL (crypto_shash_alg_has_setkey);static int shash_setkey_unaligned (struct crypto_shash *tfm,const u8 *key,unsigned int keylen)
include/crypto/internal/hash.h +1 -7
@@ -75,13 +75,7 @@ void crypto_unregister_ahashes(struct ahash_alg *algs, int count);int ahash_register_instance (struct crypto_template *tmpl,struct ahash_instance *inst); -int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, -unsigned int keylen); - -static inline bool crypto_shash_alg_has_setkey (struct shash_alg *alg) -{ -return alg->setkey != shash_no_setkey; -} +bool crypto_shash_alg_has_setkey (struct shash_alg *alg);static inline bool crypto_shash_alg_needs_key (struct shash_alg *alg) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 184/800 media: dvb_net: avoid speculation from net slot
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit abc0226df64dc137b48b911c1fe4319aec5891bb ]
The risk of especulation is actually almost-non-existing here, as there are very few users of TCP/IP using the DVB stack, as, this is mainly used with DVB-S/S2 cards, and only by people that receives TCP/IP from satellite connections, which limits a lot the number of users of such feature(*).
(*) In thesis, DVB-C cards could also benefit from it, but I'm yet to see a hardware that supports it.
Yet, fixing it is trivial.
--- drivers/media/dvb-core/dvb_net.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/media/dvb-core/dvb_net.c +19 -6
@@ -45,6 +45,7 @@#include <linux/module.h> #include <linux/kernel.h> #include <linux/netdevice.h> +#include <linux/nospec.h> #include <linux/etherdevice.h> #include <linux/dvb/net.h> #include <linux/uio.h>
@@ -1462,14 +1463,20 @@ static int dvb_net_do_ioctl(struct file *file,struct net_device *netdev;struct dvb_net_priv *priv_data;struct dvb_net_if *dvbnetif = parg; +int if_num = dvbnetif->if_num; -if (dvbnetif->if_num >=DVB_NET_DEVICES_MAX || - !dvbnet->state[dvbnetif->if_num]) { +if (if_num >=DVB_NET_DEVICES_MAX ) { ret = -EINVAL ; goto ioctl_error; } + if_num =array_index_nospec (if_num,DVB_NET_DEVICES_MAX ); - netdev = dvbnet->device[dvbnetif->if_num]; +if (!dvbnet->state[if_num]) { + ret = -EINVAL ; + goto ioctl_error; + } + + netdev = dvbnet->device[if_num]; priv_data =netdev_priv (netdev); dvbnetif->pid=priv_data->pid;
@@ -1522,14 +1529,20 @@ static int dvb_net_do_ioctl(struct file *file,struct net_device *netdev;struct dvb_net_priv *priv_data;struct __dvb_net_if_old *dvbnetif = parg; +int if_num = dvbnetif->if_num; + +if (if_num >=DVB_NET_DEVICES_MAX ) { + ret = -EINVAL ; + goto ioctl_error; + } + if_num =array_index_nospec (if_num,DVB_NET_DEVICES_MAX ); -if (dvbnetif->if_num >=DVB_NET_DEVICES_MAX || - !dvbnet->state[dvbnetif->if_num]) { +if (!dvbnet->state[if_num]) { ret = -EINVAL ; goto ioctl_error; } - netdev = dvbnet->device[dvbnetif->if_num]; + netdev = dvbnet->device[if_num]; priv_data =netdev_priv (netdev); dvbnetif->pid=priv_data->pid;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 185/800 media: dvbdev: fix error logic at dvb_register_device()
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 1fec2ecc252301110e4149e6183fa70460d29674 ]
As reported by smatch:
drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:510 dvb_register_device() warn: '&dvbdev->list_head' not removed from list drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:530 dvb_register_device() warn: '&dvbdev->list_head' not removed from list drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:545 dvb_register_device() warn: '&dvbdev->list_head' not removed from list
The error logic inside dvb_register_device() doesn't remove devices from the dvb_adapter_list in case of errors.
--- drivers/media/dvb-core/dvbdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/dvb-core/dvbdev.c +3 -0
@@ -506,6 +506,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,break ;if (minor ==MAX_DVB_MINORS ) { +list_del (&dvbdev->list_head);kfree (dvbdevfops);kfree (dvbdev);up_write (&minor_rwsem);
@@ -526,6 +527,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, __func__);dvb_media_device_free (dvbdev); +list_del (&dvbdev->list_head);kfree (dvbdevfops);kfree (dvbdev);mutex_unlock (&dvbdev_register_lock);
@@ -541,6 +543,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,pr_err ("%s: failed to create device dvb%d.%s%d (%ld)\n" , __func__, adap->num, dnames[type], id,PTR_ERR (clsdev));dvb_media_device_free (dvbdev); +list_del (&dvbdev->list_head);kfree (dvbdevfops);kfree (dvbdev);return PTR_ERR (clsdev);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 186/800 media: siano: fix device register error path
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 5368b1ee2939961a16e74972b69088433fc52195 ]
As reported by smatch:
drivers/media/common/siano/smsdvb-main.c:1231 smsdvb_hotplug() warn: '&client->entry' not removed from list
If an error occur at the end of the registration logic, it won't drop the device from the list.
--- drivers/media/common/siano/smsdvb-main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/common/siano/smsdvb-main.c +4 -0
@@ -1212,6 +1212,10 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,return 0 ; media_graph_error: +mutex_lock (&g_smsdvb_clientslock); +list_del (&client->entry); +mutex_unlock (&g_smsdvb_clientslock); +smsdvb_debugfs_release (client); client_error:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 187/800 media: imx-csi: Skip first few frames from a BT.656 source
In reply to Greg Kroah-HartmanFrom: Steve Longerbeam <[email protected]>
[ Upstream commit e198be37e52551bb863d07d2edc535d0932a3c4f ]
Some BT.656 sensors (e.g. ADV718x) transmit frames with unstable BT.656 sync codes after initial power on. This confuses the imx CSI,resulting in vertical and/or horizontal sync issues. Skip the first 20 frames to avoid the unstable sync codes.
[fabio: fixed checkpatch warning and increased the frame skipping to 20]
--- drivers/staging/media/imx/imx-media-csi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-csi.c +13 -1
@@ -750,9 +750,10 @@ static int csi_setup(struct csi_priv *priv)static int csi_start (struct csi_priv *priv) { -struct v4l2_fract *output_fi; +struct v4l2_fract *input_fi, *output_fi;int ret; + input_fi = &priv->frame_interval[CSI_SINK_PAD ]; output_fi = &priv->frame_interval[priv->active_output_pad];/* start upstream */
@@ -761,6 +762,17 @@ static int csi_start(struct csi_priv *priv)if (ret)return ret; +/* Skip first few frames from a BT.656 source */ +if (priv->upstream_ep.bus_type ==V4L2_MBUS_BT656 ) { +u32 delay_usec, bad_frames =20 ; + + delay_usec =DIV_ROUND_UP_ULL ((u64 )USEC_PER_SEC * + input_fi->numerator * bad_frames, + input_fi->denominator); + +usleep_range (delay_usec, delay_usec +1000 ); + } +if (priv->dest ==IPU_CSI_DEST_IDMAC ) { ret =csi_idmac_start (priv);if (ret)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 188/800 hwmon: (max31790) Report correct current pwm duty cycles
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 897f6339893b741a5d68ae8e2475df65946041c2 ]
The MAX31790 has two sets of registers for pwm duty cycles, one to request a duty cycle and one to read the actual current duty cycle. Both do not have to be the same.
When reporting the pwm duty cycle to the user, the actual pwm duty cycle from pwm duty cycle registers needs to be reported. When setting it, the pwm target duty cycle needs to be written. Since we don't know the actual pwm duty cycle after a target pwm duty cycle has been written, set the valid flag to false to indicate that actual pwm duty cycle should be read from the chip instead of using cached values.
--- Documentation/hwmon/max31790.rst | 3 ++- drivers/hwmon/max31790.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-)
Documentation/hwmon/max31790.rst +2 -1
@@ -39,5 +39,6 @@ fan[1-12]_input RO fan tachometer speed in RPM fan[1-12]_fault RO fan experienced fault fan[1-6]_target RW desired fan speed in RPM pwm[1-6]_enable RW regulator mode, 0=disabled, 1=manual mode, 2=rpm mode -pwm[1-6] RW fan target duty cycle (0-255) +pwm[1-6] RW read: current pwm duty cycle, + write: target pwm duty cycle (0-255) ================== === =======================================================
drivers/hwmon/max31790.c +3 -3
@@ -104,7 +104,7 @@ static struct max31790_data *max31790_update_device(struct device *dev) data->tach[NR_CHANNEL + i] = rv; }else { rv =i2c_smbus_read_word_swapped (client, -MAX31790_REG_PWMOUT (i)); +MAX31790_REG_PWM_DUTY_CYCLE (i));if (rv <0 ) goto abort; data->pwm[i] = rv;
@@ -299,10 +299,10 @@ static int max31790_write_pwm(struct device *dev, u32 attr, int channel, err = -EINVAL ;break ; } - data->pwm[channel] = val <<8 ; + data->valid = false; err =i2c_smbus_write_word_swapped (client,MAX31790_REG_PWMOUT (channel), - data->pwm[channel]); + val <<8 );break ;case hwmon_pwm_enable: fan_config = data->fan_config[channel];
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 189/800 hwmon: (max31790) Fix pwmX_enable attributes
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 148c847c9e5a54b99850617bf9c143af9a344f92 ]
pwmX_enable supports three possible values:
0: Fan control disabled. Duty cycle is fixed to 0% 1: Fan control enabled, pwm mode. Duty cycle is determined by
values written into Target Duty Cycle registers.
2: Fan control enabled, rpm mode
Duty cycle is adjusted such that fan speed matches the values in Target Count registers
The current code does not do this; instead, it mixes pwm control configuration with fan speed monitoring configuration. Worse, it reports that pwm control would be disabled (pwmX_enable==0) when it is in fact enabled in pwm mode. Part of the problem may be that the chip sets the "TACH input enable" bit on its own whenever the mode bit is set to RPM mode, but that doesn't mean that "TACH input enable" accurately reflects the pwm mode.
Fix it up and only handle pwm control with the pwmX_enable attributes. In the documentation, clarify that disabling pwm control (pwmX_enable=0) sets the pwm duty cycle to 0%. In the code, explain why TACH_INPUT_EN is set together with RPM_MODE.
While at it, only update the configuration register if the configuration has changed, and only update the cached configuration if updating the chip configuration was successful.
--- Documentation/hwmon/max31790.rst | 2 +- drivers/hwmon/max31790.c | 41 ++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 16 deletions(-)
Documentation/hwmon/max31790.rst +1 -1
@@ -38,7 +38,7 @@ Sysfs entries fan[1-12]_input RO fan tachometer speed in RPM fan[1-12]_fault RO fan experienced fault fan[1-6]_target RW desired fan speed in RPM -pwm[1-6]_enable RW regulator mode, 0=disabled, 1=manual mode, 2=rpm mode +pwm[1-6]_enable RW regulator mode, 0=disabled (duty cycle=0%), 1=manual mode, 2=rpm mode pwm[1-6] RW read: current pwm duty cycle, write: target pwm duty cycle (0-255) ================== === =======================================================
drivers/hwmon/max31790.c +26 -15
67 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 190/800 sched/fair: Take thermal pressure into account while estimating energy
In reply to Greg Kroah-HartmanFrom: Lukasz Luba <[email protected]>
[ Upstream commit 489f16459e0008c7a5c4c5af34bd80898aa82c2d ]
Energy Aware Scheduling (EAS) needs to be able to predict the frequency requests made by the SchedUtil governor to properly estimate energy used in the future. It has to take into account CPUs utilization and forecast Performance Domain (PD) frequency. There is a corner case when the max allowed frequency might be reduced due to thermal. SchedUtil is aware of that reduced frequency, so it should be taken into account also in EAS estimations.
SchedUtil, as a CPUFreq governor, knows the maximum allowed frequency of a CPU, thanks to cpufreq_driver_resolve_freq() and internal clamping to 'policy::max'. SchedUtil is responsible to respect that upper limit while setting the frequency through CPUFreq drivers. This effective frequency is stored internally in 'sugov_policy::next_freq' and EAS has to predict that value.
In the existing code the raw value of arch_scale_cpu_capacity() is used for clamping the returned CPU utilization from effective_cpu_util(). This patch fixes issue with too big single CPU utilization, by introducing clamping to the allowed CPU capacity. The allowed CPU capacity is a CPU capacity reduced by thermal pressure raw value.
Thanks to knowledge about allowed CPU capacity, we don't get too big value for a single CPU utilization, which is then added to the util sum. The util sum is used as a source of information for estimating whole PD energy. To avoid wrong energy estimation in EAS (due to capped frequency), make sure that the calculation of util sum is aware of allowed CPU capacity.
This thermal pressure might be visible in scenarios where the CPUs are not heavily loaded, but some other component (like GPU) drastically reduced available power budget and increased the SoC temperature. Thus, we still use EAS for task placement and CPUs are not over-utilized.
--- kernel/sched/fair.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
kernel/sched/fair.c +8 -3
@@ -6620,8 +6620,11 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)struct cpumask *pd_mask =perf_domain_span (pd);unsigned long cpu_cap =arch_scale_cpu_capacity (cpumask_first (pd_mask));unsigned long max_util =0 , sum_util =0 ; +unsigned long _cpu_cap = cpu_cap;int cpu; + _cpu_cap -=arch_scale_thermal_pressure (cpumask_first (pd_mask)); +/* * The capacity state of CPUs of the current rd can be driven by CPUs * of another rd if they belong to the same pd. So, account for the
@@ -6657,8 +6660,10 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)* is already enough to scale the EM reported power * consumption at the (eventually clamped) cpu_capacity. */ - sum_util +=effective_cpu_util (cpu, util_running, cpu_cap, -ENERGY_UTIL ,NULL ); + cpu_util =effective_cpu_util (cpu, util_running, cpu_cap, +ENERGY_UTIL ,NULL ); + + sum_util +=min (cpu_util, _cpu_cap);/* * Performance domain frequency: utilization clamping
@@ -6669,7 +6674,7 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)*/ cpu_util =effective_cpu_util (cpu, util_freq, cpu_cap,FREQUENCY_UTIL , tsk); - max_util =max (max_util, cpu_util); + max_util =max (max_util,min (cpu_util, _cpu_cap)); }return em_cpu_energy (pd->em_pd, max_util, sum_util);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 191/800 perf/x86: Reset the dirty counter to prevent the leak for an RDPMC task
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
[ Upstream commit 5471eea5d3bf850316f1064a6f57b34c444bce67 ]
The counter value of a perf task may leak to another RDPMC task. For example, a perf stat task as below is running on CPU 0.
perf stat -e 'branches,cycles' -- taskset -c 0 ./workload
In the meantime, an RDPMC task, which is also running on CPU 0, may read the GP counters periodically. (The RDPMC task creates a fixed event, but read four GP counters.)
$./rdpmc_read_all_counters
index 0x0 value 0x8001e5970f99
index 0x1 value 0x8005d750edb6
index 0x2 value 0x0
index 0x3 value 0x0
index 0x0 value 0x8002358e48a5
index 0x1 value 0x8006bd1e3bc9
index 0x2 value 0x0
index 0x3 value 0x0It is a potential security issue. Once the attacker knows what the other thread is counting. The PerfMon counter can be used as a side-channel to attack cryptosystems.
The counter value of the perf stat task leaks to the RDPMC task because perf never clears the counter when it's stopped.
Three methods were considered to address the issue.
- Unconditionally reset the counter in x86_pmu_del(). It can bring extra overhead even when there is no RDPMC task running.
- Only reset the un-assigned dirty counters when the RDPMC task is scheduled in via sched_task(). It fails for the below case.
Thread A Thread B clone(CLONE_THREAD) ---> set_affine(0) set_affine(1) while (!event-enabled) ; event = perf_event_open() mmap(event) ioctl(event, IOC_ENABLE); ---> RDPMC
Counters are still leaked to the thread B.
- Only reset the un-assigned dirty counters before updating the CR4.PCE bit. The method is implemented here.
The dirty counter is a counter, on which the assigned event has been deleted, but the counter is not reset. To track the dirty counters, add a 'dirty' variable in the struct cpu_hw_events.
The security issue can only be found with an RDPMC task. To enable the RDMPC, the CR4.PCE bit has to be updated. Add a perf_clear_dirty_counters() right before updating the CR4.PCE bit to clear the existing dirty counters. Only the current un-assigned dirty counters are reset, because the RDPMC assigned dirty counters will be updated soon.
After applying the patch,
$ ./rdpmc_read_all_counters
index 0x0 value 0x0
index 0x1 value 0x0
index 0x2 value 0x0
index 0x3 value 0x0 index 0x0 value 0x0
index 0x1 value 0x0
index 0x2 value 0x0
index 0x3 value 0x0Performance
The performance of a context switch only be impacted when there are two or more perf users and one of the users must be an RDPMC user. In other cases, there is no performance impact.
The worst-case occurs when there are two users: the RDPMC user only uses one counter; while the other user uses all available counters. When the RDPMC task is scheduled in, all the counters, other than the RDPMC assigned one, have to be reset.
Test results for the worst-case, using a modified lat_ctx as measured on an Ice Lake platform, which has 8 GP and 3 FP counters (ignoring SLOTS).
lat_ctx -s 128K -N 1000 processes 2
Without the patch:
The context switch time is 4.97 us
With the patch:
The context switch time is 5.16 us
There is ~4% performance drop for the context switching time in the worst-case.
--- arch/x86/events/core.c | 28 +++++++++++++++++++++++++++- arch/x86/events/perf_event.h | 1 + arch/x86/include/asm/perf_event.h | 1 + arch/x86/mm/tlb.c | 10 ++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-)
arch/x86/events/core.c +27 -1
@@ -1626,6 +1626,8 @@ static void x86_pmu_del(struct perf_event *event, int flags)if (cpuc->txn_flags &PERF_PMU_TXN_ADD ) goto do_del; +__set_bit (event->hw.idx, cpuc->dirty); +/* * Not a TXN, therefore cleanup properly. */
@@ -2474,6 +2476,31 @@ static int x86_pmu_event_init(struct perf_event *event)return err; } +void perf_clear_dirty_counters (void ) +{ +struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events); +int i; + +/* Don't need to clear the assigned counter. */ +for (i =0 ; i < cpuc->n_events; i++) +__clear_bit (cpuc->assign[i], cpuc->dirty); + +if (bitmap_empty (cpuc->dirty,X86_PMC_IDX_MAX )) +return ; + +for_each_set_bit (i, cpuc->dirty,X86_PMC_IDX_MAX ) { +/* Metrics and fake events don't have corresponding HW counters. */ +if (is_metric_idx (i) || (i ==INTEL_PMC_IDX_FIXED_VLBR )) +continue ; +else if (i >=INTEL_PMC_IDX_FIXED ) +wrmsrl (MSR_ARCH_PERFMON_FIXED_CTR0 + (i -INTEL_PMC_IDX_FIXED ),0 ); +else +wrmsrl (x86_pmu_event_addr (i),0 ); + } + +bitmap_zero (cpuc->dirty,X86_PMC_IDX_MAX ); +} +static void x86_pmu_event_mapped (struct perf_event *event,struct mm_struct *mm) {if (!(event->hw.flags &PERF_X86_EVENT_RDPMC_ALLOWED ))
@@ -2497,7 +2524,6 @@ static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm)static void x86_pmu_event_unmapped (struct perf_event *event,struct mm_struct *mm) { -if (!(event->hw.flags &PERF_X86_EVENT_RDPMC_ALLOWED ))return ;
arch/x86/events/perf_event.h +1 -0
@@ -229,6 +229,7 @@ struct cpu_hw_events {*/ struct perf_event *events[X86_PMC_IDX_MAX ];/* in counter order */ unsigned long active_mask[BITS_TO_LONGS (X86_PMC_IDX_MAX )]; +unsigned long dirty[BITS_TO_LONGS (X86_PMC_IDX_MAX )];int enabled;int n_events;/* the # of events in the below arrays */
arch/x86/include/asm/perf_event.h +1 -0
@@ -478,6 +478,7 @@ struct x86_pmu_lbr {extern void perf_get_x86_pmu_capability (struct x86_pmu_capability *cap);extern void perf_check_microcode (void ); +extern void perf_clear_dirty_counters (void );extern int x86_perf_rdpmc_index (struct perf_event *event);#else static inline void perf_get_x86_pmu_capability (struct x86_pmu_capability *cap)
arch/x86/mm/tlb.c +8 -2
@@ -14,6 +14,7 @@#include <asm/nospec-branch.h> #include <asm/cache.h> #include <asm/apic.h> +#include <asm/perf_event.h> #include "mm_internal.h"
@@ -404,9 +405,14 @@ static inline void cr4_update_pce_mm(struct mm_struct *mm) {if (static_branch_unlikely (&rdpmc_always_available_key) || (!static_branch_unlikely (&rdpmc_never_available_key) && -atomic_read (&mm->context.perf_rdpmc_allowed))) +atomic_read (&mm->context.perf_rdpmc_allowed))) { +/* +* Clear the existing dirty counters to +* prevent the leak for an RDPMC task. +*/ +perf_clear_dirty_counters ();cr4_set_bits_irqsoff (X86_CR4_PCE ); -else + }else cr4_clear_bits_irqsoff (X86_CR4_PCE ); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 192/800 drivers/perf: fix the missed ida_simple_remove() in ddr_perf_probe()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
[ Upstream commit d96b1b8c9f79b6bb234a31c80972a6f422079376 ]
ddr_perf_probe() misses to call ida_simple_remove() in an error path. Jump to cpuhp_state_err to fix it.
--- drivers/perf/fsl_imx8_ddr_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/perf/fsl_imx8_ddr_perf.c +4 -2
@@ -705,8 +705,10 @@ static int ddr_perf_probe(struct platform_device *pdev) name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,DDR_PERF_DEV_NAME "%d" , num); -if (!name) -return -ENOMEM ; +if (!name) { + ret = -ENOMEM ; + goto cpuhp_state_err; + } pmu->devtype_data =of_device_get_match_data (&pdev->dev);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 193/800 KVM: arm64: Restore PMU configuration on first run
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
[ Upstream commit d0c94c49792cf780cbfefe29f81bb8c3b73bc76b ]
Restoring a guest with an active virtual PMU results in no perf counters being instanciated on the host side. Not quite what you'd expect from a restore.
In order to fix this, force a writeback of PMCR_EL0 on the first run of a vcpu (using a new request so that it happens once the vcpu has been loaded). This will in turn create all the host-side counters that were missing.
--- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 4 ++++ arch/arm64/kvm/pmu-emul.c | 3 +++ 3 files changed, 8 insertions(+)
arch/arm64/include/asm/kvm_host.h +1 -0
@@ -46,6 +46,7 @@#define KVM_REQ_VCPU_RESET KVM_ARCH_REQ(2)#define KVM_REQ_RECORD_STEAL KVM_ARCH_REQ(3)#define KVM_REQ_RELOAD_GICv4 KVM_ARCH_REQ(4) +#define KVM_REQ_RELOAD_PMU KVM_ARCH_REQ(5)#define KVM_DIRTY_LOG_MANUAL_CAPS (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | \ KVM_DIRTY_LOG_INITIALLY_SET)
arch/arm64/kvm/arm.c +4 -0
@@ -689,6 +689,10 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu)vgic_v4_load (vcpu);preempt_enable (); } + +if (kvm_check_request (KVM_REQ_RELOAD_PMU , vcpu)) +kvm_pmu_handle_pmcr (vcpu, +__vcpu_sys_reg (vcpu,PMCR_EL0 )); } }
arch/arm64/kvm/pmu-emul.c +3 -0
@@ -850,6 +850,9 @@ int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu)return -EINVAL ; } +/* One-off reload of the PMU on first run */ +kvm_make_request (KVM_REQ_RELOAD_PMU , vcpu); +return 0 ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 194/800 KVM: PPC: Book3S HV: Fix TLB management on SMT8 POWER9 and POWER10 processors
In reply to Greg Kroah-HartmanFrom: Suraj Jitindar Singh <[email protected]>
[ Upstream commit 77bbbc0cf84834ed130838f7ac1988567f4d0288 ]
The POWER9 vCPU TLB management code assumes all threads in a core share a TLB, and that TLBIEL execued by one thread will invalidate TLBs for all threads. This is not the case for SMT8 capable POWER9 and POWER10 (big core) processors, where the TLB is split between groups of threads. This results in TLB multi-hits, random data corruption, etc.
Fix this by introducing cpu_first_tlb_thread_sibling etc., to determine which siblings share TLBs, and use that in the guest TLB flushing code.
[[email protected]: add changelog and comment]
--- arch/powerpc/include/asm/cputhreads.h | 30 +++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 13 ++++++------ arch/powerpc/kvm/book3s_hv_builtin.c | 2 +- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +- 4 files changed, 39 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/cputhreads.h +30 -0
@@ -98,6 +98,36 @@ static inline int cpu_last_thread_sibling(int cpu)return cpu | (threads_per_core -1 ); } +/* +* tlb_thread_siblings are siblings which share a TLB. This is not +* architected, is not something a hypervisor could emulate and a future +* CPU may change behaviour even in compat mode, so this should only be +* used on PowerNV, and only with care. +*/ +static inline int cpu_first_tlb_thread_sibling (int cpu) +{ +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && (threads_per_core ==8 )) +return cpu & ~0x6 ;/* Big Core */ +else +return cpu_first_thread_sibling (cpu); +} + +static inline int cpu_last_tlb_thread_sibling (int cpu) +{ +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && (threads_per_core ==8 )) +return cpu |0x6 ;/* Big Core */ +else +return cpu_last_thread_sibling (cpu); +} + +static inline int cpu_tlb_thread_sibling_step (void ) +{ +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && (threads_per_core ==8 )) +return 2 ;/* Big Core */ +else +return 1 ; +} +static inline u32 get_tensr (void ) {#ifdef CONFIG_BOOKE
arch/powerpc/kvm/book3s_hv.c +7 -6
@@ -2657,7 +2657,7 @@ static void radix_flush_cpu(struct kvm *kvm, int cpu, struct kvm_vcpu *vcpu)cpumask_t *cpu_in_guest;int i; - cpu =cpu_first_thread_sibling (cpu); + cpu =cpu_first_tlb_thread_sibling (cpu);if (nested) {cpumask_set_cpu (cpu, &nested->need_tlb_flush); cpu_in_guest = &nested->cpu_in_guest;
@@ -2671,9 +2671,10 @@ static void radix_flush_cpu(struct kvm *kvm, int cpu, struct kvm_vcpu *vcpu)* the other side is the first smp_mb() in kvmppc_run_core(). */ smp_mb (); -for (i =0 ; i < threads_per_core; ++i) -if (cpumask_test_cpu (cpu + i, cpu_in_guest)) -smp_call_function_single (cpu + i, do_nothing,NULL ,1 ); +for (i = cpu; i <=cpu_last_tlb_thread_sibling (cpu); + i +=cpu_tlb_thread_sibling_step ()) +if (cpumask_test_cpu (i, cpu_in_guest)) +smp_call_function_single (i, do_nothing,NULL ,1 ); }static void kvmppc_prepare_radix_vcpu (struct kvm_vcpu *vcpu,int pcpu)
@@ -2704,8 +2705,8 @@ static void kvmppc_prepare_radix_vcpu(struct kvm_vcpu *vcpu, int pcpu)*/ if (prev_cpu != pcpu) {if (prev_cpu >=0 && -cpu_first_thread_sibling (prev_cpu) != -cpu_first_thread_sibling (pcpu)) +cpu_first_tlb_thread_sibling (prev_cpu) != +cpu_first_tlb_thread_sibling (pcpu))radix_flush_cpu (kvm, prev_cpu, vcpu);if (nested) nested->prev_cpu[vcpu->arch.nested_vcpu_id] = pcpu;
arch/powerpc/kvm/book3s_hv_builtin.c +1 -1
@@ -800,7 +800,7 @@ void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu,* Thus we make all 4 threads use the same bit. */ if (cpu_has_feature (CPU_FTR_ARCH_300 )) - pcpu =cpu_first_thread_sibling (pcpu); + pcpu =cpu_first_tlb_thread_sibling (pcpu);if (nested) need_tlb_flush = &nested->need_tlb_flush;
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
@@ -56,7 +56,7 @@ static int global_invalidates(struct kvm *kvm)* so use the bit for the first thread to represent the core. */ if (cpu_has_feature (CPU_FTR_ARCH_300 )) - cpu =cpu_first_thread_sibling (cpu); + cpu =cpu_first_tlb_thread_sibling (cpu);cpumask_clear_cpu (cpu, &kvm->arch.need_tlb_flush); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 195/800 btrfs: fix error handling in __btrfs_update_delayed_inode
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit bb385bedded3ccbd794559600de4a09448810f4a ]
If we get an error while looking up the inode item we'll simply bail without cleaning up the delayed node. This results in this style of warning happening on commit:
WARNING: CPU: 0 PID: 76403 at fs/btrfs/delayed-inode.c:1365 btrfs_assert_delayed_root_empty+0x5b/0x90 CPU: 0 PID: 76403 Comm: fsstress Tainted: G W 5.13.0-rc1+ #373 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 RIP: 0010:btrfs_assert_delayed_root_empty+0x5b/0x90 RSP: 0018:ffffb8bb815a7e50 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffff95d6d07e1888 RCX: ffff95d6c0fa3000 RDX: 0000000000000002 RSI: 000000000029e91c RDI: ffff95d6c0fc8060 RBP: ffff95d6c0fc8060 R08: 00008d6d701a2c1d R09: 0000000000000000 R10: ffff95d6d1760ea0 R11: 0000000000000001 R12: ffff95d6c15a4d00 R13: ffff95d6c0fa3000 R14: 0000000000000000 R15: ffffb8bb815a7e90 FS: 00007f490e8dbb80(0000) GS:ffff95d73bc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6e75555cb0 CR3: 00000001101ce001 CR4: 0000000000370ef0 Call Trace: btrfs_commit_transaction+0x43c/0xb00 ? finish_wait+0x80/0x80 ? vfs_fsync_range+0x90/0x90 iterate_supers+0x8c/0x100 ksys_sync+0x50/0x90 __do_sys_sync+0xa/0x10 do_syscall_64+0x3d/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae
Because the iref isn't dropped and this leaves an elevated node->count, so any release just re-queues it onto the delayed inodes list. Fix this by going to the out label to handle the proper cleanup of the delayed node.
--- fs/btrfs/delayed-inode.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/btrfs/delayed-inode.c +4 -6
@@ -1009,12 +1009,10 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans, nofs_flag =memalloc_nofs_save (); ret =btrfs_lookup_inode (trans, root, path, &key, mod);memalloc_nofs_restore (nofs_flag); -if (ret >0 ) { -btrfs_release_path (path); -return -ENOENT ; - }else if (ret <0 ) { -return ret; - } +if (ret >0 ) + ret = -ENOENT ; +if (ret <0 ) + goto out; leaf = path->nodes[0 ]; inode_item = btrfs_item_ptr(leaf, path->slots[0],
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 196/800 btrfs: abort transaction if we fail to update the delayed inode
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 04587ad9bef6ce9d510325b4ba9852b6129eebdb ]
If we fail to update the delayed inode we need to abort the transaction, because we could leave an inode with the improper counts or some other such corruption behind.
--- fs/btrfs/delayed-inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/delayed-inode.c +8 -0
@@ -1050,6 +1050,14 @@ err_out:btrfs_delayed_inode_release_metadata (fs_info, node, (ret <0 ));btrfs_release_delayed_inode (node); +/* +* If we fail to update the delayed inode we need to abort the +* transaction, because we could leave the inode with the improper +* counts behind. +*/ +if (ret && ret != -ENOENT ) +btrfs_abort_transaction (trans, ret); +return ret; search:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 197/800 btrfs: always abort the transaction if we abort a trans handle
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 5963ffcaf383134985a5a2d8a4baa582d3999e0a ]
While stress testing our error handling I noticed that sometimes we would still commit the transaction even though we had aborted the transaction.
Currently we track if a trans handle has dirtied any metadata, and if it hasn't we mark the filesystem as having an error (so no new transactions can be started), but we will allow the current transaction to complete as we do not mark the transaction itself as having been aborted.
This sounds good in theory, but we were not properly tracking IO errors in btrfs_finish_ordered_io, and thus committing the transaction with bogus free space data. This isn't necessarily a problem per-se with the free space cache, as the other guards in place would have kept us from accepting the free space cache as valid, but highlights a real world case where we had a bug and could have corrupted the filesystem because of it.
This "skip abort on empty trans handle" is nice in theory, but assumes we have perfect error handling everywhere, which we clearly do not. Also we do not allow further transactions to be started, so all this does is save the last transaction that was happening, which doesn't necessarily gain us anything other than the potential for real corruption.
Remove this particular bit of code, if we decide we need to abort the transaction then abort the current one and keep us from doing real harm to the file system, regardless of whether this specific trans handle dirtied anything or not.
--- fs/btrfs/ctree.c | 5 +---- fs/btrfs/extent-tree.c | 1 - fs/btrfs/super.c | 11 ----------- fs/btrfs/transaction.c | 8 -------- fs/btrfs/transaction.h | 1 - 5 files changed, 1 insertion(+), 25 deletions(-)
fs/btrfs/ctree.c +1 -4
@@ -596,7 +596,6 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans, trans->transid, fs_info->generation);if (!should_cow_block (trans, root, buf)) { - trans->dirty = true; *cow_ret = buf;return 0 ; }
@@ -1788,10 +1787,8 @@ again:* then we don't want to set the path blocking, * so we test it here */ -if (!should_cow_block (trans, root, b)) { - trans->dirty = true; +if (!should_cow_block (trans, root, b)) goto cow_done; - }/* * must have write locks on this node and the
fs/btrfs/extent-tree.c +0 -1
@@ -4784,7 +4784,6 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,set_extent_dirty (&trans->transaction->dirty_pages, buf->start, buf->start + buf->len -1 ,GFP_NOFS ); } - trans->dirty = true;/* this returns a buffer locked for blocking */ return buf; }
fs/btrfs/super.c +0 -11
@@ -299,17 +299,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,struct btrfs_fs_info *fs_info = trans->fs_info;WRITE_ONCE (trans->aborted, errno); -/* Nothing used. The other threads that have joined this -* transaction may be able to continue. */ -if (!trans->dirty &&list_empty (&trans->new_bgs)) { -const char *errstr; - - errstr =btrfs_decode_error (errno); -btrfs_warn (fs_info, -"%s:%d: Aborting unused transaction(%s)." , - function, line, errstr); -return ; - }WRITE_ONCE (trans->transaction->aborted, errno);/* Wake up anybody who may be waiting on this transaction */ wake_up (&fs_info->transaction_wait);
fs/btrfs/transaction.c +0 -8
@@ -2076,14 +2076,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)ASSERT (refcount_read (&trans->use_count) ==1 ); -/* -* Some places just start a transaction to commit it. We need to make -* sure that if this commit fails that the abort code actually marks the -* transaction as failed, so set trans->dirty to make the abort code do -* the right thing. -*/ - trans->dirty = true; -/* Stop the commit early if ->aborted is set */ if (TRANS_ABORTED (cur_trans)) { ret = cur_trans->aborted;
fs/btrfs/transaction.h +0 -1
@@ -143,7 +143,6 @@ struct btrfs_trans_handle {bool allocating_chunk;bool can_flush_pending_bgs;bool reloc_reserved; -bool dirty;bool in_fsync;struct btrfs_root *root;struct btrfs_fs_info *fs_info;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 198/800 btrfs: sysfs: fix format string for some discard stats
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
[ Upstream commit 8c5ec995616f1202ab92e195fd75d6f60d86f85c ]
The type of discard_bitmap_bytes and discard_extent_bytes is u64 so the format should be %llu, though the actual values would hardly ever overflow to negative values.
--- fs/btrfs/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/sysfs.c +2 -2
@@ -429,7 +429,7 @@ static ssize_t btrfs_discard_bitmap_bytes_show(struct kobject *kobj, {struct btrfs_fs_info *fs_info =discard_to_fs_info (kobj); -return scnprintf (buf,PAGE_SIZE ,"%lld\n" , +return scnprintf (buf,PAGE_SIZE ,"%llu\n" , fs_info->discard_ctl.discard_bitmap_bytes); }BTRFS_ATTR (discard, discard_bitmap_bytes, btrfs_discard_bitmap_bytes_show);
@@ -451,7 +451,7 @@ static ssize_t btrfs_discard_extent_bytes_show(struct kobject *kobj, {struct btrfs_fs_info *fs_info =discard_to_fs_info (kobj); -return scnprintf (buf,PAGE_SIZE ,"%lld\n" , +return scnprintf (buf,PAGE_SIZE ,"%llu\n" , fs_info->discard_ctl.discard_extent_bytes); }BTRFS_ATTR (discard, discard_extent_bytes, btrfs_discard_extent_bytes_show);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 199/800 btrfs: dont clear page extent mapped if were not invalidating the full page
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
[ Upstream commit bcd77455d590eaa0422a5e84ae852007cfce574a ]
[BUG]
With current btrfs subpage rw support, the following script can lead to fs hang:
$ mkfs.btrfs -f -s 4k $dev $ mount $dev -o nospace_cache $mnt $ fsstress -w -n 100 -p 1 -s 1608140256 -v -d $mnt
The fs will hang at btrfs_start_ordered_extent().
[CAUSE]
In above test case, btrfs_invalidate() will be called with the following parameters:
offset = 0 length = 53248 page dirty = 1 subpage dirty bitmap = 0x2000
Since @offset is 0, btrfs_invalidate() will try to invalidate the full page, and finally call clear_page_extent_mapped() which will detach subpage structure from the page.
And since the page no longer has subpage structure, the subpage dirty bitmap will be cleared, preventing the dirty range from being written back, thus no way to wake up the ordered extent.
[FIX]
Just follow other filesystems, only to invalidate the page if the range covers the full page.
There are cases like truncate_setsize() which can call btrfs_invalidatepage() with offset == 0 and length != 0 for the last page of an inode.
Although the old code will still try to invalidate the full page, we are still safe to just wait for ordered extent to finish.
So it shouldn't cause extra problems.
--- fs/btrfs/inode.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +13 -1
@@ -8390,7 +8390,19 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,*/ wait_on_page_writeback (page); -if (offset) { +/* +* For subpage case, we have call sites like +* btrfs_punch_hole_lock_range() which passes range not aligned to +* sectorsize. +* If the range doesn't cover the full page, we don't need to and +* shouldn't clear page extent mapped, as page->private can still +* record subpage dirty bits for other part of the range. +* +* For cases that can invalidate the full even the range doesn't +* cover the full page, like invalidating the last page, we're +* still safe to wait for ordered extent to finish. +*/ +if (!(offset ==0 && length ==PAGE_SIZE )) {btrfs_releasepage (page,GFP_NOFS );return ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 200/800 btrfs: disable build on platforms having page size 256K
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit b05fbcc36be1f8597a1febef4892053a0b2f3f60 ]
With a config having PAGE_SIZE set to 256K, BTRFS build fails with the following message
include/linux/compiler_types.h:326:38: error: call to '__compiletime_assert_791' declared with attribute error:
BUILD_BUG_ON failed: (BTRFS_MAX_COMPRESSED % PAGE_SIZE) != 0
BTRFS_MAX_COMPRESSED being 128K, BTRFS cannot support platforms with 256K pages at the time being.
There are two platforms that can select 256K pages:
- hexagon
- powerpc
Disable BTRFS when 256K page size is selected. Supporting this would require changes to the subpage mode that's currently being developed. Given that 256K is many times larger than page sizes commonly used and for what the algorithms and structures have been tuned, it's out of scope and disabling build is a reasonable option.
--- fs/btrfs/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/Kconfig +2 -0
@@ -18,6 +18,8 @@ config BTRFS_FS select RAID6_PQ select XOR_BLOCKS select SRCU + depends on !PPC_256K_PAGES # powerpc + depends on !PAGE_SIZE_256KB # hexagon help Btrfs is a general purpose copy-on-write filesystem with extents,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 201/800 locking/lockdep: Fix the dep path printing for backwards BFS
In reply to Greg Kroah-HartmanFrom: Boqun Feng <[email protected]>
[ Upstream commit 69c7a5fb2482636f525f016c8333fdb9111ecb9d ]
We use the same code to print backwards lock dependency path as the forwards lock dependency path, and this could result into incorrect printing because for a backwards lock_list ->trace is not the call trace where the lock of ->class is acquired.
Fix this by introducing a separate function on printing the backwards dependency path. Also add a few comments about the printing while we are at it.
--- kernel/locking/lockdep.c | 108 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-)
kernel/locking/lockdep.c +106 -2
@@ -2306,7 +2306,56 @@ static void print_lock_class_header(struct lock_class *class, int depth) }/* -* printk the shortest lock dependencies from @start to @end in reverse order: +* Dependency path printing: +* +* After BFS we get a lock dependency path (linked via ->parent of lock_list), +* printing out each lock in the dependency path will help on understanding how +* the deadlock could happen. Here are some details about dependency path +* printing: +* +* 1) A lock_list can be either forwards or backwards for a lock dependency, +* for a lock dependency A -> B, there are two lock_lists: +* +* a) lock_list in the ->locks_after list of A, whose ->class is B and +* ->links_to is A. In this case, we can say the lock_list is +* "A -> B" (forwards case). +* +* b) lock_list in the ->locks_before list of B, whose ->class is A +* and ->links_to is B. In this case, we can say the lock_list is +* "B <- A" (bacwards case). +* +* The ->trace of both a) and b) point to the call trace where B was +* acquired with A held. +* +* 2) A "helper" lock_list is introduced during BFS, this lock_list doesn't +* represent a certain lock dependency, it only provides an initial entry +* for BFS. For example, BFS may introduce a "helper" lock_list whose +* ->class is A, as a result BFS will search all dependencies starting with +* A, e.g. A -> B or A -> C. +* +* The notation of a forwards helper lock_list is like "-> A", which means +* we should search the forwards dependencies starting with "A", e.g A -> B +* or A -> C. +* +* The notation of a bacwards helper lock_list is like "<- B", which means +* we should search the backwards dependencies ending with "B", e.g. +* B <- A or B <- C. +*/ + +/* +* printk the shortest lock dependencies from @root to @leaf in reverse order. +* +* We have a lock dependency path as follow: +* +* @root @leaf +* | | +* V V +* ->parent ->parent +* | lock_list | <--------- | lock_list | ... | lock_list | <--------- | lock_list | +* | -> L1 | | L1 -> L2 | ... |Ln-2 -> Ln-1| | Ln-1 -> Ln| +* +* , so it's natural that we start from @leaf and print every ->class and +* ->trace until we reach the @root. */ static void __used print_shortest_lock_dependencies(struct lock_list *leaf,
@@ -2334,6 +2383,61 @@ print_shortest_lock_dependencies(struct lock_list *leaf, }while (entry && (depth >=0 )); } +/* +* printk the shortest lock dependencies from @leaf to @root. +* +* We have a lock dependency path (from a backwards search) as follow: +* +* @leaf @root +* | | +* V V +* ->parent ->parent +* | lock_list | ---------> | lock_list | ... | lock_list | ---------> | lock_list | +* | L2 <- L1 | | L3 <- L2 | ... | Ln <- Ln-1 | | <- Ln | +* +* , so when we iterate from @leaf to @root, we actually print the lock +* dependency path L1 -> L2 -> .. -> Ln in the non-reverse order. +* +* Another thing to notice here is that ->class of L2 <- L1 is L1, while the +* ->trace of L2 <- L1 is the call trace of L2, in fact we don't have the call +* trace of L1 in the dependency path, which is alright, because most of the +* time we can figure out where L1 is held from the call trace of L2. +*/ +static void __used +print_shortest_lock_dependencies_backwards (struct lock_list *leaf, +struct lock_list *root) +{ +struct lock_list *entry = leaf; +const struct lock_trace *trace =NULL ; +int depth; + +/*compute depth from generated tree by BFS*/ + depth =get_lock_depth (leaf); + +do { +print_lock_class_header (entry->class, depth); +if (trace) { +printk ("%*s ... acquired at:\n" , depth,"" ); +print_lock_trace (trace,2 ); +printk ("\n" ); + } + +/* +* Record the pointer to the trace for the next lock_list +* entry, see the comments for the function. +*/ + trace = entry->trace; + +if (depth ==0 && (entry != root)) { +printk ("lockdep:%s bad path found in chain graph\n" , __func__); +break ; + } + + entry =get_lock_parent (entry); + depth--; + }while (entry && (depth >=0 )); +} + static void print_irq_lock_scenario(struct lock_list *safe_entry, struct lock_list *unsafe_entry,
@@ -2451,7 +2555,7 @@ print_bad_irq_dependency(struct task_struct *curr, prev_root->trace =save_trace ();if (!prev_root->trace)return ; -print_shortest_lock_dependencies (backwards_entry, prev_root); +print_shortest_lock_dependencies_backwards (backwards_entry, prev_root);pr_warn ("\nthe dependencies between the lock to be acquired" );pr_warn (" and %s-irq-unsafe lock:\n" , irqclass);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 202/800 lockding/lockdep: Avoid to find wrong lock dep path in check_irq_usage()
In reply to Greg Kroah-HartmanFrom: Boqun Feng <[email protected]>
[ Upstream commit 7b1f8c6179769af6ffa055e1169610b51d71edd5 ]
In the step #3 of check_irq_usage(), we seach backwards to find a lock whose usage conflicts the usage of @target_entry1 on safe/unsafe. However, we should only keep the irq-unsafe usage of @target_entry1 into consideration, because it could be a case where a lock is hardirq-unsafe but soft-safe, and in check_irq_usage() we find it because its hardirq-unsafe could result into a hardirq-safe-unsafe deadlock, but currently since we don't filter out the other usage bits, so we may find a lock dependency path softirq-unsafe -> softirq-safe, which in fact doesn't cause a deadlock. And this may cause misleading lockdep splats.
Fix this by only keeping LOCKF_ENABLED_IRQ_ALL bits when we try the backwards search.
--- kernel/locking/lockdep.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/locking/lockdep.c +11 -1
@@ -2773,8 +2773,18 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,* Step 3: we found a bad match! Now retrieve a lock from the backward * list whose usage mask matches the exclusive usage mask from the * lock found on the forward list. +* +* Note, we should only keep the LOCKF_ENABLED_IRQ_ALL bits, considering +* the follow case: +* +* When trying to add A -> B to the graph, we find that there is a +* hardirq-safe L, that L -> ... -> A, and another hardirq-unsafe M, +* that B -> ... -> M. However M is **softirq-safe**, if we use exact +* invert bits of M's usage_mask, we will find another lock N that is +* **softirq-unsafe** and N -> ... -> A, however N -> .. -> M will not +* cause a inversion deadlock. */ - backward_mask =original_mask (target_entry1->class->usage_mask); + backward_mask =original_mask (target_entry1->class->usage_mask &LOCKF_ENABLED_IRQ_ALL ); ret =find_usage_backwards (&this, backward_mask, &target_entry);if (bfs_error (ret)) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 203/800 KVM: s390: get rid of register asm usage
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
[ Upstream commit 4fa3b91bdee1b08348c82660668ca0ca34e271ad ]
Using register asm statements has been proven to be very error prone, especially when using code instrumentation where gcc may add function calls, which clobbers register contents in an unexpected way.
Therefore get rid of register asm statements in kvm code, even though there is currently nothing wrong with them. This way we know for sure that this bug class won't be introduced here.
--- arch/s390/kvm/kvm-s390.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/s390/kvm/kvm-s390.c +9 -9
@@ -329,31 +329,31 @@ static void allow_cpu_feat(unsigned long nr)static inline int plo_test_bit (unsigned char nr) { - register unsigned long r0 asm("0") = (unsigned long) nr | 0x100; +unsigned long function = (unsigned long )nr |0x100 ;int cc; asmvolatile ( +" lgr 0,%[function]\n" /* Parameter registers are ignored for "test bit" */ " plo 0,0,0,0(0)\n" " ipm %0\n" " srl %0,28\n" :"=d" (cc) - :"d" (r0) - :"cc" ); + : [function]"d" (function) + :"cc" ,"0" );return cc ==0 ; } static __always_inline void __insn32_query(unsigned int opcode, u8 *query) { - register unsigned long r0 asm("0") = 0; /* query function */ - register unsigned long r1 asm("1") = (unsigned long) query; - asmvolatile ( -/* Parameter regs are ignored */ +" lghi 0,0\n" +" lgr 1,%[query]\n" +/* Parameter registers are ignored */ " .insn rrf,%[opc] << 16,2,4,6,0\n" : - :"d" (r0),"a" (r1), [opc]"i" (opcode) - :"cc" ,"memory" ); + : [query]"d" ((unsigned long )query), [opc]"i" (opcode) + :"cc" ,"memory" ,"0" ,"1" ); }#define INSN_SORTL 0xb938
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 204/800 regulator: mt6358: Fix vdram2 .vsel_mask
In reply to Greg Kroah-HartmanFrom: Hsin-Hsiung Wang <[email protected]>
[ Upstream commit 50c9462edcbf900f3d5097ca3ad60171346124de ]
The valid vsel value are 0 and 12, so the .vsel_mask should be 0xf.
--- drivers/regulator/mt6358-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/mt6358-regulator.c +1 -1
@@ -457,7 +457,7 @@ static struct mt6358_regulator_info mt6358_regulators[] = {MT6358_REG_FIXED ("ldo_vaud28" ,VAUD28 ,MT6358_LDO_VAUD28_CON0 ,0 ,2800000 ),MT6358_LDO ("ldo_vdram2" ,VDRAM2 , vdram2_voltages, vdram2_idx, -MT6358_LDO_VDRAM2_CON0 ,0 ,MT6358_LDO_VDRAM2_ELR0 ,0x10 ,0 ), +MT6358_LDO_VDRAM2_CON0 ,0 ,MT6358_LDO_VDRAM2_ELR0 ,0xf ,0 ),MT6358_LDO ("ldo_vsim1" ,VSIM1 , vsim_voltages, vsim_idx,MT6358_LDO_VSIM1_CON0 ,0 ,MT6358_VSIM1_ANA_CON0 ,0xf00 ,8 ), MT6358_LDO("ldo_vibr", VIBR, vibr_voltages, vibr_idx,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 205/800 regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit a336dc8f683e5be794186b5643cd34cb28dd2c53 ]
Use DIV_ROUND_UP to prevent truncation by integer division issue. This ensures we return enough delay time.
Also fix returning negative value when new_sel < old_sel.
--- drivers/regulator/da9052-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/da9052-regulator.c +2 -1
@@ -250,7 +250,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,case DA9052_ID_BUCK3 :case DA9052_ID_LDO2 :case DA9052_ID_LDO3 : - ret = (new_sel - old_sel) * info->step_uV /6250 ; + ret =DIV_ROUND_UP (abs (new_sel - old_sel) * info->step_uV, +6250 );break ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 206/800 media: Fix Media Controller API config checks
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit 50e7a31d30e8221632675abed3be306382324ca2 ]
Smatch static checker warns that "mdev" can be null:
sound/usb/media.c:287 snd_media_device_create()
warn: 'mdev' can also be NULL
If CONFIG_MEDIA_CONTROLLER is disabled, this file should not be included in the build.
The below conditions in the sound/usb/Makefile are in place to ensure that media.c isn't included in the build.
sound/usb/Makefile:
snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER &&
(MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO)
The following config check in include/media/media-dev-allocator.h is in place to enable the API only when CONFIG_MEDIA_CONTROLLER and CONFIG_USB are enabled.
#if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB)
This check doesn't work as intended when CONFIG_USB=m. When CONFIG_USB=m, CONFIG_USB_MODULE is defined and CONFIG_USB is not. The above config check doesn't catch that CONFIG_USB is defined as a module and disables the API. This results in sound/usb enabling Media Controller specific ALSA driver code, while Media disables the Media Controller API.
Fix the problem requires two changes:
1. Change the check to use IS_ENABLED to detect when CONFIG_USB is enabled as a module or static. Since CONFIG_MEDIA_CONTROLLER is a bool, leave the check unchanged to be consistent with drivers/media/Makefile.
2. Change the drivers/media/mc/Makefile to include mc-dev-allocator.o in mc-objs when CONFIG_USB is enabled.
--- drivers/media/mc/Makefile | 2 +- include/media/media-dev-allocator.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/mc/Makefile +1 -1
@@ -3,7 +3,7 @@ mc-objs := mc-device.o mc-devnode.o mc-entity.o \ mc-request.o -ifeq ($(CONFIG_USB),y) +ifneq ($(CONFIG_USB),) mc-objs += mc-dev-allocator.o endif
include/media/media-dev-allocator.h +1 -1
@@ -19,7 +19,7 @@struct usb_device ; -#if defined(CONFIG_MEDIA_CONTROLLER ) && defined(CONFIG_USB ) +#if defined(CONFIG_MEDIA_CONTROLLER ) &&IS_ENABLED (CONFIG_USB )/** * media_device_usb_allocate() - Allocate and return struct &media device *
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 207/800 seccomp: Support atomic "addfd + send reply"
In reply to Greg Kroah-HartmanFrom: Rodrigo Campos <[email protected]>
[ Upstream commit 0ae71c7720e3ae3aabd2e8a072d27f7bd173d25c ]
Alban Crequy reported a race condition userspace faces when we want to add some fds and make the syscall return them[1] using seccomp notify.
The problem is that currently two different ioctl() calls are needed by the process handling the syscalls (agent) for another userspace process (target): SECCOMP_IOCTL_NOTIF_ADDFD to allocate the fd and SECCOMP_IOCTL_NOTIF_SEND to return that value. Therefore, it is possible for the agent to do the first ioctl to add a file descriptor but the target is interrupted (EINTR) before the agent does the second ioctl() call.
This patch adds a flag to the ADDFD ioctl() so it adds the fd and returns that value atomically to the target program, as suggested by Kees Cook[2]. This is done by simply allowing seccomp_do_user_notification() to add the fd and return it in this case. Therefore, in this case the target wakes up from the wait in seccomp_do_user_notification() either to interrupt the syscall or to add the fd and return it.
This "allocate an fd and return" functionality is useful for syscalls that return a file descriptor only, like connect(2). Other syscalls that return a file descriptor but not as return value (or return more than one fd), like socketpair(), pipe(), recvmsg with SCM_RIGHTs, will not work with this flag.
This effectively combines SECCOMP_IOCTL_NOTIF_ADDFD and SECCOMP_IOCTL_NOTIF_SEND into an atomic opteration. The notification's return value, nor error can be set by the user. Upon successful invocation of the SECCOMP_IOCTL_NOTIF_ADDFD ioctl with the SECCOMP_ADDFD_FLAG_SEND flag, the notifying process's errno will be 0, and the return value will be the file descriptor number that was installed.
[1]: https://lore.kernel.org/lkml/CADZs7q4sw71iNHmV8EOOXhUKJMORPzF7thraxZYddTZsxta-KQ@mail.gmail.com/
[2]: https://lore.kernel.org/lkml/202012011322.26DCBC64F2@keescook/
--- .../userspace-api/seccomp_filter.rst | 12 +++++ include/uapi/linux/seccomp.h | 1 + kernel/seccomp.c | 51 ++++++++++++++++--- 3 files changed, 58 insertions(+), 6 deletions(-)
Documentation/userspace-api/seccomp_filter.rst +12 -0
@@ -259,6 +259,18 @@ and ``ioctl(SECCOMP_IOCTL_NOTIF_SEND)`` a response, indicating what should be returned to userspace. The ``id`` member of ``struct seccomp_notif_resp`` should be the same ``id`` as in ``struct seccomp_notif``. +Userspace can also add file descriptors to the notifying process via +``ioctl(SECCOMP_IOCTL_NOTIF_ADDFD)``. The ``id`` member of +``struct seccomp_notif_addfd`` should be the same ``id`` as in +``struct seccomp_notif``. The ``newfd_flags`` flag may be used to set flags +like O_EXEC on the file descriptor in the notifying process. If the supervisor +wants to inject the file descriptor with a specific number, the +``SECCOMP_ADDFD_FLAG_SETFD`` flag can be used, and set the ``newfd`` member to +the specific number to use. If that file descriptor is already open in the +notifying process it will be replaced. The supervisor can also add an FD, and +respond atomically by using the ``SECCOMP_ADDFD_FLAG_SEND`` flag and the return +value will be the injected file descriptor number. + It is worth noting that ``struct seccomp_data`` contains the values of register arguments to the syscall, but does not contain pointers to memory. The task's memory is accessible to suitably privileged traces via ``ptrace()`` or
include/uapi/linux/seccomp.h +1 -0
@@ -115,6 +115,7 @@ struct seccomp_notif_resp {/* valid flags for seccomp_notif_addfd */ #define SECCOMP_ADDFD_FLAG_SETFD (1UL << 0)/* Specify remote fd */ +#define SECCOMP_ADDFD_FLAG_SEND (1UL << 1)/* Addfd and return it, atomically */ /** * struct seccomp_notif_addfd
kernel/seccomp.c +45 -6
101 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 208/800 HID: do not use down_interruptible() when unbinding devices
In reply to Greg Kroah-HartmanFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit f2145f8dc566c4f3b5a8deb58dcd12bed4e20194 ]
Action of unbinding driver from a device is not cancellable and should not fail, and driver core does not pay attention to the result of "remove" method, therefore using down_interruptible() in hid_device_remove() does not make sense.
--- drivers/hid/hid-core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/hid/hid-core.c +3 -7
@@ -2306,12 +2306,8 @@ static int hid_device_remove(struct device *dev) {struct hid_device *hdev =to_hid_device (dev);struct hid_driver *hdrv; -int ret =0 ; -if (down_interruptible (&hdev->driver_input_lock)) { - ret = -EINTR ; - goto end; - } +down (&hdev->driver_input_lock); hdev->io_started = false; hdrv = hdev->driver;
@@ -2326,8 +2322,8 @@ static int hid_device_remove(struct device *dev)if (!hdev->io_started)up (&hdev->driver_input_lock); -end: -return ret; + +return 0 ; } static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 209/800 EDAC/ti: Add missing MODULE_DEVICE_TABLE
In reply to Greg Kroah-HartmanFrom: Bixuan Cui <[email protected]>
[ Upstream commit 0a37f32ba5272b2d4ec8c8d0f6b212b81b578f7e ]
The module misses MODULE_DEVICE_TABLE() for of_device_id tables and thus never autoloads on ID matches.
Add the missing declaration.
--- drivers/edac/ti_edac.c | 1 + 1 file changed, 1 insertion(+)
drivers/edac/ti_edac.c +1 -0
@@ -197,6 +197,7 @@ static const struct of_device_id ti_edac_of_match[] = { { .compatible = "ti,emif-dra7xx", .data = (void *)EMIF_TYPE_DRA7 }, {}, }; +MODULE_DEVICE_TABLE (of, ti_edac_of_match);static int _emif_get_id (struct device_node *node) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 210/800 ACPI: PM: s2idle: Add missing LPS0 functions for AMD
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
[ Upstream commit f59a905b962c34642e862b5edec35c0eda72d70d ]
These are supposedly not required for AMD platforms, but at least some HP laptops seem to require it to properly turn off the keyboard backlight.
Based on a patch from Marcin Bachry <[email protected]>.
--- drivers/acpi/x86/s2idle.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/acpi/x86/s2idle.c +4 -0
@@ -42,6 +42,8 @@ static const struct acpi_device_id lps0_device_ids[] = {/* AMD */ #define ACPI_LPS0_DSM_UUID_AMD "e3f32452-febc-43ce-9039-932122d37721" +#define ACPI_LPS0_ENTRY_AMD 2 +#define ACPI_LPS0_EXIT_AMD 3#define ACPI_LPS0_SCREEN_OFF_AMD 4#define ACPI_LPS0_SCREEN_ON_AMD 5
@@ -408,6 +410,7 @@ int acpi_s2idle_prepare_late(void)if (acpi_s2idle_vendor_amd ()) {acpi_sleep_run_lps0_dsm (ACPI_LPS0_SCREEN_OFF_AMD ); +acpi_sleep_run_lps0_dsm (ACPI_LPS0_ENTRY_AMD ); }else {acpi_sleep_run_lps0_dsm (ACPI_LPS0_SCREEN_OFF );acpi_sleep_run_lps0_dsm (ACPI_LPS0_ENTRY );
@@ -422,6 +425,7 @@ void acpi_s2idle_restore_early(void)return ;if (acpi_s2idle_vendor_amd ()) { +acpi_sleep_run_lps0_dsm (ACPI_LPS0_EXIT_AMD );acpi_sleep_run_lps0_dsm (ACPI_LPS0_SCREEN_ON_AMD ); }else {acpi_sleep_run_lps0_dsm (ACPI_LPS0_EXIT );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 211/800 ACPI: scan: Rearrange dep_unmet initialization
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit 6d27975851b134be8d2a170437210c9719e524aa ]
The dep_unmet field in struct acpi_device is used to store the number of unresolved _DEP dependencies (that is, operation region dependencies for which there are no drivers present) for the ACPI device object represented by it.
That field is initialized to 1 for all ACPI device objects in acpi_add_single_object(), via acpi_init_device_object(), so as to avoid evaluating _STA prematurely for battery device objects in acpi_scan_init_status(), and it is "fixed up" in acpi_bus_check_add() after the acpi_add_single_object() called by it has returned.
This is not particularly straightforward and causes dep_unmet to remain 1 for device objects without dependencies created by invoking acpi_add_single_object() directly, outside acpi_bus_check_add().
For this reason, rearrange acpi_add_single_object() to initialize dep_unmet completely before calling acpi_scan_init_status(), which requires passing one extra bool argument to it, and update all of its callers accordingly.
--- drivers/acpi/scan.c | 60 +++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 32 deletions(-)
drivers/acpi/scan.c +28 -32
@@ -1671,8 +1671,20 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,device_initialize (&device->dev);dev_set_uevent_suppress (&device->dev, true);acpi_init_coherency (device); -/* Assume there are unmet deps to start with. */ - device->dep_unmet =1 ; +} + +static void acpi_scan_dep_init (struct acpi_device *adev) +{ +struct acpi_dep_data *dep; + +mutex_lock (&acpi_dep_list_lock); + +list_for_each_entry (dep, &acpi_dep_list, node) { +if (dep->consumer == adev->handle) + adev->dep_unmet++; + } + +mutex_unlock (&acpi_dep_list_lock); }void acpi_device_add_finalize (struct acpi_device *device)
@@ -1688,7 +1700,7 @@ static void acpi_scan_init_status(struct acpi_device *adev) }static int acpi_add_single_object (struct acpi_device **child, -acpi_handle handle,int type) +acpi_handle handle,int type,bool dep_init) {struct acpi_device *device;int result;
@@ -1703,8 +1715,12 @@ static int acpi_add_single_object(struct acpi_device **child,* acpi_bus_get_status() and use its quirk handling. Note that * this must be done before the get power-/wakeup_dev-flags calls. */ -if (type ==ACPI_BUS_TYPE_DEVICE || type ==ACPI_BUS_TYPE_PROCESSOR ) +if (type ==ACPI_BUS_TYPE_DEVICE || type ==ACPI_BUS_TYPE_PROCESSOR ) { +if (dep_init) +acpi_scan_dep_init (device); +acpi_scan_init_status (device); + }acpi_bus_get_power_flags (device);acpi_bus_get_wakeup_device_flags (device);
@@ -1886,22 +1902,6 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)return count; } -static void acpi_scan_dep_init (struct acpi_device *adev) -{ -struct acpi_dep_data *dep; - - adev->dep_unmet =0 ; - -mutex_lock (&acpi_dep_list_lock); - -list_for_each_entry (dep, &acpi_dep_list, node) { -if (dep->consumer == adev->handle) - adev->dep_unmet++; - } - -mutex_unlock (&acpi_dep_list_lock); -} -static bool acpi_bus_scan_second_pass; static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
@@ -1949,19 +1949,15 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,return AE_OK ; } -acpi_add_single_object (&device, handle, type); -if (!device) -return AE_CTRL_DEPTH ; - -acpi_scan_init_hotplug (device);/* * If check_dep is true at this point, the device has no dependencies, * or the creation of the device object would have been postponed above. */ -if (check_dep) - device->dep_unmet =0 ; -else -acpi_scan_dep_init (device); +acpi_add_single_object (&device, handle, type, !check_dep); +if (!device) +return AE_CTRL_DEPTH ; + +acpi_scan_init_hotplug (device); out:if (!*adev_p)
@@ -2223,7 +2219,7 @@ int acpi_bus_register_early_device(int type)struct acpi_device *device =NULL ;int result; - result =acpi_add_single_object (&device,NULL , type); + result =acpi_add_single_object (&device,NULL , type, false);if (result)return result;
@@ -2243,7 +2239,7 @@ static int acpi_bus_scan_fixed(void)struct acpi_device *device =NULL ; result =acpi_add_single_object (&device,NULL , -ACPI_BUS_TYPE_POWER_BUTTON ); +ACPI_BUS_TYPE_POWER_BUTTON , false);if (result)return result;
@@ -2259,7 +2255,7 @@ static int acpi_bus_scan_fixed(void)struct acpi_device *device =NULL ; result =acpi_add_single_object (&device,NULL , -ACPI_BUS_TYPE_SLEEP_BUTTON ); +ACPI_BUS_TYPE_SLEEP_BUTTON , false);if (result)return result;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 212/800 ACPI: processor idle: Fix up C-state latency if not ordered
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
[ Upstream commit 65ea8f2c6e230bdf71fed0137cf9e9d1b307db32 ]
Generally, the C-state latency is provided by the _CST method or FADT, but some OEM platforms using AMD Picasso, Renoir, Van Gogh, and Cezanne set the C2 latency greater than C3's which causes the C2 state to be skipped.
That will block the core entering PC6, which prevents S0ix working properly on Linux systems.
In other operating systems, the latency values are not validated and this does not cause problems by skipping states.
To avoid this issue on Linux, detect when latencies are not an arithmetic progression and sort them.
--- drivers/acpi/processor_idle.c | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/acpi/processor_idle.c +40 -0
@@ -16,6 +16,7 @@#include <linux/acpi.h> #include <linux/dmi.h> #include <linux/sched.h> /* need_resched() */ +#include <linux/sort.h> #include <linux/tick.h> #include <linux/cpuidle.h> #include <linux/cpu.h>
@@ -384,10 +385,37 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,return ; } +static int acpi_cst_latency_cmp (const void *a,const void *b) +{ +const struct acpi_processor_cx *x = a, *y = b; + +if (!(x->valid && y->valid)) +return 0 ; +if (x->latency > y->latency) +return 1 ; +if (x->latency < y->latency) +return -1 ; +return 0 ; +} +static void acpi_cst_latency_swap (void *a,void *b,int n) +{ +struct acpi_processor_cx *x = a, *y = b; +u32 tmp; + +if (!(x->valid && y->valid)) +return ; + tmp = x->latency; + x->latency = y->latency; + y->latency = tmp; +} +static int acpi_processor_power_verify (struct acpi_processor *pr) {unsigned int i;unsigned int working =0 ; +unsigned int last_latency =0 ; +unsigned int last_type =0 ; +bool buggy_latency = false; pr->power.timer_broadcast_on_state =INT_MAX ;
@@ -411,12 +439,24 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) }if (!cx->valid)continue ; +if (cx->type >= last_type && cx->latency < last_latency) + buggy_latency = true; + last_latency = cx->latency; + last_type = cx->type;lapic_timer_check_state (i, pr, cx);tsc_check_state (cx->type); working++; } +if (buggy_latency) { +pr_notice ("FW issue: working around C-state latencies out of order\n" ); +sort (&pr->power.states[1 ], max_cstate, +sizeof (struct acpi_processor_cx ), + acpi_cst_latency_cmp, + acpi_cst_latency_swap); + } +lapic_timer_propagate_broadcast (pr);return (working);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 213/800 hv_utils: Fix passing zero to PTR_ERR warning
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit c6a8625fa4c6b0a97860d053271660ccedc3d1b3 ]
Sparse warn this:
drivers/hv/hv_util.c:753 hv_timesync_init() warn:
passing zero to 'PTR_ERR'
Use PTR_ERR_OR_ZERO instead of PTR_ERR to fix this.
--- drivers/hv/hv_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hv/hv_util.c +2 -2
@@ -750,8 +750,8 @@ static int hv_timesync_init(struct hv_util_service *srv)*/ hv_ptp_clock =ptp_clock_register (&ptp_hyperv_info,NULL );if (IS_ERR_OR_NULL (hv_ptp_clock)) { -pr_err ("cannot register PTP clock: %ld\n" , -PTR_ERR (hv_ptp_clock)); +pr_err ("cannot register PTP clock: %d\n" , +PTR_ERR_OR_ZERO (hv_ptp_clock)); hv_ptp_clock =NULL ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 214/800 lib: vsprintf: Fix handling of number field widths in vsscanf
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit 900fdc4573766dd43b847b4f54bd4a1ee2bc7360 ]
The existing code attempted to handle numbers by doing a strto[u]l(), ignoring the field width, and then repeatedly dividing to extract the field out of the full converted value. If the string contains a run of valid digits longer than will fit in a long or long long, this would overflow and no amount of dividing can recover the correct value.
This patch fixes vsscanf() to obey number field widths when parsing the number.
A new _parse_integer_limit() is added that takes a limit for the number of characters to parse. The number field conversion in vsscanf is changed to use this new function.
If a number starts with a radix prefix, the field width must be long enough for at last one digit after the prefix. If not, it will be handled like this:
sscanf("0x4", "%1i", &i): i=0, scanning continues with the 'x' sscanf("0x4", "%2i", &i): i=0, scanning continues with the '4'
This is consistent with the observed behaviour of userland sscanf.
Note that this patch does NOT fix the problem of a single field value overflowing the target type. So for example:
sscanf("123456789abcdef", "%x", &i);Will not produce the correct result because the value obviously overflows INT_MAX. But sscanf will report a successful conversion.
Note that where a very large number is used to mean "unlimited", the value INT_MAX is used for consistency with the behaviour of vsnprintf().
--- lib/kstrtox.c | 13 ++++++-- lib/kstrtox.h | 2 ++ lib/vsprintf.c | 82 +++++++++++++++++++++++++++++--------------------- 3 files changed, 60 insertions(+), 37 deletions(-)
lib/kstrtox.c +10 -3
@@ -39,20 +39,22 @@ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)/* * Convert non-negative integer string representation in explicitly given radix -* to an integer. +* to an integer. A maximum of max_chars characters will be converted. +* * Return number of characters consumed maybe or-ed with overflow bit. * If overflow occurs, result integer (incorrect) is still returned. * * Don't you dare use this function. */ -unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *p) +unsigned int _parse_integer_limit (const char *s,unsigned int base,unsigned long long *p, +size_t max_chars) {unsigned long long res;unsigned int rv; res =0 ; rv =0 ; -while (1 ) { +while (max_chars--) {unsigned int c = *s;unsigned int lc = c |0x20 ;/* don't tolower() this line */ unsigned int val;
@@ -82,6 +84,11 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long longreturn rv; } +unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *p) +{ +return _parse_integer_limit (s, base, p,INT_MAX ); +} +static int _kstrtoull (const char *s,unsigned int base,unsigned long long *res) {unsigned long long _res;
lib/kstrtox.h +2 -0
@@ -4,6 +4,8 @@#define KSTRTOX_OVERFLOW (1U << 31)const char *_parse_integer_fixup_radix (const char *s,unsigned int *base); +unsigned int _parse_integer_limit (const char *s,unsigned int base,unsigned long long *res, +size_t max_chars);unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *res);#endif
lib/vsprintf.c +48 -34
113 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 215/800 Input: goodix - platform/x86: touchscreen_dmi - Move upside down quirks to touchscreen_dmi.c
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 5a6f0dbe621a5c20dc912ac474debf9f11129e03 ]
Move the DMI quirks for upside-down mounted Goodix touchscreens from drivers/input/touchscreen/goodix.c to drivers/platform/x86/touchscreen_dmi.c,
where all the other x86 touchscreen quirks live.
Note the touchscreen_dmi.c code attaches standard touchscreen device-properties to an i2c-client device based on a combination of a DMI match + a device-name match. I've verified that the: Teclast X98 Pro, WinBook TW100 and WinBook TW700 uses an ACPI devicename of "GDIX1001:00" based on acpidumps and/or dmesg output available on the web.
This patch was tested on a Teclast X89 tablet.
--- drivers/input/touchscreen/goodix.c | 52 ------------------------ drivers/platform/x86/touchscreen_dmi.c | 56 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 52 deletions(-)
drivers/input/touchscreen/goodix.c +0 -52
@@ -178,51 +178,6 @@ static const unsigned long goodix_irq_flags[] = { IRQ_TYPE_LEVEL_HIGH, }; -/* -* Those tablets have their coordinates origin at the bottom right -* of the tablet, as if rotated 180 degrees -*/ -static const struct dmi_system_id rotated_screen[] = { -#if defined(CONFIG_DMI) && defined(CONFIG_X86) - { - .ident ="Teclast X89" , - .matches = { -/* tPAD is too generic, also match on bios date */ -DMI_MATCH (DMI_BOARD_VENDOR ,"TECLAST" ), -DMI_MATCH (DMI_BOARD_NAME ,"tPAD" ), -DMI_MATCH (DMI_BIOS_DATE ,"12/19/2014" ), - }, - }, - { - .ident ="Teclast X98 Pro" , - .matches = { -/* -* Only match BIOS date, because the manufacturers -* BIOS does not report the board name at all -* (sometimes)... -*/ -DMI_MATCH (DMI_BOARD_VENDOR ,"TECLAST" ), -DMI_MATCH (DMI_BIOS_DATE ,"10/28/2015" ), - }, - }, - { - .ident ="WinBook TW100" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"WinBook" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"TW100" ) - } - }, - { - .ident ="WinBook TW700" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"WinBook" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"TW700" ) - }, - }, -#endif - {} -}; -static const struct dmi_system_id nine_bytes_report[] = { #if defined(CONFIG_DMI) && defined(CONFIG_X86) {
@@ -1123,13 +1078,6 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) ABS_MT_POSITION_Y, ts->prop.max_y); } -if (dmi_check_system (rotated_screen)) { - ts->prop.invert_x = true; - ts->prop.invert_y = true; -dev_dbg (&ts->client->dev, -"Applying '180 degrees rotated screen' quirk\n" ); - } -if (dmi_check_system (nine_bytes_report)) { ts->contact_size =9 ;
drivers/platform/x86/touchscreen_dmi.c +56 -0
80 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 216/800 platform/x86: touchscreen_dmi: Add an extra entry for the upside down Goodix touchscreen on Teclast X89 tablets
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit a22e3803f2a4d947ff0083a9448a169269ea0f62 ]
Teclast X89 tablets come in 2 versions, with Windows pre-installed and with Android pre-installed. These 2 versions have different DMI strings.
Add a match for the DMI strings used by the Android version BIOS.
Note the Android version BIOS has a bug in the DSDT where no IRQ is provided, so for the touchscreen to work a DSDT override fixing this is necessary as well.
--- drivers/platform/x86/touchscreen_dmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +8 -0
@@ -1347,6 +1347,14 @@ const struct dmi_system_id touchscreen_dmi_table[] = { DMI_MATCH(DMI_BOARD_NAME, "X3 Plus"), }, }, + { +/* Teclast X89 (Android version / BIOS) */ + .driver_data = (void *)&gdix1001_00_upside_down_data, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"WISKY" ), + DMI_MATCH(DMI_BOARD_NAME, "3G062i"), + }, + }, {/* Teclast X89 (Windows version / BIOS) */ .driver_data = (void *)&gdix1001_01_upside_down_data,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 217/800 platform/x86: touchscreen_dmi: Add info for the Goodix GT912 panel of TM800A550L tablets
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit fcd8cf0e3e48f4c66af82c8e799c37cb0cccffe0 ]
The Bay Trail Glavey TM800A550L tablet, which ships with Android installed from the factory, uses a GT912 touchscreen controller which needs to have its firmware uploaded by the OS to work (this is a first for a x86 based device with a Goodix touchscreen controller).
Add a touchscreen_dmi entry for this which specifies the filenames to use for the firmware and config files needed for this.
Note this matches on a GDIX1001 ACPI HID, while the original DSDT uses a HID of GODX0911. For the touchscreen to work on these devices a DSDT override is necessary to fix a missing IRQ and broken GPIO settings in the ACPI-resources for the touchscreen. This override also changes the HID to the standard GDIX1001 id typically used for Goodix touchscreens. The DSDT override is available here:
https://fedorapeople.org/~jwrdegoede/glavey-tm800a550l-dsdt-override/
--- drivers/platform/x86/touchscreen_dmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +21 -0
@@ -316,6 +316,18 @@ static const struct ts_dmi_data gdix1001_01_upside_down_data = { .properties = gdix1001_upside_down_props, }; +static const struct property_entry glavey_tm800a550l_props[] = { +PROPERTY_ENTRY_STRING ("firmware-name" ,"gt912-glavey-tm800a550l.fw" ), +PROPERTY_ENTRY_STRING ("goodix,config-name" ,"gt912-glavey-tm800a550l.cfg" ), +PROPERTY_ENTRY_U32 ("goodix,main-clk" ,54 ), + { } +}; + +static const struct ts_dmi_data glavey_tm800a550l_data = { + .acpi_name ="GDIX1001:00" , + .properties = glavey_tm800a550l_props, +}; +static const struct property_entry gp_electronic_t701_props[] = {PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,960 ),PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,640 ),
@@ -1055,6 +1067,15 @@ const struct dmi_system_id touchscreen_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "eSTAR BEAUTY HD Intel Quad core"), }, }, + { /* Glavey TM800A550L */ + .driver_data = (void *)&glavey_tm800a550l_data, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"AMI Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Aptio CRB" ), +/* Above strings are too generic, also match on BIOS version */ + DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), + }, + }, {/* GP-electronic T701 */ .driver_data = (void *)&gp_electronic_t701_data,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 218/800 ACPI: EC: Make more Asus laptops use ECDT _GPE
In reply to Greg Kroah-HartmanFrom: Chris Chiu <[email protected]>
[ Upstream commit 6306f0431914beaf220634ad36c08234006571d5 ]
More ASUS laptops have the _GPE define in the DSDT table with a different value than the _GPE number in the ECDT.
This is causing media keys not working on ASUS X505BA/BP, X542BA/BP
Add model info to the quirks list.
--- drivers/acpi/ec.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/acpi/ec.c +16 -0
@@ -1846,6 +1846,22 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "GL702VMK"),}, NULL}, { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BA", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X505BA"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BP", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X505BP"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BA", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X542BA"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BP", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X542BP"),}, NULL}, + { ec_honor_ecdt_gpe, "ASUS X550VXK", { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "X550VXK"),}, NULL},
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 219/800 block_dump: remove block_dump feature in mark_inode_dirty()
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
[ Upstream commit 12e0613715e1cf305fffafaf0e89d810d9a85cc0 ]
block_dump is an old debugging interface, one of it's functions is used to print the information about who write which file on disk. If we enable block_dump through /proc/sys/vm/block_dump and turn on debug log level, we can gather information about write process name, target file name and disk from kernel message. This feature is realized in block_dump___mark_inode_dirty(), it print above information into kernel message directly when marking inode dirty, so it is noisy and can easily trigger log storm. At the same time, get the dentry refcount is also not safe, we found it will lead to deadlock on ext4 file system with data=journal mode.
After tracepoints has been introduced into the kernel, we got a tracepoint in __mark_inode_dirty(), which is a better replacement of block_dump___mark_inode_dirty(). The only downside is that it only trace the inode number and not a file name, but it probably doesn't matter because the original printed file name in block_dump is not accurate in some cases, and we can still find it through the inode number and device id. So this patch delete the dirting inode part of block_dump feature.
--- fs/fs-writeback.c | 25 ------------------------- 1 file changed, 25 deletions(-)
fs/fs-writeback.c +0 -25
@@ -2205,28 +2205,6 @@ int dirtytime_interval_handler(struct ctl_table *table, int write,return ret; } -static noinline void block_dump___mark_inode_dirty(struct inode *inode) -{ -if (inode->i_ino ||strcmp (inode->i_sb->s_id,"bdev" )) { -struct dentry *dentry; -const char *name ="?" ; - - dentry =d_find_alias (inode); -if (dentry) { -spin_lock (&dentry->d_lock); - name = (const char *) dentry->d_name.name; - } -printk (KERN_DEBUG -"%s(%d): dirtied inode %lu (%s) on %s\n" , - current->comm,task_pid_nr (current), inode->i_ino, - name, inode->i_sb->s_id); -if (dentry) { -spin_unlock (&dentry->d_lock); -dput (dentry); - } - } -} -/** * __mark_inode_dirty - internal function to mark an inode dirty *
@@ -2296,9 +2274,6 @@ void __mark_inode_dirty(struct inode *inode, int flags) (dirtytime && (inode->i_state & I_DIRTY_INODE))) return; -if (unlikely (block_dump)) -block_dump___mark_inode_dirty (inode); -spin_lock (&inode->i_lock);if (dirtytime && (inode->i_state &I_DIRTY_INODE )) goto out_unlock_inode;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 220/800 blk-mq: grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 2e315dc07df009c3e29d6926871f62a30cfae394 ]
Grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter(), and this way will prevent the request from being re-used when ->fn is running. The approach is same as what we do during handling timeout.
Fix request use-after-free(UAF) related with completion race or queue releasing:
- If one rq is referred before rq->q is frozen, then queue won't be frozen before the request is released during iteration.
- If one rq is referred after rq->q is frozen, refcount_inc_not_zero() will return false, and we won't iterate over this request.
However, still one request UAF not covered: refcount_inc_not_zero() may read one freed request, and it will be handled in next patch.
--- block/blk-mq-tag.c | 44 +++++++++++++++++++++++++++++++++----------- block/blk-mq.c | 14 +++++++++----- block/blk-mq.h | 1 + 3 files changed, 43 insertions(+), 16 deletions(-)
block/blk-mq-tag.c +33 -11
@@ -199,6 +199,16 @@ struct bt_iter_data {bool reserved; }; +static struct request *blk_mq_find_and_get_req (struct blk_mq_tags *tags, +unsigned int bitnr) +{ +struct request *rq = tags->rqs[bitnr]; + +if (!rq || !refcount_inc_not_zero (&rq->ref)) +return NULL ; +return rq; +} +static bool bt_iter (struct sbitmap *bitmap,unsigned int bitnr,void *data) {struct bt_iter_data *iter_data = data;
@@ -206,18 +216,22 @@ static bool bt_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)struct blk_mq_tags *tags = hctx->tags;bool reserved = iter_data->reserved;struct request *rq; +bool ret = true;if (!reserved) bitnr += tags->nr_reserved_tags; - rq = tags->rqs[bitnr]; -/* * We can hit rq == NULL here, because the tagging functions * test and set the bit before assigning ->rqs[]. */ -if (rq && rq->q == hctx->queue && rq->mq_hctx == hctx) -return iter_data->fn (hctx, rq, iter_data->data, reserved); -return true; + rq =blk_mq_find_and_get_req (tags, bitnr); +if (!rq) +return true; + +if (rq->q == hctx->queue && rq->mq_hctx == hctx) + ret = iter_data->fn (hctx, rq, iter_data->data, reserved); +blk_mq_put_rq_ref (rq); +return ret; }/**
@@ -264,6 +278,8 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)struct blk_mq_tags *tags = iter_data->tags;bool reserved = iter_data->flags &BT_TAG_ITER_RESERVED ;struct request *rq; +bool ret = true; +bool iter_static_rqs = !!(iter_data->flags &BT_TAG_ITER_STATIC_RQS );if (!reserved) bitnr += tags->nr_reserved_tags;
@@ -272,16 +288,19 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)* We can hit rq == NULL here, because the tagging functions * test and set the bit before assigning ->rqs[]. */ -if (iter_data->flags &BT_TAG_ITER_STATIC_RQS ) +if (iter_static_rqs) rq = tags->static_rqs[bitnr];else - rq = tags->rqs[bitnr]; + rq =blk_mq_find_and_get_req (tags, bitnr);if (!rq)return true; -if ((iter_data->flags &BT_TAG_ITER_STARTED ) && - !blk_mq_request_started (rq)) -return true; -return iter_data->fn (rq, iter_data->data, reserved); + +if (!(iter_data->flags &BT_TAG_ITER_STARTED ) || +blk_mq_request_started (rq)) + ret = iter_data->fn (rq, iter_data->data, reserved); +if (!iter_static_rqs) +blk_mq_put_rq_ref (rq); +return ret; }/**
@@ -348,6 +367,9 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,* indicates whether or not @rq is a reserved request. Return * true to continue iterating tags, false to stop. * @priv: Will be passed as second argument to @fn. +* +* We grab one request reference before calling @fn and release it after +* @fn returns. */ void blk_mq_tagset_busy_iter (struct blk_mq_tag_set *tagset,busy_tag_iter_fn *fn,void *priv)
block/blk-mq.c +9 -5
@@ -909,6 +909,14 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)return false; } +void blk_mq_put_rq_ref (struct request *rq) +{ +if (is_flush_rq (rq, rq->mq_hctx)) + rq->end_io (rq,0 ); +else if (refcount_dec_and_test (&rq->ref)) +__blk_mq_free_request (rq); +} +static bool blk_mq_check_expired (struct blk_mq_hw_ctx *hctx,struct request *rq,void *priv,bool reserved) {
@@ -942,11 +950,7 @@ static bool blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,if (blk_mq_req_expired (rq, next))blk_mq_rq_timed_out (rq, reserved); -if (is_flush_rq (rq, hctx)) - rq->end_io (rq,0 ); -else if (refcount_dec_and_test (&rq->ref)) -__blk_mq_free_request (rq); - +blk_mq_put_rq_ref (rq);return true; }
block/blk-mq.h +1 -0
@@ -47,6 +47,7 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,void blk_mq_flush_busy_ctxs (struct blk_mq_hw_ctx *hctx,struct list_head *list);struct request *blk_mq_dequeue_from_ctx (struct blk_mq_hw_ctx *hctx,struct blk_mq_ctx *start); +void blk_mq_put_rq_ref (struct request *rq);/* * Internal helpers for allocating/freeing the request map
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 221/800 blk-mq: clear stale request in tags->rq[] before freeing one request pool
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit bd63141d585bef14f4caf111f6d0e27fe2300ec6 ]
refcount_inc_not_zero() in bt_tags_iter() still may read one freed request.
Fix the issue by the following approach:
1) hold a per-tags spinlock when reading ->rqs[tag] and calling refcount_inc_not_zero in bt_tags_iter()
2) clearing stale request referred via ->rqs[tag] before freeing request pool, the per-tags spinlock is held for clearing stale ->rq[tag]
So after we cleared stale requests, bt_tags_iter() won't observe freed request any more, also the clearing will wait for pending request reference.
The idea of clearing ->rqs[] is borrowed from John Garry's previous patch and one recent David's patch.
--- block/blk-mq-tag.c | 9 +++++++-- block/blk-mq-tag.h | 6 ++++++ block/blk-mq.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 7 deletions(-)
block/blk-mq-tag.c +7 -2
@@ -202,10 +202,14 @@ struct bt_iter_data {static struct request *blk_mq_find_and_get_req (struct blk_mq_tags *tags,unsigned int bitnr) { -struct request *rq = tags->rqs[bitnr]; +struct request *rq; +unsigned long flags; +spin_lock_irqsave (&tags->lock, flags); + rq = tags->rqs[bitnr];if (!rq || !refcount_inc_not_zero (&rq->ref)) -return NULL ; + rq =NULL ; +spin_unlock_irqrestore (&tags->lock, flags);return rq; }
@@ -538,6 +542,7 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags, tags->nr_tags = total_tags; tags->nr_reserved_tags = reserved_tags; +spin_lock_init (&tags->lock);if (blk_mq_is_sbitmap_shared (flags))return tags;
block/blk-mq-tag.h +6 -0
@@ -20,6 +20,12 @@ struct blk_mq_tags {struct request **rqs;struct request **static_rqs;struct list_head page_list; + +/* +* used to clear request reference in rqs[] before freeing one +* request pool +*/ +spinlock_t lock; }; extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags,
block/blk-mq.c +41 -5
64 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 222/800 fs: dlm: fix srcu read lock usage
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit b38bc9c2b3171f4411d80015ecb876bc6f9bcd26 ]
This patch holds the srcu connection read lock in cases where we lookup the connections and accessing it. We don't hold the srcu lock in workers function where the scheduled worker is part of the connection itself. The connection should not be freed if any worker is scheduled or pending.
--- fs/dlm/lowcomms.c | 75 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 23 deletions(-)
fs/dlm/lowcomms.c +52 -23
@@ -113,6 +113,7 @@ struct writequeue_entry {int len;int end;int users; +int idx;/* get()/commit() idx exchange */ struct connection *con; };
@@ -163,21 +164,14 @@ static inline int nodeid_hash(int nodeid)return nodeid & (CONN_HASH_SIZE -1 ); } -static struct connection *__find_con (int nodeid) +static struct connection *__find_con (int nodeid,int r) { -int r, idx;struct connection *con; - r =nodeid_hash (nodeid); - - idx =srcu_read_lock (&connections_srcu);hlist_for_each_entry_rcu (con, &connection_hash[r], list) { -if (con->nodeid == nodeid) { -srcu_read_unlock (&connections_srcu, idx); +if (con->nodeid == nodeid)return con; - } } -srcu_read_unlock (&connections_srcu, idx);return NULL ; }
@@ -216,7 +210,8 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)struct connection *con, *tmp;int r, ret; - con =__find_con (nodeid); + r =nodeid_hash (nodeid); + con =__find_con (nodeid, r);if (con || !alloc)return con;
@@ -230,8 +225,6 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)return NULL ; } - r =nodeid_hash (nodeid); -spin_lock (&connections_lock);/* Because multiple workqueues/threads calls this function it can * race on multiple cpu's. Instead of locking hot path __find_con()
@@ -239,7 +232,7 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)* under protection of connections_lock. If this is the case we * abort our connection creation and return the existing connection. */ - tmp =__find_con (nodeid); + tmp =__find_con (nodeid, r);if (tmp) {spin_unlock (&connections_lock);kfree (con->rx_buf);
@@ -256,15 +249,13 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)/* Loop round all connections */ static void foreach_conn (void (*conn_func)(struct connection *c)) { -int i, idx; +int i;struct connection *con; - idx =srcu_read_lock (&connections_srcu);for (i =0 ; i <CONN_HASH_SIZE ; i++) {hlist_for_each_entry_rcu (con, &connection_hash[i], list)conn_func (con); } -srcu_read_unlock (&connections_srcu, idx); }static struct dlm_node_addr *find_node_addr (int nodeid)
@@ -518,14 +509,21 @@ static void lowcomms_state_change(struct sock *sk)int dlm_lowcomms_connect_node (int nodeid) {struct connection *con; +int idx;if (nodeid ==dlm_our_nodeid ())return 0 ; + idx =srcu_read_lock (&connections_srcu); con =nodeid2con (nodeid,GFP_NOFS ); -if (!con) +if (!con) { +srcu_read_unlock (&connections_srcu, idx);return -ENOMEM ; + } +lowcomms_connect_sock (con); +srcu_read_unlock (&connections_srcu, idx); +return 0 ; }
@@ -864,7 +862,7 @@ static int accept_from_sock(struct listen_connection *con)int result;struct sockaddr_storage peeraddr;struct socket *newsock; -int len; +int len, idx;int nodeid;struct connection *newcon;struct connection *addcon;
@@ -907,8 +905,10 @@ static int accept_from_sock(struct listen_connection *con)* the same time and the connections cross on the wire. * In this case we store the incoming one in "othercon" */ + idx =srcu_read_lock (&connections_srcu); newcon =nodeid2con (nodeid,GFP_NOFS );if (!newcon) { +srcu_read_unlock (&connections_srcu, idx); result = -ENOMEM ; goto accept_err; }
@@ -924,6 +924,7 @@ static int accept_from_sock(struct listen_connection *con)if (!othercon) {log_print ("failed to allocate incoming socket" );mutex_unlock (&newcon->sock_mutex); +srcu_read_unlock (&connections_srcu, idx); result = -ENOMEM ; goto accept_err; }
@@ -932,6 +933,7 @@ static int accept_from_sock(struct listen_connection *con)if (result <0 ) {kfree (othercon);mutex_unlock (&newcon->sock_mutex); +srcu_read_unlock (&connections_srcu, idx); goto accept_err; }
@@ -966,6 +968,8 @@ static int accept_from_sock(struct listen_connection *con)if (!test_and_set_bit (CF_READ_PENDING , &addcon->flags))queue_work (recv_workqueue, &addcon->rwork); +srcu_read_unlock (&connections_srcu, idx); +return 0 ; accept_err:
@@ -1403,7 +1407,9 @@ static struct writequeue_entry *new_wq_entry(struct connection *con, int len,void *dlm_lowcomms_get_buffer (int nodeid,int len,gfp_t allocation,char **ppc) { +struct writequeue_entry *e;struct connection *con; +int idx;if (len >DEFAULT_BUFFER_SIZE || len <sizeof (struct dlm_header )) {
@@ -1413,11 +1419,23 @@ void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)return NULL ; } + idx =srcu_read_lock (&connections_srcu); con =nodeid2con (nodeid, allocation); -if (!con) +if (!con) { +srcu_read_unlock (&connections_srcu, idx);return NULL ; + } + + e =new_wq_entry (con, len, allocation, ppc); +if (!e) { +srcu_read_unlock (&connections_srcu, idx); +return NULL ; + } + +/* we assume if successful commit must called */ + e->idx = idx; -return new_wq_entry (con, len, allocation, ppc); +return e; }void dlm_lowcomms_commit_buffer (void *mh)
@@ -1435,10 +1453,12 @@ void dlm_lowcomms_commit_buffer(void *mh)spin_unlock (&con->writequeue_lock);queue_work (send_workqueue, &con->swork); +srcu_read_unlock (&connections_srcu, e->idx);return ; out:spin_unlock (&con->writequeue_lock); +srcu_read_unlock (&connections_srcu, e->idx);return ; }
@@ -1532,8 +1552,10 @@ int dlm_lowcomms_close(int nodeid) {struct connection *con;struct dlm_node_addr *na; +int idx;log_print ("closing connection to node %d" , nodeid); + idx =srcu_read_lock (&connections_srcu); con =nodeid2con (nodeid,0 );if (con) {set_bit (CF_CLOSE , &con->flags);
@@ -1542,6 +1564,7 @@ int dlm_lowcomms_close(int nodeid)if (con->othercon)clean_one_writequeue (con->othercon); } +srcu_read_unlock (&connections_srcu, idx);spin_lock (&dlm_node_addrs_spin); na =find_node_addr (nodeid);
@@ -1621,6 +1644,8 @@ static void shutdown_conn(struct connection *con)void dlm_lowcomms_shutdown (void ) { +int idx; +/* Set all the flags to prevent any * socket activity. */
@@ -1633,7 +1658,9 @@ void dlm_lowcomms_shutdown(void)dlm_close_sock (&listen_con.sock); + idx =srcu_read_lock (&connections_srcu);foreach_conn (shutdown_conn); +srcu_read_unlock (&connections_srcu, idx); }static void _stop_conn (struct connection *con,bool and_other)
@@ -1682,7 +1709,7 @@ static void free_conn(struct connection *con)static void work_flush (void ) { -int ok, idx; +int ok;int i;struct connection *con;
@@ -1693,7 +1720,6 @@ static void work_flush(void)flush_workqueue (recv_workqueue);if (send_workqueue)flush_workqueue (send_workqueue); - idx =srcu_read_lock (&connections_srcu);for (i =0 ; i <CONN_HASH_SIZE && ok; i++) {hlist_for_each_entry_rcu (con, &connection_hash[i], list) {
@@ -1707,14 +1733,17 @@ static void work_flush(void) } } } -srcu_read_unlock (&connections_srcu, idx); }while (!ok); }void dlm_lowcomms_stop (void ) { +int idx; + + idx =srcu_read_lock (&connections_srcu);work_flush ();foreach_conn (free_conn); +srcu_read_unlock (&connections_srcu, idx);work_stop ();deinit_local (); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 223/800 fs: dlm: reconnect if socket error report occurs
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit ba868d9deaab2bb1c09e50650127823925154802 ]
This patch will change the reconnect handling that if an error occurs if a socket error callback is occurred. This will also handle reconnects in a non blocking connecting case which is currently missing. If error ECONNREFUSED is reported we delay the reconnect by one second.
--- fs/dlm/lowcomms.c | 60 ++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 21 deletions(-)
fs/dlm/lowcomms.c +39 -21
@@ -79,6 +79,8 @@ struct connection {#define CF_CLOSING 8#define CF_SHUTDOWN 9#define CF_CONNECTED 10 +#define CF_RECONNECT 11 +#define CF_DELAY_CONNECT 12struct list_head writequeue;/* List of outgoing writequeue_entries */ spinlock_t writequeue_lock;void (*connect_action) (struct connection *);/* What to do to connect */
@@ -87,6 +89,7 @@ struct connection {#define MAX_CONNECT_RETRIES 3struct hlist_node list;struct connection *othercon; +struct connection *sendcon;struct work_struct rwork;/* Receive workqueue */ struct work_struct swork;/* Send workqueue */ wait_queue_head_t shutdown_wait;/* wait for graceful shutdown */
@@ -585,6 +588,22 @@ static void lowcomms_error_report(struct sock *sk) dlm_config.ci_tcp_port, sk->sk_err, sk->sk_err_soft); } + +/* below sendcon only handling */ +if (test_bit (CF_IS_OTHERCON , &con->flags)) + con = con->sendcon; + +switch (sk->sk_err) { +case ECONNREFUSED : +set_bit (CF_DELAY_CONNECT , &con->flags); +break ; +default : +break ; + } + +if (!test_and_set_bit (CF_RECONNECT , &con->flags)) +queue_work (send_workqueue, &con->swork); + out:read_unlock_bh (&sk->sk_callback_lock);if (orig_report)
@@ -702,6 +721,8 @@ static void close_connection(struct connection *con, bool and_other, con->rx_leftover =0 ; con->retries =0 ;clear_bit (CF_CONNECTED , &con->flags); +clear_bit (CF_DELAY_CONNECT , &con->flags); +clear_bit (CF_RECONNECT , &con->flags);mutex_unlock (&con->sock_mutex);clear_bit (CF_CLOSING , &con->flags); }
@@ -840,18 +861,15 @@ out_resched: out_close:mutex_unlock (&con->sock_mutex); -if (ret != -EAGAIN ) { -/* Reconnect when there is something to send */ +if (ret ==0 ) {close_connection (con, false, true, false); -if (ret ==0 ) { -log_print ("connection %p got EOF from %d" , - con, con->nodeid); -/* handling for tcp shutdown */ -clear_bit (CF_SHUTDOWN , &con->flags); -wake_up (&con->shutdown_wait); -/* signal to breaking receive worker */ - ret =-1 ; - } +log_print ("connection %p got EOF from %d" , + con, con->nodeid); +/* handling for tcp shutdown */ +clear_bit (CF_SHUTDOWN , &con->flags); +wake_up (&con->shutdown_wait); +/* signal to breaking receive worker */ + ret =-1 ; }return ret; }
@@ -939,6 +957,7 @@ static int accept_from_sock(struct listen_connection *con)lockdep_set_subclass (&othercon->sock_mutex,1 ); newcon->othercon = othercon; + othercon->sendcon = newcon; }else {/* close other sock con if we have something new */ close_connection (othercon, false, true, false);
@@ -1503,7 +1522,7 @@ static void send_to_sock(struct connection *con)cond_resched (); goto out; }else if (ret <0 ) - goto send_error; + goto out; }/* Don't starve people filling buffers */
@@ -1520,14 +1539,6 @@ out:mutex_unlock (&con->sock_mutex);return ; -send_error: -mutex_unlock (&con->sock_mutex); -close_connection (con, false, false, true); -/* Requeue the send work. When the work daemon runs again, it will try -a new connection, then call this function again. */ -queue_work (send_workqueue, &con->swork); -return ; - out_connect:mutex_unlock (&con->sock_mutex);queue_work (send_workqueue, &con->swork);
@@ -1602,8 +1613,15 @@ static void process_send_sockets(struct work_struct *work) struct connection *con = container_of(work, struct connection, swork);clear_bit (CF_WRITE_PENDING , &con->flags); -if (con->sock ==NULL )/* not mutex protected so check it inside too */ + +if (test_and_clear_bit (CF_RECONNECT , &con->flags)) +close_connection (con, false, false, true); + +if (con->sock ==NULL ) {/* not mutex protected so check it inside too */ +if (test_and_clear_bit (CF_DELAY_CONNECT , &con->flags)) +msleep (1000 ); con->connect_action (con); + }if (!list_empty (&con->writequeue))send_to_sock (con); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 224/800 fs: dlm: cancel work sync othercon
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit c6aa00e3d20c2767ba3f57b64eb862572b9744b3 ]
These rx tx flags arguments are for signaling close_connection() from which worker they are called. Obviously the receive worker cannot cancel itself and vice versa for swork. For the othercon the receive worker should only be used, however to avoid deadlocks we should pass the same flags as the original close_connection() was called.
--- fs/dlm/lowcomms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dlm/lowcomms.c +1 -1
@@ -715,7 +715,7 @@ static void close_connection(struct connection *con, bool and_other,if (con->othercon && and_other) {/* Will only re-enter once. */ -close_connection (con->othercon, false, true, true); +close_connection (con->othercon, false, tx, rx); } con->rx_leftover =0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 225/800 fs: dlm: fix connection tcp EOF handling
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit 8aa31cbf20ad168c35dd83476629402aacbf5a44 ]
This patch fixes the EOF handling for TCP that if and EOF is received we will close the socket next time the writequeue runs empty. This is a half-closed socket functionality which doesn't exists in SCTP. The midcomms layer will do a half closed socket functionality on DLM side to solve this problem for the SCTP case. However there is still the last ack flying around but other reset functionality will take care of it if it got lost.
--- fs/dlm/lowcomms.c | 48 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-)
fs/dlm/lowcomms.c +43 -5
@@ -81,10 +81,13 @@ struct connection {#define CF_CONNECTED 10#define CF_RECONNECT 11#define CF_DELAY_CONNECT 12 +#define CF_EOF 13struct list_head writequeue;/* List of outgoing writequeue_entries */ spinlock_t writequeue_lock; +atomic_t writequeue_cnt;void (*connect_action) (struct connection *);/* What to do to connect */ void (*shutdown_action)(struct connection *con);/* What to do to shutdown */ +bool (*eof_condition)(struct connection *con);/* What to do to eof check */ int retries;#define MAX_CONNECT_RETRIES 3struct hlist_node list;
@@ -179,6 +182,11 @@ static struct connection *__find_con(int nodeid, int r)return NULL ; } +static bool tcp_eof_condition (struct connection *con) +{ +return atomic_read (&con->writequeue_cnt); +} +static int dlm_con_init (struct connection *con,int nodeid) { con->rx_buflen = dlm_config.ci_buffer_size;
@@ -190,6 +198,7 @@ static int dlm_con_init(struct connection *con, int nodeid)mutex_init (&con->sock_mutex);INIT_LIST_HEAD (&con->writequeue);spin_lock_init (&con->writequeue_lock); +atomic_set (&con->writequeue_cnt,0 );INIT_WORK (&con->swork, process_send_sockets);INIT_WORK (&con->rwork, process_recv_sockets);init_waitqueue_head (&con->shutdown_wait);
@@ -197,6 +206,7 @@ static int dlm_con_init(struct connection *con, int nodeid)if (dlm_config.ci_protocol ==0 ) { con->connect_action = tcp_connect_to_sock; con->shutdown_action = dlm_tcp_shutdown; + con->eof_condition = tcp_eof_condition; }else { con->connect_action = sctp_connect_to_sock; }
@@ -723,6 +733,7 @@ static void close_connection(struct connection *con, bool and_other,clear_bit (CF_CONNECTED , &con->flags);clear_bit (CF_DELAY_CONNECT , &con->flags);clear_bit (CF_RECONNECT , &con->flags); +clear_bit (CF_EOF , &con->flags);mutex_unlock (&con->sock_mutex);clear_bit (CF_CLOSING , &con->flags); }
@@ -860,16 +871,26 @@ out_resched:return -EAGAIN ; out_close: -mutex_unlock (&con->sock_mutex);if (ret ==0 ) { -close_connection (con, false, true, false);log_print ("connection %p got EOF from %d" , con, con->nodeid); -/* handling for tcp shutdown */ -clear_bit (CF_SHUTDOWN , &con->flags); -wake_up (&con->shutdown_wait); + +if (con->eof_condition && con->eof_condition (con)) { +set_bit (CF_EOF , &con->flags); +mutex_unlock (&con->sock_mutex); + }else { +mutex_unlock (&con->sock_mutex); +close_connection (con, false, true, false); + +/* handling for tcp shutdown */ +clear_bit (CF_SHUTDOWN , &con->flags); +wake_up (&con->shutdown_wait); + } +/* signal to breaking receive worker */ ret =-1 ; + }else { +mutex_unlock (&con->sock_mutex); }return ret; }
@@ -1020,6 +1041,7 @@ static void writequeue_entry_complete(struct writequeue_entry *e, int completed)if (e->len ==0 && e->users ==0 ) {list_del (&e->list); +atomic_dec (&e->con->writequeue_cnt);free_entry (e); } }
@@ -1416,6 +1438,7 @@ static struct writequeue_entry *new_wq_entry(struct connection *con, int len, *ppc =page_address (e->page); e->end += len; +atomic_inc (&con->writequeue_cnt);spin_lock (&con->writequeue_lock);list_add_tail (&e->list, &con->writequeue);
@@ -1535,6 +1558,21 @@ static void send_to_sock(struct connection *con)writequeue_entry_complete (e, ret); }spin_unlock (&con->writequeue_lock); + +/* close if we got EOF */ +if (test_and_clear_bit (CF_EOF , &con->flags)) { +mutex_unlock (&con->sock_mutex); +close_connection (con, false, false, true); + +/* handling for tcp shutdown */ +clear_bit (CF_SHUTDOWN , &con->flags); +wake_up (&con->shutdown_wait); + }else { +mutex_unlock (&con->sock_mutex); + } + +return ; + out:mutex_unlock (&con->sock_mutex);return ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 226/800 random32: Fix implicit truncation warning in prandom_seed_state()
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit d327ea15a305024ef0085252fa3657bbb1ce25f5 ]
sparse generates the following warning:
include/linux/prandom.h:114:45: sparse: sparse: cast truncates bits from constant value
This is because the 64-bit seed value is manipulated and then placed in a u32, causing an implicit cast and truncation. A forced cast to u32 doesn't prevent this warning, which is reasonable because a typecast doesn't prove that truncation was expected.
Logical-AND the value with 0xffffffff to make explicit that truncation to 32-bit is intended.
--- include/linux/prandom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/prandom.h +1 -1
@@ -111,7 +111,7 @@ static inline u32 __seed(u32 x, u32 m)*/ static inline void prandom_seed_state (struct rnd_state *state,u64 seed) { -u32 i = (seed >>32 ) ^ (seed <<10 ) ^ seed; +u32 i = ((seed >>32 ) ^ (seed <<10 ) ^ seed) &0xffffffffUL ; state->s1 =__seed (i,2U ); state->s2 =__seed (i,8U );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 227/800 open: dont silently ignore unknown O-flags in openat2()
In reply to Greg Kroah-HartmanFrom: Christian Brauner <[email protected]>
[ Upstream commit cfe80306a0dd6d363934913e47c3f30d71b721e5 ]
The new openat2() syscall verifies that no unknown O-flag values are set and returns an error to userspace if they are while the older open syscalls like open() and openat() simply ignore unknown flag values:
#define O_FLAG_CURRENTLY_INVALID (1 << 31)
struct open_how how = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID,
.resolve = 0,
};
/* fails */
fd = openat2(-EBADF, "/dev/null", &how, sizeof(how));
/* succeeds */
fd = openat(-EBADF, "/dev/null", O_RDONLY | O_FLAG_CURRENTLY_INVALID);However, openat2() silently truncates the upper 32 bits meaning:
#define O_FLAG_CURRENTLY_INVALID_LOWER32 (1 << 31)
#define O_FLAG_CURRENTLY_INVALID_UPPER32 (1 << 40)
struct open_how how_lowe32 = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID_LOWER32,
};
struct open_how how_upper32 = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID_UPPER32,
};
/* fails */
fd = openat2(-EBADF, "/dev/null", &how_lower32, sizeof(how_lower32));
/* succeeds */
fd = openat2(-EBADF, "/dev/null", &how_upper32, sizeof(how_upper32));Fix this by preventing the immediate truncation in build_open_flags().
There's a snafu here though stripping FMODE_* directly from flags would cause the upper 32 bits to be truncated as well due to integer promotion rules since FMODE_* is unsigned int, O_* are signed ints (yuck).
In addition, struct open_flags currently defines flags to be 32 bit which is reasonable. If we simply were to bump it to 64 bit we would need to change a lot of code preemptively which doesn't seem worth it. So simply add a compile-time check verifying that all currently known O_* flags are within the 32 bit range and fail to build if they aren't anymore.
This change shouldn't regress old open syscalls since they silently truncate any unknown values anyway. It is a tiny semantic change for openat2() but it is very unlikely people pass ing > 32 bit unknown flags and the syscall is relatively new too.
--- fs/open.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/open.c +11 -3
@@ -1002,12 +1002,20 @@ inline struct open_how build_open_how(int flags, umode_t mode)inline int build_open_flags (const struct open_how *how,struct open_flags *op) { -int flags = how->flags; +u64 flags = how->flags; +u64 strip =FMODE_NONOTIFY |O_CLOEXEC ;int lookup_flags =0 ;int acc_mode =ACC_MODE (flags); -/* Must never be set by userspace */ - flags &= ~(FMODE_NONOTIFY |O_CLOEXEC ); +BUILD_BUG_ON_MSG (upper_32_bits (VALID_OPEN_FLAGS ), +"struct open_flags doesn't yet handle flags > 32 bits" ); + +/* +* Strip flags that either shouldn't be set by userspace like +* FMODE_NONOTIFY or that aren't relevant in determining struct +* open_flags like O_CLOEXEC. +*/ + flags &= ~strip;/* * Older syscalls implicitly clear all of the invalid flags or argument
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 228/800 drivers: hv: Fix missing error code in vmbus_connect()
In reply to Greg Kroah-HartmanFrom: Jiapeng Chong <[email protected]>
[ Upstream commit 9de6655cc5a6a1febc514465c87c24a0e96d8dba ]
Eliminate the follow smatch warning:
drivers/hv/connection.c:236 vmbus_connect() warn: missing error code 'ret'.
--- drivers/hv/connection.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hv/connection.c +3 -1
@@ -232,8 +232,10 @@ int vmbus_connect(void)*/ for (i =0 ; ; i++) { -if (i ==ARRAY_SIZE (vmbus_versions)) +if (i ==ARRAY_SIZE (vmbus_versions)) { + ret = -EDOM ; goto cleanup; + } version = vmbus_versions[i];if (version > max_version)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 229/800 fs: dlm: fix lowcomms_start error case
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit fcef0e6c27ce109d2c617aa12f0bfd9f7ff47d38 ]
This patch fixes the error path handling in lowcomms_start(). We need to cleanup some static allocated data structure and cleanup possible workqueue if these have started.
--- fs/dlm/lowcomms.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
fs/dlm/lowcomms.c +12 -3
@@ -1666,10 +1666,15 @@ static void process_send_sockets(struct work_struct *work)static void work_stop (void ) { -if (recv_workqueue) +if (recv_workqueue) {destroy_workqueue (recv_workqueue); -if (send_workqueue) + recv_workqueue =NULL ; + } + +if (send_workqueue) {destroy_workqueue (send_workqueue); + send_workqueue =NULL ; + } }static int work_start (void )
@@ -1686,6 +1691,7 @@ static int work_start(void)if (!send_workqueue) {log_print ("can't start dlm_send" );destroy_workqueue (recv_workqueue); + recv_workqueue =NULL ;return -ENOMEM ; }
@@ -1823,7 +1829,7 @@ int dlm_lowcomms_start(void) error =work_start ();if (error) - goto fail; + goto fail_local; dlm_allow_conn =1 ;
@@ -1840,6 +1846,9 @@ int dlm_lowcomms_start(void) fail_unlisten: dlm_allow_conn =0 ;dlm_close_sock (&listen_con.sock); +work_stop (); +fail_local: +deinit_local (); fail:return error; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 230/800 fs: dlm: fix memory leak when fenced
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
[ Upstream commit 700ab1c363c7b54c9ea3222379b33fc00ab02f7b ]
I got some kmemleak report when a node was fenced. The user space tool dlm_controld will therefore run some rmdir() in dlm configfs which was triggering some memleaks. This patch stores the sps and cms attributes which stores some handling for subdirectories of the configfs cluster entry and free them if they get released as the parent directory gets freed.
unreferenced object 0xffff88810d9e3e00 (size 192):
comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 73 70 61 63 65 73 00 00 ........spaces..
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000db8b640b>] make_cluster+0x5d/0x360
[<000000006a571db4>] configfs_mkdir+0x274/0x730
[<00000000b094501c>] vfs_mkdir+0x27e/0x340
[<0000000058b0adaf>] do_mkdirat+0xff/0x1b0
[<00000000d1ffd156>] do_syscall_64+0x40/0x80
[<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae
unreferenced object 0xffff88810d9e3a00 (size 192):
comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 63 6f 6d 6d 73 00 00 00 ........comms...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000a7ef6ad2>] make_cluster+0x82/0x360
[<000000006a571db4>] configfs_mkdir+0x274/0x730
[<00000000b094501c>] vfs_mkdir+0x27e/0x340
[<0000000058b0adaf>] do_mkdirat+0xff/0x1b0
[<00000000d1ffd156>] do_syscall_64+0x40/0x80
[<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae--- fs/dlm/config.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/dlm/config.c +9 -0
@@ -79,6 +79,9 @@ struct dlm_cluster {unsigned int cl_new_rsb_count;unsigned int cl_recover_callbacks;char cl_cluster_name[DLM_LOCKSPACE_LEN ]; + +struct dlm_spaces *sps; +struct dlm_comms *cms; };static struct dlm_cluster *config_item_to_cluster (struct config_item *i)
@@ -409,6 +412,9 @@ static struct config_group *make_cluster(struct config_group *g,if (!cl || !sps || !cms) goto fail; + cl->sps = sps; + cl->cms = cms; +config_group_init_type_name (&cl->group, name, &cluster_type);config_group_init_type_name (&sps->ss_group,"spaces" , &spaces_type);config_group_init_type_name (&cms->cs_group,"comms" , &comms_type);
@@ -458,6 +464,9 @@ static void drop_cluster(struct config_group *g, struct config_item *i)static void release_cluster (struct config_item *i) {struct dlm_cluster *cl =config_item_to_cluster (i); + +kfree (cl->sps); +kfree (cl->cms);kfree (cl); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 231/800 ACPICA: Fix memory leak caused by _CID repair function
In reply to Greg Kroah-HartmanFrom: Erik Kaneda <[email protected]>
[ Upstream commit c27bac0314131b11bccd735f7e8415ac6444b667 ]
ACPICA commit 180cb53963aa876c782a6f52cc155d951b26051a
According to the ACPI spec, _CID returns a package containing hardware ID's. Each element of an ASL package contains a reference count from the parent package as well as the element itself.
Name (TEST, Package() {
"String object" // this package element has a reference count of 2
})
A memory leak was caused in the _CID repair function because it did not decrement the reference count created by the package. Fix the memory leak by calling acpi_ut_remove_reference on _CID package elements that represent a hardware ID (_HID).
--- drivers/acpi/acpica/nsrepair2.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/acpica/nsrepair2.c +7 -0
@@ -379,6 +379,13 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info, (*element_ptr)->common.reference_count = original_ref_count; + +/* +* The original_element holds a reference from the package object +* that represents _HID. Since a new element was created by _HID, +* remove the reference from the _CID package. +*/ +acpi_ut_remove_reference (original_element); } element_ptr++;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 232/800 ACPI: bus: Call kobject_put() in acpi_init() error path
In reply to Greg Kroah-HartmanFrom: Hanjun Guo <[email protected]>
[ Upstream commit 4ac7a817f1992103d4e68e9837304f860b5e7300 ]
Although the system will not be in a good condition or it will not boot if acpi_bus_init() fails, it is still necessary to put the kobject in the error path before returning to avoid leaking memory.
--- drivers/acpi/bus.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/bus.c +1 -0
@@ -1321,6 +1321,7 @@ static int __init acpi_init(void) result =acpi_bus_init ();if (result) { +kobject_put (acpi_kobj);disable_acpi ();return result; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 233/800 ACPI: resources: Add checks for ACPI IRQ override
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
[ Upstream commit 0ec4e55e9f571f08970ed115ec0addc691eda613 ]
The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
Through debugging, we found this log in the dmesg:
ACPI: IRQ 1 override to edge, high
pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active)
And we checked the IRQ definition in the DSDT, it is:
IRQ (Level, ActiveLow, Exclusive, )
{1}
So the BIOS defines the keyboard IRQ to Level_Low, but the Linux kernel override it to Edge_High. If the Linux kernel is modified to skip the IRQ override, the keyboard will work normally.
Quoted 1 line
From the existing comment in
acpi_dev_get_irqresource(), the override
function only needs to be called when IRQ() or IRQNoFlags() is used to populate the resource descriptor, and according to Section 6.4.2.1 of ACPI 6.4 [1], if IRQ() is empty or IRQNoFlags() is used, the IRQ is High true, edge sensitive and non-shareable. ACPICA also assumes that to be the case (see acpi_rs_set_irq[] in rsirq.c).
In accordance with the above, check 3 additional conditions (EdgeSensitive, ActiveHigh and Exclusive) when deciding whether or not to treat an ACPI_RESOURCE_TYPE_IRQ resource as "legacy", in which case the IRQ override is applicable to it.
--- drivers/acpi/resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/acpi/resource.c +8 -1
@@ -423,6 +423,13 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, } } +static bool irq_is_legacy (struct acpi_resource_irq *irq) +{ +return irq->triggering ==ACPI_EDGE_SENSITIVE && + irq->polarity ==ACPI_ACTIVE_HIGH && + irq->shareable ==ACPI_EXCLUSIVE ; +} +/** * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. * @ares: Input ACPI resource object.
@@ -461,7 +468,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, }acpi_dev_get_irqresource (res, irq->interrupts[index], irq->triggering, irq->polarity, - irq->shareable, true); + irq->shareable,irq_is_legacy (irq));break ;case ACPI_RESOURCE_TYPE_EXTENDED_IRQ : ext_irq = &ares->data.extended_irq;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 234/800 HID: hid-input: add Surface Go battery quirk
In reply to Greg Kroah-HartmanFrom: Zoltan Tamas Vajda <[email protected]>
[ Upstream commit b5539722eb832441f309642fe5102cc3536f92b8 ]
The Elantech touchscreen/digitizer in the Surface Go mistakenly reports having a battery. This results in a low battery message every time you try to use the pen.
This patch adds a quirk to ignore the non-existent battery and gets rid of the false low battery messages.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-input.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -396,6 +396,7 @@#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755#define I2C_DEVICE_ID_HP_SPECTRE_X360_15 0x2817#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 +#define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A#define USB_VENDOR_ID_ELECOM 0x056e#define USB_DEVICE_ID_ELECOM_BM084 0x0061
drivers/hid/hid-input.c +2 -0
@@ -326,6 +326,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, {HID_I2C_DEVICE (USB_VENDOR_ID_ELAN ,I2C_DEVICE_ID_HP_SPECTRE_X360_15 ), HID_BATTERY_QUIRK_IGNORE }, + { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN), + HID_BATTERY_QUIRK_IGNORE }, {} };
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 235/800 HID: sony: fix freeze when inserting ghlive ps3/wii dongles
In reply to Greg Kroah-HartmanFrom: Pascal Giard <[email protected]>
[ Upstream commit fb1a79a6b6e1223ddb18f12aa35e36f832da2290 ]
This commit fixes a freeze on insertion of a Guitar Hero Live PS3/WiiU USB dongle. Indeed, with the current implementation, inserting one of those USB dongles will lead to a hard freeze. I apologize for not catching this earlier, it didn't occur on my old laptop.
While the issue was isolated to memory alloc/free, I could not figure out why it causes a freeze. So this patch fixes this issue by simplifying memory allocation and usage.
We remind that for the dongle to work properly, a control URB needs to be sent periodically. We used to alloc/free the URB each time this URB needed to be sent.
With this patch, the memory for the URB is allocated on the probe, reused for as long as the dongle is plugged in, and freed once the dongle is unplugged.
--- drivers/hid/hid-sony.c | 98 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 49 deletions(-)
drivers/hid/hid-sony.c +49 -49
@@ -597,9 +597,8 @@ struct sony_sc {/* DS4 calibration data */ struct ds4_calibration_data ds4_calib_data[6 ];/* GH Live */ +struct urb *ghl_urb;struct timer_list ghl_poke_timer; -struct usb_ctrlrequest *ghl_cr; -u8 *ghl_databuf; };static void sony_set_leds (struct sony_sc *sc);
@@ -625,66 +624,54 @@ static inline void sony_schedule_work(struct sony_sc *sc,static void ghl_magic_poke_cb (struct urb *urb) { -if (urb) { -/* Free sc->ghl_cr and sc->ghl_databuf allocated in -* ghl_magic_poke() -*/ -kfree (urb->setup_packet); -kfree (urb->transfer_buffer); - } +struct sony_sc *sc = urb->context; + +if (urb->status <0 ) +hid_err (sc->hdev,"URB transfer failed : %d" , urb->status); + +mod_timer (&sc->ghl_poke_timer, jiffies +GHL_GUITAR_POKE_INTERVAL *HZ ); }static void ghl_magic_poke (struct timer_list *t) { +int ret;struct sony_sc *sc =from_timer (sc, t, ghl_poke_timer); -int ret; + ret =usb_submit_urb (sc->ghl_urb,GFP_ATOMIC ); +if (ret <0 ) +hid_err (sc->hdev,"usb_submit_urb failed: %d" , ret); +} + +static int ghl_init_urb (struct sony_sc *sc,struct usb_device *usbdev) +{ +struct usb_ctrlrequest *cr; +u16 poke_size; +u8 *databuf;unsigned int pipe; -struct urb *urb; -struct usb_device *usbdev =to_usb_device (sc->hdev->dev.parent->parent); -const u16 poke_size = -ARRAY_SIZE (ghl_ps3wiiu_magic_data); + poke_size =ARRAY_SIZE (ghl_ps3wiiu_magic_data); pipe =usb_sndctrlpipe (usbdev,0 ); -if (!sc->ghl_cr) { - sc->ghl_cr =kzalloc (sizeof (*sc->ghl_cr),GFP_ATOMIC ); -if (!sc->ghl_cr) - goto resched; - } - -if (!sc->ghl_databuf) { - sc->ghl_databuf =kzalloc (poke_size,GFP_ATOMIC ); -if (!sc->ghl_databuf) - goto resched; - } + cr =devm_kzalloc (&sc->hdev->dev,sizeof (*cr),GFP_ATOMIC ); +if (cr ==NULL ) +return -ENOMEM ; - urb =usb_alloc_urb (0 ,GFP_ATOMIC ); -if (!urb) - goto resched; + databuf =devm_kzalloc (&sc->hdev->dev, poke_size,GFP_ATOMIC ); +if (databuf ==NULL ) +return -ENOMEM ; - sc->ghl_cr->bRequestType = + cr->bRequestType =USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_OUT ; - sc->ghl_cr->bRequest =USB_REQ_SET_CONFIGURATION ; - sc->ghl_cr->wValue =cpu_to_le16 (ghl_ps3wiiu_magic_value); - sc->ghl_cr->wIndex =0 ; - sc->ghl_cr->wLength =cpu_to_le16 (poke_size); -memcpy (sc->ghl_databuf, ghl_ps3wiiu_magic_data, poke_size); - + cr->bRequest =USB_REQ_SET_CONFIGURATION ; + cr->wValue =cpu_to_le16 (ghl_ps3wiiu_magic_value); + cr->wIndex =0 ; + cr->wLength =cpu_to_le16 (poke_size); +memcpy (databuf, ghl_ps3wiiu_magic_data, poke_size);usb_fill_control_urb ( - urb, usbdev, pipe, - (unsigned char *) sc->ghl_cr, sc->ghl_databuf, - poke_size, ghl_magic_poke_cb,NULL ); - ret =usb_submit_urb (urb,GFP_ATOMIC ); -if (ret <0 ) { -kfree (sc->ghl_databuf); -kfree (sc->ghl_cr); - } -usb_free_urb (urb); - -resched: -/* Reschedule for next time */ -mod_timer (&sc->ghl_poke_timer, jiffies +GHL_GUITAR_POKE_INTERVAL *HZ ); + sc->ghl_urb, usbdev, pipe, + (unsigned char *) cr, databuf, poke_size, + ghl_magic_poke_cb, sc); +return 0 ; } static int guitar_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -2981,6 +2968,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)int ret;unsigned long quirks = id->driver_data;struct sony_sc *sc; +struct usb_device *usbdev;unsigned int connect_mask =HID_CONNECT_DEFAULT ;if (!strcmp (hdev->name,"FutureMax Dance Mat" ))
@@ -3000,6 +2988,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) sc->quirks = quirks;hid_set_drvdata (hdev, sc); sc->hdev = hdev; + usbdev =to_usb_device (sc->hdev->dev.parent->parent); ret =hid_parse (hdev);if (ret) {
@@ -3042,6 +3031,15 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) }if (sc->quirks &GHL_GUITAR_PS3WIIU ) { + sc->ghl_urb =usb_alloc_urb (0 ,GFP_ATOMIC ); +if (!sc->ghl_urb) +return -ENOMEM ; + ret =ghl_init_urb (sc, usbdev); +if (ret) { +hid_err (hdev,"error preparing URB\n" ); +return ret; + } +timer_setup (&sc->ghl_poke_timer, ghl_magic_poke,0 );mod_timer (&sc->ghl_poke_timer, jiffies +GHL_GUITAR_POKE_INTERVAL *HZ );
@@ -3054,8 +3052,10 @@ static void sony_remove(struct hid_device *hdev) {struct sony_sc *sc =hid_get_drvdata (hdev); -if (sc->quirks &GHL_GUITAR_PS3WIIU ) +if (sc->quirks &GHL_GUITAR_PS3WIIU ) {del_timer_sync (&sc->ghl_poke_timer); +usb_free_urb (sc->ghl_urb); + }hid_hw_close (hdev);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 236/800 block: fix race between adding/removing rq qos and normal IO
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 2cafe29a8d03f02a3d16193bdaae2f3e82a423f9 ]
Yi reported several kernel panics on:
[16687.001777] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 ... [16687.163549] pc : __rq_qos_track+0x38/0x60
or
[ 997.690455] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 ... [ 997.850347] pc : __rq_qos_done+0x2c/0x50
Turns out it is caused by race between adding rq qos(wbt) and normal IO because rq_qos_add can be run when IO is being submitted, fix this issue by freezing queue before adding/deleting rq qos to queue.
rq_qos_exit() needn't to freeze queue because it is called after queue has been frozen.
iolatency calls rq_qos_add() during allocating queue, so freezing won't add delay because queue usage refcount works at atomic mode at that time.
iocost calls rq_qos_add() when writing cgroup attribute file, that is fine to freeze queue at that time since we usually freeze queue when storing to queue sysfs attribute, meantime iocost only exists on the root cgroup.
wbt_init calls it in blk_register_queue() and queue sysfs attribute store(queue_wb_lat_store() when write it 1st time in case of !BLK_WBT_MQ), the following patch will speedup the queue freezing in wbt_init.
--- block/blk-rq-qos.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
block/blk-rq-qos.h +24 -0
@@ -7,6 +7,7 @@#include <linux/blk_types.h> #include <linux/atomic.h> #include <linux/wait.h> +#include <linux/blk-mq.h> #include "blk-mq-debugfs.h"
@@ -99,8 +100,21 @@ static inline void rq_wait_init(struct rq_wait *rq_wait)static inline void rq_qos_add (struct request_queue *q,struct rq_qos *rqos) { +/* +* No IO can be in-flight when adding rqos, so freeze queue, which +* is fine since we only support rq_qos for blk-mq queue. +* +* Reuse ->queue_lock for protecting against other concurrent +* rq_qos adding/deleting +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock); rqos->next = q->rq_qos; q->rq_qos = rqos; +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q);if (rqos->ops->debugfs_attrs)blk_mq_debugfs_register_rqos (rqos);
@@ -110,12 +124,22 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos) {struct rq_qos **cur; +/* +* See comment in rq_qos_add() about freezing queue & using +* ->queue_lock. +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock);for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) {if (*cur == rqos) { *cur = rqos->next;break ; } } +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q);blk_mq_debugfs_unregister_rqos (rqos); }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 237/800 platform/x86: asus-nb-wmi: Revert "Drop duplicate DMI quirk structures"
In reply to Greg Kroah-HartmanFrom: Luke D. Jones <[email protected]>
[ Upstream commit 98c0c85b1040db24f0d04d3e1d315c6c7b05cc07 ]
This is a preparation revert for reverting the "add support for ASUS ROG Zephyrus G14 and G15" change. This reverts
commit 67186653c903 ("platform/x86: asus-nb-wmi: Drop duplicate DMI quirk structures")
--- drivers/platform/x86/asus-nb-wmi.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-nb-wmi.c +14 -9
@@ -110,7 +110,12 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_vendor_backlight = { +static struct quirk_entry quirk_asus_ga401i = { + .wmi_backlight_power = true, + .wmi_backlight_set_devstate = true, +}; + +static struct quirk_entry quirk_asus_ga502i = { .wmi_backlight_power = true, .wmi_backlight_set_devstate = true, };
@@ -432,7 +437,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -441,7 +446,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -450,7 +455,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -459,7 +464,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -468,7 +473,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -477,7 +482,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
@@ -486,7 +491,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
@@ -495,7 +500,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 238/800 platform/x86: asus-nb-wmi: Revert "add support for ASUS ROG Zephyrus G14 and G15"
In reply to Greg Kroah-HartmanFrom: Luke D. Jones <[email protected]>
[ Upstream commit 28117f3a5c3c8375a3304af76357d5bf9cf30f0b ]
The quirks added to asus-nb-wmi for the ASUS ROG Zephyrus G14 and G15 are wrong, they tell the asus-wmi code to use the vendor specific WMI backlight interface. But there is no such interface on these laptops.
As a side effect, these quirks stop the acpi_video driver to register since they make acpi_video_get_backlight_type() return acpi_backlight_vendor, leaving only the native AMD backlight driver in place, which is the one we want. This happy coincidence is being replaced with a new quirk in drivers/acpi/video_detect.c which actually sets the backlight_type to acpi_backlight_native fixinf this properly. This reverts
commit 13bceda68fb9 ("platform/x86: asus-nb-wmi: add support for ASUS ROG Zephyrus G14 and G15").
--- drivers/platform/x86/asus-nb-wmi.c | 82 ------------------------------ 1 file changed, 82 deletions(-)
drivers/platform/x86/asus-nb-wmi.c +0 -82
@@ -110,16 +110,6 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_ga401i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; - -static struct quirk_entry quirk_asus_ga502i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; -static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, };
@@ -430,78 +420,6 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_forceals, }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IH", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IVC", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), - }, - .driver_data = &quirk_asus_ga502i, - }, { .callback = dmi_matched, .ident = "Asus Transformer T100TA / T100HA / T100CHI",
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 239/800 platform/x86: toshiba_acpi: Fix missing error code in toshiba_acpi_setup_keyboard()
In reply to Greg Kroah-HartmanFrom: Jiapeng Chong <[email protected]>
[ Upstream commit 28e367127718a9cb85d615a71e152f7acee41bfc ]
The error code is missing in this code scenario, add the error code '-EINVAL' to the return value 'error'.
Eliminate the follow smatch warning:
drivers/platform/x86/toshiba_acpi.c:2834 toshiba_acpi_setup_keyboard()
warn: missing error code 'error'.
--- drivers/platform/x86/toshiba_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/toshiba_acpi.c +1 -0
@@ -2831,6 +2831,7 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)if (!dev->info_supported && !dev->system_event_supported) {pr_warn ("No hotkey query interface found\n" ); + error = -EINVAL ; goto err_remove_filter; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 240/800 nvme-pci: fix var. type for increasing cq_head
In reply to Greg Kroah-HartmanFrom: JK Kim <[email protected]>
[ Upstream commit a0aac973a26d1ac814b9e131e209eb39472a67ce ]
nvmeq->cq_head is compared with nvmeq->q_depth and changed the value and cq_phase for handling the next cq db.
but, nvmeq->q_depth's type is u32 and max. value is 0x10000 when CQP.MSQE is 0xffff and io_queue_depth is 0x10000.
current temp. variable for comparing with nvmeq->q_depth is overflowed when previous nvmeq->cq_head is 0xffff.
in this case, nvmeq->cq_phase is not updated.
so, fix data type for temp. variable to u32.
--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -1032,7 +1032,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)static inline void nvme_update_cq_head (struct nvme_queue *nvmeq) { -u16 tmp = nvmeq->cq_head +1 ; +u32 tmp = nvmeq->cq_head +1 ;if (tmp == nvmeq->q_depth) { nvmeq->cq_head =0 ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 241/800 nvmet-fc: do not check for invalid target port in nvmet_fc_handle_fcp_rqst()
In reply to Greg Kroah-HartmanFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 2a4a910aa4f0acc428dc8d10227c42e14ed21d10 ]
When parsing a request in nvmet_fc_handle_fcp_rqst() we should not check for invalid target ports; if we do the command is aborted from the fcp layer, causing the host to assume a transport error. Rather we should still forward this request to the nvmet layer, which will then correctly fail the command with an appropriate error status.
--- drivers/nvme/target/fc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/nvme/target/fc.c +2 -8
@@ -2510,13 +2510,6 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,u32 xfrlen =be32_to_cpu (cmdiu->data_len);int ret; -/* -* if there is no nvmet mapping to the targetport there -* shouldn't be requests. just terminate them. -*/ -if (!tgtport->pe) - goto transport_error; -/* * Fused commands are currently not supported in the linux * implementation.
@@ -2544,7 +2537,8 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, fod->req.cmd = &fod->cmdiubuf.sqe; fod->req.cqe = &fod->rspiubuf.cqe; - fod->req.port = tgtport->pe->port; +if (tgtport->pe) + fod->req.port = tgtport->pe->port;/* clear any response payload */ memset (&fod->rspiubuf,0 ,sizeof (fod->rspiubuf));
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 242/800 EDAC/Intel: Do not load EDAC driver when running as a guest
In reply to Greg Kroah-HartmanFrom: Luck, Tony <[email protected]>
[ Upstream commit f0a029fff4a50eb01648810a77ba1873e829fdd4 ]
There's little to no point in loading an EDAC driver running in a guest:
1) The CPU model reported by CPUID may not represent actual h/w
2) The hypervisor likely does not pass in access to memory controller devices
3) Hypervisors generally do not pass corrected error details to guests
Add a check in each of the Intel EDAC drivers for X86_FEATURE_HYPERVISOR and simply return -ENODEV in the init routine.
--- drivers/edac/i10nm_base.c | 3 +++ drivers/edac/pnd2_edac.c | 3 +++ drivers/edac/sb_edac.c | 3 +++ drivers/edac/skx_base.c | 3 +++ 4 files changed, 12 insertions(+)
drivers/edac/i10nm_base.c +3 -0
@@ -278,6 +278,9 @@ static int __init i10nm_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (i10nm_cpuids);if (!id)return -ENODEV ;
drivers/edac/pnd2_edac.c +3 -0
@@ -1554,6 +1554,9 @@ static int __init pnd2_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (pnd2_cpuids);if (!id)return -ENODEV ;
drivers/edac/sb_edac.c +3 -0
@@ -3510,6 +3510,9 @@ static int __init sbridge_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (sbridge_cpuids);if (!id)return -ENODEV ;
drivers/edac/skx_base.c +3 -0
@@ -656,6 +656,9 @@ static int __init skx_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (skx_cpuids);if (!id)return -ENODEV ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 243/800 tools/power/x86/intel-speed-select: Fix uncore memory frequency display
In reply to Greg Kroah-HartmanFrom: Srinivas Pandruvada <[email protected]>
[ Upstream commit 159f130f60f402273b235801d1fde3fc115c6795 ]
The uncore memory frequency value from the mailbox command CONFIG_TDP_GET_MEM_FREQ needs to be scaled based on the platform for display. There is no single constant multiplier.
This change introduces CPU model specific memory frequency multiplier.
--- tools/power/x86/intel-speed-select/isst-config.c | 16 ++++++++++++++++ tools/power/x86/intel-speed-select/isst-core.c | 15 +++++++++++++++ .../power/x86/intel-speed-select/isst-display.c | 2 +- tools/power/x86/intel-speed-select/isst.h | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-)
tools/power/x86/intel-speed-select/isst-config.c +16 -0
@@ -106,6 +106,22 @@ int is_skx_based_platform(void)return 0 ; } +int is_spr_platform (void ) +{ +if (cpu_model ==0x8F ) +return 1 ; + +return 0 ; +} + +int is_icx_platform (void ) +{ +if (cpu_model ==0x6A || cpu_model ==0x6C ) +return 1 ; + +return 0 ; +} +static int update_cpu_model (void ) {unsigned int ebx, ecx, edx;
tools/power/x86/intel-speed-select/isst-core.c +15 -0
@@ -201,6 +201,7 @@ void isst_get_uncore_mem_freq(int cpu, int config_index, {unsigned int resp;int ret; + ret =isst_send_mbox_command (cpu,CONFIG_TDP ,CONFIG_TDP_GET_MEM_FREQ ,0 , config_index, &resp);if (ret) {
@@ -209,6 +210,20 @@ void isst_get_uncore_mem_freq(int cpu, int config_index, } ctdp_level->mem_freq = resp &GENMASK (7 ,0 ); +if (is_spr_platform ()) { + ctdp_level->mem_freq *=200 ; + }else if (is_icx_platform ()) { +if (ctdp_level->mem_freq <7 ) { + ctdp_level->mem_freq = (12 - ctdp_level->mem_freq) *133.33 *2 *10 ; + ctdp_level->mem_freq /=10 ; +if (ctdp_level->mem_freq %10 >5 ) + ctdp_level->mem_freq++; + }else { + ctdp_level->mem_freq =0 ; + } + }else { + ctdp_level->mem_freq =0 ; + }debug_printf ("cpu:%d ctdp:%d CONFIG_TDP_GET_MEM_FREQ resp:%x uncore mem_freq:%d\n" , cpu, config_index, resp, ctdp_level->mem_freq);
tools/power/x86/intel-speed-select/isst-display.c +1 -1
@@ -446,7 +446,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,if (ctdp_level->mem_freq) {snprintf (header,sizeof (header),"mem-frequency(MHz)" );snprintf (value,sizeof (value),"%d" , - ctdp_level->mem_freq *DISP_FREQ_MULTIPLIER ); + ctdp_level->mem_freq);format_and_print (outf, level +2 , header, value); }
tools/power/x86/intel-speed-select/isst.h +2 -0
@@ -257,5 +257,7 @@ extern int get_cpufreq_base_freq(int cpu);extern int isst_read_pm_config (int cpu,int *cp_state,int *cp_cap);extern void isst_display_error_info_message (int error,char *msg,int arg_valid,int arg);extern int is_skx_based_platform (void ); +extern int is_spr_platform (void ); +extern int is_icx_platform (void );extern void isst_trl_display_information (int cpu,FILE *outf,unsigned long long trl);#endif
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 244/800 PCI: hv: Add check for hyperv_initialized in init_hv_pci_drv()
In reply to Greg Kroah-HartmanFrom: Haiyang Zhang <[email protected]>
[ Upstream commit 7d815f4afa87f2032b650ae1bba7534b550a6b8b ]
Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.
--- drivers/pci/controller/pci-hyperv.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pci/controller/pci-hyperv.c +3 -0
@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void)static int __init init_hv_pci_drv (void ) { +if (!hv_is_hyperv_initialized ()) +return -ENODEV ; +/* Set the invalid domain number's bit, so it will not be used */ set_bit (HVPCI_DOM_INVALID , hvpci_dom_map);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 245/800 cifs: improve fallocate emulation
In reply to Greg Kroah-HartmanFrom: Ronnie Sahlberg <[email protected]>
[ Upstream commit 966a3cb7c7db786452a87afdc3b48858fc4d4d6b ]
RHBZ: 1866684
We don't have a real fallocate in the SMB2 protocol so we used to emulate fallocate by simply switching the file to become non-sparse. But as that could potantially consume a lot more data than we intended to fallocate (large sparse file and fallocating a thin slice in the middle) we would only do this IFF the fallocate request was for virtually the entire file.
This patch improves this and starts allowing us to fallocate smaller chunks of a file by overwriting the region with 0, for the parts that are unallocated.
The method used is to first query the server for FSCTL_QUERY_ALLOCATED_RANGES to find what is unallocated in the fallocate range and then to only overwrite-with-zero the unallocated ranges to fill in the holes.
As overwriting-with-zero is different from just allocating blocks, and potentially much more expensive, we limit this to only allow fallocate ranges up to 1Mb in size.
--- fs/cifs/smb2ops.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+)
fs/cifs/smb2ops.c +133 -0
@@ -3601,6 +3601,119 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,return rc; } +static int smb3_simple_fallocate_write_range (unsigned int xid, +struct cifs_tcon *tcon, +struct cifsFileInfo *cfile, +loff_t off,loff_t len, +char *buf) +{ +struct cifs_io_parms io_parms = {0 }; +int nbytes; +struct kvec iov[2 ]; + + io_parms.netfid = cfile->fid.netfid; + io_parms.pid = current->tgid; + io_parms.tcon = tcon; + io_parms.persistent_fid = cfile->fid.persistent_fid; + io_parms.volatile_fid = cfile->fid.volatile_fid; + io_parms.offset = off; + io_parms.length = len; + +/* iov[0] is reserved for smb header */ + iov[1 ].iov_base = buf; + iov[1 ].iov_len = io_parms.length; +return SMB2_write (xid, &io_parms, &nbytes, iov,1 ); +} + +static int smb3_simple_fallocate_range (unsigned int xid, +struct cifs_tcon *tcon, +struct cifsFileInfo *cfile, +loff_t off,loff_t len) +{ +struct file_allocated_range_buffer in_data, *out_data =NULL , *tmp_data; +u32 out_data_len; +char *buf =NULL ; +loff_t l; +int rc; + + in_data.file_offset =cpu_to_le64 (off); + in_data.length =cpu_to_le64 (len); + rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, + cfile->fid.volatile_fid, +FSCTL_QUERY_ALLOCATED_RANGES , true, + (char *)&in_data,sizeof (in_data), +1024 *sizeof (struct file_allocated_range_buffer ), + (char **)&out_data, &out_data_len); +if (rc) + goto out; +/* +* It is already all allocated +*/ +if (out_data_len ==0 ) + goto out; + + buf =kzalloc (1024 *1024 ,GFP_KERNEL ); +if (buf ==NULL ) { + rc = -ENOMEM ; + goto out; + } + + tmp_data = out_data; +while (len) { +/* +* The rest of the region is unmapped so write it all. +*/ +if (out_data_len ==0 ) { + rc =smb3_simple_fallocate_write_range (xid, tcon, + cfile, off, len, buf); + goto out; + } + +if (out_data_len <sizeof (struct file_allocated_range_buffer )) { + rc = -EINVAL ; + goto out; + } + +if (off <le64_to_cpu (tmp_data->file_offset)) { +/* +* We are at a hole. Write until the end of the region +* or until the next allocated data, +* whichever comes next. +*/ + l =le64_to_cpu (tmp_data->file_offset) - off; +if (len < l) + l = len; + rc =smb3_simple_fallocate_write_range (xid, tcon, + cfile, off, l, buf); +if (rc) + goto out; + off = off + l; + len = len - l; +if (len ==0 ) + goto out; + } +/* +* We are at a section of allocated data, just skip forward +* until the end of the data or the end of the region +* we are supposed to fallocate, whichever comes first. +*/ + l =le64_to_cpu (tmp_data->length); +if (len < l) + l = len; + off += l; + len -= l; + + tmp_data = &tmp_data[1 ]; + out_data_len -=sizeof (struct file_allocated_range_buffer ); + } + + out: +kfree (out_data); +kfree (buf); +return rc; +} + +static long smb3_simple_falloc (struct file *file,struct cifs_tcon *tcon,loff_t off,loff_t len,bool keep_size) {
@@ -3661,6 +3774,26 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, }if ((keep_size == true) || (i_size_read (inode) >= off + len)) { +/* +* At this point, we are trying to fallocate an internal +* regions of a sparse file. Since smb2 does not have a +* fallocate command we have two otions on how to emulate this. +* We can either turn the entire file to become non-sparse +* which we only do if the fallocate is for virtually +* the whole file, or we can overwrite the region with zeroes +* using SMB2_write, which could be prohibitevly expensive +* if len is large. +*/ +/* +* We are only trying to fallocate a small region so +* just write it with zero. +*/ +if (len <=1024 *1024 ) { + rc =smb3_simple_fallocate_range (xid, tcon, cfile, + off, len); + goto out; + } +/* * Check if falloc starts within first few pages of file * and ends within a few pages of the end of file to
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 246/800 cifs: fix check of dfs interlinks
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
[ Upstream commit 889c2a700799f3b6f82210925e1faf4a9b833c4a ]
Interlink is a special type of DFS link that resolves to a different DFS domain-based namespace. To determine whether it is an interlink or not, check if ReferralServers and StorageServers bits are set to 1 and 0 respectively in ReferralHeaderFlags, as specified in MS-DFSC 3.1.5.4.5 Determining Whether a Referral Response is an Interlink.
--- fs/cifs/dfs_cache.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/cifs/dfs_cache.c +3 -4
@@ -25,8 +25,7 @@#define CACHE_HTABLE_SIZE 32#define CACHE_MAX_ENTRIES 64 -#define IS_INTERLINK_SET (v) ((v) & (DFSREF_REFERRAL_SERVER | \ - DFSREF_STORAGE_SERVER)) +#define IS_DFS_INTERLINK (v) (((v) & DFSREF_REFERRAL_SERVER) && !((v) & DFSREF_STORAGE_SERVER))struct cache_dfs_tgt {char *name;
@@ -171,7 +170,7 @@ static int dfscache_proc_show(struct seq_file *m, void *v)"cache entry: path=%s,type=%s,ttl=%d,etime=%ld,hdr_flags=0x%x,ref_flags=0x%x,interlink=%s,path_consumed=%d,expired=%s\n" , ce->path, ce->srvtype ==DFS_TYPE_ROOT ?"root" :"link" , ce->ttl, ce->etime.tv_nsec, ce->ref_flags, ce->hdr_flags, -IS_INTERLINK_SET (ce->hdr_flags) ?"yes" :"no" , +IS_DFS_INTERLINK (ce->hdr_flags) ?"yes" :"no" , ce->path_consumed, cache_entry_expired(ce) ? "yes" : "no");list_for_each_entry (t, &ce->tlist, list) {
@@ -240,7 +239,7 @@ static inline void dump_ce(const struct cache_entry *ce) ce->srvtype ==DFS_TYPE_ROOT ?"root" :"link" , ce->ttl, ce->etime.tv_nsec, ce->hdr_flags, ce->ref_flags, -IS_INTERLINK_SET (ce->hdr_flags) ?"yes" :"no" , +IS_DFS_INTERLINK (ce->hdr_flags) ?"yes" :"no" , ce->path_consumed, cache_entry_expired(ce) ? "yes" : "no");dump_tgts (ce);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 247/800 cifs: retry lookup and readdir when EAGAIN is returned.
In reply to Greg Kroah-HartmanFrom: Thiago Rafael Becker <[email protected]>
[ Upstream commit 6efa994e35a402ae4ae2161b6439c94b64816cee ]
According to the investigation performed by Jacob Shivers at Red Hat, cifs_lookup and cifs_readdir leak EAGAIN when the user session is deleted on the server. Fix this issue by implementing a retry with limits, as is implemented in cifs_revalidate_dentry_attr.
Reproducer based on the work by Jacob Shivers:
~~~
$ cat readdir-cifs-test.sh #!/bin/bash
# Install and configure powershell and sshd on the windows
# server as descibed in
# https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview
# This script uses expect(1)
USER=dude
SERVER=192.168.0.2
RPATH=root
PASS='password'
function debug_funcs {
for line in $@ ; do
echo "func $line +p" > /sys/kernel/debug/dynamic_debug/control
done
}
function setup {
echo 1 > /proc/fs/cifs/cifsFYI
debug_funcs wait_for_compound_request \
smb2_query_dir_first cifs_readdir \
compound_send_recv cifs_reconnect_tcon \
generic_ip_connect cifs_reconnect \
smb2_reconnect_server smb2_reconnect \
cifs_readv_from_socket cifs_readv_receive
tcpdump -i eth0 -w cifs.pcap host 192.168.2.182 & sleep 5
dmesg -C
}
function test_call {
if [[ $1 == 1 ]] ; then
tracer="strace -tt -f -s 4096 -o trace-$(date -Iseconds).txt"
fi
# Change the command here to anything appropriate
$tracer ls $2 > /dev/null
res=$?
if [[ $1 == 1 ]] ; then
if [[ $res == 0 ]] ; then
1>&2 echo success
else
1>&2 echo "failure ($res)"
fi
fi
}
mountpoint /mnt > /dev/null || mount -t cifs -o username=$USER,pass=$PASS //$SERVER/$RPATH /mnt test_call 0 /mnt/
/usr/bin/expect << EOF
set timeout 60
spawn ssh $USER@$SERVER
expect "yes/no" {
send "yes\r"
expect "*?assword" { send "$PASS\r" }
} "*?assword" { send "$PASS\r" } expect ">" { send "powershell close-smbsession -force\r" } expect ">" { send "exit\r" }
expect eof
EOF
sysctl -w vm.drop_caches=2 > /dev/null
sysctl -w vm.drop_caches=2 > /dev/null
setup
test_call 1 /mnt/
~~~
--- fs/cifs/dir.c | 4 ++++ fs/cifs/smb2ops.c | 5 +++++ 2 files changed, 9 insertions(+)
fs/cifs/dir.c +4 -0
@@ -630,6 +630,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,struct inode *newInode =NULL ;const char *full_path;void *page; +int retry_count =0 ; xid =get_xid ();
@@ -673,6 +674,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,cifs_dbg (FYI ,"Full path: %s inode = 0x%p\n" , full_path,d_inode (direntry)); +again:if (pTcon->posix_extensions) rc =smb311_posix_get_inode_info (&newInode, full_path, parent_dir_inode->i_sb, xid);else if (pTcon->unix_ext) {
@@ -687,6 +689,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,/* since paths are not looked up by component - the parent directories are presumed to be good here */ renew_parental_timestamps (direntry); + }else if (rc == -EAGAIN && retry_count++ <10 ) { + goto again; }else if (rc == -ENOENT ) {cifs_set_time (direntry, jiffies); newInode =NULL ;
fs/cifs/smb2ops.c +5 -0
@@ -2325,6 +2325,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,struct smb2_query_directory_rsp *qd_rsp =NULL ;struct smb2_create_rsp *op_rsp =NULL ;struct TCP_Server_Info *server =cifs_pick_channel (tcon->ses); +int retry_count =0 ; utf16_path =cifs_convert_path_to_utf16 (path, cifs_sb);if (!utf16_path)
@@ -2372,10 +2373,14 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,smb2_set_related (&rqst[1 ]); +again: rc =compound_send_recv (xid, tcon->ses, server, flags,2 , rqst, resp_buftype, rsp_iov); +if (rc == -EAGAIN && retry_count++ <10 ) + goto again; +/* If the open failed there is nothing to do */ op_rsp = (struct smb2_create_rsp *)rsp_iov[0 ].iov_base;if (op_rsp ==NULL || op_rsp->sync_hdr.Status !=STATUS_SUCCESS ) {
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 248/800 smb3: fix uninitialized value for port in witness protocol move
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit ff93b71a3eff25fe9d4364ef13b6e01d935600c6 ]
Although in practice this can not occur (since IPv4 and IPv6 are the only two cases currently supported), it is cleaner to avoid uninitialized variable warnings.
Addresses smatch warning:
fs/cifs/cifs_swn.c:468 cifs_swn_store_swn_addr() error: uninitialized symbol 'port'.
--- fs/cifs/cifs_swn.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/cifs/cifs_swn.c +3 -7
@@ -447,15 +447,13 @@ static int cifs_swn_store_swn_addr(const struct sockaddr_storage *new,const struct sockaddr_storage *old, struct sockaddr_storage *dst) { - __be16 port; + __be16 port = cpu_to_be16(CIFS_PORT);if (old->ss_family ==AF_INET ) {struct sockaddr_in *ipv4 = (struct sockaddr_in *)old; port = ipv4->sin_port; - } - -if (old->ss_family ==AF_INET6 ) { + }else if (old->ss_family ==AF_INET6 ) {struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)old; port = ipv6->sin6_port;
@@ -465,9 +463,7 @@ static int cifs_swn_store_swn_addr(const struct sockaddr_storage *new,struct sockaddr_in *ipv4 = (struct sockaddr_in *)new; ipv4->sin_port = port; - } - -if (new->ss_family ==AF_INET6 ) { + }else if (new->ss_family ==AF_INET6 ) {struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)new; ipv6->sin6_port = port;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 249/800 cifs: fix SMB1 error path in cifs_get_file_info_unix
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit e39df24169a2ceb0d359eb3a05ff982711f2eb32 ]
We were trying to fill in uninitialized file attributes in the error case.
Addresses-Coverity: 139689 ("Uninitialized variables")
--- fs/cifs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/cifs/inode.c +4 -1
@@ -367,9 +367,12 @@ cifs_get_file_info_unix(struct file *filp) }else if (rc == -EREMOTE ) {cifs_create_dfs_fattr (&fattr, inode->i_sb); rc =0 ; - } + }else + goto cifs_gfiunix_out; rc =cifs_fattr_to_inode (inode, &fattr); + +cifs_gfiunix_out:free_xid (xid);return rc; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 250/800 ACPI: EC: trust DSDT GPE for certain HP laptop
In reply to Greg Kroah-HartmanFrom: Zhang Rui <[email protected]>
[ Upstream commit 4370cbf350dbaca984dbda9f9ce3fac45d6949d5 ]
On HP Pavilion Gaming Laptop 15-cx0xxx, the ECDT EC and DSDT EC share the same port addresses but different GPEs. And the DSDT GPE is the right one to use.
The current code duplicates DSDT EC with ECDT EC if the port addresses are the same, and uses ECDT GPE as a result, which breaks this machine.
Introduce a new quirk for the HP laptop to trust the DSDT GPE, and avoid duplicating even if the port addresses are the same.
--- drivers/acpi/ec.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +20 -1
@@ -183,6 +183,7 @@ static struct workqueue_struct *ec_query_wq;static int EC_FLAGS_CORRECT_ECDT ;/* Needs ECDT port address correction */ static int EC_FLAGS_IGNORE_DSDT_GPE ;/* Needs ECDT GPE as correction setting */ +static int EC_FLAGS_TRUST_DSDT_GPE ;/* Needs DSDT GPE as correction setting */ static int EC_FLAGS_CLEAR_ON_RESUME ;/* Needs acpi_ec_clear() on boot/resume */ /* --------------------------------------------------------------------------
@@ -1593,7 +1594,8 @@ static int acpi_ec_add(struct acpi_device *device) }if (boot_ec && ec->command_addr == boot_ec->command_addr && - ec->data_addr == boot_ec->data_addr) { + ec->data_addr == boot_ec->data_addr && + !EC_FLAGS_TRUST_DSDT_GPE ) {/* * Trust PNP0C09 namespace location rather than * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1816,6 +1818,18 @@ static int ec_correct_ecdt(const struct dmi_system_id *id)return 0 ; } +/* +* Some ECDTs contain wrong GPE setting, but they share the same port addresses +* with DSDT EC, don't duplicate the DSDT EC with ECDT EC in this case. +* https://bugzilla.kernel.org/show_bug.cgi?id=209989 +*/ +static int ec_honor_dsdt_gpe (const struct dmi_system_id *id) +{ +pr_debug ("Detected system needing DSDT GPE setting.\n" ); +EC_FLAGS_TRUST_DSDT_GPE =1 ; +return 0 ; +} +/* * Some DSDTs contain wrong GPE setting. * Asus FX502VD/VE, GL702VMK, X550VXK, X580VD
@@ -1870,6 +1884,11 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL}, { +/* https://bugzilla.kernel.org/show_bug.cgi?id=209989 */ + ec_honor_dsdt_gpe, "HP Pavilion Gaming Laptop 15-cx0xxx", { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-cx0xxx"),}, NULL}, + { ec_clear_on_resume, "Samsung hardware", { DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL}, {},
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 251/800 block, bfq: fix delayed stable merge check
In reply to Greg Kroah-HartmanFrom: Luca Mariotti <[email protected]>
[ Upstream commit e03f2ab78a4a673e4af23c3b855591c48b9de4d7 ]
When attempting to schedule a merge of a given bfq_queue with the currently in-service bfq_queue or with a cooperating bfq_queue among the scheduled bfq_queues, delayed stable merge is checked for rotational or non-queueing devs. For this stable merge to be performed, some conditions must be met. If the current bfq_queue underwent some split from some merged bfq_queue, one of these conditions is that two hundred milliseconds must elapse from split, otherwise this condition is always met.
Unfortunately, by mistake, time_is_after_jiffies() was written instead of time_is_before_jiffies() for this check, verifying that less than two hundred milliseconds have elapsed instead of verifying that at least two hundred milliseconds have elapsed.
Fix this issue by replacing time_is_after_jiffies() with time_is_before_jiffies().
--- block/bfq-iosched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/bfq-iosched.c +1 -1
@@ -2697,7 +2697,7 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,if (unlikely (!bfqd->nonrot_with_queueing)) {if (bic->stable_merge_bfqq && !bfq_bfqq_just_created (bfqq) && -time_is_after_jiffies (bfqq->split_time + +time_is_before_jiffies (bfqq->split_time +msecs_to_jiffies (200 ))) {struct bfq_queue *stable_merge_bfqq = bic->stable_merge_bfqq;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 252/800 clocksource: Retry clock read if long delays detected
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit db3a34e17433de2390eb80d436970edcebd0ca3e ]
When the clocksource watchdog marks a clock as unstable, this might be due to that clock being unstable or it might be due to delays that happen to occur between the reads of the two clocks. Yes, interrupts are disabled across those two reads, but there are no shortage of things that can delay interrupts-disabled regions of code ranging from SMI handlers to vCPU preemption. It would be good to have some indication as to why the clock was marked unstable.
Therefore, re-read the watchdog clock on either side of the read from the clock under test. If the watchdog clock shows an excessive time delta between its pair of reads, the reads are retried.
The maximum number of retries is specified by a new kernel boot parameter clocksource.max_cswd_read_retries, which defaults to three, that is, up to four reads, one initial and up to three retries. If more than one retry was required, a message is printed on the console (the occasional single retry is expected behavior, especially in guest OSes). If the maximum number of retries is exceeded, the clock under test will be marked unstable. However, the probability of this happening due to various sorts of delays is quite small. In addition, the reason (clock-read delays) for the unstable marking will be apparent.
--- .../admin-guide/kernel-parameters.txt | 6 +++ kernel/time/clocksource.c | 53 ++++++++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -581,6 +581,12 @@ loops can be debugged more effectively on production systems. + clocksource.max_cswd_read_retries= [KNL] + Number of clocksource_watchdog() retries due to + external delays before the clock will be marked + unstable. Defaults to three retries, that is, + four attempts to read the clock under test. + clearcpuid=BITNUM[,BITNUM...] [X86] Disable CPUID feature X for the kernel. See arch/x86/include/asm/cpufeatures.h for the valid bit
kernel/time/clocksource.c +47 -6
75 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 253/800 clocksource: Check per-CPU clock synchronization when marked unstable
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 7560c02bdffb7c52d1457fa551b9e745d4b9e754 ]
Some sorts of per-CPU clock sources have a history of going out of synchronization with each other. However, this problem has purportedy been solved in the past ten years. Except that it is all too possible that the problem has instead simply been made less likely, which might mean that some of the occasional "Marking clocksource 'tsc' as unstable" messages might be due to desynchronization. How would anyone know?
Therefore apply CPU-to-CPU synchronization checking to newly unstable clocksource that are marked with the new CLOCK_SOURCE_VERIFY_PERCPU flag. Lists of desynchronized CPUs are printed, with the caveat that if it is the reporting CPU that is itself desynchronized, it will appear that all the other clocks are wrong. Just like in real life.
--- arch/x86/kernel/tsc.c | 3 +- include/linux/clocksource.h | 2 +- kernel/time/clocksource.c | 60 +++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-)
arch/x86/kernel/tsc.c +2 -1
@@ -1152,7 +1152,8 @@ static struct clocksource clocksource_tsc = { .mask = CLOCKSOURCE_MASK(64), .flags =CLOCK_SOURCE_IS_CONTINUOUS |CLOCK_SOURCE_VALID_FOR_HRES | - CLOCK_SOURCE_MUST_VERIFY, +CLOCK_SOURCE_MUST_VERIFY | + CLOCK_SOURCE_VERIFY_PERCPU, .vdso_clock_mode = VDSO_CLOCKMODE_TSC, .enable = tsc_cs_enable, .resume = tsc_resume,
include/linux/clocksource.h +1 -1
@@ -137,7 +137,7 @@ struct clocksource {#define CLOCK_SOURCE_UNSTABLE 0x40#define CLOCK_SOURCE_SUSPEND_NONSTOP 0x80#define CLOCK_SOURCE_RESELECT 0x100 - +#define CLOCK_SOURCE_VERIFY_PERCPU 0x200/* simplify initialization of mask field */ #define CLOCKSOURCE_MASK (bits) GENMASK_ULL((bits) - 1, 0)
kernel/time/clocksource.c +60 -0
72 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 254/800 tpm_tis_spi: add missing SPI device ID entries
In reply to Greg Kroah-HartmanFrom: Javier Martinez Canillas <[email protected]>
[ Upstream commit c46ed2281bbe4b84e6f3d4bdfb0e4e9ab813fa9d ]
The SPI core always reports a "MODALIAS=spi:<foo>", even if the device was registered via OF. This means that this module won't auto-load if a DT has for example has a node with a compatible "infineon,slb9670" string.
In that case kmod will expect a "MODALIAS=of:N*T*Cinfineon,slb9670" uevent but instead will get a "MODALIAS=spi:slb9670", which is not present in the kernel module aliases:
$ modinfo drivers/char/tpm/tpm_tis_spi.ko | grep alias alias: of:N*T*Cgoogle,cr50C* alias: of:N*T*Cgoogle,cr50 alias: of:N*T*Ctcg,tpm_tis-spiC* alias: of:N*T*Ctcg,tpm_tis-spi alias: of:N*T*Cinfineon,slb9670C* alias: of:N*T*Cinfineon,slb9670 alias: of:N*T*Cst,st33htpm-spiC* alias: of:N*T*Cst,st33htpm-spi alias: spi:cr50 alias: spi:tpm_tis_spi alias: acpi*:SMO0768:*
To workaround this issue, add in the SPI device ID table all the entries that are present in the OF device ID table.
--- drivers/char/tpm/tpm_tis_spi_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/char/tpm/tpm_tis_spi_main.c +2 -0
@@ -260,6 +260,8 @@ static int tpm_tis_spi_remove(struct spi_device *dev) }static const struct spi_device_id tpm_tis_spi_id[] = { + {"st33htpm-spi" , (unsigned long )tpm_tis_spi_probe }, + {"slb9670" , (unsigned long )tpm_tis_spi_probe }, {"tpm_tis_spi" , (unsigned long )tpm_tis_spi_probe }, {"cr50" , (unsigned long )cr50_spi_probe }, {}
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 255/800 ACPI: tables: Add custom DSDT file as makefile prerequisite
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit d1059c1b1146870c52f3dac12cb7b6cbf39ed27f ]
A custom DSDT file is mostly used during development or debugging, and in that case it is quite likely to want to rebuild the kernel after changing ONLY the content of the DSDT.
This patch adds the custom DSDT as a prerequisite to tables.o to ensure a rebuild if the DSDT file is updated. Make will merge the prerequisites from multiple rules for the same target.
--- drivers/acpi/Makefile | 5 +++++ 1 file changed, 5 insertions(+)
drivers/acpi/Makefile +5 -0
@@ -8,6 +8,11 @@ ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT # # ACPI Boot-Time Table Parsing # +ifeq ($(CONFIG_ACPI_CUSTOM_DSDT),y) +tables.o: $(src)/../../include/$(subst $\",,$(CONFIG_ACPI_CUSTOM_DSDT_FILE)) ; + +endif + obj-$(CONFIG_ACPI) += tables.o obj-$(CONFIG_X86) += blacklist.o
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 256/800 smb3: fix possible access to uninitialized pointer to DACL
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit a5628263a9f8d47d9a1548fe9d5d75ba4423a735 ]
dacl_ptr can be null so we must check for it everywhere it is used in build_sec_desc.
Addresses-Coverity: 1475598 ("Explicit null dereference")
--- fs/cifs/cifsacl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/cifsacl.c +1 -1
@@ -1308,7 +1308,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); ndacl_ptr->revision = dacloffset ? dacl_ptr->revision :cpu_to_le16 (ACL_REVISION ); - ndacl_ptr->num_aces = dacl_ptr->num_aces; + ndacl_ptr->num_aces = dacl_ptr ? dacl_ptr->num_aces :0 ;if (uid_valid (uid)) {/* chown */ uid_t id;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 257/800 HID: wacom: Correct base usage for capacitive ExpressKey status bits
In reply to Greg Kroah-HartmanFrom: Jason Gerecke <[email protected]>
[ Upstream commit 424d8237945c6c448c8b3f23885d464fb5685c97 ]
The capacitive status of ExpressKeys is reported with usages beginning at 0x940, not 0x950. Bring our driver into alignment with reality.
--- drivers/hid/wacom_wac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/wacom_wac.h +1 -1
@@ -122,7 +122,7 @@#define WACOM_HID_WD_TOUCHONOFF (WACOM_HID_UP_WACOMDIGITIZER | 0x0454)#define WACOM_HID_WD_BATTERY_LEVEL (WACOM_HID_UP_WACOMDIGITIZER | 0x043b)#define WACOM_HID_WD_EXPRESSKEY00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0910) -#define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0950) +#define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0940)#define WACOM_HID_WD_MODE_CHANGE (WACOM_HID_UP_WACOMDIGITIZER | 0x0980)#define WACOM_HID_WD_MUTE_DEVICE (WACOM_HID_UP_WACOMDIGITIZER | 0x0981)#define WACOM_HID_WD_CONTROLPANEL (WACOM_HID_UP_WACOMDIGITIZER | 0x0982)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 258/800 cifs: fix missing spinlock around update to ses->status
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit 0060a4f28a9ef45ae8163c0805e944a2b1546762 ]
In the other places where we update ses->status we protect the updates via GlobalMid_Lock. So to be consistent add the same locking around it in cifs_put_smb_ses where it was missing.
Addresses-Coverity: 1268904 ("Data race condition")
--- fs/cifs/cifsglob.h | 3 ++- fs/cifs/connect.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-)
fs/cifs/cifsglob.h +2 -1
@@ -896,7 +896,7 @@ struct cifs_ses {struct mutex session_mutex;struct TCP_Server_Info *server;/* pointer to server info */ int ses_count;/* reference counter */ -enum statusEnum status; +enum statusEnum status;/* updates protected by GlobalMid_Lock */ unsigned overrideSecFlg;/* if non-zero override global sec flags */ char *serverOS;/* name of operating system underlying server */ char *serverNOS;/* name of network operating system of server */
@@ -1795,6 +1795,7 @@ require use of the stronger protocol */* list operations on pending_mid_q and oplockQ * updates to XID counters, multiplex id and SMB sequence numbers * list operations on global DnotifyReqList +* updates to ses->status * tcp_ses_lock protects: * list operations on tcp and SMB session lists * tcon->open_file_lock protects the list of open files hanging off the tcon
fs/cifs/connect.c +4 -1
@@ -1617,9 +1617,12 @@ void cifs_put_smb_ses(struct cifs_ses *ses)spin_unlock (&cifs_tcp_ses_lock);return ; } +spin_unlock (&cifs_tcp_ses_lock); + +spin_lock (&GlobalMid_Lock);if (ses->status == CifsGood) ses->status = CifsExiting; -spin_unlock (&cifs_tcp_ses_lock); +spin_unlock (&GlobalMid_Lock);cifs_free_ipc (ses);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 259/800 bfq: Remove merged request already in bfq_requests_merged()
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit a921c655f2033dd1ce1379128efe881dda23ea37 ]
Currently, bfq does very little in bfq_requests_merged() and handles all the request cleanup in bfq_finish_requeue_request() called from blk_mq_free_request(). That is currently safe only because blk_mq_free_request() is called shortly after bfq_requests_merged() while bfqd->lock is still held. However to fix a lock inversion between bfqd->lock and ioc->lock, we need to call blk_mq_free_request() after dropping bfqd->lock. That would mean that already merged request could be seen by other processes inside bfq queues and possibly dispatched to the device which is wrong. So move cleanup of the request from bfq_finish_requeue_request() to bfq_requests_merged().
--- block/bfq-iosched.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-)
block/bfq-iosched.c +13 -28
@@ -2405,7 +2405,7 @@ static void bfq_requests_merged(struct request_queue *q, struct request *rq, *next_bfqq =bfq_init_rq (next);if (!bfqq) -return ; + goto remove;/* * If next and rq belong to the same bfq_queue and next is older
@@ -2428,6 +2428,14 @@ static void bfq_requests_merged(struct request_queue *q, struct request *rq, bfqq->next_rq = rq;bfqg_stats_update_io_merged (bfqq_group (bfqq), next->cmd_flags); +remove: +/* Merged request may be in the IO scheduler. Remove it. */ +if (!RB_EMPTY_NODE (&next->rb_node)) { +bfq_remove_request (next->q, next); +if (next_bfqq) +bfqg_stats_update_io_remove (bfqq_group (next_bfqq), + next->cmd_flags); + } }/* Must be called with bfqq != NULL */
@@ -6376,6 +6384,7 @@ static void bfq_finish_requeue_request(struct request *rq) {struct bfq_queue *bfqq =RQ_BFQQ (rq);struct bfq_data *bfqd; +unsigned long flags;/* * rq either is not associated with any icq, or is an already
@@ -6393,39 +6402,15 @@ static void bfq_finish_requeue_request(struct request *rq) rq->io_start_time_ns, rq->cmd_flags); +spin_lock_irqsave (&bfqd->lock, flags);if (likely (rq->rq_flags &RQF_STARTED )) { -unsigned long flags; - -spin_lock_irqsave (&bfqd->lock, flags); -if (rq == bfqd->waited_rq)bfq_update_inject_limit (bfqd, bfqq);bfq_completed_request (bfqq, bfqd); -bfq_finish_requeue_request_body (bfqq); - -spin_unlock_irqrestore (&bfqd->lock, flags); - }else { -/* -* Request rq may be still/already in the scheduler, -* in which case we need to remove it (this should -* never happen in case of requeue). And we cannot -* defer such a check and removal, to avoid -* inconsistencies in the time interval from the end -* of this function to the start of the deferred work. -* This situation seems to occur only in process -* context, as a consequence of a merge. In the -* current version of the code, this implies that the -* lock is held. -*/ - -if (!RB_EMPTY_NODE (&rq->rb_node)) { -bfq_remove_request (rq->q, rq); -bfqg_stats_update_io_remove (bfqq_group (bfqq), - rq->cmd_flags); - } -bfq_finish_requeue_request_body (bfqq); } +bfq_finish_requeue_request_body (bfqq); +spin_unlock_irqrestore (&bfqd->lock, flags);/* * Reset private fields. In case of a requeue, this allows
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 260/800 mailbox: qcom: Use PLATFORM_DEVID_AUTO to register platform device
In reply to Greg Kroah-HartmanFrom: Shawn Guo <[email protected]>
[ Upstream commit 96e39e95c01283ff5695dafe659df88ada802159 ]
In adding APCS clock support for MSM8939, the second clock registration fails due to duplicate device name like below.
[ 0.519657] sysfs: cannot create duplicate filename '/bus/platform/devices/qcom-apcs-msm8916-clk' ... [ 0.661158] qcom_apcs_ipc b111000.mailbox: failed to register APCS clk
This is because MSM8939 has 3 APCS instances for Cluster0 (little cores), Cluster1 (big cores) and CCI (Cache Coherent Interconnect). Although only APCS of Cluster0 and Cluster1 have IPC bits, each of 3 APCS has A53PLL clock control bits. That said, 3 'qcom-apcs-msm8916-clk' devices need to be registered to instantiate all 3 clocks. Use PLATFORM_DEVID_AUTO rather than PLATFORM_DEVID_NONE for platform_device_register_data() call to fix the issue above.
--- drivers/mailbox/qcom-apcs-ipc-mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/qcom-apcs-ipc-mailbox.c +1 -1
@@ -132,7 +132,7 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)if (apcs_data->clk_name) { apcs->clk =platform_device_register_data (&pdev->dev, apcs_data->clk_name, -PLATFORM_DEVID_NONE , +PLATFORM_DEVID_AUTO ,NULL ,0 );if (IS_ERR (apcs->clk))dev_err (&pdev->dev,"failed to register APCS clk\n" );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 261/800 block: fix discard request merge
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 2705dfb2094777e405e065105e307074af8965c1 ]
ll_new_hw_segment() is reached only in case of single range discard merge, and we don't have max discard segment size limit actually, so it is wrong to run the following check:
if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
it may be always false since req->nr_phys_segments is initialized as one, and bio's segment count is still 1, blk_rq_get_max_segments(reg) is 1 too.
Fix the issue by not doing the check and bypassing the calculation of discard request's nr_phys_segments.
Based on analysis from Wang Shanker.
--- block/blk-merge.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
block/blk-merge.c +6 -2
@@ -559,10 +559,14 @@ static inline unsigned int blk_rq_get_max_segments(struct request *rq)static inline int ll_new_hw_segment (struct request *req,struct bio *bio,unsigned int nr_phys_segs) { -if (req->nr_phys_segments + nr_phys_segs >blk_rq_get_max_segments (req)) +if (blk_integrity_merge_bio (req->q, req, bio) == false) goto no_merge; -if (blk_integrity_merge_bio (req->q, req, bio) == false) +/* discard request merge won't add new segment */ +if (req_op (req) ==REQ_OP_DISCARD ) +return 1 ; + +if (req->nr_phys_segments + nr_phys_segs >blk_rq_get_max_segments (req)) goto no_merge;/*
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 262/800 kthread_worker: fix return value when kthread_mod_delayed_work() races with kthread_cancel_delayed_work_sync()
In reply to Greg Kroah-HartmanFrom: Petr Mladek <[email protected]>
[ Upstream commit d71ba1649fa3c464c51ec7163e4b817345bff2c7 ]
kthread_mod_delayed_work() might race with kthread_cancel_delayed_work_sync() or another kthread_mod_delayed_work() call. The function lets the other operation win when it sees work->canceling counter set. And it returns @false.
But it should return @true as it is done by the related workqueue API, see mod_delayed_work_on().
The reason is that the return value might be used for reference counting. It has to distinguish the case when the number of queued works has changed or stayed the same.
The change is safe. kthread_mod_delayed_work() return value is not checked anywhere at the moment.
--- kernel/kthread.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
kernel/kthread.c +12 -7
@@ -1162,14 +1162,14 @@ static bool __kthread_cancel_work(struct kthread_work *work)* modify @dwork's timer so that it expires after @delay. If @delay is zero, * @work is guaranteed to be queued immediately. * -* Return: %true if @dwork was pending and its timer was modified, -* %false otherwise. +* Return: %false if @dwork was idle and queued, %true otherwise. * * A special case is when the work is being canceled in parallel. * It might be caused either by the real kthread_cancel_delayed_work_sync() * or yet another kthread_mod_delayed_work() call. We let the other command -* win and return %false here. The caller is supposed to synchronize these -* operations a reasonable way. +* win and return %true here. The return value can be used for reference +* counting and the number of queued works stays the same. Anyway, the caller +* is supposed to synchronize these operations a reasonable way. * * This function is safe to call from any context including IRQ handler. * See __kthread_cancel_work() and kthread_delayed_work_timer_fn()
@@ -1181,13 +1181,15 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker, {struct kthread_work *work = &dwork->work;unsigned long flags; -int ret = false; +int ret;raw_spin_lock_irqsave (&worker->lock, flags);/* Do not bother with canceling when never queued. */ -if (!work->worker) +if (!work->worker) { + ret = false; goto fast_queue; + }/* Work must not be used with >1 worker, see kthread_queue_work() */ WARN_ON_ONCE (work->worker != worker);
@@ -1205,8 +1207,11 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker,* be used for reference counting. */ kthread_cancel_delayed_work_timer (work, &flags); -if (work->canceling) +if (work->canceling) { +/* The number of works in the queue does not change. */ + ret = true; goto out; + } ret =__kthread_cancel_work (work); fast_queue:
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 263/800 ia64: mca_drv: fix incorrect array size calculation
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit c5f320ff8a79501bb59338278336ec43acb9d7e2 ]
gcc points out a mistake in the mca driver that goes back to before the git history:
arch/ia64/kernel/mca_drv.c: In function 'init_record_index_pools':arch/ia64/kernel/mca_drv.c:346:54: error: expression does not compute the number of elements in this array; element typ e is 'int', not 'size_t' {aka 'long unsigned int'} [-Werror=sizeof-array-div]
346 | for (i = 1; i < sizeof sal_log_sect_min_sizes/sizeof(size_t); i++)
| ^
This is the same as sizeof(size_t), which is two shorter than the actual array. Use the ARRAY_SIZE() macro to get the correct calculation instead.
--- arch/ia64/kernel/mca_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/mca_drv.c +1 -1
@@ -343,7 +343,7 @@ init_record_index_pools(void)/* - 2 - */ sect_min_size = sal_log_sect_min_sizes[0 ]; -for (i =1 ; i <sizeof sal_log_sect_min_sizes/sizeof (size_t ); i++) +for (i =1 ; i <ARRAY_SIZE (sal_log_sect_min_sizes); i++)if (sect_min_size > sal_log_sect_min_sizes[i]) sect_min_size = sal_log_sect_min_sizes[i];
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 264/800 writeback, cgroup: increment isw_nr_in_flight before grabbing an inode
In reply to Greg Kroah-HartmanFrom: Roman Gushchin <[email protected]>
[ Upstream commit 8826ee4fe75051f8cbfa5d4a9aa70565938e724c ]
isw_nr_in_flight is used to determine whether the inode switch queue should be flushed from the umount path. Currently it's increased after grabbing an inode and even scheduling the switch work. It means the umount path can walk past cleanup_offline_cgwb() with active inode references, which can result in a "Busy inodes after unmount." message and use-after-free issues (with inode->i_sb which gets freed).
Fix it by incrementing isw_nr_in_flight before doing anything with the inode and decrementing in the case when switching wasn't scheduled.
The problem hasn't yet been seen in the real life and was discovered by Jan Kara by looking into the code.
--- fs/fs-writeback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/fs-writeback.c +3 -2
@@ -505,6 +505,8 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)if (!isw)return ; +atomic_inc (&isw_nr_in_flight); +/* find and pin the new wb */ rcu_read_lock (); memcg_css =css_from_id (new_wb_id, &memory_cgrp_subsys);
@@ -535,11 +537,10 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)* Let's continue after I_WB_SWITCH is guaranteed to be visible. */ call_rcu (&isw->rcu_head, inode_switch_wbs_rcu_fn); - -atomic_inc (&isw_nr_in_flight);return ; out_free: +atomic_dec (&isw_nr_in_flight);if (isw->new_wb)wb_put (isw->new_wb);kfree (isw);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 265/800 mm: define default MAX_PTRS_PER_* in include/pgtable.h
In reply to Greg Kroah-HartmanFrom: Daniel Axtens <[email protected]>
[ Upstream commit c0f8aa4fa815daacb6eca52cae04820d6aecb7c2 ]
Commit c65e774fb3f6 ("x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable") made PTRS_PER_P4D variable on x86 and introduced MAX_PTRS_PER_P4D as a constant for cases which need a compile-time constant (e.g. fixed-size arrays).
powerpc likewise has boot-time selectable MMU features which can cause other mm "constants" to vary. For KASAN, we have some static PTE/PMD/PUD/P4D arrays so we need compile-time maximums for all these constants. Extend the MAX_PTRS_PER_ idiom, and place default definitions in include/pgtable.h. These define MAX_PTRS_PER_x to be PTRS_PER_x unless an architecture has defined MAX_PTRS_PER_x in its arch headers.
Clean up pgtable-nop4d.h and s390's MAX_PTRS_PER_P4D definitions while we're at it: both can just pick up the default now.
--- arch/s390/include/asm/pgtable.h | 2 -- include/asm-generic/pgtable-nop4d.h | 1 - include/linux/pgtable.h | 22 ++++++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-)
arch/s390/include/asm/pgtable.h +0 -2
@@ -344,8 +344,6 @@ static inline int is_module_addr(void *addr)#define PTRS_PER_P4D _CRST_ENTRIES#define PTRS_PER_PGD _CRST_ENTRIES -#define MAX_PTRS_PER_P4D PTRS_PER_P4D -/* * Segment table and region3 table entry encoding * (R = read-only, I = invalid, y = young bit):
include/asm-generic/pgtable-nop4d.h +0 -1
@@ -9,7 +9,6 @@typedef struct {pgd_t pgd; }p4d_t ;#define P4D_SHIFT PGDIR_SHIFT -#define MAX_PTRS_PER_P4D 1#define PTRS_PER_P4D 1#define P4D_SIZE (1UL << P4D_SHIFT)#define P4D_MASK (~(P4D_SIZE-1))
include/linux/pgtable.h +22 -0
@@ -1592,4 +1592,26 @@ typedef unsigned int pgtbl_mod_mask;#define pte_leaf_size (x) PAGE_SIZE#endif +/* +* Some architectures have MMUs that are configurable or selectable at boot +* time. These lead to variable PTRS_PER_x. For statically allocated arrays it +* helps to have a static maximum value. +*/ + +#ifndef MAX_PTRS_PER_PTE +#define MAX_PTRS_PER_PTE PTRS_PER_PTE +#endif + +#ifndef MAX_PTRS_PER_PMD +#define MAX_PTRS_PER_PMD PTRS_PER_PMD +#endif + +#ifndef MAX_PTRS_PER_PUD +#define MAX_PTRS_PER_PUD PTRS_PER_PUD +#endif + +#ifndef MAX_PTRS_PER_P4D +#define MAX_PTRS_PER_P4D PTRS_PER_P4D +#endif +#endif /* _LINUX_PGTABLE_H */
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 266/800 kbuild: skip per-CPU BTF generation for pahole v1.18-v1.21
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit a0b8200d06ad6450c179407baa5f0f52f8cfcc97 ]
Commit "mm/page_alloc: convert per-cpu list protection to local_lock" will introduce a zero-sized per-CPU variable, which causes pahole to generate invalid BTF. Only pahole versions 1.18 through 1.21 are impacted, as before 1.18 pahole doesn't know anything about per-CPU variables, and 1.22 contains the proper fix for the issue.
Luckily, pahole 1.18 got --skip_encoding_btf_vars option disabling BTF generation for per-CPU variables in anticipation of some unanticipated problems. So use this escape hatch to disable per-CPU var BTF info on those problematic pahole versions. Users relying on availability of per-CPU var BTFs would need to upgrade to pahole 1.22+, but everyone won't notice any regressions.
--- scripts/link-vmlinux.sh | 4 ++++ 1 file changed, 4 insertions(+)
scripts/link-vmlinux.sh +4 -0
@@ -235,6 +235,10 @@ gen_btf() vmlinux_link ${1} + if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then + # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars + extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars" + fi if [ "${pahole_ver}" -ge "121" ]; then extra_paholeopt="${extra_paholeopt} --btf_gen_floats" fi
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 267/800 spi: Allow to have all native CSs in use along with GPIOs
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit dbaca8e56ea3f23fa215f48c2d46dd03ede06e02 ]
The commit 7d93aecdb58d ("spi: Add generic support for unused native cs with cs-gpios") excludes the valid case for the controllers that doesn't need to switch native CS in order to perform the transfer, i.e. when
0 native
... ...
<n> - 1 native
<n> GPIO
<n> + 1 GPIO
... ...
where <n> defines maximum of native CSs supported by the controller.
To allow this, bail out from spi_get_gpio_descs() conditionally for the controllers which explicitly marked with SPI_MASTER_GPIO_SS.
--- drivers/spi/spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi.c +3 -2
@@ -2623,8 +2623,9 @@ static int spi_get_gpio_descs(struct spi_controller *ctlr) } ctlr->unused_native_cs =ffz (native_cs_mask); -if (num_cs_gpios && ctlr->max_native_cs && - ctlr->unused_native_cs >= ctlr->max_native_cs) { + +if ((ctlr->flags &SPI_MASTER_GPIO_SS ) && num_cs_gpios && + ctlr->max_native_cs && ctlr->unused_native_cs >= ctlr->max_native_cs) {dev_err (dev,"No unused native chip select available\n" );return -EINVAL ; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 268/800 spi: Avoid undefined behaviour when counting unused native CSs
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit f60d7270c8a3d2beb1c23ae0da42497afa3584c2 ]
ffz(), that has been used to count unused native CSs, might cause undefined behaviour when called against ~0U. To fix that, open code it with ffs(~value) - 1.
--- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
@@ -2622,7 +2622,7 @@ static int spi_get_gpio_descs(struct spi_controller *ctlr) native_cs_mask |=BIT (i); } - ctlr->unused_native_cs =ffz (native_cs_mask); + ctlr->unused_native_cs =ffs (~native_cs_mask) -1 ;if ((ctlr->flags &SPI_MASTER_GPIO_SS ) && num_cs_gpios && ctlr->max_native_cs && ctlr->unused_native_cs >= ctlr->max_native_cs) {
Signature · 1 line
2.30.2