Message ID | 1477578591-28924-14-git-send-email-aryabinin@virtuozzo.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Herbert Xu |
Headers | show
Return-Path: <linux-crypto-owner@kernel.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A51DA60588 for <patchwork-linux-crypto@patchwork.kernel.org>; Thu, 27 Oct 2016 16:03:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9016D2A22A for <patchwork-linux-crypto@patchwork.kernel.org>; Thu, 27 Oct 2016 16:03:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84C032A2A2; Thu, 27 Oct 2016 16:03:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A85C22A25C for <patchwork-linux-crypto@patchwork.kernel.org>; Thu, 27 Oct 2016 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941459AbcJ0QDL (ORCPT <rfc822;patchwork-linux-crypto@patchwork.kernel.org>); Thu, 27 Oct 2016 12:03:11 -0400 Received: from mail-ve1eur01on0132.outbound.protection.outlook.com ([104.47.1.132]:32496 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S936657AbcJ0QDD (ORCPT <rfc822;linux-crypto@vger.kernel.org>); Thu, 27 Oct 2016 12:03:03 -0400 X-Greylist: delayed 3640 seconds by postgrey-1.27 at vger.kernel.org; Thu, 27 Oct 2016 12:02:59 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GWIqiwTz5Cwn20av390Fx3Pf3j8z2vDHHUDMw8UjKwI=; b=LVXo9GB5rxWpsC6/NM89kLWa3XNHLJfMykIsMGcWKhipTflucdBZ5gJcnxUvYWvwMo8Bo71CwO/+RAaA0pC/+Nt6EjlHg6ewbZR52mITDc/u05szAcE76r2ILYyteaB7cuusxYWV7llnmM49VFOc1wsUCLnKRZsPVQv/dDGNv18= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from localhost.sw.ru (195.214.232.10) by HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.12; Thu, 27 Oct 2016 14:29:58 +0000 From: Andrey Ryabinin <aryabinin@virtuozzo.com> To: Willy Tarreau <w@1wt.eu>, <stable@vger.kernel.org> CC: Herbert Xu <herbert@gondor.apana.org.au>, <linux-crypto@vger.kernel.org>, Andrey Ryabinin <aryabinin@virtuozzo.com> Subject: [PATCH stable 3.10.y 13/18] crypto: algif_hash - Fix race condition in hash_check_key Date: Thu, 27 Oct 2016 17:29:46 +0300 Message-ID: <1477578591-28924-14-git-send-email-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477578591-28924-1-git-send-email-aryabinin@virtuozzo.com> References: <1477578591-28924-1-git-send-email-aryabinin@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM4PR0501CA0035.eurprd05.prod.outlook.com (10.167.83.173) To HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) X-MS-Office365-Filtering-Correlation-Id: 17a92f9e-fe6c-42d2-97f3-08d3fe75bb2e X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 2:zJwT+DfDcMco2hFTA4Ik/j326wX+3y9oA2Twux9cGrBVphOkyWZU+dn4bhilKi3Xv0rJEWlTOOqlOp+f8ajjhSADC4Wmk3NK6jsOLknw6wkB18whf6z1zBPWlZDRsLjB1QYMDj7pyul156bfvaFfHRVHBUfJjw3Pji49hvwu62SXYoyyLbc+ifYF+ogdWeCviqJthL5tpWtdCgI/CRBVEw==; 3:IWQbvT4f+Olx+cVAqPpQds5yYATLvZixeWfS2VJj8eNnQROBW6JtJuxQEGuhCpMqGO/imIowkC51QLlrqpMVKcARvvOkwpNU1iswkxQxRfosplSAwJvhFWYBwbu23pBjnepsOrWb8ABgsQGRmcudyA==; 25:eGEPMydSH97kcpgEuV+VxETUVr6zNPbaYaPHaJPZAPfGM6+LUxyFCLoWfNwKKWOerMt7uqJwzhJg1nmP1xwDLLBkHFdTD5NXNXyhYt8JUQldM9JVAQVnU2hCz/4vGgt+DiesZ6CKQkEO3l6LGV2VXQUQgnGAUVnjD1+R7UyoDu2nS3YNlpxgZbmo1SyPQDGzzAIjUSEiDzRYzKTRdl2/uWpFj77B1gOfgqqfpJSqPtU6l70BvZ7JEuWBlqz9VspkxsacP5UbH+Ic6UwCxpnPjjtVfpXdYhYuK/l/qRIpMQ6aaRTLp4X7O3ez+aPDI9u++zVO+8PEcUezv2TuVOV76iJOnFsBrVWKhokujiLXDOV12bLaXPjDjiONG6TCD5NcENQlQAsvlb+0frzoUL7gBduXxlmlxBf7DzCZsvaOvhQdana1OWxNVZM8WQHpWQyM X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0802MB2555; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 31:gE1EhA0Dprnj3omv9Vm45qa0q3RiW7ibn+43hvPbDOEIbCGxgxSj/YRUsBI+3njIrCj/tvDU9GxWTyJTm3Df51vxrYdYrhuHImkZqgoL93CFfObtwB6yGl8QGihcliC700S14OQ9EU6jIWIwqERYLu8ph08ymPiOlS1D1BppFEZ/qMXE6BtWC8SjEgfbfpvRBq6CGd0v1aYKCG+tgFmmaKiDT47ldHAOqB4roU1XhcSj2LQXJ5ohn3NBRyFTx3/4; 4:Xl1zsgPdVXah4nO8DjcJKqJkTvDpAp3QqKBMUCYBngfA75nOUuRb6Z+eisV7al3I9kFVusRetfgzIdWtbdMZS4QhF0RZoVGZtMMN8o/GYZTytg7upCQbz9kouTsms41/X5erQdHdx3MoceBEHJzt7TikEbtt0Ov/EnAbzIrZeQNYDcrshZNHwckV1rChAkGrs5MFLD+zgI+whx65nh0mKjcX8wfRgCB3PXoBM62S9zZAhcRn5NURG8dW3crSBUSItP/uZePEfXYJG4WzJIl4GCiu0aHMjNKa3x9kNe7YW5qZiMNji20VtgUgqBQipPY3/hYfvB/V1b2xB1lpkOvQZcIXp6/Jm61i7+eTanmu8yFCmELRLUyeNeZOi1LyM0RraX3aQFvYluakCqhc8eGCzFzazg3sLiha15Kf5e4/CNsn7WZuZqfl/gjtboDtGuAMbaL49T2RKvVDcZ+rCQpwJVq23abtUirhOxmd1hmULFI= X-Microsoft-Antispam-PRVS: <HE1PR0802MB2555F6F27A0DB2D99826A0FCB0AA0@HE1PR0802MB2555.eurprd08.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6043046)(6042046); SRVR:HE1PR0802MB2555; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0802MB2555; X-Forefront-PRVS: 0108A997B2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(2906002)(81166006)(53416004)(76506005)(8676002)(81156014)(42186005)(305945005)(7846002)(76176999)(48376002)(19580395003)(50986999)(7736002)(19580405001)(2950100002)(105586002)(86362001)(229853001)(586003)(6666003)(6116002)(3846002)(4001430100002)(33646002)(50466002)(36756003)(4326007)(69596002)(189998001)(77096005)(47776003)(5001770100001)(66066001)(107886002)(92566002)(5660300001)(50226002)(5003940100001)(101416001)(68736007)(106356001)(97736004)(781001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0802MB2555; H:localhost.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0802MB2555; 23:zZ0Yc7bgobILE2zQBXYivpAvXlLuGxtK7eP++ed?= =?us-ascii?Q?hqQP4a5Uc9xuYpLPuSq4Jps/RqJK3mHCSzEmEpS0Z/R8MEn8zrqRrU7oLOGq?= =?us-ascii?Q?smMpcRnnKnsB1NLCDyuV0jI5xig+FxNYKnAyCEmJ68+FrtQ1Q/fHnVvkKIOq?= =?us-ascii?Q?axBaGKwIz/S7cqT7Qy67atEwEiB3NCDsjFuceK3Oaz0EmCIBo92u1TiuJvSc?= =?us-ascii?Q?tISbA9ur+ELqPm3qOWapi+bBQn/rsXEWbDOXw/nXsdpG9UkOh+yEo6gtXrXm?= =?us-ascii?Q?srgs5g+MnGmbvgPCJ/dpfaBgz5uJxg7S3j8jfRR9ms58GtLdMr8+6O1uoPj9?= =?us-ascii?Q?DLuPprKDvxzf4u15KYSjx6ynylrbC8ZmA1KGzCyIX/1OQ5lmf2KaVvYOLdbW?= =?us-ascii?Q?46BbX7W4ETBk/g0cTOiFnaYO5LQAB0L+PRPMnS8fwl/iFvTrb584CuBuLh1N?= =?us-ascii?Q?u5nWc9P2iE0EyXWnS1o1Fyu5wR8HSnCfPI56FzZ6WfkgPYswKSUYH2Kwe3GO?= =?us-ascii?Q?XWNBy18P1UCVrI1k/DiNWCzuD66M/TLn92Tkwn7+B1DIAMoEf4Sxj37yA4F4?= =?us-ascii?Q?gFPRnH0hY0xpA42AXhpFYwQ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sxtklpbxZ10WQaIVax0DI99RZ7Ul/u2M6ZPKgro5f1COUu0Ayctzqizu1VqNok/3f/3/TGWSYjqBlMxoax2ldWJjj0Hikfwdmypirwe/pIqpILsawqY8g==; 5:IIcNv7G5qnitQtVUacEeDAT0RGytjvgb0qhePvR7XuGd9KNP7BGpoolQzpAgoRlRZUXAMcXXxYvcIYb4sjx9Z2l2lejkHB/eaMcCd0pTf0CmRop2Df4ohV0e8/akanzW/TYFNaqjbwxv3EXsIvz5hw==; 24:4UHz2o3ya7pzCxplDC3Dvob5CrJCWECJ8Gn4zxwe1X+yACfWLdYdn2Z9QyzfPpqaghpEDNPf1p7yO1cfvqhcmS7hE1oaYD2OZ3ovctOc8kE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 7:n2bEwSRzj/aPGrgfWBqmSGs7klQAGLm3SLiOWW726dI4Cn8DMXJiV/wphdrQmJCxjWn29s3wuztTOoaDo+uidqcSO4ozqye6BPEPkZV+blTKoiGTV1h7Wy03Fdk22VhghU/w6z66iTUK8tI4XpVtngKu8mqlO+Amdb5D7pclDLIwOKJwR6eJzrFXMQKMj5VeJydYyXDczUM1XocuHMBU1yZ+xHrs5vFFJfwB5HH7XUrY8trjIpk2yvBZIzbl4Y2pSfDdRnpBLCI6KUL5TIUh082mxDhCUNaXxgvOL8Y7xNVbsi47zoIwOS5tQrahed+tRmONL+P4F6TiLlkounXiyyc2fkMg+/iqP6lW9gvvy4s=; 20:6E2TUyStWoEd7N84IUg9BgbjoJ59B+j659EZ2R9Vy29FDYM2oXY0wbZW4fddqDnv6L+6u01f2672R+ZbDZTx4XDF1tr7A4hiJQsBCALSs1OVs+FfPAcbxo+u6mAuNBi2dVXSkMLgeYSAdc5KYXN/c4k5Zi20ZesPikWqp0Z3Q0o= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2016 14:29:58.8898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2555 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: <linux-crypto.vger.kernel.org> X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 512aa36..d11d431 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -255,22 +255,23 @@ static struct proto_ops algif_hash_ops = { static int hash_check_key(struct socket *sock) { - int err; + int err = 0; struct sock *psk; struct alg_sock *pask; struct algif_hash_tfm *tfm; struct sock *sk = sock->sk; struct alg_sock *ask = alg_sk(sk); + lock_sock(sk); if (ask->refcnt) - return 0; + goto unlock_child; psk = ask->parent; pask = alg_sk(ask->parent); tfm = pask->private; err = -ENOKEY; - lock_sock(psk); + lock_sock_nested(psk, SINGLE_DEPTH_NESTING); if (!tfm->has_key) goto unlock; @@ -284,6 +285,8 @@ static int hash_check_key(struct socket *sock) unlock: release_sock(psk); +unlock_child: + release_sock(sk); return err; }