Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3894324pxu; Tue, 20 Oct 2020 03:23:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHHbI9b4PgE1nTgszye1mk45sH8LYVPJjGAyCOKyMVyZkXvDYfojW12HM639T21PjM3r4W X-Received: by 2002:a17:906:647:: with SMTP id t7mr2460649ejb.428.1603189418618; Tue, 20 Oct 2020 03:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603189418; cv=none; d=google.com; s=arc-20160816; b=09t7nGVf6GVs0xO9hYTpNoQl1wg7jSkjsSErTgcMN1CyXbhkqrGpzLXGWsDvm4pRJ1 sJO+K4lTR4EDC8PWkzo1lGICBMoQ04ojaPyJoEeKJAvETXzdfRgu4c7TwIJn7bUIOwD6 NGXBimAqDOewKayw5/Y4U7i9AzUiKbEuZQFGjgnFTWIEJPbtbwTDzuW/44gvgUlECkZ/ s0UUFXMoJS6eCahaqJwx02uhMD3Amo5N+6k4OGP4bs9f/lMUGkGBl2PIcbrP6CFqa9GJ AMvbNC5GcQWqYA6ub81JJ53dAl9+0pX2ONQaSIPCbLGoqFts+lVm/vFo4yqpkX9OSNho tZ7Q== 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=oh69URcuh4hkm/jR6bFeN4nQ+LubGPhNV5qVza78Wls=; b=UGycd4HBc4JDCzbJ+nqZOVzl+hkGWFrh3iWH0vN7uDtOoCdrhbtHH97immXwlKBEJU /OKoxKNBEOjNm9P4+Hp1ymm7vfPYBjfw5/5w8rmCKSKpZh65451v2V2mP8D2WIwOdM0h WxMZIXs0zpELawlBEZHJEc3s4wvYkn/Zj8SVJnbUMhcf6PtdtG1VxqM6OuJ2uAA+E6HI QTJwdSw21Gi5wSvNYHNr8+krR4J7EKcfO+mBQUcAxjHQL2icfl9Q1QjEHuB893w5eC4e xHCKuXm2YB576rHsioFc/BigXrM6V2eZC0hW//nsMA9g9/I7d0chBdg/PEDWvsMTL0QM /1jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=tB3zZjIm; 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 o27si1004696ejh.256.2020.10.20.03.23.15; Tue, 20 Oct 2020 03:23:38 -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=tB3zZjIm; 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 S2388721AbgJTIYu (ORCPT + 99 others); Tue, 20 Oct 2020 04:24:50 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:57487 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727227AbgJTIYm (ORCPT ); Tue, 20 Oct 2020 04:24:42 -0400 X-UUID: 3d94010fe3b8456ea1e40812cad3ca8d-20201020 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=oh69URcuh4hkm/jR6bFeN4nQ+LubGPhNV5qVza78Wls=; b=tB3zZjImTLMUHSUQsOAPJLLVLhQP5qYzrW5vmXkaNPuC+kr5/j6Uf2CkOQSrE/OvoT5JINRzLuJhXH2Jd8p174Oek22F5JR5XbnqGtKx+P2l+aR1K4KOlo1Mig1QGJ1SLicmXcMK4I6bR+PZ1sJBx6pakiC9pkQph00yWaf/BYM=; X-UUID: 3d94010fe3b8456ea1e40812cad3ca8d-20201020 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.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 489266037; Tue, 20 Oct 2020 16:24:38 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 20 Oct 2020 16:24:30 +0800 Received: from localhost.localdomain (10.15.20.246) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 20 Oct 2020 16:24:30 +0800 From: Zhuoliang Zhang To: Steffen Klassert , Herbert Xu , "David S . Miller" , Jakub Kicinski , Matthias Brugger CC: , , , , , zhuoliang zhang Subject: [PATCH] net: xfrm: fix a race condition during allocing spi Date: Tue, 20 Oct 2020 16:18:00 +0800 Message-ID: <20201020081800.29454-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 X2FkZF9oZWFkX3JjdSg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