Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36457C433DF for ; Wed, 3 Jun 2020 20:46:46 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 091A12077D for ; Wed, 3 Jun 2020 20:46:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 091A12077D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jgaHH-0002pM-6J; Wed, 03 Jun 2020 20:46:23 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jgaHF-0002pH-Px for xen-devel@lists.xen.org; Wed, 03 Jun 2020 20:46:21 +0000 X-Inumbo-ID: 47119d10-a5db-11ea-adaf-12813bfff9fa Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 47119d10-a5db-11ea-adaf-12813bfff9fa; Wed, 03 Jun 2020 20:46:20 +0000 (UTC) Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ZEa2eF+s/eaIrs3thAnFPIjtP2GgNPrHpZ2geRiHgP3i9ORY3LjT0Z1DZdhMB0Bs0xLKnfEAyA DurC/XM+xhBC+/tT7TNx1/o24bs/hu+kMh1VEor0x9YW30LQJ4kHvRGA8bof/xkcsdZb18Bjxo SH06ymt2caW+StrAiNPbNJH/3zZ4ftdh9tk152jO6F/IJWi03fQUNNZ2+Fm/L/yhk0y3+C3E99 qP7oB33MvEE8kLeNxsd/bmawkZG1Ml+vARc4YBIpElE4XG6H5NidHlt7Tvo36K+RkLyKoqM6f5 NTo= X-SBRS: 2.7 X-MesageID: 19185429 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,469,1583211600"; d="scan'208";a="19185429" Subject: Re: [XTF] xenbus: fix xenbus_write() ring overflow To: Pawel Wieczorkiewicz , References: <20200603082141.42683-1-wipawel@amazon.de> From: Andrew Cooper Message-ID: <75f655aa-6bea-cfe9-84de-bd4ef0195ab3@citrix.com> Date: Wed, 3 Jun 2020 21:46:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200603082141.42683-1-wipawel@amazon.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: julien@xen.org, wipawel@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 03/06/2020 09:21, Pawel Wieczorkiewicz wrote: > Currently the xenbus_write() does not handle ring wrapping around > correctly. When ring buffer is almost full and there is not enough > space for next packet (e.g. there is 12 bytes of space left, but the > packet header needs to transmit 16 bytes) the memcpy() goes out of the > ring buffer boundry. > Instead, the part variable should be limited to the space available in > the ring buffer, so the memcpy() can fill up the buffer, update len > variable (to indicate that there is still some data to be copied) and > thereby the xenbus_write() loop can iterate again to finish copying > the remainder of data to the beginning of the ring buffer. > > Signed-off-by: Pawel Wieczorkiewicz Oops.  Reviewed-by: Andrew Cooper and pushed.