Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp659801ybb; Thu, 28 Mar 2019 09:37:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5RCc+RQHlKaEzCngVYYNwpXx3IGiBUbY23QcOAvvaNVk9cWaLRxvshSf9ws50ys22/Pvi X-Received: by 2002:aa7:8c84:: with SMTP id p4mr3674308pfd.164.1553791061885; Thu, 28 Mar 2019 09:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553791061; cv=none; d=google.com; s=arc-20160816; b=i0nLmdauVbCQNp5hp17tXakB4vBfty4VniHXX2z3Pg1IVtd3nD20jcFrwxdvkw9QPt BVQed7r6HwQHpFRuMlxVDr99VobM4y+YyfGNcWRZuLGlKTQ/u/uMsFxm+8LlChBHosJ6 dvXLyifvR5wPYin+bZdrmOkZ7bJVbp/eiNNsHN0hr0KsfqSliILy4pqxG+rvVTcRl76D rpNFPMXaWPQkeuSbOymkBmQBKRV4mdY20wdb5bZ3F2NszY20TajC4nYaVmuM7dZ0sFQ4 wtbSE7gp43RdmG8mb1fv25eOe4bKwqMJAJTkTWXvsd7I0tAkLNL0ybTOj1UUlKtelUJB TwQg== 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:message-id:subject:cc :to:from:date; bh=EeKe9Az3HmNfjLfNwusjfkgiSRKKfvRxupFED/ABnJU=; b=joSfm6GZ3rFVfyxv4MQRk1maQ5vw+u03j0/I/F2G1zfKNb86O1ru4/RL4DYxhG620f P1Bn3JJ34KFie43VS3tTvvaTJT3letsBPcAD/Xv53bcQAPY7fosFkN9fgBnS/WrZcRKs hyHL2BYSOz1CEeqNT7AiovzARPR+cHn1q9cKbFGjRFib7JWmeZv4JyTplDbmVz9YMsy8 MT6qPMiOtkWcLcayzhKEdfrNe5+gYtJ4PlPQOSdtCuCvoxnfwG1gSMlNqMNygx1LVM/G nLB2cXlIK5qXChYm+mJg0iXD9+MZhoZUv2AIoum07Zr3TWkNjRVaNBZiFGAzcz2nMnAQ khdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t64si21594434pgc.65.2019.03.28.09.37.26; Thu, 28 Mar 2019 09:37:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726281AbfC1Qgs (ORCPT + 99 others); Thu, 28 Mar 2019 12:36:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51972 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfC1Qgs (ORCPT ); Thu, 28 Mar 2019 12:36:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF7D3315878B; Thu, 28 Mar 2019 16:36:48 +0000 (UTC) Received: from localhost (ovpn-116-113.ams2.redhat.com [10.36.116.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F14718346; Thu, 28 Mar 2019 16:36:48 +0000 (UTC) Date: Thu, 28 Mar 2019 16:36:47 +0000 From: Stefan Hajnoczi To: Vitaly Mayatskih Cc: Michal Hocko , linux-kernel@vger.kernel.org Subject: Re: [PATCH] vhost: zero vhost_vsock memory on allocation Message-ID: <20190328163647.GE18536@stefanha-x1.localdomain> References: <1553648174-24913-1-git-send-email-v.mayatskih@gmail.com> <20190327164914.GE27283@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ytoMbUMiTKPMT3hY" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 28 Mar 2019 16:36:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ytoMbUMiTKPMT3hY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 27, 2019 at 01:08:53PM -0400, Vitaly Mayatskih wrote: > On Wed, Mar 27, 2019 at 12:49 PM Stefan Hajnoczi wr= ote: >=20 > > Which field was accessed before initialization? > > > > I ask because the situation is now unclear since code remains that > > assumes vsock is *not* zero-initialized: > > > > vsock->guest_cid =3D 0; /* no CID assigned yet */ > > > > atomic_set(&vsock->queued_replies, 0); >=20 > It was hash. vsock->hash is only read if vsock->guest_cid has already been set and hence vsock->hash has been initialized too. I don't see where the problem is. Was your tree missing commit a72b69dc083a931422cc8a5e33841aff7d5312f2 ("vhost/vsock: fix uninitialized vhost_vsock->guest_cid")? Are you sure the crash can be reproduced on linux.git/master? Sorry for insisting on so much information but I want to make I fully understand the issue you encountered. > > If we're going to zalloc, let's get rid of explicit zero > > initializations. Or let's use kvmalloc() and fix the uninitialized > > access. Mixing both is confusing. >=20 > I would go with zalloc, since it's easier to read and it prevents > further situations like this. > A zalloc was there originally (not in fallback though). Sounds good. Please send a v2 that also removes the explicit zero initialization since it's no longer needed with zalloc. --ytoMbUMiTKPMT3hY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJcnPgfAAoJEJykq7OBq3PIRigH/2H5ORZfaJGEE4aM0ajr10TI 6j7s0yIXb/ChPliLQYAEItPZZP1kqUA0nUbFkX+RzbWlivYfUvDmHIeEZPANOpBA 7Ezmlgt5XQhwU0tgdCGL6MJQxyTb2ZE9KvfE1+LJYZnAlB7ZcYDnBTB/2tZew8lN HOxAxkSAZ3HWeGyPxxXvq3pufK0OZ7BAxP9c+Io5XbqmMMHJz8cmM5ilhqREWYNX 9CsqhAhifw7lo9TwewBDiNH1NcM93nEKviGiXlCYmbKviztovxbzpafl0qu8jC3b fo5DtppjmJrxLZ+g5guyz3ROSrH+EX2+j8pQhYEWrKfHmocmxqZBzGlFoA3LWD0= =FVwU -----END PGP SIGNATURE----- --ytoMbUMiTKPMT3hY--