Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1320852ybi; Wed, 3 Jul 2019 13:31:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqyEqao6L95v9sUjjm9Vv05Xa02K0oliiZ49b1o9vZ62Yer5M56xEHdsYKp9SubWL0HFcs X-Received: by 2002:a63:6843:: with SMTP id d64mr31180787pgc.383.1562185915396; Wed, 03 Jul 2019 13:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562185915; cv=none; d=google.com; s=arc-20160816; b=HsdO19z2Fik8MoPlTeVIew67eKiwaYZZ+epcOAFF64DzMFTvmNG4dxefkmIBZvyxFP DVlXhiTVJ+++BoYAhtAZb9XlzKvVwh0j+UgZbdM9qzssEhYzGSTExIst3IVEgClDy/92 SE3gDKfT7+HXNOq7rPykO/fT/1IsDr6IU3j7qyzaQA98eoEI7ubKu23Mrc+JVinmpIYb C598uMhg3PlxC9UmjR+cGN0nsxpjhACZKsm5hGy8/21sePAvFtEGjbxoIIQPyzz1Pf8g uRCMoup7tFdD818jMvH/xeIL7YGlxqGfDc/O2QQnXetmSgThbcY3SQA7Mfh5OxeJp+PG q5og== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kfkPKl+nAf/i5JpSvhW0tNIljGqYvuCg1Pzfe3JYxAI=; b=tU7dNFc6VaVfOJ+UP9x0OZ8mr4qBCUhZJ9r+Y41DItjMS7uOjjp6Jl3IuZ6BNzMpVo VX4nruBpzdd2fcRsDYyJOTKUbYEtZYGDPMIFe1zKwKZikyILe/VnQ3jqk0KDv7gEtUqa dg2YjvyOsaJqVQtQEJ8nmqP+75Or++I1v0j9dz8R4aVo+f/GAHcL7mAYthj+m/4GkUzW kxfolUk4G8IXQsgBlsqk93bQUJnAaiW4B5bpYP018dl5soRGvw0wEO/nC0Wx+fRyFe39 523KPCyLtkcKw8HCBfcWUkbOP5VZY4cGymhXXYrQjmF0WFi0MrnGaFvqxlaNDNm+Atty U3Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="igHZO/Xe"; 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 s59si3145253plb.294.2019.07.03.13.31.41; Wed, 03 Jul 2019 13:31:55 -0700 (PDT) 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="igHZO/Xe"; 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 S1726581AbfGCUbc (ORCPT + 99 others); Wed, 3 Jul 2019 16:31:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:48494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbfGCUbc (ORCPT ); Wed, 3 Jul 2019 16:31:32 -0400 Received: from gmail.com (unknown [104.132.1.77]) (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 E92C1218A0; Wed, 3 Jul 2019 20:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562185891; bh=8rZJjhlUf/qMBdRLPI5prMW5R8RsnoeRcyV06al/QNE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=igHZO/XeFH2AYZ1UZL9Hr/0DlCMrJobgPYTmblwWmLYpJhrE0ThCPKavzhp8UODlC dltKVf6ekIyFcekgpsHgb2EKKhfzm/UKUp8JEeh9zMBZsnYyG+EmijpcD1zhcqkJ9c lsy2bCVVV3XzCoQn+FNDlTDjcguJ5uJAMU1QUF9c= Date: Wed, 3 Jul 2019 13:31:29 -0700 From: Eric Biggers To: Michal =?iso-8859-1?Q?Such=E1nek?= Cc: Herbert Xu , linux-crypto@vger.kernel.org, chetjain@in.ibm.com, "David S . Miller" , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Steffen Klassert Subject: Re: [PATCH] crypto: user - prevent operating on larval algorithms Message-ID: <20190703203128.GC10080@gmail.com> References: <20190701153154.1569c2dc@kitsune.suse.cz> <20190702211700.16526-1-ebiggers@kernel.org> <20190703143057.miqgc7blhjjxjmee@gondor.apana.org.au> <20190703222108.467ec204@kitsune.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190703222108.467ec204@kitsune.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Michal, On Wed, Jul 03, 2019 at 10:21:08PM +0200, Michal Such?nek wrote: > On Wed, 3 Jul 2019 22:30:57 +0800 > Herbert Xu wrote: > > > On Tue, Jul 02, 2019 at 02:17:00PM -0700, Eric Biggers wrote: > > > From: Eric Biggers > > > > > > Michal Suchanek reported [1] that running the pcrypt_aead01 test from > > > LTP [2] in a loop and holding Ctrl-C causes a NULL dereference of > > > alg->cra_users.next in crypto_remove_spawns(), via crypto_del_alg(). > > > The test repeatedly uses CRYPTO_MSG_NEWALG and CRYPTO_MSG_DELALG. > > > > > > The crash occurs when the instance that CRYPTO_MSG_DELALG is trying to > > > unregister isn't a real registered algorithm, but rather is a "test > > > larval", which is a special "algorithm" added to the algorithms list > > > while the real algorithm is still being tested. Larvals don't have > > > initialized cra_users, so that causes the crash. Normally pcrypt_aead01 > > > doesn't trigger this because CRYPTO_MSG_NEWALG waits for the algorithm > > > to be tested; however, CRYPTO_MSG_NEWALG returns early when interrupted. > > > > > Do you have some way to reproduce this reliably? > > I suppose you would have to send a signal to the process for the call > to get interrupted, right? > It reproduced pretty reliably for me with what you suggested. Just typing in terminal: while true; do pcrypt_aead01; done and then holding Ctrl-C. If I have time I'll try writing an LTP test that specifically reproduces it. Yes, it would involve sending a signal to a thread or process that's executing CRYPTO_MSG_NEWALG (unless I find a better way). - Eric