Commit 1dcf617b authored by Sabrina Dubroca's avatar Sabrina Dubroca Committed by Steffen Klassert
Browse files

xfrm: set err and extack on failure to create pcpu SA



xfrm_state_construct can fail without setting an error if the
requested pcpu_num value is too big. Set err and add an extack message
to avoid confusing userspace.

Fixes: 1ddf9916 ("xfrm: Add support for per cpu xfrm state handling.")
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 7f022857
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -947,9 +947,12 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,

	if (attrs[XFRMA_SA_PCPU]) {
		x->pcpu_num = nla_get_u32(attrs[XFRMA_SA_PCPU]);
		if (x->pcpu_num >= num_possible_cpus())
		if (x->pcpu_num >= num_possible_cpus()) {
			err = -ERANGE;
			NL_SET_ERR_MSG(extack, "pCPU number too big");
			goto error;
		}
	}

	err = __xfrm_init_state(x, extack);
	if (err)