inet_diag.c (cc9263874b42bf98209dce0afe698b550648e770) | inet_diag.c (627cc4add53c0470bfd118002669205d222d3a54) |
---|---|
1/* 2 * inet_diag.c Module for monitoring INET transport protocols sockets. 3 * 4 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 692 unchanged lines hidden (view full) --- 701{ 702 /* Port comparisons put the port in a follow-on inet_diag_bc_op. */ 703 *min_len += sizeof(struct inet_diag_bc_op); 704 if (len < *min_len) 705 return false; 706 return true; 707} 708 | 1/* 2 * inet_diag.c Module for monitoring INET transport protocols sockets. 3 * 4 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 692 unchanged lines hidden (view full) --- 701{ 702 /* Port comparisons put the port in a follow-on inet_diag_bc_op. */ 703 *min_len += sizeof(struct inet_diag_bc_op); 704 if (len < *min_len) 705 return false; 706 return true; 707} 708 |
709static int inet_diag_bc_audit(const void *bytecode, int bytecode_len) | 709static int inet_diag_bc_audit(const struct nlattr *attr) |
710{ | 710{ |
711 const void *bc = bytecode; 712 int len = bytecode_len; | 711 const void *bytecode, *bc; 712 int bytecode_len, len; |
713 | 713 |
714 if (!attr || nla_len(attr) < sizeof(struct inet_diag_bc_op)) 715 return -EINVAL; 716 717 bytecode = bc = nla_data(attr); 718 len = bytecode_len = nla_len(attr); 719 |
|
714 while (len > 0) { 715 int min_len = sizeof(struct inet_diag_bc_op); 716 const struct inet_diag_bc_op *op = bc; 717 718 switch (op->code) { 719 case INET_DIAG_BC_S_COND: 720 case INET_DIAG_BC_D_COND: 721 if (!valid_hostcond(bc, len, &min_len)) --- 293 unchanged lines hidden (view full) --- 1015 1016 if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX || 1017 nlmsg_len(nlh) < hdrlen) 1018 return -EINVAL; 1019 1020 if (nlh->nlmsg_flags & NLM_F_DUMP) { 1021 if (nlmsg_attrlen(nlh, hdrlen)) { 1022 struct nlattr *attr; | 720 while (len > 0) { 721 int min_len = sizeof(struct inet_diag_bc_op); 722 const struct inet_diag_bc_op *op = bc; 723 724 switch (op->code) { 725 case INET_DIAG_BC_S_COND: 726 case INET_DIAG_BC_D_COND: 727 if (!valid_hostcond(bc, len, &min_len)) --- 293 unchanged lines hidden (view full) --- 1021 1022 if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX || 1023 nlmsg_len(nlh) < hdrlen) 1024 return -EINVAL; 1025 1026 if (nlh->nlmsg_flags & NLM_F_DUMP) { 1027 if (nlmsg_attrlen(nlh, hdrlen)) { 1028 struct nlattr *attr; |
1029 int err; |
|
1023 1024 attr = nlmsg_find_attr(nlh, hdrlen, 1025 INET_DIAG_REQ_BYTECODE); | 1030 1031 attr = nlmsg_find_attr(nlh, hdrlen, 1032 INET_DIAG_REQ_BYTECODE); |
1026 if (!attr || 1027 nla_len(attr) < sizeof(struct inet_diag_bc_op) || 1028 inet_diag_bc_audit(nla_data(attr), nla_len(attr))) 1029 return -EINVAL; | 1033 err = inet_diag_bc_audit(attr); 1034 if (err) 1035 return err; |
1030 } 1031 { 1032 struct netlink_dump_control c = { 1033 .dump = inet_diag_dump_compat, 1034 }; 1035 return netlink_dump_start(net->diag_nlsk, skb, nlh, &c); 1036 } 1037 } --- 8 unchanged lines hidden (view full) --- 1046 1047 if (nlmsg_len(h) < hdrlen) 1048 return -EINVAL; 1049 1050 if (h->nlmsg_type == SOCK_DIAG_BY_FAMILY && 1051 h->nlmsg_flags & NLM_F_DUMP) { 1052 if (nlmsg_attrlen(h, hdrlen)) { 1053 struct nlattr *attr; | 1036 } 1037 { 1038 struct netlink_dump_control c = { 1039 .dump = inet_diag_dump_compat, 1040 }; 1041 return netlink_dump_start(net->diag_nlsk, skb, nlh, &c); 1042 } 1043 } --- 8 unchanged lines hidden (view full) --- 1052 1053 if (nlmsg_len(h) < hdrlen) 1054 return -EINVAL; 1055 1056 if (h->nlmsg_type == SOCK_DIAG_BY_FAMILY && 1057 h->nlmsg_flags & NLM_F_DUMP) { 1058 if (nlmsg_attrlen(h, hdrlen)) { 1059 struct nlattr *attr; |
1060 int err; |
|
1054 1055 attr = nlmsg_find_attr(h, hdrlen, 1056 INET_DIAG_REQ_BYTECODE); | 1061 1062 attr = nlmsg_find_attr(h, hdrlen, 1063 INET_DIAG_REQ_BYTECODE); |
1057 if (!attr || 1058 nla_len(attr) < sizeof(struct inet_diag_bc_op) || 1059 inet_diag_bc_audit(nla_data(attr), nla_len(attr))) 1060 return -EINVAL; | 1064 err = inet_diag_bc_audit(attr); 1065 if (err) 1066 return err; |
1061 } 1062 { 1063 struct netlink_dump_control c = { 1064 .dump = inet_diag_dump, 1065 }; 1066 return netlink_dump_start(net->diag_nlsk, skb, h, &c); 1067 } 1068 } --- 141 unchanged lines hidden --- | 1067 } 1068 { 1069 struct netlink_dump_control c = { 1070 .dump = inet_diag_dump, 1071 }; 1072 return netlink_dump_start(net->diag_nlsk, skb, h, &c); 1073 } 1074 } --- 141 unchanged lines hidden --- |