diff options
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r-- | net/xfrm/xfrm_user.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 783332987491..9103af02473c 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -1890,7 +1890,7 @@ static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | |||
1890 | } | 1890 | } |
1891 | #endif | 1891 | #endif |
1892 | 1892 | ||
1893 | #define XMSGSIZE(type) NLMSG_LENGTH(sizeof(struct type)) | 1893 | #define XMSGSIZE(type) sizeof(struct type) |
1894 | 1894 | ||
1895 | static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = { | 1895 | static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = { |
1896 | [XFRM_MSG_NEWSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info), | 1896 | [XFRM_MSG_NEWSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info), |
@@ -1906,13 +1906,13 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = { | |||
1906 | [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info), | 1906 | [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info), |
1907 | [XFRM_MSG_POLEXPIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_polexpire), | 1907 | [XFRM_MSG_POLEXPIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_polexpire), |
1908 | [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush), | 1908 | [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush), |
1909 | [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = NLMSG_LENGTH(0), | 1909 | [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = 0, |
1910 | [XFRM_MSG_NEWAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), | 1910 | [XFRM_MSG_NEWAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), |
1911 | [XFRM_MSG_GETAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), | 1911 | [XFRM_MSG_GETAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), |
1912 | [XFRM_MSG_REPORT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report), | 1912 | [XFRM_MSG_REPORT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report), |
1913 | [XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id), | 1913 | [XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id), |
1914 | [XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = NLMSG_LENGTH(sizeof(u32)), | 1914 | [XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = sizeof(u32), |
1915 | [XFRM_MSG_GETSPDINFO - XFRM_MSG_BASE] = NLMSG_LENGTH(sizeof(u32)), | 1915 | [XFRM_MSG_GETSPDINFO - XFRM_MSG_BASE] = sizeof(u32), |
1916 | }; | 1916 | }; |
1917 | 1917 | ||
1918 | #undef XMSGSIZE | 1918 | #undef XMSGSIZE |
@@ -1946,9 +1946,9 @@ static struct xfrm_link { | |||
1946 | 1946 | ||
1947 | static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | 1947 | static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
1948 | { | 1948 | { |
1949 | struct rtattr *xfrma[XFRMA_MAX]; | 1949 | struct nlattr *xfrma[XFRMA_MAX+1]; |
1950 | struct xfrm_link *link; | 1950 | struct xfrm_link *link; |
1951 | int type, min_len; | 1951 | int type, err; |
1952 | 1952 | ||
1953 | type = nlh->nlmsg_type; | 1953 | type = nlh->nlmsg_type; |
1954 | if (type > XFRM_MSG_MAX) | 1954 | if (type > XFRM_MSG_MAX) |
@@ -1970,30 +1970,16 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1970 | return netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL); | 1970 | return netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL); |
1971 | } | 1971 | } |
1972 | 1972 | ||
1973 | memset(xfrma, 0, sizeof(xfrma)); | 1973 | /* FIXME: Temporary hack, nlmsg_parse() starts at xfrma[1], old code |
1974 | 1974 | * expects first attribute at xfrma[0] */ | |
1975 | if (nlh->nlmsg_len < (min_len = xfrm_msg_min[type])) | 1975 | err = nlmsg_parse(nlh, xfrm_msg_min[type], xfrma-1, XFRMA_MAX, NULL); |
1976 | return -EINVAL; | 1976 | if (err < 0) |
1977 | 1977 | return err; | |
1978 | if (nlh->nlmsg_len > min_len) { | ||
1979 | int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len); | ||
1980 | struct rtattr *attr = (void *) nlh + NLMSG_ALIGN(min_len); | ||
1981 | |||
1982 | while (RTA_OK(attr, attrlen)) { | ||
1983 | unsigned short flavor = attr->rta_type; | ||
1984 | if (flavor) { | ||
1985 | if (flavor > XFRMA_MAX) | ||
1986 | return -EINVAL; | ||
1987 | xfrma[flavor - 1] = attr; | ||
1988 | } | ||
1989 | attr = RTA_NEXT(attr, attrlen); | ||
1990 | } | ||
1991 | } | ||
1992 | 1978 | ||
1993 | if (link->doit == NULL) | 1979 | if (link->doit == NULL) |
1994 | return -EINVAL; | 1980 | return -EINVAL; |
1995 | 1981 | ||
1996 | return link->doit(skb, nlh, xfrma); | 1982 | return link->doit(skb, nlh, (struct rtattr **) xfrma); |
1997 | } | 1983 | } |
1998 | 1984 | ||
1999 | static void xfrm_netlink_rcv(struct sock *sk, int len) | 1985 | static void xfrm_netlink_rcv(struct sock *sk, int len) |