Revert "xfrm: rate limit SA mapping change message to user space"

This reverts commit a0b13335a3 which is
commit 4e484b3e969b52effd95c17f7a86f39208b2ccf4 upstream.

It breaks the Android kernel ABI and is not a problem for Android
systems, so revert it.

Bug: 161946584
Fixes: a0b13335a3 ("xfrm: rate limit SA mapping change message to user space")
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I00273c8a02ac367e0b429d7d8793ea2686752f77
This commit is contained in:
Greg Kroah-Hartman
2022-01-31 18:39:43 +01:00
parent 67ea95e0e8
commit a50b069165
5 changed files with 4 additions and 49 deletions

View File

@@ -193,11 +193,6 @@ struct xfrm_state {
struct xfrm_algo_aead *aead; struct xfrm_algo_aead *aead;
const char *geniv; const char *geniv;
/* mapping change rate limiting */
__be16 new_mapping_sport;
u32 new_mapping; /* seconds */
u32 mapping_maxage; /* seconds for input SA */
/* Data for encapsulator */ /* Data for encapsulator */
struct xfrm_encap_tmpl *encap; struct xfrm_encap_tmpl *encap;
struct sock __rcu *encap_sk; struct sock __rcu *encap_sk;

View File

@@ -308,7 +308,6 @@ enum xfrm_attr_type_t {
XFRMA_SET_MARK, /* __u32 */ XFRMA_SET_MARK, /* __u32 */
XFRMA_SET_MARK_MASK, /* __u32 */ XFRMA_SET_MARK_MASK, /* __u32 */
XFRMA_IF_ID, /* __u32 */ XFRMA_IF_ID, /* __u32 */
XFRMA_MTIMER_THRESH, /* __u32 in seconds for input SA */
__XFRMA_MAX __XFRMA_MAX
#define XFRMA_OUTPUT_MARK XFRMA_SET_MARK /* Compatibility */ #define XFRMA_OUTPUT_MARK XFRMA_SET_MARK /* Compatibility */

View File

@@ -127,7 +127,6 @@ static const struct nla_policy compat_policy[XFRMA_MAX+1] = {
[XFRMA_SET_MARK] = { .type = NLA_U32 }, [XFRMA_SET_MARK] = { .type = NLA_U32 },
[XFRMA_SET_MARK_MASK] = { .type = NLA_U32 }, [XFRMA_SET_MARK_MASK] = { .type = NLA_U32 },
[XFRMA_IF_ID] = { .type = NLA_U32 }, [XFRMA_IF_ID] = { .type = NLA_U32 },
[XFRMA_MTIMER_THRESH] = { .type = NLA_U32 },
}; };
static struct nlmsghdr *xfrm_nlmsg_put_compat(struct sk_buff *skb, static struct nlmsghdr *xfrm_nlmsg_put_compat(struct sk_buff *skb,
@@ -275,10 +274,9 @@ static int xfrm_xlate64_attr(struct sk_buff *dst, const struct nlattr *src)
case XFRMA_SET_MARK: case XFRMA_SET_MARK:
case XFRMA_SET_MARK_MASK: case XFRMA_SET_MARK_MASK:
case XFRMA_IF_ID: case XFRMA_IF_ID:
case XFRMA_MTIMER_THRESH:
return xfrm_nla_cpy(dst, src, nla_len(src)); return xfrm_nla_cpy(dst, src, nla_len(src));
default: default:
BUILD_BUG_ON(XFRMA_MAX != XFRMA_MTIMER_THRESH); BUILD_BUG_ON(XFRMA_MAX != XFRMA_IF_ID);
pr_warn_once("unsupported nla_type %d\n", src->nla_type); pr_warn_once("unsupported nla_type %d\n", src->nla_type);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
@@ -433,7 +431,7 @@ static int xfrm_xlate32_attr(void *dst, const struct nlattr *nla,
int err; int err;
if (type > XFRMA_MAX) { if (type > XFRMA_MAX) {
BUILD_BUG_ON(XFRMA_MAX != XFRMA_MTIMER_THRESH); BUILD_BUG_ON(XFRMA_MAX != XFRMA_IF_ID);
NL_SET_ERR_MSG(extack, "Bad attribute"); NL_SET_ERR_MSG(extack, "Bad attribute");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }

View File

@@ -1557,9 +1557,6 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
x->km.seq = orig->km.seq; x->km.seq = orig->km.seq;
x->replay = orig->replay; x->replay = orig->replay;
x->preplay = orig->preplay; x->preplay = orig->preplay;
x->mapping_maxage = orig->mapping_maxage;
x->new_mapping = 0;
x->new_mapping_sport = 0;
return x; return x;
@@ -2211,7 +2208,7 @@ int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol)
} }
EXPORT_SYMBOL(km_query); EXPORT_SYMBOL(km_query);
static int __km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport) int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport)
{ {
int err = -EINVAL; int err = -EINVAL;
struct xfrm_mgr *km; struct xfrm_mgr *km;
@@ -2226,24 +2223,6 @@ static int __km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16
rcu_read_unlock(); rcu_read_unlock();
return err; return err;
} }
int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport)
{
int ret = 0;
if (x->mapping_maxage) {
if ((jiffies / HZ - x->new_mapping) > x->mapping_maxage ||
x->new_mapping_sport != sport) {
x->new_mapping_sport = sport;
x->new_mapping = jiffies / HZ;
ret = __km_new_mapping(x, ipaddr, sport);
}
} else {
ret = __km_new_mapping(x, ipaddr, sport);
}
return ret;
}
EXPORT_SYMBOL(km_new_mapping); EXPORT_SYMBOL(km_new_mapping);
void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 portid) void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 portid)

View File

@@ -282,10 +282,6 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
err = 0; err = 0;
if (attrs[XFRMA_MTIMER_THRESH])
if (!attrs[XFRMA_ENCAP])
err = -EINVAL;
out: out:
return err; return err;
} }
@@ -525,7 +521,6 @@ static void xfrm_update_ae_params(struct xfrm_state *x, struct nlattr **attrs,
struct nlattr *lt = attrs[XFRMA_LTIME_VAL]; struct nlattr *lt = attrs[XFRMA_LTIME_VAL];
struct nlattr *et = attrs[XFRMA_ETIMER_THRESH]; struct nlattr *et = attrs[XFRMA_ETIMER_THRESH];
struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH]; struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH];
struct nlattr *mt = attrs[XFRMA_MTIMER_THRESH];
if (re) { if (re) {
struct xfrm_replay_state_esn *replay_esn; struct xfrm_replay_state_esn *replay_esn;
@@ -557,9 +552,6 @@ static void xfrm_update_ae_params(struct xfrm_state *x, struct nlattr **attrs,
if (rt) if (rt)
x->replay_maxdiff = nla_get_u32(rt); x->replay_maxdiff = nla_get_u32(rt);
if (mt)
x->mapping_maxage = nla_get_u32(mt);
} }
static void xfrm_smark_init(struct nlattr **attrs, struct xfrm_mark *m) static void xfrm_smark_init(struct nlattr **attrs, struct xfrm_mark *m)
@@ -977,13 +969,8 @@ static int copy_to_user_state_extra(struct xfrm_state *x,
if (ret) if (ret)
goto out; goto out;
} }
if (x->security) { if (x->security)
ret = copy_sec_ctx(x->security, skb); ret = copy_sec_ctx(x->security, skb);
if (ret)
goto out;
}
if (x->mapping_maxage)
ret = nla_put_u32(skb, XFRMA_MTIMER_THRESH, x->mapping_maxage);
out: out:
return ret; return ret;
} }
@@ -2940,9 +2927,6 @@ static inline unsigned int xfrm_sa_len(struct xfrm_state *x)
/* Must count x->lastused as it may become non-zero behind our back. */ /* Must count x->lastused as it may become non-zero behind our back. */
l += nla_total_size_64bit(sizeof(u64)); l += nla_total_size_64bit(sizeof(u64));
if (x->mapping_maxage)
l += nla_total_size(sizeof(x->mapping_maxage));
return l; return l;
} }