Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp723549pxb; Fri, 14 Jan 2022 15:03:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9/jBRK+WBaVLHULye+N8CzjR0oqAttRkJwoThSU454GCUq7i1gsKWs8GW5y4Se34u5uic X-Received: by 2002:a17:907:6ea4:: with SMTP id sh36mr8924816ejc.482.1642201401584; Fri, 14 Jan 2022 15:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642201401; cv=none; d=google.com; s=arc-20160816; b=WjXzLG0UYdXRzBOCSjg7mb0hg5Y40LCujqZIZC8oQ+s2BCu6W45JAYIAdAdpyLn0oG QYte6e95EUto0UNlLsQUsb2dldv4+CH2x6xbUYjP8ZEk1Oljrvv755Yh/O7lz6i79aVD h2MVT7+zVMMDjSaG5fc/m1wUQarpbMC/IceR4VSK75N3rQpWna7CJ7vP0IWmP+FLIzk0 veK3X4zw9syIPK+Eg8I4qcPmQlFvx9IFiI4nMKkDI3IJxLnhL8CTPbpj/Km/dRf32P3g pEkCHGLXsGMNKzhghDuBjoSvHaT22Y4gDj6SGj9cJnFsu7v+V7GQqb9TeR+qEQxw0NaI LHpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=80fbgApjgxRqmQ/SUBxRZx2r8MYqVc4l2XpDiV7SkBM=; b=ubCS2ZS1Hl1qy975jUvkWoPmWvJFRiIp3SvaVARvCP+BsJwhSo77RSZgelmv/G5Le6 Ik/9AzQapAqwYXNmBQrRGMpX0WuW3KPVdajmJa7m6k+CLXXmoSPGzvU/FsC4FeuHFftW 3z42xZulC7a7XnDIAczgqcj8C7Tf3yUVcrfKWEQy8lCD0ME2G0kkS5yFN1MtIjMYGpkN YUF8T+383a8brGW8uXCkSL4E9eUz7i0rk91vwa9krtA4SUH9TkppYRj3hrMCTgGk3j50 sVNbyI7B0oBmNxIJFUnrgeWe8NqQdJu5enX+W4dtFrmh91SKRhIgRmXhkr0rBjMrj5l0 P2vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 qk42si3652394ejc.935.2022.01.14.15.02.56; Fri, 14 Jan 2022 15:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S244023AbiANTNL (ORCPT + 99 others); Fri, 14 Jan 2022 14:13:11 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:44825 "EHLO mail-wm1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234061AbiANTNK (ORCPT ); Fri, 14 Jan 2022 14:13:10 -0500 Received: by mail-wm1-f49.google.com with SMTP id f141-20020a1c1f93000000b003497aec3f86so7439883wmf.3; Fri, 14 Jan 2022 11:13:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=80fbgApjgxRqmQ/SUBxRZx2r8MYqVc4l2XpDiV7SkBM=; b=irS5VW+96mvUlD17dHtUUD+q4jmXY4vqtc/g+92N1VXrHOsQC8A7Zrrf9Ik01F1kaY uWCgFK2yV+PtjrNdCX+rMMvYIz4WVq6n1OFh0nSRuf9veMQ3GQB8BN/5e0fUsdFCWOrr xRfm5+mb3vYMXAzEASJH5iuj+QYIN+MEjJEJPpaItgF+Ay26GWFZnpW+iGKhf7sfyfiR ogLLs3WCX2zCjzh5jyInRMWj68bXCUjEfBHQBJTiy6zT+R7AT9dAyEovmgHRGP1Ev7xp SZlIrD4pI1U9/uKKxsvdJB/RrFhdC45bZBg0ydFs0pvZ2DSFwRLQeaA5a75d3ERXKHbl nBGA== X-Gm-Message-State: AOAM533RHNoEUsgE/6GzyXYXCpKe1AIQ6Ai1+HYYHo9sbi/X7rCBZWqn O5WBci29QQC9wWf4JH0BYuGhWlBUjDk= X-Received: by 2002:a05:600c:6020:: with SMTP id az32mr3830646wmb.149.1642187589431; Fri, 14 Jan 2022 11:13:09 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id z6sm7961353wmp.9.2022.01.14.11.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 11:13:08 -0800 (PST) Date: Fri, 14 Jan 2022 19:13:07 +0000 From: Wei Liu To: Andrea Parri Cc: Yanming Liu , linux-hyperv@vger.kernel.org, Wei Liu , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, decui@microsoft.com, drawat.floss@gmail.com, airlied@linux.ie, daniel@ffwll.ch, mikelley@microsoft.com, lkmlabelt@gmail.com Subject: Re: [PATCH v2] hv: account for packet descriptor in maximum packet size Message-ID: <20220114191307.uu2oel7wbxhiqe56@liuwe-devbox-debian-v2> References: <20220109095516.3250392-1-yanminglr@gmail.com> <20220110004419.GA435914@anparri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220110004419.GA435914@anparri> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 10, 2022 at 01:44:19AM +0100, Andrea Parri wrote: > (Extending Cc: list,) > > On Sun, Jan 09, 2022 at 05:55:16PM +0800, Yanming Liu wrote: > > Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V > > out of the ring buffer") introduced a notion of maximum packet size in > > vmbus channel and used that size to initialize a buffer holding all > > incoming packet along with their vmbus packet header. Currently, some > > vmbus drivers set max_pkt_size to the size of their receive buffer > > passed to vmbus_recvpacket, however vmbus_open expects this size to also > > include vmbus packet header. This leads to corruption of the ring buffer > > state when receiving a maximum sized packet. > > > > Specifically, in hv_balloon I have observed of a dm_unballoon_request > > message of 4096 bytes being truncated to 4080 bytes. When the driver > > tries to read next packet it starts from a wrong read_index, receives > > garbage and prints a lot of "Unhandled message: type: " in > > dmesg. > > > > The same mismatch also happens in hv_fcopy, hv_kvp, hv_snapshot, > > hv_util, hyperv_drm and hyperv_fb, though bad cases are not observed > > yet. > > > > Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for > > the descriptor, assuming the vmbus packet header will never be larger > > than HV_HYP_PAGE_SIZE. This is essentially free compared to just adding > > 'sizeof(struct vmpacket_descriptor)' because these buffers are all more > > than HV_HYP_PAGE_SIZE bytes so kmalloc rounds them up anyway. > > > > Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer") > > Suggested-by: Andrea Parri (Microsoft) > > Signed-off-by: Yanming Liu > > Thanks for sorting this out; the patch looks good to me: > > Reviewed-by: Andrea Parri (Microsoft) > Thanks. I will pick this up after 5.17-rc1 is out. Wei.