Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4419989pxu; Mon, 12 Oct 2020 19:48:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweO2DsWI8FjTM4E5hG15qls5i02mtPdP3EA6wm0MojkkGnBDhgZCWMDfP8R6w6WZwWIovM X-Received: by 2002:a17:906:a95:: with SMTP id y21mr32094121ejf.410.1602557323230; Mon, 12 Oct 2020 19:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602557323; cv=none; d=google.com; s=arc-20160816; b=C7fHmx2sJeXBa43lCUk5b8gvA10fdKW2ztblV/mNjK6KV3gXJ5WO59w7l8iJr3s7+2 2Yk1N0G56xUUaFESPduvxCZbhX/IwQpnVIqcrFkvUNOJ5MzlmngJiyLK8e6ZtrSNNfsx zFhG/Jb2ywpiUqfQ1KzdgqAve9uIDiya/ArnrRz+o4iko0nNO+QtV+U0F8dsycB9LFXQ EN6Ul3TFYjnz85uopVLRFH1mKY65fSAXEEnM7c+/NHi4606juLeIrImIG/ipTlbjrPpQ IgUmWAtjd5DYuJ3D5OpuZxoAb3WdYgzFltrwTXtnDd9e41Fw9mpjSvGshywkGB6W5jTk /OQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E0Xyu4iUsTGBuJq7fV+vW6jAxZ+KdQ0/CZtNzf+cPhk=; b=NUvae1Z7qc1TOX31Cg8CI1RW5t0muP8pp1SThtAuVNEoQC2rQ0c4xesNxqOgZWcwwn KaKKtugJpDyEAXR6ErXps0llvwEevhwucLMVoTMbPw5vA9S4EbPk5y3d/ZQeicF8KoJt QEvE0kS5iMsmJ6eRh0xUf0rCxlrFes+iDUI2D/lqetc98Hgs8DWenOdUqiqFWa8DZWtJ xhzBLOw639cEUpy0fBa+CqYlZ6jL/mQohNwo2Ad3ZiTdtcrTynvGDOaQUhm0ggIYitSW +PwC9g7QhxfN4jUl9p3wAdfWWnAwc9d1GOH6BlqvgQkAdBHENCFes3BZsOVNw0Ai67Xd 7/4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KEfIN7b7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si13224778eds.322.2020.10.12.19.47.55; Mon, 12 Oct 2020 19:48:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KEfIN7b7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390791AbgJLOCz (ORCPT + 99 others); Mon, 12 Oct 2020 10:02:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:40522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731230AbgJLNin (ORCPT ); Mon, 12 Oct 2020 09:38:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73F90221FC; Mon, 12 Oct 2020 13:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509895; bh=mybcqZkKBdPDpMQJmV2f3zmdIyizClBUs9tou5/HIJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KEfIN7b7HRxFO/tY25dwWgc5j21KmUevd9YUvHZXLLwaOsQE77NiFFH2/9QRMpK/s jY21P1vLtHNhZDeWWDJNJJ8inwqSORHpPkifHr5gFZP0isAaympbrW+hBoAUdLHTKf zxaVWb2FhqQI6XsBsHwcJEmdJOhAnE+j2Tjfa6g4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antony Antony , Steffen Klassert , Sasha Levin Subject: [PATCH 4.14 55/70] xfrm: clone XFRMA_SEC_CTX in xfrm_do_migrate Date: Mon, 12 Oct 2020 15:27:11 +0200 Message-Id: <20201012132632.825158571@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132630.201442517@linuxfoundation.org> References: <20201012132630.201442517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Antony Antony [ Upstream commit 7aa05d304785204703a67a6aa7f1db402889a172 ] XFRMA_SEC_CTX was not cloned from the old to the new. Migrate this attribute during XFRMA_MSG_MIGRATE v1->v2: - return -ENOMEM on error v2->v3: - fix return type to int Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)") Signed-off-by: Antony Antony Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_state.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 190ca59d5ba31..37104258808a8 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -1320,6 +1320,30 @@ out: EXPORT_SYMBOL(xfrm_state_add); #ifdef CONFIG_XFRM_MIGRATE +static inline int clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *security) +{ + struct xfrm_user_sec_ctx *uctx; + int size = sizeof(*uctx) + security->ctx_len; + int err; + + uctx = kmalloc(size, GFP_KERNEL); + if (!uctx) + return -ENOMEM; + + uctx->exttype = XFRMA_SEC_CTX; + uctx->len = size; + uctx->ctx_doi = security->ctx_doi; + uctx->ctx_alg = security->ctx_alg; + uctx->ctx_len = security->ctx_len; + memcpy(uctx + 1, security->ctx_str, security->ctx_len); + err = security_xfrm_state_alloc(x, uctx); + kfree(uctx); + if (err) + return err; + + return 0; +} + static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, struct xfrm_encap_tmpl *encap) { @@ -1376,6 +1400,10 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, goto error; } + if (orig->security) + if (clone_security(x, orig->security)) + goto error; + if (orig->coaddr) { x->coaddr = kmemdup(orig->coaddr, sizeof(*x->coaddr), GFP_KERNEL); -- 2.25.1