xfrm: misc bugfixes
Subsystems (3)
cover xfrm: misc bugfixes
These patches fix a few small bugs in IPsec.
Sabrina Dubroca (4):
xfrm: add missing extack for XFRMA_SA_PCPU in add_acquire and allocspi
xfrm: fix the condition on x->pcpu_num in xfrm_sa_len
xfrm: call xdo_dev_state_delete during state update
esp: fix skb leak with espintcp and async crypto
net/ipv4/esp4.c | 9 ++++++--- net/ipv6/esp6.c | 9 ++++++--- net/xfrm/xfrm_state.c | 1 + net/xfrm/xfrm_user.c | 7 +++++-- 4 files changed, 18 insertions(+), 8 deletions(-)
Signature · 1 line
2.51.2
PATCH 1/4 xfrm: add missing extack for XFRMA_SA_PCPU in add_acquire and allocspi
We're returning an error caused by invalid user input without setting an extack. Add one.
--- net/xfrm/xfrm_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +4 -1
@@ -1850,6 +1850,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, pcpu_num =nla_get_u32 (attrs[XFRMA_SA_PCPU ]);if (pcpu_num >=num_possible_cpus ()) { err = -EINVAL ; +NL_SET_ERR_MSG (extack,"pCPU number too big" ); goto out_noput; } }
@@ -3001,8 +3002,10 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,if (attrs[XFRMA_SA_PCPU ]) { x->pcpu_num =nla_get_u32 (attrs[XFRMA_SA_PCPU ]); err = -EINVAL ; -if (x->pcpu_num >=num_possible_cpus ()) +if (x->pcpu_num >=num_possible_cpus ()) { +NL_SET_ERR_MSG (extack,"pCPU number too big" ); goto free_state; + } } err =verify_newpolicy_info (&ua->policy, extack);
Signature · 1 line
2.51.2
PATCH 2/4 xfrm: fix the condition on x->pcpu_num in xfrm_sa_len
In reply to Sabrina Dubrocapcpu_num = 0 is a valid value. The marker for "unset pcpu_num" which makes copy_to_user_state_extra not add the XFRMA_SA_PCPU attribute is UINT_MAX.
--- net/xfrm/xfrm_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_user.c +1 -1
@@ -3676,7 +3676,7 @@ static inline unsigned int xfrm_sa_len(struct xfrm_state *x) }if (x->if_id) l +=nla_total_size (sizeof (x->if_id)); -if (x->pcpu_num) +if (x->pcpu_num !=UINT_MAX ) l +=nla_total_size (sizeof (x->pcpu_num));/* Must count x->lastused as it may become non-zero behind our back. */
Signature · 1 line
2.51.2
PATCH 3/4 xfrm: call xdo_dev_state_delete during state update
In reply to Sabrina DubrocaWhen we update an SA, we construct a new state and call xdo_dev_state_add, but never insert it. The existing state is updated, then we immediately destroy the new state. Since we haven't added it, we don't go through the standard state delete code, and we're skipping removing it from the device (but xdo_dev_state_free will get called when we destroy the temporary state).
This is similar to commit c5d4d7d83165 ("xfrm: Fix deletion of offloaded SAs on failure.").
--- net/xfrm/xfrm_state.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_state.c +1 -0
@@ -2264,6 +2264,7 @@ int xfrm_state_update(struct xfrm_state *x) err =0 ; x->km.state =XFRM_STATE_DEAD ; +xfrm_dev_state_delete (x);__xfrm_state_put (x); }
Signature · 1 line
2.51.2
PATCH 4/4 esp: fix skb leak with espintcp and async crypto
In reply to Sabrina DubrocaWhen the TX queue for espintcp is full, esp_output_tail_tcp will return an error and not free the skb, because with synchronous crypto, the common xfrm output code will drop the packet for us.
With async crypto (esp_output_done), we need to drop the skb when esp_output_tail_tcp returns an error.
--- net/ipv4/esp4.c | 9 ++++++--- net/ipv6/esp6.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-)
net/ipv4/esp4.c +6 -3
@@ -235,10 +235,13 @@ static void esp_output_done(void *data, int err)xfrm_dev_resume (skb); }else {if (!err && - x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) -esp_output_tail_tcp (x, skb); -else + x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) { + err =esp_output_tail_tcp (x, skb); +if (err != -EINPROGRESS ) +kfree_skb (skb); + }else {xfrm_output_resume (skb_to_full_sk (skb), skb, err); + } } }
net/ipv6/esp6.c +6 -3
@@ -271,10 +271,13 @@ static void esp_output_done(void *data, int err)xfrm_dev_resume (skb); }else {if (!err && - x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) -esp_output_tail_tcp (x, skb); -else + x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) { + err =esp_output_tail_tcp (x, skb); +if (err != -EINPROGRESS ) +kfree_skb (skb); + }else {xfrm_output_resume (skb_to_full_sk (skb), skb, err); + } } }
Signature · 1 line
2.51.2
Quoted 8 lines · Sabrina Dubroca
These patches fix a few small bugs in IPsec.
Sabrina Dubroca (4):
xfrm: add missing extack forXFRMA_SA_PCPUinadd_acquireand allocspi
xfrm: fix the condition onx->pcpu_numinxfrm_sa_len
xfrm: callxdo_dev_state_deleteduring state update
esp: fix skb leak with espintcp and async crypto
Quoted 5 lines
net/ipv4/esp4.c | 9 ++++++--- net/ipv6/esp6.c | 9 ++++++--- net/xfrm/xfrm_state.c | 1 + net/xfrm/xfrm_user.c | 7 +++++-- 4 files changed, 18 insertions(+), 8 deletions(-)
For the series:
Steffen Klassert
maintainerQuoted 8 lines · Sabrina Dubroca
These patches fix a few small bugs in IPsec.
Sabrina Dubroca (4):
xfrm: add missing extack forXFRMA_SA_PCPUinadd_acquireand allocspi
xfrm: fix the condition onx->pcpu_numinxfrm_sa_len
xfrm: callxdo_dev_state_deleteduring state update
esp: fix skb leak with espintcp and async crypto
Quoted 5 lines
net/ipv4/esp4.c | 9 ++++++--- net/ipv6/esp6.c | 9 ++++++--- net/xfrm/xfrm_state.c | 1 + net/xfrm/xfrm_user.c | 7 +++++-- 4 files changed, 18 insertions(+), 8 deletions(-)
Series applied, thanks a lot Sabrina!