Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1067297ybx; Tue, 5 Nov 2019 09:45:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwXOjp2OdIh50MCwg/2iHg5eU8N3iiZK0biKRSryKeDxWsjefZIT2lmy3C5Ur61nyAli9GX X-Received: by 2002:a17:906:1cc3:: with SMTP id i3mr29920467ejh.81.1572975928346; Tue, 05 Nov 2019 09:45:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572975928; cv=none; d=google.com; s=arc-20160816; b=PDpCAJG9DYpN7M88pBJJjmmdtn022+VWVC/iuMUxGozP96ESlB340i3lNwHyRyAZ+0 lA81XKGBy8V+xZ6c8ryx0HiRkkAeBTbJeNeeBRZlfREnTb3HOBL5Yfp1g5upGFY/2dCJ 4KeOTd6lbAmCWrKBZ38byRwbq7t8fY0xA9v2S78/Ku3HHywUYagOb7d1E5YMQMl8upOH dzdjxKvP/I5pKmXLl2Wt4v73ey2uTQcazsH097lhlb3Lugo2Q2sJuQL9yB5rvdduUMml aS73zsTCr0ngT0DhBo3JyKXB1TZM4o7YDWWIZiqyb8bEmwDoqbxse5aCEWdMCCWCWj0g ISBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=6G2FnOVRy2/U5dsjfnBWZ0FcEZmV31S602FM+Wz4ZgY=; b=pB0jupr6W3AWyEQ6lMABXFuCMo+iLvQ1AmhgiZ358Bk9Y1XmFlGQ2IsYKm6ae9Qtrq FABtYGFKO0f5N6I6XA3DFCZEt+l5HAAmbT/ANMMVgSUhIgEULiOM08UfLYpmSjpMogFJ nBJ3tpKUxl3TVsGCebVSXz7hqzvBiD6aMwCAUSdiVYGape0KM/AzcvLy0eYuwgZtPvXN Ppn37bz0U8ghy5+VbO350yQYVriYMKCfex0cSYunAE4eMntyz8meTY4eGxjK9DCsVKYF LK5jOeXtxKvYMuOzp4j1PXOXavTwlPDmsPG5F8+0uhnhGFnhq/PY2NyrYn74bRdMMwKl FG2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UDKQjMTq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si3555911eju.48.2019.11.05.09.45.00; Tue, 05 Nov 2019 09:45:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=UDKQjMTq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390437AbfKERmC (ORCPT + 99 others); Tue, 5 Nov 2019 12:42:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:60916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388969AbfKERmC (ORCPT ); Tue, 5 Nov 2019 12:42:02 -0500 Received: from sol.localdomain (c-24-5-143-220.hsd1.ca.comcast.net [24.5.143.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 84CE9214D8; Tue, 5 Nov 2019 17:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572975721; bh=wpN5dFK9y7CHh7qhkGjKOJbrRTRGtSpcxKUvYH3cpdM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UDKQjMTqFTL1AZCg5U4sHPerBG12YJ8qDC+VWkfCSUVMh2tGMk3XNEe7Z8hChxM1v jzI7+CbehGyLJPsR1DnBj/2FohcSXmH9eu1gOIJ8k9oBYklbyn8RrpIuOwNy1uOZXW JSwA0hdZJrEmrzKr7VVE7UEOTayZvfNe6B2Ejlw4= Date: Tue, 5 Nov 2019 09:42:00 -0800 From: Eric Biggers To: Tero Kristo Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, ard.biesheuvel@linaro.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 09/10] crypto: add timeout to crypto_wait_req Message-ID: <20191105174200.GC757@sol.localdomain> Mail-Followup-To: Tero Kristo , herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, ard.biesheuvel@linaro.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20191017122549.4634-1-t-kristo@ti.com> <20191017122549.4634-10-t-kristo@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191017122549.4634-10-t-kristo@ti.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Oct 17, 2019 at 03:25:48PM +0300, Tero Kristo wrote: > Currently crypto_wait_req waits indefinitely for an async crypto request > to complete. This is bad as it can cause for example the crypto test > manager to hang without any notification as to why it has happened. > Instead of waiting indefinitely, add a 1 second timeout to the call, > and provide a warning print if a timeout happens. > > Signed-off-by: Tero Kristo > --- > include/linux/crypto.h | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/include/linux/crypto.h b/include/linux/crypto.h > index 19ea3a371d7b..b8f0e5c3cc0c 100644 > --- a/include/linux/crypto.h > +++ b/include/linux/crypto.h > @@ -682,8 +682,15 @@ static inline int crypto_wait_req(int err, struct crypto_wait *wait) > switch (err) { > case -EINPROGRESS: > case -EBUSY: > - wait_for_completion(&wait->completion); > + err = wait_for_completion_timeout(&wait->completion, > + msecs_to_jiffies(1000)); > reinit_completion(&wait->completion); > + if (!err) { > + pr_err("%s: timeout for %p\n", __func__, wait); > + err = -ETIMEDOUT; > + break; > + } > + > err = wait->err; > break; > }; I'm not sure this is a good idea, because operations could legitimately take a long time, e.g. if someone passes in a huge data buffer. How do you know that X amount of time is always going to be enough? - Eric