Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp377351ybc; Fri, 22 Nov 2019 06:45:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxd6riz1EcIW8Uvhc+coBRyOfOGq9aJbAMwuk/Xrb2rqnIscpxfxiESpOzXssvqKMqSABa5 X-Received: by 2002:a05:6402:2d6:: with SMTP id b22mr1535295edx.133.1574433951347; Fri, 22 Nov 2019 06:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574433951; cv=none; d=google.com; s=arc-20160816; b=nR6LbMcd+yfGYpNf8vp9yOhq1sakFXHUdtD6Xvb/XTyvxWvP3zYLpZJOVD9TXdT/vj 3rh+eY9n6VzBZojXFqYAwTa3fk4kHV+7xlpxPWJQcPht1khJmu1sglc0a+xBjj6nqaT2 fV933/ZJnQ2Ml08HNGWG2+fSpG5v5pwMM7TD5WjT+fYZkiKeuwBR6k4d6vBRTB9pNScs FWOfAasczW85oHot7VZmrdExhxT0R6BozDxx87QzUdYNlvASJfXlP9yYHh6ef2jgV62Y Yt8Wq01CXe0UxMj/QEU7VuUJgNEIABuAkHeqcJEKp4gYh4eXAkwMxFlclhXQR2O7EX7k 55Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject; bh=v+7N9Tg7rf1rQZvuTznLEsFfSnhUyByz6GU0t0tVWGc=; b=XyZJ+Zo+8VMpvt6zIpNlBBjii+mc4JstUz4fXPIpdFr54aUTtkmNueeOjTluE7rNw1 ZFBKJLNtDEEYnk/TGwjZdY6CIqAspy4NMSeKAowW9/RgBBIPHyEGLF9Mf7fBeXpupFdN x/whTtpBrRrHqcwkIhez3GPK5DqWxW1X5CjPenafh8yE67qCvc5hBF0g8kM5A+5mJIra 20bCrzOZiKnIsOGrFKHEU3s/duD4bm/fEP/yZ3HA0ulh1I5QvZGtgYtkyxS8Pv4U0zDS NHY4vIr8Cx3YqdH2Q4pLdBGFP+ysEoEi5epgPqqOiSrAP5fMVSCZ075MC61lv3izHLok S9BQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b41si5172817eda.1.2019.11.22.06.45.22; Fri, 22 Nov 2019 06:45:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbfKVOpT (ORCPT + 99 others); Fri, 22 Nov 2019 09:45:19 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41796 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726100AbfKVOpT (ORCPT ); Fri, 22 Nov 2019 09:45:19 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAMEg9x2097797 for ; Fri, 22 Nov 2019 09:45:18 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wefjwcnh7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 09:45:17 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 14:45:15 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 22 Nov 2019 14:45:13 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAMEjCpf46858498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 14:45:12 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 671F742047; Fri, 22 Nov 2019 14:45:12 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AAEC4203F; Fri, 22 Nov 2019 14:45:12 +0000 (GMT) Received: from funtu.home (unknown [9.145.67.101]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 14:45:11 +0000 (GMT) Subject: Re: [PATCH 2/3] s390/crypto: Rework on paes implementation To: Herbert Xu Cc: linux-crypto@vger.kernel.org, ebiggers@kernel.org, heiko.carstens@de.ibm.com, gor@linux.ibm.com References: <20191113105523.8007-1-freude@linux.ibm.com> <20191113105523.8007-3-freude@linux.ibm.com> <20191122081338.6bdjevtyttpdzzwl@gondor.apana.org.au> <87e9dbee-4024-602c-7717-051df3ac644d@linux.ibm.com> <20191122104259.ofodwadrgszdxuto@gondor.apana.org.au> <20191122140757.mbpnasimvnhke3k2@gondor.apana.org.au> From: Harald Freudenberger Date: Fri, 22 Nov 2019 15:45:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191122140757.mbpnasimvnhke3k2@gondor.apana.org.au> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 19112214-0028-0000-0000-000003BE118F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112214-0029-0000-0000-000024813E7A Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-22_02:2019-11-21,2019-11-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220132 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 22.11.19 15:07, Herbert Xu wrote: > On Fri, Nov 22, 2019 at 02:38:30PM +0100, Harald Freudenberger wrote: >> The pkey is in fact a encrypted key + a verification pattern for the >> encrypted key used. It gets invalid when this encryption key changes. >> The encryption key changes when the LPAR is re-activated so for >> example on suspend/resume or an Linux running as kvm guest >> gets relocated. So this happens very rarely. > I see. Is there any way of you finding out that the key has been > invalidated apart from trying out the crypto and having it fail? No. By using the pkey for a crypto operation the hardware checks the verification pattern and if there is a mismatch it simple rejects the operation. Theoretically such an operation can only partly complete and then a pkey could get invalid. I have no way to check if the pkey is still valid before the cpacf instruction call. > > Ideally you'd have a global counter that gets incremented everytime > an invalidation occurs. You can then regenerate your key if its > generation counter differs from the current global counter. > > Also when the crypto fails due to an invalid key you're currently > calling skcipher_walk_done with zero. This is wrong as the done > function must be called with a positive value or an error. In > some cases this can cause a crash in scatterwalk. > > IOW you should just repeat the crypto operation after regenerating > the key rather than looping around again. That's right. I'll try to rework the functions this way to avoid calling skciper_walk_done with 0. Thanks > > Cheers,