Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp707237ybl; Fri, 9 Aug 2019 12:30:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgYlcMGZgYJjYAF5a4WIux6p/gDK347TPSZ+YdtK4ulIy+p96+jzdmUV2zRyj/v0/jKAr2 X-Received: by 2002:a65:6448:: with SMTP id s8mr18937020pgv.223.1565379012840; Fri, 09 Aug 2019 12:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565379012; cv=none; d=google.com; s=arc-20160816; b=GJ/hzdbLOCH18NViosij86Bp4/xRpfaG6/HDOyt/HPggpcSzLqNLZdzjl+hGvLClI+ IKioccAwRP4PMiRZmHhlJM7AhulD5d52z9VHF+TOdxGDru3UFuQK/LZSB+aKoDp7R8q9 4+HD7bmGOEd4VpXUBbfk/zm5ro1rty3Xc6X0AHchht3Bjvvla8bJNIw8OyVHj2Pxd7n3 gQ6nrsLSjUTFvTw2qRlbNXl7eusUvGqB8NDB+Vb/j891Zt/Yn/83sORyNv6rSW5Al/GE N2Nklo67l7YRv5DtXV7brqeQxzBXCF1vhlY1MMXzJUOkFr7Z60Ncf/pz8qRiB1EOaIE/ yLGw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=cP1lKqCv0m7pam9tebxXo/dg9KekB6e4yuCInD6+caE=; b=FPmVgpI8abGPj8xSrUjeFArx4Q93DESERKK6hGy2UUjwyUqxB7QzhizDG1mcy0VBXm 08xGJuzt6pcTXPvN5JMPL+/o+JjxQ0zntsuLMMpqvBdeWTF/7EUIj4WYOPUQRl0bWVxb XzG5U9hiAJYnjYrrg8uzJ3XpRnGtG0yPO7YtAkGIsZZWjPNKN3YjsJJInoloe/7v9tbg 8XUbL+6bxhebWmCAaRWQOKVlgHCafsfc2/qTV4qMSIkvx9eOPATtBe5Io1JIqCHgFRbA j5sbE/cYLhJ8o2i3jrnlBktcE+hRkY+/ikNDN+RzGBIBmcZcZUabcMoAyVThgulszgTT pWPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b="fQ/FPMr1"; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=txi+f+au; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id x13si57814314pfn.105.2019.08.09.12.29.57; Fri, 09 Aug 2019 12:30:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b="fQ/FPMr1"; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=txi+f+au; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726498AbfHIT3S (ORCPT + 99 others); Fri, 9 Aug 2019 15:29:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46034 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbfHIT3Q (ORCPT ); Fri, 9 Aug 2019 15:29:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79JIcNJ157279; Fri, 9 Aug 2019 19:29:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=cP1lKqCv0m7pam9tebxXo/dg9KekB6e4yuCInD6+caE=; b=fQ/FPMr1Ss3eHpewFAbQQhqDVOSD9fOh0Co9WGV6C8A3i5hVaZtc+zix++vGSsvPVdm/ xLQQ0wEYOUfY8j+tR04Kac5dRl5s6D2OdhgBAEM07aJ0+UyrhhltXzhWw8QduBZA+LSw UMqbEDkjtrC9iVb9XU9RVSEud4eYRwPHuyY4CEeJkkDviB3+IwME4A4UvS7psCRDBkSl hWSPdXpIAmOZxmYTQRiYuIploShpXT9xtYOj2AbU29xYYlkg9+G3Slzza40TsmsWytYh 4Gst0i6sgeKJRlbYODOEblOHHVeJxr8s4WWSzY94EWosMG1PsbAjrxBr3pjRR5tyeJUR SQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=cP1lKqCv0m7pam9tebxXo/dg9KekB6e4yuCInD6+caE=; b=txi+f+au5w37CRvs2HgnKjiRQgNwWceGT9awkbUgLS/e7hkC9MKKFbqpP/cqbIf7a37C h/ypGybwBGdwm2mVxCgHArfBAiojPa0aY0TN/VeXsqVXQ2gcNJ8uQ9DvJlYWke93A1Ve 4fdcbcr4qhWgEFD2agRqsYAllALcWxLcALc5QZviYyH7VT6a4u3dtPzIGTCfTC3x4CkP JijxOrU0oN+2bIkuqc+nMLdW04zokSgn8ZtZKu7FwuC9WrSExJVEbST1VPxA+thzQpOP XtzBwV4JbVuPJ32pi8tkt58FCD4DgEesTu395PdnEEAtrkErzNVg66dOYs1JhQO2GMU9 XQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2u8hps9kxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Aug 2019 19:29:06 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x79JHxjv067816; Fri, 9 Aug 2019 19:29:06 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2u8pj9fsu6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Aug 2019 19:29:05 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x79JT4qA015018; Fri, 9 Aug 2019 19:29:04 GMT Received: from localhost.localdomain (/73.60.114.248) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Aug 2019 12:29:04 -0700 From: Daniel Jordan To: Herbert Xu , Steffen Klassert Cc: Daniel Jordan , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] padata: validate cpumask without removed CPU during offline Date: Fri, 9 Aug 2019 15:28:57 -0400 Message-Id: <20190809192857.26585-2-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190809192857.26585-1-daniel.m.jordan@oracle.com> References: <20190809192857.26585-1-daniel.m.jordan@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090190 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9344 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908090190 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Configuring an instance's parallel mask without any online CPUs... echo 2 > /sys/kernel/pcrypt/pencrypt/parallel_cpumask echo 0 > /sys/devices/system/cpu/cpu1/online ...crashes like this: divide error: 0000 [#1] SMP PTI CPU: 4 PID: 281 Comm: modprobe Not tainted 5.2.0-padata-base+ #25 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0- RIP: 0010:padata_do_parallel+0xf1/0x270 ... Call Trace: pcrypt_do_parallel+0xed/0x1e0 [pcrypt] pcrypt_aead_encrypt+0xbf/0xd0 [pcrypt] do_mult_aead_op+0x68/0x112 [tcrypt] test_mb_aead_speed.constprop.0.cold+0x21a/0x55a [tcrypt] do_test+0x2280/0x4ca2 [tcrypt] tcrypt_mod_init+0x55/0x1000 [tcrypt] ... The cpumask_weight call in padata_cpu_hash returns 0, causing the division error, because the mask has no CPUs, which is expected in this situation. The problem is __padata_remove_cpu doesn't mark the instance PADATA_INVALID as expected, which would have made padata_do_parallel return error before doing the division, because it checks for valid masks too early. Fix by moving the checks after the masks have been adjusted for the offlined CPU. Only do the second check if the first succeeded to avoid inadvertently clearing PADATA_INVALID. Fixes: 33e54450683c ("padata: Handle empty padata cpumasks") Signed-off-by: Daniel Jordan Cc: Herbert Xu Cc: Steffen Klassert Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- kernel/padata.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/padata.c b/kernel/padata.c index d056276a96ce..2ab3b7402643 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -702,10 +702,7 @@ static int __padata_remove_cpu(struct padata_instance *pinst, int cpu) struct parallel_data *pd = NULL; if (cpumask_test_cpu(cpu, cpu_online_mask)) { - - if (!padata_validate_cpumask(pinst, pinst->cpumask.pcpu) || - !padata_validate_cpumask(pinst, pinst->cpumask.cbcpu)) - __padata_stop(pinst); + __padata_stop(pinst); pd = padata_alloc_pd(pinst, pinst->cpumask.pcpu, pinst->cpumask.cbcpu); @@ -716,6 +713,8 @@ static int __padata_remove_cpu(struct padata_instance *pinst, int cpu) cpumask_clear_cpu(cpu, pd->cpumask.cbcpu); cpumask_clear_cpu(cpu, pd->cpumask.pcpu); + if (padata_validate_cpumask(pinst, pd->cpumask.pcpu)) + padata_validate_cpumask(pinst, pd->cpumask.cbcpu); } return 0; -- 2.22.0