Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2260086rwb; Fri, 20 Jan 2023 00:01:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZU8EOtJFdL3Zp/3WH7ybU3bFbwVxTAGiXrWjhFJbNDtxWLQG4WKJ2VFyGY7kxYkUwqRJs X-Received: by 2002:a17:902:dad0:b0:195:e577:231c with SMTP id q16-20020a170902dad000b00195e577231cmr1228151plx.31.1674201671838; Fri, 20 Jan 2023 00:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674201671; cv=none; d=google.com; s=arc-20160816; b=i5qR00i10hUgC9b0ve3uaCK0yDVyJDIbk0cPhyLmgFFBmi8haIUGmpb6RJGfUWq23r jOF/AcEtWqCMssej1Ds7gW3IyFpI4lgfKj+WPSMwaOJk1dZTMQNfOoi0GHRnKkEOkFe8 Kzl8HsFh82hQbwQ7eKKcf7VRj8oKMrtxA1EEbEBcJj6LUYRebKw48hjCMtoMddz2VCah MpxDvYWWmHkZsVhcl9sL/DpIXVRxSt7q2LyYMd0JzknE/fQtso4Fn0aCsqDNFoVeMmON GEvLKvDigX30Snj1icVxgJlUjIqQp9Es4oQnD8K8rD2BtwQ8LkiFYbqU6jcW/Gr6RWR9 xmIQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FLjl7BuIhILUO8rddxgTv9zZJ0712cjD5uiG0ZQ/KkI=; b=fFewz/bzhYS5JntJGLJQHWUt+iGDPXSY65r3Rrn5s4lg3qQ8/a/nqcCUTdiQpg99wT SKuawSxbLrEgupHEWMQlztwiyME8Ro2ASH2E+hcCSu4Xup8QDcHqBzp8OFbuCiMcc8Me I4CngHwU4sDA+eZ86gMFdEfc37CvaNTQ4q+H64XxklfS6t2Pf3DA8BYm5SJmA+Takwud fVTTxPtuYMGhyQNotnmbIRWYQjonNhIiskvMo7fALqSHb3CKBz4Une3b8SkWGgULqMxe Xt1kyl5ODjGF0Q2zaBUSBI/l4FeQdKcv05wz0qoITOMZYD48/arayynClKyK+lXX/R94 /QrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=N4xVjnu1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a1709027c1800b00189db2e76f1si9384720pll.389.2023.01.20.00.01.05; Fri, 20 Jan 2023 00:01:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=N4xVjnu1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbjATHn4 (ORCPT + 50 others); Fri, 20 Jan 2023 02:43:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjATHnt (ORCPT ); Fri, 20 Jan 2023 02:43:49 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A90F7DFAD; Thu, 19 Jan 2023 23:43:48 -0800 (PST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30K7U2rL026954; Fri, 20 Jan 2023 07:43:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=FLjl7BuIhILUO8rddxgTv9zZJ0712cjD5uiG0ZQ/KkI=; b=N4xVjnu1a6qIpWK+c58BJVYvBIHUyR2Cxwwj7dvgoUCKAz133qFR/HXWqE8hxNzDpwwO U0l9jZFBR/5om5yp5JhnUWivimLOB4W3tV8eYI5vpY1jWw9zE+xitZy7vgvnPzM8HkEs wLEPAyxObLefxFHVXatpJK/Z0OmtvYgVVfuh46sdsLIpxHHz9KA37WybZ+CjQ0aKsI/z HBJNHgjYu4DaZETHvUGQQVs87+il8pHQBBFrPpWOFyqIzgUr4KVBv5+OY5EVkwsPcFUN IiEDb59UwvQdxTyOurg/9R+499eQ+FNRTRzWId50ekArEc6j/4xzw8Gs4LDwtonoYBhb 2Q== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n7p1e92fe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 07:43:37 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30JMPBnv010590; Fri, 20 Jan 2023 07:43:34 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3n3knfdkre-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 07:43:34 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30K7hWUs49152316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Jan 2023 07:43:32 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B2392004B; Fri, 20 Jan 2023 07:43:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E364C20040; Fri, 20 Jan 2023 07:43:31 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 20 Jan 2023 07:43:31 +0000 (GMT) Received: from jarvis-ozlabs-ibm-com.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id AB0F2605A5; Fri, 20 Jan 2023 18:43:29 +1100 (AEDT) From: Andrew Donnellan To: linuxppc-dev@lists.ozlabs.org, linux-integrity@vger.kernel.org Cc: gregkh@linuxfoundation.org, gcwilson@linux.ibm.com, linux-kernel@vger.kernel.org, nayna@linux.ibm.com, ruscur@russell.cc, zohar@linux.ibm.com, mpe@ellerman.id.au, gjoyce@linux.ibm.com, sudhakar@linux.ibm.com, bgray@linux.ibm.com, erichte@linux.ibm.com, joel@jms.id.au Subject: [PATCH v4 01/24] powerpc/pseries: Fix handling of PLPKS object flushing timeout Date: Fri, 20 Jan 2023 18:42:43 +1100 Message-Id: <20230120074306.1326298-2-ajd@linux.ibm.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120074306.1326298-1-ajd@linux.ibm.com> References: <20230120074306.1326298-1-ajd@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bXomEqbrNyGopMDAe26t5fNKyzGL8tlJ X-Proofpoint-GUID: bXomEqbrNyGopMDAe26t5fNKyzGL8tlJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-20_04,2023-01-19_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301200070 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org plpks_confirm_object_flushed() uses the H_PKS_CONFIRM_OBJECT_FLUSHED hcall to check whether changes to an object in the Platform KeyStore have been flushed to non-volatile storage. The hcall returns two output values, the return code and the flush status. plpks_confirm_object_flushed() polls the hcall until either the flush status has updated, the return code is an error, or a timeout has been exceeded. While we're still polling, the hcall is returning H_SUCCESS (0) as the return code. In the timeout case, this means that upon exiting the polling loop, rc is 0, and therefore 0 is returned to the user. Handle the timeout case separately and return ETIMEDOUT if triggered. Fixes: 2454a7af0f2a ("powerpc/pseries: define driver for Platform KeyStore") Reported-by: Benjamin Gray Signed-off-by: Andrew Donnellan Tested-by: Russell Currey Reviewed-by: Russell Currey Signed-off-by: Russell Currey --- v3: Merge plpks fixes and signed update series with secvar series Neaten how we return at the end of the function (ruscur) v4: Move up in series (npiggin) --- arch/powerpc/platforms/pseries/plpks.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c index 4edd1585e245..9e85b6d85b0b 100644 --- a/arch/powerpc/platforms/pseries/plpks.c +++ b/arch/powerpc/platforms/pseries/plpks.c @@ -248,6 +248,7 @@ static int plpks_confirm_object_flushed(struct label *label, struct plpks_auth *auth) { unsigned long retbuf[PLPAR_HCALL_BUFSIZE] = { 0 }; + bool timed_out = true; u64 timeout = 0; u8 status; int rc; @@ -259,22 +260,26 @@ static int plpks_confirm_object_flushed(struct label *label, status = retbuf[0]; if (rc) { + timed_out = false; if (rc == H_NOT_FOUND && status == 1) rc = 0; break; } - if (!rc && status == 1) + if (!rc && status == 1) { + timed_out = false; break; + } usleep_range(PKS_FLUSH_SLEEP, PKS_FLUSH_SLEEP + PKS_FLUSH_SLEEP_RANGE); timeout = timeout + PKS_FLUSH_SLEEP; } while (timeout < PKS_FLUSH_MAX_TIMEOUT); - rc = pseries_status_to_err(rc); + if (timed_out) + return -ETIMEDOUT; - return rc; + return pseries_status_to_err(rc); } int plpks_write_var(struct plpks_var var) -- 2.39.0