Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 1ddf9916ac09 ("xfrm: Add support for per cpu xfrm state handling.")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

authored by

Sabrina Dubroca and committed by
Steffen Klassert
1dcf617b 7f022857

+4 -1
+4 -1
net/xfrm/xfrm_user.c
··· 947 947 948 948 if (attrs[XFRMA_SA_PCPU]) { 949 949 x->pcpu_num = nla_get_u32(attrs[XFRMA_SA_PCPU]); 950 - if (x->pcpu_num >= num_possible_cpus()) 950 + if (x->pcpu_num >= num_possible_cpus()) { 951 + err = -ERANGE; 952 + NL_SET_ERR_MSG(extack, "pCPU number too big"); 951 953 goto error; 954 + } 952 955 } 953 956 954 957 err = __xfrm_init_state(x, extack);