4.9.325-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainercover 4.9.325-rc1 review
This is the start of the stable review cycle for the 4.9.325 release. There are 26 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 29 Jul 2022 16:09:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.325-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.9.325-rc1
Jose Alonso <[email protected]>
net: usb: ax88179_178a needs FLAG_SEND_ZLP
Jiri Slaby <[email protected]>
tty: use new tty_insert_flip_string_and_push_buffer() in pty_write()
Jiri Slaby <[email protected]>
tty: extract tty_flip_buffer_commit() from tty_flip_buffer_push()
Jiri Slaby <[email protected]>
tty: drop tty_schedule_flip()
Jiri Slaby <[email protected]>
tty: the rest, stop using tty_schedule_flip()
Jiri Slaby <[email protected]>
tty: drivers/tty/, stop using tty_schedule_flip()
Takashi Iwai <[email protected]>
ALSA: memalloc: Align buffer allocations in page size
Eric Dumazet <[email protected]>
bpf: Make sure mac_header was set before using it
Wang Cheng <[email protected]>
mm/mempolicy: fix uninit-value in mpol_rebind_policy()
Jason A. Donenfeld <[email protected]>
Revert "Revert "char/random: silence a lockdep splat with printk()""
Hristo Venev <[email protected]>
be2net: Fix buffer overflow in be_get_module_eeprom
Kuniyuki Iwashima <[email protected]>
tcp: Fix a data-race around sysctl_tcp_notsent_lowat.
Kuniyuki Iwashima <[email protected]>
igmp: Fix a data-race around sysctl_igmp_max_memberships.
Kuniyuki Iwashima <[email protected]>
igmp: Fix data-races around sysctl_igmp_llm_reports.
Robert Hancock <[email protected]>
i2c: cadence: Change large transfer count reset logic to be unconditional
Kuniyuki Iwashima <[email protected]>
tcp: Fix a data-race around sysctl_tcp_probe_threshold.
Kuniyuki Iwashima <[email protected]>
tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept.
Kuniyuki Iwashima <[email protected]>
ip: Fix a data-race around sysctl_fwmark_reflect.
Peter Zijlstra <[email protected]>
perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()
Miaoqian Lin <[email protected]>
power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe
Hangyu Hua <[email protected]>
xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup()
Shuah Khan <[email protected]>
misc: rtsx_usb: set return value in rsp_buf alloc err path
Shuah Khan <[email protected]>
misc: rtsx_usb: use separate command and response buffers
Shuah Khan <[email protected]>
misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer
Demi Marie Obenour <[email protected]>
xen/gntdev: Ignore failure to unmap INVALID_GRANT_HANDLE
Stephen Smalley <[email protected]>
security,selinux,smack: kill security_task_wait hook
-------------
Diffstat:
Makefile | 4 +- arch/alpha/kernel/srmcons.c | 2 +- drivers/char/random.c | 4 +- drivers/i2c/busses/i2c-cadence.c | 30 ++---------- drivers/mfd/rtsx_usb.c | 27 +++++++---- drivers/net/ethernet/emulex/benet/be_cmds.c | 10 ++-- drivers/net/ethernet/emulex/benet/be_cmds.h | 2 +- drivers/net/ethernet/emulex/benet/be_ethtool.c | 31 +++++++----- drivers/net/usb/ax88179_178a.c | 14 +++--- drivers/power/reset/arm-versatile-reboot.c | 1 + drivers/s390/char/keyboard.h | 4 +- drivers/tty/cyclades.c | 6 +-- drivers/tty/goldfish.c | 2 +- drivers/tty/moxa.c | 4 +- drivers/tty/pty.c | 14 +----- drivers/tty/serial/lpc32xx_hs.c | 2 +- drivers/tty/tty_buffer.c | 66 +++++++++++++++++--------- drivers/tty/vt/keyboard.c | 6 +-- drivers/tty/vt/vt.c | 2 +- drivers/xen/gntdev.c | 3 +- include/linux/lsm_hooks.h | 7 --- include/linux/mfd/rtsx_usb.h | 2 - include/linux/security.h | 6 --- include/linux/tty_flip.h | 4 +- include/net/inet_sock.h | 3 +- include/net/ip.h | 2 +- include/net/tcp.h | 2 +- kernel/bpf/core.c | 8 ++-- kernel/events/core.c | 45 ++++++++++++------ kernel/exit.c | 19 +------- mm/mempolicy.c | 2 +- net/ipv4/igmp.c | 23 +++++---- net/ipv4/tcp_output.c | 2 +- net/xfrm/xfrm_policy.c | 5 +- security/security.c | 6 --- security/selinux/hooks.c | 6 --- security/smack/smack_lsm.c | 20 -------- sound/core/memalloc.c | 1 + 38 files changed, 189 insertions(+), 208 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/26 security,selinux,smack: kill security_task_wait hook
From: Stephen Smalley <[email protected]>
commit 3a2f5a59a695a73e0cde9a61e0feae5fa730e936 upstream.
As reported by yangshukui, a permission denial from security_task_wait() can lead to a soft lockup in zap_pid_ns_processes() since it only expects sys_wait4() to return 0 or -ECHILD. Further, security_task_wait() can in general lead to zombies; in the absence of some way to automatically reparent a child process upon a denial, the hook is not useful. Remove the security hook and its implementations in SELinux and Smack. Smack already removed its check from its hook.
--- include/linux/lsm_hooks.h | 7 ------- include/linux/security.h | 6 ------ kernel/exit.c | 19 ++----------------- security/security.c | 6 ------ security/selinux/hooks.c | 6 ------ security/smack/smack_lsm.c | 20 -------------------- 6 files changed, 2 insertions(+), 62 deletions(-)
include/linux/lsm_hooks.h +0 -7
@@ -666,11 +666,6 @@* @sig contains the signal value. * @secid contains the sid of the process where the signal originated * Return 0 if permission is granted. -* @task_wait: -* Check permission before allowing a process to reap a child process @p -* and collect its status information. -* @p contains the task_struct for process. -* Return 0 if permission is granted. * @task_prctl: * Check permission before performing a process control operation on the * current process.
@@ -1507,7 +1502,6 @@ union security_list_options {int (*task_movememory)(struct task_struct *p);int (*task_kill)(struct task_struct *p,struct siginfo *info,int sig,u32 secid); -int (*task_wait)(struct task_struct *p);int (*task_prctl)(int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5);void (*task_to_inode)(struct task_struct *p,struct inode *inode);
@@ -1768,7 +1762,6 @@ struct security_hook_heads {struct list_head task_getscheduler;struct list_head task_movememory;struct list_head task_kill; -struct list_head task_wait;struct list_head task_prctl;struct list_head task_to_inode;struct list_head ipc_permission;
include/linux/security.h +0 -6
@@ -332,7 +332,6 @@ int security_task_getscheduler(struct taint security_task_movememory (struct task_struct *p);int security_task_kill (struct task_struct *p,struct siginfo *info,int sig,u32 secid); -int security_task_wait (struct task_struct *p);int security_task_prctl (int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5);void security_task_to_inode (struct task_struct *p,struct inode *inode);
@@ -979,11 +978,6 @@ static inline int security_task_kill(str {return 0 ; } - -static inline int security_task_wait (struct task_struct *p) -{ -return 0 ; -} static inline int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
kernel/exit.c +2 -17
@@ -14,7 +14,6 @@#include <linux/tty.h> #include <linux/iocontext.h> #include <linux/key.h> -#include <linux/security.h> #include <linux/cpu.h> #include <linux/acct.h> #include <linux/tsacct_kern.h>
@@ -1342,7 +1341,7 @@ static int wait_task_continued(struct wa* Returns nonzero for a final return, when we have unlocked tasklist_lock. * Returns zero if the search for a child should continue; * then ->notask_error is 0 if @p is an eligible child, -* or another error from security_task_wait(), or still -ECHILD. +* or still -ECHILD. */ static int wait_consider_task (struct wait_opts *wo,int ptrace,struct task_struct *p)
@@ -1362,20 +1361,6 @@ static int wait_consider_task(struct waiif (!ret)return ret; - ret =security_task_wait (p); -if (unlikely (ret <0 )) { -/* -* If we have not yet seen any eligible child, -* then let this error code replace -ECHILD. -* A permission error will give the user a clue -* to look for security policy problems, rather -* than for mysterious wait bugs. -*/ -if (wo->notask_error) - wo->notask_error = ret; -return 0 ; - } -if (unlikely (exit_state ==EXIT_TRACE )) {/* * ptrace == 0 means we are the natural parent. In this case
@@ -1468,7 +1453,7 @@ static int wait_consider_task(struct wai* Returns nonzero for a final return, when we have unlocked tasklist_lock. * Returns zero if the search for a child should continue; then * ->notask_error is 0 if there were any eligible children, -* or another error from security_task_wait(), or still -ECHILD. +* or still -ECHILD. */ static int do_wait_thread (struct wait_opts *wo,struct task_struct *tsk) {
security/security.c +0 -6
@@ -1032,11 +1032,6 @@ int security_task_kill(struct task_strucreturn call_int_hook (task_kill,0 , p, info, sig, secid); } -int security_task_wait (struct task_struct *p) -{ -return call_int_hook (task_wait,0 , p); -} -int security_task_prctl (int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5) {
@@ -1776,7 +1771,6 @@ struct security_hook_heads security_hook .task_movememory = LIST_HEAD_INIT(security_hook_heads.task_movememory), .task_kill = LIST_HEAD_INIT(security_hook_heads.task_kill), - .task_wait = LIST_HEAD_INIT(security_hook_heads.task_wait), .task_prctl = LIST_HEAD_INIT(security_hook_heads.task_prctl), .task_to_inode = LIST_HEAD_INIT(security_hook_heads.task_to_inode),
security/selinux/hooks.c +0 -6
@@ -3951,11 +3951,6 @@ static int selinux_task_kill(struct taskreturn rc; } -static int selinux_task_wait (struct task_struct *p) -{ -return task_has_perm (p, current,PROCESS__SIGCHLD ); -} -static void selinux_task_to_inode (struct task_struct *p,struct inode *inode) {
@@ -6220,7 +6215,6 @@ static struct security_hook_list selinuxLSM_HOOK_INIT (task_getscheduler, selinux_task_getscheduler),LSM_HOOK_INIT (task_movememory, selinux_task_movememory),LSM_HOOK_INIT (task_kill, selinux_task_kill), -LSM_HOOK_INIT (task_wait, selinux_task_wait),LSM_HOOK_INIT (task_to_inode, selinux_task_to_inode), LSM_HOOK_INIT(ipc_permission, selinux_ipc_permission),
security/smack/smack_lsm.c +0 -20
@@ -2277,25 +2277,6 @@ static int smack_task_kill(struct task_s }/** -* smack_task_wait - Smack access check for waiting -* @p: task to wait for -* -* Returns 0 -*/ -static int smack_task_wait (struct task_struct *p) -{ -/* -* Allow the operation to succeed. -* Zombies are bad. -* In userless environments (e.g. phones) programs -* get marked with SMACK64EXEC and even if the parent -* and child shouldn't be talking the parent still -* may expect to know when the child exits. -*/ -return 0 ; -} - -/** * smack_task_to_inode - copy task smack into the inode blob * @p: task to copy from * @inode: inode to copy to
@@ -4686,7 +4667,6 @@ static struct security_hook_list smack_hLSM_HOOK_INIT (task_getscheduler, smack_task_getscheduler),LSM_HOOK_INIT (task_movememory, smack_task_movememory),LSM_HOOK_INIT (task_kill, smack_task_kill), -LSM_HOOK_INIT (task_wait, smack_task_wait),LSM_HOOK_INIT (task_to_inode, smack_task_to_inode), LSM_HOOK_INIT(ipc_permission, smack_ipc_permission),
Greg Kroah-Hartman
maintainerPATCH 2/26 xen/gntdev: Ignore failure to unmap INVALID_GRANT_HANDLE
In reply to Greg Kroah-HartmanFrom: Demi Marie Obenour <[email protected]>
commit 166d3863231667c4f64dee72b77d1102cdfad11f upstream.
The error paths of gntdev_mmap() can call unmap_grant_pages() even though not all of the pages have been successfully mapped. This will trigger the WARN_ON()s in __unmap_grant_pages_done(). The number of warnings can be very large; I have observed thousands of lines of warnings in the systemd journal.
Avoid this problem by only warning on unmapping failure if the handle being unmapped is not INVALID_GRANT_HANDLE. The handle field of any page that was not successfully mapped will be INVALID_GRANT_HANDLE, so this catches all cases where unmapping can legitimately fail.
--- drivers/xen/gntdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/xen/gntdev.c +2 -1
@@ -390,7 +390,8 @@ static void __unmap_grant_pages_done(intunsigned int offset = data->unmap_ops - map->unmap_ops;for (i =0 ; i < data->count; i++) { -WARN_ON (map->unmap_ops[offset+i].status); +WARN_ON (map->unmap_ops[offset+i].status && + map->unmap_ops[offset+i].handle !=-1 );pr_debug ("unmap handle=%d st=%d\n" , map->unmap_ops[offset+i].handle, map->unmap_ops[offset+i].status);
Greg Kroah-Hartman
maintainerPATCH 3/26 misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit eb7f8e28420372787933eec079735c35034bda7d ]
rtsx_usb driver allocates coherent dma buffer for urb transfers. This buffer is passed to usb_bulk_msg() and usb core tries to map already mapped buffer running into a dma mapping error.
xhci_hcd 0000:01:00.0: rejecting DMA map of vmalloc memory
WARNING: CPU: 1 PID: 279 at include/linux/dma-mapping.h:326 usb_ hcd_map_urb_for_dma+0x7d6/0x820
...
xhci_map_urb_for_dma+0x291/0x4e0 usb_hcd_submit_urb+0x199/0x12b0 ... usb_submit_urb+0x3b8/0x9e0 usb_start_wait_urb+0xe3/0x2d0 usb_bulk_msg+0x115/0x240 rtsx_usb_transfer_data+0x185/0x1a8 [rtsx_usb] rtsx_usb_send_cmd+0xbb/0x123 [rtsx_usb] rtsx_usb_write_register+0x12c/0x143 [rtsx_usb] rtsx_usb_probe+0x226/0x4b2 [rtsx_usb]
Fix it to use kmalloc() to get DMA-able memory region instead.
--- drivers/mfd/rtsx_usb.c | 13 +++++++------ include/linux/mfd/rtsx_usb.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/mfd/rtsx_usb.c +7 -6
@@ -642,8 +642,7 @@ static int rtsx_usb_probe(struct usb_interface *intf, ucr->pusb_dev = usb_dev; - ucr->iobuf =usb_alloc_coherent (ucr->pusb_dev,IOBUF_SIZE , -GFP_KERNEL , &ucr->iobuf_dma); + ucr->iobuf =kmalloc (IOBUF_SIZE ,GFP_KERNEL );if (!ucr->iobuf)return -ENOMEM ;
@@ -679,8 +678,9 @@ static int rtsx_usb_probe(struct usb_interface *intf, out_init_fail:usb_set_intfdata (ucr->pusb_intf,NULL ); -usb_free_coherent (ucr->pusb_dev,IOBUF_SIZE , ucr->iobuf, - ucr->iobuf_dma); +kfree (ucr->iobuf); + ucr->iobuf =NULL ; + ucr->cmd_buf = ucr->rsp_buf =NULL ;return ret; }
@@ -693,8 +693,9 @@ static void rtsx_usb_disconnect(struct usb_interface *intf)mfd_remove_devices (&intf->dev);usb_set_intfdata (ucr->pusb_intf,NULL ); -usb_free_coherent (ucr->pusb_dev,IOBUF_SIZE , ucr->iobuf, - ucr->iobuf_dma); +kfree (ucr->iobuf); + ucr->iobuf =NULL ; + ucr->cmd_buf = ucr->rsp_buf =NULL ; }#ifdef CONFIG_PM
include/linux/mfd/rtsx_usb.h +0 -1
@@ -66,7 +66,6 @@ struct rtsx_ucr {struct usb_interface *pusb_intf;struct usb_sg_request current_sg;unsigned char *iobuf; -dma_addr_t iobuf_dma;struct timer_list sg_timer;struct mutex dev_mutex;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 4/26 misc: rtsx_usb: use separate command and response buffers
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit 3776c78559853fd151be7c41e369fd076fb679d5 ]
rtsx_usb uses same buffer for command and response. There could be a potential conflict using the same buffer for both especially if retries and timeouts are involved.
Use separate command and response buffers to avoid conflicts.
--- drivers/mfd/rtsx_usb.c | 26 +++++++++++++++++--------- include/linux/mfd/rtsx_usb.h | 1 - 2 files changed, 17 insertions(+), 10 deletions(-)
drivers/mfd/rtsx_usb.c +17 -9
@@ -642,15 +642,18 @@ static int rtsx_usb_probe(struct usb_interface *intf, ucr->pusb_dev = usb_dev; - ucr->iobuf =kmalloc (IOBUF_SIZE ,GFP_KERNEL ); -if (!ucr->iobuf) + ucr->cmd_buf =kmalloc (IOBUF_SIZE ,GFP_KERNEL ); +if (!ucr->cmd_buf)return -ENOMEM ; + ucr->rsp_buf =kmalloc (IOBUF_SIZE ,GFP_KERNEL ); +if (!ucr->rsp_buf) + goto out_free_cmd_buf; +usb_set_intfdata (intf, ucr); ucr->vendor_id = id->idVendor; ucr->product_id = id->idProduct; - ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf;mutex_init (&ucr->dev_mutex);
@@ -678,9 +681,11 @@ static int rtsx_usb_probe(struct usb_interface *intf, out_init_fail:usb_set_intfdata (ucr->pusb_intf,NULL ); -kfree (ucr->iobuf); - ucr->iobuf =NULL ; - ucr->cmd_buf = ucr->rsp_buf =NULL ; +kfree (ucr->rsp_buf); + ucr->rsp_buf =NULL ; +out_free_cmd_buf: +kfree (ucr->cmd_buf); + ucr->cmd_buf =NULL ;return ret; }
@@ -693,9 +698,12 @@ static void rtsx_usb_disconnect(struct usb_interface *intf)mfd_remove_devices (&intf->dev);usb_set_intfdata (ucr->pusb_intf,NULL ); -kfree (ucr->iobuf); - ucr->iobuf =NULL ; - ucr->cmd_buf = ucr->rsp_buf =NULL ; + +kfree (ucr->cmd_buf); + ucr->cmd_buf =NULL ; + +kfree (ucr->rsp_buf); + ucr->rsp_buf =NULL ; }#ifdef CONFIG_PM
include/linux/mfd/rtsx_usb.h +0 -1
@@ -65,7 +65,6 @@ struct rtsx_ucr {struct usb_device *pusb_dev;struct usb_interface *pusb_intf;struct usb_sg_request current_sg; -unsigned char *iobuf;struct timer_list sg_timer;struct mutex dev_mutex;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 5/26 misc: rtsx_usb: set return value in rsp_buf alloc err path
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit 2cd37c2e72449a7add6da1183d20a6247d6db111 ]
Set return value in rsp_buf alloc error path before going to error handling.
drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!ucr->rsp_buf)
^~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_usb.c:678:9: note: uninitialized use occurs here
return ret;
^~~
drivers/misc/cardreader/rtsx_usb.c:639:2: note: remove the 'if' if its condition is always false
if (!ucr->rsp_buf)
^~~~~~~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_usb.c:622:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0--- drivers/mfd/rtsx_usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mfd/rtsx_usb.c +3 -1
@@ -647,8 +647,10 @@ static int rtsx_usb_probe(struct usb_interface *intf,return -ENOMEM ; ucr->rsp_buf =kmalloc (IOBUF_SIZE ,GFP_KERNEL ); -if (!ucr->rsp_buf) +if (!ucr->rsp_buf) { + ret = -ENOMEM ; goto out_free_cmd_buf; + }usb_set_intfdata (intf, ucr);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 6/26 xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup()
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit f85daf0e725358be78dfd208dea5fd665d8cb901 ]
xfrm_policy_lookup() will call xfrm_pol_hold_rcu() to get a refcount of pols[0]. This refcount can be dropped in xfrm_expand_policies() when xfrm_expand_policies() return error. pols[0]'s refcount is balanced in here. But xfrm_bundle_lookup() will also call xfrm_pols_put() with num_pols == 1 to drop this refcount when xfrm_expand_policies() return error.
This patch also fix an illegal address access. pols[0] will save a error point when xfrm_policy_lookup fails. This lead to xfrm_pols_put to resolve an illegal address in xfrm_bundle_lookup's error path.
Fix these by setting num_pols = 0 in xfrm_expand_policies()'s error path.
--- net/xfrm/xfrm_policy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/xfrm/xfrm_policy.c +4 -1
@@ -1819,8 +1819,10 @@ static int xfrm_expand_policies(const struct flowi *fl, u16 family, *num_xfrms =0 ;return 0 ; } -if (IS_ERR (pols[0 ])) +if (IS_ERR (pols[0 ])) { + *num_pols =0 ;return PTR_ERR (pols[0 ]); + } *num_xfrms = pols[0 ]->xfrm_nr;
@@ -1834,6 +1836,7 @@ static int xfrm_expand_policies(const struct flowi *fl, u16 family,if (pols[1 ]) {if (IS_ERR (pols[1 ])) {xfrm_pols_put (pols, *num_pols); + *num_pols =0 ;return PTR_ERR (pols[1 ]); } (*num_pols)++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 7/26 power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 80192eff64eee9b3bc0594a47381937b94b9d65a ]
of_find_matching_node_and_match() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.
--- drivers/power/reset/arm-versatile-reboot.c | 1 + 1 file changed, 1 insertion(+)
drivers/power/reset/arm-versatile-reboot.c +1 -0
@@ -150,6 +150,7 @@ static int __init versatile_reboot_probe(void) versatile_reboot_type = (enum versatile_reboot )reboot_id->data; syscon_regmap =syscon_node_to_regmap (np); +of_node_put (np);if (IS_ERR (syscon_regmap))return PTR_ERR (syscon_regmap);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 8/26 perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 68e3c69803dada336893640110cb87221bb01dcf ]
Yang Jihing reported a race between perf_event_set_output() and perf_mmap_close():
CPU1 CPU2 perf_mmap_close(e2) if (atomic_dec_and_test(&e2->rb->mmap_count)) // 1 - > 0 detach_rest = true ioctl(e1, IOC_SET_OUTPUT, e2) perf_event_set_output(e1, e2) ... list_for_each_entry_rcu(e, &e2->rb->event_list, rb_entry) ring_buffer_attach(e, NULL); // e1 isn't yet added and // therefore not detached ring_buffer_attach(e1, e2->rb) list_add_rcu(&e1->rb_entry, &e2->rb->event_list)
After this; e1 is attached to an unmapped rb and a subsequent perf_mmap() will loop forever more:
again:
mutex_lock(&e->mmap_mutex);
if (event->rb) {
...
if (!atomic_inc_not_zero(&e->rb->mmap_count)) {
...
mutex_unlock(&e->mmap_mutex);
goto again;
}
}The loop in perf_mmap_close() holds e2->mmap_mutex, while the attach in perf_event_set_output() holds e1->mmap_mutex. As such there is no serialization to avoid this race.
Change perf_event_set_output() to take both e1->mmap_mutex and e2->mmap_mutex to alleviate that problem. Additionally, have the loop in perf_mmap() detach the rb directly, this avoids having to wait for the concurrent perf_mmap_close() to get around to doing it to make progress.
--- kernel/events/core.c | 45 ++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-)
kernel/events/core.c +31 -14
@@ -5291,10 +5291,10 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)if (!atomic_inc_not_zero (&event->rb->mmap_count)) {/* -* Raced against perf_mmap_close() through -* perf_event_set_output(). Try again, hope for better -* luck. +* Raced against perf_mmap_close(); remove the +* event and try again. */ +ring_buffer_attach (event,NULL );mutex_unlock (&event->mmap_mutex); goto again; }
@@ -9542,14 +9542,25 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr, goto out; } +static void mutex_lock_double (struct mutex *a,struct mutex *b) +{ +if (b < a) +swap (a, b); + +mutex_lock (a); +mutex_lock_nested (b,SINGLE_DEPTH_NESTING ); +} +static int perf_event_set_output (struct perf_event *event,struct perf_event *output_event) {struct ring_buffer *rb =NULL ;int ret = -EINVAL ; -if (!output_event) +if (!output_event) { +mutex_lock (&event->mmap_mutex); goto set; + }/* don't allow circular references */ if (event == output_event)
@@ -9587,8 +9598,15 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event) event->pmu != output_event->pmu) goto out; +/* +* Hold both mmap_mutex to serialize against perf_mmap_close(). Since +* output_event is already on rb->event_list, and the list iteration +* restarts after every removal, it is guaranteed this new event is +* observed *OR* if output_event is already removed, it's guaranteed we +* observe !rb->mmap_count. +*/ +mutex_lock_double (&event->mmap_mutex, &output_event->mmap_mutex); set: -mutex_lock (&event->mmap_mutex);/* Can't redirect output if we've got an active mmap() */ if (atomic_read (&event->mmap_count)) goto unlock;
@@ -9598,6 +9616,12 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event) rb =ring_buffer_get (output_event);if (!rb) goto unlock; + +/* did we race against perf_mmap_close() */ +if (!atomic_read (&rb->mmap_count)) { +ring_buffer_put (rb); + goto unlock; + } }ring_buffer_attach (event, rb);
@@ -9605,20 +9629,13 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event) ret =0 ; unlock:mutex_unlock (&event->mmap_mutex); +if (output_event) +mutex_unlock (&output_event->mmap_mutex); out:return ret; } -static void mutex_lock_double (struct mutex *a,struct mutex *b) -{ -if (b < a) -swap (a, b); - -mutex_lock (a); -mutex_lock_nested (b,SINGLE_DEPTH_NESTING ); -} -static int perf_event_set_clock (struct perf_event *event,clockid_t clk_id) {bool nmi_safe = false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 9/26 ip: Fix a data-race around sysctl_fwmark_reflect.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 85d0b4dbd74b95cc492b1f4e34497d3f894f5d9a ]
While reading sysctl_fwmark_reflect, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- include/net/ip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/ip.h +1 -1
@@ -283,7 +283,7 @@ void ipfrag_init(void);void ip_static_sysctl_init (void );#define IP4_REPLY_MARK (net, mark) \ - ((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0) + (READ_ONCE((net)->ipv4.sysctl_fwmark_reflect) ? (mark) : 0)static inline bool ip_is_fragment (const struct iphdr *iph) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 10/26 tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 1a0008f9df59451d0a17806c1ee1a19857032fa8 ]
While reading sysctl_tcp_fwmark_accept, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- include/net/inet_sock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/net/inet_sock.h +2 -1
@@ -113,7 +113,8 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)static inline u32 inet_request_mark (const struct sock *sk,struct sk_buff *skb) { -if (!sk->sk_mark &&sock_net (sk)->ipv4.sysctl_tcp_fwmark_accept) +if (!sk->sk_mark && +READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_fwmark_accept))return skb->mark;return sk->sk_mark;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 11/26 tcp: Fix a data-race around sysctl_tcp_probe_threshold.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 92c0aa4175474483d6cf373314343d4e624e882a ]
While reading sysctl_tcp_probe_threshold, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
@@ -2005,7 +2005,7 @@ static int tcp_mtu_probe(struct sock *sk)* probing process by not resetting search range to its orignal. */ if (probe_size >tcp_mtu_to_mss (sk, icsk->icsk_mtup.search_high) || - interval < net->ipv4.sysctl_tcp_probe_threshold) { + interval <READ_ONCE (net->ipv4.sysctl_tcp_probe_threshold)) {/* Check whether enough time has elaplased for * another round of probing. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 12/26 i2c: cadence: Change large transfer count reset logic to be unconditional
In reply to Greg Kroah-HartmanFrom: Robert Hancock <[email protected]>
[ Upstream commit 4ca8ca873d454635c20d508261bfc0081af75cf8 ]
Problems were observed on the Xilinx ZynqMP platform with large I2C reads. When a read of 277 bytes was performed, the controller NAKed the transfer after only 252 bytes were transferred and returned an ENXIO error on the transfer.
There is some code in cdns_i2c_master_isr to handle this case by resetting the transfer count in the controller before it reaches 0, to allow larger transfers to work, but it was conditional on the CDNS_I2C_BROKEN_HOLD_BIT quirk being set on the controller, and ZynqMP uses the r1p14 version of the core where this quirk is not being set. The requirement to do this to support larger reads seems like an inherently required workaround due to the core only having an 8-bit transfer size register, so it does not appear that this should be conditional on the broken HOLD bit quirk which is used elsewhere in the driver.
Remove the dependency on the CDNS_I2C_BROKEN_HOLD_BIT for this transfer size reset logic to fix this problem.
--- drivers/i2c/busses/i2c-cadence.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-)
drivers/i2c/busses/i2c-cadence.c +5 -25
@@ -203,9 +203,9 @@ static inline bool cdns_is_holdquirk(struct cdns_i2c *id, bool hold_wrkaround)*/ static irqreturn_t cdns_i2c_isr (int irq,void *ptr) { -unsigned int isr_status, avail_bytes, updatetx; +unsigned int isr_status, avail_bytes;unsigned int bytes_to_send; -bool hold_quirk; +bool updatetx;struct cdns_i2c *id = ptr;/* Signal completion only after everything is updated */ int done_flag =0 ;
@@ -224,11 +224,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)* Check if transfer size register needs to be updated again for a * large data receive operation. */ - updatetx =0 ; -if (id->recv_count > id->curr_recv_count) - updatetx =1 ; - - hold_quirk = (id->quirks &CDNS_I2C_BROKEN_HOLD_BIT ) && updatetx; + updatetx = id->recv_count > id->curr_recv_count;/* When receiving, handle data interrupt and completion interrupt */ if (id->p_recv_buf &&
@@ -251,7 +247,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr) id->recv_count--; id->curr_recv_count--; -if (cdns_is_holdquirk (id, hold_quirk)) +if (cdns_is_holdquirk (id, updatetx))break ; }
@@ -262,7 +258,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)* maintain transfer size non-zero while performing a large * receive operation. */ -if (cdns_is_holdquirk (id, hold_quirk)) { +if (cdns_is_holdquirk (id, updatetx)) {/* wait while fifo is full */ while (cdns_i2c_readreg (CDNS_I2C_XFER_SIZE_OFFSET ) != (id->curr_recv_count -CDNS_I2C_FIFO_DEPTH ))
@@ -284,22 +280,6 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr) CDNS_I2C_XFER_SIZE_OFFSET); id->curr_recv_count = id->recv_count; } - }else if (id->recv_count && !hold_quirk && - !id->curr_recv_count) { - -/* Set the slave address in address register*/ -cdns_i2c_writereg (id->p_msg->addr &CDNS_I2C_ADDR_MASK , -CDNS_I2C_ADDR_OFFSET ); - -if (id->recv_count >CDNS_I2C_TRANSFER_SIZE ) { -cdns_i2c_writereg (CDNS_I2C_TRANSFER_SIZE , -CDNS_I2C_XFER_SIZE_OFFSET ); - id->curr_recv_count =CDNS_I2C_TRANSFER_SIZE ; - }else { -cdns_i2c_writereg (id->recv_count, -CDNS_I2C_XFER_SIZE_OFFSET ); - id->curr_recv_count = id->recv_count; - } }/* Clear hold (if not repeated start) and signal completion */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 13/26 igmp: Fix data-races around sysctl_igmp_llm_reports.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit f6da2267e71106474fbc0943dc24928b9cb79119 ]
While reading sysctl_igmp_llm_reports, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
This test can be packed into a helper, so such changes will be in the follow-up series after net is merged into net-next.
if (ipv4_is_local_multicast(pmc->multiaddr) &&
!READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
--- net/ipv4/igmp.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
net/ipv4/igmp.c +13 -8
@@ -474,7 +474,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,if (pmc->multiaddr ==IGMP_ALL_HOSTS )return skb; -if (ipv4_is_local_multicast (pmc->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) +if (ipv4_is_local_multicast (pmc->multiaddr) && + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))return skb; mtu =READ_ONCE (dev->mtu);
@@ -600,7 +601,7 @@ static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc)if (pmc->multiaddr ==IGMP_ALL_HOSTS )continue ;if (ipv4_is_local_multicast (pmc->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))continue ;spin_lock_bh (&pmc->lock);if (pmc->sfcount[MCAST_EXCLUDE ])
@@ -743,7 +744,8 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,if (type ==IGMPV3_HOST_MEMBERSHIP_REPORT )return igmpv3_send_report (in_dev, pmc); -if (ipv4_is_local_multicast (group) && !net->ipv4.sysctl_igmp_llm_reports) +if (ipv4_is_local_multicast (group) && + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))return 0 ;if (type ==IGMP_HOST_LEAVE_MESSAGE )
@@ -921,7 +923,8 @@ static bool igmp_heard_report(struct in_device *in_dev, __be32 group)if (group ==IGMP_ALL_HOSTS )return false; -if (ipv4_is_local_multicast (group) && !net->ipv4.sysctl_igmp_llm_reports) +if (ipv4_is_local_multicast (group) && + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))return false;rcu_read_lock ();
@@ -1031,7 +1034,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,if (im->multiaddr ==IGMP_ALL_HOSTS )continue ;if (ipv4_is_local_multicast (im->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))continue ;spin_lock_bh (&im->lock);if (im->tm_running)
@@ -1272,7 +1275,8 @@ static void igmp_group_dropped(struct ip_mc_list *im)#ifdef CONFIG_IP_MULTICAST if (im->multiaddr ==IGMP_ALL_HOSTS )return ; -if (ipv4_is_local_multicast (im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) +if (ipv4_is_local_multicast (im->multiaddr) && + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))return ; reporter = im->reporter;
@@ -1309,7 +1313,8 @@ static void igmp_group_added(struct ip_mc_list *im)#ifdef CONFIG_IP_MULTICAST if (im->multiaddr ==IGMP_ALL_HOSTS )return ; -if (ipv4_is_local_multicast (im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) +if (ipv4_is_local_multicast (im->multiaddr) && + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))return ;if (in_dev->dead)
@@ -1621,7 +1626,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev)if (im->multiaddr ==IGMP_ALL_HOSTS )continue ;if (ipv4_is_local_multicast (im->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE (net->ipv4.sysctl_igmp_llm_reports))continue ;/* a failover is happening and switches
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 14/26 igmp: Fix a data-race around sysctl_igmp_max_memberships.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 6305d821e3b9b5379d348528e5b5faf316383bc2 ]
While reading sysctl_igmp_max_memberships, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- net/ipv4/igmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/igmp.c +1 -1
@@ -2171,7 +2171,7 @@ int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr) count++; } err = -ENOBUFS ; -if (count >= net->ipv4.sysctl_igmp_max_memberships) +if (count >=READ_ONCE (net->ipv4.sysctl_igmp_max_memberships)) goto done; iml =sock_kmalloc (sk,sizeof (*iml),GFP_KERNEL );if (!iml)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 15/26 tcp: Fix a data-race around sysctl_tcp_notsent_lowat.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 55be873695ed8912eb77ff46d1d1cadf028bd0f3 ]
While reading sysctl_tcp_notsent_lowat, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- include/net/tcp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/tcp.h +1 -1
@@ -1788,7 +1788,7 @@ void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr);static inline u32 tcp_notsent_lowat (const struct tcp_sock *tp) {struct net *net =sock_net ((struct sock *)tp); -return tp->notsent_lowat ?: net->ipv4.sysctl_tcp_notsent_lowat; +return tp->notsent_lowat ?:READ_ONCE (net->ipv4.sysctl_tcp_notsent_lowat); }static inline bool tcp_stream_memory_free (const struct sock *sk)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 16/26 be2net: Fix buffer overflow in be_get_module_eeprom
In reply to Greg Kroah-HartmanFrom: Hristo Venev <[email protected]>
[ Upstream commit d7241f679a59cfe27f92cb5c6272cb429fb1f7ec ]
be_cmd_read_port_transceiver_data assumes that it is given a buffer that is at least PAGE_DATA_LEN long, or twice that if the module supports SFF 8472. However, this is not always the case.
Fix this by passing the desired offset and length to be_cmd_read_port_transceiver_data so that we only copy the bytes once.
--- drivers/net/ethernet/emulex/benet/be_cmds.c | 10 +++--- drivers/net/ethernet/emulex/benet/be_cmds.h | 2 +- .../net/ethernet/emulex/benet/be_ethtool.c | 31 ++++++++++++------- 3 files changed, 25 insertions(+), 18 deletions(-)
drivers/net/ethernet/emulex/benet/be_cmds.c +5 -5
@@ -2291,7 +2291,7 @@ int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state)/* Uses sync mcc */ int be_cmd_read_port_transceiver_data (struct be_adapter *adapter, -u8 page_num,u8 *data) +u8 page_num,u32 off,u32 len,u8 *data) {struct be_dma_mem cmd;struct be_mcc_wrb *wrb;
@@ -2325,10 +2325,10 @@ int be_cmd_read_port_transceiver_data(struct be_adapter *adapter, req->port =cpu_to_le32 (adapter->hba_port_num); req->page_num =cpu_to_le32 (page_num); status =be_mcc_notify_wait (adapter); -if (!status) { +if (!status && len >0 ) {struct be_cmd_resp_port_type *resp = cmd.va; -memcpy (data, resp->page_data,PAGE_DATA_LEN ); +memcpy (data, resp->page_data + off, len); } err:mutex_unlock (&adapter->mcc_lock);
@@ -2419,7 +2419,7 @@ int be_cmd_query_cable_type(struct be_adapter *adapter)int status; status =be_cmd_read_port_transceiver_data (adapter,TR_PAGE_A0 , - page_data); +0 ,PAGE_DATA_LEN , page_data);if (!status) {switch (adapter->phy.interface_type) {case PHY_TYPE_QSFP :
@@ -2444,7 +2444,7 @@ int be_cmd_query_sfp_info(struct be_adapter *adapter)int status; status =be_cmd_read_port_transceiver_data (adapter,TR_PAGE_A0 , - page_data); +0 ,PAGE_DATA_LEN , page_data);if (!status) {strlcpy (adapter->phy.vendor_name, page_data +SFP_VENDOR_NAME_OFFSET ,SFP_VENDOR_NAME_LEN -1 );
drivers/net/ethernet/emulex/benet/be_cmds.h +1 -1
@@ -2431,7 +2431,7 @@ int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, u8 beacon,int be_cmd_get_beacon_state (struct be_adapter *adapter,u8 port_num,u32 *state);int be_cmd_read_port_transceiver_data (struct be_adapter *adapter, -u8 page_num,u8 *data); +u8 page_num,u32 off,u32 len,u8 *data);int be_cmd_query_cable_type (struct be_adapter *adapter);int be_cmd_query_sfp_info (struct be_adapter *adapter); int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
drivers/net/ethernet/emulex/benet/be_ethtool.c +19 -12
@@ -1345,7 +1345,7 @@ static int be_get_module_info(struct net_device *netdev,return -EOPNOTSUPP ; status =be_cmd_read_port_transceiver_data (adapter,TR_PAGE_A0 , - page_data); +0 ,PAGE_DATA_LEN , page_data);if (!status) {if (!page_data[SFP_PLUS_SFF_8472_COMP ]) { modinfo->type =ETH_MODULE_SFF_8079 ;
@@ -1363,25 +1363,32 @@ static int be_get_module_eeprom(struct net_device *netdev, {struct be_adapter *adapter =netdev_priv (netdev);int status; +u32 begin, end;if (!check_privilege (adapter,MAX_PRIVILEGES ))return -EOPNOTSUPP ; - status =be_cmd_read_port_transceiver_data (adapter,TR_PAGE_A0 , - data); -if (status) - goto err; + begin = eeprom->offset; + end = eeprom->offset + eeprom->len; + +if (begin <PAGE_DATA_LEN ) { + status =be_cmd_read_port_transceiver_data (adapter,TR_PAGE_A0 , begin, +min_t (u32, end,PAGE_DATA_LEN ) - begin, + data); +if (status) + goto err; + + data +=PAGE_DATA_LEN - begin; + begin =PAGE_DATA_LEN ; + } -if (eeprom->offset + eeprom->len >PAGE_DATA_LEN ) { - status =be_cmd_read_port_transceiver_data (adapter, -TR_PAGE_A2 , - data + -PAGE_DATA_LEN ); +if (end >PAGE_DATA_LEN ) { + status =be_cmd_read_port_transceiver_data (adapter,TR_PAGE_A2 , + begin -PAGE_DATA_LEN , + end - begin, data);if (status) goto err; } -if (eeprom->offset) -memcpy (data, data + eeprom->offset, eeprom->len); err:return be_cmd_status (status); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 17/26 Revert "Revert "char/random: silence a lockdep splat with printk()""
In reply to Greg Kroah-HartmanFrom: "Jason A. Donenfeld" <[email protected]>
In 2019, Sergey fixed a lockdep splat with 15341b1dd409 ("char/random:
silence a lockdep splat with printk()"), but that got reverted soon after from 4.19 because back then it apparently caused various problems. But the issue it was fixing is still there, and more generally, many patches turning printk() into printk_deferred() have landed since, making me suspect it's okay to try this out again.
This should fix the following deadlock found by the kernel test robot:
[ 18.287691] WARNING: possible circular locking dependency detected
[ 18.287692] 4.19.248-00165-g3d1f971aa81f #1 Not tainted
[ 18.287693] ------------------------------------------------------
[ 18.287712] stop/202 is trying to acquire lock:
[ 18.287713] (ptrval) (console_owner){..-.}, at: console_unlock (??:?)
[ 18.287717]
[ 18.287718] but task is already holding lock:
[ 18.287718] (ptrval) (&(&port->lock)->rlock){-...}, at: pty_write (pty.c:?)
[ 18.287722]
[ 18.287722] which lock already depends on the new lock.
[ 18.287723]
[ 18.287724]
[ 18.287725] the existing dependency chain (in reverse order) is:
[ 18.287725]
[ 18.287726] -> #2 (&(&port->lock)->rlock){-...}:
[ 18.287729] validate_chain+0x84a/0xe00
[ 18.287729] __lock_acquire (lockdep.c:?)
[ 18.287730] lock_acquire (??:?)
[ 18.287731] _raw_spin_lock_irqsave (??:?)
[ 18.287732] tty_port_tty_get (??:?)
[ 18.287733] tty_port_default_wakeup (tty_port.c:?)
[ 18.287734] tty_port_tty_wakeup (??:?)
[ 18.287734] uart_write_wakeup (??:?)
[ 18.287735] serial8250_tx_chars (??:?)
[ 18.287736] serial8250_handle_irq (??:?)
[ 18.287737] serial8250_default_handle_irq (8250_port.c:?)
[ 18.287738] serial8250_interrupt (8250_core.c:?)
[ 18.287738] __handle_irq_event_percpu (??:?)
[ 18.287739] handle_irq_event_percpu (??:?)
[ 18.287740] handle_irq_event (??:?)
[ 18.287741] handle_edge_irq (??:?)
[ 18.287742] handle_irq (??:?)
[ 18.287742] do_IRQ (??:?)
[ 18.287743] common_interrupt (entry_32.o:?)
[ 18.287744] _raw_spin_unlock_irqrestore (??:?)
[ 18.287745] uart_write (serial_core.c:?)
[ 18.287746] process_output_block (n_tty.c:?)
[ 18.287747] n_tty_write (n_tty.c:?)
[ 18.287747] tty_write (tty_io.c:?)
[ 18.287748] __vfs_write (??:?)
[ 18.287749] vfs_write (??:?)
[ 18.287750] ksys_write (??:?)
[ 18.287750] sys_write (??:?)
[ 18.287751] do_fast_syscall_32 (??:?)
[ 18.287752] entry_SYSENTER_32 (??:?)
[ 18.287752]
[ 18.287753] -> #1 (&port_lock_key){-.-.}:
[ 18.287756]
[ 18.287756] -> #0 (console_owner){..-.}:
[ 18.287759] check_prevs_add (lockdep.c:?)
[ 18.287760] validate_chain+0x84a/0xe00
[ 18.287761] __lock_acquire (lockdep.c:?)
[ 18.287761] lock_acquire (??:?)
[ 18.287762] console_unlock (??:?)
[ 18.287763] vprintk_emit (??:?)
[ 18.287764] vprintk_default (??:?)
[ 18.287764] vprintk_func (??:?)
[ 18.287765] printk (??:?)
[ 18.287766] get_random_u32 (??:?)
[ 18.287767] shuffle_freelist (slub.c:?)
[ 18.287767] allocate_slab (slub.c:?)
[ 18.287768] new_slab (slub.c:?)
[ 18.287769] ___slab_alloc+0x6d0/0xb20
[ 18.287770] __slab_alloc+0xd6/0x2e0
[ 18.287770] __kmalloc (??:?)
[ 18.287771] tty_buffer_alloc (tty_buffer.c:?)
[ 18.287772] __tty_buffer_request_room (tty_buffer.c:?)
[ 18.287773] tty_insert_flip_string_fixed_flag (??:?)
[ 18.287774] pty_write (pty.c:?)
[ 18.287775] process_output_block (n_tty.c:?)
[ 18.287776] n_tty_write (n_tty.c:?)
[ 18.287777] tty_write (tty_io.c:?)
[ 18.287778] __vfs_write (??:?)
[ 18.287779] vfs_write (??:?)
[ 18.287780] ksys_write (??:?)
[ 18.287780] sys_write (??:?)
[ 18.287781] do_fast_syscall_32 (??:?)
[ 18.287782] entry_SYSENTER_32 (??:?)
[ 18.287783]
[ 18.287783] other info that might help us debug this:
[ 18.287784]
[ 18.287785] Chain exists of:
[ 18.287785] console_owner --> &port_lock_key --> &(&port->lock)->rlock
[ 18.287789]
[ 18.287790] Possible unsafe locking scenario:
[ 18.287790]
[ 18.287791] CPU0 CPU1
[ 18.287792] ---- ----
[ 18.287792] lock(&(&port->lock)->rlock);
[ 18.287794] lock(&port_lock_key);
[ 18.287814] lock(&(&port->lock)->rlock);
[ 18.287815] lock(console_owner);
[ 18.287817]
[ 18.287818] *** DEADLOCK ***
[ 18.287818]
[ 18.287819] 6 locks held by stop/202:
[ 18.287820] #0: (ptrval) (&tty->ldisc_sem){++++}, at: ldsem_down_read (??:?)
[ 18.287823] #1: (ptrval) (&tty->atomic_write_lock){+.+.}, at: tty_write_lock (tty_io.c:?)
[ 18.287826] #2: (ptrval) (&o_tty->termios_rwsem/1){++++}, at: n_tty_write (n_tty.c:?)
[ 18.287830] #3: (ptrval) (&ldata->output_lock){+.+.}, at: process_output_block (n_tty.c:?)
[ 18.287834] #4: (ptrval) (&(&port->lock)->rlock){-...}, at: pty_write (pty.c:?)
[ 18.287838] #5: (ptrval) (console_lock){+.+.}, at: console_trylock_spinning (printk.c:?)
[ 18.287841]
[ 18.287842] stack backtrace:
[ 18.287843] CPU: 0 PID: 202 Comm: stop Not tainted 4.19.248-00165-g3d1f971aa81f #1
[ 18.287843] Call Trace:
[ 18.287844] dump_stack (??:?)
[ 18.287845] print_circular_bug.cold+0x78/0x8b
[ 18.287846] check_prev_add+0x66a/0xd20
[ 18.287847] check_prevs_add (lockdep.c:?)
[ 18.287848] validate_chain+0x84a/0xe00
[ 18.287848] __lock_acquire (lockdep.c:?)
[ 18.287849] lock_acquire (??:?)
[ 18.287850] ? console_unlock (??:?)
[ 18.287851] console_unlock (??:?)
[ 18.287851] ? console_unlock (??:?)
[ 18.287852] ? native_save_fl (??:?)
[ 18.287853] vprintk_emit (??:?)
[ 18.287854] vprintk_default (??:?)
[ 18.287855] vprintk_func (??:?)
[ 18.287855] printk (??:?)
[ 18.287856] get_random_u32 (??:?)
[ 18.287857] ? shuffle_freelist (slub.c:?)
[ 18.287858] shuffle_freelist (slub.c:?)
[ 18.287858] ? page_address (??:?)
[ 18.287859] allocate_slab (slub.c:?)
[ 18.287860] new_slab (slub.c:?)
[ 18.287861] ? pvclock_clocksource_read (??:?)
[ 18.287862] ___slab_alloc+0x6d0/0xb20
[ 18.287862] ? kvm_sched_clock_read (kvmclock.c:?)
[ 18.287863] ? __slab_alloc+0xbc/0x2e0
[ 18.287864] ? native_wbinvd (paravirt.c:?)
[ 18.287865] __slab_alloc+0xd6/0x2e0
[ 18.287865] __kmalloc (??:?)
[ 18.287866] ? __lock_acquire (lockdep.c:?)
[ 18.287867] ? tty_buffer_alloc (tty_buffer.c:?)
[ 18.287868] tty_buffer_alloc (tty_buffer.c:?)
[ 18.287869] __tty_buffer_request_room (tty_buffer.c:?)
[ 18.287869] tty_insert_flip_string_fixed_flag (??:?)
[ 18.287870] pty_write (pty.c:?)
[ 18.287871] process_output_block (n_tty.c:?)
[ 18.287872] n_tty_write (n_tty.c:?)
[ 18.287873] ? print_dl_stats (??:?)
[ 18.287874] ? n_tty_ioctl (n_tty.c:?)
[ 18.287874] tty_write (tty_io.c:?)
[ 18.287875] ? n_tty_ioctl (n_tty.c:?)
[ 18.287876] ? tty_write_unlock (tty_io.c:?)
[ 18.287877] __vfs_write (??:?)
[ 18.287877] vfs_write (??:?)
[ 18.287878] ? __fget_light (file.c:?)
[ 18.287879] ksys_write (??:?)--- drivers/char/random.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/random.c +2 -2
@@ -184,8 +184,8 @@ static void __cold process_random_ready_#define warn_unseeded_randomness () \ if (IS_ENABLED(CONFIG_WARN_ALL_UNSEEDED_RANDOM) && !crng_ready()) \ - pr_notice("%s called from %pS with crng_init=%d\n", \ - __func__, (void *)_RET_IP_, crng_init) + printk_deferred(KERN_NOTICE "random: %s called from %pS with crng_init=%d\n", \ + __func__, (void *)_RET_IP_, crng_init)/*********************************************************************
Greg Kroah-Hartman
maintainerPATCH 18/26 mm/mempolicy: fix uninit-value in mpol_rebind_policy()
In reply to Greg Kroah-HartmanFrom: Wang Cheng <[email protected]>
commit 018160ad314d75b1409129b2247b614a9f35894c upstream.
mpol_set_nodemask()(mm/mempolicy.c) does not set up nodemask when pol->mode is MPOL_LOCAL. Check pol->mode before access pol->w.cpuset_mems_allowed in mpol_rebind_policy()(mm/mempolicy.c).
BUG: KMSAN: uninit-value in mpol_rebind_policy mm/mempolicy.c:352 [inline] BUG: KMSAN: uninit-value in mpol_rebind_task+0x2ac/0x2c0 mm/mempolicy.c:368 mpol_rebind_policy mm/mempolicy.c:352 [inline] mpol_rebind_task+0x2ac/0x2c0 mm/mempolicy.c:368 cpuset_change_task_nodemask kernel/cgroup/cpuset.c:1711 [inline] cpuset_attach+0x787/0x15e0 kernel/cgroup/cpuset.c:2278 cgroup_migrate_execute+0x1023/0x1d20 kernel/cgroup/cgroup.c:2515 cgroup_migrate kernel/cgroup/cgroup.c:2771 [inline] cgroup_attach_task+0x540/0x8b0 kernel/cgroup/cgroup.c:2804 __cgroup1_procs_write+0x5cc/0x7a0 kernel/cgroup/cgroup-v1.c:520 cgroup1_tasks_write+0x94/0xb0 kernel/cgroup/cgroup-v1.c:539 cgroup_file_write+0x4c2/0x9e0 kernel/cgroup/cgroup.c:3852 kernfs_fop_write_iter+0x66a/0x9f0 fs/kernfs/file.c:296 call_write_iter include/linux/fs.h:2162 [inline] new_sync_write fs/read_write.c:503 [inline] vfs_write+0x1318/0x2030 fs/read_write.c:590 ksys_write+0x28b/0x510 fs/read_write.c:643 __do_sys_write fs/read_write.c:655 [inline] __se_sys_write fs/read_write.c:652 [inline] __x64_sys_write+0xdb/0x120 fs/read_write.c:652 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x44/0xae
Uninit was created at:
slab_post_alloc_hook mm/slab.h:524 [inline] slab_alloc_node mm/slub.c:3251 [inline] slab_alloc mm/slub.c:3259 [inline] kmem_cache_alloc+0x902/0x11c0 mm/slub.c:3264 mpol_new mm/mempolicy.c:293 [inline] do_set_mempolicy+0x421/0xb70 mm/mempolicy.c:853 kernel_set_mempolicy mm/mempolicy.c:1504 [inline] __do_sys_set_mempolicy mm/mempolicy.c:1510 [inline] __se_sys_set_mempolicy+0x44c/0xb60 mm/mempolicy.c:1507 __x64_sys_set_mempolicy+0xd8/0x110 mm/mempolicy.c:1507 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x44/0xae
KMSAN: uninit-value in mpol_rebind_task (2)
https://syzkaller.appspot.com/bug?id=d6eb90f952c2a5de9ea718a1b873c55cb13b59dc
This patch seems to fix below bug too.
KMSAN: uninit-value in mpol_rebind_mm (2)
https://syzkaller.appspot.com/bug?id=f2fecd0d7013f54ec4162f60743a2b28df40926b
The uninit-value is pol->w.cpuset_mems_allowed in mpol_rebind_policy(). When syzkaller reproducer runs to the beginning of mpol_new(),
mpol_new() mm/mempolicy.c
do_mbind() mm/mempolicy.c
kernel_mbind() mm/mempolicy.c
mode is 1(MPOL_PREFERRED), nodes_empty(*nodes) is true and flags is 0. Then
mode = MPOL_LOCAL; ... policy->mode = mode; policy->flags = flags;
will be executed. So in mpol_set_nodemask(),
mpol_set_nodemask() mm/mempolicy.c do_mbind() kernel_mbind()
pol->mode is 4 (MPOL_LOCAL), that nodemask in pol is not initialized, which will be accessed in mpol_rebind_policy().
--- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mempolicy.c +1 -1
@@ -396,7 +396,7 @@ static void mpol_rebind_preferred(structstatic void mpol_rebind_policy (struct mempolicy *pol,const nodemask_t *newmask,enum mpol_rebind_step step) { -if (!pol) +if (!pol || pol->mode ==MPOL_LOCAL )return ;if (!mpol_store_user_nodemask (pol) && step ==MPOL_REBIND_ONCE &&nodes_equal (pol->w.cpuset_mems_allowed, *newmask))
Greg Kroah-Hartman
maintainerPATCH 19/26 bpf: Make sure mac_header was set before using it
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit 0326195f523a549e0a9d7fd44c70b26fd7265090 upstream.
Classic BPF has a way to load bytes starting from the mac header.
Some skbs do not have a mac header, and skb_mac_header() in this case is returning a pointer that 65535 bytes after skb->head.
Existing range check in bpf_internal_load_pointer_neg_helper() was properly kicking and no illegal access was happening.
New sanity check in skb_mac_header() is firing, so we need to avoid it.
WARNING: CPU: 1 PID: 28990 at include/linux/skbuff.h:2785 skb_mac_header include/linux/skbuff.h:2785 [inline] WARNING: CPU: 1 PID: 28990 at include/linux/skbuff.h:2785 bpf_internal_load_pointer_neg_helper+0x1b1/0x1c0 kernel/bpf/core.c:74 Modules linked in: CPU: 1 PID: 28990 Comm: syz-executor.0 Not tainted 5.19.0-rc4-syzkaller-00865-g4874fb9484be #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022 RIP: 0010:skb_mac_header include/linux/skbuff.h:2785 [inline] RIP: 0010:bpf_internal_load_pointer_neg_helper+0x1b1/0x1c0 kernel/bpf/core.c:74 Code: ff ff 45 31 f6 e9 5a ff ff ff e8 aa 27 40 00 e9 3b ff ff ff e8 90 27 40 00 e9 df fe ff ff e8 86 27 40 00 eb 9e e8 2f 2c f3 ff <0f> 0b eb b1 e8 96 27 40 00 e9 79 fe ff ff 90 41 57 41 56 41 55 41 RSP: 0018:ffffc9000309f668 EFLAGS: 00010216 RAX: 0000000000000118 RBX: ffffffffffeff00c RCX: ffffc9000e417000 RDX: 0000000000040000 RSI: ffffffff81873f21 RDI: 0000000000000003 RBP: ffff8880842878c0 R08: 0000000000000003 R09: 000000000000ffff R10: 000000000000ffff R11: 0000000000000001 R12: 0000000000000004 R13: ffff88803ac56c00 R14: 000000000000ffff R15: dffffc0000000000 FS: 00007f5c88a16700(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fdaa9f6c058 CR3: 000000003a82c000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> ____bpf_skb_load_helper_32 net/core/filter.c:276 [inline] bpf_skb_load_helper_32+0x191/0x220 net/core/filter.c:264
--- kernel/bpf/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/bpf/core.c +5 -3
@@ -60,11 +60,13 @@ void *bpf_internal_load_pointer_neg_help {u8 *ptr =NULL ; -if (k >=SKF_NET_OFF ) +if (k >=SKF_NET_OFF ) { ptr =skb_network_header (skb) + k -SKF_NET_OFF ; -else if (k >=SKF_LL_OFF ) + }else if (k >=SKF_LL_OFF ) { +if (unlikely (!skb_mac_header_was_set (skb))) +return NULL ; ptr =skb_mac_header (skb) + k -SKF_LL_OFF ; - + }if (ptr >= skb->head && ptr + size <=skb_tail_pointer (skb))return ptr;
Greg Kroah-Hartman
maintainerPATCH 20/26 ALSA: memalloc: Align buffer allocations in page size
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 5c1733e33c888a3cb7f576564d8ad543d5ad4a9e upstream.
Currently the standard memory allocator (snd_dma_malloc_pages*()) passes the byte size to allocate as is. Most of the backends allocates real pages, hence the actual allocations are aligned in page size. However, the genalloc doesn't seem assuring the size alignment, hence it may result in the access outside the buffer when the whole memory pages are exposed via mmap.
For avoiding such inconsistencies, this patch makes the allocation size always to be aligned in page size.
Note that, after this change, snd_dma_buffer.bytes field contains the aligned size, not the originally requested size. This value is also used for releasing the pages in return.
--- sound/core/memalloc.c | 1 + 1 file changed, 1 insertion(+)
sound/core/memalloc.c +1 -0
@@ -177,6 +177,7 @@ int snd_dma_alloc_pages(int type, structif (WARN_ON (!dmab))return -ENXIO ; + size =PAGE_ALIGN (size); dmab->dev.type = type; dmab->dev.dev = device; dmab->bytes =0 ;
Greg Kroah-Hartman
maintainerPATCH 21/26 tty: drivers/tty/, stop using tty_schedule_flip()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit 5f6a85158ccacc3f09744b3aafe8b11ab3b6c6f6 upstream.
Since commit a9c3f68f3cd8d (tty: Fix low_latency BUG) in 2014, tty_flip_buffer_push() is only a wrapper to tty_schedule_flip(). We are going to remove the latter (as it is used less), so call the former in drivers/tty/.
--- drivers/tty/cyclades.c | 6 +++--- drivers/tty/goldfish.c | 2 +- drivers/tty/moxa.c | 4 ++-- drivers/tty/serial/lpc32xx_hs.c | 2 +- drivers/tty/vt/keyboard.c | 6 +++--- drivers/tty/vt/vt.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)
drivers/tty/cyclades.c +3 -3
@@ -556,7 +556,7 @@ static void cyy_chip_rx(struct cyclades_ } info->idle_stats.recv_idle = jiffies; } -tty_schedule_flip (port); +tty_flip_buffer_push (port);/* end of service */ cyy_writeb (info, CyRIR, save_xir &0x3f );
@@ -998,7 +998,7 @@ static void cyz_handle_rx(struct cyclade jiffies + 1);#endif info->idle_stats.recv_idle = jiffies; -tty_schedule_flip (&info->port); +tty_flip_buffer_push (&info->port);/* Update rx_get */ cy_writel (&buf_ctrl->rx_get, new_rx_get);
@@ -1174,7 +1174,7 @@ static void cyz_handle_cmd(struct cycladif (delta_count)wake_up_interruptible (&info->port.delta_msr_wait);if (special_count) -tty_schedule_flip (&info->port); +tty_flip_buffer_push (&info->port); } }
drivers/tty/goldfish.c +1 -1
@@ -85,7 +85,7 @@ static irqreturn_t goldfish_tty_interrupwritel (count, base +GOLDFISH_TTY_DATA_LEN );writel (GOLDFISH_TTY_CMD_READ_BUFFER , base +GOLDFISH_TTY_CMD );spin_unlock_irqrestore (&qtty->lock, irq_flags); -tty_schedule_flip (&qtty->port); +tty_flip_buffer_push (&qtty->port);return IRQ_HANDLED ; }
drivers/tty/moxa.c +2 -2
@@ -1397,7 +1397,7 @@ static int moxa_poll_port(struct moxa_poif (inited && !tty_throttled (tty) &&MoxaPortRxQueue (p) >0 ) {/* RX */ MoxaPortReadData (p); -tty_schedule_flip (&p->port); +tty_flip_buffer_push (&p->port); } }else {clear_bit (EMPTYWAIT , &p->statusflags);
@@ -1422,7 +1422,7 @@ static int moxa_poll_port(struct moxa_poif (tty && (intr & IntrBreak) && !I_IGNBRK (tty)) {/* BREAK */ tty_insert_flip_char (&p->port,0 ,TTY_BREAK ); -tty_schedule_flip (&p->port); +tty_flip_buffer_push (&p->port); }if (intr & IntrLine)
drivers/tty/serial/lpc32xx_hs.c +1 -1
@@ -350,7 +350,7 @@ static irqreturn_t serial_lpc32xx_interr LPC32XX_HSUART_IIR(port->membase)); port->icount.overrun++;tty_insert_flip_char (tport,0 ,TTY_OVERRUN ); -tty_schedule_flip (tport); +tty_flip_buffer_push (tport); }/* Data received? */
drivers/tty/vt/keyboard.c +3 -3
@@ -308,7 +308,7 @@ int kbd_rate(struct kbd_repeat *rpt)static void put_queue (struct vc_data *vc,int ch) {tty_insert_flip_char (&vc->port, ch,0 ); -tty_schedule_flip (&vc->port); +tty_flip_buffer_push (&vc->port); }static void puts_queue (struct vc_data *vc,char *cp)
@@ -317,7 +317,7 @@ static void puts_queue(struct vc_data *vtty_insert_flip_char (&vc->port, *cp,0 ); cp++; } -tty_schedule_flip (&vc->port); +tty_flip_buffer_push (&vc->port); }static void applkey (struct vc_data *vc,int key,char mode)
@@ -562,7 +562,7 @@ static void fn_inc_console(struct vc_datstatic void fn_send_intr (struct vc_data *vc) {tty_insert_flip_char (&vc->port,0 ,TTY_BREAK ); -tty_schedule_flip (&vc->port); +tty_flip_buffer_push (&vc->port); }static void fn_scroll_forw (struct vc_data *vc)
drivers/tty/vt/vt.c +1 -1
@@ -1484,7 +1484,7 @@ static void respond_string(const char *ptty_insert_flip_char (port, *p,0 ); p++; } -tty_schedule_flip (port); +tty_flip_buffer_push (port); }static void cursor_report (struct vc_data *vc,struct tty_struct *tty)
Greg Kroah-Hartman
maintainerPATCH 22/26 tty: the rest, stop using tty_schedule_flip()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit b68b914494df4f79b4e9b58953110574af1cb7a2 upstream.
Since commit a9c3f68f3cd8d (tty: Fix low_latency BUG) in 2014, tty_flip_buffer_push() is only a wrapper to tty_schedule_flip(). We are going to remove the latter (as it is used less), so call the former in the rest of the users.
--- arch/alpha/kernel/srmcons.c | 2 +- drivers/s390/char/keyboard.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/alpha/kernel/srmcons.c +1 -1
@@ -58,7 +58,7 @@ srmcons_do_receive_chars(struct tty_port }while ((result.bits.status &1 ) && (++loops <10 ));if (count) -tty_schedule_flip (port); +tty_flip_buffer_push (port);return count; }
drivers/s390/char/keyboard.h +2 -2
@@ -44,7 +44,7 @@ static inline void kbd_put_queue(struct tty_port *port, int ch) { tty_insert_flip_char(port, ch, 0); -tty_schedule_flip (port); +tty_flip_buffer_push (port); } static inline void
@@ -52,5 +52,5 @@ kbd_puts_queue(struct tty_port *port, ch {while (*cp)tty_insert_flip_char (port, *cp++,0 ); -tty_schedule_flip (port); +tty_flip_buffer_push (port); }
Greg Kroah-Hartman
maintainerPATCH 23/26 tty: drop tty_schedule_flip()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit 5db96ef23bda6c2a61a51693c85b78b52d03f654 upstream.
Since commit a9c3f68f3cd8d (tty: Fix low_latency BUG) in 2014, tty_flip_buffer_push() is only a wrapper to tty_schedule_flip(). All users were converted in the previous patches, so remove tty_schedule_flip() completely while inlining its body into tty_flip_buffer_push().
One less exported function.
--- drivers/tty/tty_buffer.c | 30 ++++++++---------------------- include/linux/tty_flip.h | 1 - 2 files changed, 8 insertions(+), 23 deletions(-)
drivers/tty/tty_buffer.c +8 -22
@@ -389,27 +389,6 @@ int __tty_insert_flip_char(struct tty_poEXPORT_SYMBOL (__tty_insert_flip_char);/** -* tty_schedule_flip - push characters to ldisc -* @port: tty port to push from -* -* Takes any pending buffers and transfers their ownership to the -* ldisc side of the queue. It then schedules those characters for -* processing by the line discipline. -*/ - -void tty_schedule_flip (struct tty_port *port) -{ -struct tty_bufhead *buf = &port->buf; - -/* paired w/ acquire in flush_to_ldisc(); ensures -* flush_to_ldisc() sees buffer data. -*/ -smp_store_release (&buf->tail->commit, buf->tail->used); -queue_work (system_unbound_wq, &buf->work); -} -EXPORT_SYMBOL (tty_schedule_flip); - -/** * tty_prepare_flip_string - make room for characters * @port: tty port * @chars: return pointer for character write area
@@ -560,7 +539,14 @@ static void flush_to_ldisc(struct work_svoid tty_flip_buffer_push (struct tty_port *port) { -tty_schedule_flip (port); +struct tty_bufhead *buf = &port->buf; + +/* +* Paired w/ acquire in flush_to_ldisc(); ensures flush_to_ldisc() sees +* buffer data. +*/ +smp_store_release (&buf->tail->commit, buf->tail->used); +queue_work (system_unbound_wq, &buf->work); }EXPORT_SYMBOL (tty_flip_buffer_push);
include/linux/tty_flip.h +0 -1
@@ -11,7 +11,6 @@ extern int tty_insert_flip_string_fixed_extern int tty_prepare_flip_string (struct tty_port *port,unsigned char **chars,size_t size);extern void tty_flip_buffer_push (struct tty_port *port); -void tty_schedule_flip (struct tty_port *port);int __tty_insert_flip_char (struct tty_port *port,unsigned char ch,char flag); static inline int tty_insert_flip_char(struct tty_port *port,
Greg Kroah-Hartman
maintainerPATCH 24/26 tty: extract tty_flip_buffer_commit() from tty_flip_buffer_push()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit 716b10580283fda66f2b88140e3964f8a7f9da89 upstream.
We will need this new helper in the next patch.
--- drivers/tty/tty_buffer.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/tty/tty_buffer.c +10 -5
@@ -526,6 +526,15 @@ static void flush_to_ldisc(struct work_stty_ldisc_deref (disc); } +static inline void tty_flip_buffer_commit (struct tty_buffer *tail) +{ +/* +* Paired w/ acquire in flush_to_ldisc(); ensures flush_to_ldisc() sees +* buffer data. +*/ +smp_store_release (&tail->commit, tail->used); +} +/** * tty_flip_buffer_push - terminal * @port: tty port to push
@@ -541,11 +550,7 @@ void tty_flip_buffer_push(struct tty_por {struct tty_bufhead *buf = &port->buf; -/* -* Paired w/ acquire in flush_to_ldisc(); ensures flush_to_ldisc() sees -* buffer data. -*/ -smp_store_release (&buf->tail->commit, buf->tail->used); +tty_flip_buffer_commit (buf->tail);queue_work (system_unbound_wq, &buf->work); }EXPORT_SYMBOL (tty_flip_buffer_push);
Greg Kroah-Hartman
maintainerPATCH 25/26 tty: use new tty_insert_flip_string_and_push_buffer() in pty_write()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit a501ab75e7624d133a5a3c7ec010687c8b961d23 upstream.
There is a race in pty_write(). pty_write() can be called in parallel with e.g. ioctl(TIOCSTI) or ioctl(TCXONC) which also inserts chars to the buffer. Provided, tty_flip_buffer_push() in pty_write() is called outside the lock, it can commit inconsistent tail. This can lead to out of bounds writes and other issues. See the Link below.
To fix this, we have to introduce a new helper called tty_insert_flip_string_and_push_buffer(). It does both tty_insert_flip_string() and tty_flip_buffer_commit() under the port lock. It also calls queue_work(), but outside the lock. See 71a174b39f10 (pty: do tty_flip_buffer_push without port->lock in pty_write) for the reasons.
Keep the helper internal-only (in drivers' tty.h). It is not intended to be used widely.
--- drivers/tty/pty.c | 14 ++------------ drivers/tty/tty_buffer.c | 31 +++++++++++++++++++++++++++++++ include/linux/tty_flip.h | 3 +++ 3 files changed, 36 insertions(+), 12 deletions(-)
drivers/tty/pty.c +2 -12
@@ -106,21 +106,11 @@ static void pty_unthrottle(struct tty_ststatic int pty_write (struct tty_struct *tty,const unsigned char *buf,int c) {struct tty_struct *to = tty->link; -unsigned long flags; -if (tty->stopped) +if (tty->stopped || !c)return 0 ; -if (c >0 ) { -spin_lock_irqsave (&to->port->lock, flags); -/* Stuff the data into the input queue of the other end */ - c =tty_insert_flip_string (to->port, buf, c); -spin_unlock_irqrestore (&to->port->lock, flags); -/* And shovel */ -if (c) -tty_flip_buffer_push (to->port); - } -return c; +return tty_insert_flip_string_and_push_buffer (to->port, buf, c); }/**
drivers/tty/tty_buffer.c +31 -0
@@ -556,6 +556,37 @@ void tty_flip_buffer_push(struct tty_porEXPORT_SYMBOL (tty_flip_buffer_push);/** +* tty_insert_flip_string_and_push_buffer - add characters to the tty buffer and +* push +* @port: tty port +* @chars: characters +* @size: size +* +* The function combines tty_insert_flip_string() and tty_flip_buffer_push() +* with the exception of properly holding the @port->lock. +* +* To be used only internally (by pty currently). +* +* Returns: the number added. +*/ +int tty_insert_flip_string_and_push_buffer (struct tty_port *port, +const unsigned char *chars,size_t size) +{ +struct tty_bufhead *buf = &port->buf; +unsigned long flags; + +spin_lock_irqsave (&port->lock, flags); + size =tty_insert_flip_string (port, chars, size); +if (size) +tty_flip_buffer_commit (buf->tail); +spin_unlock_irqrestore (&port->lock, flags); + +queue_work (system_unbound_wq, &buf->work); + +return size; +} + +/** * tty_buffer_init - prepare a tty buffer structure * @tty: tty to initialise *
include/linux/tty_flip.h +3 -0
@@ -38,4 +38,7 @@ static inline int tty_insert_flip_stringextern void tty_buffer_lock_exclusive (struct tty_port *port);extern void tty_buffer_unlock_exclusive (struct tty_port *port); +int tty_insert_flip_string_and_push_buffer (struct tty_port *port, +const unsigned char *chars,size_t cnt); +#endif /* _LINUX_TTY_FLIP_H */
Greg Kroah-Hartman
maintainerPATCH 26/26 net: usb: ax88179_178a needs FLAG_SEND_ZLP
In reply to Greg Kroah-HartmanFrom: Jose Alonso <[email protected]>
commit 36a15e1cb134c0395261ba1940762703f778438c upstream.
The extra byte inserted by usbnet.c when
(length % dev->maxpacket == 0) is causing problems to device.
This patch sets FLAG_SEND_ZLP to avoid this.
Tested with: 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
Problems observed:
======================================================================
1) Using ssh/sshfs. The remote sshd daemon can abort with the message:
"message authentication code incorrect"
This happens because the tcp message sent is corrupted during the USB "Bulk out". The device calculate the tcp checksum and send a valid tcp message to the remote sshd. Then the encryption detects the error and aborts.
2) NETDEV WATCHDOG: ... (ax88179_178a): transmit queue 0 timed out
3) Stop normal work without any log message.
The "Bulk in" continue receiving packets normally.
The host sends "Bulk out" and the device responds with -ECONNRESET. (The netusb.c code tx_complete ignore -ECONNRESET)
Under normal conditions these errors take days to happen and in intense usage take hours.
A test with ping gives packet loss, showing that something is wrong:
ping -4 -s 462 {destination} # 462 = 512 - 42 - 8
Not all packets fail.
My guess is that the device tries to find another packet starting at the extra byte and will fail or not depending on the next bytes (old buffer content).
======================================================================
--- drivers/net/usb/ax88179_178a.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/usb/ax88179_178a.c +7 -7
@@ -1703,7 +1703,7 @@ static const struct driver_info ax88179_ .link_reset = ax88179_link_reset, .reset = ax88179_reset, .stop = ax88179_stop, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup = ax88179_rx_fixup, .tx_fixup = ax88179_tx_fixup, };
@@ -1716,7 +1716,7 @@ static const struct driver_info ax88178a .link_reset = ax88179_link_reset, .reset = ax88179_reset, .stop = ax88179_stop, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup = ax88179_rx_fixup, .tx_fixup = ax88179_tx_fixup, };
@@ -1729,7 +1729,7 @@ static const struct driver_info cypress_ .link_reset = ax88179_link_reset, .reset = ax88179_reset, .stop = ax88179_stop, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup = ax88179_rx_fixup, .tx_fixup = ax88179_tx_fixup, };
@@ -1742,7 +1742,7 @@ static const struct driver_info dlink_du .link_reset = ax88179_link_reset, .reset = ax88179_reset, .stop = ax88179_stop, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup = ax88179_rx_fixup, .tx_fixup = ax88179_tx_fixup, };
@@ -1755,7 +1755,7 @@ static const struct driver_info sitecom_ .link_reset = ax88179_link_reset, .reset = ax88179_reset, .stop = ax88179_stop, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup = ax88179_rx_fixup, .tx_fixup = ax88179_tx_fixup, };
@@ -1768,7 +1768,7 @@ static const struct driver_info samsung_ .link_reset = ax88179_link_reset, .reset = ax88179_reset, .stop = ax88179_stop, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup = ax88179_rx_fixup, .tx_fixup = ax88179_tx_fixup, };
@@ -1781,7 +1781,7 @@ static const struct driver_info lenovo_i .link_reset = ax88179_link_reset, .reset = ax88179_reset, .stop = ax88179_stop, - .flags = FLAG_ETHER | FLAG_FRAMING_AX, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup = ax88179_rx_fixup, .tx_fixup = ax88179_tx_fixup, };
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.325 release. There are 26 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 29 Jul 2022 16:09:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.325-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels and build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 4.9.325 release. There are 26 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-4.9.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.325 release. There are 26 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 29 Jul 2022 16:09:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.325-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 4.9.325-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-4.9.y
* git commit: f3e4570fb8c30c0abe735f2a6b0601cb82660ecc
* git describe: v4.9.324-27-gf3e4570fb8c3
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.9.y/build/v4.9.324-27-gf3e4570fb8c3
## Test Regressions (compared to v4.9.324)
No test regressions found.
## Metric Regressions (compared to v4.9.324)
No metric regressions found.
## Test Fixes (compared to v4.9.324)
No test fixes found.
## Metric Fixes (compared to v4.9.324)
No metric fixes found.
## Test result summary
total: 68055, pass: 60210, fail: 223, skip: 6314, xfail: 1308
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 254 total, 249 passed, 5 failed
* arm64: 50 total, 43 passed, 7 failed
* i386: 26 total, 25 passed, 1 failed
* mips: 30 total, 30 passed, 0 failed
* parisc: 12 total, 0 passed, 12 failed
* powerpc: 36 total, 16 passed, 20 failed
* s390: 12 total, 9 passed, 3 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x86_64: 45 total, 44 passed, 1 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kunit
* kvm-unit-tests
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-open-posix-tests
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* packetdrill
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.325 release. There are 26 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 29 Jul 2022 16:09:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.325-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v4.9:
8 builds: 8 pass, 0 fail
14 boots: 14 pass, 0 fail
32 tests: 32 pass, 0 failLinux version: 4.9.325-rc1-gf3e4570fb8c3
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Jon
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.325 release. There are 26 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 29 Jul 2022 16:09:50 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.325-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.325 release. There are 26 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 29 Jul 2022 16:09:50 +0000. Anything received after that time might be too late.
Build results:
total: 164 pass: 164 fail: 0 Qemu test results: total: 397 pass: 397 fail: 0
Guenter