diff options
author | Xin Long <lucien.xin@gmail.com> | 2016-02-03 10:33:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-09 04:53:16 -0500 |
commit | 7a84bd46647ff181eb2659fdc99590e6f16e501d (patch) | |
tree | de102ab893fa2f1714836691658e0735bd27c115 | |
parent | ca7f41a4957b872577807169bd7464b36aae9b9c (diff) |
sctp: translate network order to host order when users get a hmacid
Commit ed5a377d87dc ("sctp: translate host order to network order when
setting a hmacid") corrected the hmacid byte-order when setting a hmacid.
but the same issue also exists on getting a hmacid.
We fix it by changing hmacids to host order when users get them with
getsockopt.
Fixes: Commit ed5a377d87dc ("sctp: translate host order to network order when setting a hmacid")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/sctp/socket.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 5ca2ebfe0be8..e878da0949db 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -5538,6 +5538,7 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, | |||
5538 | struct sctp_hmac_algo_param *hmacs; | 5538 | struct sctp_hmac_algo_param *hmacs; |
5539 | __u16 data_len = 0; | 5539 | __u16 data_len = 0; |
5540 | u32 num_idents; | 5540 | u32 num_idents; |
5541 | int i; | ||
5541 | 5542 | ||
5542 | if (!ep->auth_enable) | 5543 | if (!ep->auth_enable) |
5543 | return -EACCES; | 5544 | return -EACCES; |
@@ -5555,8 +5556,12 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, | |||
5555 | return -EFAULT; | 5556 | return -EFAULT; |
5556 | if (put_user(num_idents, &p->shmac_num_idents)) | 5557 | if (put_user(num_idents, &p->shmac_num_idents)) |
5557 | return -EFAULT; | 5558 | return -EFAULT; |
5558 | if (copy_to_user(p->shmac_idents, hmacs->hmac_ids, data_len)) | 5559 | for (i = 0; i < num_idents; i++) { |
5559 | return -EFAULT; | 5560 | __u16 hmacid = ntohs(hmacs->hmac_ids[i]); |
5561 | |||
5562 | if (copy_to_user(&p->shmac_idents[i], &hmacid, sizeof(__u16))) | ||
5563 | return -EFAULT; | ||
5564 | } | ||
5560 | return 0; | 5565 | return 0; |
5561 | } | 5566 | } |
5562 | 5567 | ||