Patch "crypto: af_alg - Fix race around ctx->rcvused by making it atomic_t" has been added to the 4.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
crypto: af_alg - Fix race around ctx->rcvused by making it atomic_t
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
crypto-af_alg-fix-race-around-ctx-rcvused-by-making-it-atomic_t.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Wed Feb 28 16:23:28 CET 2018
From: Jonathan Cameron <[email protected]>
Date: Tue, 19 Dec 2017 10:27:24 +0000
Subject: crypto: af_alg - Fix race around ctx->rcvused by making it atomic_t
From: Jonathan Cameron <[email protected]>
[ Upstream commit af955bf15d2c27496b0269b1f05c26f758c68314 ]
This variable was increased and decreased without any protection. Result was an occasional misscount and negative wrap around resulting in false resource allocation failures.
--- crypto/af_alg.c | 4 ++-- crypto/algif_aead.c | 2 +- crypto/algif_skcipher.c | 2 +- include/crypto/if_alg.h | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-)
crypto/af_alg.c +2 -2
@@ -693,7 +693,7 @@ void af_alg_free_areq_sgls(struct af_algunsigned int i;list_for_each_entry_safe (rsgl, tmp, &areq->rsgl_list, list) { - ctx->rcvused -= rsgl->sg_num_bytes; +atomic_sub (rsgl->sg_num_bytes, &ctx->rcvused);af_alg_free_sg (&rsgl->sgl);list_del (&rsgl->list);if (rsgl != &areq->first_rsgl)
@@ -1192,7 +1192,7 @@ int af_alg_get_rsgl(struct sock *sk, str areq->last_rsgl = rsgl; len += err; - ctx->rcvused += err; +atomic_add (err, &ctx->rcvused); rsgl->sg_num_bytes = err;iov_iter_advance (&msg->msg_iter, err); }
crypto/algif_aead.c +1 -1
@@ -571,7 +571,7 @@ static int aead_accept_parent_nokey(voidINIT_LIST_HEAD (&ctx->tsgl_list); ctx->len = len; ctx->used =0 ; - ctx->rcvused =0 ; +atomic_set (&ctx->rcvused,0 ); ctx->more =0 ; ctx->merge =0 ; ctx->enc =0 ;
crypto/algif_skcipher.c +1 -1
@@ -391,7 +391,7 @@ static int skcipher_accept_parent_nokey(INIT_LIST_HEAD (&ctx->tsgl_list); ctx->len = len; ctx->used =0 ; - ctx->rcvused =0 ; +atomic_set (&ctx->rcvused,0 ); ctx->more =0 ; ctx->merge =0 ; ctx->enc =0 ;
include/crypto/if_alg.h +3 -2
@@ -18,6 +18,7 @@#include <linux/if_alg.h> #include <linux/scatterlist.h> #include <linux/types.h> +#include <linux/atomic.h> #include <net/sock.h> #include <crypto/aead.h>
@@ -155,7 +156,7 @@ struct af_alg_ctx {struct af_alg_completion completion;size_t used; -size_t rcvused; +atomic_t rcvused;bool more;bool merge;
@@ -228,7 +229,7 @@ static inline int af_alg_rcvbuf(struct sstruct af_alg_ctx *ctx = ask->private;return max_t (int,max_t (int, sk->sk_rcvbuf &PAGE_MASK ,PAGE_SIZE ) - - ctx->rcvused,0 ); +atomic_read (&ctx->rcvused),0 ); }/**
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/crypto-af_alg-fix-race-around-ctx-rcvused-by-making-it-atomic_t.patch