Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1144977ybh; Mon, 13 Jul 2020 10:25:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzvnkhAn68xMZ9Dbcd7TbkFZ2DOY/w84B3WGclhhscmX44vE/4WuUmEgHmcpzlA87p/PRV X-Received: by 2002:a17:906:e2ca:: with SMTP id gr10mr721905ejb.81.1594661141709; Mon, 13 Jul 2020 10:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594661141; cv=none; d=google.com; s=arc-20160816; b=c7LEu7B4teNgMgYVqFfgWsYfxOPa8hjZV9lQ/1Mp06xx35UJYRL62eV6ngFGkm5s53 JMc6BEdEdiG8Gpv1Zt/I+38gxwv3YPtRMLb3CiQK7dunTnBhJ7GV7AzIUqXeSZcAYmTr GlLAh5E84huSOG0hXXVdU2y9mJU4SHwZ3dLmg2Bqcz1ko/1c06904knfeY9P6GU4bc/k +JeU9arXjYMk/PYdUctYs3AEFxWXHwHC2N/8lSUg2xpqomM7Z9PeUEMzFma0Ik5b7HKd UH53otfP1hmNg/L0ZW7ky5uVWwScnUd4+rdDHohgYOQk+qwNZJsjjqh3e7I/3MY8v4rc AIQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=x2EgULDuBciGMBrnDy28035mxtXPRbGSTmh04wioxiU=; b=OC+BmqItD7OAjsJhWXXcp0XHxVwaxJI7Eu/q5l5FTRE6dq6VYGEd84YIjB1SbhX+Aj Nox1vzZ5A2bQJ2an3KL3MjUjomBk6V0/RgpFteWNNf1mahKMC2L6DA/9GbK6oAvbh1PE DHk5COEzAWEz60AvDSLZg1CW5jKzqO7V2d0BJar3FHrXNukavahFX2tz8Hi9+oTDZVm9 op+V+V9kiRnrS9urO0bXTArNyGOHhmn1b6/jvnU9m5r/y5QKjDxm7IDiprLIJGO8oJ/y u6DJ1ST3gl5ZI27C1ZovfkSSSlHTIzswIXn4uubVqiGerxRpWx31hXkXkXFIpY748hWv /zPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="SjDitS/c"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id lj8si9641900ejb.60.2020.07.13.10.25.15; Mon, 13 Jul 2020 10:25:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="SjDitS/c"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S1729681AbgGMRZN (ORCPT + 99 others); Mon, 13 Jul 2020 13:25:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:51816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729644AbgGMRZN (ORCPT ); Mon, 13 Jul 2020 13:25:13 -0400 Received: from gmail.com (unknown [104.132.1.76]) (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 BA1352075D; Mon, 13 Jul 2020 17:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594661112; bh=fxE/tXDpCqHH9v2q1GbJzkhgSDT04hYmYP1D+EePAUk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SjDitS/c5nDNUcgyo2i4wXsCuTSiYAV7O2UkOV3aFo4k4R9U23IK7IYICW3yo0Z7c JhF8BHp119lnogzTDjqGlx2tyf/I8gqyIo2bf9PdxV3lHB1zQfupwdwWcGleOv2IIG 8HNbU6+lAN0RVeeFKOOq7Q9ouhN2LAzlYTv8VpCU= Date: Mon, 13 Jul 2020 10:25:11 -0700 From: Eric Biggers To: Elena Petrova Cc: linux-crypto@vger.kernel.org, Ard Biesheuvel Subject: Re: [PATCH 1/1] crypto: af_alg - add extra parameters for DRBG interface Message-ID: <20200713172511.GB722906@gmail.com> References: <20200713164857.1031117-1-lenaptr@google.com> <20200713164857.1031117-2-lenaptr@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200713164857.1031117-2-lenaptr@google.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Jul 13, 2020 at 05:48:57PM +0100, Elena Petrova wrote: > +static int rng_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) > +{ > + int err; > + struct alg_sock *ask = alg_sk(sock->sk); > + struct rng_ctx *ctx = ask->private; > + > + reset_addtl(ctx); > + ctx->addtl = kzalloc(len, GFP_KERNEL); > + if (!ctx->addtl) > + return -ENOMEM; > + > + err = memcpy_from_msg(ctx->addtl, msg, len); > + if (err) { > + reset_addtl(ctx); > + return err; > + } > + ctx->addtl_len = len; > + > + return 0; > +} This is also missing any sort of locking, both between concurrent calls to rng_sendmsg(), and between rng_sendmsg() and rng_recvmsg(). lock_sock() would solve the former. I'm not sure what should be done about rng_recvmsg(). It apparently relies on the crypto_rng doing its own locking, but maybe it should just use lock_sock() too. - Eric