Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5467737pxu; Thu, 22 Oct 2020 03:12:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzorHtEceO0lsAZNGrli8v+eDHtBrooJisZz7GW9kd8JuXZNTQQWgcGb0F3ykh6oLZFBczJ X-Received: by 2002:a17:907:a8d:: with SMTP id by13mr1415616ejc.295.1603361527624; Thu, 22 Oct 2020 03:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603361527; cv=none; d=google.com; s=arc-20160816; b=w6ssX6/ZfKdhXRMm6Y4HVOFOjNuw05pnp07sAXLZbcWT4dSKRY+0WfFAfH3CHhb+cD YC5z54kNswGdrN4kTb23jbwR1w8v59HMeU0XTRAxb+K9DA+zCw/4PGaHz8JuIDZSP9MG ys0Esn3Rz3aWfklKQhESMFTmI8r6Rn0aMbY5+oTLFcJioGbVEckOPjOq1STdBOKXvZPU m3n1EDtorrnHMt66Y7rGq4foqt21lschh4sFaWUG9y+Gd79mY/F9WET1263E1f+Sj0If vQ7naAc2vrtQAOQT5h8UgxwqaUSo+OGsZ6tck3HR5Z7Eq5m36cU5HowLqWJoTfZBNN2l eKFg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=cLAlegNOIrwzIY2JgBuXu/SNenTIIhJF/b/jv5R+48w=; b=Dp4N9gXa1gjOTgpsVG2nmz1YDl++BjEgWGhhsaX1VFmMnrXzQJMHvVuagWacXH9Yzn bu4nHoUWtY8D2BsNIP9nkasRIkDofpgyo+IvWFdM6x4PLWveeDrLiYriYqH0pnZQ7kkl 96qu6R8OJWp2w9eGFdsTi1trKwOSwK6IE6W80mdyu3rb+uqZQ6M5SHsnXPH5jqCiedus LpqK3HdK1RxpmVza9578d4pyJ4Ts3s1IZ2w+GaYwd5KZ/y4GNU8ADqWhbv3KQF7njENZ zTfaZUWRKS0nbdd8jPs2ge6c3ZaNfolXAKXnHZW3T8CfXtu0RnhJCYsHSpR3vekUJbZD SkQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=SJV3qyzS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e30si574495edj.442.2020.10.22.03.11.44; Thu, 22 Oct 2020 03:12:07 -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=@mediatek.com header.s=dk header.b=SJV3qyzS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896319AbgJVKIg (ORCPT + 99 others); Thu, 22 Oct 2020 06:08:36 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:53942 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2896274AbgJVKIf (ORCPT ); Thu, 22 Oct 2020 06:08:35 -0400 X-UUID: cb0dbf63645c406b86f8dba0a854628f-20201022 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=cLAlegNOIrwzIY2JgBuXu/SNenTIIhJF/b/jv5R+48w=; b=SJV3qyzS79qIEWY2s4RwAPrxHIidzYiCfVenbZOgEHSC/ELw4QXH+95X1EUV3dsYjD/jFb0yVL2KU+aMHkisbRd4TkIJw3l0Tmeirg7PuIu1VRvvwlbVy6U+wtOHOrwLOD80CHAbNQBwXlN676Y2lvGCv1mn4ifr0ROvhg04m6Q=; X-UUID: cb0dbf63645c406b86f8dba0a854628f-20201022 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2093845838; Thu, 22 Oct 2020 18:08:31 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 22 Oct 2020 18:08:23 +0800 Received: from localhost.localdomain (10.15.20.246) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 22 Oct 2020 18:08:22 +0800 From: Zhuoliang Zhang To: Steffen Klassert , Herbert Xu , "David S . Miller" , Jakub Kicinski , Matthias Brugger CC: , , , , , zhuoliang zhang Subject: [PATCH v2] net: xfrm: fix a race condition during allocing spi Date: Thu, 22 Oct 2020 18:01:27 +0800 Message-ID: <20201022100126.19565-1-zhuoliang.zhang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Content-Transfer-Encoding: base64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RnJvbTogemh1b2xpYW5nIHpoYW5nIDx6aHVvbGlhbmcuemhhbmdAbWVkaWF0ZWsuY29tPg0KDQp3 ZSBmb3VuZCB0aGF0IHRoZSBmb2xsb3dpbmcgcmFjZSBjb25kaXRpb24gZXhpc3RzIGluDQp4ZnJt X2FsbG9jX3VzZXJzcGkgZmxvdzoNCg0KdXNlciB0aHJlYWQgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBzdGF0ZV9oYXNoX3dvcmsgdGhyZWFkDQotLS0tICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0tLS0NCnhmcm1fYWxsb2NfdXNlcnNwaSgpDQog X19maW5kX2FjcV9jb3JlKCkNCiAgIC8qYWxsb2MgbmV3IHhmcm1fc3RhdGU6eCovDQogICB4ZnJt X3N0YXRlX2FsbG9jKCkNCiAgIC8qc2NoZWR1bGUgc3RhdGVfaGFzaF93b3JrIHRocmVhZCovDQog ICB4ZnJtX2hhc2hfZ3Jvd19jaGVjaygpICAgCSAgICAgICAgICAgICAgIHhmcm1faGFzaF9yZXNp emUoKQ0KIHhmcm1fYWxsb2Nfc3BpICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8q aG9sZCBsb2NrKi8NCiAgICAgIHgtPmlkLnNwaSA9IGh0b25sKHNwaSkgICAgICAgICAgICAgICAg ICAgICBzcGluX2xvY2tfYmgoJm5ldC0+eGZybS54ZnJtX3N0YXRlX2xvY2spDQogICAgICAvKndh aXRpbmcgbG9jayByZWxlYXNlKi8gICAgICAgICAgICAgICAgICAgICB4ZnJtX2hhc2hfdHJhbnNm ZXIoKQ0KICAgICAgc3Bpbl9sb2NrX2JoKCZuZXQtPnhmcm0ueGZybV9zdGF0ZV9sb2NrKSAgICAg IC8qYWRkIHggaW50byBobGlzdDpuZXQtPnhmcm0uc3RhdGVfYnlzcGkqLw0KCSAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhsaXN0X2FkZF9oZWFkX3JjdSgm eC0+YnlzcGkpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgc3Bpbl91bmxvY2tfYmgoJm5ldC0+eGZybS54ZnJtX3N0YXRlX2xvY2spDQoNCiAgICAvKmFk ZCB4IGludG8gaGxpc3Q6bmV0LT54ZnJtLnN0YXRlX2J5c3BpIDIgdGltZXMqLw0KICAgIGhsaXN0 X2FkZF9oZWFkX3JjdSgmeC0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