[PATCH net 1/2] net: sctp: sctp_auth_make_key_vector: fix undefined ref-count behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In sctp_auth_make_key_vector(), a sctp_auth_bytes structure is being
allocated, but without setting its object reference count, thus it's
initialized with a random value from the memory, which can lead to
i) premature free's of this object when being put (with possible
subsequent kernel panics), or ii) memory leaks when refcount has a
high value.

Fix this by using the appropriate sctp_auth_create_key() allocator,
which performs sanity checks, sets length and the refcount, as similar
done in sctp_auth_asoc_set_secret() and others. This bug seems to be
present since 2007 (1f485649f529: Implement SCTP-AUTH internals).

Signed-off-by: Daniel Borkmann <dborkman@xxxxxxxxxx>
---
 net/sctp/auth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 159b9bc..55f1b06 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -205,12 +205,10 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector(
         if (chunks)
 		len += ntohs(chunks->param_hdr.length);
 
-	new = kmalloc(sizeof(struct sctp_auth_bytes) + len, gfp);
+	new = sctp_auth_create_key(len, gfp);
 	if (!new)
 		return NULL;
 
-	new->len = len;
-
 	memcpy(new->data, random, ntohs(random->param_hdr.length));
 	offset += ntohs(random->param_hdr.length);
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Networking Development]     [Linux OMAP]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux