iio: adc: meson_saradc: Fix memory allocation order
Subsystems (24)
Sasha Levin
maintainerPATCH 1/89 iio: adc: meson_saradc: Fix memory allocation order
From: Remi Pommarel <[email protected]>
[ Upstream commit de10ac47597e7a3596b27631d0d5ce5f48d2c099 ]
meson_saradc's irq handler uses priv->regmap so make sure that it is allocated before the irq get enabled.
This also fixes crash when CONFIG_DEBUG_SHIRQ is enabled, as device managed resources are freed in the inverted order they had been allocated, priv->regmap was freed before the spurious fake irq that CONFIG_DEBUG_SHIRQ adds called the handler.
--- drivers/iio/adc/meson_saradc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/adc/meson_saradc.c +5 -5
@@ -1219,6 +1219,11 @@ static int meson_sar_adc_probe(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); + priv->regmap =devm_regmap_init_mmio (&pdev->dev, base, + priv->param->regmap_config); +if (IS_ERR (priv->regmap)) +return PTR_ERR (priv->regmap); + irq =irq_of_parse_and_map (pdev->dev.of_node,0 );if (!irq)return -EINVAL ;
@@ -1228,11 +1233,6 @@ static int meson_sar_adc_probe(struct platform_device *pdev)if (ret)return ret; - priv->regmap =devm_regmap_init_mmio (&pdev->dev, base, - priv->param->regmap_config); -if (IS_ERR (priv->regmap)) -return PTR_ERR (priv->regmap); - priv->clkin =devm_clk_get (&pdev->dev,"clkin" );if (IS_ERR (priv->clkin)) {dev_err (&pdev->dev,"failed to get clkin\n" );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/89 iio: fix center temperature of bmc150-accel-core
From: Pascal Bouwmann <[email protected]>
[ Upstream commit 6c59a962e081df6d8fe43325bbfabec57e0d4751 ]
The center temperature of the supported devices stored in the constant BMC150_ACCEL_TEMP_CENTER_VAL is not 24 degrees but 23 degrees.
It seems that some datasheets were inconsistent on this value leading to the error. For most usecases will only make minor difference so not queued for stable.
--- drivers/iio/accel/bmc150-accel-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/bmc150-accel-core.c +1 -1
@@ -117,7 +117,7 @@#define BMC150_ACCEL_SLEEP_1_SEC 0x0F#define BMC150_ACCEL_REG_TEMP 0x08 -#define BMC150_ACCEL_TEMP_CENTER_VAL 24 +#define BMC150_ACCEL_TEMP_CENTER_VAL 23#define BMC150_ACCEL_AXIS_TO_REG (axis) (BMC150_ACCEL_REG_XOUT_L + (axis * 2))#define BMC150_AUTO_SUSPEND_DELAY_MS 2000
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/89 libsubcmd: Make _FORTIFY_SOURCE defines dependent on the feature
In reply to Sasha LevinFrom: Ian Rogers <[email protected]>
[ Upstream commit 4b0b2b096da9d296e0e5668cdfba8613bd6f5bc8 ]
Unconditionally defining _FORTIFY_SOURCE can break tools that don't work with it, such as memory sanitizers:
https://github.com/google/sanitizers/wiki/AddressSanitizer#faq
--- tools/lib/subcmd/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/lib/subcmd/Makefile +7 -1
@@ -20,7 +20,13 @@ MAKEFLAGS += --no-print-directory LIBFILE = $(OUTPUT)libsubcmd.a CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC +CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -fPIC + +ifeq ($(DEBUG),0) + ifeq ($(feature-fortify-source), 1) + CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 + endif +endif ifeq ($(CC_NO_CLANG), 0) CFLAGS += -O3
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/89 perf tests: Avoid raising SEGV using an obvious NULL dereference
In reply to Sasha LevinFrom: Ian Rogers <[email protected]>
[ Upstream commit e3e2cf3d5b1fe800b032e14c0fdcd9a6fb20cf3b ]
An optimized build such as:
make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-O3
will turn the dereference operation into a ud2 instruction, raising a SIGILL rather than a SIGSEGV. Use raise(..) for correctness and clarity.
Similar issues were addressed in Numfor Mbiziwo-Tiapo's patch:
https://lkml.org/lkml/2019/7/8/1234
Committer testing:
Before:
[root@quaco ~]# perf test hooks
55: perf hooks : Ok
[root@quaco ~]# perf test -v hooks
55: perf hooks :
--- start ---
test child forked, pid 17092
SIGSEGV is observed as expected, try to recover. Fatal error (SEGFAULT) in perf hook 'test' test child finished with 0
---- end ----
perf hooks: Ok
[root@quaco ~]#
After:
[root@quaco ~]# perf test hooks
55: perf hooks : Ok
[root@quaco ~]# perf test -v hooks
55: perf hooks :
--- start ---
test child forked, pid 17909
SIGSEGV is observed as expected, try to recover. Fatal error (SEGFAULT) in perf hook 'test' test child finished with 0
---- end ----
perf hooks: Ok
[root@quaco ~]#
--- tools/perf/tests/perf-hooks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/tests/perf-hooks.c +1 -2
@@ -20,12 +20,11 @@ static void sigsegv_handler(int sig __maybe_unused)static void the_hook (void *_hook_flags) {int *hook_flags = _hook_flags; -int *p =NULL ; *hook_flags =1234 ;/* Generate a segfault, test perf_hooks__recover */ - *p =0 ; +raise (SIGSEGV ); }int test__perf_hooks (struct test *test__maybe_unused ,int subtest__maybe_unused )
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/89 perf map: Fix overlapped map handling
In reply to Sasha LevinFrom: Steve MacLean <[email protected]>
[ Upstream commit ee212d6ea20887c0ef352be8563ca13dbf965906 ]
Whenever an mmap/mmap2 event occurs, the map tree must be updated to add a new entry. If a new map overlaps a previous map, the overlapped section of the previous map is effectively unmapped, but the non-overlapping sections are still valid.
maps__fixup_overlappings() is responsible for creating any new map entries from the previously overlapped map. It optionally creates a before and an after map.
When creating the after map the existing code failed to adjust the map.pgoff. This meant the new after map would incorrectly calculate the file offset for the ip. This results in incorrect symbol name resolution for any ip in the after region.
Make maps__fixup_overlappings() correctly populate map.pgoff.
Add an assert that new mapping matches old mapping at the beginning of the after map.
Committer-testing:
Validated correct parsing of libcoreclr.so symbols from .NET Core 3.0 preview9 (which didn't strip symbols).
Preparation:
~/dotnet3.0-preview9/dotnet new webapi -o perfSymbol
cd perfSymbol
~/dotnet3.0-preview9/dotnet publish
perf record ~/dotnet3.0-preview9/dotnet \
bin/Debug/netcoreapp3.0/publish/perfSymbol.dll
^CBefore:
perf script --show-mmap-events 2>&1 | grep -e MMAP -e unknown |\
grep libcoreclr.so | head -n 4
dotnet 1907 373352.698780: PERF_RECORD_MMAP2 1907/1907: \
[0x7fe615726000(0x768000) @ 0 08:02 5510620 765057155]: \
r-xp .../3.0.0-preview9-19423-09/libcoreclr.so
dotnet 1907 373352.701091: PERF_RECORD_MMAP2 1907/1907: \
[0x7fe615974000(0x1000) @ 0x24e000 08:02 5510620 765057155]: \
rwxp .../3.0.0-preview9-19423-09/libcoreclr.so
dotnet 1907 373352.701241: PERF_RECORD_MMAP2 1907/1907: \
[0x7fe615c42000(0x1000) @ 0x51c000 08:02 5510620 765057155]: \
rwxp .../3.0.0-preview9-19423-09/libcoreclr.so
dotnet 1907 373352.705249: 250000 cpu-clock: \
7fe6159a1f99 [unknown] \
(.../3.0.0-preview9-19423-09/libcoreclr.so)After:
perf script --show-mmap-events 2>&1 | grep -e MMAP -e unknown |\
grep libcoreclr.so | head -n 4
dotnet 1907 373352.698780: PERF_RECORD_MMAP2 1907/1907: \
[0x7fe615726000(0x768000) @ 0 08:02 5510620 765057155]: \
r-xp .../3.0.0-preview9-19423-09/libcoreclr.so
dotnet 1907 373352.701091: PERF_RECORD_MMAP2 1907/1907: \
[0x7fe615974000(0x1000) @ 0x24e000 08:02 5510620 765057155]: \
rwxp .../3.0.0-preview9-19423-09/libcoreclr.so
dotnet 1907 373352.701241: PERF_RECORD_MMAP2 1907/1907: \
[0x7fe615c42000(0x1000) @ 0x51c000 08:02 5510620 765057155]: \
rwxp .../3.0.0-preview9-19423-09/libcoreclr.soAll the [unknown] symbols were resolved.
--- tools/perf/util/map.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/map.c +3 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include "symbol.h" +#include <assert.h> #include <errno.h> #include <inttypes.h> #include <limits.h>
@@ -847,6 +848,8 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp } after->start = map->end; + after->pgoff += map->end - pos->start; +assert (pos->map_ip (pos, map->end) == after->map_ip (after, map->end));__map_groups__insert (pos->groups, after);if (verbose >=2 && !use_browser)map__fprintf (after, fp);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/89 perf script brstackinsn: Fix recovery from LBR/binary mismatch
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
[ Upstream commit e98df280bc2a499fd41d7f9e2d6733884de69902 ]
When the LBR data and the instructions in a binary do not match the loop printing instructions could get confused and print a long stream of bogus <bad> instructions.
The problem was that if the instruction decoder cannot decode an instruction it ilen wasn't initialized, so the loop going through the basic block would continue with the previous value.
Harden the code to avoid such problems:
- Make sure ilen is always freshly initialized and is 0 for bad instructions.
- Do not overrun the code buffer while printing instructions
- Print a warning message if the final jump is not on an instruction boundary.
--- tools/perf/builtin-script.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-script.c +5 -1
@@ -1054,7 +1054,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,continue ; insn =0 ; -for (off =0 ;; off += ilen) { +for (off =0 ; off < (unsigned )len; off += ilen) {uint64_t ip = start + off; printed +=ip__fprintf_sym (ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp);
@@ -1065,6 +1065,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, printed +=print_srccode (thread, x.cpumode, ip);break ; }else { + ilen =0 ; printed +=fprintf (fp,"\t%016" PRIx64"\t%s\n" , ip,dump_insn (&x, ip, buffer + off, len - off, &ilen));if (ilen ==0 )
@@ -1074,6 +1075,8 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, insn++; } } +if (off != (unsigned )len) + printed +=fprintf (fp,"\tmismatch of LBR data and executable\n" ); }/*
@@ -1114,6 +1117,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, goto out; }for (off =0 ; off <= end - start; off += ilen) { + ilen =0 ; printed +=fprintf (fp,"\t%016" PRIx64"\t%s\n" , start + off,dump_insn (&x, start + off, buffer + off, len - off, &ilen));if (ilen ==0 )
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/89 perf jevents: Fix period for Intel fixed counters
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
[ Upstream commit 6bdfd9f118bd59cf0f85d3bf4b72b586adea17c1 ]
The Intel fixed counters use a special table to override the JSON information.
During this override the period information from the JSON file got dropped, which results in inst_retired.any and similar running with frequency mode instead of a period.
Just specify the expected period in the table.
--- tools/perf/pmu-events/jevents.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/pmu-events/jevents.c +6 -6
@@ -449,12 +449,12 @@ static struct fixed {const char *name;const char *event; } fixed[] = { - { "inst_retired.any", "event=0xc0" }, - { "inst_retired.any_p", "event=0xc0" }, - { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" }, - { "cpu_clk_unhalted.thread", "event=0x3c" }, - { "cpu_clk_unhalted.core", "event=0x3c" }, - { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" }, + { "inst_retired.any", "event=0xc0,period=2000003" }, + { "inst_retired.any_p", "event=0xc0,period=2000003" }, + { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03,period=2000003" }, + { "cpu_clk_unhalted.thread", "event=0x3c,period=2000003" }, + { "cpu_clk_unhalted.core", "event=0x3c,period=2000003" }, + { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1,period=2000003" }, { NULL, NULL}, };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/89 perf tools: Propagate get_cpuid() error
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit f67001a4a08eb124197ed4376941e1da9cf94b42 ]
For consistency, propagate the exact cause for get_cpuid() to have failed.
--- tools/perf/arch/powerpc/util/header.c | 3 ++- tools/perf/arch/s390/util/header.c | 9 +++++---- tools/perf/arch/x86/util/header.c | 3 ++- tools/perf/builtin-kvm.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-)
tools/perf/arch/powerpc/util/header.c +2 -1
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <sys/types.h> +#include <errno.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h>
@@ -31,7 +32,7 @@ get_cpuid(char *buffer, size_t sz) buffer[nb-1 ] ='\0' ;return 0 ; } -return -1 ; +return ENOBUFS ; } char *
tools/perf/arch/s390/util/header.c +5 -4
@@ -8,6 +8,7 @@*/ #include <sys/types.h> +#include <errno.h> #include <unistd.h> #include <stdio.h> #include <string.h>
@@ -54,7 +55,7 @@ int get_cpuid(char *buffer, size_t sz) sysinfo =fopen (SYSINFO ,"r" );if (sysinfo ==NULL ) -return -1 ; +return errno;while ((read =getline (&line, &line_sz, sysinfo)) !=-1 ) {if (!strncmp (line,SYSINFO_MANU ,strlen (SYSINFO_MANU ))) {
@@ -89,7 +90,7 @@ int get_cpuid(char *buffer, size_t sz)/* Missing manufacturer, type or model information should not happen */ if (!manufacturer[0 ] || !type[0 ] || !model[0 ]) -return -1 ; +return EINVAL ;/* * Scan /proc/service_levels and return the CPU-MF counter facility
@@ -133,14 +134,14 @@ int get_cpuid(char *buffer, size_t sz)else nbytes =snprintf (buffer, sz,"%s,%s,%s" , manufacturer, type, model); -return (nbytes >= sz) ?-1 :0 ; +return (nbytes >= sz) ?ENOBUFS :0 ; }char *get_cpuid_str (struct perf_pmu *pmu__maybe_unused ) {char *buf =malloc (128 ); -if (buf &&get_cpuid (buf,128 ) <0 ) +if (buf &&get_cpuid (buf,128 ))zfree (&buf);return buf; }
tools/perf/arch/x86/util/header.c +2 -1
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <sys/types.h> +#include <errno.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h>
@@ -57,7 +58,7 @@ __get_cpuid(char *buffer, size_t sz, const char *fmt) buffer[nb-1 ] ='\0' ;return 0 ; } -return -1 ; +return ENOBUFS ; }int
tools/perf/builtin-kvm.c +4 -3
@@ -699,14 +699,15 @@ static int process_sample_event(struct perf_tool *tool,static int cpu_isa_config (struct perf_kvm_stat *kvm) { -char buf[64 ], *cpuid; +char buf[128 ], *cpuid;int err;if (kvm->live) { err =get_cpuid (buf,sizeof (buf));if (err !=0 ) { -pr_err ("Failed to look up CPU type\n" ); -return err; +pr_err ("Failed to look up CPU type: %s\n" , +str_error_r (err, buf,sizeof (buf))); +return -err; } cpuid = buf; }else
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/89 perf annotate: Propagate perf_env__arch() error
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit a66fa0619a0ae3585ef09e9c33ecfb5c7c6cb72b ]
The callers of symbol__annotate2() use symbol__strerror_disassemble() to convert its failure returns into a human readable string, so propagate error values from functions it calls, starting with perf_env__arch() that when fails the right thing to do is to look at 'errno' to see why its possible call to uname() failed.
--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
@@ -2065,7 +2065,7 @@ int symbol__annotate(struct symbol *sym, struct map *map,int err;if (!arch_name) -return -1 ; +return errno; args.arch = arch =arch__find (arch_name);if (arch ==NULL )
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/89 perf annotate: Fix the signedness of failure returns
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 28f4417c3333940b242af03d90214f713bbef232 ]
Callers of symbol__annotate() expect a errno value or some other extended error value range in symbol__strerror_disassemble() to convert to a proper error string, fix it when propagating a failure to find the arch specific annotation routines via arch__find(arch_name).
--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
@@ -2069,7 +2069,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, args.arch = arch =arch__find (arch_name);if (arch ==NULL ) -return -ENOTSUP ; +return ENOTSUP ;if (parch) *parch = arch;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/89 perf annotate: Propagate the symbol__annotate() error return
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 211f493b611eef012841f795166c38ec7528738d ]
We were just returning -1 in symbol__annotate() when symbol__annotate() failed, propagate its error as it is used later to pass to symbol__strerror_disassemble() to present a error message to the user, that in some cases were getting:
"Invalid -1 error code"
Fix it to propagate the error.
--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
@@ -2991,7 +2991,7 @@ int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *ev out_free_offsets:zfree (¬es->offsets); -return -1 ; +return err; }#define ANNOTATION__CFG (n) \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/89 perf annotate: Fix arch specific ->init() failure errors
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 42d7a9107d83223a5fcecc6732d626a6c074cbc2 ]
They are called from symbol__annotate() and to propagate errors that can help understand the problem make them return what symbol__strerror_disassemble() known, i.e. errno codes and other annotation specific errors in a special, out of errnos, range.
--- tools/perf/arch/arm/annotate/instructions.c | 4 ++-- tools/perf/arch/arm64/annotate/instructions.c | 4 ++-- tools/perf/arch/s390/annotate/instructions.c | 6 ++++-- tools/perf/arch/x86/annotate/instructions.c | 6 ++++-- tools/perf/util/annotate.c | 6 ++++++ tools/perf/util/annotate.h | 2 ++ 6 files changed, 20 insertions(+), 8 deletions(-)
tools/perf/arch/arm/annotate/instructions.c +2 -2
@@ -36,7 +36,7 @@ static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused) arm =zalloc (sizeof (*arm));if (!arm) -return -1 ; +return ENOMEM ;#define ARM_CONDS "(cc|cs|eq|ge|gt|hi|le|ls|lt|mi|ne|pl|vc|vs)" err =regcomp (&arm->call_insn,"^blx?" ARM_CONDS "?$" ,REG_EXTENDED );
@@ -58,5 +58,5 @@ static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused)regfree (&arm->call_insn); out_free_arm:free (arm); -return -1 ; +return SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP ; }
tools/perf/arch/arm64/annotate/instructions.c +2 -2
@@ -94,7 +94,7 @@ static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused) arm =zalloc (sizeof (*arm));if (!arm) -return -1 ; +return ENOMEM ;/* bl, blr */ err =regcomp (&arm->call_insn,"^blr?$" ,REG_EXTENDED );
@@ -117,5 +117,5 @@ static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused)regfree (&arm->call_insn); out_free_arm:free (arm); -return -1 ; +return SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP ; }
tools/perf/arch/s390/annotate/instructions.c +4 -2
@@ -164,8 +164,10 @@ static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused)if (!arch->initialized) { arch->initialized = true; arch->associate_instruction_ops = s390__associate_ins_ops; -if (cpuid) - err =s390__cpuid_parse (arch, cpuid); +if (cpuid) { +if (s390__cpuid_parse (arch, cpuid)) + err =SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING ; + } }return err;
tools/perf/arch/x86/annotate/instructions.c +4 -2
@@ -196,8 +196,10 @@ static int x86__annotate_init(struct arch *arch, char *cpuid)if (arch->initialized)return 0 ; -if (cpuid) - err =x86__cpuid_parse (arch, cpuid); +if (cpuid) { +if (x86__cpuid_parse (arch, cpuid)) + err =SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING ; + } arch->initialized = true;return err;
tools/perf/util/annotate.c +6 -0
@@ -1625,6 +1625,12 @@ int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map *case SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF :scnprintf (buf, buflen,"Please link with binutils's libopcode to enable BPF annotation" );break ; +case SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP : +scnprintf (buf, buflen,"Problems with arch specific instruction name regular expressions." ); +break ; +case SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING : +scnprintf (buf, buflen,"Problems while parsing the CPUID in the arch specific initialization." ); +break ;default :scnprintf (buf, buflen,"Internal error: Invalid %d error code\n" , errnum);break ;
tools/perf/util/annotate.h +2 -0
@@ -370,6 +370,8 @@ enum symbol_disassemble_errno {SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX = __SYMBOL_ANNOTATE_ERRNO__START,SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF , +SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING , +SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP , __SYMBOL_ANNOTATE_ERRNO__END, };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 13/89 perf annotate: Return appropriate error code for allocation failures
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 16ed3c1e91159e28b02f11f71ff4ce4cbc6f99e4 ]
We should return errno or the annotation extra range understood by symbol__strerror_disassemble() instead of -1, fix it, returning ENOMEM instead.
--- tools/perf/util/annotate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/annotate.c +2 -2
@@ -1662,7 +1662,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil build_id_path =strdup (filename);if (!build_id_path) -return -1 ; +return ENOMEM ;/* * old style build-id cache has name of XX/XXXXXXX.. while
@@ -2971,7 +2971,7 @@ int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *ev notes->offsets =zalloc (size *sizeof (struct annotation_line *));if (notes->offsets ==NULL ) -return -1 ; +return ENOMEM ;if (perf_evsel__is_group_event (evsel)) nr_pcnt = evsel->nr_members;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 14/89 perf annotate: Don't return -1 for error when doing BPF disassembly
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 11aad897f6d1a28eae3b7e5b293647c522d65819 ]
Return errno when open_memstream() fails and add two new speciall error codes for when an invalid, non BPF file or one without BTF is passed to symbol__disassemble_bpf(), so that its callers can rely on symbol__strerror_disassemble() to convert that to a human readable error message that can help figure out what is wrong, with hints even.
--- tools/perf/util/annotate.c | 19 +++++++++++++++---- tools/perf/util/annotate.h | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-)
tools/perf/util/annotate.c +15 -4
@@ -1631,6 +1631,13 @@ int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map *case SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING :scnprintf (buf, buflen,"Problems while parsing the CPUID in the arch specific initialization." );break ; +case SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_FILE : +scnprintf (buf, buflen,"Invalid BPF file: %s." , dso->long_name); +break ; +case SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF : +scnprintf (buf, buflen,"The %s BPF file has no BTF section, compile with -g or use pahole -J." , + dso->long_name); +break ;default :scnprintf (buf, buflen,"Internal error: Invalid %d error code\n" , errnum);break ;
@@ -1713,13 +1720,13 @@ static int symbol__disassemble_bpf(struct symbol *sym,char tpath[PATH_MAX ];size_t buf_size;int nr_skip =0 ; -int ret =-1 ;char *buf;bfd *bfdf; +int ret;FILE *s;if (dso->binary_type !=DSO_BINARY_TYPE__BPF_PROG_INFO ) -return -1 ; +return SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_FILE ;pr_debug ("%s: handling sym %s addr %" PRIx64" len %" PRIx64"\n" , __func__, sym->name, sym->start, sym->end - sym->start);
@@ -1732,8 +1739,10 @@ static int symbol__disassemble_bpf(struct symbol *sym,assert (bfd_check_format (bfdf, bfd_object)); s =open_memstream (&buf, &buf_size); -if (!s) +if (!s) { + ret = errno; goto out; + }init_disassemble_info (&info, s, (fprintf_ftype ) fprintf);
@@ -1742,8 +1751,10 @@ static int symbol__disassemble_bpf(struct symbol *sym, info_node =perf_env__find_bpf_prog_info (dso->bpf_prog.env, dso->bpf_prog.id); -if (!info_node) +if (!info_node) { +return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF ; goto out; + } info_linear = info_node->info_linear; sub_id = dso->bpf_prog.sub_id;
tools/perf/util/annotate.h +2 -0
@@ -372,6 +372,8 @@ enum symbol_disassemble_errno {SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF ,SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING ,SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP , +SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_FILE , +SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF , __SYMBOL_ANNOTATE_ERRNO__END, };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 15/89 staging: rtl8188eu: fix null dereference when kzalloc fails
In reply to Sasha LevinFrom: Connor Kuehl <[email protected]>
[ Upstream commit 955c1532a34305f2f780b47f0c40cc7c65500810 ]
If kzalloc() returns NULL, the error path doesn't stop the flow of control from entering rtw_hal_read_chip_version() which dereferences the null pointer. Fix this by adding a 'goto' to the error path to more gracefully handle the issue and avoid proceeding with initialization steps that we're no longer prepared to handle.
Also update the debug message to be more consistent with the other debug messages in this function.
Addresses-Coverity: ("Dereference after null check")
--- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/os_dep/usb_intf.c +4 -2
@@ -348,8 +348,10 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, } padapter->HalData =kzalloc (sizeof (struct hal_data_8188e ),GFP_KERNEL ); -if (!padapter->HalData) -DBG_88E ("cant not alloc memory for HAL DATA\n" ); +if (!padapter->HalData) { +DBG_88E ("Failed to allocate memory for HAL data\n" ); + goto free_adapter; + }/* step read_chip_version */ rtw_hal_read_chip_version (padapter);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 16/89 crypto: arm/aes-ce - add dependency on AES library
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit f703964fc66804e6049f2670fc11045aa8359b1a ]
The ARM accelerated AES driver depends on the new AES library for its non-SIMD fallback so express this in its Kconfig declaration.
--- arch/arm/crypto/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/crypto/Kconfig +1 -0
@@ -98,6 +98,7 @@ config CRYPTO_AES_ARM_CE tristate "Accelerated AES using ARMv8 Crypto Extensions" depends on KERNEL_MODE_NEON select CRYPTO_BLKCIPHER + select CRYPTO_LIB_AES select CRYPTO_SIMD help Use an implementation of AES in CBC, CTR and XTS modes that uses
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 17/89 RDMA/siw: Fix serialization issue in write_space()
In reply to Sasha LevinFrom: Krishnamraju Eraparaju <[email protected]>
[ Upstream commit df791c54d627bae53c9be3be40a69594c55de487 ]
In siw_qp_llp_write_space(), 'sock' members should be accessed with sk_callback_lock held, otherwise, it could race with siw_sk_restore_upcalls(). And this could cause "NULL deref" panic. Below panic is due to the NULL cep returned from sk_to_cep(sk):
Call Trace: <IRQ> siw_qp_llp_write_space+0x11/0x40 [siw] tcp_check_space+0x4c/0xf0 tcp_rcv_established+0x52b/0x630 tcp_v4_do_rcv+0xf4/0x1e0 tcp_v4_rcv+0x9b8/0xab0 ip_protocol_deliver_rcu+0x2c/0x1c0 ip_local_deliver_finish+0x44/0x50 ip_local_deliver+0x6b/0xf0 ? ip_protocol_deliver_rcu+0x1c0/0x1c0 ip_rcv+0x52/0xd0 ? ip_rcv_finish_core.isra.14+0x390/0x390 __netif_receive_skb_one_core+0x83/0xa0 netif_receive_skb_internal+0x73/0xb0 napi_gro_frags+0x1ff/0x2b0 t4_ethrx_handler+0x4a7/0x740 [cxgb4] process_responses+0x2c9/0x590 [cxgb4] ? t4_sge_intr_msix+0x1d/0x30 [cxgb4] ? handle_irq_event_percpu+0x51/0x70 ? handle_irq_event+0x41/0x60 ? handle_edge_irq+0x97/0x1a0 napi_rx_handler+0x14/0xe0 [cxgb4] net_rx_action+0x2af/0x410 __do_softirq+0xda/0x2a8 do_softirq_own_stack+0x2a/0x40 </IRQ> do_softirq+0x50/0x60 __local_bh_enable_ip+0x50/0x60 ip_finish_output2+0x18f/0x520 ip_output+0x6e/0xf0 ? __ip_finish_output+0x1f0/0x1f0 __ip_queue_xmit+0x14f/0x3d0 ? __slab_alloc+0x4b/0x58 __tcp_transmit_skb+0x57d/0xa60 tcp_write_xmit+0x23b/0xfd0 __tcp_push_pending_frames+0x2e/0xf0 tcp_sendmsg_locked+0x939/0xd50 tcp_sendmsg+0x27/0x40 sock_sendmsg+0x57/0x80 siw_tx_hdt+0x894/0xb20 [siw] ? find_busiest_group+0x3e/0x5b0 ? common_interrupt+0xa/0xf ? common_interrupt+0xa/0xf ? common_interrupt+0xa/0xf siw_qp_sq_process+0xf1/0xe60 [siw] ? __wake_up_common_lock+0x87/0xc0 siw_sq_resume+0x33/0xe0 [siw] siw_run_sq+0xac/0x190 [siw] ? remove_wait_queue+0x60/0x60 kthread+0xf8/0x130 ? siw_sq_resume+0xe0/0xe0 [siw] ? kthread_bind+0x10/0x10 ret_from_fork+0x35/0x40
--- drivers/infiniband/sw/siw/siw_qp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/infiniband/sw/siw/siw_qp.c +11 -4
@@ -182,12 +182,19 @@ void siw_qp_llp_close(struct siw_qp *qp)*/ void siw_qp_llp_write_space (struct sock *sk) { -struct siw_cep *cep =sk_to_cep (sk); +struct siw_cep *cep; - cep->sk_write_space (sk); +read_lock (&sk->sk_callback_lock); + + cep =sk_to_cep (sk); +if (cep) { + cep->sk_write_space (sk); -if (!test_bit (SOCK_NOSPACE , &sk->sk_socket->flags)) - (void )siw_sq_start (cep->qp); +if (!test_bit (SOCK_NOSPACE , &sk->sk_socket->flags)) + (void )siw_sq_start (cep->qp); + } + +read_unlock (&sk->sk_callback_lock); }static int siw_qp_readq_init (struct siw_qp *qp,int irq_size,int orq_size)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 18/89 RDMA/hfi1: Prevent memory leak in sdma_init
In reply to Sasha LevinFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 34b3be18a04ecdc610aae4c48e5d1b799d8689f6 ]
In sdma_init if rhashtable_init fails the allocated memory for tmp_sdma_rht should be released.
--- drivers/infiniband/hw/hfi1/sdma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/sdma.c +4 -1
@@ -1526,8 +1526,11 @@ int sdma_init(struct hfi1_devdata *dd, u8 port) } ret =rhashtable_init (tmp_sdma_rht, &sdma_rht_params); -if (ret <0 ) +if (ret <0 ) { +kfree (tmp_sdma_rht); goto bail; + } + dd->sdma_rht = tmp_sdma_rht;dd_dev_info (dd,"SDMA num_sdma: %u\n" , dd->num_sdma);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 19/89 RDMA/iw_cxgb4: fix SRQ access from dump_qp()
In reply to Sasha LevinFrom: Potnuri Bharat Teja <[email protected]>
[ Upstream commit 91724c1e5afe45b64970036170659726e7dc5cff ]
dump_qp() is wrongly trying to dump SRQ structures as QP when SRQ is used by the application. This patch matches the QPID before dumping them. Also removes unwanted SRQ id addition to QP id xarray.
--- drivers/infiniband/hw/cxgb4/device.c | 7 +++++-- drivers/infiniband/hw/cxgb4/qp.c | 10 +--------- 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/infiniband/hw/cxgb4/device.c +5 -2
@@ -242,10 +242,13 @@ static void set_ep_sin6_addrs(struct c4iw_ep *ep, } } -static int dump_qp (struct c4iw_qp *qp,struct c4iw_debugfs_data *qpd) +static int dump_qp (unsigned long id,struct c4iw_qp *qp, +struct c4iw_debugfs_data *qpd) {int space;int cc; +if (id != qp->wq.sq.qid) +return 0 ; space = qpd->bufsize - qpd->pos -1 ;if (space ==0 )
@@ -350,7 +353,7 @@ static int qp_open(struct inode *inode, struct file *file)xa_lock_irq (&qpd->devp->qps);xa_for_each (&qpd->devp->qps, index, qp) -dump_qp (qp, qpd); +dump_qp (index, qp, qpd);xa_unlock_irq (&qpd->devp->qps); qpd->buf[qpd->pos++] =0 ;
drivers/infiniband/hw/cxgb4/qp.c +1 -9
@@ -2737,15 +2737,11 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs,if (CHELSIO_CHIP_VERSION (rhp->rdev.lldi.adapter_type) >CHELSIO_T6 ) srq->flags =T4_SRQ_LIMIT_SUPPORT ; - ret =xa_insert_irq (&rhp->qps, srq->wq.qid, srq,GFP_KERNEL ); -if (ret) - goto err_free_queue; -if (udata) { srq_key_mm =kmalloc (sizeof (*srq_key_mm),GFP_KERNEL );if (!srq_key_mm) { ret = -ENOMEM ; - goto err_remove_handle; + goto err_free_queue; } srq_db_key_mm =kmalloc (sizeof (*srq_db_key_mm),GFP_KERNEL );if (!srq_db_key_mm) {
@@ -2789,8 +2785,6 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs,kfree (srq_db_key_mm); err_free_srq_key_mm:kfree (srq_key_mm); -err_remove_handle: -xa_erase_irq (&rhp->qps, srq->wq.qid); err_free_queue:free_srq_queue (srq, ucontext ? &ucontext->uctx : &rhp->rdev.uctx, srq->wr_waitp);
@@ -2813,8 +2807,6 @@ void c4iw_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) rhp = srq->rhp;pr_debug ("%s id %d\n" , __func__, srq->wq.qid); - -xa_erase_irq (&rhp->qps, srq->wq.qid); ucontext = rdma_udata_to_drv_context(udata, struct c4iw_ucontext, ibucontext); free_srq_queue(srq, ucontext ? &ucontext->uctx : &rhp->rdev.uctx,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 20/89 RDMA/iwcm: Fix a lock inversion issue
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit b66f31efbdad95ec274345721d99d1d835e6de01 ]
This patch fixes the lock inversion complaint:
============================================
WARNING: possible recursive locking detected
5.3.0-rc7-dbg+ #1 Not tainted
--------------------------------------------
kworker/u16:6/171 is trying to acquire lock:00000000035c6e6c (&id_priv->handler_mutex){+.+.}, at: rdma_destroy_id+0x78/0x4a0 [rdma_cm]
but task is already holding lock:00000000bc7c307d (&id_priv->handler_mutex){+.+.}, at: iw_conn_req_handler+0x151/0x680 [rdma_cm]
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&id_priv->handler_mutex);
lock(&id_priv->handler_mutex);
*** DEADLOCK ***
May be due to missing lock nesting notation
3 locks held by kworker/u16:6/171:
#0: 00000000e2eaa773 ((wq_completion)iw_cm_wq){+.+.}, at: process_one_work+0x472/0xac0 #1: 000000001efd357b ((work_completion)(&work->work)#3){+.+.}, at: process_one_work+0x476/0xac0 #2: 00000000bc7c307d (&id_priv->handler_mutex){+.+.}, at: iw_conn_req_handler+0x151/0x680 [rdma_cm]
stack backtrace: CPU: 3 PID: 171 Comm: kworker/u16:6 Not tainted 5.3.0-rc7-dbg+ #1 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: iw_cm_wq cm_work_handler [iw_cm] Call Trace: dump_stack+0x8a/0xd6 __lock_acquire.cold+0xe1/0x24d lock_acquire+0x106/0x240 __mutex_lock+0x12e/0xcb0 mutex_lock_nested+0x1f/0x30 rdma_destroy_id+0x78/0x4a0 [rdma_cm] iw_conn_req_handler+0x5c9/0x680 [rdma_cm] cm_work_handler+0xe62/0x1100 [iw_cm] process_one_work+0x56d/0xac0 worker_thread+0x7a/0x5d0 kthread+0x1bc/0x210 ret_from_fork+0x24/0x30
This is not a bug as there are actually two lock classes here.
--- drivers/infiniband/core/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cma.c +2 -1
@@ -2396,9 +2396,10 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, conn_id->cm_id.iw =NULL ;cma_exch (conn_id,RDMA_CM_DESTROYING );mutex_unlock (&conn_id->handler_mutex); +mutex_unlock (&listen_id->handler_mutex);cma_deref_id (conn_id);rdma_destroy_id (&conn_id->id); - goto out; +return ret; }mutex_unlock (&conn_id->handler_mutex);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 21/89 HID: hyperv: Use in-place iterator API in the channel callback
In reply to Sasha LevinFrom: Dexuan Cui <[email protected]>
[ Upstream commit 6a297c90efa68b2864483193b8bfb0d19478600c ]
Simplify the ring buffer handling with the in-place API.
Also avoid the dynamic allocation and the memory leak in the channel callback function.
--- drivers/hid/hid-hyperv.c | 56 +++++++--------------------------------- 1 file changed, 10 insertions(+), 46 deletions(-)
drivers/hid/hid-hyperv.c +10 -46
@@ -314,60 +314,24 @@ static void mousevsc_on_receive(struct hv_device *device,static void mousevsc_on_channel_callback (void *context) { -const int packet_size =0x100 ; -int ret;struct hv_device *device = context; -u32 bytes_recvd; -u64 req_id;struct vmpacket_descriptor *desc; -unsigned char *buffer; -int bufferlen = packet_size; - - buffer =kmalloc (bufferlen,GFP_ATOMIC ); -if (!buffer) -return ; - -do { - ret =vmbus_recvpacket_raw (device->channel, buffer, - bufferlen, &bytes_recvd, &req_id); - -switch (ret) { -case 0 : -if (bytes_recvd <=0 ) { -kfree (buffer); -return ; - } - desc = (struct vmpacket_descriptor *)buffer; - -switch (desc->type) { -case VM_PKT_COMP : -break ; - -case VM_PKT_DATA_INBAND : -mousevsc_on_receive (device, desc); -break ; - -default : -pr_err ("unhandled packet type %d, tid %llx len %d\n" , - desc->type, req_id, bytes_recvd); -break ; - } + foreach_vmbus_pkt(desc, device->channel) { +switch (desc->type) { +case VM_PKT_COMP :break ; -case -ENOBUFS : -kfree (buffer); -/* Handle large packet */ - bufferlen = bytes_recvd; - buffer =kmalloc (bytes_recvd,GFP_ATOMIC ); - -if (!buffer) -return ; +case VM_PKT_DATA_INBAND : +mousevsc_on_receive (device, desc); +break ; +default : +pr_err ("Unhandled packet type %d, tid %llx len %d\n" , + desc->type, desc->trans_id, desc->len8 *8 );break ; } - }while (1 ); - + } }static int mousevsc_connect_to_vsp (struct hv_device *device)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 22/89 kselftest: exclude failed TARGETS from runlist
In reply to Sasha LevinFrom: Cristian Marussi <[email protected]>
[ Upstream commit 131b30c94fbc0adb15f911609884dd39dada8f00 ]
A TARGET which failed to be built/installed should not be included in the runlist generated inside the run_kselftest.sh script.
--- tools/testing/selftests/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/Makefile +4 -0
@@ -198,8 +198,12 @@ ifdef INSTALL_PATH echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT) echo "fi" >> $(ALL_SCRIPT) + @# While building run_kselftest.sh skip also non-existent TARGET dirs: + @# they could be the result of a build failure and should NOT be + @# included in the generated runlist. for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ + [ ! -d $$INSTALL_PATH/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \ echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \ echo "cd $$TARGET" >> $(ALL_SCRIPT); \ echo -n "run_many" >> $(ALL_SCRIPT); \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 23/89 selftests/kselftest/runner.sh: Add 45 second timeout per test
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit 852c8cbf34d3b3130a05c38064dd98614f97d3a8 ]
Commit a745f7af3cbd ("selftests/harness: Add 30 second timeout per test") solves the problem of kselftest_harness.h-using binary tests possibly hanging forever. However, scripts and other binaries can still hang forever. This adds a global timeout to each test script run.
To make this configurable (e.g. as needed in the "rtc" test case), include a new per-test-directory "settings" file (similar to "config") that can contain kselftest-specific settings. The first recognized field is "timeout".
Additionally, this splits the reporting for timeouts into a specific "TIMEOUT" not-ok (and adds exit code reporting in the remaining case).
--- tools/testing/selftests/kselftest/runner.sh | 36 +++++++++++++++++++-- tools/testing/selftests/rtc/settings | 1 + 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/rtc/settings
tools/testing/selftests/kselftest/runner.sh +33 -3
@@ -3,9 +3,14 @@ # # Runs a set of tests in a given subdirectory. export skip_rc=4 +export timeout_rc=124 export logfile=/dev/stdout export per_test_logging= +# Defaults for "settings" file fields: +# "timeout" how many seconds to let each test run before failing. +export kselftest_default_timeout=45 + # There isn't a shell-agnostic way to find the path of a sourced file, # so we must rely on BASE_DIR being set to find other tools. if [ -z "$BASE_DIR" ]; then
@@ -24,6 +29,16 @@ tap_prefix() fi } +tap_timeout() +{ + # Make sure tests will time out if utility is available. + if [ -x /usr/bin/timeout ] ; then + /usr/bin/timeout "$kselftest_timeout" "$1" + else + "$1" + fi +} + run_one() { DIR="$1"
@@ -32,6 +47,18 @@ run_one() BASENAME_TEST=$(basename $TEST) + # Reset any "settings"-file variables. + export kselftest_timeout="$kselftest_default_timeout" + # Load per-test-directory kselftest "settings" file. + settings="$BASE_DIR/$DIR/settings" + if [ -r "$settings" ] ; then + while read line ; do + field=$(echo "$line" | cut -d= -f1) + value=$(echo "$line" | cut -d= -f2-) + eval "kselftest_$field"="$value" + done < "$settings" + fi + TEST_HDR_MSG="selftests: $DIR: $BASENAME_TEST" echo "# $TEST_HDR_MSG" if [ ! -x "$TEST" ]; then
@@ -44,14 +71,17 @@ run_one() echo "not ok $test_num $TEST_HDR_MSG" else cd `dirname $TEST` > /dev/null - (((((./$BASENAME_TEST 2>&1; echo $? >&3) | + ((((( tap_timeout ./$BASENAME_TEST 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) | (read xs; exit $xs)) 4>>"$logfile" && echo "ok $test_num $TEST_HDR_MSG") || - (if [ $? -eq $skip_rc ]; then \ + (rc=$?; \ + if [ $rc -eq $skip_rc ]; then \ echo "not ok $test_num $TEST_HDR_MSG # SKIP" + elif [ $rc -eq $timeout_rc ]; then \ + echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT" else - echo "not ok $test_num $TEST_HDR_MSG" + echo "not ok $test_num $TEST_HDR_MSG # exit=$rc" fi) cd - >/dev/null fi
tools/testing/selftests/rtc/settings new file +1 -0
@@ -0,0 +1 @@ +timeout=90
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 24/89 nfs: Fix nfsi->nrequests count error on nfs_inode_remove_request
In reply to Sasha LevinFrom: ZhangXiaoxu <[email protected]>
[ Upstream commit 33ea5aaa87cdae0f9af4d6b7ee4f650a1a36fd1d ]
When xfstests testing, there are some WARNING as below:
WARNING: CPU: 0 PID: 6235 at fs/nfs/inode.c:122 nfs_clear_inode+0x9c/0xd8 Modules linked in: CPU: 0 PID: 6235 Comm: umount.nfs Hardware name: linux,dummy-virt (DT) pstate: 60000005 (nZCv daif -PAN -UAO) pc : nfs_clear_inode+0x9c/0xd8 lr : nfs_evict_inode+0x60/0x78
sp : fffffc000f68fc00
x29: fffffc000f68fc00 x28: fffffe00c53155c0
x27: fffffe00c5315000 x26: fffffc0009a63748
x25: fffffc000f68fd18 x24: fffffc000bfaaf40
x23: fffffc000936d3c0 x22: fffffe00c4ff5e20
x21: fffffc000bfaaf40 x20: fffffe00c4ff5d10
x19: fffffc000c056000 x18: 000000000000003c
x17: 0000000000000000 x16: 0000000000000000
x15: 0000000000000040 x14: 0000000000000228
x13: fffffc000c3a2000 x12: 0000000000000045
x11: 0000000000000000 x10: 0000000000000000
x9 : 0000000000000000 x8 : 0000000000000000
x7 : 0000000000000000 x6 : fffffc00084b027c
x5 : fffffc0009a64000 x4 : fffffe00c0e77400
x3 : fffffc000c0563a8 x2 : fffffffffffffffb
x1 : 000000000000764e x0 : 0000000000000001
Call trace: nfs_clear_inode+0x9c/0xd8 nfs_evict_inode+0x60/0x78 evict+0x108/0x380 dispose_list+0x70/0xa0 evict_inodes+0x194/0x210 generic_shutdown_super+0xb0/0x220 nfs_kill_super+0x40/0x88 deactivate_locked_super+0xb4/0x120 deactivate_super+0x144/0x160 cleanup_mnt+0x98/0x148 __cleanup_mnt+0x38/0x50 task_work_run+0x114/0x160 do_notify_resume+0x2f8/0x308 work_pending+0x8/0x14
The nrequest should be increased/decreased only if PG_INODE_REF flag was setted.
But in the nfs_inode_remove_request function, it maybe decrease when no PG_INODE_REF flag, this maybe lead nrequests count error.
--- fs/nfs/write.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfs/write.c +3 -2
@@ -786,7 +786,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)struct nfs_inode *nfsi =NFS_I (inode);struct nfs_page *head; -atomic_long_dec (&nfsi->nrequests);if (nfs_page_group_sync_on_bit (req,PG_REMOVE )) { head = req->wb_head;
@@ -799,8 +798,10 @@ static void nfs_inode_remove_request(struct nfs_page *req)spin_unlock (&mapping->private_lock); } -if (test_and_clear_bit (PG_INODE_REF , &req->wb_flags)) +if (test_and_clear_bit (PG_INODE_REF , &req->wb_flags)) {nfs_release_request (req); +atomic_long_dec (&nfsi->nrequests); + } } static void
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 25/89 arm64: cpufeature: Effectively expose FRINT capability to userspace
In reply to Sasha LevinFrom: Julien Grall <[email protected]>
[ Upstream commit 7230f7e99fecc684180322b056fad3853d1029d3 ]
The HWCAP framework will detect a new capability based on the sanitized version of the ID registers.
Sanitization is based on a whitelist, so any field not described will end up to be zeroed.
At the moment, ID_AA64ISAR1_EL1.FRINTTS is not described in ftr_id_aa64isar1. This means the field will be zeroed and therefore the userspace will not be able to see the HWCAP even if the hardware supports the feature.
This can be fixed by describing the field in ftr_id_aa64isar1.
--- arch/arm64/kernel/cpufeature.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/cpufeature.c +1 -0
@@ -136,6 +136,7 @@ static const struct arm64_ftr_bits ftr_id_aa64isar0[] = {static const struct arm64_ftr_bits ftr_id_aa64isar1[] = {ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR1_SB_SHIFT ,4 ,0 ), +ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR1_FRINTTS_SHIFT ,4 ,0 ),ARM64_FTR_BITS (FTR_VISIBLE_IF_IS_ENABLED (CONFIG_ARM64_PTR_AUTH ),FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR1_GPI_SHIFT ,4 ,0 ), ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_PTR_AUTH),
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 26/89 arm64: Fix incorrect irqflag restore for priority masking for compat
In reply to Sasha LevinFrom: James Morse <[email protected]>
[ Upstream commit f46f27a576cc3b1e3d45ea50bc06287aa46b04b2 ]
Commit bd82d4bd2188 ("arm64: Fix incorrect irqflag restore for priority masking") added a macro to the entry.S call paths that leave the PSTATE.I bit set. This tells the pPNMI masking logic that interrupts are masked by the CPU, not by the PMR. This value is read back by local_daif_save().
Commit bd82d4bd2188 added this call to el0_svc, as el0_svc_handler is called with interrupts masked. el0_svc_compat was missed, but should be covered in the same way as both of these paths end up in el0_svc_common(), which expects to unmask interrupts.
--- arch/arm64/kernel/entry.S | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/entry.S +1 -0
@@ -775,6 +775,7 @@ el0_sync_compat: b.ge el0_dbg b el0_inv el0_svc_compat: + gic_prio_kentry_setup tmp=x1 mov x0, sp bl el0_svc_compat_handler b ret_to_user
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 27/89 arm64: ftrace: Ensure synchronisation in PLT setup for Neoverse-N1 #1542419
In reply to Sasha LevinFrom: James Morse <[email protected]>
[ Upstream commit dd8a1f13488438c6c220b7cafa500baaf21a6e53 ]
CPUs affected by Neoverse-N1 #1542419 may execute a stale instruction if it was recently modified. The affected sequence requires freshly written instructions to be executable before a branch to them is updated.
There are very few places in the kernel that modify executable text, all but one come with sufficient synchronisation:
* The module loader's flush_module_icache() calls flush_icache_range(), which does a kick_all_cpus_sync()
* bpf_int_jit_compile() calls flush_icache_range().
* Kprobes calls aarch64_insn_patch_text(), which does its work in stop_machine().
* static keys and ftrace both patch between nops and branches to existing kernel code (not generated code).
The affected sequence is the interaction between ftrace and modules. The module PLT is cleaned using __flush_icache_range() as the trampoline shouldn't be executable until we update the branch to it.
Drop the double-underscore so that this path runs kick_all_cpus_sync() too.
--- arch/arm64/kernel/ftrace.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/arm64/kernel/ftrace.c +9 -3
@@ -121,10 +121,16 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)/* * Ensure updated trampoline is visible to instruction -* fetch before we patch in the branch. +* fetch before we patch in the branch. Although the +* architecture doesn't require an IPI in this case, +* Neoverse-N1 erratum #1542419 does require one +* if the TLB maintenance in module_enable_ro() is +* skipped due to rodata_enabled. It doesn't seem worth +* it to make it conditional given that this is +* certainly not a fast-path. */ -__flush_icache_range ((unsigned long )&dst[0 ], - (unsigned long)&dst[1]); +flush_icache_range ((unsigned long )&dst[0 ], + (unsigned long)&dst[1]); } addr = (unsigned long )dst;#else /* CONFIG_ARM64_MODULE_PLTS */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 28/89 tty: serial: owl: Fix the link time qualifier of 'owl_uart_exit()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 6264dab6efd6069f0387efb078a9960b5642377b ]
'exit' functions should be marked as __exit, not __init.
--- drivers/tty/serial/owl-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/owl-uart.c +1 -1
@@ -742,7 +742,7 @@ static int __init owl_uart_init(void)return ret; } -static void __init owl_uart_exit (void ) +static void __exit owl_uart_exit(void) {platform_driver_unregister (&owl_uart_platform_driver);uart_unregister_driver (&owl_uart_driver);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 29/89 tty: serial: rda: Fix the link time qualifier of 'rda_uart_exit()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 5080d127127ac5b610b57900774d9559ae55e817 ]
'exit' functions should be marked as __exit, not __init.
--- drivers/tty/serial/rda-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/rda-uart.c +1 -1
@@ -817,7 +817,7 @@ static int __init rda_uart_init(void)return ret; } -static void __init rda_uart_exit (void ) +static void __exit rda_uart_exit(void) {platform_driver_unregister (&rda_uart_platform_driver);uart_unregister_driver (&rda_uart_driver);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 30/89 serial/sifive: select SERIAL_EARLYCON
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 7e2a165de5a52003d10a611ee3884cdb5c44e8cd ]
The sifive serial driver implements earlycon support, but unless another driver is built in that supports earlycon support it won't be usable. Explicitly select SERIAL_EARLYCON instead.
--- drivers/tty/serial/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/Kconfig +1 -0
@@ -1075,6 +1075,7 @@ config SERIAL_SIFIVE_CONSOLE bool "Console on SiFive UART" depends on SERIAL_SIFIVE=y select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON help Select this option if you would like to use a SiFive UART as the system console.
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 31/89 tty: n_hdlc: fix build on SPARC
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 47a7e5e97d4edd7b14974d34f0e5a5560fad2915 ]
Fix tty driver build on SPARC by not using __exitdata. It appears that SPARC does not support section .exit.data.
Fixes these build errors:
.exit.data' referenced in section .exit.text' of drivers/tty/n_hdlc.o: defined in discarded section .exit.data' of drivers/tty/n_hdlc.o .exit.data' referenced in section .exit.text' of drivers/tty/n_hdlc.o: defined in discarded section .exit.data' of drivers/tty/n_hdlc.o .exit.data' referenced in section .exit.text' of drivers/tty/n_hdlc.o: defined in discarded section .exit.data' of drivers/tty/n_hdlc.o .exit.data' referenced in section .exit.text' of drivers/tty/n_hdlc.o: defined in discarded section .exit.data' of drivers/tty/n_hdlc.o
--- drivers/tty/n_hdlc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/n_hdlc.c +5 -0
@@ -968,6 +968,11 @@ static int __init n_hdlc_init(void) }/* end of init_module() */ +#ifdef CONFIG_SPARC +#undef __exitdata +#define __exitdata +#endif + static const char hdlc_unregister_ok[] __exitdata =KERN_INFO "N_HDLC: line discipline unregistered\n" ; static const char hdlc_unregister_fail[] __exitdata =
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 32/89 misc: fastrpc: prevent memory leak in fastrpc_dma_buf_attach
In reply to Sasha LevinFrom: Navid Emamdoost <[email protected]>
[ Upstream commit fc739a058d99c9297ef6bfd923b809d85855b9a9 ]
In fastrpc_dma_buf_attach if dma_get_sgtable fails the allocated memory for a should be released.
--- drivers/misc/fastrpc.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/fastrpc.c +1 -0
@@ -499,6 +499,7 @@ static int fastrpc_dma_buf_attach(struct dma_buf *dmabuf, FASTRPC_PHYS(buffer->phys), buffer->size);if (ret <0 ) {dev_err (buffer->dev,"failed to get scatterlist from DMA API\n" ); +kfree (a);return -EINVAL ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 33/89 RDMA/core: Fix an error handling path in 'res_get_common_doit()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit ab59ca3eb4e7059727df85eee68bda169d26c8f8 ]
According to surrounding error paths, it is likely that 'goto err_get;' is expected here. Otherwise, a call to 'rdma_restrack_put(res);' would be missing.
--- drivers/infiniband/core/nldev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/nldev.c +1 -1
@@ -1230,7 +1230,7 @@ static int res_get_common_doit(struct sk_buff *skb, struct nlmsghdr *nlh, msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg) { ret = -ENOMEM ; - goto err; + goto err_get; } nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 34/89 RDMA/cm: Fix memory leak in cm_add/remove_one
In reply to Sasha LevinFrom: Jack Morgenstein <[email protected]>
[ Upstream commit 94635c36f3854934a46d9e812e028d4721bbb0e6 ]
In the process of moving the debug counters sysfs entries, the commit mentioned below eliminated the cm_infiniband sysfs directory.
This sysfs directory was tied to the cm_port object allocated in procedure cm_add_one().
Before the commit below, this cm_port object was freed via a call to kobject_put(port->kobj) in procedure cm_remove_port_fs().
Since port no longer uses its kobj, kobject_put(port->kobj) was eliminated. This, however, meant that kfree was never called for the cm_port buffers.
Fix this by adding explicit kfree(port) calls to functions cm_add_one() and cm_remove_one().
Note: the kfree call in the first chunk below (in the cm_add_one error flow) fixes an old, undetected memory leak.
--- drivers/infiniband/core/cm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/cm.c +3 -0
@@ -4399,6 +4399,7 @@ static void cm_add_one(struct ib_device *ib_device) error1: port_modify.set_port_cap_mask =0 ; port_modify.clr_port_cap_mask =IB_PORT_CM_SUP ; +kfree (port);while (--i) {if (!rdma_cap_ib_cm (ib_device, i))continue ;
@@ -4407,6 +4408,7 @@ static void cm_add_one(struct ib_device *ib_device)ib_modify_port (ib_device, port->port_num,0 , &port_modify);ib_unregister_mad_agent (port->mad_agent);cm_remove_port_fs (port); +kfree (port); } free:kfree (cm_dev);
@@ -4460,6 +4462,7 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data)spin_unlock_irq (&cm.state_lock);ib_unregister_mad_agent (cur_mad_agent);cm_remove_port_fs (port); +kfree (port); }kfree (cm_dev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 35/89 RDMA/cxgb4: Do not dma memory off of the stack
In reply to Sasha LevinFrom: Greg KH <[email protected]>
[ Upstream commit 3840c5b78803b2b6cc1ff820100a74a092c40cbb ]
Nicolas pointed out that the cxgb4 driver is doing dma off of the stack, which is generally considered a very bad thing. On some architectures it could be a security problem, but odds are none of them actually run this driver, so it's just a "normal" bug.
Resolve this by allocating the memory for a message off of the heap instead of the stack. kmalloc() always will give us a proper memory location that DMA will work correctly from.
--- drivers/infiniband/hw/cxgb4/mem.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/infiniband/hw/cxgb4/mem.c +17 -11
@@ -275,13 +275,17 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry, struct sk_buff *skb, struct c4iw_wr_wait *wr_waitp) { int err; -struct fw_ri_tpte tpt; +struct fw_ri_tpte *tpt;u32 stag_idx;static atomic_t key;if (c4iw_fatal_error (rdev))return -EIO ; + tpt =kmalloc (sizeof (*tpt),GFP_KERNEL ); +if (!tpt) +return -ENOMEM ; + stag_state = stag_state >0 ; stag_idx = (*stag) >>8 ;
@@ -291,6 +295,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,mutex_lock (&rdev->stats.lock); rdev->stats.stag.fail++;mutex_unlock (&rdev->stats.lock); +kfree (tpt);return -ENOMEM ; }mutex_lock (&rdev->stats.lock);
@@ -305,28 +310,28 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,/* write TPT entry */ if (reset_tpt_entry) -memset (&tpt,0 ,sizeof (tpt)); +memset (tpt,0 ,sizeof (*tpt));else { - tpt.valid_to_pdid =cpu_to_be32 (FW_RI_TPTE_VALID_F | + tpt->valid_to_pdid =cpu_to_be32 (FW_RI_TPTE_VALID_F |FW_RI_TPTE_STAGKEY_V ((*stag &FW_RI_TPTE_STAGKEY_M )) |FW_RI_TPTE_STAGSTATE_V (stag_state) |FW_RI_TPTE_STAGTYPE_V (type) |FW_RI_TPTE_PDID_V (pdid)); - tpt.locread_to_qpid =cpu_to_be32 (FW_RI_TPTE_PERM_V (perm) | + tpt->locread_to_qpid =cpu_to_be32 (FW_RI_TPTE_PERM_V (perm) | (bind_enabled ?FW_RI_TPTE_MWBINDEN_F :0 ) |FW_RI_TPTE_ADDRTYPE_V ((zbva ?FW_RI_ZERO_BASED_TO :FW_RI_VA_BASED_TO ))|FW_RI_TPTE_PS_V (page_size)); - tpt.nosnoop_pbladdr = !pbl_size ?0 :cpu_to_be32 ( + tpt->nosnoop_pbladdr = !pbl_size ?0 :cpu_to_be32 (FW_RI_TPTE_PBLADDR_V (PBL_OFF (rdev, pbl_addr)>>3 )); - tpt.len_lo =cpu_to_be32 ((u32)(len &0xffffffffUL )); - tpt.va_hi =cpu_to_be32 ((u32)(to >>32 )); - tpt.va_lo_fbo =cpu_to_be32 ((u32)(to &0xffffffffUL )); - tpt.dca_mwbcnt_pstag =cpu_to_be32 (0 ); - tpt.len_hi =cpu_to_be32 ((u32)(len >>32 )); + tpt->len_lo =cpu_to_be32 ((u32)(len &0xffffffffUL )); + tpt->va_hi =cpu_to_be32 ((u32)(to >>32 )); + tpt->va_lo_fbo =cpu_to_be32 ((u32)(to &0xffffffffUL )); + tpt->dca_mwbcnt_pstag =cpu_to_be32 (0 ); + tpt->len_hi =cpu_to_be32 ((u32)(len >>32 )); } err =write_adapter_mem (rdev, stag_idx + (rdev->lldi.vr->stag.start >>5 ), -sizeof (tpt), &tpt, skb, wr_waitp); +sizeof (*tpt), tpt, skb, wr_waitp);if (reset_tpt_entry) {c4iw_put_resource (&rdev->resource.tpt_table, stag_idx);
@@ -334,6 +339,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry, rdev->stats.stag.cur -=32 ;mutex_unlock (&rdev->stats.lock); } +kfree (tpt);return err; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 36/89 RDMA/nldev: Reshuffle the code to avoid need to rebind QP in error path
In reply to Sasha LevinFrom: Leon Romanovsky <[email protected]>
[ Upstream commit 594e6c5d41ed2471ab0b90f3f0b66cdf618b7ac9 ]
Properly unwind QP counter rebinding in case of failure.
Trying to rebind the counter after unbiding it is not going to work reliably, move the unbind to the end so it doesn't have to be unwound.
--- drivers/infiniband/core/nldev.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/infiniband/core/nldev.c +4 -6
@@ -1787,10 +1787,6 @@ static int nldev_stat_del_doit(struct sk_buff *skb, struct nlmsghdr *nlh, cntn =nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID ]); qpn =nla_get_u32 (tb[RDMA_NLDEV_ATTR_RES_LQPN ]); - ret =rdma_counter_unbind_qpn (device, port, qpn, cntn); -if (ret) - goto err_unbind; - if (fill_nldev_handle(msg, device) || nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, port) || nla_put_u32(msg, RDMA_NLDEV_ATTR_STAT_COUNTER_ID, cntn) ||
@@ -1799,13 +1795,15 @@ static int nldev_stat_del_doit(struct sk_buff *skb, struct nlmsghdr *nlh, goto err_fill; } + ret =rdma_counter_unbind_qpn (device, port, qpn, cntn); +if (ret) + goto err_fill; +nlmsg_end (msg, nlh);ib_device_put (device);return rdma_nl_unicast (msg,NETLINK_CB (skb).portid); err_fill: -rdma_counter_bind_qpn (device, port, qpn, cntn); -err_unbind:nlmsg_free (msg); err:ib_device_put (device);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 37/89 RDMA/mlx5: Do not allow rereg of a ODP MR
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 880505cfef1d086d18b59d2920eb2160429ffa1f ]
This code is completely broken, the umem of a ODP MR simply cannot be discarded without a lot more locking, nor can an ODP mkey be blithely destroyed via destroy_mkey().
--- drivers/infiniband/hw/mlx5/mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +3 -3
@@ -1423,6 +1423,9 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,if (!mr->umem)return -EINVAL ; +if (is_odp_mr (mr)) +return -EOPNOTSUPP ; +if (flags &IB_MR_REREG_TRANS ) { addr = virt_addr; len = length;
@@ -1468,8 +1471,6 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, } mr->allocated_from_cache =0 ; -if (IS_ENABLED (CONFIG_INFINIBAND_ON_DEMAND_PAGING )) - mr->live =1 ; }else {/* * Send a UMR WQE
@@ -1498,7 +1499,6 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,set_mr_fields (dev, mr, npages, len, access_flags); -update_odp_mr (mr);return 0 ; err:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 38/89 RDMA/mlx5: Order num_pending_prefetch properly with synchronize_srcu
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit aa116b810ac9077a263ed8679fb4d595f180e0eb ]
During destroy setting live = 0 and then synchronize_srcu() prevents num_pending_prefetch from incrementing, and also, ensures that all work holding that count is queued on the WQ. Testing before causes races of the form:
CPU0 CPU1
dereg_mr()
mlx5_ib_advise_mr_prefetch()
srcu_read_lock()
num_pending_prefetch_inc()
if (!live)
live = 0
atomic_read() == 0
// skip flush_workqueue()
atomic_inc() queue_work();
srcu_read_unlock()
WARN_ON(atomic_read()) // Fails
Swap the order so that the synchronize_srcu() prevents this.
--- drivers/infiniband/hw/mlx5/mr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +3 -2
@@ -1591,13 +1591,14 @@ static void dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)*/ mr->live =0 ; +/* Wait for all running page-fault handlers to finish. */ +synchronize_srcu (&dev->mr_srcu); +/* dequeue pending prefetch requests for the mr */ if (atomic_read (&mr->num_pending_prefetch))flush_workqueue (system_unbound_wq);WARN_ON (atomic_read (&mr->num_pending_prefetch)); -/* Wait for all running page-fault handlers to finish. */ -synchronize_srcu (&dev->mr_srcu);/* Destroy all page mappings */ if (umem_odp->page_list) mlx5_ib_invalidate_range(umem_odp,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 39/89 RDMA/mlx5: Add missing synchronize_srcu() for MW cases
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 0417791536ae1e28d7f0418f1d20048ec4d3c6cf ]
While MR uses live as the SRCU 'update', the MW case uses the xarray directly, xa_erase() causes the MW to become inaccessible to the pagefault thread.
Thus whenever a MW is removed from the xarray we must synchronize_srcu() before freeing it.
This must be done before freeing the mkey as re-use of the mkey while the pagefault thread is using the stale mkey is undesirable.
Add the missing synchronizes to MW and DEVX indirect mkey and delete the bogus protection against double destroy in mlx5_core_destroy_mkey()
--- drivers/infiniband/hw/mlx5/devx.c | 58 ++++++-------------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 - drivers/infiniband/hw/mlx5/mr.c | 21 +++++-- drivers/net/ethernet/mellanox/mlx5/core/mr.c | 8 +-- 4 files changed, 33 insertions(+), 55 deletions(-)
drivers/infiniband/hw/mlx5/devx.c +16 -42
@@ -1275,29 +1275,6 @@ static int devx_handle_mkey_create(struct mlx5_ib_dev *dev,return 0 ; } -static void devx_free_indirect_mkey (struct rcu_head *rcu) -{ - kfree(container_of(rcu, struct devx_obj, devx_mr.rcu)); -} - -/* This function to delete from the radix tree needs to be called before -* destroying the underlying mkey. Otherwise a race might occur in case that -* other thread will get the same mkey before this one will be deleted, -* in that case it will fail via inserting to the tree its own data. -* -* Note: -* An error in the destroy is not expected unless there is some other indirect -* mkey which points to this one. In a kernel cleanup flow it will be just -* destroyed in the iterative destruction call. In a user flow, in case -* the application didn't close in the expected order it's its own problem, -* the mkey won't be part of the tree, in both cases the kernel is safe. -*/ -static void devx_cleanup_mkey (struct devx_obj *obj) -{ -xa_erase (&obj->ib_dev->mdev->priv.mkey_table, -mlx5_base_mkey (obj->devx_mr.mmkey.key)); -} -static void devx_cleanup_subscription (struct mlx5_ib_dev *dev,struct devx_event_subscription *sub) {
@@ -1339,8 +1316,16 @@ static int devx_obj_cleanup(struct ib_uobject *uobject,int ret; dev =mlx5_udata_to_mdev (&attrs->driver_udata); -if (obj->flags &DEVX_OBJ_FLAGS_INDIRECT_MKEY ) -devx_cleanup_mkey (obj); +if (obj->flags &DEVX_OBJ_FLAGS_INDIRECT_MKEY ) { +/* +* The pagefault_single_data_segment() does commands against +* the mmkey, we must wait for that to stop before freeing the +* mkey, as another allocation could get the same mkey #. +*/ +xa_erase (&obj->ib_dev->mdev->priv.mkey_table, +mlx5_base_mkey (obj->devx_mr.mmkey.key)); +synchronize_srcu (&dev->mr_srcu); + }if (obj->flags &DEVX_OBJ_FLAGS_DCT ) ret =mlx5_core_destroy_dct (obj->ib_dev->mdev, &obj->core_dct);
@@ -1359,12 +1344,6 @@ static int devx_obj_cleanup(struct ib_uobject *uobject,devx_cleanup_subscription (dev, sub_entry);mutex_unlock (&devx_event_table->event_xa_lock); -if (obj->flags &DEVX_OBJ_FLAGS_INDIRECT_MKEY ) { -call_srcu (&dev->mr_srcu, &obj->devx_mr.rcu, - devx_free_indirect_mkey); -return ret; - } -kfree (obj);return ret; }
@@ -1468,26 +1447,21 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_CREATE)( &obj_id);WARN_ON (obj->dinlen >MLX5_MAX_DESTROY_INBOX_SIZE_DW *sizeof (u32)); -if (obj->flags &DEVX_OBJ_FLAGS_INDIRECT_MKEY ) { - err =devx_handle_mkey_indirect (obj, dev, cmd_in, cmd_out); -if (err) - goto obj_destroy; - } - err =uverbs_copy_to (attrs,MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_OUT , cmd_out, cmd_out_len);if (err) - goto err_copy; + goto obj_destroy;if (opcode ==MLX5_CMD_OP_CREATE_GENERAL_OBJECT ) obj_type =MLX5_GET (general_obj_in_cmd_hdr, cmd_in, obj_type); - obj->obj_id =get_enc_obj_id (opcode | obj_type <<16 , obj_id); +if (obj->flags &DEVX_OBJ_FLAGS_INDIRECT_MKEY ) { + err =devx_handle_mkey_indirect (obj, dev, cmd_in, cmd_out); +if (err) + goto obj_destroy; + }return 0 ; -err_copy: -if (obj->flags &DEVX_OBJ_FLAGS_INDIRECT_MKEY ) -devx_cleanup_mkey (obj); obj_destroy:if (obj->flags &DEVX_OBJ_FLAGS_DCT )mlx5_core_destroy_dct (obj->ib_dev->mdev, &obj->core_dct);
drivers/infiniband/hw/mlx5/mlx5_ib.h +0 -1
@@ -638,7 +638,6 @@ struct mlx5_ib_mw {struct mlx5_ib_devx_mr {struct mlx5_core_mkey mmkey;int ndescs; -struct rcu_head rcu; };struct mlx5_ib_umr_context {
drivers/infiniband/hw/mlx5/mr.c +16 -5
@@ -1970,14 +1970,25 @@ struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,int mlx5_ib_dealloc_mw (struct ib_mw *mw) { +struct mlx5_ib_dev *dev =to_mdev (mw->device);struct mlx5_ib_mw *mmw =to_mmw (mw);int err; - err =mlx5_core_destroy_mkey ((to_mdev (mw->device))->mdev, - &mmw->mmkey); -if (!err) -kfree (mmw); -return err; +if (IS_ENABLED (CONFIG_INFINIBAND_ON_DEMAND_PAGING )) { +xa_erase (&dev->mdev->priv.mkey_table, +mlx5_base_mkey (mmw->mmkey.key)); +/* +* pagefault_single_data_segment() may be accessing mmw under +* SRCU if the user bound an ODP MR to this MW. +*/ +synchronize_srcu (&dev->mr_srcu); + } + + err =mlx5_core_destroy_mkey (dev->mdev, &mmw->mmkey); +if (err) +return err; +kfree (mmw); +return 0 ; } int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
drivers/net/ethernet/mellanox/mlx5/core/mr.c +1 -7
@@ -112,17 +112,11 @@ int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev,u32 out[MLX5_ST_SZ_DW (destroy_mkey_out)] = {0 };u32 in[MLX5_ST_SZ_DW (destroy_mkey_in)] = {0 };struct xarray *mkeys = &dev->priv.mkey_table; -struct mlx5_core_mkey *deleted_mkey;unsigned long flags;xa_lock_irqsave (mkeys, flags); - deleted_mkey =__xa_erase (mkeys,mlx5_base_mkey (mkey->key)); +__xa_erase (mkeys,mlx5_base_mkey (mkey->key));xa_unlock_irqrestore (mkeys, flags); -if (!deleted_mkey) { -mlx5_core_dbg (dev,"failed xarray delete of mkey 0x%x\n" , -mlx5_base_mkey (mkey->key)); -return -ENOENT ; - }MLX5_SET (destroy_mkey_in, in, opcode,MLX5_CMD_OP_DESTROY_MKEY );MLX5_SET (destroy_mkey_in, in, mkey_index,mlx5_mkey_to_idx (mkey->key));
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 40/89 gpio: max77620: Use correct unit for debounce times
In reply to Sasha LevinFrom: Thierry Reding <[email protected]>
[ Upstream commit fffa6af94894126994a7600c6f6f09b892e89fa9 ]
The gpiod_set_debounce() function takes the debounce time in microseconds. Adjust the switch/case values in the MAX77620 GPIO to use the correct unit.
--- drivers/gpio/gpio-max77620.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-max77620.c +3 -3
@@ -192,13 +192,13 @@ static int max77620_gpio_set_debounce(struct max77620_gpio *mgpio,case 0 : val = MAX77620_CNFG_GPIO_DBNC_None;break ; - case 1 ... 8: + case 1000 ... 8000: val = MAX77620_CNFG_GPIO_DBNC_8ms;break ; - case 9 ... 16: + case 9000 ... 16000: val = MAX77620_CNFG_GPIO_DBNC_16ms;break ; - case 17 ... 32: + case 17000 ... 32000: val = MAX77620_CNFG_GPIO_DBNC_32ms;break ;default :
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 41/89 fs: cifs: mute -Wunused-const-variable message
In reply to Sasha LevinFrom: Austin Kim <[email protected]>
[ Upstream commit dd19c106a36690b47bb1acc68372f2b472b495b8 ]
After 'Initial git repository build' commit, 'mapping_table_ERRHRD' variable has not been used.
So 'mapping_table_ERRHRD' const variable could be removed to mute below warning message:
fs/cifs/netmisc.c:120:40: warning: unused variable 'mapping_table_ERRHRD' [-Wunused-const-variable]
static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
^--- fs/cifs/netmisc.c | 4 ---- 1 file changed, 4 deletions(-)
fs/cifs/netmisc.c +0 -4
@@ -117,10 +117,6 @@ static const struct smb_to_posix_error mapping_table_ERRSRV[] = { {0, 0} }; -static const struct smb_to_posix_error mapping_table_ERRHRD[] = { - {0 ,0 } -}; -/* * Convert a string containing text IPv4 or IPv6 address to binary form. *
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 42/89 arm64: vdso32: Fix broken compat vDSO build warnings
In reply to Sasha LevinFrom: Vincenzo Frascino <[email protected]>
[ Upstream commit e0de01aafc3dd7b73308106b056ead2d48391905 ]
The .config file and the generated include/config/auto.conf can end up out of sync after a set of commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated correctly.
The sequence can be reproduced as follows:
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig [...] $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"] $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Which results in:
arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built
even though the compat vDSO has been built:
$ file arch/arm64/kernel/vdso32/vdso.so arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped
A similar case that involves changing the configuration parameter multiple times can be reconducted to the same family of problems.
Remove the use of CONFIG_CROSS_COMPILE_COMPAT_VDSO altogether and instead rely on the cross-compiler prefix coming from the environment via CROSS_COMPILE_COMPAT, much like we do for the rest of the kernel.
--- arch/arm64/Kconfig | 2 +- arch/arm64/Makefile | 18 +++++------------- arch/arm64/kernel/vdso32/Makefile | 2 -- 3 files changed, 6 insertions(+), 16 deletions(-)
arch/arm64/Kconfig +1 -1
@@ -111,7 +111,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select GENERIC_GETTIMEOFDAY - select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT) + select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && "$(CROSS_COMPILE_COMPAT)" != "") select HANDLE_DOMAIN_IRQ select HARDIRQS_SW_RESEND select HAVE_PCI
arch/arm64/Makefile +5 -13
@@ -47,20 +47,12 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif endif +COMPATCC ?= $(CROSS_COMPILE_COMPAT)gcc +export COMPATCC + ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y) - CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%) - - ifeq ($(CONFIG_CC_IS_CLANG), y) - $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built) - else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),) - $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built) - else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),) - $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT) - else - export CROSS_COMPILE_COMPAT - export CONFIG_COMPAT_VDSO := y - compat_vdso := -DCONFIG_COMPAT_VDSO=1 - endif + export CONFIG_COMPAT_VDSO := y + compat_vdso := -DCONFIG_COMPAT_VDSO=1 endif KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) $(brokengasinst) $(compat_vdso)
arch/arm64/kernel/vdso32/Makefile +0 -2
@@ -8,8 +8,6 @@ ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32 include $(srctree)/lib/vdso/Makefile -COMPATCC := $(CROSS_COMPILE_COMPAT)gcc - # Same as cc-*option, but using COMPATCC instead of CC cc32-option = $(call try-run,\ $(COMPATCC) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 43/89 arm64: vdso32: Detect binutils support for dmb ishld
In reply to Sasha LevinFrom: Vincenzo Frascino <[email protected]>
[ Upstream commit 0df2c90eba60791148cee1823c0bf5fc66e3465c ]
Older versions of binutils (prior to 2.24) do not support the "ISHLD" option for memory barrier instructions, which leads to a build failure when assembling the vdso32 library.
Add a compilation time mechanism that detects if binutils supports those instructions and configure the kernel accordingly.
--- arch/arm64/include/asm/vdso/compat_barrier.h | 2 +- arch/arm64/kernel/vdso32/Makefile | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
arch/arm64/include/asm/vdso/compat_barrier.h +1 -1
@@ -20,7 +20,7 @@#define dmb (option) __asm__ __volatile__ ("dmb " #option : : : "memory") -#if __LINUX_ARM_ARCH__ >=8 +#if __LINUX_ARM_ARCH__ >=8 && defined(CONFIG_AS_DMB_ISHLD )#define aarch32_smp_mb () dmb(ish)#define aarch32_smp_rmb () dmb(ishld)#define aarch32_smp_wmb () dmb(ishst)
arch/arm64/kernel/vdso32/Makefile +9 -0
@@ -15,6 +15,8 @@ cc32-disable-warning = $(call try-run,\ $(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) cc32-ldoption = $(call try-run,\ $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) +cc32-as-instr = $(call try-run,\ + printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) # We cannot use the global flags to compile the vDSO files, the main reason # being that the 32-bit compiler may be older than the main (64-bit) compiler
@@ -53,6 +55,7 @@ endif VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING + # Try to compile for ARMv8. If the compiler is too old and doesn't support it, # fall back to v7. There is no easy way to check for what architecture the code # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
@@ -89,6 +92,12 @@ VDSO_CFLAGS += -Wno-int-to-pointer-cast VDSO_AFLAGS := $(VDSO_CAFLAGS) VDSO_AFLAGS += -D__ASSEMBLY__ +# Check for binutils support for dmb ishld +dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1) + +VDSO_CFLAGS += $(dmbinstr) +VDSO_AFLAGS += $(dmbinstr) + VDSO_LDFLAGS := $(VDSO_CPPFLAGS) # From arm vDSO Makefile VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 44/89 serial: mctrl_gpio: Check for NULL pointer
In reply to Sasha LevinFrom: Adam Ford <[email protected]>
[ Upstream commit 37e3ab00e4734acc15d96b2926aab55c894f4d9c ]
When using mctrl_gpio_to_gpiod, it dereferences gpios into a single requested GPIO. This dereferencing can break if gpios is NULL, so this patch adds a NULL check before dereferencing it. If gpios is NULL, this function will also return NULL.
--- drivers/tty/serial/serial_mctrl_gpio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/serial/serial_mctrl_gpio.c +3 -0
@@ -61,6 +61,9 @@ EXPORT_SYMBOL_GPL(mctrl_gpio_set);struct gpio_desc *mctrl_gpio_to_gpiod (struct mctrl_gpios *gpios,enum mctrl_gpio_idx gidx) { +if (gpios ==NULL ) +return NULL ; +return gpios->gpio[gidx]; }EXPORT_SYMBOL_GPL (mctrl_gpio_to_gpiod);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 45/89 serial: 8250_omap: Fix gpio check for auto RTS/CTS
In reply to Sasha LevinFrom: Adam Ford <[email protected]>
[ Upstream commit fc64f7abbef2dae7ee4c94702fb3cf9a2be5431a ]
There are two checks to see if the manual gpio is configured, but these the check is seeing if the structure is NULL instead it should check to see if there are CTS and/or RTS pins defined.
This patch uses checks for those individual pins instead of checking for the structure itself to restore auto RTS/CTS.
--- drivers/tty/serial/8250/8250_omap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +3 -2
@@ -141,7 +141,7 @@ static void omap8250_set_mctrl(struct uart_port *port, unsigned int mctrl)serial8250_do_set_mctrl (port, mctrl); -if (!up->gpios) { +if (!mctrl_gpio_to_gpiod (up->gpios,UART_GPIO_RTS )) {/* * Turn off autoRTS if RTS is lowered and restore autoRTS * setting if RTS is raised
@@ -456,7 +456,8 @@ static void omap_8250_set_termios(struct uart_port *port, up->port.status &= ~(UPSTAT_AUTOCTS |UPSTAT_AUTORTS |UPSTAT_AUTOXOFF );if (termios->c_cflag &CRTSCTS && up->port.flags &UPF_HARD_FLOW && - !up->gpios) { + !mctrl_gpio_to_gpiod (up->gpios,UART_GPIO_RTS ) && + !mctrl_gpio_to_gpiod (up->gpios,UART_GPIO_CTS )) {/* Enable AUTOCTS (autoRTS is enabled when RTS is raised) */ up->port.status |=UPSTAT_AUTOCTS |UPSTAT_AUTORTS ; priv->efr |=UART_EFR_CTS ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 46/89 arm64: Default to building compat vDSO with clang when CONFIG_CC_IS_CLANG
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit 24ee01a927bfe56c66429ec4b1df6955a814adc8 ]
Rather than force the use of GCC for the compat cross-compiler, instead extract the target from CROSS_COMPILE_COMPAT and pass it to clang if the main compiler is clang.
--- arch/arm64/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/Makefile +4 -0
@@ -47,7 +47,11 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif endif +ifeq ($(CONFIG_CC_IS_CLANG), y) +COMPATCC ?= $(CC) --target=$(notdir $(CROSS_COMPILE_COMPAT:%-=%)) +else COMPATCC ?= $(CROSS_COMPILE_COMPAT)gcc +endif export COMPATCC ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 47/89 arm64: vdso32: Don't use KBUILD_CPPFLAGS unconditionally
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit c71e88c437962c1ec43d4d23a0ebf4c9cf9bee0d ]
KBUILD_CPPFLAGS is defined differently depending on whether the main compiler is clang or not. This means that it is not possible to build the compat vDSO with GCC if the rest of the kernel is built with clang.
Define VDSO_CPPFLAGS directly to break this dependency and allow a clang kernel to build a compat vDSO with GCC:
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- CC=clang \
COMPATCC=arm-linux-gnueabihf-gcc--- arch/arm64/kernel/vdso32/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm64/kernel/vdso32/Makefile +2 -4
@@ -25,11 +25,9 @@ cc32-as-instr = $(call try-run,\ # arm64 one. # As a result we set our own flags here. -# From top-level Makefile -# NOSTDINC_FLAGS -VDSO_CPPFLAGS := -nostdinc -isystem $(shell $(COMPATCC) -print-file-name=include) +# KBUILD_CPPFLAGS and NOSTDINC_FLAGS from top-level Makefile +VDSO_CPPFLAGS := -D__KERNEL__ -nostdinc -isystem $(shell $(COMPATCC) -print-file-name=include) VDSO_CPPFLAGS += $(LINUXINCLUDE) -VDSO_CPPFLAGS += $(KBUILD_CPPFLAGS) # Common C and assembly flags # From top-level Makefile
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 48/89 efi/cper: Fix endianness of PCIe class code
In reply to Sasha LevinFrom: Lukas Wunner <[email protected]>
[ Upstream commit 6fb9367a15d1a126d222d738b2702c7958594a5f ]
The CPER parser assumes that the class code is big endian, but at least on this edk2-derived Intel Purley platform it's little endian:
efi: EFI v2.50 by EDK II BIOS ID:PLYDCRB1.86B.0119.R05.1701181843
DMI: Intel Corporation PURLEY/PURLEY, BIOS PLYDCRB1.86B.0119.R05.1701181843 01/18/2017
{1}[Hardware Error]: device_id: 0000:5d:00.0
{1}[Hardware Error]: slot: 0
{1}[Hardware Error]: secondary_bus: 0x5e
{1}[Hardware Error]: vendor_id: 0x8086, device_id: 0x2030
{1}[Hardware Error]: class_code: 000406
^^^^^^ (should be 060400)--- drivers/firmware/efi/cper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/cper.c +1 -1
@@ -381,7 +381,7 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,printk ("%s""vendor_id: 0x%04x, device_id: 0x%04x\n" , pfx, pcie->device_id.vendor_id, pcie->device_id.device_id); p = pcie->device_id.class_code; -printk ("%s""class_code: %02x%02x%02x\n" , pfx, p[0 ], p[1 ], p[2 ]); +printk ("%s""class_code: %02x%02x%02x\n" , pfx, p[2 ], p[1 ], p[0 ]); }if (pcie->validation_bits &CPER_PCIE_VALID_SERIAL_NUMBER ) printk("%s""serial number: 0x%04x, 0x%04x\n", pfx,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 49/89 efi/x86: Do not clean dummy variable in kexec path
In reply to Sasha LevinFrom: Dave Young <[email protected]>
[ Upstream commit 2ecb7402cfc7f22764e7bbc80790e66eadb20560 ]
kexec reboot fails randomly in UEFI based KVM guest. The firmware just resets while calling efi_delete_dummy_variable(); Unfortunately I don't know how to debug the firmware, it is also possible a potential problem on real hardware as well although nobody reproduced it.
The intention of the efi_delete_dummy_variable is to trigger garbage collection when entering virtual mode. But SetVirtualAddressMap can only run once for each physical reboot, thus kexec_enter_virtual_mode() is not necessarily a good place to clean a dummy object.
Drop the efi_delete_dummy_variable so that kexec reboot can work.
--- arch/x86/platform/efi/efi.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/platform/efi/efi.c +0 -3
@@ -894,9 +894,6 @@ static void __init kexec_enter_virtual_mode(void)if (efi_enabled (EFI_OLD_MEMMAP ) && (__supported_pte_mask & _PAGE_NX))runtime_code_page_mkexec (); - -/* clean DUMMY object */ -efi_delete_dummy_variable ();#endif }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 50/89 kbuild: fix build error of 'make nsdeps' in clean tree
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit d85103ac78a6d8573b21348b36f4cca2e1839a31 ]
Running 'make nsdeps' in a clean source tree fails as follows:
$ make -s clean; make -s defconfig; make nsdeps [ snip ] awk: fatal: cannot open file `init/modules.order' for reading (No such file or directory) make: *** [Makefile;1307: modules.order] Error 2 make: *** Deleting file 'modules.order' make: *** Waiting for unfinished jobs....
The cause of the error is 'make nsdeps' does not build modules at all. Set KBUILD_MODULES to fix it.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -594,7 +594,7 @@ endif # in addition to whatever we do anyway. # Just "make" or "make all" shall build modules as well -ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) +ifneq ($(filter all _all modules nsdeps,$(MAKECMDGOALS)),) KBUILD_MODULES := 1 endif
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.3 50/89] kbuild: fix build error of 'make nsdeps' in clean tree
Quoted 14 lines · Sasha Levin
From: Masahiro Yamada <[email protected]>
[ Upstream commit
d85103ac78a6d8573b21348b36f4cca2e1839a31]Running 'make nsdeps' in a clean source tree fails as follows:
$ make -s clean; make -s defconfig; make nsdeps [ snip ] awk: fatal: cannot open file `init/modules.order' for reading (No such file or directory) make: *** [Makefile;1307: modules.order] Error 2 make: *** Deleting file 'modules.order' make: *** Waiting for unfinished jobs....
Quoted 8 lines
The cause of the error is 'make nsdeps' does not build modules at all. Set
KBUILD_MODULESto fix it.Reviewed-by Matthias Maennich <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>Signed-off-by Jessica Yu <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
nsdeps was introduced in v5.4
Please do not backport this commit.
Quoted 19 lines
Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Makefile +1
-2@@ -594,7 +594,7 @@ endif # in addition to whatever we do anyway. # Just "make" or "make all" shall build modules as well -ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) +ifneq ($(filter all _all modules nsdeps,$(MAKECMDGOALS)),) KBUILD_MODULES := 1 endif --2.20.1
Signature · 2 lines
Best Regards Masahiro Yamada
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.3 50/89] kbuild: fix build error of 'make nsdeps' in clean tree
Quoted 24 lines · Masahiro Yamada
Quoted 14 lines · Sasha Levin
From: Masahiro Yamada <[email protected]>
[ Upstream commit
d85103ac78a6d8573b21348b36f4cca2e1839a31]Running 'make nsdeps' in a clean source tree fails as follows:
$ make -s clean; make -s defconfig; make nsdeps [ snip ] awk: fatal: cannot open file `init/modules.order' for reading (No such file or directory) make: *** [Makefile;1307: modules.order] Error 2 make: *** Deleting file 'modules.order' make: *** Waiting for unfinished jobs....Quoted 8 lines
The cause of the error is 'make nsdeps' does not build modules at all. Set
KBUILD_MODULESto fix it.Reviewed-by Matthias Maennich <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>Signed-off-by Jessica Yu <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Quoted 3 lines
nsdeps was introduced in v5.4
Please do not backport this commit.
I've dropped it everywhere, thank you.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 51/89 MIPS: include: Mark __cmpxchg as __always_inline
In reply to Sasha LevinFrom: Thomas Bogendoerfer <[email protected]>
[ Upstream commit 88356d09904bc606182c625575237269aeece22e ]
Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly") allows compiler to uninline functions marked as 'inline'. In cace of cmpxchg this would cause to reference function __cmpxchg_called_with_bad_pointer, which is a error case for catching bugs and will not happen for correct code, if __cmpxchg is inlined.
--- arch/mips/include/asm/cmpxchg.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/include/asm/cmpxchg.h +3 -2
@@ -153,8 +153,9 @@ static inline unsigned long __xchg(volatile void *ptr, unsigned long x,extern unsigned long __cmpxchg_small (volatile void *ptr,unsigned long old,unsigned long new,unsigned int size); -static inline unsigned long __cmpxchg (volatile void *ptr,unsigned long old, -unsigned long new,unsigned int size) +static __always_inline +unsigned long __cmpxchg (volatile void *ptr,unsigned long old, +unsigned long new,unsigned int size) {switch (size) {case 1 :
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 52/89 riscv: avoid kernel hangs when trapped in BUG()
In reply to Sasha LevinFrom: Vincent Chen <[email protected]>
[ Upstream commit 8b04825ed205da38754f86f4c07ea8600d8c2a65 ]
When the CONFIG_GENERIC_BUG is disabled by disabling CONFIG_BUG, if a kernel thread is trapped by BUG(), the whole system will be in the loop that infinitely handles the ebreak exception instead of entering the die function. To fix this problem, the do_trap_break() will always call the die() to deal with the break exception as the type of break is BUG_TRAP_TYPE_BUG.
--- arch/riscv/kernel/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/kernel/traps.c +3 -3
@@ -124,23 +124,23 @@ static inline unsigned long get_break_insn_length(unsigned long pc) asmlinkage void do_trap_break(struct pt_regs *regs) { -#ifdef CONFIG_GENERIC_BUG if (!user_mode (regs)) {enum bug_trap_type type; type =report_bug (regs->sepc, regs);switch (type) { +#ifdef CONFIG_GENERIC_BUG case BUG_TRAP_TYPE_NONE :break ;case BUG_TRAP_TYPE_WARN : regs->sepc +=get_break_insn_length (regs->sepc);break ;case BUG_TRAP_TYPE_BUG : +#endif /* CONFIG_GENERIC_BUG */ +default :die (regs,"Kernel BUG" ); } } -#endif /* CONFIG_GENERIC_BUG */ -force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)(regs->sepc)); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 53/89 riscv: avoid sending a SIGTRAP to a user thread trapped in WARN()
In reply to Sasha LevinFrom: Vincent Chen <[email protected]>
[ Upstream commit e0c0fc18f10d5080cddde0e81505fd3e952c20c4 ]
On RISC-V, when the kernel runs code on behalf of a user thread, and the kernel executes a WARN() or WARN_ON(), the user thread will be sent a bogus SIGTRAP. Fix the RISC-V kernel code to not send a SIGTRAP when a WARN()/WARN_ON() is executed.
--- arch/riscv/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/traps.c +1 -1
@@ -134,7 +134,7 @@ asmlinkage void do_trap_break(struct pt_regs *regs)break ;case BUG_TRAP_TYPE_WARN : regs->sepc +=get_break_insn_length (regs->sepc); -break ; +return ;case BUG_TRAP_TYPE_BUG :#endif /* CONFIG_GENERIC_BUG */ default :
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 54/89 riscv: Correct the handling of unexpected ebreak in do_trap_break()
In reply to Sasha LevinFrom: Vincent Chen <[email protected]>
[ Upstream commit 8bb0daef64e5a92db63ad1d3bbf9e280a7b3612a ]
For the kernel space, all ebreak instructions are determined at compile time because the kernel space debugging module is currently unsupported. Hence, it should be treated as a bug if an ebreak instruction which does not belong to BUG_TRAP_TYPE_WARN or BUG_TRAP_TYPE_BUG is executed in kernel space. For the userspace, debugging module or user problem may intentionally insert an ebreak instruction to trigger a SIGTRAP signal. To approach the above two situations, the do_trap_break() will direct the BUG_TRAP_TYPE_NONE ebreak exception issued in kernel space to die() and will send a SIGTRAP to the trapped process only when the ebreak is in userspace.
--- arch/riscv/kernel/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/kernel/traps.c +3 -3
@@ -130,8 +130,6 @@ asmlinkage void do_trap_break(struct pt_regs *regs) type =report_bug (regs->sepc, regs);switch (type) {#ifdef CONFIG_GENERIC_BUG -case BUG_TRAP_TYPE_NONE : -break ;case BUG_TRAP_TYPE_WARN : regs->sepc +=get_break_insn_length (regs->sepc);return ;
@@ -140,8 +138,10 @@ asmlinkage void do_trap_break(struct pt_regs *regs)default :die (regs,"Kernel BUG" ); } + }else { +force_sig_fault (SIGTRAP ,TRAP_BRKPT , + (void __user *)(regs->sepc)); } -force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)(regs->sepc)); }#ifdef CONFIG_GENERIC_BUG
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 55/89 x86/xen: Return from panic notifier
In reply to Sasha LevinFrom: Boris Ostrovsky <[email protected]>
[ Upstream commit c6875f3aacf2a5a913205accddabf0bfb75cac76 ]
Currently execution of panic() continues until Xen's panic notifier (xen_panic_event()) is called at which point we make a hypercall that never returns.
This means that any notifier that is supposed to be called later as well as significant part of panic() code (such as pstore writes from kmsg_dump()) is never executed.
There is no reason for xen_panic_event() to be this last point in execution since panic()'s emergency_restart() will call into xen_emergency_restart() from where we can perform our hypercall.
Nevertheless, we will provide xen_legacy_crash boot option that will preserve original behavior during crash. This option could be used, for example, if running kernel dumper (which happens after panic notifiers) is undesirable.
--- .../admin-guide/kernel-parameters.txt | 4 +++ arch/x86/xen/enlighten.c | 28 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +4 -0
@@ -5267,6 +5267,10 @@ the unplug protocol never -- do not unplug even if version check succeeds + xen_legacy_crash [X86,XEN] + Crash from Xen panic notifier, without executing late + panic() code such as dumping handler. + xen_nopvspin [X86,XEN] Disables the ticketlock slowpath using Xen PV optimizations.
arch/x86/xen/enlighten.c +25 -3
@@ -269,19 +269,41 @@ void xen_reboot(int reason)BUG (); } +static int reboot_reason = SHUTDOWN_reboot; +static bool xen_legacy_crash;void xen_emergency_restart (void ) { -xen_reboot (SHUTDOWN_reboot); +xen_reboot (reboot_reason); }static int xen_panic_event (struct notifier_block *this,unsigned long event,void *ptr) { -if (!kexec_crash_loaded ()) -xen_reboot (SHUTDOWN_crash); +if (!kexec_crash_loaded ()) { +if (xen_legacy_crash) +xen_reboot (SHUTDOWN_crash); + + reboot_reason = SHUTDOWN_crash; + +/* +* If panic_timeout==0 then we are supposed to wait forever. +* However, to preserve original dom0 behavior we have to drop +* into hypervisor. (domU behavior is controlled by its +* config file) +*/ +if (panic_timeout ==0 ) + panic_timeout =-1 ; + }return NOTIFY_DONE ; } +static int __init parse_xen_legacy_crash (char *arg) +{ + xen_legacy_crash = true; +return 0 ; +} +early_param ("xen_legacy_crash" , parse_xen_legacy_crash); +static struct notifier_block xen_panic_block = { .notifier_call = xen_panic_event, .priority =INT_MIN
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 56/89 ocfs2: clear zero in unaligned direct IO
In reply to Sasha LevinFrom: Jia Guo <[email protected]>
[ Upstream commit 7a243c82ea527cd1da47381ad9cd646844f3b693 ]
Unused portion of a part-written fs-block-sized block is not set to zero in unaligned append direct write.This can lead to serious data inconsistencies.
Ocfs2 manage disk with cluster size(for example, 1M), part-written in one cluster will change the cluster state from UN-WRITTEN to WRITTEN, VFS(function dio_zero_block) doesn't do the cleaning because bh's state is not set to NEW in function ocfs2_dio_wr_get_block when we write a WRITTEN cluster. For example, the cluster size is 1M, file size is 8k and we direct write from 14k to 15k, then 12k~14k and 15k~16k will contain dirty data.
We have to deal with two cases:
1.The starting position of direct write is outside the file. 2.The starting position of direct write is located in the file.
We need set bh's state to NEW in the first case. In the second case, we need mapped twice because bh's state of area out file should be set to NEW while area in file not.
--- fs/ocfs2/aops.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
fs/ocfs2/aops.c +21 -1
@@ -2139,13 +2139,30 @@ static int ocfs2_dio_wr_get_block(struct inode *inode, sector_t iblock,struct ocfs2_dio_write_ctxt *dwc =NULL ;struct buffer_head *di_bh =NULL ;u64 p_blkno; -loff_t pos = iblock << inode->i_sb->s_blocksize_bits; +unsigned int i_blkbits = inode->i_sb->s_blocksize_bits; +loff_t pos = iblock << i_blkbits; +sector_t endblk = (i_size_read (inode) -1 ) >> i_blkbits;unsigned len, total_len = bh_result->b_size;int ret =0 , first_get_block =0 ; len = osb->s_clustersize - (pos & (osb->s_clustersize -1 )); len =min (total_len, len); +/* +* bh_result->b_size is count in get_more_blocks according to write +* "pos" and "end", we need map twice to return different buffer state: +* 1. area in file size, not set NEW; +* 2. area out file size, set NEW. +* +* iblock endblk +* |--------|---------|---------|--------- +* |<-------area in file------->| +*/ + +if ((iblock <= endblk) && + ((iblock + ((len -1 ) >> i_blkbits)) > endblk)) + len = (endblk - iblock +1 ) << i_blkbits; +mlog (0 ,"get block of %lu at %llu:%u req %u\n" , inode->i_ino, pos, len, total_len);
@@ -2229,6 +2246,9 @@ static int ocfs2_dio_wr_get_block(struct inode *inode, sector_t iblock,if (desc->c_needs_zero)set_buffer_new (bh_result); +if (iblock > endblk) +set_buffer_new (bh_result); +/* May sleep in end_io. It should not happen in a irq context. So defer * it to dio work queue. */ set_buffer_defer_completion (bh_result);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 57/89 fs: ocfs2: fix possible null-pointer dereferences in ocfs2_xa_prepare_entry()
In reply to Sasha LevinFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 56e94ea132bb5c2c1d0b60a6aeb34dcb7d71a53d ]
In ocfs2_xa_prepare_entry(), there is an if statement on line 2136 to check whether loc->xl_entry is NULL:
if (loc->xl_entry)
When loc->xl_entry is NULL, it is used on line 2158:
ocfs2_xa_add_entry(loc, name_hash);
loc->xl_entry->xe_name_hash = cpu_to_le32(name_hash);
loc->xl_entry->xe_name_offset = cpu_to_le16(loc->xl_size);and line 2164:
ocfs2_xa_add_namevalue(loc, xi);
loc->xl_entry->xe_value_size = cpu_to_le64(xi->xi_value_len);
loc->xl_entry->xe_name_len = xi->xi_name_len;Thus, possible null-pointer dereferences may occur.
To fix these bugs, if loc-xl_entry is NULL, ocfs2_xa_prepare_entry() abnormally returns with -EINVAL.
These bugs are found by a static analysis tool STCheck written by us.
--- fs/ocfs2/xattr.c | 56 ++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 33 deletions(-)
fs/ocfs2/xattr.c +23 -33
@@ -1490,18 +1490,6 @@ static int ocfs2_xa_check_space(struct ocfs2_xa_loc *loc,return loc->xl_ops->xlo_check_space (loc, xi); } -static void ocfs2_xa_add_entry (struct ocfs2_xa_loc *loc,u32 name_hash) -{ - loc->xl_ops->xlo_add_entry (loc, name_hash); - loc->xl_entry->xe_name_hash =cpu_to_le32 (name_hash); -/* -* We can't leave the new entry's xe_name_offset at zero or -* add_namevalue() will go nuts. We set it to the size of our -* storage so that it can never be less than any other entry. -*/ - loc->xl_entry->xe_name_offset =cpu_to_le16 (loc->xl_size); -} -static void ocfs2_xa_add_namevalue (struct ocfs2_xa_loc *loc,struct ocfs2_xattr_info *xi) {
@@ -2133,29 +2121,31 @@ static int ocfs2_xa_prepare_entry(struct ocfs2_xa_loc *loc,if (rc) goto out; -if (loc->xl_entry) { -if (ocfs2_xa_can_reuse_entry (loc, xi)) { - orig_value_size = loc->xl_entry->xe_value_size; - rc =ocfs2_xa_reuse_entry (loc, xi, ctxt); -if (rc) - goto out; - goto alloc_value; - } +if (!loc->xl_entry) { + rc = -EINVAL ; + goto out; + } -if (!ocfs2_xattr_is_local (loc->xl_entry)) { - orig_clusters =ocfs2_xa_value_clusters (loc); - rc =ocfs2_xa_value_truncate (loc,0 , ctxt); -if (rc) { -mlog_errno (rc); -ocfs2_xa_cleanup_value_truncate (loc, -"overwriting" , - orig_clusters); - goto out; - } +if (ocfs2_xa_can_reuse_entry (loc, xi)) { + orig_value_size = loc->xl_entry->xe_value_size; + rc =ocfs2_xa_reuse_entry (loc, xi, ctxt); +if (rc) + goto out; + goto alloc_value; + } + +if (!ocfs2_xattr_is_local (loc->xl_entry)) { + orig_clusters =ocfs2_xa_value_clusters (loc); + rc =ocfs2_xa_value_truncate (loc,0 , ctxt); +if (rc) { +mlog_errno (rc); +ocfs2_xa_cleanup_value_truncate (loc, +"overwriting" , + orig_clusters); + goto out; } -ocfs2_xa_wipe_namevalue (loc); - }else -ocfs2_xa_add_entry (loc, name_hash); + } +ocfs2_xa_wipe_namevalue (loc);/* * If we get here, we have a blank entry. Fill it. We grow our
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 58/89 fs: ocfs2: fix a possible null-pointer dereference in ocfs2_write_end_nolock()
In reply to Sasha LevinFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 583fee3e12df0e6f1f66f063b989d8e7fed0e65a ]
In ocfs2_write_end_nolock(), there are an if statement on lines 1976, 2047 and 2058, to check whether handle is NULL:
if (handle)
When handle is NULL, it is used on line 2045:
ocfs2_update_inode_fsync_trans(handle, inode, 1);
oi->i_sync_tid = handle->h_transaction->t_tid;Thus, a possible null-pointer dereference may occur.
To fix this bug, handle is checked before callingocfs2_update_inode_fsync_trans().
This bug is found by a static analysis tool STCheck written by us.
--- fs/ocfs2/aops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ocfs2/aops.c +2 -1
@@ -2042,7 +2042,8 @@ int ocfs2_write_end_nolock(struct address_space *mapping, inode->i_mtime = inode->i_ctime =current_time (inode); di->i_mtime = di->i_ctime =cpu_to_le64 (inode->i_mtime.tv_sec); di->i_mtime_nsec = di->i_ctime_nsec =cpu_to_le32 (inode->i_mtime.tv_nsec); -ocfs2_update_inode_fsync_trans (handle, inode,1 ); +if (handle) +ocfs2_update_inode_fsync_trans (handle, inode,1 ); }if (handle)ocfs2_journal_dirty (handle, wc->w_di_bh);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 59/89 fs: ocfs2: fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc()
In reply to Sasha LevinFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 2abb7d3b12d007c30193f48bebed781009bebdd2 ]
In ocfs2_info_scan_inode_alloc(), there is an if statement on line 283 to check whether inode_alloc is NULL:
if (inode_alloc)
When inode_alloc is NULL, it is used on line 287:
ocfs2_inode_lock(inode_alloc, &bh, 0);
ocfs2_inode_lock_full_nested(inode, ...)
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);Thus, a possible null-pointer dereference may occur.
To fix this bug, inode_alloc is checked on line 286.
This bug is found by a static analysis tool STCheck written by us.
--- fs/ocfs2/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/ioctl.c +1 -1
@@ -283,7 +283,7 @@ static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb,if (inode_alloc)inode_lock (inode_alloc); -if (o2info_coherent (&fi->ifi_req)) { +if (inode_alloc &&o2info_coherent (&fi->ifi_req)) { status =ocfs2_inode_lock (inode_alloc, &bh,0 );if (status <0 ) {mlog_errno (status);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 60/89 btrfs: silence maybe-uninitialized warning in clone_range
In reply to Sasha LevinFrom: Austin Kim <[email protected]>
[ Upstream commit 431d39887d6273d6d84edf3c2eab09f4200e788a ]
GCC throws warning message as below:
‘clone_src_i_size’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
^fs/btrfs/send.c:5088:6: note: ‘clone_src_i_size’ was declared here
u64 clone_src_i_size;
^
The clone_src_i_size is only used as call-by-reference in a call to get_inode_info().
Silence the warning by initializing clone_src_i_size to 0.
Note that the warning is a false positive and reported by older versions of GCC (eg. 7.x) but not eg 9.x. As there have been numerous people, the patch is applied. Setting clone_src_i_size to 0 does not otherwise make sense and would not do any action in case the code changes in the future.
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +1 -1
@@ -5070,7 +5070,7 @@ static int clone_range(struct send_ctx *sctx,struct btrfs_path *path;struct btrfs_key key;int ret; -u64 clone_src_i_size; +u64 clone_src_i_size =0 ;/* * Prevent cloning from a zero offset with a length matching the sector
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 61/89 arm64: armv8_deprecated: Checking return value for memory allocation
In reply to Sasha LevinFrom: Yunfeng Ye <[email protected]>
[ Upstream commit 3e7c93bd04edfb0cae7dad1215544c9350254b8f ]
There are no return value checking when using kzalloc() and kcalloc() for memory allocation. so add it.
--- arch/arm64/kernel/armv8_deprecated.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/kernel/armv8_deprecated.c +5 -0
@@ -174,6 +174,9 @@ static void __init register_insn_emulation(struct insn_emulation_ops *ops)struct insn_emulation *insn; insn =kzalloc (sizeof (*insn),GFP_KERNEL ); +if (!insn) +return ; + insn->ops = ops; insn->min =INSN_UNDEF ;
@@ -233,6 +236,8 @@ static void __init register_insn_emulation_sysctl(void) insns_sysctl =kcalloc (nr_insn_emulated +1 ,sizeof (*sysctl),GFP_KERNEL ); +if (!insns_sysctl) +return ;raw_spin_lock_irqsave (&insn_emulation_lock, flags);list_for_each_entry (insn, &insn_emulation, node) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 62/89 x86/cpu: Add Comet Lake to the Intel CPU models header
In reply to Sasha LevinFrom: Kan Liang <[email protected]>
[ Upstream commit 8d7c6ac3b2371eb1cbc9925a88f4d10efff374de ]
Comet Lake is the new 10th Gen Intel processor. Add two new CPU model numbers to the Intel family list.
The CPU model numbers are not published in the SDM yet but they come from an authoritative internal source.
[ bp: Touch up commit message. ]
--- arch/x86/include/asm/intel-family.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/intel-family.h +3 -0
@@ -76,6 +76,9 @@#define INTEL_FAM6_TIGERLAKE_L 0x8C#define INTEL_FAM6_TIGERLAKE 0x8D +#define INTEL_FAM6_COMETLAKE 0xA5 +#define INTEL_FAM6_COMETLAKE_L 0xA6 +/* "Small Core" Processors (Atom) */ #define INTEL_FAM6_ATOM_BONNELL 0x1C/* Diamondville, Pineview */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 63/89 sched/fair: Scale bandwidth quota and period without losing quota/period ratio precision
In reply to Sasha LevinFrom: Xuewei Zhang <[email protected]>
[ Upstream commit 4929a4e6faa0f13289a67cae98139e727f0d4a97 ]
The quota/period ratio is used to ensure a child task group won't get more bandwidth than the parent task group, and is calculated as:
normalized_cfs_quota() = [(quota_us << 20) / period_us]
If the quota/period ratio was changed during this scaling due to precision loss, it will cause inconsistency between parent and child task groups.
See below example:
A userspace container manager (kubelet) does three operations:
1) Create a parent cgroup, set quota to 1,000us and period to 10,000us.
2) Create a few children cgroups.
3) Set quota to 1,000us and period to 10,000us on a child cgroup.
These operations are expected to succeed. However, if the scaling of 147/128 happens before step 3, quota and period of the parent cgroup will be changed:
new_quota: 1148437ns, 1148us
new_period: 11484375ns, 11484us
And when step 3 comes in, the ratio of the child cgroup will be 104857, which will be larger than the parent cgroup ratio (104821), and will fail.
Scaling them by a factor of 2 will fix the problem.
--- kernel/sched/fair.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
kernel/sched/fair.c +22 -14
@@ -4995,20 +4995,28 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer)if (++count >3 ) {u64 new, old =ktime_to_ns (cfs_b->period); - new = (old *147 ) /128 ;/* ~115% */ - new =min (new, max_cfs_quota_period); - - cfs_b->period =ns_to_ktime (new); - -/* since max is 1s, this is limited to 1e9^2, which fits in u64 */ - cfs_b->quota *= new; - cfs_b->quota =div64_u64 (cfs_b->quota, old); - -pr_warn_ratelimited ( -"cfs_period_timer[cpu%d]: period too short, scaling up (new cfs_period_us %lld, cfs_quota_us = %lld)\n" , -smp_processor_id (), -div_u64 (new,NSEC_PER_USEC ), -div_u64 (cfs_b->quota,NSEC_PER_USEC )); +/* +* Grow period by a factor of 2 to avoid losing precision. +* Precision loss in the quota/period ratio can cause __cfs_schedulable +* to fail. +*/ + new = old *2 ; +if (new < max_cfs_quota_period) { + cfs_b->period =ns_to_ktime (new); + cfs_b->quota *=2 ; + +pr_warn_ratelimited ( +"cfs_period_timer[cpu%d]: period too short, scaling up (new cfs_period_us = %lld, cfs_quota_us = %lld)\n" , +smp_processor_id (), +div_u64 (new,NSEC_PER_USEC ), +div_u64 (cfs_b->quota,NSEC_PER_USEC )); + }else { +pr_warn_ratelimited ( +"cfs_period_timer[cpu%d]: period too short, but cannot scale up without losing precision (cfs_period_us = %lld, cfs_quota_us = %lld)\n" , +smp_processor_id (), +div_u64 (old,NSEC_PER_USEC ), +div_u64 (cfs_b->quota,NSEC_PER_USEC )); + }/* reset count so we don't come right back in here */ count =0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 64/89 sched/vtime: Fix guest/system mis-accounting on task switch
In reply to Sasha LevinFrom: Frederic Weisbecker <[email protected]>
[ Upstream commit 68e7a4d66b0ce04bf18ff2ffded5596ab3618585 ]
vtime_account_system() assumes that the target task to account cputime to is always the current task. This is most often true indeed except on task switch where we call:
vtime_common_task_switch(prev)
vtime_account_system(prev)
Here prev is the scheduling-out task where we account the cputime to. It doesn't match current that is already the scheduling-in task at this stage of the context switch.
So we end up checking the wrong task flags to determine if we are accounting guest or system time to the previous task.
As a result the wrong task is used to check if the target is running in guest mode. We may then spuriously account or leak either system or guest time on task switch.
Fix this assumption and also turn vtime_guest_enter/exit() to use the task passed in parameter as well to avoid future similar issues.
--- kernel/sched/cputime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/cputime.c +3 -3
@@ -740,7 +740,7 @@ void vtime_account_system(struct task_struct *tsk)write_seqcount_begin (&vtime->seqcount);/* We might have scheduled out from guest path */ -if (current->flags &PF_VCPU ) +if (tsk->flags &PF_VCPU )vtime_account_guest (tsk, vtime);else __vtime_account_system (tsk, vtime);
@@ -783,7 +783,7 @@ void vtime_guest_enter(struct task_struct *tsk)*/ write_seqcount_begin (&vtime->seqcount);__vtime_account_system (tsk, vtime); - current->flags |=PF_VCPU ; + tsk->flags |=PF_VCPU ;write_seqcount_end (&vtime->seqcount); }EXPORT_SYMBOL_GPL (vtime_guest_enter);
@@ -794,7 +794,7 @@ void vtime_guest_exit(struct task_struct *tsk)write_seqcount_begin (&vtime->seqcount);vtime_account_guest (tsk, vtime); - current->flags &= ~PF_VCPU ; + tsk->flags &= ~PF_VCPU ;write_seqcount_end (&vtime->seqcount); }EXPORT_SYMBOL_GPL (vtime_guest_exit);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 65/89 perf/core: Rework memory accounting in perf_mmap()
In reply to Sasha LevinFrom: Song Liu <[email protected]>
[ Upstream commit d44248a41337731a111374822d7d4451b64e73e4 ]
perf_mmap() always increases user->locked_vm. As a result, "extra" could grow bigger than "user_extra", which doesn't make sense. Here is an example case:
(Note: Assume "user_lock_limit" is very small.)
| # of perf_mmap calls |vma->vm_mm->pinned_vm|user->locked_vm| | 0 | 0 | 0 | | 1 | user_extra | user_extra | | 2 | 3 * user_extra | 2 * user_extra| | 3 | 6 * user_extra | 3 * user_extra| | 4 | 10 * user_extra | 4 * user_extra|
Fix this by maintaining proper user_extra and extra.
--- kernel/events/core.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
kernel/events/core.c +15 -2
@@ -5585,7 +5585,8 @@ static void perf_mmap_close(struct vm_area_struct *vma)* undo the VM accounting. */ -atomic_long_sub ((size >>PAGE_SHIFT ) +1 , &mmap_user->locked_vm); +atomic_long_sub ((size >>PAGE_SHIFT ) +1 - mmap_locked, + &mmap_user->locked_vm);atomic64_sub (mmap_locked, &vma->vm_mm->pinned_vm);free_uid (mmap_user);
@@ -5729,8 +5730,20 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) user_locked =atomic_long_read (&user->locked_vm) + user_extra; -if (user_locked > user_lock_limit) +if (user_locked <= user_lock_limit) { +/* charge all to locked_vm */ + }else if (atomic_long_read (&user->locked_vm) >= user_lock_limit) { +/* charge all to pinned_vm */ + extra = user_extra; + user_extra =0 ; + }else { +/* +* charge locked_vm until it hits user_lock_limit; +* charge the rest from pinned_vm +*/ extra = user_locked - user_lock_limit; + user_extra -= extra; + } lock_limit =rlimit (RLIMIT_MEMLOCK ); lock_limit >>=PAGE_SHIFT ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 66/89 perf/core: Fix corner case in perf_rotate_context()
In reply to Sasha LevinFrom: Song Liu <[email protected]>
[ Upstream commit 7fa343b7fdc4f351de4e3f28d5c285937dd1f42f ]
In perf_rotate_context(), when the first cpu flexible event fail to schedule, cpu_rotate is 1, while cpu_event is NULL. Since cpu_event is NULL, perf_rotate_context will _NOT_ call cpu_ctx_sched_out(), thus cpuctx->ctx.is_active will have EVENT_FLEXIBLE set. Then, the next perf_event_sched_in() will skip all cpu flexible events because of the EVENT_FLEXIBLE bit.
In the next call of perf_rotate_context(), cpu_rotate stays 1, and cpu_event stays NULL, so this process repeats. The end result is, flexible events on this cpu will not be scheduled (until another event being added to the cpuctx).
Here is an easy repro of this issue. On Intel CPUs, where ref-cycles could only use one counter, run one pinned event for ref-cycles, one flexible event for ref-cycles, and one flexible event for cycles. The flexible ref-cycles is never scheduled, which is expected. However, because of this issue, the cycles event is never scheduled either.
$ perf stat -e ref-cycles:D,ref-cycles,cycles -C 5 -I 1000
time counts unit events
1.000152973 15,412,480 ref-cycles:D
1.000152973 <not counted> ref-cycles (0.00%)
1.000152973 <not counted> cycles (0.00%)
2.000486957 18,263,120 ref-cycles:D
2.000486957 <not counted> ref-cycles (0.00%)
2.000486957 <not counted> cycles (0.00%)To fix this, when the flexible_active list is empty, try rotate the first event in the flexible_groups. Also, rename ctx_first_active() to ctx_event_to_rotate(), which is more accurate.
--- kernel/events/core.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
kernel/events/core.c +17 -5
@@ -3694,11 +3694,23 @@ static void rotate_ctx(struct perf_event_context *ctx, struct perf_event *event)perf_event_groups_insert (&ctx->flexible_groups, event); } +/* pick an event from the flexible_groups to rotate */ static inline struct perf_event * -ctx_first_active (struct perf_event_context *ctx) +ctx_event_to_rotate (struct perf_event_context *ctx) { -return list_first_entry_or_null (&ctx->flexible_active, - struct perf_event, active_list); +struct perf_event *event; + +/* pick the first active flexible event */ + event =list_first_entry_or_null (&ctx->flexible_active, + struct perf_event, active_list); + +/* if no active flexible event, pick the first event */ +if (!event) { + event =rb_entry_safe (rb_first (&ctx->flexible_groups.tree), +typeof (*event), group_node); + } + +return event; }static bool perf_rotate_context (struct perf_cpu_context *cpuctx)
@@ -3723,9 +3735,9 @@ static bool perf_rotate_context(struct perf_cpu_context *cpuctx)perf_pmu_disable (cpuctx->ctx.pmu);if (task_rotate) - task_event =ctx_first_active (task_ctx); + task_event =ctx_event_to_rotate (task_ctx);if (cpu_rotate) - cpu_event =ctx_first_active (&cpuctx->ctx); + cpu_event =ctx_event_to_rotate (&cpuctx->ctx);/* * As per the order given at ctx_resched() first 'pop' task flexible
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 67/89 perf/x86/amd: Change/fix NMI latency mitigation to use a timestamp
In reply to Sasha LevinFrom: Tom Lendacky <[email protected]>
[ Upstream commit df4d29732fdad43a51284f826bec3e6ded177540 ]
It turns out that the NMI latency workaround from commit:
6d3edaae16c6 ("x86/perf/amd: Resolve NMI latency issues for active PMCs")
ends up being too conservative and results in the perf NMI handler claiming NMIs too easily on AMD hardware when the NMI watchdog is active.
This has an impact, for example, on the hpwdt (HPE watchdog timer) module. This module can produce an NMI that is used to reset the system. It registers an NMI handler for the NMI_UNKNOWN type and relies on the fact that nothing has claimed an NMI so that its handler will be invoked when the watchdog device produces an NMI. After the referenced commit, the hpwdt module is unable to process its generated NMI if the NMI watchdog is active, because the current NMI latency mitigation results in the NMI being claimed by the perf NMI handler.
Update the AMD perf NMI latency mitigation workaround to, instead, use a window of time. Whenever a PMC is handled in the perf NMI handler, set a timestamp which will act as a perf NMI window. Any NMIs arriving within that window will be claimed by perf. Anything outside that window will not be claimed by perf. The value for the NMI window is set to 100 msecs. This is a conservative value that easily covers any NMI latency in the hardware. While this still results in a window in which the hpwdt module will not receive its NMI, the window is now much, much smaller.
--- arch/x86/events/amd/core.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
arch/x86/events/amd/core.c +17 -13
@@ -5,12 +5,14 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/delay.h> +#include <linux/jiffies.h> #include <asm/apicdef.h> #include <asm/nmi.h> #include "../perf_event.h" -static DEFINE_PER_CPU(unsigned int, perf_nmi_counter); +static DEFINE_PER_CPU(unsigned long, perf_nmi_tstamp); +static unsigned long perf_nmi_window;static __initconst const u64 amd_hw_cache_event_ids [PERF_COUNT_HW_CACHE_MAX ]
@@ -641,11 +643,12 @@ static void amd_pmu_disable_event(struct perf_event *event)* handler when multiple PMCs are active or PMC overflow while handling some * other source of an NMI. * -* Attempt to mitigate this by using the number of active PMCs to determine -* whether to return NMI_HANDLED if the perf NMI handler did not handle/reset -* any PMCs. The per-CPU perf_nmi_counter variable is set to a minimum of the -* number of active PMCs or 2. The value of 2 is used in case an NMI does not -* arrive at the LAPIC in time to be collapsed into an already pending NMI. +* Attempt to mitigate this by creating an NMI window in which un-handled NMIs +* received during this window will be claimed. This prevents extending the +* window past when it is possible that latent NMIs should be received. The +* per-CPU perf_nmi_tstamp will be set to the window end time whenever perf has +* handled a counter. When an un-handled NMI is received, it will be claimed +* only if arriving within that window. */ static int amd_pmu_handle_irq (struct pt_regs *regs) {
@@ -663,21 +666,19 @@ static int amd_pmu_handle_irq(struct pt_regs *regs) handled =x86_pmu_handle_irq (regs);/* -* If a counter was handled, record the number of possible remaining -* NMIs that can occur. +* If a counter was handled, record a timestamp such that un-handled +* NMIs will be claimed if arriving within that window. */ if (handled) { -this_cpu_write (perf_nmi_counter, - min_t(unsigned int, 2, active)); +this_cpu_write (perf_nmi_tstamp, + jiffies + perf_nmi_window);return handled; } -if (!this_cpu_read (perf_nmi_counter)) +if (time_after (jiffies,this_cpu_read (perf_nmi_tstamp)))return NMI_DONE ; -this_cpu_dec (perf_nmi_counter); -return NMI_HANDLED ; }
@@ -909,6 +910,9 @@ static int __init amd_core_pmu_init(void)if (!boot_cpu_has (X86_FEATURE_PERFCTR_CORE ))return 0 ; +/* Avoid calulating the value each time in the NMI handler */ + perf_nmi_window =msecs_to_jiffies (100 ); +switch (boot_cpu_data.x86) {case 0x15 :pr_cont ("Fam15h " );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 68/89 drm/amdgpu: fix memory leak
In reply to Sasha LevinFrom: Nirmoy Das <[email protected]>
[ Upstream commit 083164dbdb17c5ea4ad92c1782b59c9d75567790 ]
cleanup error handling code and make sure temporary info array with the handles are freed by amdgpu_bo_list_put() on idr_replace()'s failure.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +7 -7
@@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r =amdgpu_bo_create_list_entry_array (&args->in, &info);if (r) - goto error_free; +return r;switch (args->in.operation) {case AMDGPU_BO_LIST_OP_CREATE :
@@ -283,8 +283,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL );mutex_unlock (&fpriv->bo_list_lock);if (r <0 ) { -amdgpu_bo_list_put (list); -return r; + goto error_put_list; } handle = r;
@@ -306,9 +305,8 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,mutex_unlock (&fpriv->bo_list_lock);if (IS_ERR (old)) { -amdgpu_bo_list_put (list); r =PTR_ERR (old); - goto error_free; + goto error_put_list; }amdgpu_bo_list_put (old);
@@ -325,8 +323,10 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,return 0 ; +error_put_list: +amdgpu_bo_list_put (list); + error_free: -if (info) -kvfree (info); +kvfree (info);return r; }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 69/89 iio: adc: hx711: fix bug in sampling of data
In reply to Sasha LevinFrom: Andreas Klinger <[email protected]>
[ Upstream commit 4043ecfb5fc4355a090111e14faf7945ff0fdbd5 ]
Fix bug in sampling function hx711_cycle() when interrupt occures while PD_SCK is high. If PD_SCK is high for at least 60 us power down mode of the sensor is entered which in turn leads to a wrong measurement.
Switch off interrupts during a PD_SCK high period and move query of DOUT to the latest point of time which is at the end of PD_SCK low period.
This bug exists in the driver since it's initial addition. The more interrupts on the system the higher is the probability that it happens.
--- drivers/iio/adc/hx711.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/adc/hx711.c +5 -5
@@ -100,14 +100,14 @@ struct hx711_data {static int hx711_cycle (struct hx711_data *hx711_data) { -int val; +unsigned long flags;/* * if preempted for more then 60us while PD_SCK is high: * hx711 is going in reset * ==> measuring is false */ -preempt_disable (); +local_irq_save (flags);gpiod_set_value (hx711_data->gpiod_pd_sck,1 );/*
@@ -117,7 +117,6 @@ static int hx711_cycle(struct hx711_data *hx711_data)*/ ndelay (hx711_data->data_ready_delay_ns); - val =gpiod_get_value (hx711_data->gpiod_dout);/* * here we are not waiting for 0.2 us as suggested by the datasheet, * because the oscilloscope showed in a test scenario
@@ -125,7 +124,7 @@ static int hx711_cycle(struct hx711_data *hx711_data)* and 0.56 us for PD_SCK low on TI Sitara with 800 MHz */ gpiod_set_value (hx711_data->gpiod_pd_sck,0 ); -preempt_enable (); +local_irq_restore (flags);/* * make it a square wave for addressing cases with capacitance on
@@ -133,7 +132,8 @@ static int hx711_cycle(struct hx711_data *hx711_data)*/ ndelay (hx711_data->data_ready_delay_ns); -return val; +/* sample as late as possible */ +return gpiod_get_value (hx711_data->gpiod_dout); }static int hx711_read (struct hx711_data *hx711_data)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 70/89 iio: accel: adxl372: Fix/remove limitation for FIFO samples
In reply to Sasha LevinFrom: Stefan Popa <[email protected]>
[ Upstream commit d202ce4787e446556c6b9d01f84734c3f8174ba3 ]
Currently, the driver sets the FIFO_SAMPLES register with the number of sample sets (maximum of 170 for 3 axis data, 256 for 2-axis and 512 for single axis). However, the FIFO_SAMPLES register should store the number of samples, regardless of how the FIFO format is configured.
--- drivers/iio/accel/adxl372.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/iio/accel/adxl372.c +8 -3
@@ -474,12 +474,17 @@ static int adxl372_configure_fifo(struct adxl372_state *st)if (ret <0 )return ret; - fifo_samples = st->watermark &0xFF ; +/* +* watermark stores the number of sets; we need to write the FIFO +* registers with the number of samples +*/ + fifo_samples = (st->watermark * st->fifo_set_size); fifo_ctl =ADXL372_FIFO_CTL_FORMAT_MODE (st->fifo_format) |ADXL372_FIFO_CTL_MODE_MODE (st->fifo_mode) | -ADXL372_FIFO_CTL_SAMPLES_MODE (st->watermark); +ADXL372_FIFO_CTL_SAMPLES_MODE (fifo_samples); - ret =regmap_write (st->regmap,ADXL372_FIFO_SAMPLES , fifo_samples); + ret =regmap_write (st->regmap, +ADXL372_FIFO_SAMPLES , fifo_samples &0xFF );if (ret <0 )return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 71/89 iio: accel: adxl372: Fix push to buffers lost samples
In reply to Sasha LevinFrom: Stefan Popa <[email protected]>
[ Upstream commit 62df81b74393079debf04961c48cb22268fc5fab ]
One in two sample sets was lost by multiplying fifo_set_size with sizeof(u16). Also, the double number of available samples were pushed to the iio buffers.
--- drivers/iio/accel/adxl372.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/accel/adxl372.c +1 -2
@@ -553,8 +553,7 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p) goto err;/* Each sample is 2 bytes */ -for (i =0 ; i < fifo_entries *sizeof (u16); - i += st->fifo_set_size *sizeof (u16)) +for (i =0 ; i < fifo_entries; i += st->fifo_set_size)iio_push_to_buffers (indio_dev, &st->fifo_buf[i]); } err:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 72/89 iio: accel: adxl372: Perform a reset at start up
In reply to Sasha LevinFrom: Stefan Popa <[email protected]>
[ Upstream commit d9a997bd4d762d5bd8cc548d762902f58b5e0a74 ]
We need to perform a reset a start up to make sure that the chip is in a consistent state. This reset also disables all the interrupts which should only be enabled together with the iio buffer. Not doing this, was sometimes causing unwanted interrupts to trigger.
--- drivers/iio/accel/adxl372.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iio/accel/adxl372.c +8 -0
@@ -575,6 +575,14 @@ static int adxl372_setup(struct adxl372_state *st)return -ENODEV ; } +/* +* Perform a software reset to make sure the device is in a consistent +* state after start up. +*/ + ret =regmap_write (st->regmap,ADXL372_RESET ,ADXL372_RESET_CODE ); +if (ret <0 ) +return ret; + ret =adxl372_set_op_mode (st,ADXL372_STANDBY );if (ret <0 )return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 73/89 iio: imu: adis16400: release allocated memory on failure
In reply to Sasha LevinFrom: Navid Emamdoost <[email protected]>
[ Upstream commit ab612b1daf415b62c58e130cb3d0f30b255a14d0 ]
In adis_update_scan_mode, if allocation for adis->buffer fails, previously allocated adis->xfer needs to be released.
--- drivers/iio/imu/adis_buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis_buffer.c +4 -1
@@ -78,8 +78,11 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,return -ENOMEM ; adis->buffer =kcalloc (indio_dev->scan_bytes,2 ,GFP_KERNEL ); -if (!adis->buffer) +if (!adis->buffer) { +kfree (adis->xfer); + adis->xfer =NULL ;return -ENOMEM ; + } rx = adis->buffer; tx = rx + scan_count;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 74/89 iio: imu: adis16400: fix memory leak
In reply to Sasha LevinFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 9c0530e898f384c5d279bfcebd8bb17af1105873 ]
In adis_update_scan_mode_burst, if adis->buffer allocation fails release the adis->xfer.
--- drivers/iio/imu/adis_buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis_buffer.c +4 -1
@@ -35,8 +35,11 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,return -ENOMEM ; adis->buffer =kzalloc (burst_length +sizeof (u16),GFP_KERNEL ); -if (!adis->buffer) +if (!adis->buffer) { +kfree (adis->xfer); + adis->xfer =NULL ;return -ENOMEM ; + } tx = adis->buffer + burst_length; tx[0 ] =ADIS_READ_REG (adis->burst->reg_cmd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 75/89 iio: imu: st_lsm6dsx: fix waitime for st_lsm6dsx i2c controller
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit fdb828e2c71a09bb9e865f41b015597c5f671705 ]
i2c controller available in st_lsm6dsx series performs i2c slave configuration using accel clock as trigger. st_lsm6dsx_shub_wait_complete routine is used to wait the controller has carried out the requested configuration. However if the accel sensor is not enabled we should not use its configured odr to estimate a proper timeout
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +3 -1
@@ -92,9 +92,11 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = {static void st_lsm6dsx_shub_wait_complete (struct st_lsm6dsx_hw *hw) {struct st_lsm6dsx_sensor *sensor; +u16 odr; sensor =iio_priv (hw->iio_devs[ST_LSM6DSX_ID_ACC ]); -msleep ((2000U / sensor->odr) +1 ); + odr = (hw->enable_mask &BIT (ST_LSM6DSX_ID_ACC )) ? sensor->odr :13 ; +msleep ((2000U / odr) +1 ); }/**
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 76/89 iio: light: fix vcnl4000 devicetree hooks
In reply to Sasha LevinFrom: Marco Felsch <[email protected]>
[ Upstream commit 1436a78c63495dd94c8d4f84a76d78d5317d481b ]
Since commit ebd457d55911 ("iio: light: vcnl4000 add devicetree hooks") the of_match_table is supported but the data shouldn't be a string. Instead it shall be one of 'enum vcnl4000_device_ids'. Also the matching logic for the vcnl4020 was wrong. Since the data retrieve mechanism is still based on the i2c_device_id no failures did appeared till now.
--- drivers/iio/light/vcnl4000.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/light/vcnl4000.c +5 -5
@@ -398,19 +398,19 @@ static int vcnl4000_probe(struct i2c_client *client,static const struct of_device_id vcnl_4000_of_match[] = { { .compatible ="vishay,vcnl4000" , - .data ="VCNL4000" , + .data = (void *)VCNL4000 , }, { .compatible ="vishay,vcnl4010" , - .data ="VCNL4010" , + .data = (void *)VCNL4010 , }, { - .compatible ="vishay,vcnl4010" , - .data ="VCNL4020" , + .compatible ="vishay,vcnl4020" , + .data = (void *)VCNL4010 , }, { .compatible ="vishay,vcnl4200" , - .data ="VCNL4200" , + .data = (void *)VCNL4200 , }, {}, };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 77/89 iio: light: add missing vcnl4040 of_compatible
In reply to Sasha LevinFrom: Marco Felsch <[email protected]>
[ Upstream commit 7fd1c2606508eb384992251e87d50591393a48d0 ]
Commit 5a441aade5b3 ("iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor") added the support for the vcnl4040 but forgot to add the of_compatible. Fix this by adding it now.
--- drivers/iio/light/vcnl4000.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iio/light/vcnl4000.c +4 -0
@@ -408,6 +408,10 @@ static const struct of_device_id vcnl_4000_of_match[] = { .compatible = "vishay,vcnl4020", .data = (void *)VCNL4010, }, + { + .compatible = "vishay,vcnl4040", + .data = (void *)VCNL4040, + }, { .compatible = "vishay,vcnl4200", .data = (void *)VCNL4200,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 78/89 iio: adc: ad799x: fix probe error handling
In reply to Sasha LevinFrom: Marco Felsch <[email protected]>
[ Upstream commit c62dd44901cfff12acc5792bf3d2dec20bcaf392 ]
Since commit 0f7ddcc1bff1 ("iio:adc:ad799x: Write default config on probe and reset alert status on probe") the error path is wrong since it leaves the vref regulator on. Fix this by disabling both regulators.
--- drivers/iio/adc/ad799x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad799x.c +2 -2
@@ -810,10 +810,10 @@ static int ad799x_probe(struct i2c_client *client, ret =ad799x_write_config (st, st->chip_config->default_config);if (ret <0 ) - goto error_disable_reg; + goto error_disable_vref; ret =ad799x_read_config (st);if (ret <0 ) - goto error_disable_reg; + goto error_disable_vref; st->config = ret; ret = iio_triggered_buffer_setup(indio_dev, NULL,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 79/89 iio: light: opt3001: fix mutex unlock race
In reply to Sasha LevinFrom: David Frey <[email protected]>
[ Upstream commit 82f3015635249a8c8c45bac303fd84905066f04f ]
When an end-of-conversion interrupt is received after performing a single-shot reading of the light sensor, the driver was waking up the result ready queue before checking opt->ok_to_ignore_lock to determine if it should unlock the mutex. The problem occurred in the case where the other thread woke up and changed the value of opt->ok_to_ignore_lock to false prior to the interrupt thread performing its read of the variable. In this case, the mutex would be unlocked twice.
--- drivers/iio/light/opt3001.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/light/opt3001.c +5 -1
@@ -686,6 +686,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio)struct iio_dev *iio = _iio;struct opt3001 *opt =iio_priv (iio);int ret; +bool wake_result_ready_queue = false;if (!opt->ok_to_ignore_lock)mutex_lock (&opt->lock);
@@ -720,13 +721,16 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) } opt->result = ret; opt->result_ready = true; -wake_up (&opt->result_ready_queue); + wake_result_ready_queue = true; } out:if (!opt->ok_to_ignore_lock)mutex_unlock (&opt->lock); +if (wake_result_ready_queue) +wake_up (&opt->result_ready_queue); +return IRQ_HANDLED ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 80/89 MIPS: include: Mark __xchg as __always_inline
In reply to Sasha LevinFrom: Thomas Bogendoerfer <[email protected]>
[ Upstream commit 46f1619500d022501a4f0389f9f4c349ab46bb86 ]
Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly") allows compiler to uninline functions marked as 'inline'. In cace of __xchg this would cause to reference function __xchg_called_with_bad_pointer, which is an error case for catching bugs and will not happen for correct code, if __xchg is inlined.
--- arch/mips/include/asm/cmpxchg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/include/asm/cmpxchg.h +2 -2
@@ -77,8 +77,8 @@ extern unsigned long __xchg_called_with_bad_pointer(void)extern unsigned long __xchg_small (volatile void *ptr,unsigned long val,unsigned int size); -static inline unsigned long __xchg (volatile void *ptr,unsigned long x, -int size) +static __always_inline +unsigned long __xchg (volatile void *ptr,unsigned long x,int size) {switch (size) {case 1 :
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 81/89 MIPS: fw: sni: Fix out of bounds init of o32 stack
In reply to Sasha LevinFrom: Thomas Bogendoerfer <[email protected]>
[ Upstream commit efcb529694c3b707dc0471b312944337ba16e4dd ]
Use ARRAY_SIZE to caluculate the top of the o32 stack.
--- arch/mips/fw/sni/sniprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/fw/sni/sniprom.c +1 -1
@@ -43,7 +43,7 @@/* O32 stack has to be 8-byte aligned. */ static u64 o32_stk[4096 ]; -#define O32_STK &o32_stk[sizeof(o32_stk)] +#define O32_STK (&o32_stk[ARRAY_SIZE(o32_stk)])#define __PROM_O32 (fun, arg) fun arg __asm__(#fun); \ __asm__(#fun " = call_o32")
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 82/89 s390/cio: fix virtio-ccw DMA without PV
In reply to Sasha LevinFrom: Halil Pasic <[email protected]>
[ Upstream commit 05668e1d74b84c53fbe0f28565e4c9502a6b8a67 ]
Commit 37db8985b211 ("s390/cio: add basic protected virtualization support") breaks virtio-ccw devices with VIRTIO_F_IOMMU_PLATFORM for non Protected Virtualization (PV) guests. The problem is that the dma_mask of the ccw device, which is used by virtio core, gets changed from 64 to 31 bit, because some of the DMA allocations do require 31 bit addressable memory. For PV the only drawback is that some of the virtio structures must end up in ZONE_DMA because we have the bounce the buffers mapped via DMA API anyway.
But for non PV guests we have a problem: because of the 31 bit mask guests bigger than 2G are likely to try bouncing buffers. The swiotlb however is only initialized for PV guests, because we don't want to bounce anything for non PV guests. The first such map kills the guest.
Since the DMA API won't allow us to specify for each allocation whether we need memory from ZONE_DMA (31 bit addressable) or any DMA capable memory will do, let us use coherent_dma_mask (which is used for allocations) to force allocating form ZONE_DMA while changing dma_mask to DMA_BIT_MASK(64) so that at least the streaming API will regard the whole memory DMA capable.
--- drivers/s390/cio/cio.h | 1 + drivers/s390/cio/css.c | 7 ++++++- drivers/s390/cio/device.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)
drivers/s390/cio/cio.h +1 -0
@@ -113,6 +113,7 @@ struct subchannel {enum sch_todo todo;struct work_struct todo_work;struct schib_config config; +u64 dma_mask;char *driver_override;/* Driver name to force a match */ } __attribute__ ((aligned(8)));
drivers/s390/cio/css.c +6 -1
@@ -232,7 +232,12 @@ struct subchannel *css_alloc_subchannel(struct subchannel_id schid,* belong to a subchannel need to fit 31 bit width (e.g. ccw). */ sch->dev.coherent_dma_mask =DMA_BIT_MASK (31 ); - sch->dev.dma_mask = &sch->dev.coherent_dma_mask; +/* +* But we don't have such restrictions imposed on the stuff that +* is handled by the streaming API. +*/ + sch->dma_mask =DMA_BIT_MASK (64 ); + sch->dev.dma_mask = &sch->dma_mask;return sch; err:
drivers/s390/cio/device.c +1 -1
@@ -710,7 +710,7 @@ static struct ccw_device * io_subchannel_allocate_dev(struct subchannel *sch)if (!cdev->private) goto err_priv; cdev->dev.coherent_dma_mask = sch->dev.coherent_dma_mask; - cdev->dev.dma_mask = &cdev->dev.coherent_dma_mask; + cdev->dev.dma_mask = sch->dev.dma_mask; dma_pool =cio_gp_dma_create (&cdev->dev,1 );if (!dma_pool) goto err_dma_pool;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 83/89 USB: usb-skeleton: fix use-after-free after driver unbind
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 6353001852776e7eeaab4da78922d4c6f2b076af ]
The driver failed to stop its read URB on disconnect, something which could lead to a use-after-free in the completion handler after driver unbind in case the character device has been closed.
--- drivers/usb/usb-skeleton.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/usb-skeleton.c +1 -0
@@ -574,6 +574,7 @@ static void skel_disconnect(struct usb_interface *interface) dev->interface =NULL ;mutex_unlock (&dev->io_mutex); +usb_kill_urb (dev->bulk_in_urb);usb_kill_anchored_urbs (&dev->submitted);/* decrement our usage count */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 84/89 virt: vbox: fix memory leak in hgcm_call_preprocess_linaddr
In reply to Sasha LevinFrom: Navid Emamdoost <[email protected]>
[ Upstream commit e0b0cb9388642c104838fac100a4af32745621e2 ]
In hgcm_call_preprocess_linaddr memory is allocated for bounce_buf but is not released if copy_form_user fails. In order to prevent memory leak in case of failure, the assignment to bounce_buf_ret is moved before the error check. This way the allocated bounce_buf will be released by the caller.
--- drivers/virt/vboxguest/vboxguest_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virt/vboxguest/vboxguest_utils.c +2 -1
@@ -220,6 +220,8 @@ static int hgcm_call_preprocess_linaddr(if (!bounce_buf)return -ENOMEM ; + *bounce_buf_ret = bounce_buf; +if (copy_in) { ret =copy_from_user (bounce_buf, (void __user *)buf, len);if (ret)
@@ -228,7 +230,6 @@ static int hgcm_call_preprocess_linaddr(memset (bounce_buf,0 , len); } - *bounce_buf_ret = bounce_buf;hgcm_call_add_pagelist_size (bounce_buf, len, extra);return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 85/89 nbd: fix possible sysfs duplicate warning
In reply to Sasha LevinFrom: Xiubo Li <[email protected]>
[ Upstream commit 862488105b84ca744b3d8ff131e0fcfe10644be1 ]
1. nbd_put takes the mutex and drops nbd->ref to 0. It then does idr_remove and drops the mutex.
2. nbd_genl_connect takes the mutex. idr_find/idr_for_each fails to find an existing device, so it does nbd_dev_add.
3. just before the nbd_put could call nbd_dev_remove or not finished totally, but if nbd_dev_add try to add_disk, we can hit:
debugfs: Directory 'nbd1' with parent 'block' already present!
This patch will make sure all the disk add/remove stuff are done by holding the nbd_index_mutex lock.
--- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
@@ -230,8 +230,8 @@ static void nbd_put(struct nbd_device *nbd)if (refcount_dec_and_mutex_lock (&nbd->refs, &nbd_index_mutex)) {idr_remove (&nbd_index_idr, nbd->index); -mutex_unlock (&nbd_index_mutex);nbd_dev_remove (nbd); +mutex_unlock (&nbd_index_mutex); } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 86/89 NFSv4: Fix leak of clp->cl_acceptor string
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit 1047ec868332034d1fbcb2fae19fe6d4cb869ff2 ]
Our client can issue multiple SETCLIENTID operations to the same server in some circumstances. Ensure that calls to nfs4_proc_setclientid() after the first one do not overwrite the previously allocated cl_acceptor string.
unreferenced object 0xffff888461031800 (size 32):
comm "mount.nfs", pid 2227, jiffies 4294822467 (age 1407.749s) hex dump (first 32 bytes):
6e 66 73 40 6b 6c 69 6d 74 2e 69 62 2e 31 30 31 [email protected] 35 67 72 61 6e 67 65 72 2e 6e 65 74 00 00 00 00 5granger.net.... backtrace: [<00000000ab820188>] __kmalloc+0x128/0x176 [<00000000eeaf4ec8>] gss_stringify_acceptor+0xbd/0x1a7 [auth_rpcgss] [<00000000e85e3382>] nfs4_proc_setclientid+0x34e/0x46c [nfsv4] [<000000003d9cf1fa>] nfs40_discover_server_trunking+0x7a/0xed [nfsv4] [<00000000b81c3787>] nfs4_discover_server_trunking+0x81/0x244 [nfsv4] [<000000000801b55f>] nfs4_init_client+0x1b0/0x238 [nfsv4] [<00000000977daf7f>] nfs4_set_client+0xfe/0x14d [nfsv4] [<0000000053a68a2a>] nfs4_create_server+0x107/0x1db [nfsv4] [<0000000088262019>] nfs4_remote_mount+0x2c/0x59 [nfsv4] [<00000000e84a2fd0>] legacy_get_tree+0x2d/0x4c [<00000000797e947c>] vfs_get_tree+0x20/0xc7 [<00000000ecabaaa8>] fc_mount+0xe/0x36 [<00000000f15fafc2>] vfs_kern_mount+0x74/0x8d [<00000000a3ff4e26>] nfs_do_root_mount+0x8a/0xa3 [nfsv4] [<00000000d1c2b337>] nfs4_try_mount+0x58/0xad [nfsv4] [<000000004c9bddee>] nfs_fs_mount+0x820/0x869 [nfs]
--- fs/nfs/nfs4proc.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/nfs4proc.c +1 -0
@@ -6058,6 +6058,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, } status = task->tk_status;if (setclientid.sc_cred) { +kfree (clp->cl_acceptor); clp->cl_acceptor =rpcauth_stringify_acceptor (setclientid.sc_cred);put_rpccred (setclientid.sc_cred); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 87/89 SUNRPC: fix race to sk_err after xs_error_report
In reply to Sasha LevinFrom: Benjamin Coddington <[email protected]>
[ Upstream commit af84537dbd1b39505d1f3d8023029b4a59666513 ]
Since commit 4f8943f80883 ("SUNRPC: Replace direct task wakeups from softirq context") there has been a race to the value of the sk_err if both XPRT_SOCK_WAKE_ERROR and XPRT_SOCK_WAKE_DISCONNECT are set. In that case, we may end up losing the sk_err value that existed when xs_error_report was called.
Fix this by reverting to the previous behavior: instead of using SO_ERROR to retrieve the value at a later time (which might also return sk_err_soft), copy the sk_err value onto struct sock_xprt, and use that value to wake pending tasks.
--- include/linux/sunrpc/xprtsock.h | 1 + net/sunrpc/xprtsock.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-)
include/linux/sunrpc/xprtsock.h +1 -0
@@ -61,6 +61,7 @@ struct sock_xprt {struct mutex recv_mutex;struct sockaddr_storage srcaddr;unsigned short srcport; +int xprt_err;/* * UDP socket buffer size parameters
net/sunrpc/xprtsock.c +8 -9
@@ -1243,19 +1243,21 @@ static void xs_error_report(struct sock *sk) {struct sock_xprt *transport;struct rpc_xprt *xprt; -int err;read_lock_bh (&sk->sk_callback_lock);if (!(xprt =xprt_from_sock (sk))) goto out; transport = container_of(xprt, struct sock_xprt, xprt); - err = -sk->sk_err; -if (err ==0 ) + transport->xprt_err = -sk->sk_err; +if (transport->xprt_err ==0 ) goto out;dprintk ("RPC: xs_error_report client %p, error=%d...\n" , - xprt, -err); -trace_rpc_socket_error (xprt, sk->sk_socket, err); + xprt, -transport->xprt_err); +trace_rpc_socket_error (xprt, sk->sk_socket, transport->xprt_err); + +/* barrier ensures xprt_err is set before XPRT_SOCK_WAKE_ERROR */ +smp_mb__before_atomic ();xs_run_error_worker (transport,XPRT_SOCK_WAKE_ERROR ); out:read_unlock_bh (&sk->sk_callback_lock);
@@ -2470,7 +2472,6 @@ static void xs_wake_write(struct sock_xprt *transport)static void xs_wake_error (struct sock_xprt *transport) {int sockerr; -int sockerr_len =sizeof (sockerr);if (!test_bit (XPRT_SOCK_WAKE_ERROR , &transport->sock_state))return ;
@@ -2479,9 +2480,7 @@ static void xs_wake_error(struct sock_xprt *transport) goto out;if (!test_and_clear_bit (XPRT_SOCK_WAKE_ERROR , &transport->sock_state)) goto out; -if (kernel_getsockopt (transport->sock,SOL_SOCKET ,SO_ERROR , - (char *)&sockerr, &sockerr_len) !=0 ) - goto out; + sockerr =xchg (&transport->xprt_err,0 );if (sockerr <0 )xprt_wake_pending_tasks (&transport->xprt, sockerr); out:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 88/89 s390/uaccess: avoid (false positive) compiler warnings
In reply to Sasha LevinFrom: Christian Borntraeger <[email protected]>
[ Upstream commit 062795fcdcb2d22822fb42644b1d76a8ad8439b3 ]
Depending on inlining decisions by the compiler, __get/put_user_fn might become out of line. Then the compiler is no longer able to tell that size can only be 1,2,4 or 8 due to the check in __get/put_user resulting in false positives like
./arch/s390/include/asm/uaccess.h: In function ‘__put_user_fn’:./arch/s390/include/asm/uaccess.h:113:9: warning: ‘rc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
113 | return rc;
| ^~./arch/s390/include/asm/uaccess.h: In function ‘__get_user_fn’:./arch/s390/include/asm/uaccess.h:143:9: warning: ‘rc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
143 | return rc;
| ^~
These functions are supposed to be always inlined. Mark it as such.
--- arch/s390/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/uaccess.h +2 -2
@@ -83,7 +83,7 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n); __rc; \ }) -static inline int __put_user_fn (void *x,void __user *ptr,unsigned long size) +static __always_inline int __put_user_fn(void *x, void __user *ptr, unsigned long size) {unsigned long spec =0x010000UL ;int rc;
@@ -113,7 +113,7 @@ static inline int __put_user_fn(void *x, void __user *ptr, unsigned long size)return rc; } -static inline int __get_user_fn (void *x,const void __user *ptr,unsigned long size) +static __always_inline int __get_user_fn(void *x, const void __user *ptr, unsigned long size) {unsigned long spec =0x01UL ;int rc;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 89/89 tracing: Initialize iter->seq after zeroing in tracing_read_pipe()
In reply to Sasha LevinFrom: Petr Mladek <[email protected]>
[ Upstream commit d303de1fcf344ff7c15ed64c3f48a991c9958775 ]
A customer reported the following softlockup:
[899688.160002] NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [test.sh:16464] [899688.160002] CPU: 0 PID: 16464 Comm: test.sh Not tainted 4.12.14-6.23-azure #1 SLE12-SP4 [899688.160002] RIP: 0010:up_write+0x1a/0x30 [899688.160002] Kernel panic - not syncing: softlockup: hung tasks [899688.160002] RIP: 0010:up_write+0x1a/0x30 [899688.160002] RSP: 0018:ffffa86784d4fde8 EFLAGS: 00000257 ORIG_RAX: ffffffffffffff12 [899688.160002] RAX: ffffffff970fea00 RBX: 0000000000000001 RCX: 0000000000000000 [899688.160002] RDX: ffffffff00000001 RSI: 0000000000000080 RDI: ffffffff970fea00 [899688.160002] RBP: ffffffffffffffff R08: ffffffffffffffff R09: 0000000000000000 [899688.160002] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8b59014720d8 [899688.160002] R13: ffff8b59014720c0 R14: ffff8b5901471090 R15: ffff8b5901470000 [899688.160002] tracing_read_pipe+0x336/0x3c0 [899688.160002] __vfs_read+0x26/0x140 [899688.160002] vfs_read+0x87/0x130 [899688.160002] SyS_read+0x42/0x90 [899688.160002] do_syscall_64+0x74/0x160
It caught the process in the middle of trace_access_unlock(). There is no loop. So, it must be looping in the caller tracing_read_pipe() via the "waitagain" label.
Crashdump analyze uncovered that iter->seq was completely zeroed at this point, including iter->seq.seq.size. It means that print_trace_line() was never able to print anything and there was no forward progress.
The culprit seems to be in the code:
/* reset all but tr, trace, and overruns */ memset(&iter->seq, 0, sizeof(struct trace_iterator) - offsetof(struct trace_iterator, seq));
It was added by the commit 53d0aa773053ab182877 ("ftrace:
add logic to record overruns"). It was v2.6.27-rc1. It was the time when iter->seq looked like:
struct trace_seq {
unsigned char buffer[PAGE_SIZE];
unsigned int len;
};There was no "size" variable and zeroing was perfectly fine.
The solution is to reinitialize the structure after or without zeroing.
--- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace.c +1 -0
@@ -5999,6 +5999,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,sizeof (struct trace_iterator ) - offsetof(struct trace_iterator, seq));cpumask_clear (iter->started); +trace_seq_init (&iter->seq); iter->pos =-1 ;trace_event_read_lock ();
Signature · 1 line
2.20.1