4.14.48-stable review
Subsystems (4)
Greg Kroah-Hartman
maintainercover 4.14.48-stable review
This is the start of the stable review cycle for the 4.14.48 release. There are 52 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 Wed Jun 6 06:55:52 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.48-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.14.48-rc1
Christophe Leroy <[email protected]>
powerpc/mm/slice: Fix hugepage allocation at hint address on 8xx
Christophe Leroy <[email protected]>
powerpc/mm/slice: Enhance for supporting PPC32
Christophe Leroy <[email protected]>
powerpc/mm/slice: create header files dedicated to slices
Christophe Leroy <[email protected]>
powerpc/mm/slice: Remove intermediate bitmap copy
Ondrej Zary <[email protected]>
drm/i915: Disable LVDS on Radiant P845
Chris Wilson <[email protected]>
drm/i915/lvds: Move acpi lid notification registration to registration phase
Dhinakaran Pandiyan <[email protected]>
drm/psr: Fix missed entry in PSR setup time table.
Alexander Shishkin <[email protected]>
intel_th: Use correct device when freeing buffers
Stanislaw Gruszka <[email protected]>
Revert "rt2800: use TXOP_BACKOFF for probe frames"
Hugh Dickins <[email protected]>
mm/huge_memory.c: __split_huge_page() use atomic ClearPageDirty()
Parav Pandit <[email protected]>
IB/core: Fix error code for invalid GID entry
Greg Kroah-Hartman <[email protected]>
hwtracing: stm: fix build error on some arches
Alexander Shishkin <[email protected]>
stm class: Use vmalloc for the master map
Bart Van Assche <[email protected]>
scsi: scsi_transport_srp: Fix shost to rport translation
Maciej W. Rozycki <[email protected]>
MIPS: prctl: Disallow FRE without FR with PR_SET_FP_MODE requests
Maciej W. Rozycki <[email protected]>
MIPS: ptrace: Fix PTRACE_PEEKUSR requests for 64-bit FGRs
Mathias Kresin <[email protected]>
MIPS: lantiq: gphy: Drop reboot/remove reset asserts
Eugen Hristev <[email protected]>
iio: adc: select buffer for at91-sama5d2_adc
Martin Kelly <[email protected]>
iio:kfifo_buf: check for uint overflow
Martin Kelly <[email protected]>
iio:buffer: make length types match kfifo types
Michael Nosthoff <[email protected]>
iio: ad7793: implement IIO_CHAN_INFO_SAMP_FREQ
Eric Dumazet <[email protected]>
tcp: avoid integer overflows in tcp_rcv_space_adjust()
Sodagudi Prasad <[email protected]>
kbuild: clang: disable unused variable warnings only when constant
Colin Ian King <[email protected]>
platform/chrome: cros_ec_lpc: remove redundant pointer request
Colin Ian King <[email protected]>
ASoC: Intel: sst: remove redundant variable dma_dev_name
Matthias Kaehlcke <[email protected]>
rtlwifi: rtl8192cu: Remove variable self-assignment in rf.c
Matthias Kaehlcke <[email protected]>
drm/amd/powerplay: Fix enum mismatch
Colin Ian King <[email protected]>
dma-buf: remove redundant initialization of sg_table
Chris Wilson <[email protected]>
drm/i915: Always sanity check engine state upon idling
Nick Desaulniers <[email protected]>
kbuild: clang: remove crufty HOSTCFLAGS
Eric Biggers <[email protected]>
cfg80211: further limit wiphy names to 64 bytes
Sachin Grover <[email protected]>
selinux: KASAN: slab-out-of-bounds in xattr_getsecurity
Steven Rostedt (VMware) <[email protected]>
tracing: Make the snapshot trigger work with instances
Steven Rostedt (VMware) <[email protected]>
tracing: Fix crash when freeing instances with event triggers
Benjamin Tissoires <[email protected]>
Input: elan_i2c_smbus - fix corrupted stack
Benjamin Tissoires <[email protected]>
Input: synaptics - add Lenovo 80 series ids to SMBus
Aaron Ma <[email protected]>
Input: synaptics - add Intertouch support on X1 Carbon 6th and X280
Edvard Holst <[email protected]>
Input: synaptics - Lenovo Thinkpad X1 Carbon G5 (2017) with Elantech trackpoints should use RMI
Dmitry Torokhov <[email protected]>
Input: synaptics - Lenovo Carbon X1 Gen5 (2017) devices should use RMI
Brian Foster <[email protected]>
xfs: detect agfl count corruption and reset agfl
Dave Chinner <[email protected]>
xfs: convert XFS_AGFL_SIZE to a helper function
Dexuan Cui <[email protected]>
PCI: hv: Fix 2 hang issues in hv_compose_msi_msg()
Greg Kroah-Hartman <[email protected]>
Revert "pinctrl: msm: Use dynamic GPIO numbering"
Borislav Petkov <[email protected]>
x86/MCE/AMD: Cache SMCA MISC block addresses
Yazen Ghannam <[email protected]>
x86/mce/AMD: Carve out SMCA get_block_address() code
Josh Poimboeuf <[email protected]>
objtool: Fix "noreturn" detection for recursive sibling calls
Josh Poimboeuf <[email protected]>
objtool: Detect RIP-relative switch table references, part 2
Josh Poimboeuf <[email protected]>
objtool: Detect RIP-relative switch table references
Josh Poimboeuf <[email protected]>
objtool: Support GCC 8 switch tables
Josh Poimboeuf <[email protected]>
objtool: Support GCC 8's cold subfunctions
Hugh Dickins <[email protected]>
mm: fix the NULL mapping case in __isolate_lru_page()
Al Viro <[email protected]>
fix io_destroy()/aio_complete() race
-------------
Diffstat:
Makefile | 12 +- arch/mips/kernel/process.c | 4 + arch/mips/kernel/ptrace.c | 2 +- arch/mips/kernel/ptrace32.c | 2 +- arch/powerpc/include/asm/book3s/64/slice.h | 27 ++++ arch/powerpc/include/asm/mmu-8xx.h | 6 + arch/powerpc/include/asm/nohash/32/slice.h | 18 +++ arch/powerpc/include/asm/nohash/64/slice.h | 12 ++ arch/powerpc/include/asm/page.h | 1 + arch/powerpc/include/asm/page_64.h | 59 -------- arch/powerpc/include/asm/slice.h | 42 ++++++ arch/powerpc/kernel/setup-common.c | 2 + arch/powerpc/mm/8xx_mmu.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 + arch/powerpc/mm/mmu_context_nohash.c | 18 ++- arch/powerpc/mm/slice.c | 49 ++++-- arch/powerpc/platforms/Kconfig.cputype | 1 + arch/x86/kernel/cpu/mcheck/mce_amd.c | 72 ++++----- drivers/dma-buf/dma-buf.c | 2 +- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 8 +- .../amd/powerplay/hwmgr/smu7_clockpowergating.c | 2 +- drivers/gpu/drm/drm_dp_helper.c | 1 + drivers/gpu/drm/i915/i915_gem.c | 27 +--- drivers/gpu/drm/i915/intel_lvds.c | 51 +++++-- drivers/hwtracing/intel_th/msu.c | 6 +- drivers/hwtracing/stm/core.c | 7 +- drivers/iio/adc/Kconfig | 1 + drivers/iio/adc/ad7793.c | 75 +++------ drivers/iio/buffer/industrialio-buffer-dma.c | 2 +- drivers/iio/buffer/kfifo_buf.c | 11 +- drivers/infiniband/core/cache.c | 2 +- drivers/input/mouse/elan_i2c_smbus.c | 22 +-- drivers/input/mouse/synaptics.c | 6 + drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 7 +- .../net/wireless/realtek/rtlwifi/rtl8192cu/rf.c | 3 - drivers/pci/host/pci-hyperv.c | 58 ++++++- drivers/pinctrl/qcom/pinctrl-msm.c | 2 +- drivers/platform/chrome/cros_ec_lpc.c | 3 - drivers/scsi/scsi_transport_srp.c | 22 ++- drivers/soc/lantiq/gphy.c | 36 ----- fs/aio.c | 3 +- fs/xfs/libxfs/xfs_alloc.c | 125 ++++++++++++++- fs/xfs/libxfs/xfs_alloc.h | 2 + fs/xfs/libxfs/xfs_format.h | 13 +- fs/xfs/xfs_fsops.c | 2 +- fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_trace.h | 9 +- include/linux/iio/buffer_impl.h | 6 +- include/linux/tcp.h | 2 +- include/uapi/linux/nl80211.h | 2 +- kernel/trace/trace.c | 12 +- kernel/trace/trace.h | 11 ++ kernel/trace/trace_events_trigger.c | 15 +- mm/huge_memory.c | 2 +- mm/vmscan.c | 2 +- net/ipv4/tcp_input.c | 10 +- security/selinux/ss/services.c | 2 +- sound/soc/intel/common/sst-firmware.c | 2 - tools/objtool/check.c | 167 ++++++++++++--------- tools/objtool/elf.c | 42 +++++- tools/objtool/elf.h | 2 + 61 files changed, 715 insertions(+), 402 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/52 fix io_destroy()/aio_complete() race
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 4faa99965e027cc057c5145ce45fa772caa04e8d upstream.
If io_destroy() gets to cancelling everything that can be cancelled and gets to kiocb_cancel() calling the function driver has left in ->ki_cancel, it becomes vulnerable to a race with IO completion. At that point req is already taken off the list and aio_complete() does *NOT* spin until we (in free_ioctx_users()) releases ->ctx_lock. As the result, it proceeds to kiocb_free(), freing req just it gets passed to ->ki_cancel().
Fix is simple - remove from the list after the call of kiocb_cancel(). All instances of ->ki_cancel() already have to cope with the being called with iocb still on list - that's what happens in io_cancel(2).
--- fs/aio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/aio.c +1 -2
@@ -643,9 +643,8 @@ static void free_ioctx_users(struct percwhile (!list_empty (&ctx->active_reqs)) { req =list_first_entry (&ctx->active_reqs, struct aio_kiocb, ki_list); - -list_del_init (&req->ki_list);kiocb_cancel (req); +list_del_init (&req->ki_list); }spin_unlock_irq (&ctx->ctx_lock);
Greg Kroah-Hartman
maintainerPATCH 2/52 mm: fix the NULL mapping case in __isolate_lru_page()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugh Dickins <[email protected]>
commit 145e1a71e090575c74969e3daa8136d1e5b99fc8 upstream.
George Boole would have noticed a slight error in 4.16 commit 69d763fc6d3a ("mm: pin address_space before dereferencing it while isolating an LRU page"). Fix it, to match both the comment above it, and the original behaviour.
Although anonymous pages are not marked PageDirty at first, we have an old habit of calling SetPageDirty when a page is removed from swap
cache: so there's a category of ex-swap pages that are easily migratable, but were inadvertently excluded from compaction's async migration in 4.16.
--- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/vmscan.c +1 -1
@@ -1451,7 +1451,7 @@ int __isolate_lru_page(struct page *pagereturn ret; mapping =page_mapping (page); - migrate_dirty = mapping && mapping->a_ops->migratepage; + migrate_dirty = !mapping || mapping->a_ops->migratepage;unlock_page (page);if (!migrate_dirty)return ret;
Greg Kroah-Hartman
maintainerPATCH 3/52 objtool: Support GCC 8s cold subfunctions
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 13810435b9a7014fb92eb715f77da488f3b65b99 upstream.
GCC 8 moves a lot of unlikely code out of line to "cold" subfunctions in .text.unlikely. Properly detect the new subfunctions and treat them as extensions of the original functions.
This fixes a bunch of warnings like:
kernel/cgroup/cgroup.o: warning: objtool: parse_cgroup_root_flags()+0x33: sibling call from callable instruction with modified stack frame kernel/cgroup/cgroup.o: warning: objtool: cgroup_addrm_files()+0x290: sibling call from callable instruction with modified stack frame kernel/cgroup/cgroup.o: warning: objtool: cgroup_apply_control_enable()+0x25b: sibling call from callable instruction with modified stack frame kernel/cgroup/cgroup.o: warning: objtool: rebind_subsystems()+0x325: sibling call from callable instruction with modified stack frame
--- tools/objtool/check.c | 93 +++++++++++++++++++++++++++----------------------- tools/objtool/elf.c | 42 +++++++++++++++++++++- tools/objtool/elf.h | 2 + 3 files changed, 93 insertions(+), 44 deletions(-)
tools/objtool/check.c +51 -42
@@ -59,6 +59,31 @@ static struct instruction *next_insn_samreturn next; } +static struct instruction *next_insn_same_func (struct objtool_file *file, +struct instruction *insn) +{ +struct instruction *next =list_next_entry (insn, list); +struct symbol *func = insn->func; + +if (!func) +return NULL ; + +if (&next->list != &file->insn_list && next->func == func) +return next; + +/* Check if we're already in the subfunction: */ +if (func == func->cfunc) +return NULL ; + +/* Move to the subfunction: */ +return find_insn (file, func->cfunc->sec, func->cfunc->offset); +} + +#define func_for_each_insn_all (file, func, insn) \ + for (insn = find_insn(file, func->sec, func->offset); \ + insn; \ + insn = next_insn_same_func(file, insn)) +#define func_for_each_insn (file, func, insn) \ for (insn = find_insn(file, func->sec, func->offset); \ insn && &insn->list != &file->insn_list && \
@@ -148,10 +173,14 @@ static int __dead_end_function(struct obif (!strcmp (func->name, global_noreturns[i]))return 1 ; -if (!func->sec) +if (!func->len) +return 0 ; + + insn =find_insn (file, func->sec, func->offset); +if (!insn->func)return 0 ; -func_for_each_insn (file, func, insn) { +func_for_each_insn_all (file, func, insn) { empty = false;if (insn->type ==INSN_RETURN )
@@ -166,35 +195,24 @@ static int __dead_end_function(struct ob* case, the function's dead-end status depends on whether the target * of the sibling call returns. */ -func_for_each_insn (file, func, insn) { -if (insn->sec != func->sec || - insn->offset >= func->offset + func->len) -break ; - +func_for_each_insn_all (file, func, insn) {if (insn->type ==INSN_JUMP_UNCONDITIONAL ) {struct instruction *dest = insn->jump_dest; -struct symbol *dest_func;if (!dest)/* sibling call to another file */ return 0 ; -if (dest->sec != func->sec || - dest->offset < func->offset || - dest->offset >= func->offset + func->len) { -/* local sibling call */ - dest_func =find_symbol_by_offset (dest->sec, - dest->offset); -if (!dest_func) -continue ; +if (dest->func && dest->func->pfunc != insn->func->pfunc) { +/* local sibling call */ if (recursion ==5 ) {WARN_FUNC ("infinite recursion (objtool bug!)" , dest->sec, dest->offset);return -1 ; } -return __dead_end_function (file, dest_func, +return __dead_end_function (file, dest->func, recursion +1 ); } }
@@ -421,7 +439,7 @@ static void add_ignores(struct objtool_fif (!ignore_func (file, func))continue ; -func_for_each_insn (file, func, insn) +func_for_each_insn_all (file, func, insn) insn->ignore = true; } }
@@ -781,9 +799,8 @@ out:return ret; } -static int add_switch_table (struct objtool_file *file,struct symbol *func, -struct instruction *insn,struct rela *table, -struct rela *next_table) +static int add_switch_table (struct objtool_file *file,struct instruction *insn, +struct rela *table,struct rela *next_table) {struct rela *rela = table;struct instruction *alt_insn;
@@ -793,18 +810,13 @@ static int add_switch_table(struct objtoif (rela == next_table)break ; -if (rela->sym->sec != insn->sec || - rela->addend <= func->offset || - rela->addend >= func->offset + func->len) + alt_insn =find_insn (file, rela->sym->sec, rela->addend); +if (!alt_insn)break ; - alt_insn =find_insn (file, insn->sec, rela->addend); -if (!alt_insn) { -WARN ("%s: can't find instruction at %s+0x%x" , - file->rodata->rela->name, insn->sec->name, - rela->addend); -return -1 ; - } +/* Make sure the jmp dest is in the function or subfunction: */ +if (alt_insn->func->pfunc != insn->func->pfunc) +break ; alt =malloc (sizeof (*alt));if (!alt) {
@@ -942,7 +954,7 @@ static int add_func_switch_tables(structstruct rela *rela, *prev_rela =NULL ;int ret; -func_for_each_insn (file, func, insn) { +func_for_each_insn_all (file, func, insn) {if (!last) last = insn;
@@ -973,8 +985,7 @@ static int add_func_switch_tables(struct* the beginning of another switch table in the same function. */ if (prev_jump) { - ret =add_switch_table (file, func, prev_jump, prev_rela, - rela); + ret =add_switch_table (file, prev_jump, prev_rela, rela);if (ret)return ret; }
@@ -984,7 +995,7 @@ static int add_func_switch_tables(struct }if (prev_jump) { - ret =add_switch_table (file, func, prev_jump, prev_rela,NULL ); + ret =add_switch_table (file, prev_jump, prev_rela,NULL );if (ret)return ret; }
@@ -1748,15 +1759,13 @@ static int validate_branch(struct objtoowhile (1 ) { next_insn =next_insn_same_sec (file, insn); - -if (file->c_file && func && insn->func && func != insn->func) { +if (file->c_file && func && insn->func && func != insn->func->pfunc) {WARN ("%s() falls through to next function %s()" , func->name, insn->func->name);return 1 ; } -if (insn->func) - func = insn->func; + func = insn->func ? insn->func->pfunc :NULL ;if (func && insn->ignore) { WARN_FUNC("BUG: why am I validating an ignored function?",
@@ -1777,7 +1786,7 @@ static int validate_branch(struct objtoo i = insn; save_insn =NULL ; -func_for_each_insn_continue_reverse (file, func, i) { +func_for_each_insn_continue_reverse (file, insn->func, i) {if (i->save) { save_insn = i;break ;
@@ -1864,7 +1873,7 @@ static int validate_branch(struct objtoocase INSN_JUMP_UNCONDITIONAL :if (insn->jump_dest && (!func || !insn->jump_dest->func || - func == insn->jump_dest->func)) { + insn->jump_dest->func->pfunc == func)) { ret =validate_branch (file, insn->jump_dest, state);if (ret)
@@ -2059,7 +2068,7 @@ static int validate_functions(struct objfor_each_sec (file, sec) {list_for_each_entry (func, &sec->symbol_list, list) { -if (func->type !=STT_FUNC ) +if (func->type !=STT_FUNC || func->pfunc != func)continue ; insn =find_insn (file, sec, func->offset);
tools/objtool/elf.c +40 -2
62 lines not on this page · raw message
tools/objtool/elf.h +2 -0
@@ -61,6 +61,7 @@ struct symbol {unsigned char bind, type;unsigned long offset;unsigned int len; +struct symbol *pfunc, *cfunc; };struct rela {
@@ -86,6 +87,7 @@ struct elf {struct elf *elf_open (const char *name,int flags);struct section *find_section_by_name (struct elf *elf,const char *name);struct symbol *find_symbol_by_offset (struct section *sec,unsigned long offset); +struct symbol *find_symbol_by_name (struct elf *elf,const char *name);struct symbol *find_symbol_containing (struct section *sec,unsigned long offset);struct rela *find_rela_by_dest (struct section *sec,unsigned long offset); struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset,
Greg Kroah-Hartman
maintainerPATCH 4/52 objtool: Support GCC 8 switch tables
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit fd35c88b74170d9335530d9abf271d5d73eb5401 upstream.
With GCC 8, some issues were found with the objtool switch table detection.
1) In the .rodata section, immediately after the switch table, there can be another object which contains a pointer to the function which had the switch statement. In this case objtool wrongly considers the function pointer to be part of the switch table. Fix it by:
a) making sure there are no pointers to the beginning of the function; and
b) making sure there are no gaps in the switch table.
Only the former was needed, the latter adds additional protection for future optimizations.
2) In find_switch_table(), case 1 and case 2 are missing the check to ensure that the .rodata switch table data is anonymous, i.e. that it isn't already associated with an ELF symbol. Fix it by adding the same find_symbol_containing() check which is used for case 3.
This fixes the following warnings with GCC 8:
drivers/block/virtio_blk.o: warning: objtool: virtio_queue_rq()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+72 net/ipv6/icmp.o: warning: objtool: icmpv6_rcv()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+64 drivers/usb/core/quirks.o: warning: objtool: quirks_param_set()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+48 drivers/mtd/nand/raw/nand_hynix.o: warning: objtool: hynix_nand_decode_id()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+24 drivers/mtd/nand/raw/nand_samsung.o: warning: objtool: samsung_nand_decode_id()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+32 drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.o: warning: objtool: gk104_top_oneinit()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+64
--- tools/objtool/check.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
tools/objtool/check.c +22 -2
@@ -805,17 +805,28 @@ static int add_switch_table(struct objtostruct rela *rela = table;struct instruction *alt_insn;struct alternative *alt; +struct symbol *pfunc = insn->func->pfunc; +unsigned int prev_offset =0 ;list_for_each_entry_from (rela, &file->rodata->rela->rela_list, list) {if (rela == next_table)break ; +/* Make sure the switch table entries are consecutive: */ +if (prev_offset && rela->offset != prev_offset +8 ) +break ; + +/* Detect function pointers from contiguous objects: */ +if (rela->sym->sec == pfunc->sec && + rela->addend == pfunc->offset) +break ; + alt_insn =find_insn (file, rela->sym->sec, rela->addend);if (!alt_insn)break ;/* Make sure the jmp dest is in the function or subfunction: */ -if (alt_insn->func->pfunc != insn->func->pfunc) +if (alt_insn->func->pfunc != pfunc)break ; alt =malloc (sizeof (*alt));
@@ -826,6 +837,13 @@ static int add_switch_table(struct objto alt->insn = alt_insn;list_add_tail (&alt->list, &insn->alts); + prev_offset = rela->offset; + } + +if (!prev_offset) { +WARN_FUNC ("can't find switch jump table" , + insn->sec, insn->offset); +return -1 ; }return 0 ;
@@ -882,7 +900,9 @@ static struct rela *find_switch_table(ststruct instruction *orig_insn = insn; text_rela =find_rela_by_dest_range (insn->sec, insn->offset, insn->len); -if (text_rela && text_rela->sym == file->rodata->sym) { +if (text_rela && text_rela->sym == file->rodata->sym && + !find_symbol_containing (file->rodata, text_rela->addend)) { +/* case 1 */ rodata_rela =find_rela_by_dest (file->rodata, text_rela->addend);
Greg Kroah-Hartman
maintainerPATCH 5/52 objtool: Detect RIP-relative switch table references
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 6f5ec2993b1f39aed12fa6fd56e8dc2272ee8a33 upstream.
Typically a switch table can be found by detecting a .rodata access followed an indirect jump:
1969: 4a 8b 0c e5 00 00 00 mov 0x0(,%r12,8),%rcx
1970: 00
196d: R_X86_64_32S .rodata+0x438
1971: e9 00 00 00 00 jmpq 1976 <dispc_runtime_suspend+0xb6a>
1972: R_X86_64_PC32 __x86_indirect_thunk_rcx-0x4Randy Dunlap reported a case (seen with GCC 4.8) where the .rodata access uses RIP-relative addressing:
19bd: 48 8b 3d 00 00 00 00 mov 0x0(%rip),%rdi # 19c4 <dispc_runtime_suspend+0xbb8>
19c0: R_X86_64_PC32 .rodata+0x45c
19c4: e9 00 00 00 00 jmpq 19c9 <dispc_runtime_suspend+0xbbd>
19c5: R_X86_64_PC32 __x86_indirect_thunk_rdi-0x4In this case the relocation addend needs to be adjusted accordingly in order to find the location of the switch table.
The fix is for case 3 (as described in the comments), but also make the existing case 1 & 2 checks more precise by only adjusting the addend for R_X86_64_PC32 relocations.
This fixes the following warnings:
drivers/video/fbdev/omap2/omapfb/dss/dispc.o: warning: objtool: dispc_runtime_suspend()+0xbb8: sibling call from callable instruction with modified stack frame drivers/video/fbdev/omap2/omapfb/dss/dispc.o: warning: objtool: dispc_runtime_resume()+0xcc5: sibling call from callable instruction with modified stack frame
--- tools/objtool/check.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
tools/objtool/check.c +18 -15
@@ -898,24 +898,24 @@ static struct rela *find_switch_table(st {struct rela *text_rela, *rodata_rela;struct instruction *orig_insn = insn; +unsigned long table_offset; +/* case 1 & 2 */ text_rela =find_rela_by_dest_range (insn->sec, insn->offset, insn->len);if (text_rela && text_rela->sym == file->rodata->sym && !find_symbol_containing (file->rodata, text_rela->addend)) { -/* case 1 */ - rodata_rela =find_rela_by_dest (file->rodata, - text_rela->addend); -if (rodata_rela) -return rodata_rela; + table_offset = text_rela->addend; +if (text_rela->type ==R_X86_64_PC32 ) { +/* case 2 */ + table_offset +=4 ; + file->ignore_unreachables = true; + } -/* case 2 */ - rodata_rela =find_rela_by_dest (file->rodata, - text_rela->addend +4 ); + rodata_rela =find_rela_by_dest (file->rodata, table_offset);if (!rodata_rela)return NULL ; - file->ignore_unreachables = true;return rodata_rela; }
@@ -949,18 +949,21 @@ static struct rela *find_switch_table(stif (!text_rela || text_rela->sym != file->rodata->sym)continue ; + table_offset = text_rela->addend; +if (text_rela->type ==R_X86_64_PC32 ) + table_offset +=4 ; +/* * Make sure the .rodata address isn't associated with a * symbol. gcc jump tables are anonymous data. */ -if (find_symbol_containing (file->rodata, text_rela->addend)) +if (find_symbol_containing (file->rodata, table_offset))continue ; - rodata_rela =find_rela_by_dest (file->rodata, text_rela->addend); -if (!rodata_rela) -continue ; - -return rodata_rela; +/* mov [rodata addr], %reg */ + rodata_rela =find_rela_by_dest (file->rodata, table_offset); +if (rodata_rela) +return rodata_rela; }return NULL ;
Greg Kroah-Hartman
maintainerPATCH 6/52 objtool: Detect RIP-relative switch table references, part 2
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 7dec80ccbe310fb7e225bf21c48c672bb780ce7b upstream.
With the following commit:
fd35c88b7417 ("objtool: Support GCC 8 switch tables")
I added a "can't find switch jump table" warning, to stop covering up silent failures if add_switch_table() can't find anything.
That warning found yet another bug in the objtool switch table detection logic. For cases 1 and 2 (as described in the comments of find_switch_table()), the find_symbol_containing() check doesn't adjust the offset for RIP-relative switch jumps.
Incidentally, this bug was already fixed for case 3 with:
6f5ec2993b1f ("objtool: Detect RIP-relative switch table references")
However, that commit missed the fix for cases 1 and 2.
The different cases are now starting to look more and more alike. So fix the bug by consolidating them into a single case, by checking the original dynamic jump instruction in the case 3 loop.
This also simplifies the code and makes it more robust against future switch table detection issues -- of which I'm sure there will be many...
Switch table detection has been the most fragile area of objtool, by far. I long for the day when we'll have a GCC plugin for annotating switch tables. Linus asked me to delay such a plugin due to the flakiness of the plugin infrastructure in older versions of GCC, so this rickety code is what we're stuck with for now. At least the code is now a little simpler than it was.
--- tools/objtool/check.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-)
tools/objtool/check.c +12 -25
@@ -900,40 +900,19 @@ static struct rela *find_switch_table(ststruct instruction *orig_insn = insn;unsigned long table_offset; -/* case 1 & 2 */ - text_rela =find_rela_by_dest_range (insn->sec, insn->offset, insn->len); -if (text_rela && text_rela->sym == file->rodata->sym && - !find_symbol_containing (file->rodata, text_rela->addend)) { - - table_offset = text_rela->addend; -if (text_rela->type ==R_X86_64_PC32 ) { -/* case 2 */ - table_offset +=4 ; - file->ignore_unreachables = true; - } - - rodata_rela =find_rela_by_dest (file->rodata, table_offset); -if (!rodata_rela) -return NULL ; - -return rodata_rela; - } - -/* case 3 */ /* * Backward search using the @first_jump_src links, these help avoid * much of the 'in between' code. Which avoids us getting confused by * it. */ -for (insn =list_prev_entry (insn, list); - +for (; &insn->list != &file->insn_list && insn->sec == func->sec && insn->offset >= func->offset; insn = insn->first_jump_src ?:list_prev_entry (insn, list)) { -if (insn->type ==INSN_JUMP_DYNAMIC ) +if (insn != orig_insn && insn->type ==INSN_JUMP_DYNAMIC )break ;/* allow small jumps within the range */
@@ -960,10 +939,18 @@ static struct rela *find_switch_table(stif (find_symbol_containing (file->rodata, table_offset))continue ; -/* mov [rodata addr], %reg */ rodata_rela =find_rela_by_dest (file->rodata, table_offset); -if (rodata_rela) +if (rodata_rela) { +/* +* Use of RIP-relative switch jumps is quite rare, and +* indicates a rare GCC quirk/bug which can leave dead +* code behind. +*/ +if (text_rela->type ==R_X86_64_PC32 ) + file->ignore_unreachables = true; +return rodata_rela; + } }return NULL ;
Greg Kroah-Hartman
maintainerPATCH 7/52 objtool: Fix "noreturn" detection for recursive sibling calls
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 0afd0d9e0e7879d666c1df2fa1bea4d8716909fe upstream.
Objtool has some crude logic for detecting static "noreturn" functions (aka "dead ends"). This is necessary for being able to correctly follow GCC code flow when such functions are called.
It's remotely possible for two functions to call each other via sibling calls. If they don't have RET instructions, objtool's noreturn detection logic goes into a recursive loop:
drivers/char/ipmi/ipmi_ssif.o: warning: objtool: return_hosed_msg()+0x0: infinite recursion (objtool bug!) drivers/char/ipmi/ipmi_ssif.o: warning: objtool: deliver_recv_msg()+0x0: infinite recursion (objtool bug!)
Instead of reporting an error in this case, consider the functions to be non-dead-ends.
--- tools/objtool/check.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/objtool/check.c +7 -3
@@ -207,9 +207,13 @@ static int __dead_end_function(struct ob/* local sibling call */ if (recursion ==5 ) { -WARN_FUNC ("infinite recursion (objtool bug!)" , - dest->sec, dest->offset); -return -1 ; +/* +* Infinite recursion: two functions +* have sibling calls to each other. +* This is a very rare case. It means +* they aren't dead ends. +*/ +return 0 ; } return __dead_end_function(file, dest->func,
Greg Kroah-Hartman
maintainerPATCH 8/52 x86/mce/AMD: Carve out SMCA get_block_address() code
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yazen Ghannam <[email protected]>
commit 8a331f4a0863bea758561c921b94b4d28f7c4029 upstream.
Carve out the SMCA code in get_block_address() into a separate helper function.
No functional change.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 57 +++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
arch/x86/kernel/cpu/mcheck/mce_amd.c +31 -26
@@ -429,6 +429,35 @@ static void deferred_error_interrupt_enawrmsr (MSR_CU_DEF_ERR , low, high); } +static u32 smca_get_block_address (unsigned int cpu,unsigned int bank, +unsigned int block) +{ +u32 low, high; +u32 addr =0 ; + +if (smca_get_bank_type (bank) ==SMCA_RESERVED ) +return addr; + +if (!block) +return MSR_AMD64_SMCA_MCx_MISC (bank); + +/* +* For SMCA enabled processors, BLKPTR field of the first MISC register +* (MCx_MISC0) indicates presence of additional MISC regs set (MISC1-4). +*/ +if (rdmsr_safe_on_cpu (cpu,MSR_AMD64_SMCA_MCx_CONFIG (bank), &low, &high)) +return addr; + +if (!(low &MCI_CONFIG_MCAX )) +return addr; + +if (!rdmsr_safe_on_cpu (cpu,MSR_AMD64_SMCA_MCx_MISC (bank), &low, &high) && + (low &MASK_BLKPTR_LO )) +return MSR_AMD64_SMCA_MCx_MISCy (bank, block -1 ); + +return addr; +} +static u32 get_block_address (unsigned int cpu,u32 current_addr,u32 low,u32 high,unsigned int bank,unsigned int block) {
@@ -449,32 +478,8 @@ static u32 get_block_address(unsigned in } } -if (mce_flags.smca) { -if (smca_get_bank_type (bank) ==SMCA_RESERVED ) -return addr; - -if (!block) { - addr =MSR_AMD64_SMCA_MCx_MISC (bank); - }else { -/* -* For SMCA enabled processors, BLKPTR field of the -* first MISC register (MCx_MISC0) indicates presence of -* additional MISC register set (MISC1-4). -*/ -u32 low, high; - -if (rdmsr_safe_on_cpu (cpu,MSR_AMD64_SMCA_MCx_CONFIG (bank), &low, &high)) -return addr; - -if (!(low &MCI_CONFIG_MCAX )) -return addr; - -if (!rdmsr_safe_on_cpu (cpu,MSR_AMD64_SMCA_MCx_MISC (bank), &low, &high) && - (low &MASK_BLKPTR_LO )) - addr =MSR_AMD64_SMCA_MCx_MISCy (bank, block -1 ); - } -return addr; - } +if (mce_flags.smca) +return smca_get_block_address (cpu, bank, block);/* Fall back to method we used for older processors: */ switch (block) {
Greg Kroah-Hartman
maintainerPATCH 9/52 x86/MCE/AMD: Cache SMCA MISC block addresses
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov <[email protected]>
commit 78ce241099bb363b19dbd0245442e66c8de8f567 upstream.
... into a global, two-dimensional array and service subsequent reads from that cache to avoid rdmsr_on_cpu() calls during CPU hotplug (IPIs with IRQs disabled).
In addition, this fixes a KASAN slab-out-of-bounds read due to wrong usage of the bank->blocks pointer.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +14 -15
@@ -94,6 +94,11 @@ static struct smca_bank_name smca_names[ [SMCA_SMU] = { "smu", "System Management Unit" }, }; +static u32 smca_bank_addrs[MAX_NR_BANKS ][NR_BLOCKS ]__ro_after_init = +{ + [0 ...MAX_NR_BANKS -1 ] = { [0 ...NR_BLOCKS -1 ] =-1 } +}; +const char *smca_get_name (enum smca_bank_types t) {if (t >=N_SMCA_BANK_TYPES )
@@ -441,20 +446,26 @@ static u32 smca_get_block_address(unsignif (!block)return MSR_AMD64_SMCA_MCx_MISC (bank); +/* Check our cache first: */ +if (smca_bank_addrs[bank][block] !=-1 ) +return smca_bank_addrs[bank][block]; +/* * For SMCA enabled processors, BLKPTR field of the first MISC register * (MCx_MISC0) indicates presence of additional MISC regs set (MISC1-4). */ if (rdmsr_safe_on_cpu (cpu,MSR_AMD64_SMCA_MCx_CONFIG (bank), &low, &high)) -return addr; + goto out;if (!(low &MCI_CONFIG_MCAX )) -return addr; + goto out;if (!rdmsr_safe_on_cpu (cpu,MSR_AMD64_SMCA_MCx_MISC (bank), &low, &high) && (low &MASK_BLKPTR_LO )) -return MSR_AMD64_SMCA_MCx_MISCy (bank, block -1 ); + addr =MSR_AMD64_SMCA_MCx_MISCy (bank, block -1 ); +out: + smca_bank_addrs[bank][block] = addr;return addr; }
@@ -466,18 +477,6 @@ static u32 get_block_address(unsigned inif ((bank >= mca_cfg.banks) || (block >=NR_BLOCKS ))return addr; -/* Get address from already initialized block. */ -if (per_cpu (threshold_banks, cpu)) { -struct threshold_bank *bankp =per_cpu (threshold_banks, cpu)[bank]; - -if (bankp && bankp->blocks) { -struct threshold_block *blockp = &bankp->blocks[block]; - -if (blockp) -return blockp->address; - } - } -if (mce_flags.smca)return smca_get_block_address (cpu, bank, block);
Greg Kroah-Hartman
maintainerPATCH 10/52 Revert "pinctrl: msm: Use dynamic GPIO numbering"
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
This reverts commit bd36ea57d6d58041180c4f7d2c2bf5194c26845d which is commit a7aa75a2a7dba32594291a71c3704000a2fd7089 upstream.
There's been too many complaints about this. Personally I think it's going to blow up when people hit this in mainline, but hey, it's not my systems. At least we don't have to backport the mess to the stable kernels to give them some more life to live unscathed :)
--- drivers/pinctrl/qcom/pinctrl-msm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-msm.c +1 -1
@@ -818,7 +818,7 @@ static int msm_gpio_init(struct msm_pincreturn -EINVAL ; chip = &pctrl->chip; - chip->base =-1 ; + chip->base =0 ; chip->ngpio = ngpio; chip->label =dev_name (pctrl->dev); chip->parent = pctrl->dev;
Greg Kroah-Hartman
maintainerPATCH 11/52 PCI: hv: Fix 2 hang issues in hv_compose_msi_msg()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dexuan Cui <[email protected]>
commit de0aa7b2f97d348ba7d1e17a00744c989baa0cb6 upstream.
1. With the patch "x86/vector/msi: Switch to global reservation mode", the recent v4.15 and newer kernels always hang for 1-vCPU Hyper-V VM with SR-IOV. This is because when we reach hv_compose_msi_msg() by request_irq() -> request_threaded_irq() ->__setup_irq()->irq_startup() -> __irq_startup() -> irq_domain_activate_irq() -> ... -> msi_domain_activate() -> ... -> hv_compose_msi_msg(), local irq is disabled in __setup_irq().
Note: when we reach hv_compose_msi_msg() by another code path:pci_enable_msix_range() -> ... -> irq_domain_activate_irq() -> ... -> hv_compose_msi_msg(), local irq is not disabled.
hv_compose_msi_msg() depends on an interrupt from the host. With interrupts disabled, a UP VM always hangs in the busy loop in the function, because the interrupt callback hv_pci_onchannelcallback() can not be called.
We can do nothing but work it around by polling the channel. This is ugly, but we don't have any other choice.
2. If the host is ejecting the VF device before we reach hv_compose_msi_msg(), in a UP VM, we can hang in hv_compose_msi_msg() forever, because at this time the host doesn't respond to the CREATE_INTERRUPT request. This issue exists the first day the pci-hyperv driver appears in the kernel.
Luckily, this can also by worked around by polling the channel for the PCI_EJECT message and hpdev->state, and by checking the PCI vendor ID.
Note: actually the above 2 issues also happen to a SMP VM, if "hbus->hdev->channel->target_cpu == smp_processor_id()" is true.
--- drivers/pci/host/pci-hyperv.c | 58 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-)
drivers/pci/host/pci-hyperv.c +57 -1
@@ -531,6 +531,8 @@ struct hv_pci_compl {s32 completion_status; }; +static void hv_pci_onchannelcallback (void *context); +/** * hv_pci_generic_compl() - Invoked for a completion packet * @context: Set up by the sender of the packet.
@@ -675,6 +677,31 @@ static void _hv_pcifront_read_config(str } } +static u16 hv_pcifront_get_vendor_id (struct hv_pci_dev *hpdev) +{ +u16 ret; +unsigned long flags; +void __iomem *addr = hpdev->hbus->cfg_addr +CFG_PAGE_OFFSET + +PCI_VENDOR_ID ; + +spin_lock_irqsave (&hpdev->hbus->config_lock, flags); + +/* Choose the function to be read. (See comment above) */ +writel (hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); +/* Make sure the function was chosen before we start reading. */ +mb (); +/* Read from that function's config space. */ + ret =readw (addr); +/* +* mb() is not required here, because the spin_unlock_irqrestore() +* is a barrier. +*/ + +spin_unlock_irqrestore (&hpdev->hbus->config_lock, flags); + +return ret; +} +/** * _hv_pcifront_write_config() - Internal PCI config write * @hpdev: The PCI driver's representation of the device
@@ -1121,8 +1148,37 @@ static void hv_compose_msi_msg(struct ir* Since this function is called with IRQ locks held, can't * do normal wait for completion; instead poll. */ -while (!try_wait_for_completion (&comp.comp_pkt.host_event)) +while (!try_wait_for_completion (&comp.comp_pkt.host_event)) { +/* 0xFFFF means an invalid PCI VENDOR ID. */ +if (hv_pcifront_get_vendor_id (hpdev) ==0xFFFF ) { +dev_err_once (&hbus->hdev->device, +"the device has gone\n" ); + goto free_int_desc; + } + +/* +* When the higher level interrupt code calls us with +* interrupt disabled, we must poll the channel by calling +* the channel callback directly when channel->target_cpu is +* the current CPU. When the higher level interrupt code +* calls us with interrupt enabled, let's add the +* local_bh_disable()/enable() to avoid race. +*/ +local_bh_disable (); + +if (hbus->hdev->channel->target_cpu ==smp_processor_id ()) +hv_pci_onchannelcallback (hbus); + +local_bh_enable (); + +if (hpdev->state == hv_pcichild_ejecting) { +dev_err_once (&hbus->hdev->device, +"the device is being ejected\n" ); + goto free_int_desc; + } +udelay (100 ); + }if (comp.comp_pkt.completion_status <0 ) { dev_err(&hbus->hdev->device,
Greg Kroah-Hartman
maintainerPATCH 12/52 xfs: convert XFS_AGFL_SIZE to a helper function
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit a78ee256c325ecfaec13cafc41b315bd4e1dd518 upstream.
The AGFL size calculation is about to get more complex, so lets turn the macro into a function first and remove the macro.
--- fs/xfs/libxfs/xfs_alloc.c | 31 ++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_alloc.h | 2 ++ fs/xfs/libxfs/xfs_format.h | 13 +------------ fs/xfs/xfs_fsops.c | 2 +- 4 files changed, 28 insertions(+), 20 deletions(-)
fs/xfs/libxfs/xfs_alloc.c +24 -7
@@ -52,6 +52,23 @@ STATIC int xfs_alloc_ag_vextent_size(xfs STATIC int xfs_alloc_ag_vextent_small(xfs_alloc_arg_t *,xfs_btree_cur_t *,xfs_agblock_t *,xfs_extlen_t *,int *); +/* +* Size of the AGFL. For CRC-enabled filesystes we steal a couple of slots in +* the beginning of the block for a proper header with the location information +* and CRC. +*/ +unsigned int +xfs_agfl_size ( +struct xfs_mount *mp) +{ +unsigned int size = mp->m_sb.sb_sectsize; + +if (xfs_sb_version_hascrc (&mp->m_sb)) + size -=sizeof (struct xfs_agfl ); + +return size /sizeof (xfs_agblock_t); +} +unsigned int xfs_refc_block (struct xfs_mount *mp)
@@ -540,7 +557,7 @@ xfs_agfl_verify(if (bp->b_pag &&be32_to_cpu (agfl->agfl_seqno) != bp->b_pag->pag_agno)return false; -for (i =0 ; i <XFS_AGFL_SIZE (mp); i++) { +for (i =0 ; i <xfs_agfl_size (mp); i++) {if (be32_to_cpu (agfl->agfl_bno[i]) !=NULLAGBLOCK &&be32_to_cpu (agfl->agfl_bno[i]) >= mp->m_sb.sb_agblocks)return false;
@@ -2252,7 +2269,7 @@ xfs_alloc_get_freelist( bno =be32_to_cpu (agfl_bno[be32_to_cpu (agf->agf_flfirst)]);be32_add_cpu (&agf->agf_flfirst,1 );xfs_trans_brelse (tp, agflbp); -if (be32_to_cpu (agf->agf_flfirst) ==XFS_AGFL_SIZE (mp)) +if (be32_to_cpu (agf->agf_flfirst) ==xfs_agfl_size (mp)) agf->agf_flfirst =0 ; pag =xfs_perag_get (mp,be32_to_cpu (agf->agf_seqno));
@@ -2363,7 +2380,7 @@ xfs_alloc_put_freelist( be32_to_cpu(agf->agf_seqno), &agflbp)))return error;be32_add_cpu (&agf->agf_fllast,1 ); -if (be32_to_cpu (agf->agf_fllast) ==XFS_AGFL_SIZE (mp)) +if (be32_to_cpu (agf->agf_fllast) ==xfs_agfl_size (mp)) agf->agf_fllast =0 ; pag =xfs_perag_get (mp,be32_to_cpu (agf->agf_seqno));
@@ -2381,7 +2398,7 @@ xfs_alloc_put_freelist(xfs_alloc_log_agf (tp, agbp, logflags); -ASSERT (be32_to_cpu (agf->agf_flcount) <=XFS_AGFL_SIZE (mp)); +ASSERT (be32_to_cpu (agf->agf_flcount) <=xfs_agfl_size (mp)); agfl_bno =XFS_BUF_TO_AGFL_BNO (mp, agflbp); blockp = &agfl_bno[be32_to_cpu (agf->agf_fllast)];
@@ -2414,9 +2431,9 @@ xfs_agf_verify(if (!(agf->agf_magicnum ==cpu_to_be32 (XFS_AGF_MAGIC ) &&XFS_AGF_GOOD_VERSION (be32_to_cpu (agf->agf_versionnum)) &&be32_to_cpu (agf->agf_freeblks) <=be32_to_cpu (agf->agf_length) && -be32_to_cpu (agf->agf_flfirst) <XFS_AGFL_SIZE (mp) && -be32_to_cpu (agf->agf_fllast) <XFS_AGFL_SIZE (mp) && -be32_to_cpu (agf->agf_flcount) <=XFS_AGFL_SIZE (mp))) +be32_to_cpu (agf->agf_flfirst) <xfs_agfl_size (mp) && +be32_to_cpu (agf->agf_fllast) <xfs_agfl_size (mp) && +be32_to_cpu (agf->agf_flcount) <=xfs_agfl_size (mp)))return false; if (be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) < 1 ||
fs/xfs/libxfs/xfs_alloc.h +2 -0
@@ -26,6 +26,8 @@ struct xfs_trans;extern struct workqueue_struct *xfs_alloc_wq; +unsigned int xfs_agfl_size (struct xfs_mount *mp); +/* * Freespace allocation types. Argument to xfs_alloc_[v]extent. */
fs/xfs/libxfs/xfs_format.h +1 -12
@@ -798,24 +798,13 @@ typedef struct xfs_agi { &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \ (__be32 *)(bp)->b_addr) -/* -* Size of the AGFL. For CRC-enabled filesystes we steal a couple of -* slots in the beginning of the block for a proper header with the -* location information and CRC. -*/ -#define XFS_AGFL_SIZE (mp) \ - (((mp)->m_sb.sb_sectsize - \ - (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ - sizeof(struct xfs_agfl) : 0)) / \ - sizeof(xfs_agblock_t)) -typedef struct xfs_agfl {__be32 agfl_magicnum;__be32 agfl_seqno;uuid_t agfl_uuid;__be64 agfl_lsn;__be32 agfl_crc; -__be32 agfl_bno[];/* actually XFS_AGFL_SIZE(mp) */ +__be32 agfl_bno[];/* actually xfs_agfl_size(mp) */ } __attribute__((packed))xfs_agfl_t ;#define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc)
fs/xfs/xfs_fsops.c +1 -1
@@ -294,7 +294,7 @@ xfs_growfs_data_private( } agfl_bno =XFS_BUF_TO_AGFL_BNO (mp, bp); -for (bucket =0 ; bucket <XFS_AGFL_SIZE (mp); bucket++) +for (bucket =0 ; bucket <xfs_agfl_size (mp); bucket++) agfl_bno[bucket] =cpu_to_be32 (NULLAGBLOCK ); error =xfs_bwrite (bp);
Greg Kroah-Hartman
maintainerPATCH 13/52 xfs: detect agfl count corruption and reset agfl
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Foster <[email protected]>
commit a27ba2607e60312554cbcd43fc660b2c7f29dc9c upstream.
The struct xfs_agfl v5 header was originally introduced with unexpected padding that caused the AGFL to operate with one less slot than intended. The header has since been packed, but the fix left an incompatibility for users who upgrade from an old kernel with the unpacked header to a newer kernel with the packed header while the AGFL happens to wrap around the end. The newer kernel recognizes one extra slot at the physical end of the AGFL that the previous kernel did not. The new kernel will eventually attempt to allocate a block from that slot, which contains invalid data, and cause a crash.
This condition can be detected by comparing the active range of the AGFL to the count. While this detects a padding mismatch, it can also trigger false positives for unrelated flcount corruption. Since we cannot distinguish a size mismatch due to padding from unrelated corruption, we can't trust the AGFL enough to simply repopulate the empty slot.
Instead, avoid unnecessarily complex detection logic and and use a solution that can handle any form of flcount corruption that slips through read verifiers: distrust the entire AGFL and reset it to an empty state. Any valid blocks within the AGFL are intentionally leaked. This requires xfs_repair to rectify (which was already necessary based on the state the AGFL was found in). The reset mitigates the side effect of the padding mismatch problem from a filesystem crash to a free space accounting inconsistency. The generic approach also means that this patch can be safely backported to kernels with or without a packed struct xfs_agfl.
Check the AGF for an invalid freelist count on initial read from disk. If detected, set a flag on the xfs_perag to indicate that a reset is required before the AGFL can be used. In the first transaction that attempts to use a flagged AGFL, reset it to empty, warn the user about the inconsistency and allow the freelist fixup code to repopulate the AGFL with new blocks. The xfs_perag flag is cleared to eliminate the need for repeated checks on each block allocation operation.
This allows kernels that include the packing fix commit 96f859d52bcb ("libxfs: pack the agfl header structure so XFS_AGFL_SIZE is correct") to handle older unpacked AGFL formats without a filesystem crash.
Reviewed-by Dave Chiluk <[email protected]>
--- fs/xfs/libxfs/xfs_alloc.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_mount.h | 1 fs/xfs/xfs_trace.h | 9 +++- 3 files changed, 103 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +94 -0
@@ -2057,6 +2057,93 @@ xfs_alloc_space_available( }/* +* Check the agfl fields of the agf for inconsistency or corruption. The purpose +* is to detect an agfl header padding mismatch between current and early v5 +* kernels. This problem manifests as a 1-slot size difference between the +* on-disk flcount and the active [first, last] range of a wrapped agfl. This +* may also catch variants of agfl count corruption unrelated to padding. Either +* way, we'll reset the agfl and warn the user. +* +* Return true if a reset is required before the agfl can be used, false +* otherwise. +*/ +static bool +xfs_agfl_needs_reset ( +struct xfs_mount *mp, +struct xfs_agf *agf) +{ +uint32_t f =be32_to_cpu (agf->agf_flfirst); +uint32_t l =be32_to_cpu (agf->agf_fllast); +uint32_t c =be32_to_cpu (agf->agf_flcount); +int agfl_size =xfs_agfl_size (mp); +int active; + +/* no agfl header on v4 supers */ +if (!xfs_sb_version_hascrc (&mp->m_sb)) +return false; + +/* +* The agf read verifier catches severe corruption of these fields. +* Repeat some sanity checks to cover a packed -> unpacked mismatch if +* the verifier allows it. +*/ +if (f >= agfl_size || l >= agfl_size) +return true; +if (c > agfl_size) +return true; + +/* +* Check consistency between the on-disk count and the active range. An +* agfl padding mismatch manifests as an inconsistent flcount. +*/ +if (c && l >= f) + active = l - f +1 ; +else if (c) + active = agfl_size - f + l +1 ; +else + active =0 ; + +return active != c; +} + +/* +* Reset the agfl to an empty state. Ignore/drop any existing blocks since the +* agfl content cannot be trusted. Warn the user that a repair is required to +* recover leaked blocks. +* +* The purpose of this mechanism is to handle filesystems affected by the agfl +* header padding mismatch problem. A reset keeps the filesystem online with a +* relatively minor free space accounting inconsistency rather than suffer the +* inevitable crash from use of an invalid agfl block. +*/ +static void +xfs_agfl_reset ( +struct xfs_trans *tp, +struct xfs_buf *agbp, +struct xfs_perag *pag) +{ +struct xfs_mount *mp = tp->t_mountp; +struct xfs_agf *agf =XFS_BUF_TO_AGF (agbp); + +ASSERT (pag->pagf_agflreset); +trace_xfs_agfl_reset (mp, agf,0 , _RET_IP_); + +xfs_warn (mp, +"WARNING: Reset corrupted AGFL on AG %u. %d blocks leaked. " +"Please unmount and run xfs_repair." , + pag->pag_agno, pag->pagf_flcount); + + agf->agf_flfirst =0 ; + agf->agf_fllast =cpu_to_be32 (xfs_agfl_size (mp) -1 ); + agf->agf_flcount =0 ; +xfs_alloc_log_agf (tp, agbp,XFS_AGF_FLFIRST |XFS_AGF_FLLAST | +XFS_AGF_FLCOUNT ); + + pag->pagf_flcount =0 ; + pag->pagf_agflreset = false; +} + +/* * Decide whether to use this allocation group for this allocation. * If so, fix up the btree freelist's size. */
@@ -2117,6 +2204,10 @@ xfs_alloc_fix_freelist( } } +/* reset a padding mismatched agfl before final free space check */ +if (pag->pagf_agflreset) +xfs_agfl_reset (tp, agbp, pag); +/* If there isn't enough total space or single-extent, reject it. */ need =xfs_alloc_min_freelist (mp, pag);if (!xfs_alloc_space_available (args, need, flags))
@@ -2273,6 +2364,7 @@ xfs_alloc_get_freelist( agf->agf_flfirst =0 ; pag =xfs_perag_get (mp,be32_to_cpu (agf->agf_seqno)); +ASSERT (!pag->pagf_agflreset);be32_add_cpu (&agf->agf_flcount,-1 );xfs_trans_agflist_delta (tp,-1 ); pag->pagf_flcount--;
@@ -2384,6 +2476,7 @@ xfs_alloc_put_freelist( agf->agf_fllast =0 ; pag =xfs_perag_get (mp,be32_to_cpu (agf->agf_seqno)); +ASSERT (!pag->pagf_agflreset);be32_add_cpu (&agf->agf_flcount,1 );xfs_trans_agflist_delta (tp,1 ); pag->pagf_flcount++;
@@ -2589,6 +2682,7 @@ xfs_alloc_read_agf( pag->pagb_count =0 ; pag->pagb_tree =RB_ROOT ; pag->pagf_init =1 ; + pag->pagf_agflreset =xfs_agfl_needs_reset (mp, agf); }#ifdef DEBUG else if (!XFS_FORCED_SHUTDOWN(mp)) {
fs/xfs/xfs_mount.h +1 -0
@@ -353,6 +353,7 @@ typedef struct xfs_perag {char pagi_inodeok;/* The agi is ok for inodes */ uint8_t pagf_levels[XFS_BTNUM_AGF ];/* # of levels in bno & cnt btree */ +bool pagf_agflreset;/* agfl requires reset before use */ uint32_t pagf_flcount;/* count of blocks in freelist */ xfs_extlen_t pagf_freeblks;/* total free blocks */ xfs_extlen_t pagf_longest;/* longest free space */
fs/xfs/xfs_trace.h +8 -1
@@ -1513,7 +1513,7 @@ TRACE_EVENT(xfs_extent_busy_trim, __entry->tlen) ); -TRACE_EVENT(xfs_agf, +DECLARE_EVENT_CLASS(xfs_agf_class, TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags, unsigned long caller_ip), TP_ARGS(mp, agf, flags, caller_ip),
@@ -1569,6 +1569,13 @@ TRACE_EVENT(xfs_agf, __entry->longest, (void *)__entry->caller_ip) ); +#define DEFINE_AGF_EVENT (name) \ +DEFINE_EVENT(xfs_agf_class, name, \ + TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags, \ + unsigned long caller_ip), \ + TP_ARGS(mp, agf, flags, caller_ip)) +DEFINE_AGF_EVENT (xfs_agf); +DEFINE_AGF_EVENT (xfs_agfl_reset); TRACE_EVENT(xfs_free_extent, TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
Greg Kroah-Hartman
maintainerPATCH 14/52 Input: synaptics - Lenovo Carbon X1 Gen5 (2017) devices should use RMI
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit 9b2071028f8def49971a3b213ab6efd02a7e56e8 upstream.
The touchpad on Lenovo Carbon X1 Gen 5 (2017 - Kabylake) is accessible over SMBUS/RMI, so let's activate it by default.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -172,6 +172,7 @@ static const char * const smbus_pnp_ids["LEN0048" ,/* X1 Carbon 3 */ "LEN0046" ,/* X250 */ "LEN004a" ,/* W541 */ +"LEN0072" ,/* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ "LEN200f" ,/* T450s */ NULL };
Greg Kroah-Hartman
maintainerPATCH 15/52 Input: synaptics - Lenovo Thinkpad X1 Carbon G5 (2017) with Elantech trackpoints should use RMI
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edvard Holst <[email protected]>
commit 15e2cffec3aa0d47a8d75ae80e1b136bfb5dff30 upstream.
Lenovo use two different trackpoints in the fifth generation Thinkpad X1 Carbon. Both are accessible over SMBUS/RMI but the pnpIDs are missing. This patch is for the Elantech trackpoint specifically which also reports SMB version 3 so rmi_smbus needs to be updated in order to handle it.
For the record, I was not the first one to come up with this patch as it has been floating around the internet for a while now. However, I have spent significant time with testing and my efforts to find the original author of the patch have been unsuccessful.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -173,6 +173,7 @@ static const char * const smbus_pnp_ids["LEN0046" ,/* X250 */ "LEN004a" ,/* W541 */ "LEN0072" ,/* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ +"LEN0073" ,/* X1 Carbon G5 (Elantech) */ "LEN200f" ,/* T450s */ NULL };
Greg Kroah-Hartman
maintainerPATCH 16/52 Input: synaptics - add Intertouch support on X1 Carbon 6th and X280
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Ma <[email protected]>
commit 5717a09aeaf62d197deba1fc7ccd6bc45f3a9dcc upstream.
Synaptics devices reported it has Intertouch support, and it fails via PS/2 as following logs:
psmouse serio2: Failed to reset mouse on synaptics-pt/serio0 psmouse serio2: Failed to enable mouse on synaptics-pt/serio0
Set these new devices to use SMBus to fix this issue, then they report SMBus version 3 is using, patch:
https://patchwork.kernel.org/patch/9989547/ enabled SMBus ver 3 and makes synaptics devices work fine on SMBus mode.
--- drivers/input/mouse/synaptics.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/input/mouse/synaptics.c +2 -0
@@ -174,6 +174,8 @@ static const char * const smbus_pnp_ids["LEN004a" ,/* W541 */ "LEN0072" ,/* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ "LEN0073" ,/* X1 Carbon G5 (Elantech) */ +"LEN0092" ,/* X1 Carbon 6 */ +"LEN0096" ,/* X280 */ "LEN200f" ,/* T450s */ NULL };
Greg Kroah-Hartman
maintainerPATCH 17/52 Input: synaptics - add Lenovo 80 series ids to SMBus
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Tissoires <[email protected]>
commit ad8fb554f04e38f155c9bc34bbf521fc592ceee7 upstream.
This time, Lenovo decided to go with different pieces in its latest series of Thinkpads.
For those we have been able to test:
- the T480 is using Synaptics with an IBM trackpoint
-> it behaves properly with or without intertouch, there is no point
not using RMI4
- the X1 Carbon 6th gen is using Synaptics with an IBM trackpoint -> the touchpad doesn't behave properly under PS/2 so we have to switch it to RMI4 if we do not want to have disappointed users
- the X280 is using Synaptics with an ALPS trackpoint
-> the recent fixes in the trackpoint handling fixed it so upstream
now works fine with or without RMI4, and there is no point not using RMI4
- the T480s is using an Elan touchpad, so that's a different story
--- drivers/input/mouse/synaptics.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/input/mouse/synaptics.c +2 -0
@@ -172,10 +172,12 @@ static const char * const smbus_pnp_ids["LEN0048" ,/* X1 Carbon 3 */ "LEN0046" ,/* X250 */ "LEN004a" ,/* W541 */ +"LEN0071" ,/* T480 */ "LEN0072" ,/* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ "LEN0073" ,/* X1 Carbon G5 (Elantech) */ "LEN0092" ,/* X1 Carbon 6 */ "LEN0096" ,/* X280 */ +"LEN0097" ,/* X280 -> ALPS trackpoint */ "LEN200f" ,/* T450s */ NULL };
Greg Kroah-Hartman
maintainerPATCH 18/52 Input: elan_i2c_smbus - fix corrupted stack
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Tissoires <[email protected]>
commit 40f7090bb1b4ec327ea1e1402ff5783af5b35195 upstream.
New ICs (like the one on the Lenovo T480s) answer to ETP_SMBUS_IAP_VERSION_CMD 4 bytes instead of 3. This corrupts the stack as i2c_smbus_read_block_data() uses the values returned by the i2c device to know how many data it need to return.
i2c_smbus_read_block_data() can read up to 32 bytes (I2C_SMBUS_BLOCK_MAX) and there is no safeguard on how many bytes are provided in the return value. Ensure we always have enough space for any future firmware. Also 0-initialize the values to prevent any access to uninitialized memory.
--- drivers/input/mouse/elan_i2c_smbus.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/input/mouse/elan_i2c_smbus.c +11 -11
@@ -130,7 +130,7 @@ static int elan_smbus_get_baseline_data( bool max_baseline, u8 *value) { int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; error = i2c_smbus_read_block_data(client, max_baseline ?
@@ -149,7 +149,7 @@ static int elan_smbus_get_version(struct bool iap, u8 *version) { int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; error = i2c_smbus_read_block_data(client, iap ? ETP_SMBUS_IAP_VERSION_CMD :
@@ -170,7 +170,7 @@ static int elan_smbus_get_sm_version(str u8 *clickpad) {int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; error =i2c_smbus_read_block_data (client,ETP_SMBUS_SM_VERSION_CMD , val);
@@ -188,7 +188,7 @@ static int elan_smbus_get_sm_version(strstatic int elan_smbus_get_product_id (struct i2c_client *client,u16 *id) {int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; error =i2c_smbus_read_block_data (client,ETP_SMBUS_UNIQUEID_CMD , val);
@@ -205,7 +205,7 @@ static int elan_smbus_get_checksum(struc bool iap, u16 *csum) { int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; error = i2c_smbus_read_block_data(client, iap ? ETP_SMBUS_FW_CHECKSUM_CMD :
@@ -226,7 +226,7 @@ static int elan_smbus_get_max(struct i2c {int ret;int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; ret =i2c_smbus_read_block_data (client,ETP_SMBUS_RANGE_CMD , val);if (ret !=3 ) {
@@ -246,7 +246,7 @@ static int elan_smbus_get_resolution(str {int ret;int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; ret =i2c_smbus_read_block_data (client,ETP_SMBUS_RESOLUTION_CMD , val);if (ret !=3 ) {
@@ -267,7 +267,7 @@ static int elan_smbus_get_num_traces(str {int ret;int error; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; ret =i2c_smbus_read_block_data (client,ETP_SMBUS_XY_TRACENUM_CMD , val);if (ret !=3 ) {
@@ -294,7 +294,7 @@ static int elan_smbus_iap_get_mode(struc {int error;u16 constant; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 }; error =i2c_smbus_read_block_data (client,ETP_SMBUS_IAP_CTRL_CMD , val);if (error <0 ) {
@@ -345,7 +345,7 @@ static int elan_smbus_prepare_fw_update(int len;int error;enum tp_mode mode; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 };u8 cmd[4 ] = {0x0F ,0x78 ,0x00 ,0x06 };u16 password;
@@ -419,7 +419,7 @@ static int elan_smbus_write_fw_block(strstruct device *dev = &client->dev;int error;u16 result; -u8 val[3 ]; +u8 val[I2C_SMBUS_BLOCK_MAX ] = {0 };/* * Due to the limitation of smbus protocol limiting
Greg Kroah-Hartman
maintainerPATCH 19/52 tracing: Fix crash when freeing instances with event triggers
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (VMware) <[email protected]>
commit 86b389ff22bd6ad8fd3cb98e41cd271886c6d023 upstream.
If a instance has an event trigger enabled when it is freed, it could cause an access of free memory. Here's the case that crashes:
# cd /sys/kernel/tracing # mkdir instances/foo # echo snapshot > instances/foo/events/initcall/initcall_start/trigger # rmdir instances/foo
Would produce:
general protection fault: 0000 [#1] PREEMPT SMP PTI Modules linked in: tun bridge ... CPU: 5 PID: 6203 Comm: rmdir Tainted: G W 4.17.0-rc4-test+ #933 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016 RIP: 0010:clear_event_triggers+0x3b/0x70 RSP: 0018:ffffc90003783de0 EFLAGS: 00010286 RAX: 0000000000000000 RBX: 6b6b6b6b6b6b6b2b RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8800c7130ba0 RBP: ffffc90003783e00 R08: ffff8801131993f8 R09: 0000000100230016 R10: ffffc90003783d80 R11: 0000000000000000 R12: ffff8800c7130ba0 R13: ffff8800c7130bd8 R14: ffff8800cc093768 R15: 00000000ffffff9c FS: 00007f6f4aa86700(0000) GS:ffff88011eb40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6f4a5aed60 CR3: 00000000cd552001 CR4: 00000000001606e0 Call Trace: event_trace_del_tracer+0x2a/0xc5 instance_rmdir+0x15c/0x200 tracefs_syscall_rmdir+0x52/0x90 vfs_rmdir+0xdb/0x160 do_rmdir+0x16d/0x1c0 __x64_sys_rmdir+0x17/0x20 do_syscall_64+0x55/0x1a0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
This was due to the call the clears out the triggers when an instance is being deleted not removing the trigger from the link list.
--- kernel/trace/trace_events_trigger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace_events_trigger.c +3 -2
@@ -482,9 +482,10 @@ clear_event_triggers(struct trace_arraystruct trace_event_file *file;list_for_each_entry (file, &tr->events, list) { -struct event_trigger_data *data; -list_for_each_entry_rcu (data, &file->triggers, list) { +struct event_trigger_data *data, *n; +list_for_each_entry_safe (data, n, &file->triggers, list) {trace_event_trigger_enable_disable (file,0 ); +list_del_rcu (&data->list);if (data->ops->free) data->ops->free (data->ops, data); }
Greg Kroah-Hartman
maintainerPATCH 20/52 tracing: Make the snapshot trigger work with instances
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (VMware) <[email protected]>
commit 2824f5033248600673e3e126a4d135363cbfd9ac upstream.
The snapshot trigger currently only affects the main ring buffer, even when it is used by the instances. This can be confusing as the snapshot trigger is listed in the instance.
Quoted 8 lines
# cd /sys/kernel/tracing # mkdir instances/foo # echo snapshot > instances/foo/events/syscalls/sys_enter_fchownat/trigger # echo top buffer > trace_marker # echo foo buffer > instances/foo/trace_marker # touch /tmp/bar # chown rostedt /tmp/bar # cat instances/foo/snapshot
# tracer: nop
#
#
# * Snapshot is freed *
#
# Snapshot commands:
# echo 0 > snapshot : Clears and frees snapshot buffer # echo 1 > snapshot : Allocates snapshot buffer, if not already allocated. # Takes a snapshot of the main buffer. # echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free) # (Doesn't have to be '2' works with any number that # is not a '0' or '1')
Quoted 1 line
# cat snapshot
# tracer: nop
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
bash-1189 [000] .... 111.488323: tracing_mark_write: top bufferNot only did the snapshot occur in the top level buffer, but the instance snapshot buffer should have been allocated, and it is still free.
--- kernel/trace/trace.c | 12 ++++++------ kernel/trace/trace.h | 11 +++++++++++ kernel/trace/trace_events_trigger.c | 10 ++++++++-- 3 files changed, 25 insertions(+), 8 deletions(-)
kernel/trace/trace.c +6 -6
@@ -894,7 +894,7 @@ int __trace_bputs(unsigned long ip, consEXPORT_SYMBOL_GPL (__trace_bputs);#ifdef CONFIG_TRACER_SNAPSHOT -static void tracing_snapshot_instance (struct trace_array *tr) +void tracing_snapshot_instance (struct trace_array *tr) {struct tracer *tracer = tr->current_trace;unsigned long flags;
@@ -950,7 +950,7 @@ static int resize_buffer_duplicate_size( struct trace_buffer *size_buf, int cpu_id);static void set_buffer_entries (struct trace_buffer *buf,unsigned long val); -static int alloc_snapshot (struct trace_array *tr) +int tracing_alloc_snapshot_instance (struct trace_array *tr) {int ret;
@@ -996,7 +996,7 @@ int tracing_alloc_snapshot(void)struct trace_array *tr = &global_trace;int ret; - ret =alloc_snapshot (tr); + ret =tracing_alloc_snapshot_instance (tr);WARN_ON (ret <0 );return ret;
@@ -5400,7 +5400,7 @@ static int tracing_set_tracer(struct tra#ifdef CONFIG_TRACER_MAX_TRACE if (t->use_max_tr && !had_max_tr) { - ret =alloc_snapshot (tr); + ret =tracing_alloc_snapshot_instance (tr);if (ret <0 ) goto out; }
@@ -6378,7 +6378,7 @@ tracing_snapshot_write(struct file *filp }#endif if (!tr->allocated_snapshot) { - ret =alloc_snapshot (tr); + ret =tracing_alloc_snapshot_instance (tr);if (ret <0 )break ; }
@@ -7099,7 +7099,7 @@ ftrace_trace_snapshot_callback(struct trreturn ret; out_reg: - ret =alloc_snapshot (tr); + ret =tracing_alloc_snapshot_instance (tr);if (ret <0 ) goto out;
kernel/trace/trace.h +11 -0
@@ -1807,6 +1807,17 @@ static inline void __init trace_event_instatic inline void trace_event_eval_update (struct trace_eval_map **map,int len) { }#endif +#ifdef CONFIG_TRACER_SNAPSHOT +void tracing_snapshot_instance (struct trace_array *tr); +int tracing_alloc_snapshot_instance (struct trace_array *tr); +#else +static inline void tracing_snapshot_instance (struct trace_array *tr) { } +static inline int tracing_alloc_snapshot_instance (struct trace_array *tr) +{ +return 0 ; +} +#endif +extern struct trace_iterator *tracepoint_print_iter;#endif /* _LINUX_KERNEL_TRACE_H */
kernel/trace/trace_events_trigger.c +8 -2
@@ -642,6 +642,7 @@ event_trigger_callback(struct event_comm trigger_data->count =-1 ; trigger_data->ops = trigger_ops; trigger_data->cmd_ops = cmd_ops; + trigger_data->private_data = file;INIT_LIST_HEAD (&trigger_data->list);INIT_LIST_HEAD (&trigger_data->named_list);
@@ -1042,7 +1043,12 @@ static struct event_command trigger_tracstatic void snapshot_trigger (struct event_trigger_data *data,void *rec) { -tracing_snapshot (); +struct trace_event_file *file = data->private_data; + +if (file) +tracing_snapshot_instance (file->tr); +else +tracing_snapshot (); } static void
@@ -1064,7 +1070,7 @@ register_snapshot_trigger(char *glob, st {int ret =register_trigger (glob, ops, data, file); -if (ret >0 &&tracing_alloc_snapshot () !=0 ) { +if (ret >0 &&tracing_alloc_snapshot_instance (file->tr) !=0 ) {unregister_trigger (glob, ops, data, file); ret =0 ; }
Greg Kroah-Hartman
maintainerPATCH 21/52 selinux: KASAN: slab-out-of-bounds in xattr_getsecurity
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sachin Grover <[email protected]>
commit efe3de79e0b52ca281ef6691480c8c68c82a4657 upstream.
Call trace: [<ffffff9203a8d7a8>] dump_backtrace+0x0/0x428 [<ffffff9203a8dbf8>] show_stack+0x28/0x38 [<ffffff920409bfb8>] dump_stack+0xd4/0x124 [<ffffff9203d187e8>] print_address_description+0x68/0x258 [<ffffff9203d18c00>] kasan_report.part.2+0x228/0x2f0 [<ffffff9203d1927c>] kasan_report+0x5c/0x70 [<ffffff9203d1776c>] check_memory_region+0x12c/0x1c0 [<ffffff9203d17cdc>] memcpy+0x34/0x68 [<ffffff9203d75348>] xattr_getsecurity+0xe0/0x160 [<ffffff9203d75490>] vfs_getxattr+0xc8/0x120 [<ffffff9203d75d68>] getxattr+0x100/0x2c8 [<ffffff9203d76fb4>] SyS_fgetxattr+0x64/0xa0 [<ffffff9203a83f70>] el0_svc_naked+0x24/0x28
If user get root access and calls security.selinux setxattr() with an embedded NUL on a file and then if some process performs a getxattr() on that file with a length greater than the actual length of the string, it would result in a panic.
To fix this, add the actual length of the string to the security context instead of the length passed by the userspace process.
--- security/selinux/ss/services.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/ss/services.c +1 -1
@@ -1448,7 +1448,7 @@ static int security_context_to_sid_core( scontext_len, &context, def_sid);if (rc == -EINVAL && force) { context.str = str; - context.len = scontext_len; + context.len =strlen (str) +1 ; str =NULL ; }else if (rc) goto out_unlock;
Greg Kroah-Hartman
maintainerPATCH 22/52 cfg80211: further limit wiphy names to 64 bytes
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 814596495dd2b9d4aab92d8f89cf19060d25d2ea upstream.
wiphy names were recently limited to 128 bytes by commit a7cfebcb7594 ("cfg80211: limit wiphy names to 128 bytes"). As it turns out though, this isn't sufficient because dev_vprintk_emit() needs the syslog header string "SUBSYSTEM=ieee80211\0DEVICE=+ieee80211:$devname" to fit into 128 bytes. This triggered the "device/subsystem name too long" WARN when the device name was >= 90 bytes. As before, this was reproduced by syzbot by sending an HWSIM_CMD_NEW_RADIO command to the MAC80211_HWSIM generic netlink family.
Fix it by further limiting wiphy names to 64 bytes.
--- include/uapi/linux/nl80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/nl80211.h +1 -1
@@ -2604,7 +2604,7 @@ enum nl80211_attrs {#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS -#define NL80211_WIPHY_NAME_MAXLEN 128 +#define NL80211_WIPHY_NAME_MAXLEN 64#define NL80211_MAX_SUPP_RATES 32#define NL80211_MAX_SUPP_HT_RATES 77
Greg Kroah-Hartman
maintainerPATCH 23/52 kbuild: clang: remove crufty HOSTCFLAGS
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nick Desaulniers <[email protected]>
commit df16aaac26e92e97ab7234d3f93c953466adc4b5 upstream.
When compiling with make CC=clang HOSTCC=clang, I was seeing warnings that clang did not recognize -fno-delete-null-pointer-checks for HOSTCC targets. These were added in commit 61163efae020 ("kbuild: LLVMLinux:
Add Kbuild support for building kernel with Clang").
Clang does not support -fno-delete-null-pointer-checks, so adding it to HOSTCFLAGS if HOSTCC is clang does not make sense.
It's not clear why the other warnings were disabled, and just for HOSTCFLAGS, but I can remove them, add -Werror to HOSTCFLAGS and compile with clang just fine.
--- Makefile | 5 ----- 1 file changed, 5 deletions(-)
Makefile +0 -5
@@ -369,11 +369,6 @@ HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) HOST_LOADLIBES := $(HOST_LFS_LIBS) -ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1) -HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \ - -Wno-missing-field-initializers -fno-delete-null-pointer-checks -endif - # Make variables (CC, etc...) AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld
Greg Kroah-Hartman
maintainerPATCH 24/52 drm/i915: Always sanity check engine state upon idling
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit cad9946c2a4375386062131858881cfd30fc1b8f upstream.
When we do a locked idle we know that afterwards all requests have been completed and the engines have been cleared of tasks. For whatever reason, this doesn't always happen and we may go into a suspend with ELSP still full, and this causes an issue upon resume as we get very, very confused.
If the engines refuse to idle, mark the device as wedged. In the process we get rid of the maybe unused open-coded version of wait_for_engines reported by Nick Desaulniers and Matthias Kaehlcke.
v2: Suppress the -EIO before suspend, but keep it for seqno wrap.
References: https://bugs.freedesktop.org/show_bug.cgi?id=101891
References: https://bugs.freedesktop.org/show_bug.cgi?id=102456
--- drivers/gpu/drm/i915/i915_gem.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +8 -19
@@ -3378,24 +3378,12 @@ static int wait_for_timeline(struct i915return 0 ; } -static int wait_for_engine (struct intel_engine_cs *engine,int timeout_ms) -{ -return wait_for (intel_engine_is_idle (engine), timeout_ms); -} -static int wait_for_engines (struct drm_i915_private *i915) { -struct intel_engine_cs *engine; -enum intel_engine_id id; - -for_each_engine (engine, i915, id) { -if (GEM_WARN_ON (wait_for_engine (engine,50 ))) { -i915_gem_set_wedged (i915); -return -EIO ; - } - -GEM_BUG_ON (intel_engine_get_seqno (engine) != -intel_engine_last_submit (engine)); +if (wait_for (intel_engines_are_idle (i915),50 )) { +DRM_ERROR ("Failed to idle engines, declaring wedged!\n" ); +i915_gem_set_wedged (i915); +return -EIO ; }return 0 ;
@@ -4575,7 +4563,7 @@ int i915_gem_suspend(struct drm_i915_pri ret =i915_gem_wait_for_idle (dev_priv,I915_WAIT_INTERRUPTIBLE |I915_WAIT_LOCKED ); -if (ret) +if (ret && ret != -EIO ) goto err_unlock;assert_kernel_context_is_current (dev_priv);
@@ -4619,11 +4607,12 @@ int i915_gem_suspend(struct drm_i915_pri* machine in an unusable condition. */ i915_gem_sanitize (dev_priv); - goto out_rpm_put; + +intel_runtime_pm_put (dev_priv); +return 0 ; err_unlock:mutex_unlock (&dev->struct_mutex); -out_rpm_put:intel_runtime_pm_put (dev_priv);return ret; }
Greg Kroah-Hartman
maintainerPATCH 25/52 dma-buf: remove redundant initialization of sg_table
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 531beb067c6185aceabfdee0965234c6a8fd133b upstream.
sg_table is being initialized and is never read before it is updated again later on, hence making the initialization redundant. Remove the initialization.
Detected by clang scan-build:
"warning: Value stored to 'sg_table' during its initialization is never read"
--- drivers/dma-buf/dma-buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-buf.c +1 -1
@@ -625,7 +625,7 @@ EXPORT_SYMBOL_GPL(dma_buf_detach);struct sg_table *dma_buf_map_attachment (struct dma_buf_attachment *attach,enum dma_data_direction direction) { -struct sg_table *sg_table =ERR_PTR (-EINVAL ); +struct sg_table *sg_table;might_sleep ();
Greg Kroah-Hartman
maintainerPATCH 26/52 drm/amd/powerplay: Fix enum mismatch
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Kaehlcke <[email protected]>
commit 42b5122e828a6ccd9952ad3116343dc032d33efe upstream.
In several locations the driver uses AMD_CG_STATE_UNGATE (type enum amd_clockgating_state) instead of AMD_PG_STATE_UNGATE (type enum amd_powergating_stat) and vice versa. Both constants have the same value, so this doesn't cause any problems, but we still want to pass the correct type.
Fixing the mismatch resolves multiple warnings like this when building with clang:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/cz_clockpowergating.c:169:7:
error: implicit conversion from enumeration type 'enum amd_powergating_state' to different enumeration type 'enum amd_clockgating_state' [-Werror,-Wenum-conversion]
AMD_PG_STATE_UNGATE);
--- drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 8 ++++---- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_clockpowergating.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +4 -4
@@ -176,10 +176,10 @@ int cz_dpm_powergate_uvd(struct pp_hwmgrcz_dpm_powerup_uvd (hwmgr);cgs_set_clockgating_state (hwmgr->device,AMD_IP_BLOCK_TYPE_UVD , -AMD_PG_STATE_UNGATE ); +AMD_CG_STATE_UNGATE );cgs_set_powergating_state (hwmgr->device,AMD_IP_BLOCK_TYPE_UVD , -AMD_CG_STATE_UNGATE ); +AMD_PG_STATE_UNGATE );cz_dpm_update_uvd_dpm (hwmgr, false); }
@@ -208,11 +208,11 @@ int cz_dpm_powergate_vce(struct pp_hwmgrcgs_set_clockgating_state ( hwmgr->device,AMD_IP_BLOCK_TYPE_VCE , -AMD_PG_STATE_UNGATE ); +AMD_CG_STATE_UNGATE );cgs_set_powergating_state ( hwmgr->device,AMD_IP_BLOCK_TYPE_VCE , -AMD_CG_STATE_UNGATE ); +AMD_PG_STATE_UNGATE );cz_dpm_update_vce_dpm (hwmgr);cz_enable_disable_vce_dpm (hwmgr, true);return 0 ;
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_clockpowergating.c +1 -1
@@ -162,7 +162,7 @@ int smu7_powergate_uvd(struct pp_hwmgr * AMD_CG_STATE_UNGATE);cgs_set_powergating_state (hwmgr->device,AMD_IP_BLOCK_TYPE_UVD , -AMD_CG_STATE_UNGATE ); +AMD_PG_STATE_UNGATE );smu7_update_uvd_dpm (hwmgr, false); }
Greg Kroah-Hartman
maintainerPATCH 27/52 rtlwifi: rtl8192cu: Remove variable self-assignment in rf.c
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Kaehlcke <[email protected]>
commit fb239c1209bb0f0b4830cc72507cc2f2d63fadbd upstream.
In _rtl92c_get_txpower_writeval_by_regulatory() the variable writeVal is assigned to itself in an if ... else statement, apparently only to document that the branch condition is handled and that a previously read value should be returned unmodified. The self-assignment causes clang to raise the following warning:
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c:304:13:
error: explicitly assigning value of variable of type 'u32'
(aka 'unsigned int') to itself [-Werror,-Wself-assign]
writeVal = writeVal;
Delete the branch with the self-assignment.
--- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rf.c +0 -3
@@ -299,9 +299,6 @@ static void _rtl92c_get_txpower_writeval writeVal =0x00000000 ;if (rtlpriv->dm.dynamic_txhighpower_lvl ==TXHIGHPWRLEVEL_BT1 ) writeVal = writeVal -0x06060606 ; -else if (rtlpriv->dm.dynamic_txhighpower_lvl == -TXHIGHPWRLEVEL_BT2 ) - writeVal = writeVal; *(p_outwriteval + rf) = writeVal; } }
Greg Kroah-Hartman
maintainerPATCH 28/52 ASoC: Intel: sst: remove redundant variable dma_dev_name
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 271ef65b5882425d500e969e875c98e47a6b0c86 upstream.
The pointer dma_dev_name is assigned but never read, it is redundant and can therefore be removed.
Cleans up clang warning:sound/soc/intel/common/sst-firmware.c:288:3: warning: Value stored to 'dma_dev_name' is never read
--- sound/soc/intel/common/sst-firmware.c | 2 -- 1 file changed, 2 deletions(-)
sound/soc/intel/common/sst-firmware.c +0 -2
@@ -274,7 +274,6 @@ int sst_dma_new(struct sst_dsp *sst)struct sst_pdata *sst_pdata = sst->pdata;struct sst_dma *dma;struct resource mem; -const char *dma_dev_name;int ret =0 ;if (sst->pdata->resindex_dma_base ==-1 )
@@ -285,7 +284,6 @@ int sst_dma_new(struct sst_dsp *sst)* is attached to the ADSP IP. */ switch (sst->pdata->dma_engine) {case SST_DMA_TYPE_DW : - dma_dev_name ="dw_dmac" ;break ;default : dev_err(sst->dev, "error: invalid DMA engine %d\n",
Greg Kroah-Hartman
maintainerPATCH 29/52 platform/chrome: cros_ec_lpc: remove redundant pointer request
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit d3b56c566d4ba8cae688baf3cca94425d57ea783 upstream.
Pointer request is being assigned but never used, so remove it. Cleans up the clang warning:
drivers/platform/chrome/cros_ec_lpc.c:68:2: warning: Value stored to 'request' is never read
--- drivers/platform/chrome/cros_ec_lpc.c | 3 --- 1 file changed, 3 deletions(-)
drivers/platform/chrome/cros_ec_lpc.c +0 -3
@@ -54,7 +54,6 @@ static int ec_response_timed_out(void)static int cros_ec_pkt_xfer_lpc (struct cros_ec_device *ec,struct cros_ec_command *msg) { -struct ec_host_request *request;struct ec_host_response response;u8 sum;int ret =0 ;
@@ -65,8 +64,6 @@ static int cros_ec_pkt_xfer_lpc(struct c/* Write buffer */ cros_ec_lpc_write_bytes (EC_LPC_ADDR_HOST_PACKET , ret, ec->dout); - request = (struct ec_host_request *)ec->dout; -/* Here we go */ sum =EC_COMMAND_PROTOCOL_3 ;cros_ec_lpc_write_bytes (EC_LPC_ADDR_HOST_CMD ,1 , &sum);
Greg Kroah-Hartman
maintainerPATCH 30/52 kbuild: clang: disable unused variable warnings only when constant
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sodagudi Prasad <[email protected]>
commit 0a5f41767444cc3b4fc5573921ab914b4f78baaa upstream.
Currently, GCC disables -Wunused-const-variable, but not -Wunused-variable, so warns unused variables if they are non-constant.
While, Clang does not warn unused variables at all regardless of the const qualifier because -Wno-unused-const-variable is implied by the stronger option -Wno-unused-variable.
Disable -Wunused-const-variable instead of -Wunused-variable so that GCC and Clang work in the same way.
--- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
@@ -706,7 +706,6 @@ KBUILD_CFLAGS += $(stackp-flag) ifeq ($(cc-name),clang) KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) KBUILD_CFLAGS += $(call cc-disable-warning, gnu) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
@@ -724,9 +723,9 @@ else # These warnings generated too much noise in a regular build. # Use make W=1 to enable them (see scripts/Makefile.extrawarn) KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) endif +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls else
Greg Kroah-Hartman
maintainerPATCH 31/52 tcp: avoid integer overflows in tcp_rcv_space_adjust()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 607065bad9931e72207b0cac365d7d4abc06bd99 upstream.
When using large tcp_rmem[2] values (I did tests with 500 MB), I noticed overflows while computing rcvwin.
Lets fix this before the following patch.
--- include/linux/tcp.h | 2 +- net/ipv4/tcp_input.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-)
include/linux/tcp.h +1 -1
@@ -334,7 +334,7 @@ struct tcp_sock {/* Receiver queue space */ struct { -int space; +u32 space;u32 seq;u64 time; } rcvq_space;
net/ipv4/tcp_input.c +6 -4
@@ -591,8 +591,8 @@ static inline void tcp_rcv_rtt_measure_tvoid tcp_rcv_space_adjust (struct sock *sk) {struct tcp_sock *tp =tcp_sk (sk); +u32 copied;int time; -int copied;tcp_mstamp_refresh (tp); time =tcp_stamp_us_delta (tp->tcp_mstamp, tp->rcvq_space.time);
@@ -615,12 +615,13 @@ void tcp_rcv_space_adjust(struct sock *sif (sysctl_tcp_moderate_rcvbuf && !(sk->sk_userlocks &SOCK_RCVBUF_LOCK )) { -int rcvwin, rcvmem, rcvbuf; +int rcvmem, rcvbuf; +u64 rcvwin;/* minimal window to cope with packet losses, assuming * steady state. Add some cushion because of small variations. */ - rcvwin = (copied <<1 ) +16 * tp->advmss; + rcvwin = ((u64 )copied <<1 ) +16 * tp->advmss;/* If rate increased by 25%, * assume slow start, rcvwin = 3 * copied
@@ -640,7 +641,8 @@ void tcp_rcv_space_adjust(struct sock *swhile (tcp_win_from_space (rcvmem) < tp->advmss) rcvmem +=128 ; - rcvbuf =min (rcvwin / tp->advmss * rcvmem, sysctl_tcp_rmem[2 ]); +do_div (rcvwin, tp->advmss); + rcvbuf =min_t (u64, rcvwin * rcvmem, sysctl_tcp_rmem[2 ]);if (rcvbuf > sk->sk_rcvbuf) { sk->sk_rcvbuf = rcvbuf;
Greg Kroah-Hartman
maintainerPATCH 32/52 iio: ad7793: implement IIO_CHAN_INFO_SAMP_FREQ
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Nosthoff <[email protected]>
commit 490fba90a90eb7b741f57fefd2bcf2c1e11eb471 upstream.
This commit is a follow-up to changes made to ad_sigma_delta.h in staging: iio: ad7192: implement IIO_CHAN_INFO_SAMP_FREQ which broke ad7793 as it was not altered to match those changes.
This driver predates the availability of IIO_CHAN_INFO_SAMP_FREQ attribute wherein usage has some advantages like it can be accessed by in-kernel consumers as well as reduces the code size.
Therefore, use IIO_CHAN_INFO_SAMP_FREQ to implement the sampling_frequency attribute instead of using IIO_DEV_ATTR_SAMP_FREQ() macro.
Move code from the functions associated with IIO_DEV_ATTR_SAMP_FREQ() into respective read and write hooks with the mask set to IIO_CHAN_INFO_SAMP_FREQ.
--- drivers/iio/adc/ad7793.c | 75 +++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 51 deletions(-)
drivers/iio/adc/ad7793.c +24 -51
@@ -348,55 +348,6 @@ static const u16 ad7793_sample_freq_avaistatic const u16 ad7797_sample_freq_avail[16 ] = {0 ,0 ,0 ,123 ,62 ,50 ,0 ,33 ,0 ,17 ,16 ,12 ,10 ,8 ,6 ,4 }; -static ssize_t ad7793_read_frequency (struct device *dev, -struct device_attribute *attr, -char *buf) -{ -struct iio_dev *indio_dev =dev_to_iio_dev (dev); -struct ad7793_state *st =iio_priv (indio_dev); - -return sprintf (buf,"%d\n" , - st->chip_info->sample_freq_avail[AD7793_MODE_RATE (st->mode)]); -} - -static ssize_t ad7793_write_frequency (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t len) -{ -struct iio_dev *indio_dev =dev_to_iio_dev (dev); -struct ad7793_state *st =iio_priv (indio_dev); -long lval; -int i, ret; - - ret =kstrtol (buf,10 , &lval); -if (ret) -return ret; - -if (lval ==0 ) -return -EINVAL ; - -for (i =0 ; i <16 ; i++) -if (lval == st->chip_info->sample_freq_avail[i]) -break ; -if (i ==16 ) -return -EINVAL ; - - ret =iio_device_claim_direct_mode (indio_dev); -if (ret) -return ret; - st->mode &= ~AD7793_MODE_RATE (-1 ); - st->mode |=AD7793_MODE_RATE (i); -ad_sd_write_reg (&st->sd,AD7793_REG_MODE ,sizeof (st->mode), st->mode); -iio_device_release_direct_mode (indio_dev); - -return len; -} - -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - ad7793_read_frequency, - ad7793_write_frequency); - static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( "470 242 123 62 50 39 33 19 17 16 12 10 8 6 4");
@@ -424,7 +375,6 @@ static IIO_DEVICE_ATTR_NAMED(in_m_in_sca ad7793_show_scale_available, NULL, 0);static struct attribute *ad7793_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_in_m_in_scale_available.dev_attr.attr,NULL
@@ -435,7 +385,6 @@ static const struct attribute_group ad77 };static struct attribute *ad7797_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available_ad7797.dev_attr.attr,NULL };
@@ -505,6 +454,10 @@ static int ad7793_read_raw(struct iio_de *val -= offset; }return IIO_VAL_INT ; +case IIO_CHAN_INFO_SAMP_FREQ : + *val = st->chip_info + ->sample_freq_avail[AD7793_MODE_RATE (st->mode)]; +return IIO_VAL_INT ; }return -EINVAL ; }
@@ -542,6 +495,26 @@ static int ad7793_write_raw(struct iio_dbreak ; }break ; +case IIO_CHAN_INFO_SAMP_FREQ : +if (!val) { + ret = -EINVAL ; +break ; + } + +for (i =0 ; i <16 ; i++) +if (val == st->chip_info->sample_freq_avail[i]) +break ; + +if (i ==16 ) { + ret = -EINVAL ; +break ; + } + + st->mode &= ~AD7793_MODE_RATE (-1 ); + st->mode |=AD7793_MODE_RATE (i); +ad_sd_write_reg (&st->sd,AD7793_REG_MODE ,sizeof (st->mode), + st->mode); +break ;default : ret = -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 33/52 iio:buffer: make length types match kfifo types
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kelly <[email protected]>
commit c043ec1ca5baae63726aae32abbe003192bc6eec upstream.
Currently, we use int for buffer length and bytes_per_datum. However, kfifo uses unsigned int for length and size_t for element size. We need to make sure these matches or we will have bugs related to overflow (in the range between INT_MAX and UINT_MAX for length, for example).
In addition, set_bytes_per_datum uses size_t while bytes_per_datum is an int, which would cause bugs for large values of bytes_per_datum.
Change buffer length to use unsigned int and bytes_per_datum to use size_t.
--- drivers/iio/buffer/industrialio-buffer-dma.c | 2 +- drivers/iio/buffer/kfifo_buf.c | 4 ++-- include/linux/iio/buffer_impl.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/iio/buffer/industrialio-buffer-dma.c +1 -1
@@ -587,7 +587,7 @@ EXPORT_SYMBOL_GPL(iio_dma_buffer_set_byt* Should be used as the set_length callback for iio_buffer_access_ops * struct for DMA buffers. */ -int iio_dma_buffer_set_length (struct iio_buffer *buffer,int length) +int iio_dma_buffer_set_length (struct iio_buffer *buffer,unsigned int length) {/* Avoid an invalid state */ if (length <2 )
drivers/iio/buffer/kfifo_buf.c +2 -2
@@ -22,7 +22,7 @@ struct iio_kfifo {#define iio_to_kfifo (r) container_of(r, struct iio_kfifo, buffer)static inline int __iio_allocate_kfifo (struct iio_kfifo *buf, -int bytes_per_datum,int length) +size_t bytes_per_datum,unsigned int length) {if ((length ==0 ) || (bytes_per_datum ==0 ))return -EINVAL ;
@@ -67,7 +67,7 @@ static int iio_set_bytes_per_datum_kfiforeturn 0 ; } -static int iio_set_length_kfifo (struct iio_buffer *r,int length) +static int iio_set_length_kfifo (struct iio_buffer *r,unsigned int length) {/* Avoid an invalid state */ if (length <2 )
include/linux/iio/buffer_impl.h +3 -3
@@ -53,7 +53,7 @@ struct iio_buffer_access_funcs {int (*request_update)(struct iio_buffer *buffer);int (*set_bytes_per_datum)(struct iio_buffer *buffer,size_t bpd); -int (*set_length)(struct iio_buffer *buffer,int length); +int (*set_length)(struct iio_buffer *buffer,unsigned int length);int (*enable)(struct iio_buffer *buffer,struct iio_dev *indio_dev);int (*disable)(struct iio_buffer *buffer,struct iio_dev *indio_dev);
@@ -72,10 +72,10 @@ struct iio_buffer_access_funcs {*/ struct iio_buffer {/** @length: Number of datums in buffer. */ -int length; +unsigned int length;/** @bytes_per_datum: Size of individual datum including timestamp. */ -int bytes_per_datum; +size_t bytes_per_datum;/** * @access: Buffer access functions associated with the
Greg Kroah-Hartman
maintainerPATCH 34/52 iio:kfifo_buf: check for uint overflow
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kelly <[email protected]>
commit 3d13de4b027d5f6276c0f9d3a264f518747d83f2 upstream.
Currently, the following causes a kernel OOPS in memcpy:
echo 1073741825 > buffer/length
echo 1 > buffer/enable
Note that using 1073741824 instead of 1073741825 causes "write error:
Cannot allocate memory" but no OOPS.
This is because 1073741824 == 2^30 and 1073741825 == 2^30+1. Since kfifo rounds up to the nearest power of 2, it will actually call kmalloc with roundup_pow_of_two(length) * bytes_per_datum.
Using length == 1073741825 and bytes_per_datum == 2, we get:
kmalloc(roundup_pow_of_two(1073741825) * 2
or kmalloc(2147483648 * 2)
or kmalloc(4294967296)
or kmalloc(UINT_MAX + 1)
so this overflows to 0, causing kmalloc to return ZERO_SIZE_PTR and subsequent memcpy to fail once the device is enabled.
Fix this by checking for overflow prior to allocating a kfifo. With this check added, the above code returns -EINVAL when enabling the buffer, rather than causing an OOPS.
--- drivers/iio/buffer/kfifo_buf.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iio/buffer/kfifo_buf.c +7 -0
@@ -27,6 +27,13 @@ static inline int __iio_allocate_kfifo(sif ((length ==0 ) || (bytes_per_datum ==0 ))return -EINVAL ; +/* +* Make sure we don't overflow an unsigned int after kfifo rounds up to +* the next power of 2. +*/ +if (roundup_pow_of_two (length) >UINT_MAX / bytes_per_datum) +return -EINVAL ; +return __kfifo_alloc ((struct __kfifo *)&buf->kf, length, bytes_per_datum,GFP_KERNEL ); }
Greg Kroah-Hartman
maintainerPATCH 35/52 iio: adc: select buffer for at91-sama5d2_adc
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugen Hristev <[email protected]>
commit 76974ef9d1bf397b7bb97892a3b3bc516a1fc2c2 upstream.
We need to select the buffer code, otherwise we get build errors with undefined functions on the trigger and buffer,
if we select just IIO and then AT91_SAMA5D2_ADC from menuconfig
This adds a Kconfig 'select' statement like other ADC drivers have it already.
--- drivers/iio/adc/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/iio/adc/Kconfig +1 -0
@@ -158,6 +158,7 @@ config AT91_SAMA5D2_ADC tristate "Atmel AT91 SAMA5D2 ADC" depends on ARCH_AT91 || COMPILE_TEST depends on HAS_IOMEM + select IIO_BUFFER select IIO_TRIGGERED_BUFFER help Say yes here to build support for Atmel SAMA5D2 ADC which is
Greg Kroah-Hartman
maintainerPATCH 36/52 MIPS: lantiq: gphy: Drop reboot/remove reset asserts
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Kresin <[email protected]>
commit 32795631e67e16141aa5e065c28ba03bf17abb90 upstream.
While doing a global software reset, these bits are not cleared and let some bootloader fail to initialise the GPHYs. The bootloader don't expect the GPHYs in reset, as they aren't during power on.
The asserts were a workaround for a wrong syscon-reboot mask. With a mask set which includes the GPHY resets, these resets aren't required any more.
Patchwork: https://patchwork.linux-mips.org/patch/19003/
--- drivers/soc/lantiq/gphy.c | 36 ------------------------------------ 1 file changed, 36 deletions(-)
drivers/soc/lantiq/gphy.c +0 -36
@@ -30,7 +30,6 @@ struct xway_gphy_priv {struct clk *gphy_clk_gate;struct reset_control *gphy_reset;struct reset_control *gphy_reset2; -struct notifier_block gphy_reboot_nb;void __iomem *membase;char *fw_name; };
@@ -64,24 +63,6 @@ static const struct of_device_id xway_gp };MODULE_DEVICE_TABLE (of, xway_gphy_match); -static struct xway_gphy_priv *to_xway_gphy_priv (struct notifier_block *nb) -{ - return container_of(nb, struct xway_gphy_priv, gphy_reboot_nb); -} - -static int xway_gphy_reboot_notify (struct notifier_block *reboot_nb, -unsigned long code,void *unused) -{ -struct xway_gphy_priv *priv =to_xway_gphy_priv (reboot_nb); - -if (priv) { -reset_control_assert (priv->gphy_reset); -reset_control_assert (priv->gphy_reset2); - } - -return NOTIFY_DONE ; -} -static int xway_gphy_load (struct device *dev,struct xway_gphy_priv *priv,dma_addr_t *dev_addr) {
@@ -205,14 +186,6 @@ static int xway_gphy_probe(struct platforeset_control_deassert (priv->gphy_reset);reset_control_deassert (priv->gphy_reset2); -/* assert the gphy reset because it can hang after a reboot: */ - priv->gphy_reboot_nb.notifier_call = xway_gphy_reboot_notify; - priv->gphy_reboot_nb.priority =-1 ; - - ret =register_reboot_notifier (&priv->gphy_reboot_nb); -if (ret) -dev_warn (dev,"Failed to register reboot notifier\n" ); -platform_set_drvdata (pdev, priv);return ret;
@@ -220,21 +193,12 @@ static int xway_gphy_probe(struct platfostatic int xway_gphy_remove (struct platform_device *pdev) { -struct device *dev = &pdev->dev;struct xway_gphy_priv *priv =platform_get_drvdata (pdev); -int ret; - -reset_control_assert (priv->gphy_reset); -reset_control_assert (priv->gphy_reset2);iowrite32be (0 , priv->membase);clk_disable_unprepare (priv->gphy_clk_gate); - ret =unregister_reboot_notifier (&priv->gphy_reboot_nb); -if (ret) -dev_warn (dev,"Failed to unregister reboot notifier\n" ); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 37/52 MIPS: ptrace: Fix PTRACE_PEEKUSR requests for 64-bit FGRs
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit c7e814628df65f424fe197dde73bfc67e4a244d7 upstream.
Use 64-bit accesses for 64-bit floating-point general registers with PTRACE_PEEKUSR, removing the truncation of their upper halves in the FR=1 mode, caused by commit bbd426f542cb ("MIPS: Simplify FP context access"), which inadvertently switched them to using 32-bit accesses.
The PTRACE_POKEUSR side is fine as it's never been broken and continues using 64-bit accesses.
Patchwork: https://patchwork.linux-mips.org/patch/19334/
--- arch/mips/kernel/ptrace.c | 2 +- arch/mips/kernel/ptrace32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/ptrace.c +1 -1
@@ -809,7 +809,7 @@ long arch_ptrace(struct task_struct *chi break; }#endif - tmp =get_fpr32 (&fregs[addr -FPR_BASE ],0 ); + tmp =get_fpr64 (&fregs[addr -FPR_BASE ],0 );break ;case PC : tmp = regs->cp0_epc;
arch/mips/kernel/ptrace32.c +1 -1
@@ -108,7 +108,7 @@ long compat_arch_ptrace(struct task_stru addr & 1);break ; } - tmp =get_fpr32 (&fregs[addr -FPR_BASE ],0 ); + tmp =get_fpr64 (&fregs[addr -FPR_BASE ],0 );break ;case PC : tmp = regs->cp0_epc;
Greg Kroah-Hartman
maintainerPATCH 38/52 MIPS: prctl: Disallow FRE without FR with PR_SET_FP_MODE requests
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 28e4213dd331e944e7fca1954a946829162ed9d4 upstream.
Having PR_FP_MODE_FRE (i.e. Config5.FRE) set without PR_FP_MODE_FR (i.e. Status.FR) is not supported as the lone purpose of Config5.FRE is to emulate Status.FR=0 handling on FPU hardware that has Status.FR=1 hardwired[1][2]. Also we do not handle this case elsewhere, and assume throughout our code that TIF_HYBRID_FPREGS and TIF_32BIT_FPREGS cannot be set both at once for a task, leading to inconsistent behaviour if this does happen.
Return unsuccessfully then from prctl(2) PR_SET_FP_MODE calls requesting PR_FP_MODE_FRE to be set with PR_FP_MODE_FR clear. This corresponds to modes allowed by `mips_set_personality_fp'.
References:
[1] "MIPS Architecture For Programmers, Vol. III: MIPS32 / microMIPS32 Privileged Resource Architecture", Imagination Technologies, Document Number: MD00090, Revision 6.02, July 10, 2015, Table 9.69 "Config5 Register Field Descriptions", p. 262
[2] "MIPS Architecture For Programmers, Volume III: MIPS64 / microMIPS64 Privileged Resource Architecture", Imagination Technologies, Document Number: MD00091, Revision 6.03, December 22, 2015, Table 9.72 "Config5 Register Field Descriptions", p. 288
Patchwork: https://patchwork.linux-mips.org/patch/19327/
--- arch/mips/kernel/process.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/mips/kernel/process.c +4 -0
@@ -721,6 +721,10 @@ int mips_set_process_fp_mode(struct taskif (value & ~known_bits)return -EOPNOTSUPP ; +/* Setting FRE without FR is not supported. */ +if ((value & (PR_FP_MODE_FR |PR_FP_MODE_FRE )) ==PR_FP_MODE_FRE ) +return -EOPNOTSUPP ; +/* Avoid inadvertently triggering emulation */ if ((value &PR_FP_MODE_FR ) && raw_cpu_has_fpu && !(raw_current_cpu_data.fpu_id &MIPS_FPIR_F64 ))
Greg Kroah-Hartman
maintainerPATCH 39/52 scsi: scsi_transport_srp: Fix shost to rport translation
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit c9ddf73476ff4fffb7a87bd5107a0705bf2cf64b upstream.
Since an SRP remote port is attached as a child to shost->shost_gendev and as the only child, the translation from the shost pointer into an rport pointer must happen by looking up the shost child that is an rport. This patch fixes the following KASAN complaint:
BUG: KASAN: slab-out-of-bounds in srp_timed_out+0x57/0x110 [scsi_transport_srp] Read of size 4 at addr ffff880035d3fcc0 by task kworker/1:0H/19 CPU: 1 PID: 19 Comm: kworker/1:0H Not tainted 4.16.0-rc3-dbg+ #1 Workqueue: kblockd blk_mq_timeout_work Call Trace: dump_stack+0x85/0xc7 print_address_description+0x65/0x270 kasan_report+0x231/0x350 srp_timed_out+0x57/0x110 [scsi_transport_srp] scsi_times_out+0xc7/0x3f0 [scsi_mod] blk_mq_terminate_expired+0xc2/0x140 bt_iter+0xbc/0xd0 blk_mq_queue_tag_busy_iter+0x1c7/0x350 blk_mq_timeout_work+0x325/0x3f0 process_one_work+0x441/0xa50 worker_thread+0x76/0x6c0 kthread+0x1b2/0x1d0 ret_from_fork+0x24/0x30
--- drivers/scsi/scsi_transport_srp.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/scsi/scsi_transport_srp.c +20 -2
@@ -51,6 +51,8 @@ struct srp_internal {struct transport_container rport_attr_cont; }; +static int scsi_is_srp_rport (const struct device *dev); +#define to_srp_internal (tmpl) container_of(tmpl, struct srp_internal, t)#define dev_to_rport (d) container_of(d, struct srp_rport, dev)
@@ -60,9 +62,24 @@ static inline struct Scsi_Host *rport_toreturn dev_to_shost (r->dev.parent); } +static int find_child_rport (struct device *dev,void *data) +{ +struct device **child = data; + +if (scsi_is_srp_rport (dev)) { +WARN_ON_ONCE (*child); + *child = dev; + } +return 0 ; +} +static inline struct srp_rport *shost_to_rport (struct Scsi_Host *shost) { -return transport_class_to_srp_rport (&shost->shost_gendev); +struct device *child =NULL ; + +WARN_ON_ONCE (device_for_each_child (&shost->shost_gendev, &child, + find_child_rport) <0 ); +return child ?dev_to_rport (child) :NULL ; }/**
@@ -600,7 +617,8 @@ enum blk_eh_timer_return srp_timed_out(sstruct srp_rport *rport =shost_to_rport (shost);pr_debug ("timeout for sdev %s\n" ,dev_name (&sdev->sdev_gendev)); -return rport->fast_io_fail_tmo <0 && rport->dev_loss_tmo <0 && +return rport && rport->fast_io_fail_tmo <0 && + rport->dev_loss_tmo <0 && i->f->reset_timer_if_blocked &&scsi_device_blocked (sdev) ?BLK_EH_RESET_TIMER :BLK_EH_NOT_HANDLED ; }
Greg Kroah-Hartman
maintainerPATCH 40/52 stm class: Use vmalloc for the master map
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Shishkin <[email protected]>
commit b5e2ced9bf81393034072dd4d372f6b430bc1f0a upstream.
Fengguang is running into a warning from the buddy allocator:
Quoted 4 lines
swapper/0: page allocation failure: order:9, mode:0x14040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null)
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.17.0-rc1 #262 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 Call Trace:
...
Quoted 2 lines
__kmalloc+0x14b/0x180: ____cache_alloc at mm/slab.c:3127 stm_register_device+0xf3/0x5c0: stm_register_device at drivers/hwtracing/stm/core.c:695
...
Which is basically a result of the stm class trying to allocate ~512kB for the dummy_stm with its default parameters. There's no reason, however, for it not to be vmalloc()ed instead, which is what this patch does.
--- drivers/hwtracing/stm/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/stm/core.c +3 -3
@@ -682,7 +682,7 @@ static void stm_device_release(struct de {struct stm_device *stm =to_stm_device (dev); -kfree (stm); +vfree (stm); } int stm_register_device(struct device *parent, struct stm_data *stm_data,
@@ -699,7 +699,7 @@ int stm_register_device(struct device *preturn -EINVAL ; nmasters = stm_data->sw_end - stm_data->sw_start +1 ; - stm =kzalloc (sizeof (*stm) + nmasters *sizeof (void *),GFP_KERNEL ); + stm =vzalloc (sizeof (*stm) + nmasters *sizeof (void *));if (!stm)return -ENOMEM ;
@@ -752,7 +752,7 @@ err_device:/* matches device_initialize() above */ put_device (&stm->dev); err_free: -kfree (stm); +vfree (stm);return err; }
Greg Kroah-Hartman
maintainerPATCH 41/52 hwtracing: stm: fix build error on some arches
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 806e30873f0e74d9d41b0ef761bd4d3e55c7d510 upstream.
Commit b5e2ced9bf81 ("stm class: Use vmalloc for the master map") caused a build error on some arches as vmalloc.h was not explicitly included.
Fix that by adding it to the list of includes.
--- drivers/hwtracing/stm/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwtracing/stm/core.c +1 -0
@@ -27,6 +27,7 @@#include <linux/stm.h> #include <linux/fs.h> #include <linux/mm.h> +#include <linux/vmalloc.h> #include "stm.h" #include <uapi/linux/stm.h>
Greg Kroah-Hartman
maintainerPATCH 42/52 IB/core: Fix error code for invalid GID entry
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
commit a840c93ca7582bb6c88df2345a33f979b7a67874 upstream.
When a GID entry is invalid EAGAIN is returned. This is an incorrect error code, there is nothing that will make this GID entry valid again in bounded time.
Some user space tools fail incorrectly if EAGAIN is returned here, and this represents a small ABI change from earlier kernels.
The first patch in the Fixes list makes entries that were valid before to become invalid, allowing this code to trigger, while the second patch in the Fixes list introduced the wrong EAGAIN.
Therefore revert the return result to EINVAL which matches the historical expectations of the ibv_query_gid_type() API of the libibverbs user space library.
--- drivers/infiniband/core/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/cache.c +1 -1
@@ -434,7 +434,7 @@ static int __ib_cache_gid_get(struct ib_return -EINVAL ;if (table->data_vec[index].props &GID_TABLE_ENTRY_INVALID ) -return -EAGAIN ; +return -EINVAL ;memcpy (gid, &table->data_vec[index].gid,sizeof (*gid));if (attr) {
Greg Kroah-Hartman
maintainerPATCH 43/52 mm/huge_memory.c: __split_huge_page() use atomic ClearPageDirty()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugh Dickins <[email protected]>
commit 2d077d4b59924acd1f5180c6fb73b57f4771fde6 upstream.
Swapping load on huge=always tmpfs (with khugepaged tuned up to be very eager, but I'm not sure that is relevant) soon hung uninterruptibly, waiting for page lock in shmem_getpage_gfp()'s find_lock_entry(), most often when "cp -a" was trying to write to a smallish file. Debug showed that the page in question was not locked, and page->mapping NULL by now, but page->index consistent with having been in a huge page before.
Reproduced in minutes on a 4.15 kernel, even with 4.17's 605ca5ede764 ("mm/huge_memory.c: reorder operations in __split_huge_page_tail()") added in; but took hours to reproduce on a 4.17 kernel (no idea why).
The culprit proved to be the __ClearPageDirty() on tails beyond i_size in __split_huge_page(): the non-atomic __bitoperation may have been safe when 4.8's baa355fd3314 ("thp: file pages support for split_huge_page()") introduced it, but liable to erase PageWaiters after 4.10's 62906027091f ("mm: add PageWaiters indicating tasks are waiting for a page bit").
--- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/huge_memory.c +1 -1
@@ -2388,7 +2388,7 @@ static void __split_huge_page(struct pag__split_huge_page_tail (head, i, lruvec, list);/* Some pages can be beyond i_size: drop them from page cache */ if (head[i].index >= end) { -__ClearPageDirty (head + i); +ClearPageDirty (head + i);__delete_from_page_cache (head + i,NULL );if (IS_ENABLED (CONFIG_SHMEM ) &&PageSwapBacked (head))shmem_uncharge (head->mapping->host,1 );
Greg Kroah-Hartman
maintainerPATCH 44/52 Revert "rt2800: use TXOP_BACKOFF for probe frames"
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
commit 52a192362932f333a7ebafd581c4d9b81da2fec8 upstream.
This reverts commit fb47ada8dc3c30c8e7b415da155742b49536c61e.
In some situations when we set TXOP_BACKOFF, the probe frame is not sent at all. What it worse then sending probe frame as part of AMPDU and can degrade 11n performance to 11g rates.
--- drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c +3 -4
@@ -372,16 +372,15 @@ static void rt2x00queue_create_tx_descri/* * Determine IFS values -* - Use TXOP_BACKOFF for probe and management frames except beacons +* - Use TXOP_BACKOFF for management frames except beacons * - Use TXOP_SIFS for fragment bursts * - Use TXOP_HTTXOP for everything else * * Note: rt2800 devices won't use CTS protection (if used) * for frames not transmitted with TXOP_HTTXOP */ -if ((ieee80211_is_mgmt (hdr->frame_control) && - !ieee80211_is_beacon (hdr->frame_control)) || - (tx_info->flags &IEEE80211_TX_CTL_RATE_CTRL_PROBE )) +if (ieee80211_is_mgmt (hdr->frame_control) && + !ieee80211_is_beacon (hdr->frame_control)) txdesc->u.ht.txop =TXOP_BACKOFF ;else if (!(tx_info->flags &IEEE80211_TX_CTL_FIRST_FRAGMENT )) txdesc->u.ht.txop =TXOP_SIFS ;
Greg Kroah-Hartman
maintainerPATCH 45/52 intel_th: Use correct device when freeing buffers
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Shishkin <[email protected]>
commit 0ed2424b911f3a058dfea01b78817abed767433d upstream.
Commit d5c435df4a890 ("intel_th: msu: Use the real device in case of IOMMU domain allocation") changes dma buffer allocation to use the actual underlying device, but forgets to change the deallocation path, which leads to (if you've got CAP_SYS_RAWIO):
Quoted 5 lines
# echo 0,0 > /sys/bus/intel_th/devices/0-msc0/nr_pages ------------[ cut here ]------------ kernel BUG at ../linux/drivers/iommu/intel-iommu.c:3670! CPU: 3 PID: 231 Comm: sh Not tainted 4.17.0-rc1+ #2729 RIP: 0010:intel_unmap+0x11e/0x130
...
Quoted 3 lines
Call Trace: intel_free_coherent+0x3e/0x60 msc_buffer_win_free+0x100/0x160 [intel_th_msu]
This patch fixes the buffer deallocation code to use the correct device.
--- drivers/hwtracing/intel_th/msu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/intel_th/msu.c +3 -3
@@ -741,8 +741,8 @@ err_nomem:/* Reset the page to write-back before releasing */ set_memory_wb ((unsigned long )win->block[i].bdesc,1 );#endif -dma_free_coherent (msc_dev (msc), size, win->block[i].bdesc, - win->block[i].addr); +dma_free_coherent (msc_dev (msc)->parent->parent, size, + win->block[i].bdesc, win->block[i].addr); }kfree (win);
@@ -777,7 +777,7 @@ static void msc_buffer_win_free(struct m/* Reset the page to write-back before releasing */ set_memory_wb ((unsigned long )win->block[i].bdesc,1 );#endif -dma_free_coherent (msc_dev (win->msc),PAGE_SIZE , +dma_free_coherent (msc_dev (win->msc)->parent->parent,PAGE_SIZE , win->block[i].bdesc, win->block[i].addr); }
Greg Kroah-Hartman
maintainerPATCH 46/52 drm/psr: Fix missed entry in PSR setup time table.
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dhinakaran Pandiyan <[email protected]>
commit bdcc02cf1bb508fc700df7662f55058f651f2621 upstream.
Entry corresponding to 220 us setup time was missing. I am not aware of any specific bug this fixes, but this could potentially result in enabling PSR on a panel with a higher setup time requirement than supported by the hardware.
I verified the value is present in eDP spec versions 1.3, 1.4 and 1.4a.
--- drivers/gpu/drm/drm_dp_helper.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_dp_helper.c +1 -0
@@ -1139,6 +1139,7 @@ int drm_dp_psr_setup_time(const u8 psr_cstatic const u16 psr_setup_time_us[] = {PSR_SETUP_TIME (330 ),PSR_SETUP_TIME (275 ), +PSR_SETUP_TIME (220 ),PSR_SETUP_TIME (165 ),PSR_SETUP_TIME (110 ),PSR_SETUP_TIME (55 ),
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Greg Kroah-Hartman
maintainerPATCH 49/52 powerpc/mm/slice: Remove intermediate bitmap copy
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit 326691ad4f179e6edc7eb1271e618dd673e4736d upstream.
bitmap_or() and bitmap_andnot() can work properly with dst identical to src1 or src2. There is no need of an intermediate result bitmap that is copied back to dst in a second step.
--- arch/powerpc/mm/slice.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/mm/slice.c +4 -8
@@ -379,21 +379,17 @@ static unsigned long slice_find_area(strstatic inline void slice_or_mask (struct slice_mask *dst,struct slice_mask *src) { -DECLARE_BITMAP (result,SLICE_NUM_HIGH ); - dst->low_slices |= src->low_slices; -bitmap_or (result, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); -bitmap_copy (dst->high_slices, result,SLICE_NUM_HIGH ); +bitmap_or (dst->high_slices, dst->high_slices, src->high_slices, +SLICE_NUM_HIGH ); }static inline void slice_andnot_mask (struct slice_mask *dst,struct slice_mask *src) { -DECLARE_BITMAP (result,SLICE_NUM_HIGH ); - dst->low_slices &= ~src->low_slices; -bitmap_andnot (result, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); -bitmap_copy (dst->high_slices, result,SLICE_NUM_HIGH ); +bitmap_andnot (dst->high_slices, dst->high_slices, src->high_slices, +SLICE_NUM_HIGH ); }#ifdef CONFIG_PPC_64K_PAGES
Greg Kroah-Hartman
maintainerPATCH 50/52 powerpc/mm/slice: create header files dedicated to slices
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit a3286f05bc5a5bc7fc73a9783ec89de78fcd07f8 upstream.
In preparation for the following patch which will enhance 'slices' for supporting PPC32 in order to fix an issue on hugepages on 8xx, this patch takes out of page*.h all bits related to 'slices' and put them into newly created slice.h header files.
While common parts go into asm/slice.h, subarch specific parts go into respective books3s/64/slice.c and nohash/64/slice.c 'slices'
--- arch/powerpc/include/asm/book3s/64/slice.h | 27 +++++++++++++ arch/powerpc/include/asm/nohash/64/slice.h | 12 +++++ arch/powerpc/include/asm/page.h | 1 arch/powerpc/include/asm/page_64.h | 59 ----------------------------- arch/powerpc/include/asm/slice.h | 40 +++++++++++++++++++ 5 files changed, 80 insertions(+), 59 deletions(-)
arch/powerpc/include/asm/book3s/64/slice.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_BOOK3S_64_SLICE_H +#define _ASM_POWERPC_BOOK3S_64_SLICE_H + +#ifdef CONFIG_PPC_MM_SLICES + +#define SLICE_LOW_SHIFT 28 +#define SLICE_LOW_TOP (0x100000000ul) +#define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) +#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT) + +#define SLICE_HIGH_SHIFT 40 +#define SLICE_NUM_HIGH (H_PGTABLE_RANGE >> SLICE_HIGH_SHIFT) +#define GET_HIGH_SLICE_INDEX (addr) ((addr) >> SLICE_HIGH_SHIFT) + +#else /* CONFIG_PPC_MM_SLICES */ + +#define get_slice_psize (mm, addr) ((mm)->context.user_psize) +#define slice_set_user_psize (mm, psize) \ +do { \ + (mm)->context.user_psize = (psize); \ + (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \ +} while (0) + +#endif /* CONFIG_PPC_MM_SLICES */ + +#endif /* _ASM_POWERPC_BOOK3S_64_SLICE_H */
arch/powerpc/include/asm/nohash/64/slice.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_NOHASH_64_SLICE_H +#define _ASM_POWERPC_NOHASH_64_SLICE_H + +#ifdef CONFIG_PPC_64K_PAGES +#define get_slice_psize (mm, addr) MMU_PAGE_64K +#else /* CONFIG_PPC_64K_PAGES */ +#define get_slice_psize (mm, addr) MMU_PAGE_4K +#endif /* !CONFIG_PPC_64K_PAGES */ +#define slice_set_user_psize (mm, psize) do { BUG(); } while (0) + +#endif /* _ASM_POWERPC_NOHASH_64_SLICE_H */
arch/powerpc/include/asm/page.h +1 -0
@@ -344,5 +344,6 @@ typedef struct page *pgtable_t;#include <asm-generic/memory_model.h> #endif /* __ASSEMBLY__ */ +#include <asm/slice.h> #endif /* _ASM_POWERPC_PAGE_H */
arch/powerpc/include/asm/page_64.h +0 -59
65 lines not on this page · raw message
arch/powerpc/include/asm/slice.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_SLICE_H +#define _ASM_POWERPC_SLICE_H + +#ifdef CONFIG_PPC_BOOK3S_64 +#include <asm/book3s/64/slice.h> +#else +#include <asm/nohash/64/slice.h> +#endif + +#ifdef CONFIG_PPC_MM_SLICES + +#ifdef CONFIG_HUGETLB_PAGE +#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA +#endif +#define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN + +#ifndef __ASSEMBLY__ + +struct mm_struct ; + +unsigned long slice_get_unmapped_area (unsigned long addr,unsigned long len, +unsigned long flags,unsigned int psize, +int topdown); + +unsigned int get_slice_psize (struct mm_struct *mm,unsigned long addr); + +void slice_set_user_psize (struct mm_struct *mm,unsigned int psize); +void slice_set_range_psize (struct mm_struct *mm,unsigned long start, +unsigned long len,unsigned int psize); +#endif /* __ASSEMBLY__ */ + +#else /* CONFIG_PPC_MM_SLICES */ + +#define slice_set_range_psize (mm, start, len, psize) \ + slice_set_user_psize((mm), (psize)) +#endif /* CONFIG_PPC_MM_SLICES */ + +#endif /* _ASM_POWERPC_SLICE_H */
Greg Kroah-Hartman
maintainerPATCH 51/52 powerpc/mm/slice: Enhance for supporting PPC32
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit db3a528db41caaa6dfd4c64e9f5efb1c81a80467 upstream.
In preparation for the following patch which will fix an issue on the 8xx by re-using the 'slices', this patch enhances the 'slices' implementation to support 32 bits CPUs.
On PPC32, the address space is limited to 4Gbytes, hence only the low slices will be used.
The high slices use bitmaps. As bitmap functions are not prepared to handle bitmaps of size 0, this patch ensures that bitmap functions are called only when SLICE_NUM_HIGH is not nul.
--- arch/powerpc/include/asm/nohash/32/slice.h | 18 ++++++++++++++ arch/powerpc/include/asm/slice.h | 4 ++- arch/powerpc/mm/slice.c | 37 ++++++++++++++++++++++------- 3 files changed, 50 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/nohash/32/slice.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_NOHASH_32_SLICE_H +#define _ASM_POWERPC_NOHASH_32_SLICE_H + +#ifdef CONFIG_PPC_MM_SLICES + +#define SLICE_LOW_SHIFT 28 +#define SLICE_LOW_TOP (0x100000000ull) +#define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) +#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT) + +#define SLICE_HIGH_SHIFT 0 +#define SLICE_NUM_HIGH 0ul +#define GET_HIGH_SLICE_INDEX (addr) (addr & 0) + +#endif /* CONFIG_PPC_MM_SLICES */ + +#endif /* _ASM_POWERPC_NOHASH_32_SLICE_H */
arch/powerpc/include/asm/slice.h +3 -1
@@ -4,8 +4,10 @@#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/slice.h> -#else +#elif defined(CONFIG_PPC64 )#include <asm/nohash/64/slice.h> +#elif defined(CONFIG_PPC_MMU_NOHASH ) +#include <asm/nohash/32/slice.h> #endif #ifdef CONFIG_PPC_MM_SLICES
arch/powerpc/mm/slice.c +29 -8
@@ -73,10 +73,12 @@ static void slice_range_to_mask(unsignedunsigned long end = start + len -1 ; ret->low_slices =0 ; -bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); +if (SLICE_NUM_HIGH ) +bitmap_zero (ret->high_slices,SLICE_NUM_HIGH );if (start <SLICE_LOW_TOP ) { -unsigned long mend =min (end, (SLICE_LOW_TOP -1 )); +unsigned long mend =min (end, + (unsigned long )(SLICE_LOW_TOP -1 )); ret->low_slices = (1u << (GET_LOW_SLICE_INDEX (mend) +1 )) - (1u <<GET_LOW_SLICE_INDEX (start));
@@ -113,11 +115,13 @@ static int slice_high_has_vma(struct mm_unsigned long start = slice <<SLICE_HIGH_SHIFT ;unsigned long end = start + (1ul <<SLICE_HIGH_SHIFT ); +#ifdef CONFIG_PPC64 /* Hack, so that each addresses is controlled by exactly one * of the high or low area bitmaps, the first high area starts * at 4GB, not 0 */ if (start ==0 ) start =SLICE_LOW_TOP ; +#endif return !slice_area_is_free (mm, start, end - start); }
@@ -127,7 +131,8 @@ static void slice_mask_for_free(struct munsigned long i; ret->low_slices =0 ; -bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); +if (SLICE_NUM_HIGH ) +bitmap_zero (ret->high_slices,SLICE_NUM_HIGH );for (i =0 ; i <SLICE_NUM_LOW ; i++)if (!slice_low_has_vma (mm, i))
@@ -149,7 +154,8 @@ static void slice_mask_for_size(struct mu64 lpsizes; ret->low_slices =0 ; -bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); +if (SLICE_NUM_HIGH ) +bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); lpsizes = mm->context.low_slices_psize;for (i =0 ; i <SLICE_NUM_LOW ; i++)
@@ -171,6 +177,10 @@ static int slice_check_fit(struct mm_strDECLARE_BITMAP (result,SLICE_NUM_HIGH );unsigned long slice_count =GET_HIGH_SLICE_INDEX (mm->context.addr_limit); +if (!SLICE_NUM_HIGH ) +return (mask.low_slices & available.low_slices) == + mask.low_slices; +bitmap_and (result, mask.high_slices, available.high_slices, slice_count);
@@ -180,6 +190,7 @@ static int slice_check_fit(struct mm_strstatic void slice_flush_segments (void *parm) { +#ifdef CONFIG_PPC64 struct mm_struct *mm = parm;unsigned long flags;
@@ -191,6 +202,7 @@ static void slice_flush_segments(void *plocal_irq_save (flags);slb_flush_and_rebolt ();local_irq_restore (flags); +#endif }static void slice_convert (struct mm_struct *mm,struct slice_mask mask,int psize)
@@ -380,6 +392,8 @@ static unsigned long slice_find_area(strstatic inline void slice_or_mask (struct slice_mask *dst,struct slice_mask *src) { dst->low_slices |= src->low_slices; +if (!SLICE_NUM_HIGH ) +return ;bitmap_or (dst->high_slices, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); }
@@ -388,6 +402,8 @@ static inline void slice_andnot_mask(str { dst->low_slices &= ~src->low_slices; +if (!SLICE_NUM_HIGH ) +return ;bitmap_andnot (dst->high_slices, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); }
@@ -437,14 +453,17 @@ unsigned long slice_get_unmapped_area(un* init different masks */ mask.low_slices =0 ; -bitmap_zero (mask.high_slices,SLICE_NUM_HIGH );/* silence stupid warning */ ; potential_mask.low_slices =0 ; -bitmap_zero (potential_mask.high_slices,SLICE_NUM_HIGH ); compat_mask.low_slices =0 ; -bitmap_zero (compat_mask.high_slices,SLICE_NUM_HIGH ); + +if (SLICE_NUM_HIGH ) { +bitmap_zero (mask.high_slices,SLICE_NUM_HIGH ); +bitmap_zero (potential_mask.high_slices,SLICE_NUM_HIGH ); +bitmap_zero (compat_mask.high_slices,SLICE_NUM_HIGH ); + }/* Sanity checks */ BUG_ON (mm->task_size ==0 );
@@ -582,7 +601,9 @@ unsigned long slice_get_unmapped_area(un convert:slice_andnot_mask (&mask, &good_mask);slice_andnot_mask (&mask, &compat_mask); -if (mask.low_slices || !bitmap_empty (mask.high_slices,SLICE_NUM_HIGH )) { +if (mask.low_slices || + (SLICE_NUM_HIGH && + !bitmap_empty (mask.high_slices,SLICE_NUM_HIGH ))) {slice_convert (mm, mask, psize);if (psize >MMU_PAGE_BASE )on_each_cpu (slice_flush_segments, mm,1 );
Greg Kroah-Hartman
maintainerPATCH 52/52 powerpc/mm/slice: Fix hugepage allocation at hint address on 8xx
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit aa0ab02ba992eb956934b21373e0138211486ddd upstream.
On the 8xx, the page size is set in the PMD entry and applies to all pages of the page table pointed by the said PMD entry.
When an app has some regular pages allocated (e.g. see below) and tries to mmap() a huge page at a hint address covered by the same PMD entry, the kernel accepts the hint allthough the 8xx cannot handle different page sizes in the same PMD entry.
10000000-10001000 r-xp 00000000 00:0f 2597 /root/malloc 10010000-10011000 rwxp 00000000 00:0f 2597 /root/malloc
mmap(0x10080000, 524288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS|0x40000, -1, 0) = 0x10080000
This results the app remaining forever in do_page_fault()/hugetlb_fault() and when interrupting that app, we get the following warning:
[162980.035629] WARNING: CPU: 0 PID: 2777 at arch/powerpc/mm/hugetlbpage.c:354 hugetlb_free_pgd_range+0xc8/0x1e4 [162980.035699] CPU: 0 PID: 2777 Comm: malloc Tainted: G W 4.14.6 #85 [162980.035744] task: c67e2c00 task.stack: c668e000 [162980.035783] NIP: c000fe18 LR: c00e1eec CTR: c00f90c0 [162980.035830] REGS: c668fc20 TRAP: 0700 Tainted: G W (4.14.6) [162980.035854] MSR: 00029032 <EE,ME,IR,DR,RI> CR: 24044224 XER: 20000000 [162980.036003] [162980.036003] GPR00: c00e1eec c668fcd0 c67e2c00 00000010 c6869410 10080000 00000000 77fb4000 [162980.036003] GPR08: ffff0001 0683c001 00000000 ffffff80 44028228 10018a34 00004008 418004fc [162980.036003] GPR16: c668e000 00040100 c668e000 c06c0000 c668fe78 c668e000 c6835ba0 c668fd48 [162980.036003] GPR24: 00000000 73ffffff 74000000 00000001 77fb4000 100fffff 10100000 10100000 [162980.036743] NIP [c000fe18] hugetlb_free_pgd_range+0xc8/0x1e4 [162980.036839] LR [c00e1eec] free_pgtables+0x12c/0x150 [162980.036861] Call Trace: [162980.036939] [c668fcd0] [c00f0774] unlink_anon_vmas+0x1c4/0x214 (unreliable) [162980.037040] [c668fd10] [c00e1eec] free_pgtables+0x12c/0x150 [162980.037118] [c668fd40] [c00eabac] exit_mmap+0xe8/0x1b4 [162980.037210] [c668fda0] [c0019710] mmput.part.9+0x20/0xd8 [162980.037301] [c668fdb0] [c001ecb0] do_exit+0x1f0/0x93c [162980.037386] [c668fe00] [c001f478] do_group_exit+0x40/0xcc [162980.037479] [c668fe10] [c002a76c] get_signal+0x47c/0x614 [162980.037570] [c668fe70] [c0007840] do_signal+0x54/0x244 [162980.037654] [c668ff30] [c0007ae8] do_notify_resume+0x34/0x88 [162980.037744] [c668ff40] [c000dae8] do_user_signal+0x74/0xc4 [162980.037781] Instruction dump: [162980.037821] 7fdff378 81370000 54a3463a 80890020 7d24182e 7c841a14 712a0004 4082ff94 [162980.038014] 2f890000 419e0010 712a0ff0 408200e0 <0fe00000> 54a9000a 7f984840 419d0094 [162980.038216] ---[ end trace c0ceeca8e7a5800a ]--- [162980.038754] BUG: non-zero nr_ptes on freeing mm: 1 [162985.363322] BUG: non-zero nr_ptes on freeing mm: -1
In order to fix this, this patch uses the address space "slices" implemented for BOOK3S/64 and enhanced to support PPC32 by the preceding patch.
This patch modifies the context.id on the 8xx to be in the range [1:16] instead of [0:15] in order to identify context.id == 0 as not initialised contexts as done on BOOK3S
This patch activates CONFIG_PPC_MM_SLICES when CONFIG_HUGETLB_PAGE is selected for the 8xx
Alltough we could in theory have as many slices as PMD entries, the current slices implementation limits the number of low slices to 16. This limitation is not preventing us to fix the initial issue allthough it is suboptimal. It will be cured in a subsequent patch.
--- arch/powerpc/include/asm/mmu-8xx.h | 6 ++++++ arch/powerpc/kernel/setup-common.c | 2 ++ arch/powerpc/mm/8xx_mmu.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 ++ arch/powerpc/mm/mmu_context_nohash.c | 18 ++++++++++++++++-- arch/powerpc/platforms/Kconfig.cputype | 1 + 6 files changed, 28 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/mmu-8xx.h +6 -0
@@ -169,6 +169,12 @@ typedef struct {unsigned int id;unsigned int active;unsigned long vdso_base; +#ifdef CONFIG_PPC_MM_SLICES +u16 user_psize;/* page size index */ +u64 low_slices_psize;/* page size encodings */ +unsigned char high_slices_psize[0 ]; +unsigned long addr_limit; +#endif } mm_context_t;#define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000)
arch/powerpc/kernel/setup-common.c +2 -0
@@ -915,6 +915,8 @@ void __init setup_arch(char **cmdline_p)#ifdef CONFIG_PPC_MM_SLICES #ifdef CONFIG_PPC64 init_mm.context.addr_limit =DEFAULT_MAP_WINDOW_USER64 ; +#elif defined(CONFIG_PPC_8xx) + init_mm.context.addr_limit =DEFAULT_MAP_WINDOW ;#else #error "context.addr_limit not initialized."#endif
arch/powerpc/mm/8xx_mmu.c +1 -1
@@ -192,7 +192,7 @@ void set_context(unsigned long id, pgd_tmtspr (SPRN_M_TW ,__pa (pgd) - offset);/* Update context */ -mtspr (SPRN_M_CASID , id); +mtspr (SPRN_M_CASID , id -1 );/* sync */ mb (); }
arch/powerpc/mm/hugetlbpage.c +2 -0
@@ -552,9 +552,11 @@ unsigned long hugetlb_get_unmapped_area(struct hstate *hstate =hstate_file (file);int mmu_psize =shift_to_mmu_psize (huge_page_shift (hstate)); +#ifdef CONFIG_PPC_RADIX_MMU if (radix_enabled ())return radix__hugetlb_get_unmapped_area (file, addr, len, pgoff, flags); +#endif return slice_get_unmapped_area(addr, len, flags, mmu_psize, 1); }#endif
arch/powerpc/mm/mmu_context_nohash.c +16 -2
@@ -331,6 +331,20 @@ int init_new_context(struct task_struct {pr_hard ("initing context for mm @%p\n" , mm); +#ifdef CONFIG_PPC_MM_SLICES +if (!mm->context.addr_limit) + mm->context.addr_limit =DEFAULT_MAP_WINDOW ; + +/* +* We have MMU_NO_CONTEXT set to be ~0. Hence check +* explicitly against context.id == 0. This ensures that we properly +* initialize context slice details for newly allocated mm's (which will +* have id == 0) and don't alter context slice inherited via fork (which +* will have id != 0). +*/ +if (mm->context.id ==0 ) +slice_set_user_psize (mm, mmu_virtual_psize); +#endif mm->context.id =MMU_NO_CONTEXT ; mm->context.active =0 ;return 0 ;
@@ -428,8 +442,8 @@ void __init mmu_context_init(void)* -- BenH */ if (mmu_has_feature (MMU_FTR_TYPE_8xx)) { - first_context =0 ; - last_context =15 ; + first_context =1 ; + last_context =16 ; no_selective_tlbil = true; }else if (mmu_has_feature (MMU_FTR_TYPE_47x)) { first_context =1 ;
arch/powerpc/platforms/Kconfig.cputype +1 -0
@@ -325,6 +325,7 @@ config PPC_BOOK3E_MMU config PPC_MM_SLICES bool default y if PPC_STD_MMU_64 + default y if PPC_8xx && HUGETLB_PAGE default n config PPC_HAVE_PMU_SUPPORT
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.48 release. There are 52 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 Wed Jun 6 06:55:52 UTC 2018. Anything received after that time might be too late.
Build results:
total: 139 pass: 139 fail: 0 Qemu test results: total: 143 pass: 143 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.48 release. There are 52 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 Wed Jun 6 06:55:52 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.48-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.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 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.48 release. There are 52 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 Wed Jun 6 06:55:52 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.48-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm and x86_64.
NOTE: Short summary report generator will resume soon. This time we are using old and long report.
Summary
------------------------------------------------------------------------
kernel: 4.14.48-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.14.y
git commit: 721adf61fde28b9a87a95e45ecf3f5a325e7c76f
git describe: v4.14.47-53-g721adf61fde2
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.14-oe/build/v4.14.47-53-g721adf61fde2
No regressions (compared to build v4.14.47)
Boards, architectures and test suites:
-------------------------------------
hi6220-hikey - arm64
* boot - pass: 21,
* kselftest - skip: 23, pass: 43, fail: 1
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 17, pass: 64,
* ltp-cve-tests - skip: 8, pass: 25, fail: 2
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - skip: 6, pass: 60,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - skip: 1, pass: 21,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 4, pass: 10,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 133, pass: 1013, fail: 3
* ltp-timers-tests - pass: 13,
juno-r2 - arm64
* boot - pass: 9,
* kselftest - skip: 25, pass: 42, fail: 1
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 17, pass: 64,
* ltp-cve-tests - skip: 8, pass: 24, fail: 3
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
qemu_arm
* boot - pass: 21,
* kselftest - skip: 29, pass: 36, fail: 3
* libhugetlbfs - skip: 1, pass: 87,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 18, pass: 63,
* ltp-cve-tests - skip: 8, pass: 22, fail: 5
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - skip: 5, pass: 61,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - skip: 1, pass: 21,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 7, pass: 7,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 93, pass: 1053, fail: 3
* ltp-timers-tests - pass: 13,
qemu_arm64
* boot - pass: 21,
* kselftest - skip: 29, pass: 40, fail: 1
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 17, pass: 64,
* ltp-cve-tests - skip: 8, pass: 23, fail: 4
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - skip: 6, pass: 60,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - pass: 22,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 6, pass: 8,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 154, pass: 991, fail: 4
* ltp-timers-tests - pass: 13,
qemu_x86_64
* boot - pass: 21,
* kselftest - skip: 29, pass: 52, fail: 1
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 17, pass: 64,
* ltp-cve-tests - skip: 3, pass: 29, fail: 3
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - skip: 6, pass: 60,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - pass: 22,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 1, pass: 13,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 153, pass: 994, fail: 2
* ltp-timers-tests - pass: 13,
x15 - arm
* boot - pass: 19,
* kselftest - skip: 26, pass: 38, fail: 3
* libhugetlbfs - skip: 1, pass: 87,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 18, pass: 63,
* ltp-cve-tests - skip: 8, pass: 24, fail: 3
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-fs-tests - skip: 5, pass: 61,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - skip: 2, pass: 20,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 1, pass: 13,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 76, pass: 1073,
* ltp-timers-tests - pass: 13,
x86_64
* boot - pass: 23,
* kselftest - skip: 24, pass: 54, fail: 1
* kselftest-vsyscall-mode-native - skip: 24, pass: 52, fail: 2
* kselftest-vsyscall-mode-none - skip: 21, pass: 55, fail: 1
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 17, pass: 64,
* ltp-cve-tests - skip: 3, pass: 29, fail: 3
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - skip: 5, pass: 61,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - pass: 22,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 5, pass: 9,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 116, pass: 1031, fail: 2
* ltp-timers-tests - pass: 13,
Signature · 2 lines
Linaro QA (BETA) https://qa-reports.linaro.org
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Greg Kroah-Hartman
maintainerQuoted 20 lines · Kevin Hilman
Quoted 18 lines · kernelci.org bot
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.14.y/kernel/v4.14.47-53-g721adf61fde2/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.14.y/kernel/v4.14.47-53-g721adf61fde2/Tree: stable-rc
Branch: linux-4.14.y
Git Describe: v4.14.47-53-g721adf61fde2
Git Commit:721adf61fde28b9a87a95e45ecf3f5a325e7c76f
Git URL: http://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 56 unique boards, 23 SoC families, 14 builds out of 185Boot Regressions Detected:
arm64:
defconfig: meson-gxl-s905x-khadas-vim: lab-baylibre: failing since 39 days (last pass: v4.14.26-140-g2a1700a4929f - first fail: v4.14.36-184-g3cd53e436ee2)
Quoted 7 lines
Quoted 1 line
Conflicting Boot Failure Detected: (These likely are not failures as other labs are reporting PASS. Needs review.)
TL;DR; All is well.
The failing board is having a power supply issue and has been taken offline for repair. Since the same board is passing fine in another lab, it can be ignored.
Thanks for the updates on this, and the 4.9 board breakage.
greg k-h