summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorOndrej Mosnacek <omosnace@redhat.com>2018-11-13 16:16:08 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-21 09:19:24 +0100
commitc75e3cbfd91b421747d1ff74f706315855706297 (patch)
tree219a4cdb8f342bd3f8b6406e2793d92548ddfe62 /security
parent18cd6106cf9b427ae072964c7c36b05df5704cd3 (diff)
downloadlinux-stable-c75e3cbfd91b421747d1ff74f706315855706297.tar.gz
linux-stable-c75e3cbfd91b421747d1ff74f706315855706297.tar.bz2
linux-stable-c75e3cbfd91b421747d1ff74f706315855706297.zip
selinux: check length properly in SCTP bind hook
commit c138325fb8713472d5a0c3c7258b9131bab40725 upstream. selinux_sctp_bind_connect() must verify if the address buffer has sufficient length before accessing the 'sa_family' field. See __sctp_connect() for a similar check. The length of the whole address ('len') is already checked in the callees. Reported-by: Qian Cai <cai@gmx.us> Fixes: d452930fd3b9 ("selinux: Add SCTP support") Cc: <stable@vger.kernel.org> # 4.17+ Cc: Richard Haines <richard_c_haines@btinternet.com> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Tested-by: Qian Cai <cai@gmx.us> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/hooks.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 18b98b5e1e3c..fe251c6f09f1 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -5318,6 +5318,9 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
addr_buf = address;
while (walk_size < addrlen) {
+ if (walk_size + sizeof(sa_family_t) > addrlen)
+ return -EINVAL;
+
addr = addr_buf;
switch (addr->sa_family) {
case AF_UNSPEC: