Re: [dm-devel] [PATCH v3] md: dm-init: Wait devices if it's not find on first adpet

2022-04-24 Thread Michael Nazzareno Trimarchi
Hi all On Wed, Apr 6, 2022 at 5:46 PM Fabio Aiuto wrote: > > From: Michael Trimarchi > > The device driver can be deferrable and can be a race during > the dm-init early. We need to wait all the probe are really finished > in a loop as is done in do_mounts. This is was tested on kernel 5.4 >

Re: [dm-devel] [PATCH] hex2bin: make the function hex_to_bin constant-time

2022-04-24 Thread Linus Torvalds
On Sun, Apr 24, 2022 at 2:37 PM Linus Torvalds wrote: > > Finally, for the same reason - please don't use ">> 8". Because I do > not believe that bit 8 is well-defined in your arithmetic. The *sign* > bit will be, but I'm not convinced bit 8 is. Hmm.. I think it's ok. It can indeed overflow in

Re: [dm-devel] [PATCH] hex2bin: make the function hex_to_bin constant-time

2022-04-24 Thread Linus Torvalds
On Sun, Apr 24, 2022 at 1:54 PM Mikulas Patocka wrote: > > + * > + * Explanation of the logic: > + * (ch - '9' - 1) is negative if ch <= '9' > + * ('0' - 1 - ch) is negative if ch >= '0' True, but... Please, just to make me happier, make the sign of 'ch' be something very explicit. Right now

Re: [dm-devel] [PATCH] hex2bin: make the function hex_to_bin constant-time

2022-04-24 Thread Joe Perches
On Sun, 2022-04-24 at 16:54 -0400, Mikulas Patocka wrote: > This patch changes the function hex_to_bin so that it contains no branches > and no memory accesses. [] > +++ linux-2.6/lib/hexdump.c 2022-04-24 18:51:20.0 +0200 [] > + * the next line is similar to the previous one, but we need

[dm-devel] [PATCH] dm-crypt: make printing of the key constant-time

2022-04-24 Thread Mikulas Patocka
The device mapper dm-crypt target is using scnprintf("%02x", cc->key[i]) to report the current key to userspace. However, this is not constant-time operation and it may leak information about the key via timing, via cache access patterns or via the branch predictor. This patch changes it to use

[dm-devel] [PATCH] hex2bin: make the function hex_to_bin constant-time

2022-04-24 Thread Mikulas Patocka
The function hex2bin is used to load cryptographic keys into device mapper targets dm-crypt and dm-integrity. It should take constant time independent on the processed data, so that concurrently running unprivileged code can't infer any information about the keys via microarchitectural convert

[dm-devel] [PATCH] hex2bin: fix access beyond string end

2022-04-24 Thread Mikulas Patocka
If we pass too short string to "hex2bin" (and the string size without the terminating NUL character is even), "hex2bin" reads one byte after the terminating NUL character. This patch fixes it. Signed-off-by: Mikulas Patocka Cc: sta...@vger.kernel.org --- lib/hexdump.c |9 ++--- 1 file

[dm-devel] [PATCH] dm-stats: add cond_resched when looping over entries

2022-04-24 Thread Mikulas Patocka
dm-stats can be used with very large number of entries (it is only limited by 1/4 of total system memory), so we should add rescheduling points to the loops that iterate over the entries. Signed-off-by: Mikulas Patocka Cc: sta...@vger.kernel.org --- drivers/md/dm-stats.c |8 1