Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4342028pxu; Mon, 12 Oct 2020 16:53:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv/8ookAbTsPhjJwOE77PHUdUZ6T3oHOkGMt0C/dKTtX8Gv1ijNW9Tf9OJFvoo+3Su14tf X-Received: by 2002:a17:906:791:: with SMTP id l17mr29303245ejc.361.1602546686414; Mon, 12 Oct 2020 16:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602546686; cv=none; d=google.com; s=arc-20160816; b=vB12H0EPHf9HPx8CSOIxvYMOx2eJcwDewIdowPfpETU8f+1mywpc7p7TbwVWHhVDOk 34FeKgneC4k+ZWGvB3ZSNGTT6GKIXFJZSTup0WBKwfKIsFSH/QxSZAMXp71HugiIPcpu WzQxF6VKhQmbi1yEen7G9/mQTc+9JgBA8g+9TAQOjIWDRUA5AEouk5dVOBCM49ip4t0Z O398IMGpbBRZXeSLXjDKVcMTVk4MwF6eY1+yVAeZpe57XDoYmMN4sVmjatyhbb9M81Dy oAeznInLxEZvgZfKV0rEFLFojAt2MZXL5j7C0+rEEMVeQXYM38r3dsi4TtEMjS8MF3fI ZYIQ== 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=B8HjcJjgm6OaftOy13bAuYFOAR/f2SYP4L2FODho1VM=; b=fr90SUQEpXZbbbUoh5mygBpG4mTB68xcZMp6mx9MORlkxUs3lMvm3b4NOQxhi0bV7a KLmlruDqeKvhUgPk7o5MBOdDY9HSGkgGGpoi6Be1EMjjF8e5trAnzw73Qr8JNejymYDY iAlQHOi92WKt9XrDkPgfTjtbppnBsrtgyTWChwaAbo8v1QkhKFd6rnjAwSOafFkYi04D tP6xVSLd9Jw7fD2IFv1C347nOIpy5m+cWwAcLBRaEvUCd6II1oit47n7918XC3qOlTil xl8uruTsg/K7nYopiBByACurK/O0Y2mOXx7rrx8IvaXviodVk+q0mQW9KWpNHeLTvpub W6jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fJALk0hE; 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 oz20si8240553ejb.373.2020.10.12.16.51.03; Mon, 12 Oct 2020 16:51:26 -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=fJALk0hE; 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 S2389629AbgJLNpX (ORCPT + 99 others); Mon, 12 Oct 2020 09:45:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:48538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388373AbgJLNnR (ORCPT ); Mon, 12 Oct 2020 09:43:17 -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 1E8DA221FE; Mon, 12 Oct 2020 13:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510196; bh=UfrYpmMLSfHoSfyBBh1Q85+/udG9IiZNyjLAVN6D9bY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fJALk0hE1250vV73Ndbb9cRIGdmPVQxXsglWmaZRdp41NJIZXRib/MGGFHJo6cJDw IslJVrWOmXZNCKUftmcwBS3ubWXBVBLCprbYDKY4xaghzKre97qwA367mM/G2j6/uP kJWCmXGGB1pqybKZsflZku7IPrOzg50cik/XTqU8= 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 5.4 51/85] xfrm: clone XFRMA_SEC_CTX in xfrm_do_migrate Date: Mon, 12 Oct 2020 15:27:14 +0200 Message-Id: <20201012132635.320244639@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@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 10d30f0338d72..fc1b391ba1554 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -1438,6 +1438,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) { @@ -1494,6 +1518,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