Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1727360ybk; Thu, 21 May 2020 13:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpY4StwJGvkGJY2S+ZQKwJt77Wykio9ep58lCN6tXRRTNXYyiZviHHVphG0iF/l1RQvHWz X-Received: by 2002:a17:906:edb5:: with SMTP id sa21mr5208896ejb.78.1590094181360; Thu, 21 May 2020 13:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590094181; cv=none; d=google.com; s=arc-20160816; b=bhu9hhCgoUMm5N7pPTFasgPr8xpXCC8VXk7k/3XXnygzpTssF7QZe+fMZH7Veyaq1R BQhcbm+TnHiAkSwKnyRT63TUKyUTDiIiF9+MuVKB+a+DfjQNUdhxbrOdeje1HwHbD9yW eS6C8wUiWoyb/7T6wKw9AM0cL0qvN2ZehMR/JPV81YTz266t4Jv2ZV16VmOQTz6Vytck 7ockSTmEmDbfUQp6Fuwyt49cYR4t9Q2n7AWp5+BvppO8KmltAa8aU0IGEy58rOpFBF7g 1RwI1ZO+K83oX6Xg7JR223dEY9v70b+NQpYnu0I26HyREZLR07pOMGflAdmMBU8sK35A Y4sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=P5MFO0nMjIobXcB4VC1dpLtWIqlaul0EXeuZjFJVDDM=; b=Gl7ACbRkEY7rTOKYMDllyI3JGeM0OLRscvjmapO0G+q6cia4N6HDjg2v8I3gtH3KAc axX21mZUNx5/g/ga1ZoEzgJc9+zmtOs8BKB1lY9kNAjfX6akFnnvcPWDiKYoxNsfRXrs WKrrkK2EDhMxL5yQD10MtVQtnMCIqAXJ+rTpVbtiM97QKCwnIlGCQCEX/Oj//gvdeke0 u06vqBvGoNBFJAph0jLTO1GAa3FVR9zXleEA9fATSsSzuOMJyfAarv4+tlumsx/wcK0j lyKRgp/HO/AhrHo9F4Lg/G/8vM4lhRTu0QM3CY9/U+CNh7LHcGZpqdoApLSSK1oqWhUx XKqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Khr0hmC6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du11si4650310ejc.40.2020.05.21.13.49.17; Thu, 21 May 2020 13:49:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@oracle.com header.s=corp-2020-01-29 header.b=Khr0hmC6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730110AbgEUUtE (ORCPT + 99 others); Thu, 21 May 2020 16:49:04 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33832 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730101AbgEUUtE (ORCPT ); Thu, 21 May 2020 16:49:04 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04LKlUfJ115683; Thu, 21 May 2020 20:48:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=P5MFO0nMjIobXcB4VC1dpLtWIqlaul0EXeuZjFJVDDM=; b=Khr0hmC6F8R5xMLuEZ5B0J5ZhD1ZbbuGeFMWD0J+EjRwNYKRxBbayn4RD99xlmaTyPP/ IQ80Bgqk6VEOF1DMERx3UvZ/41Bh5c2jyNJXw9UK0WiqqfulDr+U/51BhUGlUKecFcxW n55MITjzMBZrPyRDpGnck5TzqVrwS/JEFHo0BfH+WkglmB0VAifFr8o5WpLzxoSiLOKr 5DmlKqermvTFcWhsbzkyd7otpbHkeLZ4RVCjfjHy87kRSy9eGUSm0JG3l4YJubl7a0kr +3LLKEJAH+DQSGQP7HJynlTmFSOdQAQWRkd7AMsQ9JBRAaRPLrTFAkhakY7Nd7k6N9o5 GQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 31501rh6kd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 May 2020 20:48:53 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04LKmhNL125879; Thu, 21 May 2020 20:48:52 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 313gj6a5hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2020 20:48:52 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 04LKmqtx023030; Thu, 21 May 2020 20:48:52 GMT Received: from localhost.localdomain (/98.229.125.203) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 May 2020 13:48:51 -0700 From: Daniel Jordan To: Greg Kroah-Hartman , Sasha Levin Cc: Ben Hutchings , Herbert Xu , Mathias Krause , Steffen Klassert , stable@vger.kernel.org, linux-crypto@vger.kernel.org, Daniel Jordan Subject: [stable-4.9 1/4] padata: set cpu_index of unused CPUs to -1 Date: Thu, 21 May 2020 16:48:44 -0400 Message-Id: <20200521204847.1953064-1-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9628 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005210154 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9628 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 cotscore=-2147483648 impostorscore=0 bulkscore=0 adultscore=0 malwarescore=0 phishscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005210154 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Mathias Krause [ Upstream commit 1bd845bcb41d5b7f83745e0cb99273eb376f2ec5 ] The parallel queue per-cpu data structure gets initialized only for CPUs in the 'pcpu' CPU mask set. This is not sufficient as the reorder timer may run on a different CPU and might wrongly decide it's the target CPU for the next reorder item as per-cpu memory gets memset(0) and we might be waiting for the first CPU in cpumask.pcpu, i.e. cpu_index 0. Make the '__this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index' compare in padata_get_next() fail in this case by initializing the cpu_index member of all per-cpu parallel queues. Use -1 for unused ones. Signed-off-by: Mathias Krause Signed-off-by: Herbert Xu Signed-off-by: Daniel Jordan --- kernel/padata.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/padata.c b/kernel/padata.c index 693536efccf9..52a1d3fd13b5 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -462,8 +462,14 @@ static void padata_init_pqueues(struct parallel_data *pd) struct padata_parallel_queue *pqueue; cpu_index = 0; - for_each_cpu(cpu, pd->cpumask.pcpu) { + for_each_possible_cpu(cpu) { pqueue = per_cpu_ptr(pd->pqueue, cpu); + + if (!cpumask_test_cpu(cpu, pd->cpumask.pcpu)) { + pqueue->cpu_index = -1; + continue; + } + pqueue->pd = pd; pqueue->cpu_index = cpu_index; cpu_index++; -- 2.26.2