[PATCH 3/7] linux/bitmap.h: remove redundant uses of small_const_nbits()

2018-08-18 Thread Rasmus Villemoes
0020 : 20: 48 8b 06mov(%rsi),%rax 23: 48 89 07mov%rax,(%rdi) 26: c3 retq Signed-off-by: Rasmus Villemoes --- include/linux/bitmap.h | 24 ++-- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git

[PATCH 7/7] lib/bitmap.c: simplify bitmap_print_to_pagebuf

2018-08-18 Thread Rasmus Villemoes
0' to that final byte in the page, but that's an improvement: We now guarantee that after the call, buf is a properly terminated C string of length exactly the return value. Signed-off-by: Rasmus Villemoes --- lib/bitmap.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff

[PATCH 6/7] lib/bitmap.c: fix remaining space computation in bitmap_print_to_pagebuf

2018-08-18 Thread Rasmus Villemoes
huge, scnprintf() ends up writing beyond the page boundary. I don't think any current callers actually write anything before bitmap_print_to_pagebuf, but the API seems to be designed to allow it. Signed-off-by: Rasmus Villemoes --- lib/bitmap.c | 9 + 1 file changed, 5 insertions(

[PATCH 0/7] assorted minor bitmap patches

2018-08-18 Thread Rasmus Villemoes
A recent LKML thread had me look into bitmap.{h,c} again, and I stumbled on/rediscovered a few things. Rasmus Villemoes (7): lib/bitmap.c: remove wrong documentation linux/bitmap.h: handle constant zero-size bitmaps correctly linux/bitmap.h: remove redundant uses of small_const_nbits

[PATCH 1/7] lib/bitmap.c: remove wrong documentation

2018-08-18 Thread Rasmus Villemoes
This promise is violated in a number of places, e.g. already in the second function below this paragraph. Since I don't think anybody relies on this being true, and since actually honouring it would hurt performance and code size in various places, just remove the paragraph. Signed-off-by: R

[PATCH] linux/compiler.h: don't use bool

2018-08-17 Thread Rasmus Villemoes
7;bool'; did you >> mean '_Bool'? bool __cond = !(condition);\ for something I'm working on. Rather than contributing to the #include madness and including linux/types.h from compiler.h, just use int. Signed-off-by: Rasmus Villemoes --- include/linux/compiler.h

Re: [PATCH] linux/bitmap.h: (buildbot-only) check if we have any compile-time zero-size bitmaps

2018-08-17 Thread Rasmus Villemoes
On 2018-08-17 01:21, Yury Norov wrote: > Hi Rasmus, > > On Wed, Aug 15, 2018 at 10:55:39AM +0200, Rasmus Villemoes wrote: >> Most of the inline bitmap functions are buggy if passed a compile-time >> constant nbits==0. > > I think it's bad wording. Functions are O

[PATCH] ia64/sn/hwperf: check seq_open return value to avoid NULL deref

2018-08-16 Thread Rasmus Villemoes
This code should check the return value of seq_open(); if it failed, file->private_data is NULL. But in that case we then need to dispose of objbuf to prevent a resource leak. Signed-off-by: Rasmus Villemoes --- arch/ia64/sn/kernel/sn2/sn_hwperf.c | 8 ++-- 1 file changed, 6 inserti

[PATCH 2/3] Kbuild: teach fixdep to optionally remove the depfile

2018-08-15 Thread Rasmus Villemoes
behaviour of keeping the depfile if fixdep exits prematurely. Signed-off-by: Rasmus Villemoes --- scripts/Kbuild.include | 7 +++ scripts/basic/fixdep.c | 10 -- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index d

[PATCH 3/3] Kbuild: let fixdep do the renaming to .cmd

2018-08-15 Thread Rasmus Villemoes
Avoid spawning one more process per TU by having fixdep open the tmpfile and rename to its final name. The only change in behaviour is that if fixdep fails, the tmpfile we leave behind is $(dot-target).cmd.tmp rather than $(dot-target).tmp . Signed-off-by: Rasmus Villemoes --- scripts

[PATCH 1/3] Kbuild: refactor fixdep to use getopt()

2018-08-15 Thread Rasmus Villemoes
As preparation for teaching an old dog a few new tricks. Signed-off-by: Rasmus Villemoes --- scripts/basic/fixdep.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 850966f3d602..666041841200 100644

[PATCH 0/3] Kbuild: Some fixdep tweaks

2018-08-15 Thread Rasmus Villemoes
These patches eliminate two (albeit tiny and shortlived) processes from the cmd_and_fixdep rule, i.e. from every TU being compiled. Whether the diffstat below is worth it I'll leave to Kbuild maintainers to decide. Rasmus Villemoes (3): Kbuild: refactor fixdep to use getopt() Kbuild:

[PATCH] linux/bitmap.h: (buildbot-only) check if we have any compile-time zero-size bitmaps

2018-08-15 Thread Rasmus Villemoes
bitmap should turn up. Not-really-signed-off-by: Rasmus Villemoes --- include/linux/bitmap.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 1ee46f492267..a5879cb45687 100644 --- a/include/linux/bitmap.h +++ b/include/l

Re: [PATCH] perf: disable parallelism for 'make clean'

2018-08-15 Thread Rasmus Villemoes
On 2018-07-05 15:49, Jiri Olsa wrote: > On Thu, Jul 05, 2018 at 03:15:27PM +0200, Rasmus Villemoes wrote: >> this only happens in combination with a O=... parameter. In any case, we >> don't lose much by explicitly disabling the parallelism for the clean >> target, and

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-06 Thread Rasmus Villemoes
On 2018-07-26 12:15, Wei Wang wrote: > On 07/26/2018 05:37 PM, Yury Norov wrote: >> On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: >>> The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is >>> 0. This patch changes the macro to return 0 when there is no bit >>> needs to

Re: [PATCH rdma-next v4 2/3] test_overflow: Add shift overflow tests

2018-08-06 Thread Rasmus Villemoes
upstream during next merge window. > Co-developed-by: Rasmus Villemoes > Signed-off-by: Kees Cook > --- > +static int __init test_overflow_shift(void) > +{ > + int err = 0; > + > +/* Args are: value, shift, type, expected result, overflow expected */ > +#defin

[tip:x86/debug] x86: Avoid pr_cont() in show_opcodes()

2018-07-19 Thread tip-bot for Rasmus Villemoes
Commit-ID: 8e974b3b8eddd42a8c43a18e8ea66a3e7b803a0d Gitweb: https://git.kernel.org/tip/8e974b3b8eddd42a8c43a18e8ea66a3e7b803a0d Author: Rasmus Villemoes AuthorDate: Thu, 19 Jul 2018 23:07:58 +0900 Committer: Thomas Gleixner CommitDate: Thu, 19 Jul 2018 16:46:23 +0200 x86: Avoid

Re: [PATCH] x86: Avoid pr_cont() in show_opcodes()

2018-07-17 Thread Rasmus Villemoes
On 2018-07-17 15:53, Tetsuo Handa wrote: > On 2018/07/17 18:01, Rasmus Villemoes wrote: >> Why not this instead? Less stack use, less code, no intermediary >> snprintfs, no pr_cont... > > Excellent! I didn't notice %ph extension. > >> Not compile-tested, proba

Re: [PATCH] x86: Avoid pr_cont() in show_opcodes()

2018-07-17 Thread Rasmus Villemoes
On 2018-07-07 15:54, Tetsuo Handa wrote: > On 2018/07/07 20:12, Ingo Molnar wrote: >> >> * Tetsuo Handa wrote: >> >>> From: Tetsuo Handa >>> >>> Since syzbot is confused by concurrent printk() messages [1], >>> this patch changes show_opcodes() to use snprintf(). >>> >>> When we start adding pref

[PATCH] perf: disable parallelism for 'make clean'

2018-07-05 Thread Rasmus Villemoes
pens in combination with a O=... parameter. In any case, we don't lose much by explicitly disabling the parallelism for the clean target, and it makes automated builds much more reliable. Signed-off-by: Rasmus Villemoes --- Another option is to add -ignore_readdir_race to all find commands, b

Re: sparse warnings in overflow.h

2018-06-07 Thread Rasmus Villemoes
On 2018-06-07 20:35, Kees Cook wrote: > On Thu, Jun 7, 2018 at 4:01 AM, Miroslav Benes wrote: >> >> Hi Kees, >> >> sparse (make C=1) gives me this warnings today... >> >> ./include/linux/overflow.h:254:13: error: undefined identifier >> '__builtin_mul_overflow' >> ./include/linux/overflow.h:254:1

Re: [PATCH 04/13] mm: Use array_size() helpers for kmalloc()

2018-05-09 Thread Rasmus Villemoes
On 2018-05-09 20:07, Kees Cook wrote: > On Wed, May 9, 2018 at 11:00 AM, Rasmus Villemoes > wrote: > Okay, consensus is to remove new SIZE_MAX checks, then? Yes, don't add such to static inlines. But the out-of-line implementations do need an audit (as you've observed) for u

Re: [PATCH 03/13] overflow.h: Add allocation size calculation helpers

2018-05-09 Thread Rasmus Villemoes
On 2018-05-09 02:42, Kees Cook wrote: > In preparation for replacing unchecked overflows for memory allocations, > this creates helpers for the 3 most common calculations: > > array_size(a, b): 2-dimensional array > array3_size(a, b, c): 2-dimensional array yeah... complete confusion... > +/** >

Re: [PATCH 04/13] mm: Use array_size() helpers for kmalloc()

2018-05-09 Thread Rasmus Villemoes
On 2018-05-09 13:34, Matthew Wilcox wrote: > On Tue, May 08, 2018 at 05:42:20PM -0700, Kees Cook wrote: >> @@ -499,6 +500,8 @@ static __always_inline void *kmalloc_large(size_t size, >> gfp_t flags) >> */ >> static __always_inline void *kmalloc(size_t size, gfp_t flags) >> { >> +if (size =

Re: *alloc API changes

2018-05-07 Thread Rasmus Villemoes
On 2018-05-05 06:24, Kees Cook wrote: > >> Right, I was thinking: >> >> static inline size_t mul_ab(size_t a, size_t b) >> { >> #if COMPILER_SUPPORTS_OVERFLOW >> unsigned long c; >> if (__builtin_mul_overflow(a, b, &c)) >> return SIZE_MAX; >> return c; >> #e

Re: [PATCH v5 2/2] dt/bindings: Add bindings for Layerscape external irqs

2018-05-04 Thread Rasmus Villemoes
On 2018-03-02 20:49, Rob Herring wrote: > On Fri, Feb 23, 2018 at 10:09:00PM +0100, Rasmus Villemoes wrote: >> This adds Device Tree binding documentation for the external interrupt >> lines with configurable polarity present on some Layerscape SOCs. >> >> Sign

Re: [PATCH v5 1/2] irqchip: add support for Layerscape external interrupt lines

2018-05-04 Thread Rasmus Villemoes
On 2018-03-01 13:16, Thomas Gleixner wrote: > On Fri, 23 Feb 2018, Rasmus Villemoes wrote: >> +#include >> +#include >> +#include >> +#include > > of.h is already included from of_irq.h and of_address.h Yes. But if we're ever going to have a chance of r

Re: [PATCH] proc: use #pragma once

2018-05-03 Thread Rasmus Villemoes
On 2018-05-04 00:42, Al Viro wrote: > On Fri, May 04, 2018 at 12:14:57AM +0200, Rasmus Villemoes wrote: > >> FWIW, it's not just removing some identifiers from cpp's hash tables, it >> also reduces I/O: Due to our header mess, we have some cyclic includes, >> e.g

Re: [PATCH 2/2] mm: Add kvmalloc_ab_c and kvzalloc_struct

2018-05-03 Thread Rasmus Villemoes
On 2018-05-01 19:00, Kees Cook wrote: > On Mon, Apr 30, 2018 at 2:29 PM, Rasmus Villemoes > wrote: >> >> gcc 5.1+ (I think) have the __builtin_OP_overflow checks that should >> generate reasonable code. Too bad there's no completely generic >> check_a

Re: [PATCH] proc: use #pragma once

2018-05-03 Thread Rasmus Villemoes
On 2018-05-02 00:13, Andrew Morton wrote: > On Thu, 26 Apr 2018 22:24:44 +0300 Alexey Dobriyan > wrote: > >>> The LOC argument also does not sound very convincing. >> >> When was the last time you did -80 kLOC patch for free? > > That would be the way to do it - sell the idea to Linus, send him

Re: [PATCH 2/2] mm: Add kvmalloc_ab_c and kvzalloc_struct

2018-04-30 Thread Rasmus Villemoes
On 2018-04-30 22:16, Matthew Wilcox wrote: > On Mon, Apr 30, 2018 at 12:02:14PM -0700, Kees Cook wrote: >> >> Getting the constant ordering right could be part of the macro >> definition, maybe? i.e.: >> >> static inline void *kmalloc_ab(size_t a, size_t b, gfp_t flags) >> { >> if (__builtin_co

Re: [PATCH v5 10/11] vsprintf: WARN() on invalid pointer access

2018-04-25 Thread Rasmus Villemoes
On 2018-04-25 13:12, Petr Mladek wrote: > > diff --git a/lib/test_printf.c b/lib/test_printf.c > index 45c33143fb4a..74dff6c44ec6 100644 > --- a/lib/test_printf.c > +++ b/lib/test_printf.c > @@ -285,12 +285,19 @@ null_pointer(void) > > #define PTR_INVALID ((void *)0x00ab) > > +extern in

Re: [PATCH v3 1/6] ilog2: create truly constant version for sparse

2018-04-19 Thread Rasmus Villemoes
On 2018-04-18 23:21, Linus Torvalds wrote: > On Wed, Apr 18, 2018 at 1:12 AM, Martin Wilck wrote: >> >> No, it doesn't (gcc 7.3.0). -> https://paste.opensuse.org/27471594 >> It doesn't even warn on an expression like this: >> >> #define SIZE (1<<10) >> static int foo[ilog2(SIZE)]; > > Ok, I t

[PATCH v2] Kbuild: fix # escaping in .cmd files for future Make

2018-04-08 Thread Rasmus Villemoes
s the above change, but at least this builds an x86_64 defconfig with the new make. Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=197847 Cc: Randy Dunlap Signed-off-by: Rasmus Villemoes --- v2: - squash the original objtool-only patch with the patch fixing up make-cmd, to avoid repeating

Re: [PATCH?] reiserfs: prevent panic: don't allow %-char in journal dev. name

2018-04-06 Thread Rasmus Villemoes
On 2018-04-05 11:04, Rasmus Villemoes wrote: > On 2018-04-05 03:45, Andrew Morton wrote: >> >> Isn't the bug in journal_init_dev()? > > Urgh. At first I was about to reply that the real bug was in reiserfs.h > for failing to annotate __reiserfs_warning with __printf

Re: [PATCH v4 4/9] vsprintf: Consolidate handling of unknown pointer specifiers

2018-04-06 Thread Rasmus Villemoes
On 2018-04-06 13:43, Petr Mladek wrote: > On Thu 2018-04-05 16:55:35, Joe Perches wrote: >> On Thu, 2018-04-05 at 16:45 -0700, Joe Perches wrote: >>> On Thu, 2018-04-05 at 16:25 +0200, Rasmus Villemoes wrote: >>>> Even just git grep -1 -E '%p"$' finds %

Re: [PATCH v4 8/9] vsprintf: Prevent crash when dereferencing invalid pointers

2018-04-06 Thread Rasmus Villemoes
On 2018-04-06 14:26, Petr Mladek wrote: > On Thu 2018-04-05 16:46:23, Rasmus Villemoes wrote: >> On 2018-04-04 10:58, Petr Mladek wrote: >> >>> diff --git a/lib/vsprintf.c b/lib/vsprintf.c >>> index 3551b7957d9e..1a080a75a825 100644 >>> --- a/lib/vsprintf

Re: [PATCH v4 8/9] vsprintf: Prevent crash when dereferencing invalid pointers

2018-04-06 Thread Rasmus Villemoes
On 2018-04-04 10:58, Petr Mladek wrote: > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > index 3551b7957d9e..1a080a75a825 100644 > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -599,12 +599,46 @@ char *__string(char *buf, char *end, const char *s, > struct printf_spec spec) > return wide

Re: [PATCH 2/1] Kbuild: fix # escaping in .cmd files for future Make

2018-04-05 Thread Rasmus Villemoes
On 2018-03-26 13:48, Masahiro Yamada wrote: > 2018-03-26 8:09 GMT+09:00 Rasmus Villemoes : >> The latest official Make release is 4.2.1 from mid-2016, but the current >> git release has this relevant note in the NEWS file: >> >> * WARNING: Backward-incompati

Re: [PATCH v4 8/9] vsprintf: Prevent crash when dereferencing invalid pointers

2018-04-05 Thread Rasmus Villemoes
On 2018-04-04 10:58, Petr Mladek wrote: > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > index 3551b7957d9e..1a080a75a825 100644 > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -599,12 +599,46 @@ char *__string(char *buf, char *end, const char *s, > struct printf_spec spec) > return wide

Re: [PATCH v4 4/9] vsprintf: Consolidate handling of unknown pointer specifiers

2018-04-05 Thread Rasmus Villemoes
On 2018-04-04 10:58, Petr Mladek wrote: > There are few printk formats that make sense only with two or more > specifiers. Also some specifiers make sense only when a kernel feature > is enabled. > > The handling of unknown specifiers is strange, inconsistent, and > even leaking the address. For e

Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-05 Thread Rasmus Villemoes
On 2018-04-04 10:58, Petr Mladek wrote: > We are going to check the address using probe_kernel_address(). It will > be more expensive and it does not make sense for well known address. > > This patch splits the string() function. The variant without the check > is then used on locations that handl

Re: [PATCH?] reiserfs: prevent panic: don't allow %-char in journal dev. name

2018-04-05 Thread Rasmus Villemoes
On 2018-04-05 03:45, Andrew Morton wrote: > On Wed, 4 Apr 2018 18:25:16 -0700 Randy Dunlap wrote: > >> From: Randy Dunlap >> >> If the reiserfs mount option's journal name contains a '%' character, >> it can lead to a WARN_ONCE() in lib/vsprintf.c::format_decode(), >> saying: "Please remove unsu

Re: [PATCHv3] gpio: Remove VLA from gpiolib

2018-04-05 Thread Rasmus Villemoes
On 2018-03-28 20:18, Laura Abbott wrote: > The new challenge is to remove VLAs from the kernel > (see https://lkml.org/lkml/2018/3/7/621) to eventually > turn on -Wvla. > > Using a kmalloc array is the easy way to fix this but kmalloc is still > more expensive than stack allocation. Introduce a fa

[PATCH 2/1] Kbuild: fix # escaping in .cmd files for future Make

2018-03-25 Thread Rasmus Villemoes
r future Make release contains that change by fixing up the .cmd file escaping - without this, make always thinks the command string has changed and hence rebuilds everything. Signed-off-by: Rasmus Villemoes --- So the previous patch made everything build, but building again revealed that thi

[PATCH] objtool: fix build with future Make

2018-03-25 Thread Rasmus Villemoes
To detect this change search for 'nocomment' in the .FEATURES variable. There are likely other places in the tree that will need fixing, so cc-ing Kbuild, but with this at least a x86-64 defconfig builds. Signed-off-by: Rasmus Villemoes --- tools/objtool/Makefile | 2 +- tools/scri

Re: [PATCH 3/4] mm: Add free()

2018-03-23 Thread Rasmus Villemoes
On 2018-03-22 20:58, Matthew Wilcox wrote: > From: Matthew Wilcox > > free() can free many different kinds of memory. I'd be a bit worried about using that name. gcc very much knows about the C standard's definition of that function, as can be seen on godbolt.org by compiling void free(const vo

[RFC resend 2/2] modpost: sumversions: try to fix "same dir" logic

2018-03-22 Thread Rasmus Villemoes
e included file using . as starting point, we include it - otherwise it was found via some -I path, so do not include it". In any case, this is mostly just something I stumbled on because I'm about to change the .o.cmd layout slightly, so I'd like to know what the rules are really

[RFC resend 1/2] modpost: delete stale comment

2018-03-22 Thread Rasmus Villemoes
Commit (7840fea200cd "kbuild: Fix computing srcversion for modules") fixed the comment above parse_source_files to refer to the new source_ line, but left this one behind that could still give the impression that drivers/net/dummy.c appears in the deps_ variable. Signed-off-by: Rasmus

[PATCH] MAINTAINERS: Update Kbuild entry with a few paths

2018-03-22 Thread Rasmus Villemoes
/Makefile itself, and add one matching the Kbuild.include file as well. Signed-off-by: Rasmus Villemoes --- Hi Kbuild maintainers. Hope you don't mind me extending this entry a bit. MAINTAINERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS

[RFC PATCH 2/2] modpost: sumversions: try to fix "same dir" logic

2018-03-22 Thread Rasmus Villemoes
e included file using . as starting point, we include it - otherwise it was found via some -I path, so do not include it". In any case, this is mostly just something I stumbled on because I'm about to change the .o.cmd layout slightly, so I'd like to know what the rules are really supp

[RFC PATCH 1/2] modpost: delete stale comment

2018-03-22 Thread Rasmus Villemoes
Commit (7840fea200cd "kbuild: Fix computing srcversion for modules") fixed the comment above parse_source_files to refer to the new source_ line, but left this one behind that could still give the impression that drivers/net/dummy.c appears in the deps_ variable. Signed-off-by: Rasmus

Re: detecting integer constant expressions in macros

2018-03-21 Thread Rasmus Villemoes
On 2018-03-21 00:08, Linus Torvalds wrote: > On Tue, Mar 20, 2018 at 3:13 PM, Uecker, Martin > wrote: >> >> here is an idea: > > That's not "an idea". > > That is either genius, or a seriously diseased mind. > > I can't quite tell which. > >> a test for integer constant expressions which retur

Re: [PATCH v5 0/2] Remove false-positive VLAs when using max()

2018-03-18 Thread Rasmus Villemoes
On 2018-03-18 22:33, Linus Torvalds wrote: > On Sun, Mar 18, 2018 at 2:13 PM, Rasmus Villemoes > wrote: >> On 2018-03-17 19:52, Linus Torvalds wrote: >>> >>> Ok, so it really looks like that same "__builtin_constant_p() doesn't >>> return a cons

Re: [PATCH] vfs: make sure struct filename->iname is word-aligned

2018-03-18 Thread Rasmus Villemoes
On 2018-03-01 00:19, Rasmus Villemoes wrote: > I noticed that offsetof(struct filename, iname) is actually 28 on 64 > bit platforms, so we always pass an unaligned pointer to > strncpy_from_user. This is mostly a problem for those 64 bit platforms > without HAVE_EFFICIENT_UNALIGNED

Re: [PATCH v5 0/2] Remove false-positive VLAs when using max()

2018-03-18 Thread Rasmus Villemoes
On 2018-03-17 19:52, Linus Torvalds wrote: > On Sat, Mar 17, 2018 at 12:27 AM, Kees Cook wrote: >> >> Unfortunately my 4.4 test fails quickly: >> >> ./include/linux/jiffies.h: In function ‘jiffies_delta_to_clock_t’: >> ./include/linux/jiffies.h:444: error: first argument to >> ‘__builtin_choose_ex

Re: [PATCH 1/4] gpio: Remove VLA from gpiolib

2018-03-18 Thread Rasmus Villemoes
On 2018-03-18 15:23, Lukas Wunner wrote: >>> >>> Other random thoughts: maybe two allocations for each loop iteration is >>> a bit much. Maybe do a first pass over the array and collect the maximal >>> chip->ngpio, do the memory allocation and freeing outside the loop (then >>> you'd of course need

Re: [PATCH][RFC] kernel.h: provide array iterator

2018-03-16 Thread Rasmus Villemoes
On 2018-03-15 11:00, Kieran Bingham wrote: > Simplify array iteration with a helper to iterate each entry in an array. > Utilise the existing ARRAY_SIZE macro to identify the length of the array > and pointer arithmetic to process each item as a for loop. > > Signed-off-by: Kieran Bingham > --- >

Re: [PATCH v4 1/2] kernel.h: Introduce const_max() for VLA removal

2018-03-16 Thread Rasmus Villemoes
On 2018-03-16 00:46, Linus Torvalds wrote: > On Thu, Mar 15, 2018 at 4:41 PM, Kees Cook wrote: >> >> I much prefer explicit typing, but both you and Rasmus mentioned >> wanting the int/sizeof_t mixing. > > Well, the explicit typing allows that mixing, in that you can just > have "const_max_t(5,si

[PATCH] x86: vdso: eliminate some redundant loads in update_vsyscall

2018-03-14 Thread Rasmus Villemoes
old new delta update_vsyscall 480 398 -82 (i386) update_vsyscall 304 281 -23 (x86_64) Signed-off-by: Rasmus Villemoes --- Other tricks are possible (reuse the initial monotonic_time com

Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers

2018-03-14 Thread Rasmus Villemoes
On 2018-03-14 15:09, Petr Mladek wrote: > diff --git a/lib/test_printf.c b/lib/test_printf.c > index 71ebfa43ad05..61c05a352d79 100644 > --- a/lib/test_printf.c > +++ b/lib/test_printf.c > @@ -207,14 +207,15 @@ test_string(void) > @@ -256,18 +259,18 @@ plain_hash(void) > * after an address is ha

Re: [PATCH] test_rhashtable: avoid gcc-8 -Wformat-overflow warning

2018-03-13 Thread Rasmus Villemoes
On 2018-03-13 14:21, Arnd Bergmann wrote: > gcc-8 warns about a code pattern that is used in the newly added > test_rhashtable code: > > lib/test_rhashtable.c: In function 'print_ht': > lib/test_rhashtable.c:511:21: error: ' > bucket[' directive writing 8 bytes into a region of size between 1 and

Re: [PATCH 1/4] gpio: Remove VLA from gpiolib

2018-03-13 Thread Rasmus Villemoes
On 2018-03-13 00:40, Laura Abbott wrote: > On 03/12/2018 08:00 AM, Rasmus Villemoes wrote: >> >> Hm, it seems you're now only clearing the first word of mask, not the >> entire allocation. Why not just use kcalloc() instead of kmalloc_array >> to have it automatica

Re: [PATCH 1/4] gpio: Remove VLA from gpiolib

2018-03-12 Thread Rasmus Villemoes
On 2018-03-10 01:10, Laura Abbott wrote: > /* collect all inputs belonging to the same chip */ > first = i; > - memset(mask, 0, sizeof(mask)); > + memset(mask, 0, sizeof(*mask)); see below > @@ -2887,14 +2909,30 @@ void gpiod_set_array_value_com

Re: a Heisenbug tale

2018-03-10 Thread Rasmus Villemoes
On 2018-03-09 10:45, Ard Biesheuvel wrote: > On 8 March 2018 at 23:19, Rasmus Villemoes wrote: >> On 2018-03-07 20:25, Leonard Crestez wrote: >>> Hello, >>> >> >> What we ended up doing was to explicitly set the mtime of every file in >> the repo to t

a Heisenbug tale (was: Re: arm crypto .S_shipped files sometimes get rebuilt randomly)

2018-03-08 Thread Rasmus Villemoes
On 2018-03-07 20:25, Leonard Crestez wrote: > Hello, > > I am using a toolchain with a broken/old version of perl which doesn't > include integer.pm and I noticed it triggers occasional build failures > on arch/arm64/crypto/sha512-core.S_shipped. Workarounds are easy, but > if the purpose of the .

Re: [PATCH 0/3] Remove accidental VLA usage

2018-03-08 Thread Rasmus Villemoes
On 8 March 2018 at 21:39, Kees Cook wrote: > On Thu, Mar 8, 2018 at 11:57 AM, Rasmus Villemoes > wrote: >> On 2018-03-08 16:02, Josh Poimboeuf wrote: >>> On Wed, Mar 07, 2018 at 07:30:44PM -0800, Kees Cook wrote: >>> +extern long __error_incompatible_types_

Re: [PATCH 0/3] Remove accidental VLA usage

2018-03-08 Thread Rasmus Villemoes
On 2018-03-08 16:02, Josh Poimboeuf wrote: > On Wed, Mar 07, 2018 at 07:30:44PM -0800, Kees Cook wrote: >> This series adds SIMPLE_MAX() to be used in places where a stack array >> is actually fixed, but the compiler still warns about VLA usage due to >> confusion caused by the safety checks in the

Re: [PATCH v2 1/3] vsprintf: Remove accidental VLA usage

2018-03-08 Thread Rasmus Villemoes
On 2018-03-08 04:30, Kees Cook wrote: > In the quest to remove all stack VLAs from the kernel[1], this introduces > a new "simple max" macro, and changes the "sym" array size calculation to > use it. The value is actually a fixed size, but since the max() macro uses > some extensive tricks for safe

Re: [PATCH] staging: lustre: Remove VLA usage

2018-03-07 Thread Rasmus Villemoes
On Wed, Mar 07 2018, Kees Cook wrote: > On Wed, Mar 7, 2018 at 5:10 AM, Rasmus Villemoes > wrote: >> On 2018-03-07 06:46, Kees Cook wrote: >>> The kernel would like to remove all VLA usage. This switches to a >>> simple kasprintf() instead. >>> >>

Re: [PATCH] staging: lustre: Remove VLA usage

2018-03-07 Thread Rasmus Villemoes
On 2018-03-07 06:46, Kees Cook wrote: > The kernel would like to remove all VLA usage. This switches to a > simple kasprintf() instead. > > Signed-off-by: Kees Cook > --- > drivers/staging/lustre/lustre/llite/xattr.c | 19 +-- > 1 file changed, 13 insertions(+), 6 deletions(-) >

Re: [PATCH] vsprintf: Make "null" pointer dereference more robust

2018-03-05 Thread Rasmus Villemoes
On 2 March 2018 at 13:53, Petr Mladek wrote: > %p has many modifiers where the pointer is dereferenced. An invalid > pointer might cause kernel to crash silently. > > Note that printk() formats the string under logbuf_lock. Any recursive > printks are redirected to the printk_safe implementation a

Re: [PATCH 3/3] fixdep: do not ignore kconfig.h

2018-03-05 Thread Rasmus Villemoes
On 5 March 2018 at 05:52, Masahiro Yamada wrote: > 2018-03-01 4:17 GMT+09:00 Rasmus Villemoes : >> kconfig.h was excluded from consideration by fixdep by >> 6a5be57f0f00 (fixdep: fix extraneous dependencies) to avoid some false >> positive hits [...] >> We've al

Re: [RFC 2/5] ia64/sn/hwperf: use seq_open_data

2018-03-02 Thread Rasmus Villemoes
On 2 March 2018 at 00:37, Rasmus Villemoes wrote: > This code should check the return value of seq_open(); if it failed, > file->private_data is NULL. But we can avoid the issue entirely and > simplify the code by letting seq_open_data() set the ->private member > to objbuf.

[RFC 3/5] powerpc/pseries: use seq_open_data in hcall_inst_seq_open

2018-03-01 Thread Rasmus Villemoes
This code should check the return value of seq_open(); if it failed, file->private_data is NULL. But we can avoid the issue entirely and simplify the code by letting seq_open_data() set the ->private member. Signed-off-by: Rasmus Villemoes --- arch/powerpc/platforms/pseries/hvCall_inst

[RFC 4/5] fm10k: use seq_open_data()

2018-03-01 Thread Rasmus Villemoes
Simplify the code slightly by having seq_open_data do the ->private assignment. Signed-off-by: Rasmus Villemoes --- drivers/net/ethernet/intel/fm10k/fm10k_debugfs.c | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_debugfs.c

[RFC 1/5] seq_file: introduce seq_open_data helper

2018-03-01 Thread Rasmus Villemoes
There are quite a few callers of seq_open that could be simplified by setting the ->private member via the seq_open call instead of fetching file->private_data afterwards. Signed-off-by: Rasmus Villemoes --- I've just included a few examples of possible users of this helper, there ar

[RFC 2/5] ia64/sn/hwperf: use seq_open_data

2018-03-01 Thread Rasmus Villemoes
This code should check the return value of seq_open(); if it failed, file->private_data is NULL. But we can avoid the issue entirely and simplify the code by letting seq_open_data() set the ->private member to objbuf. Signed-off-by: Rasmus Villemoes --- arch/ia64/sn/kernel/sn2/sn_hwperf

[RFC 5/5] PCI: tegra: use seq_open_data

2018-03-01 Thread Rasmus Villemoes
Simplify the code slightly by having seq_open_data do the ->private assignment. Signed-off-by: Rasmus Villemoes --- drivers/pci/host/pci-tegra.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c in

[PATCH resend] drivers/char/random.c: remove unused dont_count_entropy

2018-02-28 Thread Rasmus Villemoes
inux/kernel/git/tglx/history.git/commit/?id=c1c48e61c251f57e7a3f1bf11b3c462b2de9dcb5 Signed-off-by: Rasmus Villemoes --- drivers/char/random.c | 53 --- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/char/random.c b/drivers

[PATCH] vfs: make sure struct filename->iname is word-aligned

2018-02-28 Thread Rasmus Villemoes
nter to strncpy_from_user. Instead of explicit padding, simply swap the refcnt and aname members, as suggested by Al Viro. Signed-off-by: Rasmus Villemoes --- fs/namei.c | 2 ++ include/linux/fs.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/namei.c b/fs/n

[PATCH 3/3] fixdep: do not ignore kconfig.h

2018-02-28 Thread Rasmus Villemoes
/booger.h - we could change that to FOO if we care [2] https://lkml.org/lkml/2018/2/22/838 Cc: Linus Torvalds Signed-off-by: Rasmus Villemoes --- scripts/basic/fixdep.c | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 1b21870d6e7f..449b68c4c90c

[PATCH 1/3] fixdep: remove stale references to uml-config.h

2018-02-28 Thread Rasmus Villemoes
user-mode-linux-de...@lists.sourceforge.net Signed-off-by: Rasmus Villemoes --- scripts/basic/fixdep.c | 9 - 1 file changed, 9 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index fa3d39b6f23b..d7fbe545dd5d 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/

[PATCH 2/3] fixdep: remove some false CONFIG_ matches

2018-02-28 Thread Rasmus Villemoes
...) lines from the .o.cmd files. Signed-off-by: Rasmus Villemoes --- scripts/basic/fixdep.c | 5 + 1 file changed, 5 insertions(+) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index d7fbe545dd5d..1b21870d6e7f 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c

Re: [PATCH] EDAC, layerscape: allow building for LS1021A

2018-02-27 Thread Rasmus Villemoes
On 2018-02-22 22:22, York Sun wrote: > Then you are good to go. Great. Borislav, will you pick this up? Rasmus

Re: [PATCH/RFC] headers: drop 2 #included headers from

2018-02-25 Thread Rasmus Villemoes
On Fri, Feb 16 2018, Ingo Molnar wrote: > * Randy Dunlap wrote: > >> Does anyone know or see why needs or >> ? There are no direct uses in AFAICT. > > These are likely historical, plus it's a classic 'tragedy of the commons' > scenario: it's easy to take away from the "public good" of "clea

[PATCH v5 2/2] dt/bindings: Add bindings for Layerscape external irqs

2018-02-23 Thread Rasmus Villemoes
This adds Device Tree binding documentation for the external interrupt lines with configurable polarity present on some Layerscape SOCs. Signed-off-by: Rasmus Villemoes --- .../interrupt-controller/fsl,ls-extirq.txt | 44 ++ 1 file changed, 44 insertions(+) create

[PATCH v5 0/2] irqchip: add support for Layerscape external interrupt lines

2018-02-23 Thread Rasmus Villemoes
fiers Changes since v3: - Add non-empty commit log to 2/2 Changes since v2: - use fsl,bit-reverse rather than bit-reverse - make the dts node a child of the scfg node - make the node name "interrupt-controller" Rasmus Villemoes (2): irqchip: add support for Layerscape external inte

[PATCH v5 1/2] irqchip: add support for Layerscape external interrupt lines

2018-02-23 Thread Rasmus Villemoes
The LS1021A allows inverting the polarity of six interrupt lines IRQ[0:5] via the scfg_intpcr register, effectively allowing IRQ_TYPE_LEVEL_LOW and IRQ_TYPE_EDGE_FALLING for those. We just need to check the type, set the relevant bit in INTPCR accordingly, and fixup the type argument before calling

Re: [RFC PATCH] ARM: dts: ls1021a: add size-cells and address-cells to scfg and dcfg nodes

2018-02-23 Thread Rasmus Villemoes
On 2018-02-23 14:31, Rasmus Villemoes wrote: > A single u32 is sufficient to specify a register in the Device > Configuration Unit/Supplemental Configuration Unit. Moreover, they only > consist of 32 bit registers (for the DCFG we even have "These registers > only suppor

Re: [PATCH RFC v2 1/3] drivers: irqchip: pdc: Add PDC interrupt controller for QCOM SoCs

2018-02-23 Thread Rasmus Villemoes
On 2018-02-23 14:37, Marc Zyngier wrote: > Hi Rasmus, > > On 23/02/18 12:16, Rasmus Villemoes wrote: >> On 2018-02-02 15:58, Marc Zyngier wrote: >>> Why 3? Reading the DT binding, this is indeed set to 3 without any >>> reason. I'd suggest this beco

[RFC PATCH] ARM: dts: ls1021a: add size-cells and address-cells to scfg and dcfg nodes

2018-02-23 Thread Rasmus Villemoes
cification is needed. Signed-off-by: Rasmus Villemoes --- None of the in-tree .dts files using ls1021a.dtsi currently define a subnode of either node. It is possible, though somewhat unlikely, that some out-of-tree .dts file is built against the in-tree ls1021a.dtsi, and I don't know if

Re: [PATCH RFC v2 1/3] drivers: irqchip: pdc: Add PDC interrupt controller for QCOM SoCs

2018-02-23 Thread Rasmus Villemoes
On 2018-02-02 15:58, Marc Zyngier wrote: > Hi Lina, > > On 02/02/18 14:21, Lina Iyer wrote: >> From : Archana Sathyakumar >> >> + >> +static int qcom_pdc_translate(struct irq_domain *d, >> +struct irq_fwspec *fwspec, unsigned long *hwirq, unsigned int *type) >> +{ >> +if (is_of_node(fwspe

Re: [PATCH v3] kconfig.h: Include compiler types to avoid missed struct attributes

2018-02-22 Thread Rasmus Villemoes
On 2018-02-22 22:07, Rasmus Villemoes wrote: > > The whole point of fixdep and the include/config hierarchy is to be able > to remove the dependency on autoconf.h, but I'm not sure I understand > why kconfig.h itself is also forcibly removed. Ah, 6a5be57f "fixdep: fix e

Re: [PATCH v3] kconfig.h: Include compiler types to avoid missed struct attributes

2018-02-22 Thread Rasmus Villemoes
On 2018-02-22 19:04, Linus Torvalds wrote: > > Lookie here (in a fully built tree): > > find . -name '*.o.cmd' | > xargs grep -L linux/compiler_types.h | > xargs grep -l linux/kconfig.h | > while read i; do > j=$(echo $i | sed 's/\.o.cmd$/\.c/' | sed 's:/\.

Re: [PATCH] EDAC, layerscape: allow building for LS1021A

2018-02-22 Thread Rasmus Villemoes
On 2018-02-20 22:01, York Sun wrote: > Sorry for top posting. I am on vacation and replying from my phone. > > The controller is compatible and the driver should work. Please double check > to make sure you can inject errors and receive interrupt. After that you are > good to go. I can indeed i

Re: [PATCH 2/2] proc: use set_puts() at /proc/*/wchan

2018-02-21 Thread Rasmus Villemoes
On 2018-02-21 01:02, Andrew Morton wrote: > On Sat, 17 Feb 2018 16:06:42 +0200 Andy Shevchenko > wrote: > >> On Sat, Feb 17, 2018 at 9:20 AM, Alexey Dobriyan wrote: >>> Signed-off-by: Alexey Dobriyan >> >> >>> - seq_printf(m, "%s", symname); >>> + seq_puts(m, symnam

Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt

2018-02-20 Thread Rasmus Villemoes
On 2018-02-21 00:55, Joe Perches wrote: > On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote: >> There are users which print time and date represented by content of >> struct rtc_time in human readable format. >> >> Instead of open coding that each time introduce %ptR[dt][rv] specifier. >> >>

[PATCH] EDAC, layerscape: allow building for LS1021A

2018-02-20 Thread Rasmus Villemoes
The LS1021A has a memory controller supported by this driver. It builds just fine, and I've done some rudimentary testing using the error injection facility, which suggests that it is indeed working. Signed-off-by: Rasmus Villemoes --- Hi York In https://patchwork.kernel.org/patch/9264623/

Re: 500 ms delay in time saved into RTC

2018-02-19 Thread Rasmus Villemoes
On 2018-02-19 11:07, Alexandre Belloni wrote: > On 19/02/2018 at 12:16:04 +0300, Igor Plyatov wrote: >> Dear Rasmus, >> >> thank you very much for explanation! >> >> I have set "RTC_SET_DELAY_SECS = 0.0" in hwclock.c and got acceptable >> result. >> >> It wonder why such critical function does not

<    4   5   6   7   8   9   10   11   12   13   >