Skip to content

Commit

Permalink
crypto: lib/chacha20poly1305 - Set SG_MITER_ATOMIC unconditionally
Browse files Browse the repository at this point in the history
There is no reason for the chacha20poly1305 SG miter code to use
kmap instead of kmap_atomic as the critical section doesn't sleep
anyway.  So we can simply get rid of the preemptible check and
set SG_MITER_ATOMIC unconditionally.

Even if we need to reenable preemption to lower latency we should
be doing that by interrupting the SG miter walk rather than using
kmap.

Reported-by: Linus Torvalds <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Sep 25, 2020
1 parent 63cdd87 commit 255f6c2
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/crypto/chacha20poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ bool chacha20poly1305_crypt_sg_inplace(struct scatterlist *src,
poly1305_update(&poly1305_state, pad0, 0x10 - (ad_len & 0xf));
}

flags = SG_MITER_TO_SG;
if (!preemptible())
flags |= SG_MITER_ATOMIC;
flags = SG_MITER_TO_SG | SG_MITER_ATOMIC;

sg_miter_start(&miter, src, sg_nents(src), flags);

Expand Down

0 comments on commit 255f6c2

Please sign in to comment.