Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1353090ybi; Wed, 3 Jul 2019 14:10:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxe3LOe2hvY2P4ymRKm8rDM8Pfq9vIwSVWBljfw4gsRaOfDaqHJKccxaVHOIj2iok1ii2Ud X-Received: by 2002:a63:6b07:: with SMTP id g7mr40602645pgc.325.1562188241387; Wed, 03 Jul 2019 14:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562188241; cv=none; d=google.com; s=arc-20160816; b=V7EZvpHMKQdTnBtr2AZF4GB2lw+fRQACmN1k/QfFHLPKtRhCMqm7K0r7zhb4VV7QTw TU6clYIyb5ODEvnuskwsTnV9A7sQvarOkB8742vZpcxohfAOj6OJkBPOMs5Z8x3pI75l n6TQP9Z8Qnhf7Cdemsm7fugAorf6NFgpuqyJjKQYyQzPGQjSc8i8S9TUkXTncDeTa2Y0 x+CLQntCRazFPPPW55LpSMmo17dMMHT/QSgWP/+QOc9jMzW83Hpg17fHKBSwNDPP14+z UZr5jaMhjS6uTqYIx0GjyM+ZvF9T92MwgrLCeeCJ1LtKcMS/M4MuQaLYQS9Fxws7HWnr omKg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=2/7FnqCdWRgrkLZQPmVQdIBJa6yJOA/gXvrHgOUPGQM=; b=oE7B5ccEyCzVHvinDWy9eF8J38H8E2/9C2QVNvKAthLe2QLEBlsc27+ANJ4XQJxBig PUy/w43vjwU5fJxlhT6zBdqKbqaR+A+oA9COS9KPLEMtBpODpF0dfi15ulq+47qs/njL FVaf2RQ7XnFnNHAxjtk7IwHYRrbdoiS/SAdnFUi6Dcgs18e60gAtGCAqiy5estionxgQ dw+YlzJ8n/rfXtfVBFnTsYtNkkNoykiWZeBuuW9liOMlUcbsz9chy+CwiRwe3T66OlZT U4lRcqE40oI9xT+DFzLmgab/aVFQ8YRRjMWGqmQNSr8N5n3j6nqMZ0thj+TOgn/WdIhf aZJg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si874443pfb.206.2019.07.03.14.10.19; Wed, 03 Jul 2019 14:10:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726678AbfGCVKQ convert rfc822-to-8bit (ORCPT + 99 others); Wed, 3 Jul 2019 17:10:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:35034 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726550AbfGCVKQ (ORCPT ); Wed, 3 Jul 2019 17:10:16 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 24FABAD35; Wed, 3 Jul 2019 21:10:15 +0000 (UTC) Date: Wed, 3 Jul 2019 23:10:14 +0200 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= To: Eric Biggers 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: <20190703231014.610ab8b5@kitsune.suse.cz> In-Reply-To: <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> <20190703203128.GC10080@gmail.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, 3 Jul 2019 13:31:29 -0700 Eric Biggers wrote: > 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). Maybe it is possible to just send the remove message without waiting for the ack on add. Thanks Michal