3.18.139-stable review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 20/104 SoC: imx-sgtl5000: add missing put_device()
In reply to Greg Kroah-Hartman[ Upstream commit 8fa857da9744f513036df1c43ab57f338941ae7d ]
The of_find_device_by_node() takes a reference to the underlying device structure, we should release that reference.
Detected by coccinelle with the following warnings:
./sound/soc/fsl/imx-sgtl5000.c:169:1-7: ERROR: missing put_device; call of_find_device_by_node on line 105, but without a corresponding object release within this function. ./sound/soc/fsl/imx-sgtl5000.c:177:1-7: ERROR: missing put_device; call of_find_device_by_node on line 105, but without a corresponding object release within this function.
--- sound/soc/fsl/imx-sgtl5000.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/fsl/imx-sgtl5000.c +1 -0
@@ -115,6 +115,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) ret = -EPROBE_DEFER ; goto fail; } +put_device (&ssi_pdev->dev); codec_dev =of_find_i2c_device_by_node (codec_np);if (!codec_dev) {dev_err (&pdev->dev,"failed to find codec platform device\n" );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 1/104 ext4: cleanup bh release code in ext4_ind_remove_space()
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
commit 5e86bdda41534e17621d5a071b294943cae4376e upstream.
Currently, we are releasing the indirect buffer where we are done with it in ext4_ind_remove_space(), so we can see the brelse() and BUFFER_TRACE() everywhere. It seems fragile and hard to read, and we may probably forget to release the buffer some day. This patch cleans up the code by putting of the code which releases the buffers to the end of the function.
--- fs/ext4/indirect.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-)
fs/ext4/indirect.c +22 -25
@@ -1312,6 +1312,7 @@ int ext4_ind_remove_space(handle_t *handext4_lblk_t offsets[4 ], offsets2[4 ];Indirect chain[4 ], chain2[4 ];Indirect *partial, *partial2; +Indirect *p =NULL , *p2 =NULL ;ext4_lblk_t max_block;__le32 nr =0 , nr2 =0 ;int n =0 , n2 =0 ;
@@ -1353,7 +1354,7 @@ int ext4_ind_remove_space(handle_t *hand } - partial =ext4_find_shared (inode, n, offsets, chain, &nr); + partial = p =ext4_find_shared (inode, n, offsets, chain, &nr);if (nr) {if (partial == chain) {/* Shared branch grows from the inode */
@@ -1378,13 +1379,11 @@ int ext4_ind_remove_space(handle_t *hand partial->p +1 , (__le32 *)partial->bh->b_data+addr_per_block, (chain+n-1) - partial); -BUFFER_TRACE (partial->bh,"call brelse" ); -brelse (partial->bh); partial--; } end_range: - partial2 =ext4_find_shared (inode, n2, offsets2, chain2, &nr2); + partial2 = p2 =ext4_find_shared (inode, n2, offsets2, chain2, &nr2);if (nr2) {if (partial2 == chain2) {/*
@@ -1414,16 +1413,14 @@ end_range: (__le32 *)partial2->bh->b_data, partial2->p, (chain2+n2-1) - partial2); -BUFFER_TRACE (partial2->bh,"call brelse" ); -brelse (partial2->bh); partial2--; } goto do_indirects; }/* Punch happened within the same level (n == n2) */ - partial =ext4_find_shared (inode, n, offsets, chain, &nr); - partial2 =ext4_find_shared (inode, n2, offsets2, chain2, &nr2); + partial = p =ext4_find_shared (inode, n, offsets, chain, &nr); + partial2 = p2 =ext4_find_shared (inode, n2, offsets2, chain2, &nr2);/* Free top, but only if partial2 isn't its subtree. */ if (nr) {
@@ -1480,15 +1477,7 @@ end_range: partial->p +1 , partial2->p, (chain+n-1) - partial); -while (partial > chain) { -BUFFER_TRACE (partial->bh,"call brelse" ); -brelse (partial->bh); - } -while (partial2 > chain2) { -BUFFER_TRACE (partial2->bh,"call brelse" ); -brelse (partial2->bh); - } -return 0 ; + goto cleanup; }/*
@@ -1503,8 +1492,6 @@ end_range: partial->p +1 , (__le32 *)partial->bh->b_data+addr_per_block, (chain+n-1) - partial); -BUFFER_TRACE (partial->bh,"call brelse" ); -brelse (partial->bh); partial--; }if (partial2 > chain2 && depth2 <= depth) {
@@ -1512,11 +1499,21 @@ end_range: (__le32 *)partial2->bh->b_data, partial2->p, (chain2+n2-1) - partial2); -BUFFER_TRACE (partial2->bh,"call brelse" ); -brelse (partial2->bh); partial2--; } } + +cleanup: +while (p && p > chain) { +BUFFER_TRACE (p->bh,"call brelse" ); +brelse (p->bh); + p--; + } +while (p2 && p2 > chain2) { +BUFFER_TRACE (p2->bh,"call brelse" ); +brelse (p2->bh); + p2--; + }return 0 ; do_indirects:
@@ -1524,7 +1521,7 @@ do_indirects:switch (offsets[0 ]) {default :if (++n >= n2) -return 0 ; +break ; nr = i_data[EXT4_IND_BLOCK ];if (nr) {ext4_free_branches (handle, inode,NULL , &nr, &nr+1 ,1 );
@@ -1532,7 +1529,7 @@ do_indirects: }case EXT4_IND_BLOCK :if (++n >= n2) -return 0 ; +break ; nr = i_data[EXT4_DIND_BLOCK ];if (nr) {ext4_free_branches (handle, inode,NULL , &nr, &nr+1 ,2 );
@@ -1540,7 +1537,7 @@ do_indirects: }case EXT4_DIND_BLOCK :if (++n >= n2) -return 0 ; +break ; nr = i_data[EXT4_TIND_BLOCK ];if (nr) {ext4_free_branches (handle, inode,NULL , &nr, &nr+1 ,3 );
@@ -1549,5 +1546,5 @@ do_indirects:case EXT4_TIND_BLOCK : ; } -return 0 ; + goto cleanup; }
Greg Kroah-Hartman
maintainerPATCH 10/104 dm thin: add sanity checks to thin-pool and external snapshot creation
In reply to Greg Kroah-Hartman[ Upstream commit 70de2cbda8a5d788284469e755f8b097d339c240 ]
Invoking dm_get_device() twice on the same device path with different modes is dangerous. Because in that case, upgrade_mode() will alloc a new 'dm_dev' and free the old one, which may be referenced by a previous caller. Dereferencing the dangling pointer will trigger kernel NULL pointer dereference.
The following two cases can reproduce this issue. Actually, they are invalid setups that must be disallowed, e.g.:
1. Creating a thin-pool with read_only mode, and the same device as both metadata and data.
dmsetup create thinp --table \
"0 41943040 thin-pool /dev/vdb /dev/vdb 128 0 1 read_only"BUG: unable to handle kernel NULL pointer dereference at 0000000000000080 ... Call Trace: new_read+0xfb/0x110 [dm_bufio] dm_bm_read_lock+0x43/0x190 [dm_persistent_data] ? kmem_cache_alloc_trace+0x15c/0x1e0 __create_persistent_data_objects+0x65/0x3e0 [dm_thin_pool] dm_pool_metadata_open+0x8c/0xf0 [dm_thin_pool] pool_ctr.cold.79+0x213/0x913 [dm_thin_pool] ? realloc_argv+0x50/0x70 [dm_mod] dm_table_add_target+0x14e/0x330 [dm_mod] table_load+0x122/0x2e0 [dm_mod] ? dev_status+0x40/0x40 [dm_mod] ctl_ioctl+0x1aa/0x3e0 [dm_mod] dm_ctl_ioctl+0xa/0x10 [dm_mod] do_vfs_ioctl+0xa2/0x600 ? handle_mm_fault+0xda/0x200 ? __do_page_fault+0x26c/0x4f0 ksys_ioctl+0x60/0x90 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x55/0x150 entry_SYSCALL_64_after_hwframe+0x44/0xa9
2. Creating a external snapshot using the same thin-pool device.
dmsetup create thinp --table \
"0 41943040 thin-pool /dev/vdc /dev/vdb 128 0 2 ignore_discard"
dmsetup message /dev/mapper/thinp 0 "create_thin 0"
dmsetup create snap --table \
"0 204800 thin /dev/mapper/thinp 0 /dev/mapper/thinp"BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 ... Call Trace: ? __alloc_pages_nodemask+0x13c/0x2e0 retrieve_status+0xa5/0x1f0 [dm_mod] ? dm_get_live_or_inactive_table.isra.7+0x20/0x20 [dm_mod] table_status+0x61/0xa0 [dm_mod] ctl_ioctl+0x1aa/0x3e0 [dm_mod] dm_ctl_ioctl+0xa/0x10 [dm_mod] do_vfs_ioctl+0xa2/0x600 ksys_ioctl+0x60/0x90 ? ksys_write+0x4f/0xb0 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x55/0x150 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- drivers/md/dm-thin.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/md/dm-thin.c +13 -0
@@ -2560,6 +2560,13 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv) as.argc = argc; as.argv = argv; +/* make sure metadata and data are different devices */ +if (!strcmp (argv[0 ], argv[1 ])) { + ti->error ="Error setting metadata or data device" ; + r = -EINVAL ; + goto out_unlock; + } +/* * Set default pool features. */
@@ -3386,6 +3393,12 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) tc->sort_bio_list =RB_ROOT ;if (argc ==3 ) { +if (!strcmp (argv[0 ], argv[2 ])) { + ti->error ="Error setting origin device" ; + r = -EINVAL ; + goto bad_origin_dev; + } + r =dm_get_device (ti, argv[2 ],FMODE_READ , &origin_dev);if (r) { ti->error ="Error opening origin device" ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 11/104 cifs: Fix NULL pointer dereference of devname
In reply to Greg Kroah-Hartman[ Upstream commit 68e2672f8fbd1e04982b8d2798dd318bf2515dd2 ]
There is a NULL pointer dereference of devname in strspn()
The oops looks something like:
CIFS: Attempting to mount (null)
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 ... RIP: 0010:strspn+0x0/0x50 ... Call Trace: ? cifs_parse_mount_options+0x222/0x1710 [cifs] ? cifs_get_volume_info+0x2f/0x80 [cifs] cifs_setup_volume_info+0x20/0x190 [cifs] cifs_get_volume_info+0x50/0x80 [cifs] cifs_smb3_do_mount+0x59/0x630 [cifs] ? ida_alloc_range+0x34b/0x3d0 cifs_do_mount+0x11/0x20 [cifs] mount_fs+0x52/0x170 vfs_kern_mount+0x6b/0x170 do_mount+0x216/0xdc0 ksys_mount+0x83/0xd0 __x64_sys_mount+0x25/0x30 do_syscall_64+0x65/0x220 entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fix this by adding a NULL check on devname in cifs_parse_devname()
--- fs/cifs/connect.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/cifs/connect.c +5 -0
@@ -1186,6 +1186,11 @@ cifs_parse_devname(const char *devname, struct smb_vol *vol)const char *delims ="/\\" ;size_t len; +if (unlikely (!devname || !*devname)) { +cifs_dbg (VFS ,"Device name not specified.\n" ); +return -EINVAL ; + } +/* make sure we have a valid UNC double delimiter prefix */ len =strspn (devname, delims);if (len !=2 )
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 12/104 fs: fix guard_bio_eod to check for real EOD errors
In reply to Greg Kroah-Hartman[ Upstream commit dce30ca9e3b676fb288c33c1f4725a0621361185 ]
guard_bio_eod() can truncate a segment in bio to allow it to do IO on odd last sectors of a device.
It already checks if the IO starts past EOD, but it does not consider the possibility of an IO request starting within device boundaries can contain more than one segment past EOD.
In such cases, truncated_bytes can be bigger than PAGE_SIZE, and will underflow bvec->bv_len.
Fix this by checking if truncated_bytes is lower than PAGE_SIZE.
This situation has been found on filesystems such as isofs and vfat, which doesn't check the device size before mount, if the device is smaller than the filesystem itself, a readahead on such filesystem, which spans EOD, can trigger this situation, leading a call to zero_user() with a wrong size possibly corrupting memory.
I didn't see any crash, or didn't let the system run long enough to check if memory corruption will be hit somewhere, but adding instrumentation to guard_bio_end() to check truncated_bytes size, was enough to see the error.
The following script can trigger the error.
MNT=/mnt
IMG=./DISK.img
DEV=/dev/loop0
mkfs.vfat $IMG
mount $IMG $MNT
cp -R /etc $MNT &> /dev/null
umount $MNT
losetup -D
losetup --find --show --sizelimit 16247280 $IMG
mount $DEV $MNT
find $MNT -type f -exec cat {} + >/dev/null
Kudos to Eric Sandeen for coming up with the reproducer above
--- fs/buffer.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/buffer.c +7 -0
@@ -2986,6 +2986,13 @@ void guard_bio_eod(int rw, struct bio *bio)/* Uhhuh. We've got a bio that straddles the device size! */ truncated_bytes = bio->bi_iter.bi_size - (maxsector <<9 ); +/* +* The bio contains more than one segment which spans EOD, just return +* and let IO layer turn it into an EIO +*/ +if (truncated_bytes > bvec->bv_len) +return ; +/* Truncate the bio.. */ bio->bi_iter.bi_size -= truncated_bytes; bvec->bv_len -= truncated_bytes;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 13/104 tools lib traceevent: Fix buffer overflow in arg_eval
In reply to Greg Kroah-Hartman[ Upstream commit 7c5b019e3a638a5a290b0ec020f6ca83d2ec2aaa ]
Fix buffer overflow observed when running perf test.
The overflow is when trying to evaluate "1ULL << (64 - 1)" which is resulting in -9223372036854775808 which overflows the 20 character buffer.
If is possible this bug has been reported before but I still don't see any fix checked in:
See: https://www.spinics.net/lists/linux-perf-users/msg07714.html
--- tools/lib/traceevent/event-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
@@ -2283,7 +2283,7 @@ static int arg_num_eval(struct print_arg *arg, long long *val)static char *arg_eval (struct print_arg *arg) {long long val; -static char buf[20 ]; +static char buf[24 ];switch (arg->type) {case PRINT_ATOM :
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 15/104 ARM: 8840/1: use a raw_spinlock_t in unwind
In reply to Greg Kroah-Hartman[ Upstream commit 74ffe79ae538283bbf7c155e62339f1e5c87b55a ]
Mostly unwind is done with irqs enabled however SLUB may call it with irqs disabled while creating a new SLUB cache.
I had system freeze while loading a module which called kmem_cache_create() on init. That means SLUB's __slab_alloc() disabled interrupts and then
->new_slab_objects()
->new_slab()
->setup_object()
->setup_object_debug()
->init_tracking()
->set_track()
->save_stack_trace()
->save_stack_trace_tsk()
->walk_stackframe()
->unwind_frame()
->unwind_find_idx()
=>spin_lock_irqsave(&unwind_lock);--- arch/arm/kernel/unwind.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/arm/kernel/unwind.c +7 -7
@@ -93,7 +93,7 @@ extern const struct unwind_idx __start_unwind_idx[];static const struct unwind_idx *__origin_unwind_idx;extern const struct unwind_idx __stop_unwind_idx[]; -static DEFINE_SPINLOCK (unwind_lock); +static DEFINE_RAW_SPINLOCK (unwind_lock);static LIST_HEAD (unwind_tables);/* Convert a prel31 symbol to an absolute address */
@@ -201,7 +201,7 @@ static const struct unwind_idx *unwind_find_idx(unsigned long addr)/* module unwind tables */ struct unwind_table *table; -spin_lock_irqsave (&unwind_lock, flags); +raw_spin_lock_irqsave (&unwind_lock, flags);list_for_each_entry (table, &unwind_tables, list) {if (addr >= table->begin_addr && addr < table->end_addr) {
@@ -213,7 +213,7 @@ static const struct unwind_idx *unwind_find_idx(unsigned long addr)break ; } } -spin_unlock_irqrestore (&unwind_lock, flags); +raw_spin_unlock_irqrestore (&unwind_lock, flags); }pr_debug ("%s: idx = %p\n" , __func__, idx);
@@ -530,9 +530,9 @@ struct unwind_table *unwind_table_add(unsigned long start, unsigned long size, tab->begin_addr = text_addr; tab->end_addr = text_addr + text_size; -spin_lock_irqsave (&unwind_lock, flags); +raw_spin_lock_irqsave (&unwind_lock, flags);list_add_tail (&tab->list, &unwind_tables); -spin_unlock_irqrestore (&unwind_lock, flags); +raw_spin_unlock_irqrestore (&unwind_lock, flags);return tab; }
@@ -544,9 +544,9 @@ void unwind_table_del(struct unwind_table *tab)if (!tab)return ; -spin_lock_irqsave (&unwind_lock, flags); +raw_spin_lock_irqsave (&unwind_lock, flags);list_del (&tab->list); -spin_unlock_irqrestore (&unwind_lock, flags); +raw_spin_unlock_irqrestore (&unwind_lock, flags);kfree (tab); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 17/104 e1000e: Fix -Wformat-truncation warnings
In reply to Greg Kroah-Hartman[ Upstream commit 135e7245479addc6b1f5d031e3d7e2ddb3d2b109 ]
Provide precision hints to snprintf() since we know the destination buffer size of the RX/TX ring names are IFNAMSIZ + 5 - 1. This fixes the following warnings:
drivers/net/ethernet/intel/e1000e/netdev.c: In function 'e1000_request_msix':drivers/net/ethernet/intel/e1000e/netdev.c:2109:13: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
"%s-rx-0", netdev->name);
^drivers/net/ethernet/intel/e1000e/netdev.c:2107:3: note: 'snprintf' output between 6 and 21 bytes into a destination of size 20
snprintf(adapter->rx_ring->name, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(adapter->rx_ring->name) - 1,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s-rx-0", netdev->name);
~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/e1000e/netdev.c:2125:13: warning: 'snprintf'
output may be truncated before the last format character
[-Wformat-truncation=]
"%s-tx-0", netdev->name);
^drivers/net/ethernet/intel/e1000e/netdev.c:2123:3: note: 'snprintf' output between 6 and 21 bytes into a destination of size 20
snprintf(adapter->tx_ring->name, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(adapter->tx_ring->name) - 1,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s-tx-0", netdev->name);
~~~~~~~~~~~~~~~~~~~~~~~~--- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +2 -2
@@ -2132,7 +2132,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)if (strlen (netdev->name) < (IFNAMSIZ -5 ))snprintf (adapter->rx_ring->name,sizeof (adapter->rx_ring->name) -1 , -"%s-rx-0" , netdev->name); +"%.14s-rx-0" , netdev->name);else memcpy (adapter->rx_ring->name, netdev->name,IFNAMSIZ ); err = request_irq(adapter->msix_entries[vector].vector,
@@ -2148,7 +2148,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)if (strlen (netdev->name) < (IFNAMSIZ -5 ))snprintf (adapter->tx_ring->name,sizeof (adapter->tx_ring->name) -1 , -"%s-tx-0" , netdev->name); +"%.14s-tx-0" , netdev->name);else memcpy (adapter->tx_ring->name, netdev->name,IFNAMSIZ ); err = request_irq(adapter->msix_entries[vector].vector,
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 18/104 IB/mlx4: Increase the timeout for CM cache
In reply to Greg Kroah-Hartman[ Upstream commit 2612d723aadcf8281f9bf8305657129bd9f3cd57 ]
Using CX-3 virtual functions, either from a bare-metal machine or pass-through from a VM, MAD packets are proxied through the PF driver.
Since the VF drivers have separate name spaces for MAD Transaction Ids (TIDs), the PF driver has to re-map the TIDs and keep the book keeping in a cache.
Following the RDMA Connection Manager (CM) protocol, it is clear when an entry has to evicted form the cache. But life is not perfect, remote peers may die or be rebooted. Hence, it's a timeout to wipe out a cache entry, when the PF driver assumes the remote peer has gone.
During workloads where a high number of QPs are destroyed concurrently, excessive amount of CM DREQ retries has been observed
The problem can be demonstrated in a bare-metal environment, where two nodes have instantiated 8 VFs each. This using dual ported HCAs, so we have 16 vPorts per physical server.
64 processes are associated with each vPort and creates and destroys one QP for each of the remote 64 processes. That is, 1024 QPs per vPort, all in all 16K QPs. The QPs are created/destroyed using the CM.
When tearing down these 16K QPs, excessive CM DREQ retries (and duplicates) are observed. With some cat/paste/awk wizardry on the infiniband_cm sysfs, we observe as sum of the 16 vPorts on one of the nodes:
cm_rx_duplicates:
dreq 2102
cm_rx_msgs:
drep 1989
dreq 6195
rep 3968
req 4224
rtu 4224
cm_tx_msgs:
drep 4093
dreq 27568
rep 4224
req 3968
rtu 3968
cm_tx_retries:
dreq 23469Note that the active/passive side is equally distributed between the two nodes.
Enabling pr_debug in cm.c gives tons of:
[171778.814239] <mlx4_ib> mlx4_ib_multiplex_cm_handler: id{slave:1,sl_cm_id: 0xd393089f} is NULL!
By increasing the CM_CLEANUP_CACHE_TIMEOUT from 5 to 30 seconds, the tear-down phase of the application is reduced from approximately 90 to 50 seconds. Retries/duplicates are also significantly reduced:
cm_rx_duplicates:
dreq 2460
[]
cm_tx_retries:
dreq 3010
req 47Increasing the timeout further didn't help, as these duplicates and retries stems from a too short CMA timeout, which was 20 (~4 seconds) on the systems. By increasing the CMA timeout to 22 (~17 seconds), the numbers fell down to about 10 for both of them.
Adjustment of the CMA timeout is not part of this commit.
--- drivers/infiniband/hw/mlx4/cm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/cm.c +1 -1
@@ -39,7 +39,7 @@#include "mlx4_ib.h" -#define CM_CLEANUP_CACHE_TIMEOUT (5 * HZ) +#define CM_CLEANUP_CACHE_TIMEOUT (30 * HZ)struct id_map_entry {struct rb_node node;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 2/104 i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA
In reply to Greg Kroah-HartmanFrom: Jeremy Compostella <[email protected]>
commit 89c6efa61f5709327ecfa24bff18e57a4e80c7fa upstream.
On a I2C_SMBUS_I2C_BLOCK_DATA read request, if data->block[0] is greater than I2C_SMBUS_BLOCK_MAX + 1, the underlying I2C driver writes data out of the msgbuf1 array boundary.
It is possible from a user application to run into that issue by calling the I2C_SMBUS ioctl with data.block[0] greater than I2C_SMBUS_BLOCK_MAX + 1.
This patch makes the code compliant with Documentation/i2c/dev-interface by raising an error when the requested size is larger than 32 bytes.
Call Trace: [<ffffffff8139f695>] dump_stack+0x67/0x92 [<ffffffff811802a4>] panic+0xc5/0x1eb [<ffffffff810ecb5f>] ? vprintk_default+0x1f/0x30 [<ffffffff817456d3>] ? i2cdev_ioctl_smbus+0x303/0x320 [<ffffffff8109a68b>] __stack_chk_fail+0x1b/0x20 [<ffffffff817456d3>] i2cdev_ioctl_smbus+0x303/0x320 [<ffffffff81745aed>] i2cdev_ioctl+0x4d/0x1e0 [<ffffffff811f761a>] do_vfs_ioctl+0x2ba/0x490 [<ffffffff81336e43>] ? security_file_ioctl+0x43/0x60 [<ffffffff811f7869>] SyS_ioctl+0x79/0x90 [<ffffffff81a22e97>] entry_SYSCALL_64_fastpath+0x12/0x6a
--- drivers/i2c/i2c-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/i2c/i2c-core.c +6 -6
@@ -2762,16 +2762,16 @@ static s32 i2c_smbus_xfer_emulated(structhe underlying bus driver */ break ;case I2C_SMBUS_I2C_BLOCK_DATA : +if (data->block[0 ] >I2C_SMBUS_BLOCK_MAX ) { +dev_err (&adapter->dev,"Invalid block %s size %d\n" , + read_write ==I2C_SMBUS_READ ?"read" :"write" , + data->block[0 ]); +return -EINVAL ; + }if (read_write ==I2C_SMBUS_READ ) { msg[1 ].len = data->block[0 ]; }else { msg[0 ].len = data->block[0 ] +1 ; -if (msg[0 ].len >I2C_SMBUS_BLOCK_MAX +1 ) { -dev_err (&adapter->dev, -"Invalid block write size %d\n" , - data->block[0 ]); -return -EINVAL ; - }for (i =1 ; i <= data->block[0 ]; i++) msgbuf0[i] = data->block[i]; }
Greg Kroah-Hartman
maintainerPATCH 19/104 scsi: megaraid_sas: return error when create DMA pool failed
In reply to Greg Kroah-Hartman[ Upstream commit bcf3b67d16a4c8ffae0aa79de5853435e683945c ]
when create DMA pool for cmd frames failed, we should return -ENOMEM, instead of 0.
In some case in:
megasas_init_adapter_fusion()
-->megasas_alloc_cmds()
-->megasas_create_frame_pool
create DMA pool failed,
--> megasas_free_cmds() [1]
-->megasas_alloc_cmds_fusion()
failed, then goto fail_alloc_cmds.
-->megasas_free_cmds() [2]we will call megasas_free_cmds twice, [1] will kfree cmd_list,
[2] will use cmd_list.it will cause a problem:
Unable to handle kernel NULL pointer dereference at virtual address
00000000
pgd = ffffffc000f70000
[00000000] *pgd=0000001fbf893003, *pud=0000001fbf893003, *pmd=0000001fbf894003, *pte=006000006d000707
Internal error: Oops: 96000005 [#1] SMP Modules linked in: CPU: 18 PID: 1 Comm: swapper/0 Not tainted task: ffffffdfb9290000 ti: ffffffdfb923c000 task.ti: ffffffdfb923c000 PC is at megasas_free_cmds+0x30/0x70 LR is at megasas_free_cmds+0x24/0x70 ... Call trace: [<ffffffc0005b779c>] megasas_free_cmds+0x30/0x70 [<ffffffc0005bca74>] megasas_init_adapter_fusion+0x2f4/0x4d8 [<ffffffc0005b926c>] megasas_init_fw+0x2dc/0x760 [<ffffffc0005b9ab0>] megasas_probe_one+0x3c0/0xcd8 [<ffffffc0004a5abc>] local_pci_probe+0x4c/0xb4 [<ffffffc0004a5c40>] pci_device_probe+0x11c/0x14c [<ffffffc00053a5e4>] driver_probe_device+0x1ec/0x430 [<ffffffc00053a92c>] __driver_attach+0xa8/0xb0 [<ffffffc000538178>] bus_for_each_dev+0x74/0xc8 [<ffffffc000539e88>] driver_attach+0x28/0x34 [<ffffffc000539a18>] bus_add_driver+0x16c/0x248 [<ffffffc00053b234>] driver_register+0x6c/0x138 [<ffffffc0004a5350>] __pci_register_driver+0x5c/0x6c [<ffffffc000ce3868>] megasas_init+0xc0/0x1a8 [<ffffffc000082a58>] do_one_initcall+0xe8/0x1ec [<ffffffc000ca7be8>] kernel_init_freeable+0x1c8/0x284 [<ffffffc0008d90b8>] kernel_init+0x1c/0xe4
--- drivers/scsi/megaraid/megaraid_sas_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/megaraid/megaraid_sas_base.c +1 -0
@@ -3743,6 +3743,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)if (megasas_create_frame_pool (instance)) {printk (KERN_DEBUG "megasas: Error creating frame DMA pool\n" );megasas_free_cmds (instance); +return -ENOMEM ; }return 0 ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 21/104 leds: lp55xx: fix null deref on firmware load failure
In reply to Greg Kroah-Hartman[ Upstream commit 5ddb0869bfc1bca6cfc592c74c64a026f936638c ]
I've stumbled upon a kernel crash and the logs
pointed me towards the lp5562 driver:
Quoted 8 lines
<4>[306013.841294] lp5562 0-0030: Direct firmware load for lp5562 failed with error -2 <4>[306013.894990] lp5562 0-0030: Falling back to user helper ... <3>[306073.924886] lp5562 0-0030: firmware request failed <1>[306073.939456] Unable to handle kernel NULL pointer dereference at virtual address 00000000 <4>[306074.251011] PC is at _raw_spin_lock+0x1c/0x58 <4>[306074.255539] LR is at release_firmware+0x6c/0x138...
After taking a look I noticed firmware_release()
could be called with either NULL or a dangling
pointer.
--- drivers/leds/leds-lp55xx-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-lp55xx-common.c +2 -2
@@ -200,7 +200,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)if (!fw) {dev_err (dev,"firmware request failed\n" ); - goto out; +return ; }/* handling firmware data is chip dependent */
@@ -213,9 +213,9 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)mutex_unlock (&chip->lock); -out:/* firmware should be released for other channel use */ release_firmware (chip->fw); + chip->fw =NULL ; }static int lp55xx_request_firmware (struct lp55xx_chip *chip)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 23/104 ARM: 8833/1: Ensure that NEON code always compiles with Clang
In reply to Greg Kroah-Hartman[ Upstream commit de9c0d49d85dc563549972edc5589d195cd5e859 ]
While building arm32 allyesconfig, I ran into the following errors:
arch/arm/lib/xor-neon.c:17:2: error: You should compile this file with '-mfloat-abi=softfp -mfpu=neon'
In file included from lib/raid6/neon1.c:27:
/home/nathan/cbl/prebuilt/lib/clang/8.0.0/include/arm_neon.h:28:2:
error: "NEON support not enabled"
Building V=1 showed NEON_FLAGS getting passed along to Clang but __ARM_NEON__ was not getting defined. Ultimately, it boils down to Clang only defining __ARM_NEON__ when targeting armv7, rather than armv6k, which is the '-march' value for allyesconfig.
Quoted 1 line
From
lib/Basic/Targets/ARM.cppin the Clang source:
// This only gets set when Neon instructions are actually available, unlike // the VFP define, hence the soft float and arch check. This is subtly // different from gcc, we follow the intent which was that it should be set // when Neon instructions are actually available.
if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) {
Builder.defineMacro("__ARM_NEON", "1");
Builder.defineMacro("__ARM_NEON__");
// current AArch32 NEON implementations do not support double-precision
// floating-point even when it is present in VFP.
Builder.defineMacro("__ARM_NEON_FP",
"0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));}
Ard Biesheuvel recommended explicitly adding '-march=armv7-a' at the beginning of the NEON_FLAGS definitions so that __ARM_NEON__ always gets definined by Clang. This doesn't functionally change anything because that code will only run where NEON is supported, which is implicitly armv7.
--- Documentation/arm/kernel_mode_neon.txt | 4 ++-- arch/arm/lib/Makefile | 2 +- arch/arm/lib/xor-neon.c | 2 +- lib/raid6/Makefile | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
Documentation/arm/kernel_mode_neon.txt +2 -2
@@ -6,7 +6,7 @@ TL;DR summary * Use only NEON instructions, or VFP instructions that don't rely on support code * Isolate your NEON code in a separate compilation unit, and compile it with - '-mfpu=neon -mfloat-abi=softfp' + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp' * Put kernel_neon_begin() and kernel_neon_end() calls around the calls into your NEON code * Don't sleep in your NEON code, and be aware that it will be executed with
@@ -87,7 +87,7 @@ instructions appearing in unexpected places if no special care is taken. Therefore, the recommended and only supported way of using NEON/VFP in the kernel is by adhering to the following rules: * isolate the NEON code in a separate compilation unit and compile it with - '-mfpu=neon -mfloat-abi=softfp'; + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp'; * issue the calls to kernel_neon_begin(), kernel_neon_end() as well as the calls into the unit containing the NEON code from a compilation unit which is *not* built with the GCC flag '-mfpu=neon' set.
arch/arm/lib/Makefile +1 -1
@@ -46,7 +46,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S ifeq ($(CONFIG_KERNEL_MODE_NEON),y) - NEON_FLAGS := -mfloat-abi=softfp -mfpu=neon + NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon CFLAGS_xor-neon.o += $(NEON_FLAGS) obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o endif
arch/arm/lib/xor-neon.c +1 -1
@@ -14,7 +14,7 @@MODULE_LICENSE ("GPL" );#ifndef __ARM_NEON__ -#error You should compile this file with '-mfloat-abi=softfp -mfpu=neon' +#error You should compile this file with '-march=armv7-a -mfloat-abi=softfp -mfpu=neon'#endif /*
lib/raid6/Makefile +1 -1
@@ -23,7 +23,7 @@ endif ifeq ($(CONFIG_KERNEL_MODE_NEON),y) NEON_FLAGS := -ffreestanding ifeq ($(ARCH),arm) -NEON_FLAGS += -mfloat-abi=softfp -mfpu=neon +NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon endif ifeq ($(ARCH),arm64) CFLAGS_REMOVE_neon1.o += -mgeneral-regs-only
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 22/104 kprobes: Prohibit probing on bsearch()
In reply to Greg Kroah-Hartman[ Upstream commit 02106f883cd745523f7766d90a739f983f19e650 ]
Since kprobe breakpoing handler is using bsearch(), probing on this routine can cause recursive breakpoint problem.
int3
->do_int3()
->ftrace_int3_handler()
->ftrace_location()
->ftrace_location_range()
->bsearch() -> int3Prohibit probing on bsearch().
--- lib/bsearch.c | 2 ++ 1 file changed, 2 insertions(+)
lib/bsearch.c +2 -0
@@ -11,6 +11,7 @@#include <linux/export.h> #include <linux/bsearch.h> +#include <linux/kprobes.h> /* * bsearch - binary search an array of elements
@@ -51,3 +52,4 @@ void *bsearch(const void *key, const void *base, size_t num, size_t size,return NULL ; }EXPORT_SYMBOL (bsearch); +NOKPROBE_SYMBOL (bsearch);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 25/104 bcache: fix input overflow to cache set sysfs file io_error_halflife
In reply to Greg Kroah-Hartman[ Upstream commit a91fbda49f746119828f7e8ad0f0aa2ab0578f65 ]
Cache set sysfs entry io_error_halflife is used to set c->error_decay. c->error_decay is in type unsigned int, and it is converted by strtoul_or_return(), therefore overflow to c->error_decay is possible for a large input value.
This patch fixes the overflow by using strtoul_safe_clamp() to convert input string to an unsigned long value in range [0, UINT_MAX], then divides by 88 and set it to c->error_decay.
--- drivers/md/bcache/sysfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/md/bcache/sysfs.c +11 -2
@@ -645,8 +645,17 @@ STORE(__bch_cache_set) c->error_limit =strtoul_or_return (buf) <<IO_ERROR_SHIFT ;/* See count_io_errors() for why 88 */ -if (attr == &sysfs_io_error_halflife) - c->error_decay =strtoul_or_return (buf) /88 ; +if (attr == &sysfs_io_error_halflife) { +unsigned long v =0 ; +ssize_t ret; + + ret =strtoul_safe_clamp (buf, v,0 ,UINT_MAX ); +if (!ret) { + c->error_decay = v /88 ; +return size; + } +return ret; + }sysfs_strtoul (journal_delay_ms, c->journal_delay_ms);sysfs_strtoul (verify, c->verify);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 26/104 bcache: fix input overflow to sequential_cutoff
In reply to Greg Kroah-Hartman[ Upstream commit 8c27a3953e92eb0b22dbb03d599f543a05f9574e ]
People may set sequential_cutoff of a cached device via sysfs file, but current code does not check input value overflow. E.g. if value 4294967295 (UINT_MAX) is written to file sequential_cutoff, its value is 4GB, but if 4294967296 (UINT_MAX + 1) is written into, its value will be 0. This is an unexpected behavior.
This patch replaces d_strtoi_h() by sysfs_strtoul_clamp() to convert input string to unsigned integer value, and limit its range in [0, UINT_MAX]. Then the input overflow can be fixed.
--- drivers/md/bcache/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/sysfs.c +3 -1
@@ -215,7 +215,9 @@ STORE(__cached_dev)d_strtoul (writeback_rate_d_term);d_strtoul_nonzero (writeback_rate_p_term_inverse); -d_strtoi_h (sequential_cutoff); +sysfs_strtoul_clamp (sequential_cutoff, + dc->sequential_cutoff, +0 ,UINT_MAX );d_strtoi_h (readahead);if (attr == &sysfs_clear_stats)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 28/104 fbdev: fbmem: fix memory access if logo is bigger than the screen
In reply to Greg Kroah-Hartman[ Upstream commit a5399db139cb3ad9b8502d8b1bd02da9ce0b9df0 ]
There is no clipping on the x or y axis for logos larger that the framebuffer size. Therefore: a logo bigger than screen size leads to invalid memory access:
[ 1.254664] Backtrace: [ 1.254728] [<c02714e0>] (cfb_imageblit) from [<c026184c>] (fb_show_logo+0x620/0x684) [ 1.254763] r10:00000003 r9:00027fd8 r8:c6a40000 r7:c6a36e50 r6:00000000 r5:c06b81e4 [ 1.254774] r4:c6a3e800 [ 1.254810] [<c026122c>] (fb_show_logo) from [<c026c1e4>] (fbcon_switch+0x3fc/0x46c) [ 1.254842] r10:c6a3e824 r9:c6a3e800 r8:00000000 r7:c6a0c000 r6:c070b014 r5:c6a3e800 [ 1.254852] r4:c6808c00 [ 1.254889] [<c026bde8>] (fbcon_switch) from [<c029c8f8>] (redraw_screen+0xf0/0x1e8) [ 1.254918] r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:c070d5a0 r5:00000080 [ 1.254928] r4:c6808c00 [ 1.254961] [<c029c808>] (redraw_screen) from [<c029d264>] (do_bind_con_driver+0x194/0x2e4) [ 1.254991] r9:00000000 r8:00000000 r7:00000014 r6:c070d5a0 r5:c070d5a0 r4:c070d5a0
So prevent displaying a logo bigger than screen size and avoid invalid memory access.
--- drivers/video/fbdev/core/fbmem.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/core/fbmem.c +3 -0
@@ -425,6 +425,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image, {unsigned int x; +if (image->width > info->var.xres || image->height > info->var.yres) +return ; +if (rotate ==FB_ROTATE_UR ) { for (x = 0; x < num && image->dx + image->width <= info->var.xres;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 3/104 tracing: kdb: Fix ftdump to not sleep
In reply to Greg Kroah-Hartman[ Upstream commit 31b265b3baaf55f209229888b7ffea523ddab366 ]
As reported back in 2016-11 [1], the "ftdump" kdb command triggers a BUG for "sleeping function called from invalid context".
kdb's "ftdump" command wants to call ring_buffer_read_prepare() in atomic context. A very simple solution for this is to add allocation flags to ring_buffer_read_prepare() so kdb can call it without triggering the allocation error. This patch does that.
Note that in the original email thread about this, it was suggested that perhaps the solution for kdb was to either preallocate the buffer ahead of time or create our own iterator. I'm hoping that this alternative of adding allocation flags to ring_buffer_read_prepare() can be considered since it means I don't need to duplicate more of the core trace code into "trace_kdb.c" (for either creating my own iterator or re-preparing a ring allocator whose memory was already allocated).
NOTE: another option for kdb is to actually figure out how to make it reuse the existing ftrace_dump() function and totally eliminate the duplication. This sounds very appealing and actually works (the "sr z" command can be seen to properly dump the ftrace buffer). The downside here is that ftrace_dump() fully consumes the trace buffer. Unless that is changed I'd rather not use it because it means "ftdump | grep xyz" won't be very useful to search the ftrace buffer since it will throw away the whole trace on the first grep. A future patch to dump only the last few lines of the buffer will also be hard to implement.
[1] https://lkml.kernel.org/r/[email protected]
--- include/linux/ring_buffer.h | 2 +- kernel/trace/ring_buffer.c | 5 +++-- kernel/trace/trace.c | 6 ++++-- kernel/trace/trace_kdb.c | 6 ++++-- 4 files changed, 12 insertions(+), 7 deletions(-)
include/linux/ring_buffer.h +1 -1
@@ -125,7 +125,7 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts, unsigned long *lost_events);struct ring_buffer_iter * -ring_buffer_read_prepare (struct ring_buffer *buffer,int cpu); +ring_buffer_read_prepare (struct ring_buffer *buffer,int cpu,gfp_t flags);void ring_buffer_read_prepare_sync (void );void ring_buffer_read_start (struct ring_buffer_iter *iter);void ring_buffer_read_finish (struct ring_buffer_iter *iter);
kernel/trace/ring_buffer.c +3 -2
@@ -4039,6 +4039,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);* ring_buffer_read_prepare - Prepare for a non consuming read of the buffer * @buffer: The ring buffer to read from * @cpu: The cpu buffer to iterate over +* @flags: gfp flags to use for memory allocation * * This performs the initial preparations necessary to iterate * through the buffer. Memory is allocated, buffer recording
@@ -4056,7 +4057,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);* This overall must be paired with ring_buffer_read_finish. */ struct ring_buffer_iter * -ring_buffer_read_prepare (struct ring_buffer *buffer,int cpu) +ring_buffer_read_prepare (struct ring_buffer *buffer,int cpu,gfp_t flags) {struct ring_buffer_per_cpu *cpu_buffer;struct ring_buffer_iter *iter;
@@ -4064,7 +4065,7 @@ ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu)if (!cpumask_test_cpu (cpu, buffer->cpumask))return NULL ; - iter =kmalloc (sizeof (*iter),GFP_KERNEL ); + iter =kmalloc (sizeof (*iter), flags);if (!iter)return NULL ;
kernel/trace/trace.c +4 -2
@@ -3047,7 +3047,8 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)if (iter->cpu_file ==RING_BUFFER_ALL_CPUS ) {for_each_tracing_cpu (cpu) { iter->buffer_iter[cpu] = -ring_buffer_read_prepare (iter->trace_buffer->buffer, cpu); +ring_buffer_read_prepare (iter->trace_buffer->buffer, + cpu,GFP_KERNEL ); }ring_buffer_read_prepare_sync ();for_each_tracing_cpu (cpu) {
@@ -3057,7 +3058,8 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot) }else { cpu = iter->cpu_file; iter->buffer_iter[cpu] = -ring_buffer_read_prepare (iter->trace_buffer->buffer, cpu); +ring_buffer_read_prepare (iter->trace_buffer->buffer, + cpu,GFP_KERNEL );ring_buffer_read_prepare_sync ();ring_buffer_read_start (iter->buffer_iter[cpu]);tracing_iter_reset (iter, cpu);
kernel/trace/trace_kdb.c +4 -2
@@ -46,14 +46,16 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file)if (cpu_file ==RING_BUFFER_ALL_CPUS ) {for_each_tracing_cpu (cpu) { iter.buffer_iter[cpu] = -ring_buffer_read_prepare (iter.trace_buffer->buffer, cpu); +ring_buffer_read_prepare (iter.trace_buffer->buffer, + cpu,GFP_ATOMIC );ring_buffer_read_start (iter.buffer_iter[cpu]);tracing_iter_reset (&iter, cpu); } }else { iter.cpu_file = cpu_file; iter.buffer_iter[cpu_file] = -ring_buffer_read_prepare (iter.trace_buffer->buffer, cpu_file); +ring_buffer_read_prepare (iter.trace_buffer->buffer, + cpu_file,GFP_ATOMIC );ring_buffer_read_start (iter.buffer_iter[cpu_file]);tracing_iter_reset (&iter, cpu_file); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 5/104 mm/cma.c: cma_declare_contiguous: correct err handling
In reply to Greg Kroah-Hartman[ Upstream commit 0d3bd18a5efd66097ef58622b898d3139790aa9d ]
In case cma_init_reserved_mem failed, need to free the memblock allocated by memblock_reserve or memblock_alloc_range.
Quote Catalin's comments:
https://lkml.org/lkml/2019/2/26/482
Kmemleak is supposed to work with the memblock_{alloc,free} pair and it ignores the memblock_reserve() as a memblock_alloc() implementation detail. It is, however, tolerant to memblock_free() being called on a sub-range or just a different range from a previous memblock_alloc(). So the original patch looks fine to me. FWIW:
--- mm/cma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/cma.c +3 -1
@@ -340,12 +340,14 @@ int __init cma_declare_contiguous(phys_addr_t base, ret =cma_init_reserved_mem (base, size, order_per_bit, res_cma);if (ret) - goto err; + goto free_mem;pr_info ("Reserved %ld MiB at %pa\n" , (unsigned long )size /SZ_1M , &base);return 0 ; +free_mem: +memblock_free (base, size); err:pr_err ("Failed to reserve %ld MiB\n" , (unsigned long )size /SZ_1M );return ret;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 4/104 sysctl: handle overflow for file-max
In reply to Greg Kroah-Hartman[ Upstream commit 32a5ad9c22852e6bd9e74bdec5934ef9d1480bc5 ]
Currently, when writing
echo 18446744073709551616 > /proc/sys/fs/file-max
/proc/sys/fs/file-max will overflow and be set to 0. That quickly crashes the system.
This commit sets the max and min value for file-max. The max value is set to long int. Any higher value cannot currently be used as the percpu counters are long ints and not unsigned integers.
Note that the file-max value is ultimately parsed via __do_proc_doulongvec_minmax(). This function does not report error when min or max are exceeded. Which means if a value largen that long int is written userspace will not receive an error instead the old value will be kept. There is an argument to be made that this should be changed and __do_proc_doulongvec_minmax() should return an error when a dedicated min or max value are exceeded. However this has the potential to break userspace so let's defer this to an RFC patch.
--- kernel/sysctl.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/sysctl.c +3 -0
@@ -125,6 +125,7 @@ static int __maybe_unused one = 1;static int __maybe_unused two =2 ;static int __maybe_unused four =4 ;static unsigned long one_ul =1 ; +static unsigned long long_max =LONG_MAX ;static int one_hundred =100 ;#ifdef CONFIG_PRINTK static int ten_thousand =10000 ;
@@ -1521,6 +1522,8 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(files_stat.max_files), .mode = 0644, .proc_handler = proc_doulongvec_minmax, + .extra1 = &zero, + .extra2 = &long_max, }, { .procname = "nr_open",
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 6/104 mm/vmalloc.c: fix kernel BUG at mm/vmalloc.c:512!
In reply to Greg Kroah-Hartman[ Upstream commit afd07389d3f4933c7f7817a92fb5e053d59a3182 ]
One of the vmalloc stress test case triggers the kernel BUG():
<snip>
[60.562151] ------------[ cut here ]------------ [60.562154] kernel BUG at mm/vmalloc.c:512! [60.562206] invalid opcode: 0000 [#1] PREEMPT SMP PTI [60.562247] CPU: 0 PID: 430 Comm: vmalloc_test/0 Not tainted 4.20.0+ #161 [60.562293] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 [60.562351] RIP: 0010:alloc_vmap_area+0x36f/0x390 <snip>
it can happen due to big align request resulting in overflowing of calculated address, i.e. it becomes 0 after ALIGN()'s fixup.
Fix it by checking if calculated address is within vstart/vend range.
--- mm/vmalloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
mm/vmalloc.c +5 -1
@@ -439,7 +439,11 @@ nocache: } found: -if (addr + size > vend) +/* +* Check also calculated address against the vstart, +* because it can be 0 because of big align request. +*/ +if (addr + size > vend || addr < vstart) goto overflow; va->va_start = addr;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 7/104 mm/slab.c: kmemleak no scan alien caches
In reply to Greg Kroah-Hartman[ Upstream commit 92d1d07daad65c300c7d0b68bbef8867e9895d54 ]
Kmemleak throws endless warnings during boot due to in __alloc_alien_cache(),
alc = kmalloc_node(memsize, gfp, node);
init_arraycache(&alc->ac, entries, batch);
kmemleak_no_scan(ac);Kmemleak does not track the array cache (alc->ac) but the alien cache (alc) instead, so let it track the latter by lifting kmemleak_no_scan() out of init_arraycache().
There is another place that calls init_arraycache(), but alloc_kmem_cache_cpus() uses the percpu allocation where will never be considered as a leak.
kmemleak: Found object by alias at 0xffff8007b9aa7e38
CPU: 190 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc2+ #2
Call trace:
dump_backtrace+0x0/0x168
show_stack+0x24/0x30
dump_stack+0x88/0xb0
lookup_object+0x84/0xac
find_and_get_object+0x84/0xe4
kmemleak_no_scan+0x74/0xf4
setup_kmem_cache_node+0x2b4/0x35c
__do_tune_cpucache+0x250/0x2d4
do_tune_cpucache+0x4c/0xe4
enable_cpucache+0xc8/0x110
setup_cpu_cache+0x40/0x1b8
__kmem_cache_create+0x240/0x358
create_cache+0xc0/0x198
kmem_cache_create_usercopy+0x158/0x20c
kmem_cache_create+0x50/0x64
fsnotify_init+0x58/0x6c
do_one_initcall+0x194/0x388
kernel_init_freeable+0x668/0x688
kernel_init+0x18/0x124
ret_from_fork+0x10/0x18
kmemleak: Object 0xffff8007b9aa7e00 (size 256):
kmemleak: comm "swapper/0", pid 1, jiffies 4294697137
kmemleak: min_count = 1
kmemleak: count = 0
kmemleak: flags = 0x1
kmemleak: checksum = 0
kmemleak: backtrace:
kmemleak_alloc+0x84/0xb8
kmem_cache_alloc_node_trace+0x31c/0x3a0
__kmalloc_node+0x58/0x78
setup_kmem_cache_node+0x26c/0x35c
__do_tune_cpucache+0x250/0x2d4
do_tune_cpucache+0x4c/0xe4
enable_cpucache+0xc8/0x110
setup_cpu_cache+0x40/0x1b8
__kmem_cache_create+0x240/0x358
create_cache+0xc0/0x198
kmem_cache_create_usercopy+0x158/0x20c
kmem_cache_create+0x50/0x64
fsnotify_init+0x58/0x6c
do_one_initcall+0x194/0x388
kernel_init_freeable+0x668/0x688
kernel_init+0x18/0x124
kmemleak: Not scanning unknown object at 0xffff8007b9aa7e38
CPU: 190 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc2+ #2
Call trace:
dump_backtrace+0x0/0x168
show_stack+0x24/0x30
dump_stack+0x88/0xb0
kmemleak_no_scan+0x90/0xf4
setup_kmem_cache_node+0x2b4/0x35c
__do_tune_cpucache+0x250/0x2d4
do_tune_cpucache+0x4c/0xe4
enable_cpucache+0xc8/0x110
setup_cpu_cache+0x40/0x1b8
__kmem_cache_create+0x240/0x358
create_cache+0xc0/0x198
kmem_cache_create_usercopy+0x158/0x20c
kmem_cache_create+0x50/0x64
fsnotify_init+0x58/0x6c
do_one_initcall+0x194/0x388
kernel_init_freeable+0x668/0x688
kernel_init+0x18/0x124
ret_from_fork+0x10/0x18--- mm/slab.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
mm/slab.c +9 -8
@@ -659,14 +659,6 @@ static void start_cpu_timer(int cpu)static void init_arraycache (struct array_cache *ac,int limit,int batch) { -/* -* The array_cache structures contain pointers to free object. -* However, when such objects are allocated or transferred to another -* cache the pointers are not cleared and they could be counted as -* valid references during a kmemleak scan. Therefore, kmemleak must -* not scan such objects. -*/ -kmemleak_no_scan (ac);if (ac) { ac->avail =0 ; ac->limit = limit;
@@ -682,6 +674,14 @@ static struct array_cache *alloc_arraycache(int node, int entries,struct array_cache *ac =NULL ; ac =kmalloc_node (memsize, gfp, node); +/* +* The array_cache structures contain pointers to free object. +* However, when such objects are allocated or transferred to another +* cache the pointers are not cleared and they could be counted as +* valid references during a kmemleak scan. Therefore, kmemleak must +* not scan such objects. +*/ +kmemleak_no_scan (ac);init_arraycache (ac, entries, batchcount);return ac; }
@@ -870,6 +870,7 @@ static struct alien_cache *__alloc_alien_cache(int node, int entries, alc =kmalloc_node (memsize, gfp, node);if (alc) { +kmemleak_no_scan (alc);init_arraycache (&alc->ac, entries, batch);spin_lock_init (&alc->lock); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 8/104 ocfs2: fix a panic problem caused by o2cb_ctl
In reply to Greg Kroah-Hartman[ Upstream commit cc725ef3cb202ef2019a3c67c8913efa05c3cce6 ]
In the process of creating a node, it will cause NULL pointer dereference in kernel if o2cb_ctl failed in the interval (mkdir, o2cb_set_node_attribute(node_num)] in function o2cb_add_node.
The node num is initialized to 0 in function o2nm_node_group_make_item, o2nm_node_group_drop_item will mistake the node number 0 for a valid node number when we delete the node before the node number is set correctly. If the local node number of the current host happens to be 0, cluster->cl_local_node will be set to O2NM_INVALID_NODE_NUM while o2hb_thread still running. The panic stack is generated as follows:
o2hb_thread
\-o2hb_do_disk_heartbeat
\-o2hb_check_own_slot
|-slot = ®->hr_slots[o2nm_this_node()];
//o2nm_this_node() return O2NM_INVALID_NODE_NUMWe need to check whether the node number is set when we delete the node.
--- fs/ocfs2/cluster/nodemanager.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
fs/ocfs2/cluster/nodemanager.c +8 -6
@@ -721,13 +721,15 @@ static void o2nm_node_group_drop_item(struct config_group *group,struct o2nm_node *node =to_o2nm_node (item);struct o2nm_cluster *cluster =to_o2nm_cluster (group->cg_item.ci_parent); -o2net_disconnect_node (node); +if (cluster->cl_nodes[node->nd_num] == node) { +o2net_disconnect_node (node); -if (cluster->cl_has_local && - (cluster->cl_local_node == node->nd_num)) { - cluster->cl_has_local =0 ; - cluster->cl_local_node =O2NM_INVALID_NODE_NUM ; -o2net_stop_listening (node); +if (cluster->cl_has_local && + (cluster->cl_local_node == node->nd_num)) { + cluster->cl_has_local =0 ; + cluster->cl_local_node =O2NM_INVALID_NODE_NUM ; +o2net_stop_listening (node); + } }/* XXX call into net to stop this node from trading messages */
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainercover 3.18.139-stable review
This is the start of the stable review cycle for the 3.18.139 release. There are 104 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 26 Apr 2019 05:07:26 PM UTC. 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/v3.x/stable-review/patch-3.18.139-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-3.18.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 3.18.139-rc1
Jann Horn <[email protected]>
device_cgroup: fix RCU imbalance in error case
Phil Auld <[email protected]>
sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup
Masami Hiramatsu <[email protected]>
kprobes: Fix error check when reusing optimized probes
Masami Hiramatsu <[email protected]>
x86/kprobes: Verify stack frame on kretprobe
Takashi Iwai <[email protected]>
ALSA: core: Fix card races between register and disconnect
Ian Abbott <[email protected]>
staging: comedi: ni_usb6501: Fix possible double-free of ->usb_rx_buf
Ian Abbott <[email protected]>
staging: comedi: vmk80xx: Fix possible double-free of ->usb_rx_buf
Ian Abbott <[email protected]>
staging: comedi: vmk80xx: Fix use of uninitialized semaphore
Georg Ottinger <[email protected]>
iio: adc: at91: disable adc channel interrupt in timeout case
Dragos Bogdan <[email protected]>
iio: ad_sigma_delta: select channel when reading register
Eric Dumazet <[email protected]>
tcp: tcp_grow_window() needs to respect tcp_space()
Eric Dumazet <[email protected]>
ipv4: ensure rcu_read_lock() in ipv4_link_failure()
Stephen Suryaputra <[email protected]>
ipv4: recompile ip options in ipv4_link_failure
Nikolay Aleksandrov <[email protected]>
net: bridge: multicast: use rcu to access port list from br_multicast_start_querier
Sabrina Dubroca <[email protected]>
bonding: fix event handling for stacked bonds
Jarkko Sakkinen <[email protected]>
tpm/tpm_i2c_atmel: Return -E2BIG when the transfer is incomplete
Christian Lamparter <[email protected]>
crypto: crypto4xx - properly set IV after de- and encrypt
Arnd Bergmann <[email protected]>
appletalk: Fix compile regression
Amit Klein <[email protected]>
inet: update the IP ID generation algorithm to higher standards.
Pi-Hsun Shih <[email protected]>
include/linux/swap.h: use offsetof() instead of custom __swapoffset macro
Stanislaw Gruszka <[email protected]>
lib/div64.c: off by one in shift
YueHaibing <[email protected]>
appletalk: Fix use-after-free in atalk_proc_exit
Julia Cartwright <[email protected]>
iommu/dmar: Fix buffer overflow during PCI bus notification
Ronald Tschalär <[email protected]>
ACPI / SBS: Fix GPE storm on recent MacBookPro's
Bartlomiej Zolnierkiewicz <[email protected]>
ARM: samsung: Limit SAMSUNG_PM_CHECK config option to non-Exynos platforms
Michal Simek <[email protected]>
serial: uartps: console_setup() can't be placed to init section
Dinu-Razvan Chis-Serban <[email protected]>
9p locks: add mount option for lock retry interval
Gertjan Halkes <[email protected]>
9p: do not trust pdu content for stat item size
Siva Rebbagondla <[email protected]>
rsi: improve kernel thread handling to fix kernel panic
Steve French <[email protected]>
fix incorrect error code mapping for OBJECTID_NOT_FOUND
Lu Baolu <[email protected]>
iommu/vt-d: Check capability before disabling protected memory
Matthew Whitehead <[email protected]>
x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors
Aditya Pakki <[email protected]>
x86/hpet: Prevent potential NULL pointer dereference
Changbin Du <[email protected]>
perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test()
Changbin Du <[email protected]>
perf top: Fix error handling in cmd_top()
David Arcari <[email protected]>
tools/power turbostat: return the exit status of a command
Matthew Garrett <[email protected]>
thermal/int340x_thermal: fix mode setting
Colin Ian King <[email protected]>
ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration
Arnd Bergmann <[email protected]>
mmc: davinci: remove extraneous __init annotation
Jack Morgenstein <[email protected]>
IB/mlx4: Fix race condition between catas error reset and aliasguid flows
Kangjie Lu <[email protected]>
ALSA: sb8: add a check for request_region
Kangjie Lu <[email protected]>
ALSA: echoaudio: add a check for ioremap_nocache
Lukas Czerner <[email protected]>
ext4: report real fs size after failed resize
Stephane Eranian <[email protected]>
perf/core: Restore mmap record type correctly
Tejun Heo <[email protected]>
string: drop __must_check from strscpy() and restore strscpy() usages in cgroup
Andre Przywara <[email protected]>
PCI: Add function 1 DMA alias quirk for Marvell 9170 SATA controller
Max Filippov <[email protected]>
xtensa: fix return_address
Mel Gorman <[email protected]>
sched/fair: Do not re-read ->h_load_next during hierarchical load calculation
Dan Carpenter <[email protected]>
xen: Prevent buffer overflow in privcmd ioctl
Will Deacon <[email protected]>
arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value
Jérôme Glisse <[email protected]>
block: do not leak memory in bio_copy_user_iov()
S.j. Wang <[email protected]>
ASoC: fsl_esai: fix channel swap issue when stream starts
Zubin Mithra <[email protected]>
ALSA: seq: Fix OOB-reads from strlcpy
Sheena Mira-ato <[email protected]>
ip6_tunnel: Match to ARPHRD_TUNNEL6 for dev type
Li RongQing <[email protected]>
net: ethtool: not call vzalloc for zero sized memory request
Eric Dumazet <[email protected]>
netns: provide pure entropy for net_hash_mix()
Xin Long <[email protected]>
sctp: initialize _pad of sockaddr_in before copying to user memory
Bjørn Mork <[email protected]>
qmi_wwan: add Olicard 600
Andrea Righi <[email protected]>
openvswitch: fix flow actions reallocation
Greg Kroah-Hartman <[email protected]>
tty: ldisc: add sysctl to prevent autoloading of ldiscs
Greg Kroah-Hartman <[email protected]>
tty: mark Siemens R3964 line discipline as BROKEN
Nick Desaulniers <[email protected]>
lib/string.c: implement a basic bcmp
Linus Torvalds <[email protected]>
binfmt_elf: switch to new creds when switching to new mm
Ville Syrjälä <[email protected]>
drm/dp/mst: Configure no_stop_bit correctly for remote i2c xfers
Ben Dooks <[email protected]>
dmaengine: tegra: avoid overflow of byte tracking
Rafael Ávila de Espíndola <[email protected]>
x86/build: Mark per-CPU symbols as absolute explicitly for LLD
Zumeng Chen <[email protected]>
wlcore: Fix memory leak in case wl12xx_fetch_firmware failure
Pawe? Chmiel <[email protected]>
media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration
Anders Roxell <[email protected]>
dmaengine: imx-dma: fix warning comparison of distinct pointer types
Buland Singh <[email protected]>
hpet: Fix missing '=' character in the __setup() code of hpet_mmap_enable
David Tolnay <[email protected]>
hwrng: virtio - Avoid repeated init of completion
Akinobu Mita <[email protected]>
media: mt9m111: set initial frame size other than 0x0
Manfred Schlaegl <[email protected]>
tty: increase the default flip buffer limit to 2*640K
Waiman Long <[email protected]>
locking/lockdep: Add debug_locks check in __lock_downgrade()
Konstantin Khlebnikov <[email protected]>
e1000e: fix cyclic resets at link up with active tx
Guenter Roeck <[email protected]>
cdrom: Fix race condition in cdrom_sysctl_register
Manfred Schlaegl <[email protected]>
fbdev: fbmem: fix memory access if logo is bigger than the screen
Coly Li <[email protected]>
bcache: improve sysfs_strtoul_clamp()
Coly Li <[email protected]>
bcache: fix input overflow to sequential_cutoff
Coly Li <[email protected]>
bcache: fix input overflow to cache set sysfs file io_error_halflife
Ranjani Sridharan <[email protected]>
ALSA: PCM: check if ops are defined before suspending PCM
Nathan Chancellor <[email protected]>
ARM: 8833/1: Ensure that NEON code always compiles with Clang
Andrea Righi <[email protected]>
kprobes: Prohibit probing on bsearch()
Michal Kazior <[email protected]>
leds: lp55xx: fix null deref on firmware load failure
Wen Yang <[email protected]>
SoC: imx-sgtl5000: add missing put_device()
Jason Yan <[email protected]>
scsi: megaraid_sas: return error when create DMA pool failed
Håkon Bugge <[email protected]>
IB/mlx4: Increase the timeout for CM cache
Florian Fainelli <[email protected]>
e1000e: Fix -Wformat-truncation warnings
Aaro Koskinen <[email protected]>
mmc: omap: fix the maximum timeout setting
Sebastian Andrzej Siewior <[email protected]>
ARM: 8840/1: use a raw_spinlock_t in unwind
Benjamin Block <[email protected]>
scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c
Tony Jones <[email protected]>
tools lib traceevent: Fix buffer overflow in arg_eval
Carlos Maiolino <[email protected]>
fs: fix guard_bio_eod to check for real EOD errors
Yao Liu <[email protected]>
cifs: Fix NULL pointer dereference of devname
Jason Cai (Xiang Feng) <[email protected]>
dm thin: add sanity checks to thin-pool and external snapshot creation
Louis Taylor <[email protected]>
cifs: use correct format characters
Jia Guo <[email protected]>
ocfs2: fix a panic problem caused by o2cb_ctl
Qian Cai <[email protected]>
mm/slab.c: kmemleak no scan alien caches
Uladzislau Rezki (Sony) <[email protected]>
mm/vmalloc.c: fix kernel BUG at mm/vmalloc.c:512!
Peng Fan <[email protected]>
mm/cma.c: cma_declare_contiguous: correct err handling
Christian Brauner <[email protected]>
sysctl: handle overflow for file-max
Douglas Anderson <[email protected]>
tracing: kdb: Fix ftdump to not sleep
Jeremy Compostella <[email protected]>
i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA
zhangyi (F) <[email protected]>
ext4: cleanup bh release code in ext4_ind_remove_space()
-------------
Diffstat:
Documentation/arm/kernel_mode_neon.txt | 4 +- Makefile | 4 +- arch/arm/kernel/unwind.c | 14 +++---- arch/arm/lib/Makefile | 2 +- arch/arm/lib/xor-neon.c | 2 +- arch/arm/plat-samsung/Kconfig | 2 +- arch/arm64/include/asm/futex.h | 16 ++++---- arch/x86/include/asm/xen/hypercall.h | 3 ++ arch/x86/kernel/cpu/cyrix.c | 14 +++---- arch/x86/kernel/hpet.c | 2 + arch/x86/kernel/kprobes/core.c | 26 +++++++++++++ arch/x86/kernel/vmlinux.lds.S | 2 +- arch/xtensa/kernel/stacktrace.c | 6 ++- block/bio.c | 5 ++- drivers/acpi/sbs.c | 8 +++- drivers/cdrom/cdrom.c | 7 ++-- drivers/char/Kconfig | 2 +- drivers/char/hpet.c | 2 +- drivers/char/hw_random/virtio-rng.c | 2 +- drivers/char/tpm/tpm_i2c_atmel.c | 10 ++++- drivers/crypto/amcc/crypto4xx_alg.c | 3 +- drivers/crypto/amcc/crypto4xx_core.c | 9 +++++ drivers/dma/imx-dma.c | 2 +- drivers/dma/tegra20-apb-dma.c | 5 ++- drivers/gpu/drm/drm_dp_mst_topology.c | 1 + drivers/i2c/i2c-core.c | 12 +++--- drivers/iio/adc/ad_sigma_delta.c | 1 + drivers/iio/adc/at91_adc.c | 28 ++++++++------ drivers/infiniband/hw/mlx4/alias_GUID.c | 2 +- drivers/infiniband/hw/mlx4/cm.c | 2 +- drivers/iommu/dmar.c | 2 +- drivers/iommu/intel-iommu.c | 3 ++ drivers/leds/leds-lp55xx-common.c | 4 +- drivers/md/bcache/sysfs.c | 17 ++++++-- drivers/md/bcache/sysfs.h | 13 +++++-- drivers/md/dm-thin.c | 13 +++++++ drivers/media/i2c/soc_camera/mt9m111.c | 2 + drivers/media/platform/s5p-jpeg/jpeg-core.c | 19 +++++---- drivers/mmc/host/davinci_mmc.c | 2 +- drivers/mmc/host/omap.c | 2 +- drivers/net/bonding/bond_main.c | 6 ++- drivers/net/ethernet/intel/e1000e/netdev.c | 19 ++++----- drivers/net/usb/qmi_wwan.c | 1 + drivers/net/wireless/rsi/rsi_common.h | 1 - drivers/net/wireless/ti/wlcore/main.c | 7 +++- drivers/pci/quirks.c | 2 + drivers/scsi/megaraid/megaraid_sas_base.c | 1 + drivers/scsi/scsi_scan.c | 6 +-- drivers/staging/comedi/drivers/ni_usb6501.c | 4 +- drivers/staging/comedi/drivers/vmk80xx.c | 8 ++-- drivers/thermal/int340x_thermal/int3400_thermal.c | 7 ++-- drivers/tty/Kconfig | 23 +++++++++++ drivers/tty/serial/xilinx_uartps.c | 2 +- drivers/tty/tty_buffer.c | 2 +- drivers/tty/tty_io.c | 3 ++ drivers/tty/tty_ldisc.c | 47 +++++++++++++++++++++++ drivers/video/fbdev/core/fbmem.c | 3 ++ fs/9p/v9fs.c | 21 ++++++++++ fs/9p/v9fs.h | 1 + fs/9p/vfs_dir.c | 8 ++-- fs/9p/vfs_file.c | 6 ++- fs/binfmt_elf.c | 2 +- fs/buffer.c | 7 ++++ fs/cifs/cifs_dfs_ref.c | 4 +- fs/cifs/connect.c | 5 +++ fs/cifs/smb1ops.c | 2 +- fs/cifs/smb2maperror.c | 3 +- fs/ext4/indirect.c | 47 +++++++++++------------ fs/ext4/resize.c | 6 ++- fs/ocfs2/cluster/nodemanager.c | 14 ++++--- include/linux/atalk.h | 20 +++++++--- include/linux/kprobes.h | 1 + include/linux/ring_buffer.h | 2 +- include/linux/string.h | 5 ++- include/linux/swap.h | 4 +- include/net/net_namespace.h | 2 + include/net/netns/hash.h | 15 +------- kernel/events/core.c | 2 + kernel/kprobes.c | 6 +-- kernel/locking/lockdep.c | 3 ++ kernel/sched/fair.c | 31 +++++++++++++-- kernel/sysctl.c | 3 ++ kernel/trace/ring_buffer.c | 5 ++- kernel/trace/trace.c | 6 ++- kernel/trace/trace_kdb.c | 6 ++- lib/bsearch.c | 2 + lib/div64.c | 4 +- lib/raid6/Makefile | 2 +- lib/string.c | 20 ++++++++++ mm/cma.c | 4 +- mm/slab.c | 17 ++++---- mm/vmalloc.c | 6 ++- net/9p/protocol.c | 3 +- net/appletalk/atalk_proc.c | 2 +- net/appletalk/ddp.c | 37 +++++++++++++++--- net/appletalk/sysctl_net_atalk.c | 5 ++- net/bridge/br_multicast.c | 4 +- net/core/ethtool.c | 29 +++++++++----- net/core/net_namespace.c | 1 + net/ipv4/route.c | 20 +++++++++- net/ipv4/tcp_input.c | 10 ++--- net/ipv6/ip6_output.c | 3 ++ net/ipv6/ip6_tunnel.c | 4 +- net/openvswitch/flow_netlink.c | 4 +- net/sctp/protocol.c | 1 + security/device_cgroup.c | 2 +- sound/core/init.c | 18 ++++----- sound/core/pcm_native.c | 8 ++++ sound/core/seq/seq_clientmgr.c | 6 +-- sound/drivers/opl3/opl3_voice.h | 2 +- sound/isa/sb/sb8.c | 4 ++ sound/pci/echoaudio/echoaudio.c | 5 +++ sound/soc/fsl/fsl_esai.c | 47 ++++++++++++++++++----- sound/soc/fsl/imx-sgtl5000.c | 1 + tools/lib/traceevent/event-parse.c | 2 +- tools/perf/builtin-top.c | 5 ++- tools/perf/tests/evsel-tp-sched.c | 1 + tools/power/x86/turbostat/turbostat.c | 3 ++ 118 files changed, 672 insertions(+), 264 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 30/104 e1000e: fix cyclic resets at link up with active tx
[ Upstream commit 0f9e980bf5ee1a97e2e401c846b2af989eb21c61 ]
I'm seeing series of e1000e resets (sometimes endless) at system boot if something generates tx traffic at this time. In my case this is netconsole who sends message "e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames" from e1000e itself. As result e1000_watchdog_task sees used tx buffer while carrier is off and start this reset cycle again.
[ 17.794359] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None [ 17.794714] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready [ 22.936455] e1000e 0000:02:00.0 eth1: changing MTU from 1500 to 9000 [ 23.033336] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 26.102364] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None [ 27.174495] 8021q: 802.1Q VLAN Support v1.8 [ 27.174513] 8021q: adding VLAN 0 to HW filter on device eth1 [ 30.671724] cgroup: cgroup: disabling cgroup2 socket matching due to net_prio or net_cls activation [ 30.898564] netpoll: netconsole: local port 6666 [ 30.898566] netpoll: netconsole: local IPv6 address 2a02:6b8:0:80b:beae:c5ff:fe28:23f8 [ 30.898567] netpoll: netconsole: interface 'eth1' [ 30.898568] netpoll: netconsole: remote port 6666 [ 30.898568] netpoll: netconsole: remote IPv6 address 2a02:6b8:b000:605c:e61d:2dff:fe03:3790 [ 30.898569] netpoll: netconsole: remote ethernet address b0:a8:6e:f4:ff:c0 [ 30.917747] console [netcon0] enabled [ 30.917749] netconsole: network logging started [ 31.453353] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 34.185730] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 34.321840] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 34.465822] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 34.597423] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 34.745417] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 34.877356] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 35.005441] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 35.157376] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 35.289362] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 35.417441] e1000e 0000:02:00.0: Some CPU C-states have been disabled in order to enable jumbo frames [ 37.790342] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
This patch flushes tx buffers only once when carrier is off rather than at each watchdog iteration.
--- drivers/net/ethernet/intel/e1000e/netdev.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +6 -9
@@ -5073,8 +5073,13 @@ static void e1000_watchdog_task(struct work_struct *work)/* 8000ES2LAN requires a Rx packet buffer work-around * on link down event; reset the controller to flush * the Rx packet buffer. +* +* If the link is lost the controller stops DMA, but +* if there is queued Tx work it cannot be done. So +* reset the controller to flush the Tx packet buffers. */ -if (adapter->flags &FLAG_RX_NEEDS_RESTART ) +if ((adapter->flags &FLAG_RX_NEEDS_RESTART ) || +e1000_desc_unused (tx_ring) +1 < tx_ring->count) adapter->flags |=FLAG_RESTART_NOW ;else pm_schedule_suspend(netdev->dev.parent,
@@ -5097,14 +5102,6 @@ link_up: adapter->gotc_old = adapter->stats.gotc;spin_unlock (&adapter->stats64_lock); -/* If the link is lost the controller stops DMA, but -* if there is queued Tx work it cannot be done. So -* reset the controller to flush the Tx packet buffers. -*/ -if (!netif_carrier_ok (netdev) && - (e1000_desc_unused (tx_ring) +1 < tx_ring->count)) - adapter->flags |=FLAG_RESTART_NOW ; -/* If reset is necessary, do it outside of interrupt context. */ if (adapter->flags &FLAG_RESTART_NOW ) {schedule_work (&adapter->reset_task);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 39/104 x86/build: Mark per-CPU symbols as absolute explicitly for LLD
In reply to Greg Kroah-Hartman[ Upstream commit d071ae09a4a1414c1433d5ae9908959a7325b0ad ]
Accessing per-CPU variables is done by finding the offset of the variable in the per-CPU block and adding it to the address of the respective CPU's block.
Section 3.10.8 of ld.bfd's documentation states:
For expressions involving numbers, relative addresses and absolute addresses, ld follows these rules to evaluate terms:
Other binary operations, that is, between two relative addresses not in the same section, or between a relative address and an absolute address, first convert any non-absolute term to an absolute address before applying the operator."
Note that LLVM's linker does not adhere to the GNU ld's implementation and as such requires implicitly-absolute terms to be explicitly marked as absolute in the linker script. If not, it fails currently with:
ld.lld: error: ./arch/x86/kernel/vmlinux.lds:153: at least one side of the expression must be absolute ld.lld: error: ./arch/x86/kernel/vmlinux.lds:154: at least one side of the expression must be absolute Makefile:1040: recipe for target 'vmlinux' failed
This is not a functional change for ld.bfd which converts the term to an absolute symbol anyways as specified above.
Based on a previous submission by Tri Vo <[email protected]>.
--- arch/x86/kernel/vmlinux.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/vmlinux.lds.S +1 -1
@@ -345,7 +345,7 @@ SECTIONS * Per-cpu symbols which need to be offset from __per_cpu_load * for the boot processor. */ -#define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load +#define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x) + __per_cpu_load INIT_PER_CPU(gdt_page); INIT_PER_CPU(irq_stack_union);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 40/104 dmaengine: tegra: avoid overflow of byte tracking
In reply to Greg Kroah-Hartman[ Upstream commit e486df39305864604b7e25f2a95d51039517ac57 ]
The dma_desc->bytes_transferred counter tracks the number of bytes moved by the DMA channel. This is then used to calculate the information passed back in the in the tegra_dma_tx_status callback, which is usually fine.
When the DMA channel is configured as continous, then the bytes_transferred counter will increase over time and eventually overflow to become negative so the residue count will become invalid and the ALSA sound-dma code will report invalid hardware pointer values to the application. This results in some users becoming confused about the playout position and putting audio data in the wrong place.
To fix this issue, always ensure the bytes_transferred field is modulo the size of the request. We only do this for the case of the cyclic transfer done ISR as anyone attempting to move 2GiB of DMA data in one transfer is unlikely.
Note, we don't fix the issue that we should /never/ transfer a negative number of bytes so we could make those fields unsigned.
--- drivers/dma/tegra20-apb-dma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/tegra20-apb-dma.c +4 -1
@@ -613,7 +613,10 @@ static void handle_cont_sngl_cycle_dma_done(struct tegra_dma_channel *tdc, sgreq =list_first_entry (&tdc->pending_sg_req,typeof (*sgreq), node); dma_desc = sgreq->dma_desc; - dma_desc->bytes_transferred += sgreq->req_len; +/* if we dma for long enough the transfer count will wrap */ + dma_desc->bytes_transferred = + (dma_desc->bytes_transferred + sgreq->req_len) % + dma_desc->bytes_requested;/* Callback need to be call */ if (!dma_desc->cb_count)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 41/104 drm/dp/mst: Configure no_stop_bit correctly for remote i2c xfers
In reply to Greg Kroah-Hartman[ Upstream commit c978ae9bde582e82a04c63a4071701691dd8b35c ]
We aren't supposed to force a stop+start between every i2c msg when performing multi message transfers. This should eg. cause the DDC segment address to be reset back to 0 between writing the segment address and reading the actual EDID extension block.
To quote the E-DDC spec:
"... this standard requires that the segment pointer be
reset to 00h when a NO ACK or a STOP condition is received."
Since we're going to touch this might as well consult the I2C_M_STOP flag to determine whether we want to force the stop or not.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
@@ -2816,6 +2816,7 @@ static int drm_dp_mst_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs msg.u.i2c_read.transactions[i].i2c_dev_id = msgs[i].addr; msg.u.i2c_read.transactions[i].num_bytes = msgs[i].len; msg.u.i2c_read.transactions[i].bytes = msgs[i].buf; + msg.u.i2c_read.transactions[i].no_stop_bit = !(msgs[i].flags &I2C_M_STOP ); } msg.u.i2c_read.read_i2c_device_id = msgs[num -1 ].addr; msg.u.i2c_read.num_bytes_read = msgs[num -1 ].len;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 42/104 binfmt_elf: switch to new creds when switching to new mm
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 9f834ec18defc369d73ccf9e87a2790bfa05bf46 upstream.
We used to delay switching to the new credentials until after we had mapped the executable (and possible elf interpreter). That was kind of odd to begin with, since the new executable will actually then _run_ with the new creds, but whatever.
The bigger problem was that we also want to make sure that we turn off prof events and tracing before we start mapping the new executable state. So while this is a cleanup, it's also a fix for a possible information leak.
--- fs/binfmt_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +1 -1
@@ -734,6 +734,7 @@ static int load_elf_binary(struct linux_ current->flags |=PF_RANDOMIZE ;setup_new_exec (bprm); +install_exec_creds (bprm);/* Do this so that we can load the interpreter, if need be. We will change some of these later */
@@ -935,7 +936,6 @@ static int load_elf_binary(struct linux_ goto out;#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ -install_exec_creds (bprm); retval =create_elf_tables (bprm, &loc->elf_ex, load_addr, interp_load_addr);if (retval <0 )
Greg Kroah-Hartman
maintainerPATCH 44/104 tty: mark Siemens R3964 line discipline as BROKEN
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
commit c7084edc3f6d67750f50d4183134c4fb5712a5c8 upstream.
The n_r3964 line discipline driver was written in a different time, when SMP machines were rare, and users were trusted to do the right thing. Since then, the world has moved on but not this code, it has stayed rooted in the past with its lovely hand-crafted list structures and loads of "interesting" race conditions all over the place.
After attempting to clean up most of the issues, I just gave up and am now marking the driver as BROKEN so that hopefully someone who has this hardware will show up out of the woodwork (I know you are out there!) and will help with debugging a raft of changes that I had laying around for the code, but was too afraid to commit as odds are they would break things.
Many thanks to Jann and Linus for pointing out the initial problems in this codebase, as well as many reviews of my attempts to fix the issues. It was a case of whack-a-mole, and as you can see, the mole won.
--- drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/Kconfig +1 -1
@@ -380,7 +380,7 @@ config XILINX_HWICAP config R3964 tristate "Siemens R3964 line discipline" - depends on TTY + depends on TTY && BROKEN ---help--- This driver allows synchronous communication with devices using the Siemens R3964 packet protocol. Unless you are dealing with special
Greg Kroah-Hartman
maintainerPATCH 45/104 tty: ldisc: add sysctl to prevent autoloading of ldiscs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
commit 7c0cca7c847e6e019d67b7d793efbbe3b947d004 upstream.
By default, the kernel will automatically load the module of any line dicipline that is asked for. As this sometimes isn't the safest thing to do, provide a sysctl to disable this feature.
By default, we set this to 'y' as that is the historical way that Linux has worked, and we do not want to break working systems. But in the future, perhaps this can default to 'n' to prevent this functionality.
--- drivers/tty/Kconfig | 23 +++++++++++++++++++++++ drivers/tty/tty_io.c | 3 +++ drivers/tty/tty_ldisc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+)
drivers/tty/Kconfig +23 -0
@@ -419,4 +419,27 @@ config DA_CONSOLE help This enables a console on a Dash channel. +config LDISC_AUTOLOAD + bool "Automatically load TTY Line Disciplines" + default y + help + Historically the kernel has always automatically loaded any + line discipline that is in a kernel module when a user asks + for it to be loaded with the TIOCSETD ioctl, or through other + means. This is not always the best thing to do on systems + where you know you will not be using some of the more + "ancient" line disciplines, so prevent the kernel from doing + this unless the request is coming from a process with the + CAP_SYS_MODULE permissions. + + Say 'Y' here if you trust your userspace users to do the right + thing, or if you have only provided the line disciplines that + you know you will be using, or if you wish to continue to use + the traditional method of on-demand loading of these modules + by any user. + + This functionality can be changed at runtime with the + dev.tty.ldisc_autoload sysctl, this configuration option will + only set the default value of this functionality. + endif # TTY
drivers/tty/tty_io.c +3 -0
@@ -492,6 +492,8 @@ static const struct file_operations hungstatic DEFINE_SPINLOCK (redirect_lock);static struct file *redirect; +extern void tty_sysctl_init (void ); +/** * tty_wakeup - request more data * @tty: terminal
@@ -3625,6 +3627,7 @@ void console_sysfs_notify(void)*/ int __init tty_init (void ) { +tty_sysctl_init ();cdev_init (&tty_cdev, &tty_fops);if (cdev_add (&tty_cdev,MKDEV (TTYAUX_MAJOR ,0 ),1 ) ||register_chrdev_region (MKDEV (TTYAUX_MAJOR ,0 ),1 ,"/dev/tty" ) <0 )
drivers/tty/tty_ldisc.c +47 -0
62 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 46/104 openvswitch: fix flow actions reallocation
In reply to Greg Kroah-HartmanFrom: Andrea Righi <[email protected]>
[ Upstream commit f28cd2af22a0c134e4aa1c64a70f70d815d473fb ]
The flow action buffer can be resized if it's not big enough to contain all the requested flow actions. However, this resize doesn't take into account the new requested size, the buffer is only increased by a factor of 2x. This might be not enough to contain the new data, causing a buffer overflow, for example:
[ 42.044472] ============================================================================= [ 42.045608] BUG kmalloc-96 (Not tainted): Redzone overwritten [ 42.046415] -----------------------------------------------------------------------------
[ 42.047715] Disabling lock debugging due to kernel taint [ 42.047716] INFO: 0x8bf2c4a5-0x720c0928. First byte 0x0 instead of 0xcc [ 42.048677] INFO: Slab 0xbc6d2040 objects=29 used=18 fp=0xdc07dec4 flags=0x2808101 [ 42.049743] INFO: Object 0xd53a3464 @offset=2528 fp=0xccdcdebb
[ 42.050747] Redzone 76f1b237: cc cc cc cc cc cc cc cc ........ [ 42.051839] Object d53a3464: 6b 6b 6b 6b 6b 6b 6b 6b 0c 00 00 00 6c 00 00 00 kkkkkkkk....l... [ 42.053015] Object f49a30cc: 6c 00 0c 00 00 00 00 00 00 00 00 03 78 a3 15 f6 l...........x... [ 42.054203] Object acfe4220: 20 00 02 00 ff ff ff ff 00 00 00 00 00 00 00 00 ............... [ 42.055370] Object 21024e91: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [ 42.056541] Object 070e04c3: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [ 42.057797] Object 948a777a: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [ 42.059061] Redzone 8bf2c4a5: 00 00 00 00 .... [ 42.060189] Padding a681b46e: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ
Fix by making sure the new buffer is properly resized to contain all the requested data.
--- net/openvswitch/flow_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/openvswitch/flow_netlink.c +2 -2
@@ -1261,14 +1261,14 @@ static struct nlattr *reserve_sfa_size(sstruct sw_flow_actions *acts;int new_acts_size; -int req_size =NLA_ALIGN (attr_len); +size_t req_size =NLA_ALIGN (attr_len);int next_offset = offsetof(struct sw_flow_actions , actions) + (*sfa)->actions_len;if (req_size <= (ksize (*sfa) - next_offset)) goto out; - new_acts_size =ksize (*sfa) *2 ; + new_acts_size =max (next_offset + req_size,ksize (*sfa) *2 );if (new_acts_size >MAX_ACTIONS_BUFSIZE ) {if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size)
Greg Kroah-Hartman
maintainerPATCH 47/104 qmi_wwan: add Olicard 600
In reply to Greg Kroah-HartmanFrom: Bjørn Mork <[email protected]>
[ Upstream commit 6289d0facd9ebce4cc83e5da39e15643ee998dc5 ]
This is a Qualcomm based device with a QMI function on interface 4. It is mode switched from 2020:2030 using a standard eject message.
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=2020 ProdID=2031 Rev= 2.32 S: Manufacturer=Mobile Connect S: Product=Mobile Connect S: SerialNumber=0123456789ABCDEF C:* #Ifs= 6 Cfg#= 1 Atr=80 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none) E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none) E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none) E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) E: Ad=89(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none) E: Ad=8a(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
--- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/qmi_wwan.c +1 -0
@@ -759,6 +759,7 @@ static const struct usb_device_id produc {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */ {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */ + {QMI_FIXED_INTF(0x2020, 0x2031, 4)}, /* Olicard 600 */ {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */ {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
Greg Kroah-Hartman
maintainerPATCH 48/104 sctp: initialize _pad of sockaddr_in before copying to user memory
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 09279e615c81ce55e04835970601ae286e3facbe ]
Syzbot report a kernel-infoleak:
BUG: KMSAN: kernel-infoleak in _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
Call Trace:
_copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
copy_to_user include/linux/uaccess.h:174 [inline]
sctp_getsockopt_peer_addrs net/sctp/socket.c:5911 [inline]
sctp_getsockopt+0x1668e/0x17f70 net/sctp/socket.c:7562
...
Uninit was stored to memory at:
sctp_transport_init net/sctp/transport.c:61 [inline]
sctp_transport_new+0x16d/0x9a0 net/sctp/transport.c:115
sctp_assoc_add_peer+0x532/0x1f70 net/sctp/associola.c:637
sctp_process_param net/sctp/sm_make_chunk.c:2548 [inline]
sctp_process_init+0x1a1b/0x3ed0 net/sctp/sm_make_chunk.c:2361
...
Bytes 8-15 of 16 are uninitializedIt was caused by that th _pad field (the 8-15 bytes) of a v4 addr (saved in struct sockaddr_in) wasn't initialized, but directly copied to user memory in sctp_getsockopt_peer_addrs().
So fix it by calling memset(addr->v4.sin_zero, 0, 8) to initialize _pad of sockaddr_in before copying it to user memory in sctp_v4_addr_to_user(), as sctp_v6_addr_to_user() does.
--- net/sctp/protocol.c | 1 + 1 file changed, 1 insertion(+)
net/sctp/protocol.c +1 -0
@@ -578,6 +578,7 @@ out:static int sctp_v4_addr_to_user (struct sctp_sock *sp,union sctp_addr *addr) {/* No address mapping for V4 sockets */ +memset (addr->v4.sin_zero,0 ,sizeof (addr->v4.sin_zero));return sizeof (struct sockaddr_in ); }
Greg Kroah-Hartman
maintainerPATCH 50/104 net: ethtool: not call vzalloc for zero sized memory request
In reply to Greg Kroah-HartmanFrom: Li RongQing <[email protected]>
[ Upstream commit 3d8830266ffc28c16032b859e38a0252e014b631 ]
NULL or ZERO_SIZE_PTR will be returned for zero sized memory request, and derefencing them will lead to a segfault
so it is unnecessory to call vzalloc for zero sized memory request and not call functions which maybe derefence the NULL allocated memory
this also fixes a possible memory leak if phy_ethtool_get_stats returns error, memory should be freed before exit
--- net/core/ethtool.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
net/core/ethtool.c +19 -10
@@ -1257,17 +1257,22 @@ static int ethtool_get_strings(struct ne gstrings.len = ret; - data =kcalloc (gstrings.len,ETH_GSTRING_LEN ,GFP_USER ); -if (!data) -return -ENOMEM ; +if (gstrings.len) { + data =kcalloc (gstrings.len,ETH_GSTRING_LEN ,GFP_USER ); +if (!data) +return -ENOMEM ; -__ethtool_get_strings (dev, gstrings.string_set, data); +__ethtool_get_strings (dev, gstrings.string_set, data); + }else { + data =NULL ; + } ret = -EFAULT ;if (copy_to_user (useraddr, &gstrings,sizeof (gstrings))) goto out; useraddr +=sizeof (gstrings); -if (copy_to_user (useraddr, data, gstrings.len *ETH_GSTRING_LEN )) +if (gstrings.len && +copy_to_user (useraddr, data, gstrings.len *ETH_GSTRING_LEN )) goto out; ret =0 ;
@@ -1355,17 +1360,21 @@ static int ethtool_get_stats(struct net_return -EFAULT ; stats.n_stats = n_stats; - data =kmalloc (n_stats *sizeof (u64),GFP_USER ); -if (!data) -return -ENOMEM ; +if (n_stats) { + data =kmalloc (n_stats *sizeof (u64),GFP_USER ); +if (!data) +return -ENOMEM ; - ops->get_ethtool_stats (dev, &stats, data); + ops->get_ethtool_stats (dev, &stats, data); + }else { + data =NULL ; + } ret = -EFAULT ;if (copy_to_user (useraddr, &stats,sizeof (stats))) goto out; useraddr +=sizeof (stats); -if (copy_to_user (useraddr, data, stats.n_stats *sizeof (u64))) +if (n_stats &©_to_user (useraddr, data, n_stats *sizeof (u64))) goto out; ret =0 ;
Greg Kroah-Hartman
maintainerPATCH 51/104 ip6_tunnel: Match to ARPHRD_TUNNEL6 for dev type
In reply to Greg Kroah-HartmanFrom: Sheena Mira-ato <[email protected]>
[ Upstream commit b2e54b09a3d29c4db883b920274ca8dca4d9f04d ]
The device type for ip6 tunnels is set to ARPHRD_TUNNEL6. However, the ip4ip6_err function is expecting the device type of the tunnel to be ARPHRD_TUNNEL. Since the device types do not match, the function exits and the ICMP error packet is not sent to the originating host. Note that the device type for IPv4 tunnels is set to ARPHRD_TUNNEL.
Fix is to expect a tunnel device type of ARPHRD_TUNNEL6 instead. Now the tunnel device type matches and the ICMP error packet is sent to the originating host.
--- net/ipv6/ip6_tunnel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_tunnel.c +2 -2
@@ -638,7 +638,7 @@ ip4ip6_err(struct sk_buff *skb, struct iIPPROTO_IPIP , RT_TOS(eiph->tos), 0);if (IS_ERR (rt) || - rt->dst.dev->type !=ARPHRD_TUNNEL ) { + rt->dst.dev->type !=ARPHRD_TUNNEL6 ) {if (!IS_ERR (rt))ip_rt_put (rt); goto out;
@@ -648,7 +648,7 @@ ip4ip6_err(struct sk_buff *skb, struct iip_rt_put (rt);if (ip_route_input (skb2, eiph->daddr, eiph->saddr, eiph->tos, skb2->dev) || -skb_dst (skb2)->dev->type !=ARPHRD_TUNNEL ) +skb_dst (skb2)->dev->type !=ARPHRD_TUNNEL6 ) goto out; }
Greg Kroah-Hartman
maintainerPATCH 52/104 ALSA: seq: Fix OOB-reads from strlcpy
In reply to Greg Kroah-HartmanFrom: Zubin Mithra <[email protected]>
commit 212ac181c158c09038c474ba68068be49caecebb upstream.
When ioctl calls are made with non-null-terminated userspace strings, strlcpy causes an OOB-read from within strlen. Fix by changing to use strscpy instead.
--- sound/core/seq/seq_clientmgr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/core/seq/seq_clientmgr.c +3 -3
@@ -1249,7 +1249,7 @@ static int snd_seq_ioctl_set_client_info/* fill the info fields */ if (client_info.name[0 ]) -strlcpy (client->name, client_info.name,sizeof (client->name)); +strscpy (client->name, client_info.name,sizeof (client->name)); client->filter = client_info.filter; client->event_lost = client_info.event_lost;
@@ -1564,7 +1564,7 @@ static int snd_seq_ioctl_create_queue(st/* set queue name */ if (! info.name[0 ])snprintf (info.name,sizeof (info.name),"Queue-%d" , q->queue); -strlcpy (q->name, info.name,sizeof (q->name)); +strscpy (q->name, info.name,sizeof (q->name));queuefree (q);if (copy_to_user (arg, &info,sizeof (info)))
@@ -1642,7 +1642,7 @@ static int snd_seq_ioctl_set_queue_info(queuefree (q);return -EPERM ; } -strlcpy (q->name, info.name,sizeof (q->name)); +strscpy (q->name, info.name,sizeof (q->name));queuefree (q);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 53/104 ASoC: fsl_esai: fix channel swap issue when stream starts
In reply to Greg Kroah-HartmanFrom: S.j. Wang <[email protected]>
commit 0ff4e8c61b794a4bf6c854ab071a1abaaa80f358 upstream.
There is very low possibility ( < 0.1% ) that channel swap happened in beginning when multi output/input pin is enabled. The issue is that hardware can't send data to correct pin in the beginning with the normal enable flow.
This is hardware issue, but there is no errata, the workaround flow is that: Each time playback/recording, firstly clear the xSMA/xSMB, then enable TE/RE, then enable xSMB and xSMA (xSMB must be enabled before xSMA). Which is to use the xSMA as the trigger start register, previously the xCR_TE or xCR_RE is the bit for starting.
Fixes commit 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver")
--- sound/soc/fsl/fsl_esai.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-)
sound/soc/fsl/fsl_esai.c +37 -10
@@ -57,6 +57,8 @@ struct fsl_esai {u32 fifo_depth;u32 slot_width;u32 slots; +u32 tx_mask; +u32 rx_mask;u32 hck_rate[2 ];u32 sck_rate[2 ];bool hck_dir[2 ];
@@ -357,21 +359,13 @@ static int fsl_esai_set_dai_tdm_slot(strregmap_update_bits (esai_priv->regmap,REG_ESAI_TCCR , ESAI_xCCR_xDC_MASK,ESAI_xCCR_xDC (slots)); -regmap_update_bits (esai_priv->regmap,REG_ESAI_TSMA , - ESAI_xSMA_xS_MASK,ESAI_xSMA_xS (tx_mask)); -regmap_update_bits (esai_priv->regmap,REG_ESAI_TSMB , - ESAI_xSMB_xS_MASK,ESAI_xSMB_xS (tx_mask)); -regmap_update_bits (esai_priv->regmap,REG_ESAI_RCCR , ESAI_xCCR_xDC_MASK,ESAI_xCCR_xDC (slots)); -regmap_update_bits (esai_priv->regmap,REG_ESAI_RSMA , - ESAI_xSMA_xS_MASK,ESAI_xSMA_xS (rx_mask)); -regmap_update_bits (esai_priv->regmap,REG_ESAI_RSMB , - ESAI_xSMB_xS_MASK,ESAI_xSMB_xS (rx_mask)); - esai_priv->slot_width = slot_width; esai_priv->slots = slots; + esai_priv->tx_mask = tx_mask; + esai_priv->rx_mask = rx_mask;return 0 ; }
@@ -577,6 +571,7 @@ static int fsl_esai_trigger(struct snd_pbool tx = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ;u8 i, channels = substream->runtime->channels;u32 pins =DIV_ROUND_UP (channels, esai_priv->slots); +u32 mask;switch (cmd) {case SNDRV_PCM_TRIGGER_START :
@@ -589,15 +584,38 @@ static int fsl_esai_trigger(struct snd_pfor (i =0 ; tx && i < channels; i++)regmap_write (esai_priv->regmap,REG_ESAI_ETDR ,0x0 ); +/* +* When set the TE/RE in the end of enablement flow, there +* will be channel swap issue for multi data line case. +* In order to workaround this issue, we switch the bit +* enablement sequence to below sequence +* 1) clear the xSMB & xSMA: which is done in probe and +* stop state. +* 2) set TE/RE +* 3) set xSMB +* 4) set xSMA: xSMA is the last one in this flow, which +* will trigger esai to start. +*/ regmap_update_bits (esai_priv->regmap,REG_ESAI_xCR (tx), tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, tx ?ESAI_xCR_TE (pins) :ESAI_xCR_RE (pins)); + mask = tx ? esai_priv->tx_mask : esai_priv->rx_mask; + +regmap_update_bits (esai_priv->regmap,REG_ESAI_xSMB (tx), + ESAI_xSMB_xS_MASK,ESAI_xSMB_xS (mask)); +regmap_update_bits (esai_priv->regmap,REG_ESAI_xSMA (tx), + ESAI_xSMA_xS_MASK,ESAI_xSMA_xS (mask)); +break ;case SNDRV_PCM_TRIGGER_SUSPEND :case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_PAUSE_PUSH :regmap_update_bits (esai_priv->regmap,REG_ESAI_xCR (tx), tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK,0 ); +regmap_update_bits (esai_priv->regmap,REG_ESAI_xSMA (tx), + ESAI_xSMA_xS_MASK,0 ); +regmap_update_bits (esai_priv->regmap,REG_ESAI_xSMB (tx), + ESAI_xSMB_xS_MASK,0 );/* Disable and reset FIFO */ regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx),
@@ -838,6 +856,15 @@ static int fsl_esai_probe(struct platforreturn ret; } + esai_priv->tx_mask =0xFFFFFFFF ; + esai_priv->rx_mask =0xFFFFFFFF ; + +/* Clear the TSMA, TSMB, RSMA, RSMB */ +regmap_write (esai_priv->regmap,REG_ESAI_TSMA ,0 ); +regmap_write (esai_priv->regmap,REG_ESAI_TSMB ,0 ); +regmap_write (esai_priv->regmap,REG_ESAI_RSMA ,0 ); +regmap_write (esai_priv->regmap,REG_ESAI_RSMB ,0 ); + ret =devm_snd_soc_register_component (&pdev->dev, &fsl_esai_component, &fsl_esai_dai,1 );if (ret) {
Greg Kroah-Hartman
maintainerPATCH 54/104 block: do not leak memory in bio_copy_user_iov()
In reply to Greg Kroah-HartmanFrom: Jérôme Glisse <[email protected]>
commit a3761c3c91209b58b6f33bf69dd8bb8ec0c9d925 upstream.
When bio_add_pc_page() fails in bio_copy_user_iov() we should free the page we just allocated otherwise we are leaking it.
--- block/bio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
block/bio.c +4 -1
@@ -1217,8 +1217,11 @@ struct bio *bio_copy_user_iov(struct req } } -if (bio_add_pc_page (q, bio, page, bytes, offset) < bytes) +if (bio_add_pc_page (q, bio, page, bytes, offset) < bytes) { +if (!map_data) +__free_page (page);break ; + } len -= bytes; offset =0 ;
Greg Kroah-Hartman
maintainerPATCH 55/104 arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit 045afc24124d80c6998d9c770844c67912083506 upstream.
Rather embarrassingly, our futex() FUTEX_WAKE_OP implementation doesn't explicitly set the return value on the non-faulting path and instead leaves it holding the result of the underlying atomic operation. This means that any FUTEX_WAKE_OP atomic operation which computes a non-zero value will be reported as having failed. Regrettably, I wrote the buggy code back in 2011 and it was upstreamed as part of the initial arm64 support in 2012.
The reasons we appear to get away with this are:
1. FUTEX_WAKE_OP is rarely used and therefore doesn't appear to get exercised by futex() test applications
2. If the result of the atomic operation is zero, the system call behaves correctly
3. Prior to version 2.25, the only operation used by GLIBC set the futex to zero, and therefore worked as expected. From 2.25 onwards, FUTEX_WAKE_OP is not used by GLIBC at all.
Fix the implementation by ensuring that the return value is either 0 to indicate that the atomic operation completed successfully, or -EFAULT if we encountered a fault when accessing the user mapping.
--- arch/arm64/include/asm/futex.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/arm64/include/asm/futex.h +8 -8
@@ -26,8 +26,8 @@ asmvolatile ( \"1: ldxr %w1, %2\n" \ insn"\n" \ -"2: stlxr %w3, %w0, %2\n" \ -" cbnz %w3, 1b\n" \ +"2: stlxr %w0, %w3, %2\n" \ +" cbnz %w0, 1b\n" \" dmb ish\n" \"3:\n" \ " .pushsection .fixup,\"ax\"\n" \
@@ -50,7 +50,7 @@ futex_atomic_op_inuser(unsigned int encoint cmp = (encoded_op >>24 ) &15 ;int oparg = (int )(encoded_op <<8 ) >>20 ;int cmparg = (int )(encoded_op <<20 ) >>20 ; -int oldval =0 , ret, tmp; +int oldval, ret, tmp;if (encoded_op & (FUTEX_OP_OPARG_SHIFT <<28 )) oparg =1U << (oparg &0x1f );
@@ -62,23 +62,23 @@ futex_atomic_op_inuser(unsigned int encoswitch (op) {case FUTEX_OP_SET : -__futex_atomic_op ("mov %w0, %w4" , +__futex_atomic_op ("mov %w3, %w4" , ret, oldval, uaddr, tmp, oparg);break ;case FUTEX_OP_ADD : -__futex_atomic_op ("add %w0, %w1, %w4" , +__futex_atomic_op ("add %w3, %w1, %w4" , ret, oldval, uaddr, tmp, oparg);break ;case FUTEX_OP_OR : -__futex_atomic_op ("orr %w0, %w1, %w4" , +__futex_atomic_op ("orr %w3, %w1, %w4" , ret, oldval, uaddr, tmp, oparg);break ;case FUTEX_OP_ANDN : -__futex_atomic_op ("and %w0, %w1, %w4" , +__futex_atomic_op ("and %w3, %w1, %w4" , ret, oldval, uaddr, tmp, ~oparg);break ;case FUTEX_OP_XOR : -__futex_atomic_op ("eor %w0, %w1, %w4" , +__futex_atomic_op ("eor %w3, %w1, %w4" , ret, oldval, uaddr, tmp, oparg);break ;default :
Greg Kroah-Hartman
maintainerPATCH 56/104 xen: Prevent buffer overflow in privcmd ioctl
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 42d8644bd77dd2d747e004e367cb0c895a606f39 upstream.
The "call" variable comes from the user in privcmd_ioctl_hypercall(). It's an offset into the hypercall_page[] which has (PAGE_SIZE / 32) elements. We need to put an upper bound on it to prevent an out of bounds access.
--- arch/x86/include/asm/xen/hypercall.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/xen/hypercall.h +3 -0
@@ -213,6 +213,9 @@ privcmd_call(unsigned call, __HYPERCALL_DECLS;__HYPERCALL_5ARG (a1, a2, a3, a4, a5); +if (call >=PAGE_SIZE /sizeof (hypercall_page[0 ])) +return -EINVAL ; + asmvolatile ("call *%[call]" : __HYPERCALL_5PARAM : [call] "a" (&hypercall_page[call])
Greg Kroah-Hartman
maintainerPATCH 57/104 sched/fair: Do not re-read ->h_load_next during hierarchical load calculation
In reply to Greg Kroah-HartmanFrom: Mel Gorman <[email protected]>
commit 0e9f02450da07fc7b1346c8c32c771555173e397 upstream.
A NULL pointer dereference bug was reported on a distribution kernel but the same issue should be present on mainline kernel. It occured on s390 but should not be arch-specific. A partial oops looks like:
Unable to handle kernel pointer dereference in virtual kernel address space
...
Call Trace:
...
try_to_wake_up+0xfc/0x450
vhost_poll_wakeup+0x3a/0x50 [vhost]
__wake_up_common+0xbc/0x178
__wake_up_common_lock+0x9e/0x160
__wake_up_sync_key+0x4e/0x60
sock_def_readable+0x5e/0x98The bug hits any time between 1 hour to 3 days. The dereference occurs in update_cfs_rq_h_load when accumulating h_load. The problem is that cfq_rq->h_load_next is not protected by any locking and can be updated by parallel calls to task_h_load. Depending on the compiler, code may be generated that re-reads cfq_rq->h_load_next after the check for NULL and then oops when reading se->avg.load_avg. The dissassembly showed that it was possible to reread h_load_next after the check for NULL.
While this does not appear to be an issue for later compilers, it's still an accident if the correct code is generated. Full locking in this path would have high overhead so this patch uses READ_ONCE to read h_load_next only once and check for NULL before dereferencing. It was confirmed that there were no further oops after 10 days of testing.
As Peter pointed out, it is also necessary to use WRITE_ONCE() to avoid any potential problems with store tearing.
--- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/fair.c +3 -3
@@ -5617,10 +5617,10 @@ static void update_cfs_rq_h_load(structif (cfs_rq->last_h_load_update == now)return ; - cfs_rq->h_load_next =NULL ; +WRITE_ONCE (cfs_rq->h_load_next,NULL );for_each_sched_entity (se) { cfs_rq =cfs_rq_of (se); - cfs_rq->h_load_next = se; +WRITE_ONCE (cfs_rq->h_load_next, se);if (cfs_rq->last_h_load_update == now)break ; }
@@ -5630,7 +5630,7 @@ static void update_cfs_rq_h_load(struct cfs_rq->last_h_load_update = now; } -while ((se = cfs_rq->h_load_next) !=NULL ) { +while ((se =READ_ONCE (cfs_rq->h_load_next)) !=NULL ) { load = cfs_rq->h_load; load =div64_ul (load * se->avg.load_avg_contrib, cfs_rq->runnable_load_avg +1 );
Greg Kroah-Hartman
maintainerPATCH 32/104 tty: increase the default flip buffer limit to 2*640K
In reply to Greg Kroah-Hartman[ Upstream commit 7ab57b76ebf632bf2231ccabe26bea33868118c6 ]
We increase the default limit for buffer memory allocation by a factor of 10 to 640K to prevent data loss when using fast serial interfaces.
For example when using RS485 without flow-control at speeds of 1Mbit/s an upwards we've run into problems such as applications being too slow to read out this buffer (on embedded devices based on imx53 or imx6).
If you want to write transmitted data to a slow SD card and thus have realtime requirements, this limit can become a problem.
That shouldn't be the case and 640K buffers fix such problems for us.
This value is a maximum limit for allocation only. It has no effect on systems that currently run fine. When transmission is slow enough applications and hardware can keep up and increasing this limit doesn't change anything.
It only _allows_ to allocate more than 2*64K in cases we currently fail to allocate memory despite having some.
--- drivers/tty/tty_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_buffer.c +1 -1
@@ -25,7 +25,7 @@* Byte threshold to limit memory consumption for flip buffers. * The actual memory limit is > 2x this amount. */ -#define TTYB_DEFAULT_MEM_LIMIT 65536 +#define TTYB_DEFAULT_MEM_LIMIT (640 * 1024UL)/* * We default to dicing tty buffer allocations to this many characters
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 59/104 PCI: Add function 1 DMA alias quirk for Marvell 9170 SATA controller
In reply to Greg Kroah-HartmanFrom: Andre Przywara <[email protected]>
commit 9cde402a59770a0669d895399c13407f63d7d209 upstream.
There is a Marvell 88SE9170 PCIe SATA controller I found on a board here. Some quick testing with the ARM SMMU enabled reveals that it suffers from the same requester ID mixup problems as the other Marvell chips listed already.
Add the PCI vendor/device ID to the list of chips which need the workaround.
--- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/quirks.c +2 -0
@@ -3565,6 +3565,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_M/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */ DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9130 , quirk_dma_func1_alias); +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9170 , + quirk_dma_func1_alias);/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c47 + c57 */ DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9172 , quirk_dma_func1_alias);
Greg Kroah-Hartman
maintainerPATCH 60/104 string: drop __must_check from strscpy() and restore strscpy() usages in cgroup
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 08a77676f9c5fc69a681ccd2cd8140e65dcb26c7 upstream.
e7fd37ba1217 ("cgroup: avoid copying strings longer than the buffers") converted possibly unsafe strncpy() usages in cgroup to strscpy(). However, although the callsites are completely fine with truncated copied, because strscpy() is marked __must_check, it led to the following warnings.
kernel/cgroup/cgroup.c: In function ‘cgroup_file_name’:
kernel/cgroup/cgroup.c:1400:10: warning: ignoring return value of ‘strscpy’, declared with attribute warn_unused_result [-Wunused-result]
strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX); ^
To avoid the warnings, 50034ed49645 ("cgroup: use strlcpy() instead of strscpy() to avoid spurious warning") switched them to strlcpy().
strlcpy() is worse than strlcpy() because it unconditionally runs strlen() on the source string, and the only reason we switched to strlcpy() here was because it was lacking __must_check, which doesn't reflect any material differences between the two function. It's just that someone added __must_check to strscpy() and not to strlcpy().
These basic string copy operations are used in variety of ways, and one of not-so-uncommon use cases is safely handling truncated copies, where the caller naturally doesn't care about the return value. The __must_check doesn't match the actual use cases and forces users to opt for inferior variants which lack __must_check by happenstance or spread ugly (void) casts.
Remove __must_check from strscpy() and restore strscpy() usages in cgroup.
--- include/linux/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/string.h +1 -1
@@ -26,7 +26,7 @@ extern char * strncpy(char *,const charsize_t strlcpy (char *,const char *,size_t );#endif #ifndef __HAVE_ARCH_STRSCPY -ssize_t __must_check strscpy (char *,const char *,size_t ); +ssize_t strscpy (char *,const char *,size_t );#endif #ifndef __HAVE_ARCH_STRCATextern char *strcat (char *,const char *);
Greg Kroah-Hartman
maintainerPATCH 61/104 perf/core: Restore mmap record type correctly
In reply to Greg Kroah-Hartman[ Upstream commit d9c1bb2f6a2157b38e8eb63af437cb22701d31ee ]
On mmap(), perf_events generates a RECORD_MMAP record and then checks which events are interested in this record. There are currently 2 versions of mmap records: RECORD_MMAP and RECORD_MMAP2. MMAP2 is larger. The event configuration controls which version the user level tool accepts.
If the event->attr.mmap2=1 field then MMAP2 record is returned. The perf_event_mmap_output() takes care of this. It checks attr->mmap2 and corrects the record fields before putting it in the sampling buffer of the event. At the end the function restores the modified MMAP record fields.
The problem is that the function restores the size but not the type. Thus, if a subsequent event only accepts MMAP type, then it would instead receive an MMAP2 record with a size of MMAP record.
This patch fixes the problem by restoring the record type on exit.
--- kernel/events/core.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/events/core.c +2 -0
@@ -5533,6 +5533,7 @@ static void perf_event_mmap_output(struct perf_event *event,struct perf_output_handle handle;struct perf_sample_data sample;int size = mmap_event->event_id.header.size; +u32 type = mmap_event->event_id.header.type;int ret;if (!perf_event_mmap_match (event, data))
@@ -5576,6 +5577,7 @@ static void perf_event_mmap_output(struct perf_event *event,perf_output_end (&handle); out: mmap_event->event_id.header.size = size; + mmap_event->event_id.header.type = type; }static void perf_event_mmap_event (struct perf_mmap_event *mmap_event)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 62/104 ext4: report real fs size after failed resize
In reply to Greg Kroah-Hartman[ Upstream commit 6c7328400e0488f7d49e19e02290ba343b6811b2 ]
Currently when the file system resize using ext4_resize_fs() fails it will report into log that "resized filesystem to <requested block count>". However this may not be true in the case of failure. Use the current block count as returned by ext4_blocks_count() to report the block count.
Additionally, report a warning that "error occurred during file system resize"
--- fs/ext4/resize.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ext4/resize.c +5 -1
@@ -2042,6 +2042,10 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)free_flex_gd (flex_gd);if (resize_inode !=NULL )iput (resize_inode); -ext4_msg (sb,KERN_INFO ,"resized filesystem to %llu" , n_blocks_count); +if (err) +ext4_warning (sb,"error (%d) occurred during " +"file system resize" , err); +ext4_msg (sb,KERN_INFO ,"resized filesystem to %llu" , +ext4_blocks_count (es));return err; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 65/104 IB/mlx4: Fix race condition between catas error reset and aliasguid flows
In reply to Greg Kroah-Hartman[ Upstream commit 587443e7773e150ae29e643ee8f41a1eed226565 ]
Code review revealed a race condition which could allow the catas error flow to interrupt the alias guid query post mechanism at random points. Thiis is fixed by doing cancel_delayed_work_sync() instead of cancel_delayed_work() during the alias guid mechanism destroy flow.
--- drivers/infiniband/hw/mlx4/alias_GUID.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/alias_GUID.c +1 -1
@@ -579,8 +579,8 @@ void mlx4_ib_destroy_alias_guid_service(struct mlx4_ib_dev *dev)unsigned long flags;for (i =0 ; i < dev->num_ports; i++) { -cancel_delayed_work (&dev->sriov.alias_guid.ports_guid[i].alias_guid_work); det = &sriov->alias_guid.ports_guid[i]; +cancel_delayed_work_sync (&det->alias_guid_work);spin_lock_irqsave (&sriov->alias_guid.ag_work_lock, flags);while (!list_empty (&det->cb_list)) { cb_ctx = list_entry(det->cb_list.next,
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 64/104 ALSA: sb8: add a check for request_region
In reply to Greg Kroah-Hartman[ Upstream commit dcd0feac9bab901d5739de51b3f69840851f8919 ]
In case request_region fails, the fix returns an error code to avoid NULL pointer dereference.
--- sound/isa/sb/sb8.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/isa/sb/sb8.c +4 -0
@@ -111,6 +111,10 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)/* block the 0x388 port to avoid PnP conflicts */ acard->fm_res =request_region (0x388 ,4 ,"SoundBlaster FM" ); +if (!acard->fm_res) { + err = -EBUSY ; + goto _err; + } if (port[dev] != SNDRV_AUTO_PORT) { if ((err = snd_sbdsp_create(card, port[dev], irq[dev],
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 66/104 mmc: davinci: remove extraneous __init annotation
In reply to Greg Kroah-Hartman[ Upstream commit 9ce58dd7d9da3ca0d7cb8c9568f1c6f4746da65a ]
Building with clang finds a mistaken __init tag:
WARNING: vmlinux.o(.text+0x5e4250): Section mismatch in reference from the function davinci_mmcsd_probe() to the function .init.text:init_mmcsd_host() The function davinci_mmcsd_probe() references
the function __init init_mmcsd_host().
This is often because davinci_mmcsd_probe lacks a __init
annotation or the annotation of init_mmcsd_host is wrong.
--- drivers/mmc/host/davinci_mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/davinci_mmc.c +1 -1
@@ -1147,7 +1147,7 @@ static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host *host) { }#endif -static void __init init_mmcsd_host (struct mmc_davinci_host *host) +static void init_mmcsd_host (struct mmc_davinci_host *host) {mmc_davinci_reset_ctrl (host,1 );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 68/104 thermal/int340x_thermal: fix mode setting
In reply to Greg Kroah-Hartman[ Upstream commit 396ee4d0cd52c13b3f6421b8d324d65da5e7e409 ]
int3400 only pushes the UUID into the firmware when the mode is flipped to "enable". The current code only exposes the mode flag if the firmware supports the PASSIVE_1 UUID, which not all machines do. Remove the restriction.
--- drivers/thermal/int340x_thermal/int3400_thermal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/thermal/int340x_thermal/int3400_thermal.c +3 -4
@@ -208,10 +208,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, priv); -if (priv->uuid_bitmap &1 <<INT3400_THERMAL_PASSIVE_1 ) { - int3400_thermal_ops.get_mode = int3400_thermal_get_mode; - int3400_thermal_ops.set_mode = int3400_thermal_set_mode; - } + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; + int3400_thermal_ops.set_mode = int3400_thermal_set_mode; + priv->thermal =thermal_zone_device_register ("INT3400 Thermal" ,0 ,0 , priv, &int3400_thermal_ops, &int3400_thermal_params,0 ,0 );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 33/104 media: mt9m111: set initial frame size other than 0x0
In reply to Greg Kroah-Hartman[ Upstream commit 29856308137de1c21eda89411695f4fc6e9780ff ]
This driver sets initial frame width and height to 0x0, which is invalid. So set it to selection rectangle bounds instead.
This is detected by v4l2-compliance detected.
--- drivers/media/i2c/soc_camera/mt9m111.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/soc_camera/mt9m111.c +2 -0
@@ -983,6 +983,8 @@ static int mt9m111_probe(struct i2c_client *client, mt9m111->rect.top =MT9M111_MIN_DARK_ROWS ; mt9m111->rect.width =MT9M111_MAX_WIDTH ; mt9m111->rect.height =MT9M111_MAX_HEIGHT ; + mt9m111->width = mt9m111->rect.width; + mt9m111->height = mt9m111->rect.height; mt9m111->fmt = &mt9m111_colour_fmts[0 ]; mt9m111->lastpage =-1 ;mutex_init (&mt9m111->power_lock);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 69/104 tools/power turbostat: return the exit status of a command
In reply to Greg Kroah-Hartman[ Upstream commit 2a95496634a017c19641f26f00907af75b962f01 ]
turbostat failed to return a non-zero exit status even though the supplied command (turbostat <command>) failed. Currently when turbostat forks a command it returns zero instead of the actual exit status of the command. Modify the code to return the exit status.
--- tools/power/x86/turbostat/turbostat.c | 3 +++ 1 file changed, 3 insertions(+)
tools/power/x86/turbostat/turbostat.c +3 -0
@@ -2347,6 +2347,9 @@ int fork_it(char **argv)signal (SIGQUIT ,SIG_IGN );if (waitpid (child_pid, &status,0 ) ==-1 )err (status,"waitpid" ); + +if (WIFEXITED (status)) + status =WEXITSTATUS (status); }/* * n.b. fork_it() does not check for errors from for_all_cpus()
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 70/104 perf top: Fix error handling in cmd_top()
In reply to Greg Kroah-Hartman[ Upstream commit 70c819e4bf1c5f492768b399d898d458ccdad2b6 ]
We should go to the cleanup path, to avoid leaks, detected using gcc's ASan.
--- tools/perf/builtin-top.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/builtin-top.c +3 -2
@@ -1256,8 +1256,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) symbol_conf.priv_size =sizeof (struct annotation ); symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name ==NULL ); -if (symbol__init (NULL ) <0 ) -return -1 ; + status =symbol__init (NULL ); +if (status <0 ) + goto out_delete_evlist;sort__setup_elide (stdout);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 71/104 perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test()
In reply to Greg Kroah-Hartman[ Upstream commit d982b33133284fa7efa0e52ae06b88f9be3ea764 ]
=================================================================
==20875==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1160 byte(s) in 1 object(s) allocated from:
#0 0x7f1b6fc84138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
#1 0x55bd50005599 in zalloc util/util.h:23
#2 0x55bd500068f5 in perf_evsel__newtp_idx util/evsel.c:327
#3 0x55bd4ff810fc in perf_evsel__newtp /home/work/linux/tools/perf/util/evsel.h:216
#4 0x55bd4ff81608 in test__perf_evsel__tp_sched_test tests/evsel-tp-sched.c:69
#5 0x55bd4ff528e6 in run_test tests/builtin-test.c:358
#6 0x55bd4ff52baf in test_and_print tests/builtin-test.c:388
#7 0x55bd4ff543fe in __cmd_test tests/builtin-test.c:583
#8 0x55bd4ff5572f in cmd_test tests/builtin-test.c:722
#9 0x55bd4ffc4087 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#10 0x55bd4ffc45c6 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#11 0x55bd4ffc49ca in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#12 0x55bd4ffc5138 in main /home/changbin/work/linux/tools/perf/perf.c:520
#13 0x7f1b6e34809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)Indirect leak of 19 byte(s) in 1 object(s) allocated from:
#0 0x7f1b6fc83f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
#1 0x7f1b6e3ac30f in vasprintf (/lib/x86_64-linux-gnu/libc.so.6+0x8830f)--- tools/perf/tests/evsel-tp-sched.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/evsel-tp-sched.c +1 -0
@@ -78,5 +78,6 @@ int test__perf_evsel__tp_sched_test(void)if (perf_evsel__test_field (evsel,"target_cpu" ,4 , true)) ret =-1 ; +perf_evsel__delete (evsel);return ret; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 74/104 iommu/vt-d: Check capability before disabling protected memory
In reply to Greg Kroah-Hartman[ Upstream commit 5bb71fc790a88d063507dc5d445ab8b14e845591 ]
The spec states in 10.4.16 that the Protected Memory Enable Register should be treated as read-only for implementations not supporting protected memory regions (PLMR and PHMR fields reported as Clear in the Capability register).
--- drivers/iommu/intel-iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/intel-iommu.c +3 -0
@@ -1402,6 +1402,9 @@ static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu)u32 pmen;unsigned long flags; +if (!cap_plmr (iommu->cap) && !cap_phmr (iommu->cap)) +return ; +raw_spin_lock_irqsave (&iommu->register_lock, flags); pmen =readl (iommu->reg +DMAR_PMEN_REG ); pmen &= ~DMA_PMEN_EPM ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 76/104 rsi: improve kernel thread handling to fix kernel panic
In reply to Greg Kroah-Hartman[ Upstream commit 4c62764d0fc21a34ffc44eec1210038c3a2e4473 ]
While running regressions, observed below kernel panic when sdio disconnect called. This is because of, kthread_stop() is taking care of wait_for_completion() by default. When wait_for_completion triggered in kthread_stop and as it was done already, giving kernel panic. Hence, removing redundant wait_for_completion() from rsi_kill_thread().
... skipping ...
BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff810a63df>] exit_creds+0x1f/0x50 PGD 0 Oops: 0002 [#1] SMP CPU: 0 PID: 6502 Comm: rmmod Tainted: G OE 4.15.9-Generic #154-Ubuntu Hardware name: Dell Inc. Edge Gateway 3003/ , BIOS 01.00.00 04/17/2017 Stack: ffff88007392e600 ffff880075847dc0 ffffffff8108160a 0000000000000000 ffff88007392e600 ffff880075847de8 ffffffff810a484b ffff880076127000 ffff88003cd3a800 ffff880074f12a00 ffff880075847e28 ffffffffc09bed15 Call Trace: [<ffffffff8108160a>] __put_task_struct+0x5a/0x140 [<ffffffff810a484b>] kthread_stop+0x10b/0x110 [<ffffffffc09bed15>] rsi_disconnect+0x2f5/0x300 [ven_rsi_sdio] [<ffffffff81578bcb>] ? __pm_runtime_resume+0x5b/0x80 [<ffffffff816f0918>] sdio_bus_remove+0x38/0x100 [<ffffffff8156cc64>] __device_release_driver+0xa4/0x150 [<ffffffff8156d7a5>] driver_detach+0xb5/0xc0 [<ffffffff8156c6c5>] bus_remove_driver+0x55/0xd0 [<ffffffff8156dfbc>] driver_unregister+0x2c/0x50 [<ffffffff816f0b8a>] sdio_unregister_driver+0x1a/0x20 [<ffffffffc09bf0f5>] rsi_module_exit+0x15/0x30 [ven_rsi_sdio] [<ffffffff8110cad8>] SyS_delete_module+0x1b8/0x210 [<ffffffff81851dc8>] entry_SYSCALL_64_fastpath+0x1c/0xbb
--- drivers/net/wireless/rsi/rsi_common.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/rsi/rsi_common.h +0 -1
@@ -75,7 +75,6 @@ static inline int rsi_kill_thread(struct rsi_thread *handle)atomic_inc (&handle->thread_done);rsi_set_event (&handle->event); -wait_for_completion (&handle->completion);return kthread_stop (handle->task); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 75/104 fix incorrect error code mapping for OBJECTID_NOT_FOUND
In reply to Greg Kroah-Hartman[ Upstream commit 85f9987b236cf46e06ffdb5c225cf1f3c0acb789 ]
It was mapped to EIO which can be confusing when user space queries for an object GUID for an object for which the server file system doesn't support (or hasn't saved one).
As Amir Goldstein suggested this is similar to ENOATTR (equivalently ENODATA in Linux errno definitions) so changing NT STATUS code mapping for OBJECTID_NOT_FOUND to ENODATA.
--- fs/cifs/smb2maperror.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/smb2maperror.c +2 -1
@@ -1034,7 +1034,8 @@ static const struct status_to_posix_error smb2_error_map_table[] = { {STATUS_UNFINISHED_CONTEXT_DELETED , -EIO , "STATUS_UNFINISHED_CONTEXT_DELETED"}, {STATUS_NO_TGT_REPLY, -EIO, "STATUS_NO_TGT_REPLY"}, - {STATUS_OBJECTID_NOT_FOUND, -EIO, "STATUS_OBJECTID_NOT_FOUND"}, +/* Note that ENOATTTR and ENODATA are the same errno */ + {STATUS_OBJECTID_NOT_FOUND, -ENODATA, "STATUS_OBJECTID_NOT_FOUND"}, {STATUS_NO_IP_ADDRESSES, -EIO, "STATUS_NO_IP_ADDRESSES"}, {STATUS_WRONG_CREDENTIAL_HANDLE, -EIO, "STATUS_WRONG_CREDENTIAL_HANDLE"},
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 34/104 hwrng: virtio - Avoid repeated init of completion
In reply to Greg Kroah-Hartman[ Upstream commit aef027db48da56b6f25d0e54c07c8401ada6ce21 ]
The virtio-rng driver uses a completion called have_data to wait for a virtio read to be fulfilled by the hypervisor. The completion is reset before placing a buffer on the virtio queue and completed by the virtio callback once data has been written into the buffer.
Prior to this commit, the driver called init_completion on this completion both during probe as well as when registering virtio buffers as part of a hwrng read operation. The second of these init_completion calls should instead be reinit_completion because the have_data completion has already been inited by probe. As described in Documentation/scheduler/completion.txt, "Calling init_completion() twice on the same completion object is most likely a bug".
This bug was present in the initial implementation of virtio-rng in f7f510ec1957 ("virtio: An entropy device, as suggested by hpa"). Back then the have_data completion was a single static completion rather than a member of one of potentially multiple virtrng_info structs as implemented later by 08e53fbdb85c ("virtio-rng: support multiple virtio-rng devices"). The original driver incorrectly used init_completion rather than INIT_COMPLETION to reset have_data during read.
Tested by running head -c48 /dev/random | hexdump within crosvm, the Chrome OS virtual machine monitor, and confirming that the virtio-rng driver successfully produces random bytes from the host.
--- drivers/char/hw_random/virtio-rng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/virtio-rng.c +1 -1
@@ -74,7 +74,7 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)if (!vi->busy) { vi->busy = true; -init_completion (&vi->have_data); +reinit_completion (&vi->have_data);register_buffer (vi, buf, size); }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 35/104 hpet: Fix missing = character in the __setup() code of hpet_mmap_enable
In reply to Greg Kroah-Hartman[ Upstream commit 24d48a61f2666630da130cc2ec2e526eacf229e3 ]
Commit '3d035f580699 ("drivers/char/hpet.c: allow user controlled mmap for user processes")' introduced a new kernel command line parameter hpet_mmap, that is required to expose the memory map of the HPET registers to user-space. Unfortunately the kernel command line parameter 'hpet_mmap' is broken and never takes effect due to missing '=' character in the __setup() code of hpet_mmap_enable.
Before this patch:
dmesg output with the kernel command line parameter hpet_mmap=1
[ 0.204152] HPET mmap disabled
dmesg output with the kernel command line parameter hpet_mmap=0
[ 0.204192] HPET mmap disabled
After this patch:
dmesg output with the kernel command line parameter hpet_mmap=1
[ 0.203945] HPET mmap enabled
dmesg output with the kernel command line parameter hpet_mmap=0
[ 0.204652] HPET mmap disabled
--- drivers/char/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hpet.c +1 -1
@@ -377,7 +377,7 @@ static __init int hpet_mmap_enable(char *str)pr_info ("HPET mmap %s\n" , hpet_mmap_enabled ?"enabled" :"disabled" );return 1 ; } -__setup ("hpet_mmap" , hpet_mmap_enable); +__setup ("hpet_mmap=" , hpet_mmap_enable);static int hpet_mmap (struct file *file,struct vm_area_struct *vma) {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 36/104 dmaengine: imx-dma: fix warning comparison of distinct pointer types
In reply to Greg Kroah-Hartman[ Upstream commit 9227ab5643cb8350449502dd9e3168a873ab0e3b ]
The warning got introduced by commit 930507c18304 ("arm64: add basic Kconfig symbols for i.MX8"). Since it got enabled for arm64. The warning haven't been seen before since size_t was 'unsigned int' when built on arm32.
../drivers/dma/imx-dma.c: In function ‘imxdma_sg_next’:../include/linux/kernel.h:846:29: warning: comparison of distinct pointer types lacks a cast
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^~
../include/linux/kernel.h:860:4: note: in expansion of macro ‘__typecheck’
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~
../include/linux/kernel.h:870:24: note: in expansion of macro ‘__safe_cmp’
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~
../include/linux/kernel.h:879:19: note: in expansion of macro ‘__careful_cmp’
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~
../drivers/dma/imx-dma.c:288:8: note: in expansion of macro ‘min’
now = min(d->len, sg_dma_len(sg));
^~~Rework so that we use min_t and pass in the size_t that returns the minimum of two values, using the specified type.
--- drivers/dma/imx-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/imx-dma.c +1 -1
@@ -291,7 +291,7 @@ static inline int imxdma_sg_next(struct imxdma_desc *d)struct scatterlist *sg = d->sg;unsigned long now; - now =min (d->len,sg_dma_len (sg)); + now =min_t (size_t, d->len,sg_dma_len (sg));if (d->len !=IMX_DMA_LENGTH_LOOP ) d->len -= now;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 38/104 wlcore: Fix memory leak in case wl12xx_fetch_firmware failure
In reply to Greg Kroah-Hartman[ Upstream commit ba2ffc96321c8433606ceeb85c9e722b8113e5a7 ]
Release fw_status, raw_fw_status, and tx_res_if when wl12xx_fetch_firmware failed instead of meaningless goto out to avoid the following memory leak reports(Only the last one listed):
unreferenced object 0xc28a9a00 (size 512):
comm "kworker/0:4", pid 31298, jiffies 2783204 (age 203.290s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<6624adab>] kmemleak_alloc+0x40/0x74
[<500ddb31>] kmem_cache_alloc_trace+0x1ac/0x270
[<db4d731d>] wl12xx_chip_wakeup+0xc4/0x1fc [wlcore]
[<76c5db53>] wl1271_op_add_interface+0x4a4/0x8f4 [wlcore]
[<cbf30777>] drv_add_interface+0xa4/0x1a0 [mac80211]
[<65bac325>] ieee80211_reconfig+0x9c0/0x1644 [mac80211]
[<2817c80e>] ieee80211_restart_work+0x90/0xc8 [mac80211]
[<7e1d425a>] process_one_work+0x284/0x42c
[<55f9432e>] worker_thread+0x2fc/0x48c
[<abb582c6>] kthread+0x148/0x160
[<63144b13>] ret_from_fork+0x14/0x2c
[< (null)>] (null)
[<1f6e7715>] 0xffffffff--- drivers/net/wireless/ti/wlcore/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ti/wlcore/main.c +5 -2
@@ -1110,8 +1110,11 @@ static int wl12xx_chip_wakeup(struct wl1271 *wl, bool plt) goto out; ret =wl12xx_fetch_firmware (wl, plt); -if (ret <0 ) - goto out; +if (ret <0 ) { +kfree (wl->fw_status); +kfree (wl->raw_fw_status); +kfree (wl->tx_res_if); + } out:return ret;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 79/104 serial: uartps: console_setup() cant be placed to init section
In reply to Greg Kroah-Hartman[ Upstream commit 4bb1ce2350a598502b23088b169e16b43d4bc639 ]
When console device is rebinded, console_setup() is called again. But marking it as __init means that function will be clear after boot is complete. If console device is binded again console_setup() is not found and error "Unable to handle kernel paging request at virtual address" is reported.
--- drivers/tty/serial/xilinx_uartps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/xilinx_uartps.c +1 -1
@@ -1120,7 +1120,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,* * Return: 0 on success, negative errno otherwise. */ -static int __init cdns_uart_console_setup (struct console *co,char *options) +static int cdns_uart_console_setup (struct console *co,char *options) {struct uart_port *port = &cdns_uart_port[co->index];int baud =9600 ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 88/104 crypto: crypto4xx - properly set IV after de- and encrypt
In reply to Greg Kroah-Hartman[ Upstream commit fc340115ffb8235c1bbd200c28855e6373d0dd1a ]
This patch fixes cts(cbc(aes)) test when cbc-aes-ppc4xx is used.
alg: skcipher: Test 1 failed (invalid result) on encryption for cts(cbc-aes-ppc4xx) 00000000: 4b 10 75 fc 2f 14 1b 6a 27 35 37 33 d1 b7 70 05
00000010: 97
alg: skcipher: Failed to load transform for cts(cbc(aes)): -2
The CTS cipher mode expect the IV (req->iv) of skcipher_request to contain the last ciphertext block after the {en,de}crypt operation is complete.
Fix this issue for the AMCC Crypto4xx hardware engine. The tcrypt test case for cts(cbc(aes)) is now correctly passed.
name : cts(cbc(aes))
driver : cts(cbc-aes-ppc4xx)
module : cts
priority : 300
refcnt : 1
selftest : passed
internal : no
type : skcipher
async : yes
blocksize : 16
min keysize : 16
max keysize : 32
ivsize : 16
chunksize : 16
walksize : 16
--- drivers/crypto/amcc/crypto4xx_alg.c | 3 ++- drivers/crypto/amcc/crypto4xx_core.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/crypto/amcc/crypto4xx_alg.c +2 -1
@@ -138,7 +138,8 @@ static int crypto4xx_setkey_aes(struct crypto_ablkcipher *cipher, sa = (struct dynamic_sa_ctl *) ctx->sa_in; ctx->hash_final =0 ; - set_dynamic_sa_command_0(sa, SA_NOT_SAVE_HASH, SA_NOT_SAVE_IV, + set_dynamic_sa_command_0(sa, SA_NOT_SAVE_HASH, (cm == CRYPTO_MODE_CBC ? + SA_SAVE_IV : SA_NOT_SAVE_IV), SA_LOAD_HASH_FROM_SA, SA_LOAD_IV_FROM_STATE, SA_NO_HEADER_PROC, SA_HASH_ALG_NULL, SA_CIPHER_ALG_AES, SA_PAD_TYPE_ZERO,
drivers/crypto/amcc/crypto4xx_core.c +9 -0
@@ -645,6 +645,15 @@ static u32 crypto4xx_ablkcipher_done(struct crypto4xx_device *dev, addr =dma_map_page (dev->core_dev->device,sg_page (dst), dst->offset, dst->length,DMA_FROM_DEVICE ); } + +if (pd_uinfo->sa_va->sa_command_0.bf.save_iv ==SA_SAVE_IV ) { +struct crypto_skcipher *skcipher =crypto_skcipher_reqtfm (req); + +crypto4xx_memcpy_from_le32 ((u32 *)req->iv, + pd_uinfo->sr_va->save_iv, +crypto_skcipher_ivsize (skcipher)); + } +crypto4xx_ret_sg_desc (dev, pd_uinfo);if (ablk_req->base.complete !=NULL ) ablk_req->base.complete (&ablk_req->base,0 );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 90/104 bonding: fix event handling for stacked bonds
In reply to Greg Kroah-HartmanFrom: Sabrina Dubroca <[email protected]>
[ Upstream commit 92480b3977fd3884649d404cbbaf839b70035699 ]
When a bond is enslaved to another bond, bond_netdev_event() only handles the event as if the bond is a master, and skips treating the bond as a slave.
This leads to a refcount leak on the slave, since we don't remove the adjacency to its master and the master holds a reference on the slave.
Reproducer:
ip link add bondL type bond
ip link add bondU type bond
ip link set bondL master bondU
ip link del bondL
No "Fixes:" tag, this code is older than git history.
--- drivers/net/bonding/bond_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +5 -1
@@ -2958,8 +2958,12 @@ static int bond_netdev_event(struct notireturn NOTIFY_DONE ;if (event_dev->flags &IFF_MASTER ) { +int ret; +netdev_dbg (event_dev,"IFF_MASTER\n" ); -return bond_master_netdev_event (event, event_dev); + ret =bond_master_netdev_event (event, event_dev); +if (ret !=NOTIFY_DONE ) +return ret; }if (event_dev->flags &IFF_SLAVE ) {
Greg Kroah-Hartman
maintainerPATCH 89/104 tpm/tpm_i2c_atmel: Return -E2BIG when the transfer is incomplete
In reply to Greg Kroah-Hartmancommit 442601e87a4769a8daba4976ec3afa5222ca211d upstream
Return -E2BIG when the transfer is incomplete. The upper layer does not retry, so not doing that is incorrect behaviour.
--- drivers/char/tpm/tpm_i2c_atmel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_i2c_atmel.c +9 -1
@@ -65,7 +65,15 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)dev_dbg (chip->dev,"%s(buf=%*ph len=%0zx) -> sts=%d\n" , __func__, (int )min_t (size_t,64 , len), buf, len, status); -return status; + +if (status <0 ) +return status; + +/* The upper layer does not support incomplete sends. */ +if (status != len) +return -E2BIG ; + +return 0 ; }static int i2c_atmel_recv (struct tpm_chip *chip,u8 *buf,size_t count)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 92/104 ipv4: recompile ip options in ipv4_link_failure
In reply to Greg Kroah-HartmanFrom: Stephen Suryaputra <[email protected]>
[ Upstream commit ed0de45a1008991fdaa27a0152befcb74d126a8b ]
Recompile IP options since IPCB may not be valid anymore when ipv4_link_failure is called from arp_error_report.
Refer to the commit 3da1ed7ac398 ("net: avoid use IPCB in cipso_v4_error") and the commit before that (9ef6b42ad6fd) for a similar issue.
--- net/ipv4/route.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/ipv4/route.c +9 -1
@@ -1151,8 +1151,16 @@ static struct dst_entry *ipv4_dst_check(static void ipv4_link_failure (struct sk_buff *skb) {struct rtable *rt; +struct ip_options opt; -icmp_send (skb,ICMP_DEST_UNREACH ,ICMP_HOST_UNREACH ,0 ); +/* Recompile ip options since IPCB may not be valid anymore. +*/ +memset (&opt,0 ,sizeof (opt)); + opt.optlen =ip_hdr (skb)->ihl*4 -sizeof (struct iphdr ); +if (__ip_options_compile (dev_net (skb->dev), &opt, skb,NULL )) +return ; + +__icmp_send (skb,ICMP_DEST_UNREACH ,ICMP_HOST_UNREACH ,0 , &opt); rt =skb_rtable (skb);if (rt)
Greg Kroah-Hartman
maintainerPATCH 93/104 ipv4: ensure rcu_read_lock() in ipv4_link_failure()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit c543cb4a5f07e09237ec0fc2c60c9f131b2c79ad ]
fib_compute_spec_dst() needs to be called under rcu protection.
syzbot reported :
WARNING: suspicious RCU usage
5.1.0-rc4+ #165 Not taintedinclude/linux/inetdevice.h:220 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by swapper/0/0:
#0: 0000000051b67925 ((&n->timer)){+.-.}, at: lockdep_copy_map include/linux/lockdep.h:170 [inline] #0: 0000000051b67925 ((&n->timer)){+.-.}, at: call_timer_fn+0xda/0x720 kernel/time/timer.c:1315
stack backtrace: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.1.0-rc4+ #165 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x172/0x1f0 lib/dump_stack.c:113 lockdep_rcu_suspicious+0x153/0x15d kernel/locking/lockdep.c:5162 __in_dev_get_rcu include/linux/inetdevice.h:220 [inline] fib_compute_spec_dst+0xbbd/0x1030 net/ipv4/fib_frontend.c:294 spec_dst_fill net/ipv4/ip_options.c:245 [inline] __ip_options_compile+0x15a7/0x1a10 net/ipv4/ip_options.c:343 ipv4_link_failure+0x172/0x400 net/ipv4/route.c:1195 dst_link_failure include/net/dst.h:427 [inline] arp_error_report+0xd1/0x1c0 net/ipv4/arp.c:297 neigh_invalidate+0x24b/0x570 net/core/neighbour.c:995 neigh_timer_handler+0xc35/0xf30 net/core/neighbour.c:1081 call_timer_fn+0x190/0x720 kernel/time/timer.c:1325 expire_timers kernel/time/timer.c:1362 [inline] __run_timers kernel/time/timer.c:1681 [inline] __run_timers kernel/time/timer.c:1649 [inline] run_timer_softirq+0x652/0x1700 kernel/time/timer.c:1694 __do_softirq+0x266/0x95a kernel/softirq.c:293 invoke_softirq kernel/softirq.c:374 [inline] irq_exit+0x180/0x1d0 kernel/softirq.c:414 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0x14a/0x570 arch/x86/kernel/apic/apic.c:1062 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:807
--- net/ipv4/route.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/ipv4/route.c +8 -2
@@ -1150,14 +1150,20 @@ static struct dst_entry *ipv4_dst_check(static void ipv4_link_failure (struct sk_buff *skb) { -struct rtable *rt;struct ip_options opt; +struct rtable *rt; +int res;/* Recompile ip options since IPCB may not be valid anymore. */ memset (&opt,0 ,sizeof (opt)); opt.optlen =ip_hdr (skb)->ihl*4 -sizeof (struct iphdr ); -if (__ip_options_compile (dev_net (skb->dev), &opt, skb,NULL )) + +rcu_read_lock (); + res =__ip_options_compile (dev_net (skb->dev), &opt, skb,NULL ); +rcu_read_unlock (); + +if (res)return ;__icmp_send (skb,ICMP_DEST_UNREACH ,ICMP_HOST_UNREACH ,0 , &opt);
Greg Kroah-Hartman
maintainerPATCH 95/104 iio: ad_sigma_delta: select channel when reading register
In reply to Greg Kroah-HartmanFrom: Dragos Bogdan <[email protected]>
commit fccfb9ce70ed4ea7a145f77b86de62e38178517f upstream.
The desired channel has to be selected in order to correctly fill the buffer with the corresponding data.
The ad_sd_write_reg() already does this, but for the ad_sd_read_reg_raw() this was omitted.
--- drivers/iio/adc/ad_sigma_delta.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/adc/ad_sigma_delta.c +1 -0
@@ -121,6 +121,7 @@ static int ad_sd_read_reg_raw(struct ad_if (sigma_delta->info->has_registers) { data[0 ] = reg << sigma_delta->info->addr_shift; data[0 ] |= sigma_delta->info->read_mask; + data[0 ] |= sigma_delta->comm;spi_message_add_tail (&t[0 ], &m); }spi_message_add_tail (&t[1 ], &m);
Greg Kroah-Hartman
maintainerPATCH 96/104 iio: adc: at91: disable adc channel interrupt in timeout case
In reply to Greg Kroah-HartmanFrom: Georg Ottinger <[email protected]>
commit 09c6bdee51183a575bf7546890c8c137a75a2b44 upstream.
Having a brief look at at91_adc_read_raw() it is obvious that in the case of a timeout the setting of AT91_ADC_CHDR and AT91_ADC_IDR registers is omitted. If 2 different channels are queried we can end up with a situation where two interrupts are enabled, but only one interrupt is cleared in the interrupt handler. Resulting in a interrupt loop and a system hang.
--- drivers/iio/adc/at91_adc.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/iio/adc/at91_adc.c +17 -11
@@ -703,23 +703,29 @@ static int at91_adc_read_raw(struct iio_ ret =wait_event_interruptible_timeout (st->wq_data_avail, st->done,msecs_to_jiffies (1000 )); -if (ret ==0 ) - ret = -ETIMEDOUT ; -if (ret <0 ) { -mutex_unlock (&st->lock); -return ret; - } - - *val = st->last_value; +/* Disable interrupts, regardless if adc conversion was +* successful or not +*/ at91_adc_writel (st,AT91_ADC_CHDR ,AT91_ADC_CH (chan->channel));at91_adc_writel (st,AT91_ADC_IDR ,BIT (chan->channel)); - st->last_value =0 ; - st->done = false; +if (ret >0 ) { +/* a valid conversion took place */ + *val = st->last_value; + st->last_value =0 ; + st->done = false; + ret =IIO_VAL_INT ; + }else if (ret ==0 ) { +/* conversion timeout */ +dev_err (&idev->dev,"ADC Channel %d timeout.\n" , + chan->channel); + ret = -ETIMEDOUT ; + } +mutex_unlock (&st->lock); -return IIO_VAL_INT ; +return ret;case IIO_CHAN_INFO_SCALE : *val = st->vref_mv;
Greg Kroah-Hartman
maintainerPATCH 80/104 ARM: samsung: Limit SAMSUNG_PM_CHECK config option to non-Exynos platforms
In reply to Greg Kroah-Hartman[ Upstream commit 6862fdf2201ab67cd962dbf0643d37db909f4860 ]
"S3C2410 PM Suspend Memory CRC" feature (controlled by SAMSUNG_PM_CHECK config option) is incompatible with highmem (uses phys_to_virt() instead of proper mapping) which is used by the majority of Exynos boards. The issue manifests itself in OOPS on affected boards, i.e. on Odroid-U3 I got the following one:
Unable to handle kernel paging request at virtual address f0000000 pgd = 1c0f9bb4 [f0000000] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM [<c0458034>] (crc32_le) from [<c0121f8c>] (s3c_pm_makecheck+0x34/0x54) [<c0121f8c>] (s3c_pm_makecheck) from [<c0121efc>] (s3c_pm_run_res+0x74/0x8c) [<c0121efc>] (s3c_pm_run_res) from [<c0121ecc>] (s3c_pm_run_res+0x44/0x8c) [<c0121ecc>] (s3c_pm_run_res) from [<c01210b8>] (exynos_suspend_enter+0x64/0x148) [<c01210b8>] (exynos_suspend_enter) from [<c018893c>] (suspend_devices_and_enter+0x9ec/0xe74) [<c018893c>] (suspend_devices_and_enter) from [<c0189534>] (pm_suspend+0x770/0xc04) [<c0189534>] (pm_suspend) from [<c0186ce8>] (state_store+0x6c/0xcc) [<c0186ce8>] (state_store) from [<c09db434>] (kobj_attr_store+0x14/0x20) [<c09db434>] (kobj_attr_store) from [<c02fa63c>] (sysfs_kf_write+0x4c/0x50) [<c02fa63c>] (sysfs_kf_write) from [<c02f97a4>] (kernfs_fop_write+0xfc/0x1e4) [<c02f97a4>] (kernfs_fop_write) from [<c027b198>] (__vfs_write+0x2c/0x140) [<c027b198>] (__vfs_write) from [<c027b418>] (vfs_write+0xa4/0x160) [<c027b418>] (vfs_write) from [<c027b5d8>] (ksys_write+0x40/0x8c) [<c027b5d8>] (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
Add PLAT_S3C24XX, ARCH_S3C64XX and ARCH_S5PV210 dependencies to SAMSUNG_PM_CHECK config option to hide it on Exynos platforms.
--- arch/arm/plat-samsung/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-samsung/Kconfig +1 -1
@@ -287,7 +287,7 @@ config S3C_PM_DEBUG_LED_SMDK config SAMSUNG_PM_CHECK bool "S3C2410 PM Suspend Memory CRC" - depends on PM + depends on PM && (PLAT_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210) select CRC32 help Enable the PM code's memory area checksum over sleep. This option
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 98/104 staging: comedi: vmk80xx: Fix possible double-free of ->usb_rx_buf
In reply to Greg Kroah-HartmanFrom: Ian Abbott <[email protected]>
commit 663d294b4768bfd89e529e069bffa544a830b5bf upstream.
vmk80xx_alloc_usb_buffers() is called from vmk80xx_auto_attach() to allocate RX and TX buffers for USB transfers. It allocates devpriv->usb_rx_buf followed by devpriv->usb_tx_buf. If the allocation of devpriv->usb_tx_buf fails, it frees devpriv->usb_rx_buf, leaving the pointer set dangling, and returns an error. Later, vmk80xx_detach() will be called from the core comedi module code to clean up. vmk80xx_detach() also frees both devpriv->usb_rx_buf and devpriv->usb_tx_buf, but devpriv->usb_rx_buf may have already been freed, leading to a double-free error. Fix it by removing the call to kfree(devpriv->usb_rx_buf) from vmk80xx_alloc_usb_buffers(), relying on vmk80xx_detach() to free the memory.
--- drivers/staging/comedi/drivers/vmk80xx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/vmk80xx.c +1 -3
@@ -757,10 +757,8 @@ static int vmk80xx_alloc_usb_buffers(str size =le16_to_cpu (devpriv->ep_tx->wMaxPacketSize); devpriv->usb_tx_buf =kzalloc (size,GFP_KERNEL ); -if (!devpriv->usb_tx_buf) { -kfree (devpriv->usb_rx_buf); +if (!devpriv->usb_tx_buf)return -ENOMEM ; - }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 99/104 staging: comedi: ni_usb6501: Fix possible double-free of ->usb_rx_buf
In reply to Greg Kroah-HartmanFrom: Ian Abbott <[email protected]>
commit af4b54a2e5ba18259ff9aac445bf546dd60d037e upstream.
ni6501_alloc_usb_buffers() is called from ni6501_auto_attach() to allocate RX and TX buffers for USB transfers. It allocates devpriv->usb_rx_buf followed by devpriv->usb_tx_buf. If the allocation of devpriv->usb_tx_buf fails, it frees devpriv->usb_rx_buf, leaving the pointer set dangling, and returns an error. Later, ni6501_detach() will be called from the core comedi module code to clean up. ni6501_detach() also frees both devpriv->usb_rx_buf and devpriv->usb_tx_buf, but devpriv->usb_rx_buf may have already beed freed, leading to a double-free error. Fix it bu removing the call to kfree(devpriv->usb_rx_buf) from ni6501_alloc_usb_buffers(), relying on ni6501_detach() to free the memory.
--- drivers/staging/comedi/drivers/ni_usb6501.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/ni_usb6501.c +1 -3
@@ -478,10 +478,8 @@ static int ni6501_alloc_usb_buffers(stru size =le16_to_cpu (devpriv->ep_tx->wMaxPacketSize); devpriv->usb_tx_buf =kzalloc (size,GFP_KERNEL ); -if (!devpriv->usb_tx_buf) { -kfree (devpriv->usb_rx_buf); +if (!devpriv->usb_tx_buf)return -ENOMEM ; - }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 100/104 ALSA: core: Fix card races between register and disconnect
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 2a3f7221acddfe1caa9ff09b3a8158c39b2fdeac upstream.
There is a small race window in the card disconnection code that allows the registration of another card with the very same card id. This leads to a warning in procfs creation as caught by syzkaller.
The problem is that we delete snd_cards and snd_cards_lock entries at the very beginning of the disconnection procedure. This makes the slot available to be assigned for another card object while the disconnection procedure is being processed. Then it becomes possible to issue a procfs registration with the existing file name although we check the conflict beforehand.
The fix is simply to move the snd_cards and snd_cards_lock clearances at the end of the disconnection procedure. The references to these entries are merely either from the global proc files like /proc/asound/cards or from the card registration / disconnection, so it should be fine to shift at the very end.
--- sound/core/init.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
sound/core/init.c +9 -9
@@ -389,14 +389,7 @@ int snd_card_disconnect(struct snd_card card->shutdown =1 ;spin_unlock (&card->files_lock); -/* phase 1: disable fops (user space) operations for ALSA API */ -mutex_lock (&snd_card_mutex); - snd_cards[card->number] =NULL ; -clear_bit (card->number, snd_cards_lock); -mutex_unlock (&snd_card_mutex); - -/* phase 2: replace file->f_op with special dummy operations */ - +/* replace file->f_op with special dummy operations */ spin_lock (&card->files_lock);list_for_each_entry (mfile, &card->files_list, list) {/* it's critical part, use endless loop */
@@ -412,7 +405,7 @@ int snd_card_disconnect(struct snd_card }spin_unlock (&card->files_lock); -/* phase 3: notify all connected devices about disconnection */ +/* notify all connected devices about disconnection */ /* at this point, they cannot respond to any calls except release() */ #if IS_ENABLED (CONFIG_SND_MIXER_OSS )
@@ -430,6 +423,13 @@ int snd_card_disconnect(struct snd_carddevice_del (&card->card_dev); card->registered = false; } + +/* disable fops (user space) operations for ALSA API */ +mutex_lock (&snd_card_mutex); + snd_cards[card->number] =NULL ; +clear_bit (card->number, snd_cards_lock); +mutex_unlock (&snd_card_mutex); +#ifdef CONFIG_PM wake_up (&card->power_sleep);#endif
Greg Kroah-Hartman
maintainerPATCH 103/104 sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup
In reply to Greg Kroah-Hartman[ Upstream commit 2e8e19226398db8265a8e675fcc0118b9e80c9e8 ]
With extremely short cfs_period_us setting on a parent task group with a large number of children the for loop in sched_cfs_period_timer() can run until the watchdog fires. There is no guarantee that the call to hrtimer_forward_now() will ever return 0. The large number of children can make do_sched_cfs_period_timer() take longer than the period.
NMI watchdog: Watchdog detected hard LOCKUP on cpu 24
RIP: 0010:tg_nop+0x0/0x10 <IRQ> walk_tg_tree_from+0x29/0xb0 unthrottle_cfs_rq+0xe0/0x1a0 distribute_cfs_runtime+0xd3/0xf0 sched_cfs_period_timer+0xcb/0x160 ? sched_cfs_slack_timer+0xd0/0xd0 __hrtimer_run_queues+0xfb/0x270 hrtimer_interrupt+0x122/0x270 smp_apic_timer_interrupt+0x6a/0x140 apic_timer_interrupt+0xf/0x20 </IRQ>
To prevent this we add protection to the loop that detects when the loop has run too many times and scales the period and quota up, proportionally, so that the timer can complete before then next period expires. This preserves the relative runtime quota while preventing the hard lockup.
A warning is issued reporting this state and the new values.
--- kernel/sched/fair.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
kernel/sched/fair.c +25 -0
@@ -3771,6 +3771,8 @@ static enum hrtimer_restart sched_cfs_slack_timer(struct hrtimer *timer)return HRTIMER_NORESTART ; } +extern const u64 max_cfs_quota_period; +static enum hrtimer_restart sched_cfs_period_timer (struct hrtimer *timer) { struct cfs_bandwidth *cfs_b =
@@ -3778,6 +3780,7 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)ktime_t now;int overrun;int idle =0 ; +int count =0 ;raw_spin_lock (&cfs_b->lock);for (;;) {
@@ -3787,6 +3790,28 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)if (!overrun)break ; +if (++count >3 ) { +u64 new, old =ktime_to_ns (cfs_b->period); + + new = (old *147 ) /128 ;/* ~115% */ + new =min (new, max_cfs_quota_period); + + cfs_b->period =ns_to_ktime (new); + +/* since max is 1s, this is limited to 1e9^2, which fits in u64 */ + cfs_b->quota *= new; + cfs_b->quota =div64_u64 (cfs_b->quota, old); + +pr_warn_ratelimited ( +"cfs_period_timer[cpu%d]: period too short, scaling up (new cfs_period_us %lld, cfs_quota_us = %lld)\n" , +smp_processor_id (), +div_u64 (new,NSEC_PER_USEC ), +div_u64 (cfs_b->quota,NSEC_PER_USEC )); + +/* reset count so we don't come right back in here */ + count =0 ; + } + idle =do_sched_cfs_period_timer (cfs_b, overrun); }raw_spin_unlock (&cfs_b->lock);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 102/104 kprobes: Fix error check when reusing optimized probes
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit 5f843ed415581cfad4ef8fefe31c138a8346ca8a upstream.
The following commit introduced a bug in one of our error paths:
819319fc9346 ("kprobes: Return error if we fail to reuse kprobe instead of BUG_ON()")
it missed to handle the return value of kprobe_optready() as error-value. In reality, the kprobe_optready() returns a bool result, so "true" case must be passed instead of 0.
This causes some errors on kprobe boot-time selftests on ARM:
[ ] Beginning kprobe tests... [ ] Probe ARM code [ ] kprobe [ ] kretprobe [ ] ARM instruction simulation [ ] Check decoding tables [ ] Run test cases [ ] FAIL: test_case_handler not run [ ] FAIL: Test andge r10, r11, r14, asr r7 [ ] FAIL: Scenario 11 ... [ ] FAIL: Scenario 7 [ ] Total instruction simulation tests=1631, pass=1433 fail=198 [ ] kprobe tests failed
This can happen if an optimized probe is unregistered and next kprobe is registered on same address until the previous probe is not reclaimed.
If this happens, a hidden aggregated probe may be kept in memory, and no new kprobe can probe same address. Also, in that case register_kprobe() will return "1" instead of minus error value, which can mislead caller logic.
--- kernel/kprobes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/kprobes.c +2 -4
@@ -668,7 +668,6 @@ static void unoptimize_kprobe(struct kprstatic int reuse_unused_kprobe (struct kprobe *ap) {struct optimized_kprobe *op; -int ret;BUG_ON (!kprobe_unused (ap));/*
@@ -682,9 +681,8 @@ static int reuse_unused_kprobe(struct kp/* Enable the probe again */ ap->flags &= ~KPROBE_FLAG_DISABLED ;/* Optimize it again (remove from op->list) */ - ret =kprobe_optready (ap); -if (ret) -return ret; +if (!kprobe_optready (ap)) +return -EINVAL ;optimize_kprobe (ap);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 81/104 ACPI / SBS: Fix GPE storm on recent MacBookPros
In reply to Greg Kroah-Hartman[ Upstream commit ca1721c5bee77105829cbd7baab8ee0eab85b06d ]
On Apple machines, plugging-in or unplugging the power triggers a GPE for the EC. Since these machines expose an SBS device, this GPE ends up triggering the acpi_sbs_callback(). This in turn tries to get the status of the SBS charger. However, on MBP13,* and MBP14,* machines, performing the smbus-read operation to get the charger's status triggers the EC's GPE again. The result is an endless re-triggering and handling of that GPE, consuming significant CPU resources (> 50% in irq).
In the end this is quite similar to commit 3031cddea633 (ACPI / SBS:
Don't assume the existence of an SBS charger), except that on the above machines a status of all 1's is returned. And like there, we just want ignore the charger here.
--- drivers/acpi/sbs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/acpi/sbs.c +6 -2
@@ -439,9 +439,13 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs)/* * The spec requires that bit 4 always be 1. If it's not set, assume -* that the implementation doesn't support an SBS charger +* that the implementation doesn't support an SBS charger. +* +* And on some MacBooks a status of 0xffff is always returned, no +* matter whether the charger is plugged in or not, which is also +* wrong, so ignore the SBS charger for those too. */ -if (!((status >>4 ) &0x1 )) +if (!((status >>4 ) &0x1 ) || status ==0xffff )return -ENODEV ; sbs->charger_present = (status >>15 ) &0x1 ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 82/104 iommu/dmar: Fix buffer overflow during PCI bus notification
In reply to Greg Kroah-Hartman[ Upstream commit cffaaf0c816238c45cd2d06913476c83eb50f682 ]
Commit 57384592c433 ("iommu/vt-d: Store bus information in RMRR PCI device path") changed the type of the path data, however, the change in path type was not reflected in size calculations. Update to use the correct type and prevent a buffer overflow.
This bug manifests in systems with deep PCI hierarchies, and can lead to an overflow of the static allocated buffer (dmar_pci_notify_info_buf), or can lead to overflow of slab-allocated data.
BUG: KASAN: global-out-of-bounds in dmar_alloc_pci_notify_info+0x1d5/0x2e0
Write of size 1 at addr ffffffff90445d80 by task swapper/0/1
CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.14.87-rt49-02406-gd0a0e96 #1
Call Trace:
? dump_stack+0x46/0x59
? print_address_description+0x1df/0x290
? dmar_alloc_pci_notify_info+0x1d5/0x2e0
? kasan_report+0x256/0x340
? dmar_alloc_pci_notify_info+0x1d5/0x2e0
? e820__memblock_setup+0xb0/0xb0
? dmar_dev_scope_init+0x424/0x48f
? __down_write_common+0x1ec/0x230
? dmar_dev_scope_init+0x48f/0x48f
? dmar_free_unused_resources+0x109/0x109
? cpumask_next+0x16/0x20
? __kmem_cache_create+0x392/0x430
? kmem_cache_create+0x135/0x2f0
? e820__memblock_setup+0xb0/0xb0
? intel_iommu_init+0x170/0x1848
? _raw_spin_unlock_irqrestore+0x32/0x60
? migrate_enable+0x27a/0x5b0
? sched_setattr+0x20/0x20
? migrate_disable+0x1fc/0x380
? task_rq_lock+0x170/0x170
? try_to_run_init_process+0x40/0x40
? locks_remove_file+0x85/0x2f0
? dev_prepare_static_identity_mapping+0x78/0x78
? rt_spin_unlock+0x39/0x50
? lockref_put_or_lock+0x2a/0x40
? dput+0x128/0x2f0
? __rcu_read_unlock+0x66/0x80
? __fput+0x250/0x300
? __rcu_read_lock+0x1b/0x30
? mntput_no_expire+0x38/0x290
? e820__memblock_setup+0xb0/0xb0
? pci_iommu_init+0x25/0x63
? pci_iommu_init+0x25/0x63
? do_one_initcall+0x7e/0x1c0
? initcall_blacklisted+0x120/0x120
? kernel_init_freeable+0x27b/0x307
? rest_init+0xd0/0xd0
? kernel_init+0xf/0x120
? rest_init+0xd0/0xd0
? ret_from_fork+0x1f/0x40
The buggy address belongs to the variable:
dmar_pci_notify_info_buf+0x40/0x60--- drivers/iommu/dmar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dmar.c +1 -1
@@ -134,7 +134,7 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event)for (tmp = dev; tmp; tmp = tmp->bus->self) level++; - size =sizeof (*info) + level *sizeof (struct acpi_dmar_pci_path ); + size =sizeof (*info) + level *sizeof (info->path[0 ]);if (size <=sizeof (dmar_pci_notify_info_buf)) { info = (struct dmar_pci_notify_info *)dmar_pci_notify_info_buf; }else {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 83/104 appletalk: Fix use-after-free in atalk_proc_exit
In reply to Greg Kroah-Hartman[ Upstream commit 6377f787aeb945cae7abbb6474798de129e1f3ac ]
KASAN report this:
BUG: KASAN: use-after-free in pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71
Read of size 8 at addr ffff8881f41fe5b0 by task syz-executor.0/2806
CPU: 0 PID: 2806 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xfa/0x1ce lib/dump_stack.c:113
print_address_description+0x65/0x270 mm/kasan/report.c:187
kasan_report+0x149/0x18d mm/kasan/report.c:317
pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71
remove_proc_entry+0xe8/0x420 fs/proc/generic.c:667
atalk_proc_exit+0x18/0x820 [appletalk]
atalk_exit+0xf/0x5a [appletalk]
__do_sys_delete_module kernel/module.c:1018 [inline]
__se_sys_delete_module kernel/module.c:961 [inline]
__x64_sys_delete_module+0x3dc/0x5e0 kernel/module.c:961
do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x462e99
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:00007fb2de6b9c58 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0
RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200001c0
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fb2de6ba6bc
R13: 00000000004bccaa R14: 00000000006f6bc8 R15: 00000000ffffffff
Allocated by task 2806:
set_track mm/kasan/common.c:85 [inline]
__kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:496
slab_post_alloc_hook mm/slab.h:444 [inline]
slab_alloc_node mm/slub.c:2739 [inline]
slab_alloc mm/slub.c:2747 [inline]
kmem_cache_alloc+0xcf/0x250 mm/slub.c:2752
kmem_cache_zalloc include/linux/slab.h:730 [inline]
__proc_create+0x30f/0xa20 fs/proc/generic.c:408
proc_mkdir_data+0x47/0x190 fs/proc/generic.c:469
0xffffffffc10c01bb
0xffffffffc10c0166
do_one_initcall+0xfa/0x5ca init/main.c:887
do_init_module+0x204/0x5f6 kernel/module.c:3460
load_module+0x66b2/0x8570 kernel/module.c:3808
__do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902
do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 2806:
set_track mm/kasan/common.c:85 [inline]
__kasan_slab_free+0x130/0x180 mm/kasan/common.c:458
slab_free_hook mm/slub.c:1409 [inline]
slab_free_freelist_hook mm/slub.c:1436 [inline]
slab_free mm/slub.c:2986 [inline]
kmem_cache_free+0xa6/0x2a0 mm/slub.c:3002
pde_put+0x6e/0x80 fs/proc/generic.c:647
remove_proc_entry+0x1d3/0x420 fs/proc/generic.c:684
0xffffffffc10c031c
0xffffffffc10c0166
do_one_initcall+0xfa/0x5ca init/main.c:887
do_init_module+0x204/0x5f6 kernel/module.c:3460
load_module+0x66b2/0x8570 kernel/module.c:3808
__do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902
do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff8881f41fe500
which belongs to the cache proc_dir_entry of size 256
The buggy address is located 176 bytes inside of
256-byte region [ffff8881f41fe500, ffff8881f41fe600)
The buggy address belongs to the page:
page:ffffea0007d07f80 count:1 mapcount:0 mapping:ffff8881f6e69a00 index:0x0
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 dead000000000100 dead000000000200 ffff8881f6e69a00
raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8881f41fe480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8881f41fe500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881f41fe580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881f41fe600: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff8881f41fe680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fbIt should check the return value of atalk_proc_init fails, otherwise atalk_exit will trgger use-after-free in pde_subdir_find while unload the module.This patch fix error cleanup path of atalk_init
--- include/linux/atalk.h | 2 +- net/appletalk/atalk_proc.c | 2 +- net/appletalk/ddp.c | 37 ++++++++++++++++++++++++++------ net/appletalk/sysctl_net_atalk.c | 5 ++++- 4 files changed, 37 insertions(+), 9 deletions(-)
include/linux/atalk.h +1 -1
@@ -150,7 +150,7 @@ extern int sysctl_aarp_retransmit_limit;extern int sysctl_aarp_resolve_time;#ifdef CONFIG_SYSCTL -extern void atalk_register_sysctl (void ); +extern int atalk_register_sysctl (void );extern void atalk_unregister_sysctl (void );#else #define atalk_register_sysctl () do { } while(0)
net/appletalk/atalk_proc.c +1 -1
@@ -293,7 +293,7 @@ int __init atalk_proc_init(void) goto out; } -void __exit atalk_proc_exit(void) +void atalk_proc_exit (void ) {remove_proc_entry ("interface" , atalk_proc_dir);remove_proc_entry ("route" , atalk_proc_dir);
net/appletalk/ddp.c +31 -6
@@ -1913,12 +1913,16 @@ static const char atalk_err_snap[] __initconst =/* Called by proto.c on kernel start up */ static int __init atalk_init (void ) { -int rc =proto_register (&ddp_proto,0 ); +int rc; -if (rc !=0 ) + rc =proto_register (&ddp_proto,0 ); +if (rc) goto out; - (void )sock_register (&atalk_family_ops); + rc =sock_register (&atalk_family_ops); +if (rc) + goto out_proto; + ddp_dl =register_snap_client (ddp_snap_id, atalk_rcv);if (!ddp_dl)printk (atalk_err_snap);
@@ -1926,12 +1930,33 @@ static int __init atalk_init(void)dev_add_pack (<alk_packet_type);dev_add_pack (&ppptalk_packet_type); -register_netdevice_notifier (&ddp_notifier); + rc =register_netdevice_notifier (&ddp_notifier); +if (rc) + goto out_sock; +aarp_proto_init (); -atalk_proc_init (); -atalk_register_sysctl (); + rc =atalk_proc_init (); +if (rc) + goto out_aarp; + + rc =atalk_register_sysctl (); +if (rc) + goto out_proc; out:return rc; +out_proc: +atalk_proc_exit (); +out_aarp: +aarp_cleanup_module (); +unregister_netdevice_notifier (&ddp_notifier); +out_sock: +dev_remove_pack (&ppptalk_packet_type); +dev_remove_pack (<alk_packet_type); +unregister_snap_client (ddp_dl); +sock_unregister (PF_APPLETALK ); +out_proto: +proto_unregister (&ddp_proto); + goto out; }module_init (atalk_init);
net/appletalk/sysctl_net_atalk.c +4 -1
@@ -44,9 +44,12 @@ static struct ctl_table atalk_table[] = {static struct ctl_table_header *atalk_table_header; -void atalk_register_sysctl (void ) +int __init atalk_register_sysctl (void ) { atalk_table_header =register_net_sysctl (&init_net,"net/appletalk" , atalk_table); +if (!atalk_table_header) +return -ENOMEM ; +return 0 ; }void atalk_unregister_sysctl (void )
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 84/104 lib/div64.c: off by one in shift
In reply to Greg Kroah-Hartman[ Upstream commit cdc94a37493135e355dfc0b0e086d84e3eadb50d ]
fls counts bits starting from 1 to 32 (returns 0 for zero argument). If we add 1 we shift right one bit more and loose precision from divisor, what cause function incorect results with some numbers.
Corrected code was tested in user-space, see bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=202391
--- lib/div64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/div64.c +2 -2
@@ -100,7 +100,7 @@ u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder) quot =div_u64_rem (dividend, divisor, &rem32); *remainder = rem32; }else { -int n =1 +fls (high); +int n =fls (high); quot =div_u64 (dividend >> n, divisor >> n);if (quot !=0 )
@@ -138,7 +138,7 @@ u64 div64_u64(u64 dividend, u64 divisor)if (high ==0 ) { quot =div_u64 (dividend, divisor); }else { -int n =1 +fls (high); +int n =fls (high); quot =div_u64 (dividend >> n, divisor >> n);if (quot !=0 )
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 85/104 include/linux/swap.h: use offsetof() instead of custom __swapoffset macro
In reply to Greg Kroah-Hartman[ Upstream commit a4046c06be50a4f01d435aa7fe57514818e6cc82 ]
Use offsetof() to calculate offset of a field to take advantage of compiler built-in version when possible, and avoid UBSAN warning when compiling with Clang:
UBSAN: Undefined behaviour in mm/swapfile.c:3010:38 member access within null pointer of type 'union swap_header' CPU: 6 PID: 1833 Comm: swapon Tainted: G S 4.19.23 #43 Call trace: dump_backtrace+0x0/0x194 show_stack+0x20/0x2c __dump_stack+0x20/0x28 dump_stack+0x70/0x94 ubsan_epilogue+0x14/0x44 ubsan_type_mismatch_common+0xf4/0xfc __ubsan_handle_type_mismatch_v1+0x34/0x54 __se_sys_swapon+0x654/0x1084 __arm64_sys_swapon+0x1c/0x24 el0_svc_common+0xa8/0x150 el0_svc_compat_handler+0x2c/0x38 el0_svc_compat+0x8/0x18
--- include/linux/swap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/swap.h +2 -2
@@ -143,9 +143,9 @@ struct swap_extent {/* * Max bad pages in the new format.. */ -#define __swapoffset (x) ((unsigned long)&((union swap_header *)0)->x)#define MAX_SWAP_BADPAGES \ - ((__swapoffset(magic.magic) - __swapoffset(info.badpages)) / sizeof(int)) + ((offsetof(union swap_header, magic.magic) - \ + offsetof(union swap_header, info.badpages)) / sizeof(int))enum {SWP_USED = (1 <<0 ),/* is slot in swap_info[] used? */
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 86/104 inet: update the IP ID generation algorithm to higher standards.
In reply to Greg Kroah-HartmanFrom: Amit Klein <[email protected]>
Commit 355b98553789 ("netns: provide pure entropy for net_hash_mix()") makes net_hash_mix() return a true 32 bits of entropy. When used in the IP ID generation algorithm, this has the effect of extending the IP ID generation key from 32 bits to 64 bits.
However, net_hash_mix() is only used for IP ID generation starting with kernel version 4.1. Therefore, earlier kernels remain with 32-bit key no matter what the net_hash_mix() return value is.
This change addresses the issue by explicitly extending the key to 64 bits for kernels older than 4.1.
--- net/ipv4/route.c | 4 +++- net/ipv6/ip6_output.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
net/ipv4/route.c +3 -1
@@ -488,13 +488,15 @@ EXPORT_SYMBOL(ip_idents_reserve);void __ip_select_ident (struct iphdr *iph,int segs) {static u32 ip_idents_hashrnd__read_mostly ; +static u32 ip_idents_hashrnd_extra__read_mostly ;u32 hash, id;net_get_random_once (&ip_idents_hashrnd,sizeof (ip_idents_hashrnd)); +net_get_random_once (&ip_idents_hashrnd_extra,sizeof (ip_idents_hashrnd_extra)); hash =jhash_3words ((__force u32 )iph->daddr, (__force u32 )iph->saddr, - iph->protocol, + iph->protocol ^ ip_idents_hashrnd_extra, ip_idents_hashrnd); id =ip_idents_reserve (hash, segs); iph->id =htons (id);
net/ipv6/ip6_output.c +3 -0
@@ -546,12 +546,15 @@ static void ip6_copy_metadata(struct sk_static void ipv6_select_ident (struct frag_hdr *fhdr,struct rt6_info *rt) {static u32 ip6_idents_hashrnd__read_mostly ; +static u32 ip6_idents_hashrnd_extra__read_mostly ;u32 hash, id;net_get_random_once (&ip6_idents_hashrnd,sizeof (ip6_idents_hashrnd)); +net_get_random_once (&ip6_idents_hashrnd_extra,sizeof (ip6_idents_hashrnd_extra)); hash =__ipv6_addr_jhash (&rt->rt6i_dst.addr, ip6_idents_hashrnd); hash =__ipv6_addr_jhash (&rt->rt6i_src.addr, hash); + hash =jhash_1word (hash, ip6_idents_hashrnd_extra); id =ip_idents_reserve (hash,1 ); fhdr->identification =htonl (id);
Greg Kroah-Hartman
maintainerPATCH 87/104 appletalk: Fix compile regression
In reply to Greg Kroah-Hartman[ Upstream commit 27da0d2ef998e222a876c0cec72aa7829a626266 ]
A bugfix just broke compilation of appletalk when CONFIG_SYSCTL is disabled:
In file included from net/appletalk/ddp.c:65:net/appletalk/ddp.c: In function 'atalk_init':include/linux/atalk.h:164:34: error: expected expression before 'do'
#define atalk_register_sysctl() do { } while(0)
^~net/appletalk/ddp.c:1934:7: note: in expansion of macro 'atalk_register_sysctl'
rc = atalk_register_sysctl();
This is easier to avoid by using conventional inline functions as stubs rather than macros. The header already has inline functions for other purposes, so I'm changing over all the macros for consistency.
--- include/linux/atalk.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
include/linux/atalk.h +14 -4
@@ -153,16 +153,26 @@ extern int sysctl_aarp_resolve_time;extern int atalk_register_sysctl (void );extern void atalk_unregister_sysctl (void );#else -#define atalk_register_sysctl () do { } while(0) -#define atalk_unregister_sysctl () do { } while(0) +static inline int atalk_register_sysctl (void ) +{ +return 0 ; +} +static inline void atalk_unregister_sysctl (void ) +{ +}#endif #ifdef CONFIG_PROC_FS extern int atalk_proc_init (void );extern void atalk_proc_exit (void );#else -#define atalk_proc_init () ({ 0; }) -#define atalk_proc_exit () do { } while(0) +static inline int atalk_proc_init (void ) +{ +return 0 ; +} +static inline void atalk_proc_exit (void ) +{ +}#endif /* CONFIG_PROC_FS */ #endif /* __LINUX_ATALK_H__ */
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 78/104 9p locks: add mount option for lock retry interval
In reply to Greg Kroah-Hartman[ Upstream commit 5e172f75e51e3de1b4274146d9b990f803cb5c2a ]
The default P9_LOCK_TIMEOUT can be too long for some users exporting a local file system to a guest VM (30s), make this configurable at mount time.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195727
--- fs/9p/v9fs.c | 21 +++++++++++++++++++++ fs/9p/v9fs.h | 1 + fs/9p/vfs_file.c | 6 +++++- 3 files changed, 27 insertions(+), 1 deletion(-)
fs/9p/v9fs.c +21 -0
@@ -59,6 +59,8 @@ enum { Opt_cache_loose, Opt_fscache, Opt_mmap,/* Access options */ Opt_access, Opt_posixacl, +/* Lock timeout option */ + Opt_locktimeout,/* Error token */ Opt_err };
@@ -78,6 +80,7 @@ static const match_table_t tokens = { {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, {Opt_posixacl, "posixacl"}, + {Opt_locktimeout, "locktimeout=%u"}, {Opt_err, NULL} };
@@ -126,6 +129,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)#ifdef CONFIG_9P_FSCACHE v9ses->cachetag =NULL ;#endif + v9ses->session_lock_timeout =P9_LOCK_TIMEOUT ;if (!opts)return 0 ;
@@ -298,6 +302,23 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)#endif break ; +case Opt_locktimeout: + r =match_int (&args[0 ], &option); +if (r <0 ) { +p9_debug (P9_DEBUG_ERROR , +"integer field, but no integer?\n" ); + ret = r; +continue ; + } +if (option <1 ) { +p9_debug (P9_DEBUG_ERROR , +"locktimeout must be a greater than zero integer.\n" ); + ret = -EINVAL ; +continue ; + } + v9ses->session_lock_timeout = (long )option *HZ ; +break ; +default :continue ; }
fs/9p/v9fs.h +1 -0
@@ -117,6 +117,7 @@ struct v9fs_session_info {struct list_head slist;/* list of sessions registered with v9fs */ struct backing_dev_info bdi;struct rw_semaphore rename_sem; +long session_lock_timeout;/* retry interval for blocking locks */ };/* cache_validity flags */
fs/9p/vfs_file.c +5 -1
@@ -152,6 +152,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)uint8_t status;int res =0 ;unsigned char fl_type; +struct v9fs_session_info *v9ses; fid = filp->private_data;BUG_ON (fid ==NULL );
@@ -187,6 +188,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)if (IS_SETLKW (cmd)) flock.flags =P9_LOCK_FLAGS_BLOCK ; + v9ses =v9fs_inode2v9ses (file_inode (filp)); +/* * if its a blocked request and we get P9_LOCK_BLOCKED as the status * for lock request, keep on trying
@@ -200,7 +203,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)break ;if (status ==P9_LOCK_BLOCKED && !IS_SETLKW (cmd))break ; -if (schedule_timeout_interruptible (P9_LOCK_TIMEOUT ) !=0 ) +if (schedule_timeout_interruptible (v9ses->session_lock_timeout) + !=0 )break ; }
Signature · 1 line
2.19.1
Re: [PATCH 3.18 031/104] locking/lockdep: Add debug_locks check in __lock_downgrade()
In reply to Greg Kroah-HartmanQuoted 9 lines · Greg Kroah-Hartman
[ Upstream commit
71492580571467fb7177aade19c18ce7486267f5]Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.
Fix that by add a check for
debug_locksat the beginning of__lock_downgrade().
Excuse me?
Quoted 24 lines
Debugged-by Tetsuo Handa <[email protected]>Reported-by Tetsuo Handa <[email protected]>Reported-by [email protected]Signed-off-by Waiman Long <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Cc Andrew Morton <[email protected]>Cc Linus Torvalds <[email protected]>Cc Paul E. McKenney <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+)kernel/locking/lockdep.c +0
-0
kernel/locking/lockdep.c __lock_set_class(struct lockdep_map *lock, const char *name, · line 3317
Quoted 6 lines
kernel/locking/lockdep.c +3
-0@@ -3312,6 +3312,9 @@ __lock_set_class(struct lockdep_map *lock, const char *name,unsigned int depth;int i; +if (unlikely (!debug_locks)) +return 0 ; +
This is __lock_set_class() function rather than __lock_downgrade() function. __lock_downgrade() is available in 4.12+.
For 3.18-stable, downgrade_write() is in kernel/locking/rwsem.c . Therefore, we should check whether adding this check into __lock_set_class() is what we want to do...
Quoted 4 lines
kernel/locking/lockdep.c +0
-0depth = curr->lockdep_depth;/* * This function is about (re)setting the class of a held lock,
Re: [PATCH 3.18 055/104] arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value
In reply to Greg Kroah-HartmanHi Greg,
Quoted 51 lines · Greg Kroah-Hartman
From: Will Deacon <[email protected]>
commit
045afc24124d80c6998d9c770844c67912083506upstream.Rather embarrassingly, our
futex()FUTEX_WAKE_OPimplementation doesn't explicitly set the return value on the non-faulting path and instead leaves it holding the result of the underlying atomic operation. This means that anyFUTEX_WAKE_OPatomic operation which computes a non-zero value will be reported as having failed. Regrettably, I wrote the buggy code back in 2011 and it was upstreamed as part of the initial arm64 support in 2012.The reasons we appear to get away with this are:
1.
FUTEX_WAKE_OPis rarely used and therefore doesn't appear to get exercised byfutex()test applications2. If the result of the atomic operation is zero, the system call behaves correctly
3. Prior to version 2.25, the only operation used by GLIBC set the futex to zero, and therefore worked as expected. From 2.25 onwards,
FUTEX_WAKE_OPis not used by GLIBC at all.Fix the implementation by ensuring that the return value is either 0 to indicate that the atomic operation completed successfully, or
-EFAULTif we encountered a fault when accessing the user mapping.Cc <[email protected]>Fixes 6170a97460db ("arm64: Atomic operations")Signed-off-by Will Deacon <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/arm64/include/asm/futex.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)arch/arm64/include/asm/futex.h +2
-2@@ -26,8 +26,8 @@ asmvolatile ( \"1: ldxr %w1, %2\n" \ insn"\n" \ -"2: stlxr %w3, %w0, %2\n" \ -" cbnz %w3, 1b\n" \ +"2: stlxr %w0, %w3, %2\n" \ +" cbnz %w0, 1b\n" \" dmb ish\n" \"3:\n" \ " .pushsection .fixup,\"ax\"\n" \
arch/arm64/include/asm/futex.h futex_atomic_op_inuser(unsigned int enco · line 53
Quoted 5 lines
arch/arm64/include/asm/futex.h +1
-1@@ -50,7 +50,7 @@ futex_atomic_op_inuser(unsigned int encoint cmp = (encoded_op >>24 ) &15 ;int oparg = (int )(encoded_op <<8 ) >>20 ;int cmparg = (int )(encoded_op <<20 ) >>20 ; -int oldval =0 , ret, tmp; +int oldval, ret, tmp;
Please ensure the follow up fix gets queued up for 3.18 as well (backport attached).
Thanks,
Nathan
Quoted 24 lines
arch/arm64/include/asm/futex.h +3
-3if (encoded_op & (FUTEX_OP_OPARG_SHIFT <<28 )) oparg =1U << (oparg &0x1f );@@ -62,23 +62,23 @@ futex_atomic_op_inuser(unsigned int encoswitch (op) {case FUTEX_OP_SET : -__futex_atomic_op ("mov %w0, %w4" , +__futex_atomic_op ("mov %w3, %w4" , ret, oldval, uaddr, tmp, oparg);break ;case FUTEX_OP_ADD : -__futex_atomic_op ("add %w0, %w1, %w4" , +__futex_atomic_op ("add %w3, %w1, %w4" , ret, oldval, uaddr, tmp, oparg);break ;case FUTEX_OP_OR : -__futex_atomic_op ("orr %w0, %w1, %w4" , +__futex_atomic_op ("orr %w3, %w1, %w4" , ret, oldval, uaddr, tmp, oparg);break ;case FUTEX_OP_ANDN :
arch/arm64/include/asm/futex.h futex_atomic_op_inuser(unsigned int enco · line 84
Quoted 10 lines
arch/arm64/include/asm/futex.h +2
-2-__futex_atomic_op ("and %w0, %w1, %w4" , +__futex_atomic_op ("and %w3, %w1, %w4" , ret, oldval, uaddr, tmp, ~oparg);break ;case FUTEX_OP_XOR : -__futex_atomic_op ("eor %w0, %w1, %w4" , +__futex_atomic_op ("eor %w3, %w1, %w4" , ret, oldval, uaddr, tmp, oparg);break ;default :
From 334d683655a0a4a68792ab1de6b20f4b559b0fcd Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <[email protected]>
Date: Wed, 17 Apr 2019 00:21:21 -0700
Subject: [PATCH] arm64: futex: Restore oldval initialization to work around
buggy compilers
commit ff8acf929014b7f87315588e0daf8597c8aa9d1c upstream.
Commit 045afc24124d ("arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value") removed oldval's zero initialization in arch_futex_atomic_op_inuser because it is not necessary. Unfortunately, Android's arm64 GCC 4.9.4 [1] does not agree:
../kernel/futex.c: In function 'do_futex':../kernel/futex.c:1658:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]
return oldval == cmparg;
^
In file included from ../kernel/futex.c:73:0:
../arch/arm64/include/asm/futex.h:53:6: note: 'oldval' was declared here
int oldval, ret, tmp;
^GCC fails to follow that when ret is non-zero, futex_atomic_op_inuser returns right away, avoiding the uninitialized use that it claims. Restoring the zero initialization works around this issue.
[1]: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
--- arch/arm64/include/asm/futex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/futex.h +1 -1
@@ -50,7 +50,7 @@ futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)int cmp = (encoded_op >>24 ) &15 ;int oparg = (int )(encoded_op <<8 ) >>20 ;int cmparg = (int )(encoded_op <<20 ) >>20 ; -int oldval, ret, tmp; +int oldval =0 , ret, tmp;if (encoded_op & (FUTEX_OP_OPARG_SHIFT <<28 )) oparg =1U << (oparg &0x1f );
Signature · 1 line
2.21.0
Greg Kroah-Hartman
maintainerPATCH 104/104 device_cgroup: fix RCU imbalance in error case
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
commit 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 upstream.
When dev_exception_add() returns an error (due to a failed memory allocation), make sure that we move the RCU preemption count back to where it was before we were called. We dropped the RCU read lock inside the loop body, so we can't just "break".
sparse complains about this, too:
$ make -s C=2 security/device_cgroup.o ./include/linux/rcupdate.h:647:9: warning: context imbalance in 'propagate_exception' - unexpected unlock
--- security/device_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/device_cgroup.c +1 -1
@@ -568,7 +568,7 @@ static int propagate_exception(struct de devcg->behavior == DEVCG_DEFAULT_ALLOW) { rc = dev_exception_add(devcg, ex); if (rc) - break; + return rc; } else {/* * in the other possible cases:
Greg Kroah-Hartman
maintainerPATCH 101/104 x86/kprobes: Verify stack frame on kretprobe
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit 3ff9c075cc767b3060bdac12da72fc94dd7da1b8 upstream.
Verify the stack frame pointer on kretprobe trampoline handler, If the stack frame pointer does not match, it skips the wrong entry and tries to find correct one.
This can happen if user puts the kretprobe on the function which can be used in the path of ftrace user-function call. Such functions should not be probed, so this adds a warning message that reports which function should be blacklisted.
--- arch/x86/kernel/kprobes/core.c | 26 ++++++++++++++++++++++++++ include/linux/kprobes.h | 1 + 2 files changed, 27 insertions(+)
arch/x86/kernel/kprobes/core.c +26 -0
@@ -500,6 +500,7 @@ void arch_prepare_kretprobe(struct kretpunsigned long *sara =stack_addr (regs); ri->ret_addr = (kprobe_opcode_t *) *sara; + ri->fp = sara;/* Replace the return addr with trampoline addr */ *sara = (unsigned long ) &kretprobe_trampoline;
@@ -701,15 +702,21 @@ __visible __used void *trampoline_handleunsigned long flags, orig_ret_address =0 ;unsigned long trampoline_address = (unsigned long )&kretprobe_trampoline;kprobe_opcode_t *correct_ret_addr =NULL ; +void *frame_pointer; +bool skipped = false;INIT_HLIST_HEAD (&empty_rp);kretprobe_hash_lock (current, &head, &flags);/* fixup registers */ #ifdef CONFIG_X86_64 regs->cs = __KERNEL_CS; +/* On x86-64, we use pt_regs->sp for return address holder. */ + frame_pointer = ®s->sp;#else regs->cs = __KERNEL_CS |get_kernel_rpl (); regs->gs =0 ; +/* On x86-32, we use pt_regs->flags for return address holder. */ + frame_pointer = ®s->flags;#endif regs->ip = trampoline_address; regs->orig_ax = ~0UL ;
@@ -731,8 +738,25 @@ __visible __used void *trampoline_handleif (ri->task != current)/* another task is sharing our hash bucket */ continue ; +/* +* Return probes must be pushed on this hash list correct +* order (same as return order) so that it can be poped +* correctly. However, if we find it is pushed it incorrect +* order, this means we find a function which should not be +* probed, because the wrong order entry is pushed on the +* path of processing other kretprobe itself. +*/ +if (ri->fp != frame_pointer) { +if (!skipped) +pr_warn ("kretprobe is stacked incorrectly. Trying to fixup.\n" ); + skipped = true; +continue ; + } orig_ret_address = (unsigned long )ri->ret_addr; +if (skipped) +pr_warn ("%ps must be blacklisted because of incorrect kretprobe order\n" , + ri->rp->kp.addr);if (orig_ret_address != trampoline_address)/*
@@ -750,6 +774,8 @@ __visible __used void *trampoline_handleif (ri->task != current)/* another task is sharing our hash bucket */ continue ; +if (ri->fp != frame_pointer) +continue ; orig_ret_address = (unsigned long )ri->ret_addr;if (ri->rp && ri->rp->handler) {
include/linux/kprobes.h +1 -0
@@ -197,6 +197,7 @@ struct kretprobe_instance {struct kretprobe *rp;kprobe_opcode_t *ret_addr;struct task_struct *task; +void *fp;char data[0 ]; };
Greg Kroah-Hartman
maintainerPATCH 97/104 staging: comedi: vmk80xx: Fix use of uninitialized semaphore
In reply to Greg Kroah-HartmanFrom: Ian Abbott <[email protected]>
commit 08b7c2f9208f0e2a32159e4e7a4831b7adb10a3e upstream.
If vmk80xx_auto_attach() returns an error, the core comedi module code will call vmk80xx_detach() to clean up. If vmk80xx_auto_attach() successfully allocated the comedi device private data, vmk80xx_detach() assumes that a struct semaphore limit_sem contained in the private data has been initialized and uses it. Unfortunately, there are a couple of places where vmk80xx_auto_attach() can return an error after allocating the device private data but before initializing the semaphore, so this assumption is invalid. Fix it by initializing the semaphore just after allocating the private data in vmk80xx_auto_attach() before any other errors can be returned.
I believe this was the cause of the following syzbot crash report
<https://syzkaller.appspot.com/bug?extid=54c2f58f15fe6876b6ad>:
usb 1-1: config 0 has no interface number 0
usb 1-1: New USB device found, idVendor=10cf, idProduct=8068, bcdDevice=e6.8d usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 usb 1-1: config 0 descriptor??
vmk80xx 1-1:0.117: driver 'vmk80xx' failed to auto-configure device.
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.1.0-rc4-319354-g9a33b36 #3 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xe8/0x16e lib/dump_stack.c:113 assign_lock_key kernel/locking/lockdep.c:786 [inline] register_lock_class+0x11b8/0x1250 kernel/locking/lockdep.c:1095 __lock_acquire+0xfb/0x37c0 kernel/locking/lockdep.c:3582 lock_acquire+0x10d/0x2f0 kernel/locking/lockdep.c:4211 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x44/0x60 kernel/locking/spinlock.c:152 down+0x12/0x80 kernel/locking/semaphore.c:58 vmk80xx_detach+0x59/0x100 drivers/staging/comedi/drivers/vmk80xx.c:829 comedi_device_detach+0xed/0x800 drivers/staging/comedi/drivers.c:204 comedi_device_cleanup.part.0+0x68/0x140 drivers/staging/comedi/comedi_fops.c:156 comedi_device_cleanup drivers/staging/comedi/comedi_fops.c:187 [inline] comedi_free_board_dev.part.0+0x16/0x90 drivers/staging/comedi/comedi_fops.c:190 comedi_free_board_dev drivers/staging/comedi/comedi_fops.c:189 [inline] comedi_release_hardware_device+0x111/0x140 drivers/staging/comedi/comedi_fops.c:2880 comedi_auto_config.cold+0x124/0x1b0 drivers/staging/comedi/drivers.c:1068 usb_probe_interface+0x31d/0x820 drivers/usb/core/driver.c:361 really_probe+0x2da/0xb10 drivers/base/dd.c:509 driver_probe_device+0x21d/0x350 drivers/base/dd.c:671 __device_attach_driver+0x1d8/0x290 drivers/base/dd.c:778 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:454 __device_attach+0x223/0x3a0 drivers/base/dd.c:844 bus_probe_device+0x1f1/0x2a0 drivers/base/bus.c:514 device_add+0xad2/0x16e0 drivers/base/core.c:2106 usb_set_configuration+0xdf7/0x1740 drivers/usb/core/message.c:2021 generic_probe+0xa2/0xda drivers/usb/core/generic.c:210 usb_probe_device+0xc0/0x150 drivers/usb/core/driver.c:266 really_probe+0x2da/0xb10 drivers/base/dd.c:509 driver_probe_device+0x21d/0x350 drivers/base/dd.c:671 __device_attach_driver+0x1d8/0x290 drivers/base/dd.c:778 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:454 __device_attach+0x223/0x3a0 drivers/base/dd.c:844 bus_probe_device+0x1f1/0x2a0 drivers/base/bus.c:514 device_add+0xad2/0x16e0 drivers/base/core.c:2106 usb_new_device.cold+0x537/0xccf drivers/usb/core/hub.c:2534 hub_port_connect drivers/usb/core/hub.c:5089 [inline] hub_port_connect_change drivers/usb/core/hub.c:5204 [inline] port_event drivers/usb/core/hub.c:5350 [inline] hub_event+0x138e/0x3b00 drivers/usb/core/hub.c:5432 process_one_work+0x90f/0x1580 kernel/workqueue.c:2269 worker_thread+0x9b/0xe20 kernel/workqueue.c:2415 kthread+0x313/0x420 kernel/kthread.c:253 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
--- drivers/staging/comedi/drivers/vmk80xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/comedi/drivers/vmk80xx.c +2 -2
@@ -872,6 +872,8 @@ static int vmk80xx_auto_attach(struct co devpriv->model = boardinfo->model; +sema_init (&devpriv->limit_sem,8 ); + ret =vmk80xx_find_usb_endpoints (dev);if (ret)return ret;
@@ -880,8 +882,6 @@ static int vmk80xx_auto_attach(struct coif (ret)return ret; -sema_init (&devpriv->limit_sem,8 ); -usb_set_intfdata (intf, devpriv);if (devpriv->model ==VMK8061_MODEL ) {
Greg Kroah-Hartman
maintainerPATCH 94/104 tcp: tcp_grow_window() needs to respect tcp_space()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 50ce163a72d817a99e8974222dcf2886d5deb1ae ]
For some reason, tcp_grow_window() correctly tests if enough room is present before attempting to increase tp->rcv_ssthresh, but does not prevent it to grow past tcp_space()
This is causing hard to debug issues, like failing the (__tcp_select_window(sk) >= tp->rcv_wnd) test in __tcp_ack_snd_check(), causing ACK delays and possibly slow flows.
Depending on tcp_rmem[2], MTU, skb->len/skb->truesize ratio, we can see the problem happening on "netperf -t TCP_RR -- -r 2000,2000" after about 60 round trips, when the active side no longer sends immediate acks.
This bug predates git history.
--- net/ipv4/tcp_input.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/ipv4/tcp_input.c +5 -5
@@ -358,11 +358,12 @@ static int __tcp_grow_window(const strucstatic void tcp_grow_window (struct sock *sk,const struct sk_buff *skb) {struct tcp_sock *tp =tcp_sk (sk); +int room; + + room =min_t (int, tp->window_clamp,tcp_space (sk)) - tp->rcv_ssthresh;/* Check #1 */ -if (tp->rcv_ssthresh < tp->window_clamp && - (int )tp->rcv_ssthresh <tcp_space (sk) && - !sk_under_memory_pressure (sk)) { +if (room >0 && !sk_under_memory_pressure (sk)) {int incr;/* Check #2. Increase window, if skb with such overhead
@@ -375,8 +376,7 @@ static void tcp_grow_window(struct sockif (incr) { incr =max_t (int, incr,2 * skb->len); - tp->rcv_ssthresh =min (tp->rcv_ssthresh + incr, - tp->window_clamp); + tp->rcv_ssthresh +=min (room, incr);inet_csk (sk)->icsk_ack.quick |=1 ; } }
Greg Kroah-Hartman
maintainerPATCH 91/104 net: bridge: multicast: use rcu to access port list from br_multicast_start_querier
In reply to Greg Kroah-HartmanFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit c5b493ce192bd7a4e7bd073b5685aad121eeef82 ]
br_multicast_start_querier() walks over the port list but it can be called from a timer with only multicast_lock held which doesn't protect the port list, so use RCU to walk over it.
--- net/bridge/br_multicast.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/bridge/br_multicast.c +3 -1
@@ -2023,7 +2023,8 @@ static void br_multicast_start_querier(s__br_multicast_open (br, query); -list_for_each_entry (port, &br->port_list, list) { +rcu_read_lock (); +list_for_each_entry_rcu (port, &br->port_list, list) {if (port->state ==BR_STATE_DISABLED || port->state ==BR_STATE_BLOCKING )continue ;
@@ -2035,6 +2036,7 @@ static void br_multicast_start_querier(sbr_multicast_enable (&port->ip6_own_query);#endif } +rcu_read_unlock (); }int br_multicast_toggle (struct net_bridge *br,unsigned long val)
Greg Kroah-Hartman
maintainerPATCH 29/104 cdrom: Fix race condition in cdrom_sysctl_register
In reply to Greg Kroah-Hartman[ Upstream commit f25191bb322dec8fa2979ecb8235643aa42470e1 ]
The following traceback is sometimes seen when booting an image in qemu:
[ 54.608293] cdrom: Uniform CD-ROM driver Revision: 3.20 [ 54.611085] Fusion MPT base driver 3.04.20 [ 54.611877] Copyright (c) 1999-2008 LSI Corporation [ 54.616234] Fusion MPT SAS Host driver 3.04.20 [ 54.635139] sysctl duplicate entry: /dev/cdrom//info [ 54.639578] CPU: 0 PID: 266 Comm: kworker/u4:5 Not tainted 5.0.0-rc5 #1 [ 54.639578] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 [ 54.641273] Workqueue: events_unbound async_run_entry_fn [ 54.641273] Call Trace: [ 54.641273] dump_stack+0x67/0x90 [ 54.641273] __register_sysctl_table+0x50b/0x570 [ 54.641273] ? rcu_read_lock_sched_held+0x6f/0x80 [ 54.641273] ? kmem_cache_alloc_trace+0x1c7/0x1f0 [ 54.646814] __register_sysctl_paths+0x1c8/0x1f0 [ 54.646814] cdrom_sysctl_register.part.7+0xc/0x5f [ 54.646814] register_cdrom.cold.24+0x2a/0x33 [ 54.646814] sr_probe+0x4bd/0x580 [ 54.646814] ? __driver_attach+0xd0/0xd0 [ 54.646814] really_probe+0xd6/0x260 [ 54.646814] ? __driver_attach+0xd0/0xd0 [ 54.646814] driver_probe_device+0x4a/0xb0 [ 54.646814] ? __driver_attach+0xd0/0xd0 [ 54.646814] bus_for_each_drv+0x73/0xc0 [ 54.646814] __device_attach+0xd6/0x130 [ 54.646814] bus_probe_device+0x9a/0xb0 [ 54.646814] device_add+0x40c/0x670 [ 54.646814] ? __pm_runtime_resume+0x4f/0x80 [ 54.646814] scsi_sysfs_add_sdev+0x81/0x290 [ 54.646814] scsi_probe_and_add_lun+0x888/0xc00 [ 54.646814] ? scsi_autopm_get_host+0x21/0x40 [ 54.646814] __scsi_add_device+0x116/0x130 [ 54.646814] ata_scsi_scan_host+0x93/0x1c0 [ 54.646814] async_run_entry_fn+0x34/0x100 [ 54.646814] process_one_work+0x237/0x5e0 [ 54.646814] worker_thread+0x37/0x380 [ 54.646814] ? rescuer_thread+0x360/0x360 [ 54.646814] kthread+0x118/0x130 [ 54.646814] ? kthread_create_on_node+0x60/0x60 [ 54.646814] ret_from_fork+0x3a/0x50
The only sensible explanation is that cdrom_sysctl_register() is called twice, once from the module init function and once from register_cdrom(). cdrom_sysctl_register() is not mutex protected and may happily execute twice if the second call is made before the first call is complete.
Use a static atomic to ensure that the function is executed exactly once.
--- drivers/cdrom/cdrom.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/cdrom/cdrom.c +3 -4
@@ -265,6 +265,7 @@/* #define ERRLOGMASK (CD_WARNING|CD_OPEN|CD_COUNT_TRACKS|CD_CLOSE) */ /* #define ERRLOGMASK (CD_WARNING|CD_REG_UNREG|CD_DO_IOCTL|CD_OPEN|CD_CLOSE|CD_COUNT_TRACKS) */ +#include <linux/atomic.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/major.h>
@@ -3676,9 +3677,9 @@ static struct ctl_table_header *cdrom_sysctl_header;static void cdrom_sysctl_register (void ) { -static int initialized; +static atomic_t initialized =ATOMIC_INIT (0 ); -if (initialized ==1 ) +if (!atomic_add_unless (&initialized,1 ,1 ))return ; cdrom_sysctl_header =register_sysctl_table (cdrom_root_table);
@@ -3689,8 +3690,6 @@ static void cdrom_sysctl_register(void) cdrom_sysctl_settings.debug = debug; cdrom_sysctl_settings.lock = lockdoor; cdrom_sysctl_settings.check = check_media_type; - - initialized =1 ; }static void cdrom_sysctl_unregister (void )
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 37/104 media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration
In reply to Greg Kroah-Hartman[ Upstream commit 49710c32cd9d6626a77c9f5f978a5f58cb536b35 ]
Previously when doing format enumeration, it was returning all
formats supported by driver, even if they're not supported by hw.
Add missing check for fmt_ver_flag, so it'll be fixed and only those
supported by hw will be returned. Similar thing is already done in s5p_jpeg_find_format.
It was found by using v4l2-compliance tool and checking result
of VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS test
and using v4l2-ctl to get list of all supported formats.
Tested on s5pv210-galaxys (Samsung i9000 phone).
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +11 -8
@@ -1011,13 +1011,16 @@ static int s5p_jpeg_querycap(struct file *file, void *priv,return 0 ; } -static int enum_fmt (struct s5p_jpeg_fmt *sjpeg_formats,int n, +static int enum_fmt (struct s5p_jpeg_ctx *ctx, +struct s5p_jpeg_fmt *sjpeg_formats,int n,struct v4l2_fmtdesc *f,u32 type) {int i, num =0 ; +unsigned int fmt_ver_flag = ctx->jpeg->variant->fmt_ver_flag;for (i =0 ; i < n; ++i) { -if (sjpeg_formats[i].flags & type) { +if (sjpeg_formats[i].flags & type && + sjpeg_formats[i].flags & fmt_ver_flag) {/* index-th format of type type found ? */ if (num == f->index)break ;
@@ -1043,11 +1046,11 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,struct s5p_jpeg_ctx *ctx =fh_to_ctx (priv);if (ctx->mode ==S5P_JPEG_ENCODE ) -return enum_fmt (sjpeg_formats,SJPEG_NUM_FORMATS , f, +return enum_fmt (ctx, sjpeg_formats,SJPEG_NUM_FORMATS , f,SJPEG_FMT_FLAG_ENC_CAPTURE ); -return enum_fmt (sjpeg_formats,SJPEG_NUM_FORMATS , f, -SJPEG_FMT_FLAG_DEC_CAPTURE ); +return enum_fmt (ctx, sjpeg_formats,SJPEG_NUM_FORMATS , f, +SJPEG_FMT_FLAG_DEC_CAPTURE ); } static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
@@ -1056,11 +1059,11 @@ static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,struct s5p_jpeg_ctx *ctx =fh_to_ctx (priv);if (ctx->mode ==S5P_JPEG_ENCODE ) -return enum_fmt (sjpeg_formats,SJPEG_NUM_FORMATS , f, +return enum_fmt (ctx, sjpeg_formats,SJPEG_NUM_FORMATS , f,SJPEG_FMT_FLAG_ENC_OUTPUT ); -return enum_fmt (sjpeg_formats,SJPEG_NUM_FORMATS , f, -SJPEG_FMT_FLAG_DEC_OUTPUT ); +return enum_fmt (ctx, sjpeg_formats,SJPEG_NUM_FORMATS , f, +SJPEG_FMT_FLAG_DEC_OUTPUT ); } static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx,
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 77/104 9p: do not trust pdu content for stat item size
In reply to Greg Kroah-Hartman[ Upstream commit 2803cf4379ed252894f046cb8812a48db35294e3 ]
v9fs_dir_readdir() could deadloop if a struct was sent with a size set to -2
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88021
--- fs/9p/vfs_dir.c | 8 +++----- net/9p/protocol.c | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-)
fs/9p/vfs_dir.c +3 -5
@@ -104,7 +104,6 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)int err =0 ;struct p9_fid *fid;int buflen; -int reclen =0 ;struct p9_rdir *rdir;p9_debug (P9_DEBUG_VFS ,"name %pD\n" , file);
@@ -129,11 +128,10 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)while (rdir->head < rdir->tail) { err =p9stat_read (fid->clnt, rdir->buf + rdir->head, rdir->tail - rdir->head, &st); -if (err) { +if (err <=0 ) {p9_debug (P9_DEBUG_VFS ,"returned %d\n" , err);return -EIO ; } - reclen = st.size+2 ; over = !dir_emit (ctx, st.name,strlen (st.name),v9fs_qid2ino (&st.qid),dt_type (&st));
@@ -141,8 +139,8 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)if (over)return 0 ; - rdir->head += reclen; - ctx->pos += reclen; + rdir->head += err; + ctx->pos += err; } } }
net/9p/protocol.c +2 -1
@@ -578,9 +578,10 @@ int p9stat_read(struct p9_client *clnt, char *buf, int len, struct p9_wstat *st)if (ret) {p9_debug (P9_DEBUG_9P ,"<<< p9stat_read failed: %d\n" , ret);trace_9p_protocol_dump (clnt, &fake_pdu); +return ret; } -return ret; +return fake_pdu.offset; }EXPORT_SYMBOL (p9stat_read);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 72/104 x86/hpet: Prevent potential NULL pointer dereference
In reply to Greg Kroah-Hartman[ Upstream commit 2e84f116afca3719c9d0a1a78b47b48f75fd5724 ]
hpet_virt_address may be NULL when ioremap_nocache fail, but the code lacks a check.
Add a check to prevent NULL pointer dereference.
--- arch/x86/kernel/hpet.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/hpet.c +2 -0
@@ -799,6 +799,8 @@ int __init hpet_enable(void)return 0 ;hpet_set_mapping (); +if (!hpet_virt_address) +return 0 ;/* * Read the period and check for a sane value:
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 73/104 x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors
In reply to Greg Kroah-Hartman[ Upstream commit 18fb053f9b827bd98cfc64f2a35df8ab19745a1d ]
There are comments in processor-cyrix.h advising you to _not_ make calls using the deprecated macros in this style:
setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
This is because it expands the macro into a non-functioning calling sequence. The calling order must be:
outb(CX86_CCR2, 0x22); inb(0x23);
Quoted 1 line
From the comments:
* When using the old macros a line like
* setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
* gets expanded to:
* do {
* outb((CX86_CCR2), 0x22);
* outb((({
* outb((CX86_CCR2), 0x22);
* inb(0x23);
* }) | 0x88), 0x23);
* } while (0);
The new macros fix this problem, so use them instead. Tested on an actual Geode processor.
--- arch/x86/kernel/cpu/cyrix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/cyrix.c +7 -7
@@ -120,7 +120,7 @@ static void set_cx86_reorder(void)setCx86 (CX86_CCR3 , (ccr3 &0x0f ) |0x10 );/* enable MAPEN */ /* Load/Store Serialize to mem access disable (=reorder it) */ -setCx86_old (CX86_PCR0 ,getCx86_old (CX86_PCR0 ) & ~0x80 ); +setCx86 (CX86_PCR0 ,getCx86 (CX86_PCR0 ) & ~0x80 );/* set load/store serialize from 1GB to 4GB */ ccr3 |=0xe0 ;setCx86 (CX86_CCR3 , ccr3);
@@ -131,11 +131,11 @@ static void set_cx86_memwb(void)printk (KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n" );/* CCR2 bit 2: unlock NW bit */ -setCx86_old (CX86_CCR2 ,getCx86_old (CX86_CCR2 ) & ~0x04 ); +setCx86 (CX86_CCR2 ,getCx86 (CX86_CCR2 ) & ~0x04 );/* set 'Not Write-through' */ write_cr0 (read_cr0 () |X86_CR0_NW );/* CCR2 bit 2: lock NW bit and set WT1 */ -setCx86_old (CX86_CCR2 ,getCx86_old (CX86_CCR2 ) |0x14 ); +setCx86 (CX86_CCR2 ,getCx86 (CX86_CCR2 ) |0x14 ); }/*
@@ -149,14 +149,14 @@ static void geode_configure(void)local_irq_save (flags);/* Suspend on halt power saving and enable #SUSP pin */ -setCx86_old (CX86_CCR2 ,getCx86_old (CX86_CCR2 ) |0x88 ); +setCx86 (CX86_CCR2 ,getCx86 (CX86_CCR2 ) |0x88 ); ccr3 =getCx86 (CX86_CCR3 );setCx86 (CX86_CCR3 , (ccr3 &0x0f ) |0x10 );/* enable MAPEN */ /* FPU fast, DTE cache, Mem bypass */ -setCx86_old (CX86_CCR4 ,getCx86_old (CX86_CCR4 ) |0x38 ); +setCx86 (CX86_CCR4 ,getCx86 (CX86_CCR4 ) |0x38 );setCx86 (CX86_CCR3 , ccr3);/* disable MAPEN */ set_cx86_memwb ();
@@ -291,7 +291,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)/* GXm supports extended cpuid levels 'ala' AMD */ if (c->cpuid_level ==2 ) {/* Enable cxMMX extensions (GX1 Datasheet 54) */ -setCx86_old (CX86_CCR7 ,getCx86_old (CX86_CCR7 ) |1 ); +setCx86 (CX86_CCR7 ,getCx86 (CX86_CCR7 ) |1 );/* * GXm : 0x30 ... 0x5f GXm datasheet 51
@@ -314,7 +314,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)if (dir1 >7 ) { dir0_msn++;/* M II */ /* Enable MMX extensions (App note 108) */ -setCx86_old (CX86_CCR7 ,getCx86_old (CX86_CCR7 )|1 ); +setCx86 (CX86_CCR7 ,getCx86 (CX86_CCR7 )|1 ); }else {/* A 6x86MX - it has the bug. */ set_cpu_bug (c,X86_BUG_COMA );
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 67/104 ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration
In reply to Greg Kroah-Hartman[ Upstream commit b4748e7ab731e436cf5db4786358ada5dd2db6dd ]
The function snd_opl3_drum_switch declaration in the header file has the order of the two arguments on_off and vel swapped when compared to the definition arguments of vel and on_off. Fix this by swapping them around to match the definition.
This error predates the git history, so no idea when this error was introduced.
--- sound/drivers/opl3/opl3_voice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/drivers/opl3/opl3_voice.h +1 -1
@@ -41,7 +41,7 @@ void snd_opl3_timer_func(unsigned long data);/* Prototypes for opl3_drums.c */ void snd_opl3_load_drums (struct snd_opl3 *opl3); -void snd_opl3_drum_switch (struct snd_opl3 *opl3,int note,int on_off,int vel,struct snd_midi_channel *chan); +void snd_opl3_drum_switch (struct snd_opl3 *opl3,int note,int vel,int on_off,struct snd_midi_channel *chan);/* Prototypes for opl3_oss.c */ #ifdef CONFIG_SND_SEQUENCER_OSS
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 63/104 ALSA: echoaudio: add a check for ioremap_nocache
In reply to Greg Kroah-Hartman[ Upstream commit 6ade657d6125ec3ec07f95fa51e28138aef6208f ]
In case ioremap_nocache fails, the fix releases chip and returns an error code upstream to avoid NULL pointer dereference.
--- sound/pci/echoaudio/echoaudio.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/pci/echoaudio/echoaudio.c +5 -0
@@ -1990,6 +1990,11 @@ static int snd_echo_create(struct snd_card *card, } chip->dsp_registers = (volatile u32 __iomem *)ioremap_nocache (chip->dsp_registers_phys, sz); +if (!chip->dsp_registers) { +dev_err (chip->card->dev,"ioremap failed\n" ); +snd_echo_free (chip); +return -ENOMEM ; + }if (request_irq (pci->irq, snd_echo_interrupt,IRQF_SHARED ,KBUILD_MODNAME , chip)) {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 58/104 xtensa: fix return_address
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit ada770b1e74a77fff2d5f539bf6c42c25f4784db upstream.
return_address returns the address that is one level higher in the call stack than requested in its argument, because level 0 corresponds to its caller's return address. Use requested level as the number of stack frames to skip.
This fixes the address reported by might_sleep and friends.
--- arch/xtensa/kernel/stacktrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/xtensa/kernel/stacktrace.c +5 -1
@@ -107,10 +107,14 @@ static int return_address_cb(struct stacreturn 1 ; } +/* +* level == 0 is for the return address from the caller of this function, +* not from this function itself. +*/ unsigned long return_address (unsigned level) {struct return_addr_data r = { - .skip = level +1 , + .skip = level, };walk_stackframe (stack_pointer (NULL ), return_address_cb, &r);return r.addr;
Greg Kroah-Hartman
maintainerPATCH 31/104 locking/lockdep: Add debug_locks check in __lock_downgrade()
In reply to Greg Kroah-Hartman[ Upstream commit 71492580571467fb7177aade19c18ce7486267f5 ]
Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.
Fix that by add a check for debug_locks at the beginning of __lock_downgrade().
--- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/locking/lockdep.c +3 -0
@@ -3312,6 +3312,9 @@ __lock_set_class(struct lockdep_map *lock, const char *name,unsigned int depth;int i; +if (unlikely (!debug_locks)) +return 0 ; + depth = curr->lockdep_depth;/* * This function is about (re)setting the class of a held lock,
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 49/104 netns: provide pure entropy for net_hash_mix()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 355b98553789b646ed97ad801a619ff898471b92 ]
net_hash_mix() currently uses kernel address of a struct net, and is used in many places that could be used to reveal this address to a patient attacker, thus defeating KASLR, for the typical case (initial net namespace, &init_net is not dynamically allocated)
I believe the original implementation tried to avoid spending too many cycles in this function, but security comes first.
Also provide entropy regardless of CONFIG_NET_NS.
--- include/net/net_namespace.h | 2 ++ include/net/netns/hash.h | 15 ++------------- net/core/net_namespace.c | 1 + 3 files changed, 5 insertions(+), 13 deletions(-)
include/net/net_namespace.h +2 -0
@@ -54,6 +54,8 @@ struct net {#endif spinlock_t rules_mod_lock; +u32 hash_mix; +struct list_head list;/* list of network namespaces */ struct list_head cleanup_list;/* namespaces on death row */ struct list_head exit_list;/* Use only net_mutex */
include/net/netns/hash.h +2 -13
@@ -1,21 +1,10 @@#ifndef __NET_NS_HASH_H__#define __NET_NS_HASH_H__ -#include <asm/cache.h> - -struct net ; +#include <net/net_namespace.h> static inline unsigned int net_hash_mix (struct net *net) { -#ifdef CONFIG_NET_NS -/* -* shift this right to eliminate bits, that are -* always zeroed -*/ - -return (unsigned )(((unsigned long )net) >>L1_CACHE_SHIFT ); -#else -return 0 ; -#endif +return net->hash_mix; }#endif
net/core/net_namespace.c +1 -0
@@ -156,6 +156,7 @@ static __net_init int setup_net(struct natomic_set (&net->count,1 );atomic_set (&net->passive,1 ); +get_random_bytes (&net->hash_mix,sizeof (u32)); net->dev_base_seq =1 ; net->user_ns = user_ns;
Greg Kroah-Hartman
maintainerPATCH 43/104 lib/string.c: implement a basic bcmp
In reply to Greg Kroah-Hartman[ Upstream commit 5f074f3e192f10c9fade898b9b3b8812e3d83342 ]
A recent optimization in Clang (r355672) lowers comparisons of the return value of memcmp against zero to comparisons of the return value of bcmp against zero. This helps some platforms that implement bcmp more efficiently than memcmp. glibc simply aliases bcmp to memcmp, but an optimized implementation is in the works.
This results in linkage failures for all targets with Clang due to the undefined symbol. For now, just implement bcmp as a tailcail to memcmp to unbreak the build. This routine can be further optimized in the future.
Other ideas discussed:
* A weak alias was discussed, but breaks for architectures that define their own implementations of memcmp since aliases to declarations are not permitted (only definitions). Arch-specific memcmp implementations typically declare memcmp in C headers, but implement them in assembly.
* -ffreestanding also is used sporadically throughout the kernel.
* -fno-builtin-bcmp doesn't work when doing LTO.
--- include/linux/string.h | 3 +++ lib/string.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+)
include/linux/string.h +3 -0
@@ -113,6 +113,9 @@ extern void * memscan(void *,int,__kernel_size_t);#ifndef __HAVE_ARCH_MEMCMPextern int memcmp (const void *,const void *,__kernel_size_t );#endif +#ifndef __HAVE_ARCH_BCMP +extern int bcmp (const void *,const void *,__kernel_size_t ); +#endif #ifndef __HAVE_ARCH_MEMCHRextern void *memchr (const void *,int ,__kernel_size_t );#endif
lib/string.c +20 -0
@@ -778,6 +778,26 @@ __visible int memcmp(const void *cs, const void *ct, size_t count)EXPORT_SYMBOL (memcmp);#endif +#ifndef __HAVE_ARCH_BCMP +/** +* bcmp - returns 0 if and only if the buffers have identical contents. +* @a: pointer to first buffer. +* @b: pointer to second buffer. +* @len: size of buffers. +* +* The sign or magnitude of a non-zero return value has no particular +* meaning, and architectures may implement their own more efficient bcmp(). So +* while this particular implementation is a simple (tail) call to memcmp, do +* not rely on anything but whether the return value is zero or non-zero. +*/ +#undef bcmp +int bcmp (const void *a,const void *b,size_t len) +{ +return memcmp (a, b, len); +} +EXPORT_SYMBOL (bcmp); +#endif +#ifndef __HAVE_ARCH_MEMSCAN/** * memscan - Find a character in an area of memory.
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 9/104 cifs: use correct format characters
In reply to Greg Kroah-Hartman[ Upstream commit 259594bea574e515a148171b5cd84ce5cbdc028a ]
When compiling with -Wformat, clang emits the following warnings:
fs/cifs/smb1ops.c:312:20: warning: format specifies type 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
tgt_total_cnt, total_in_tgt);
^~~~~~~~~~~~fs/cifs/cifs_dfs_ref.c:289:4: warning: format specifies type 'short' but the argument has type 'int' [-Wformat]
ref->flags, ref->server_type);
^~~~~~~~~~fs/cifs/cifs_dfs_ref.c:289:16: warning: format specifies type 'short' but the argument has type 'int' [-Wformat]
ref->flags, ref->server_type);
^~~~~~~~~~~~~~~~fs/cifs/cifs_dfs_ref.c:291:4: warning: format specifies type 'short' but the argument has type 'int' [-Wformat]
ref->ref_flag, ref->path_consumed);
^~~~~~~~~~~~~fs/cifs/cifs_dfs_ref.c:291:19: warning: format specifies type 'short' but the argument has type 'int' [-Wformat]
ref->ref_flag, ref->path_consumed);
^~~~~~~~~~~~~~~~~~The types of these arguments are unconditionally defined, so this patch updates the format character to the correct ones for ints and unsigned ints.
--- fs/cifs/cifs_dfs_ref.c | 4 ++-- fs/cifs/smb1ops.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/cifs/cifs_dfs_ref.c +2 -2
@@ -265,9 +265,9 @@ static void dump_referral(const struct dfs_info3_param *ref) {cifs_dbg (FYI ,"DFS: ref path: %s\n" , ref->path_name);cifs_dbg (FYI ,"DFS: node path: %s\n" , ref->node_name); -cifs_dbg (FYI ,"DFS: fl: %hd, srv_type: %hd\n" , +cifs_dbg (FYI ,"DFS: fl: %d, srv_type: %d\n" , ref->flags, ref->server_type); -cifs_dbg (FYI ,"DFS: ref_flags: %hd, path_consumed: %hd\n" , +cifs_dbg (FYI ,"DFS: ref_flags: %d, path_consumed: %d\n" , ref->ref_flag, ref->path_consumed); }
fs/cifs/smb1ops.c +1 -1
@@ -305,7 +305,7 @@ coalesce_t2(char *second_buf, struct smb_hdr *target_hdr) remaining = tgt_total_cnt - total_in_tgt;if (remaining <0 ) { -cifs_dbg (FYI ,"Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%hu\n" , +cifs_dbg (FYI ,"Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%u\n" , tgt_total_cnt, total_in_tgt);return -EPROTO ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 27/104 bcache: improve sysfs_strtoul_clamp()
In reply to Greg Kroah-Hartman[ Upstream commit 596b5a5dd1bc2fa019fdaaae522ef331deef927f ]
Currently sysfs_strtoul_clamp() is defined as,
82 #define sysfs_strtoul_clamp(file, var, min, max) \
83 do { \
84 if (attr == &sysfs_ ## file) \
85 return strtoul_safe_clamp(buf, var, min, max) \
86 ?: (ssize_t) size; \87 } while (0)
The problem is, if bit width of var is less then unsigned long, min and max may not protect var from integer overflow, because overflow happens in strtoul_safe_clamp() before checking min and max.
To fix such overflow in sysfs_strtoul_clamp(), to make min and max take effect, this patch adds an unsigned long variable, and uses it to macro strtoul_safe_clamp() to convert an unsigned long value in range defined by [min, max]. Then assign this value to var. By this method, if bit width of var is less than unsigned long, integer overflow won't happen before min and max are checking.
Now sysfs_strtoul_clamp() can properly handle smaller data type like unsigned int, of cause min and max should be defined in range of unsigned int too.
--- drivers/md/bcache/sysfs.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/md/bcache/sysfs.h +10 -3
@@ -80,9 +80,16 @@ do { \#define sysfs_strtoul_clamp (file, var, min, max) \ do { \ - if (attr == &sysfs_ ## file) \ - return strtoul_safe_clamp(buf, var, min, max) \ - ?: (ssize_t) size; \ + if (attr == &sysfs_ ## file) { \ + unsigned long v = 0; \ + ssize_t ret; \ + ret = strtoul_safe_clamp(buf, v, min, max); \ + if (!ret) { \ + var = v; \ + return size; \ + } \ + return ret; \ + } \ } while (0)#define strtoul_or_return (cp) \
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 24/104 ALSA: PCM: check if ops are defined before suspending PCM
In reply to Greg Kroah-Hartman[ Upstream commit d9c0b2afe820fa3b3f8258a659daee2cc71ca3ef ]
BE dai links only have internal PCM's and their substream ops may not be set. Suspending these PCM's will result in their
ops->trigger() being invoked and cause a kernel oops.
So skip suspending PCM's if their ops are NULL.
[ NOTE: this change is required now for following the recent PCM core
change to get rid of snd_pcm_suspend() call. Since DPCM BE takes the runtime carried from FE while keeping NULL ops, it can hit this bug. See details at:
https://github.com/thesofproject/linux/pull/582
-- tiwai ]
--- sound/core/pcm_native.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/core/pcm_native.c +8 -0
@@ -1315,6 +1315,14 @@ int snd_pcm_suspend_all(struct snd_pcm *pcm)/* FIXME: the open/close code should lock this as well */ if (substream->runtime ==NULL )continue ; + +/* +* Skip BE dai link PCM's that are internal and may +* not have their substream ops set. +*/ +if (!substream->ops) +continue ; + err =snd_pcm_suspend (substream);if (err <0 && err != -EBUSY )return err;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 16/104 mmc: omap: fix the maximum timeout setting
In reply to Greg Kroah-Hartman[ Upstream commit a6327b5e57fdc679c842588c3be046c0b39cc127 ]
When running OMAP1 kernel on QEMU, MMC access is annoyingly noisy:
MMC: CTO of 0xff and 0xfe cannot be used! MMC: CTO of 0xff and 0xfe cannot be used! MMC: CTO of 0xff and 0xfe cannot be used! [ad inf.]
Emulator warnings appear to be valid. The TI document SPRU680 [1] ("OMAP5910 Dual-Core Processor MultiMedia Card/Secure Data Memory Card (MMC/SD) Reference Guide") page 36 states that the maximum timeout is 253 cycles and "0xff and 0xfe cannot be used".
Fix by using 0xfd as the maximum timeout.
Tested using QEMU 2.5 (Siemens SX1 machine, OMAP310), and also checked on real hardware using Palm TE (OMAP310), Nokia 770 (OMAP1710) and Nokia N810 (OMAP2420) that MMC works as before.
[1] http://www.ti.com/lit/ug/spru680/spru680.pdf
--- drivers/mmc/host/omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/omap.c +1 -1
@@ -921,7 +921,7 @@ static inline void set_cmd_timeout(struct mmc_omap_host *host, struct mmc_reques reg &= ~(1 <<5 );OMAP_MMC_WRITE (host,SDIO , reg);/* Set maximum timeout */ -OMAP_MMC_WRITE (host,CTO ,0xff ); +OMAP_MMC_WRITE (host,CTO ,0xfd ); }static inline void set_data_timeout (struct mmc_omap_host *host,struct mmc_request *req)
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 14/104 scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c
In reply to Greg Kroah-Hartman[ Upstream commit 1749ef00f7312679f76d5e9104c5d1e22a829038 ]
We had a test-report where, under memory pressure, adding LUNs to the systems would fail (the tests add LUNs strictly in sequence):
[ 5525.853432] scsi 0:0:1:1088045124: Direct-Access IBM 2107900 .148 PQ: 0 ANSI: 5 [ 5525.853826] scsi 0:0:1:1088045124: alua: supports implicit TPGS [ 5525.853830] scsi 0:0:1:1088045124: alua: device naa.6005076303ffd32700000000000044da port group 0 rel port 43 [ 5525.853931] sd 0:0:1:1088045124: Attached scsi generic sg10 type 0 [ 5525.854075] sd 0:0:1:1088045124: [sdk] Disabling DIF Type 1 protection [ 5525.855495] sd 0:0:1:1088045124: [sdk] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB) [ 5525.855606] sd 0:0:1:1088045124: [sdk] Write Protect is off [ 5525.855609] sd 0:0:1:1088045124: [sdk] Mode Sense: ed 00 00 08 [ 5525.855795] sd 0:0:1:1088045124: [sdk] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [ 5525.857838] sdk: sdk1 [ 5525.859468] sd 0:0:1:1088045124: [sdk] Attached SCSI disk [ 5525.865073] sd 0:0:1:1088045124: alua: transition timeout set to 60 seconds [ 5525.865078] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA [ 5526.015070] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA [ 5526.015213] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA [ 5526.587439] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured [ 5526.588562] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured
Looking at the code of scsi_alloc_sdev(), and all the calling contexts, there seems to be no reason to use GFP_ATMOIC here. All the different call-contexts use a mutex at some point, and nothing in between that requires no sleeping, as far as I could see. Additionally, the code that later allocates the block queue for the device (scsi_mq_alloc_queue()) already uses GFP_KERNEL.
There are similar allocations in two other functions:scsi_probe_and_add_lun(), and scsi_add_lun(),; that can also be done with GFP_KERNEL.
Here is the contexts for the three functions so far:
scsi_alloc_sdev()
scsi_probe_and_add_lun()
scsi_sequential_lun_scan()
__scsi_scan_target()
scsi_scan_target()
mutex_lock()
scsi_scan_channel()
scsi_scan_host_selected()
mutex_lock()
scsi_report_lun_scan()
__scsi_scan_target()
...
__scsi_add_device()
mutex_lock()
__scsi_scan_target()
...
scsi_report_lun_scan()
...
scsi_get_host_dev()
mutex_lock()
scsi_probe_and_add_lun()
...
scsi_add_lun()
scsi_probe_and_add_lun()
...So replace all these, and give them a bit of a better chance to succeed, with more chances of reclaim.
--- drivers/scsi/scsi_scan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/scsi_scan.c +3 -3
@@ -229,7 +229,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,extern void scsi_requeue_run_queue (struct work_struct *work); sdev =kzalloc (sizeof (*sdev) + shost->transportt->device_size, -GFP_ATOMIC ); +GFP_KERNEL );if (!sdev) goto out;
@@ -791,7 +791,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,*/ sdev->inquiry =kmemdup (inq_result,max_t (size_t, sdev->inquiry_len,36 ), -GFP_ATOMIC ); +GFP_KERNEL );if (sdev->inquiry ==NULL )return SCSI_SCAN_NO_RESPONSE ;
@@ -1083,7 +1083,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,if (!sdev) goto out; - result =kmalloc (result_len,GFP_ATOMIC | + result =kmalloc (result_len,GFP_KERNEL | ((shost->unchecked_isa_dma) ? __GFP_DMA :0 ));if (!result) goto out_free_sdev;
Signature · 1 line
2.19.1
stable-rc/linux-3.18.y boot: 47 boots: 1 failed, 44 passed with 2 offline (v3.18.138-105-g84a721a30d55)
stable-rc/linux-3.18.y boot: 47 boots: 1 failed, 44 passed with 2 offline (v3.18.138-105-g84a721a30d55)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-3.18.y/kernel/v3.18.138-105-g84a721a30d55/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-3.18.y/kernel/v3.18.138-105-g84a721a30d55/
Tree: stable-rc
Branch: linux-3.18.y
Git Describe: v3.18.138-105-g84a721a30d55
Git Commit: 84a721a30d5546bc805cdbd24c4065a20d883de8
Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 22 unique boards, 12 SoC families, 13 builds out of 189
Boot Failure Detected:
x86_64:
x86_64_defconfig:
gcc-7:
minnowboard-turbot-E3826: 1 failed labOffline Platforms:
arm:
multi_v7_defconfig:
gcc-7
tegra20-iris-512: 1 offline lab
tegra_defconfig:
gcc-7
tegra20-iris-512: 1 offline lab---
For more info write to <[email protected]>
Greg Kroah-Hartman
maintainerRe: [PATCH 3.18 055/104] arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value
In reply to Nathan ChancellorQuoted 54 lines · Nathan Chancellor
Hi Greg,
Quoted 51 lines · Greg Kroah-Hartman
From: Will Deacon <[email protected]>
commit
045afc24124d80c6998d9c770844c67912083506upstream.Rather embarrassingly, our
futex()FUTEX_WAKE_OPimplementation doesn't explicitly set the return value on the non-faulting path and instead leaves it holding the result of the underlying atomic operation. This means that anyFUTEX_WAKE_OPatomic operation which computes a non-zero value will be reported as having failed. Regrettably, I wrote the buggy code back in 2011 and it was upstreamed as part of the initial arm64 support in 2012.The reasons we appear to get away with this are:
1.
FUTEX_WAKE_OPis rarely used and therefore doesn't appear to get exercised byfutex()test applications2. If the result of the atomic operation is zero, the system call behaves correctly
3. Prior to version 2.25, the only operation used by GLIBC set the futex to zero, and therefore worked as expected. From 2.25 onwards,
FUTEX_WAKE_OPis not used by GLIBC at all.Fix the implementation by ensuring that the return value is either 0 to indicate that the atomic operation completed successfully, or
-EFAULTif we encountered a fault when accessing the user mapping.Cc <[email protected]>Fixes 6170a97460db ("arm64: Atomic operations")Signed-off-by Will Deacon <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/arm64/include/asm/futex.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)arch/arm64/include/asm/futex.h +2
-2@@ -26,8 +26,8 @@ asmvolatile ( \"1: ldxr %w1, %2\n" \ insn"\n" \ -"2: stlxr %w3, %w0, %2\n" \ -" cbnz %w3, 1b\n" \ +"2: stlxr %w0, %w3, %2\n" \ +" cbnz %w0, 1b\n" \" dmb ish\n" \"3:\n" \ " .pushsection .fixup,\"ax\"\n" \@@ -50,7 +50,7 @@ futex_atomic_op_inuser(unsigned int enco
Quoted 8 lines
arch/arm64/include/asm/futex.h futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)
Quoted 5 lines
arch/arm64/include/asm/futex.h +1
-1int cmp = (encoded_op >>24 ) &15 ;int oparg = (int )(encoded_op <<8 ) >>20 ;int cmparg = (int )(encoded_op <<20 ) >>20 ; -int oldval =0 , ret, tmp; +int oldval, ret, tmp;Please ensure the follow up fix gets queued up for 3.18 as well (backport attached).
Ugh, I forgot it, thanks for the backport, now queued up.
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH 3.18 031/104] locking/lockdep: Add debug_locks check in __lock_downgrade()
In reply to Tetsuo HandaQuoted 47 lines · Tetsuo Handa
Quoted 9 lines · Greg Kroah-Hartman
[ Upstream commit
71492580571467fb7177aade19c18ce7486267f5]Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.
Fix that by add a check for
debug_locksat the beginning of__lock_downgrade().Excuse me?
Quoted 24 lines
Debugged-by Tetsuo Handa <[email protected]>Reported-by Tetsuo Handa <[email protected]>Reported-by [email protected]Signed-off-by Waiman Long <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Cc Andrew Morton <[email protected]>Cc Linus Torvalds <[email protected]>Cc Paul E. McKenney <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+)kernel/locking/lockdep.c +0
-0kernel/locking/lockdep.c __lock_set_class(struct lockdep_map *lock, const char *name, · line 3317
Quoted 6 lines
kernel/locking/lockdep.c +3
-0@@ -3312,6 +3312,9 @@ __lock_set_class(struct lockdep_map *lock, const char *name,unsigned int depth;int i; +if (unlikely (!debug_locks)) +return 0 ; +This is
__lock_set_class()function rather than__lock_downgrade()function.__lock_downgrade()is available in 4.12+.
Quoted 3 lines
For 3.18-stable,
downgrade_write()is inkernel/locking/rwsem.c. Therefore, we should check whether adding this check into__lock_set_class()is what we want to do...
Ugh, this got backported incorrectly to 4.4.y as well, let me check 4.9.y... Yup, that's wrong too.
As is 4.14.y.
As is 4.19.y.
Hey, I got it right in 5.0.y!
Ok, let me go drop this 3.18.y patch, and revert it from all of the other trees for now as well, thanks for catching this.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.18.139 release. There are 104 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 26 Apr 2019 05:07:26 PM UTC. 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/v3.x/stable-review/patch-3.18.139-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-3.18.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 3.18.139 release. There are 104 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 26 Apr 2019 05:07:26 PM UTC. Anything received after that time might be too late.
For v3.18.138-105-g24b000f:
Build results:
total: 155 pass: 155 fail: 0 Qemu test results: total: 230 pass: 230 fail: 0
Guenter