From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E51618C033 for ; Thu, 12 Sep 2024 07:38:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726126704; cv=none; b=bXVpQWN8vlwkVRgX54V5ABeQTitafMa4OmC/rKPpun8QuMZLgca0SaAbMiNr2DvT9gz2XxpCI7QzC2UdRK8dro43DzpUDWjI15K8pNfLA3rCEdf+GShrydnyCK771BoURA9cwzPfMfTPG7D6hKQTV+FRL12p8gCEIWtzt06FHGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726126704; c=relaxed/simple; bh=z3/ZlPRYKpImydcKEv/wyodhIpd9NvgY2Js54fR2fdA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S9RvC2TL3gdV1LCBU7p0Ro+FnvVRX3uo6/CwN58mqy0Ri10+ZZgY7J685aRzv3rCEvsIQfZYprbdNZ1i/8JvZVkIy0gwpABLFPAua84SfgFszYQs3ll41rEipWW0qXkOH1CBHQhzYhb2JrTrqYnZCnE2P958ZMVyDNC1lV4F4p8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iPcTqjfQ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iPcTqjfQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726126701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H4fBuBnCEidjmbeIEXnc/9CKuIY9TAKerLdXJtzxaNI=; b=iPcTqjfQ60j88uBIL6QT3hgh2XuNaftgSv1B9p1jTjdEkEkJboRW8BLEn+F8YP08TH7PyN THpIrpeO6dZviUfcEQIKToD1VckJtODKy++3irn0DmfiVG0rfkOI/d4BgBU6rPdA9TNijT v0xd85uiLpYFyTx+Gv4hByqkMPXJrIQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-466-rC4kkDUdPde6zRh3LVc1xA-1; Thu, 12 Sep 2024 03:38:19 -0400 X-MC-Unique: rC4kkDUdPde6zRh3LVc1xA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb0ed9072so5210095e9.1 for ; Thu, 12 Sep 2024 00:38:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726126698; x=1726731498; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=H4fBuBnCEidjmbeIEXnc/9CKuIY9TAKerLdXJtzxaNI=; b=l8Kg7uLDN0QoA5sVX6mWHiZ8MKt+A6iOWtL/+41pYpFQwvPWQ0UMIn2BCMTuObLtft 3iPW2PXGRFm1i4EGa6OQdeykWBmIzUzT3ba7AqY8b2JHlajyfeYDBkwF8LQLRbD9HjK4 hcBgvGBOf2MBfc051F2KSNmMTARVd5CWU+/ll7jZxcsyiFV/Ex7oQNGQSkBOF4Et7++p GHRrILpGYvwTc+h8oOpkUyVm3td5eersWw1RampH5Nwg8gBfcza1q+6zT11l6Dt2aza+ 8lpSpsLvBnGJOhQLZx/wH1UBw8OGiNFVDZlyvNL+fNCFqCHhk6l9OxU4uXi9NgdHf1Hu mKsQ== X-Gm-Message-State: AOJu0YwMZu/8p6PTRzMBZkIEHpwnNFj1/P3iR9A66iw+kdgU2XbxR7Gd PWPDfnrG+mAChTlM865Z9jyxWObIvbm6zObg/285dSmiSuTJc9+zupRXrNQXPhmTrzVouiLDzzE M+7BcLxLYeCaiwez/TKy2yj0N7kjF1xTWffAoQDQlAap9vDbVIduTKA== X-Received: by 2002:adf:fcd1:0:b0:374:bd01:707c with SMTP id ffacd0b85a97d-378c2d55876mr1413307f8f.48.1726126698251; Thu, 12 Sep 2024 00:38:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOO68ioJGvs/NwodO5lKd9xytWZxftBSaY9t/pTKbQ/jAAYNVMqH9/p8jEMuTR6sj3X/JFbg== X-Received: by 2002:adf:fcd1:0:b0:374:bd01:707c with SMTP id ffacd0b85a97d-378c2d55876mr1413275f8f.48.1726126697433; Thu, 12 Sep 2024 00:38:17 -0700 (PDT) Received: from redhat.com ([31.187.78.105]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956767dasm13740647f8f.62.2024.09.12.00.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 00:38:16 -0700 (PDT) Date: Thu, 12 Sep 2024 03:38:12 -0400 From: "Michael S. Tsirkin" To: Xuan Zhuo Cc: netdev@vger.kernel.org, Jason Wang , Eugenio =?iso-8859-1?Q?P=E9rez?= , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , virtualization@lists.linux.dev, bpf@vger.kernel.org Subject: Re: [PATCH net-next 03/13] virtio_ring: packed: harden dma unmap for indirect Message-ID: <20240912030013-mutt-send-email-mst@kernel.org> References: <20240820073330.9161-1-xuanzhuo@linux.alibaba.com> <20240820073330.9161-4-xuanzhuo@linux.alibaba.com> <20240911072537-mutt-send-email-mst@kernel.org> <1726124138.2346847-1-xuanzhuo@linux.alibaba.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1726124138.2346847-1-xuanzhuo@linux.alibaba.com> On Thu, Sep 12, 2024 at 02:55:38PM +0800, Xuan Zhuo wrote: > On Wed, 11 Sep 2024 07:28:36 -0400, "Michael S. Tsirkin" wrote: > > As gcc luckily noted: > > > > On Tue, Aug 20, 2024 at 03:33:20PM +0800, Xuan Zhuo wrote: > > > @@ -1617,23 +1617,24 @@ static void detach_buf_packed(struct vring_virtqueue *vq, > > > } > > > > > > if (vq->indirect) { > > > + struct vring_desc_extra *extra; > > > u32 len; > > > > > > /* Free the indirect table, if any, now that it's unmapped. */ > > > - desc = state->indir_desc; > > > - if (!desc) > > > > desc is no longer initialized here > > > Will fix. > > > > > > > + extra = state->indir; > > > + if (!extra) > > > return; > > > > > > if (vring_need_unmap_buffer(vq)) { > > > len = vq->packed.desc_extra[id].len; > > > for (i = 0; i < len / sizeof(struct vring_packed_desc); > > > i++) > > > - vring_unmap_desc_packed(vq, &desc[i]); > > > + vring_unmap_extra_packed(vq, &extra[i]); > > > } > > > kfree(desc); > > > > > > but freed here > > > > > - state->indir_desc = NULL; > > > + state->indir = NULL; > > > } else if (ctx) { > > > - *ctx = state->indir_desc; > > > + *ctx = state->indir; > > > } > > > } > > > > > > It seems unlikely this was always 0 on all paths with even > > a small amount of stress, so now I question how this was tested. > > Besides, do not ignore compiler warnings, and do not tweak code > > to just make compiler shut up - they are your friend. > > I agree. > > Normally I do this by make W=12, but we have too many message, > so I missed this. > > make W=12 drivers/net/virtio_net.o drivers/virtio/virtio_ring.o > > If not W=12, then I did not get any warning message. > How do you get the message quickly? > > Thanks. If you stress test this for a long enough time, and with debug enabled, you will see a crash. > > > > > > > > -- > > > 2.32.0.3.g01195cf9f > >