From patchwork Thu Mar 17 22:10:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Philipson X-Patchwork-Id: 8614661 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 68E6BC0553 for ; Thu, 17 Mar 2016 22:15:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9CDC2026F for ; Thu, 17 Mar 2016 22:15:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1F69201F5 for ; Thu, 17 Mar 2016 22:15:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agg9Q-00042u-6H; Thu, 17 Mar 2016 22:12:16 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agg9O-00042o-RK for xen-devel@lists.xen.org; Thu, 17 Mar 2016 22:12:15 +0000 Received: from [193.109.254.147] by server-14.bemta-14.messagelabs.com id 0D/9D-02987-DBB2BE65; Thu, 17 Mar 2016 22:12:13 +0000 X-Env-Sender: ross.philipson@gmail.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1458252732!30128303!1 X-Originating-IP: [209.85.220.174] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24907 invoked from network); 17 Mar 2016 22:12:13 -0000 Received: from mail-qk0-f174.google.com (HELO mail-qk0-f174.google.com) (209.85.220.174) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Mar 2016 22:12:13 -0000 Received: by mail-qk0-f174.google.com with SMTP id o6so41731370qkc.2 for ; Thu, 17 Mar 2016 15:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=/Qr37qnNscZ6LL2DJDKi7b8Wgv07OOHXMYaWS4qJARY=; b=Z3sN7pmn9qJ1hA3sD3ykplT9h5/7tjQtrkL36sOfgg8CzwtiPWOsy7xuL/sh2QVN+N Qp/hgvHvDuPQu1ZcK4E0CN8u6wBOARnVh0VAMd/UaAyMDzsAe4J1cabKNAzaSWqvvw4R u6gnM7p+AEfcjMnn+I9CI25Gyb41vyHRG2+tIMPsP+nJMAkA89cvLvYu3etyPhejszrF kVvD8ZZNmM8PpePrVmwZ0fJfgAwAerbmBtyDljz5Wc10gVnPocDjdC3LohG5mkVD9zbK pXyyCMSgIgD4xSA41NUsHpryVGmo9SavDm52WsdE1jSftX/US2AZnzAhmZWBZtXEhO9/ BNHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=/Qr37qnNscZ6LL2DJDKi7b8Wgv07OOHXMYaWS4qJARY=; b=jxypK3eUX02Q3OruRrRQCUGBkh9UDachyNdTf5xfFrJ/dPEMcB5xZY2G7UlziaRKqV scm4QeJfwnj3n96h67WjbgWEdiGvQoymBhuh7XoRloofTsKEqh+3ceQJftNgRnZ6PnUI cmyQYj8F773eqdn8M1He12ZMBb4g9MIUm1bfo/deofiOGIgcX2IvTGAB0iKZT4Hrrk0g 3IFJQ1ColMlcFJePMatM1Y3B55T0tkXHE+YlXTXwLwbaH0daTjRny+oAHqkZFj2CEJW9 IdPO/goOmfLi3kY+f9IrEh859ulkdN85LowBsplNiuKJhcBEIvbiAUp4W7Ow6+Kqr14W f9nQ== X-Gm-Message-State: AD7BkJIf8fkl+JtapzGZ01rMDKlod/JA9EybSOqvz9K5RWq44vW9HpduAv6khdlfhRCgNg== X-Received: by 10.55.221.200 with SMTP id u69mr17680032qku.0.1458252732092; Thu, 17 Mar 2016 15:12:12 -0700 (PDT) Received: from [192.168.2.11] (70-88-247-169-ma-nh-me-ne.hfc.comcastbusiness.net. [70.88.247.169]) by smtp.googlemail.com with ESMTPSA id c127sm4547100qhc.23.2016.03.17.15.12.11 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Mar 2016 15:12:11 -0700 (PDT) To: "xen-devel@lists.xen.org" From: Ross Philipson Message-ID: <56EB2B73.3060905@gmail.com> Date: Thu, 17 Mar 2016 18:10:59 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] blktap2: Invalid logic detecting unaligned buffers in vhd_write_block X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It seems the logic is meant to detect sector unaligned buffers for block writes. The NOTing of the logic instead masks off any unaligned bits and also would cause the function to always fail. It seems the function is not used in any of the tools so that is probably why the problem is not seen. In the vhd_read_block function it is correct. Signed-off-by: Ross Philipson diff --git a/tools/blktap2/vhd/lib/libvhd.c b/tools/blktap2/vhd/lib/libvhd.c index 1fd5b4e..4ebe012 100644 --- a/tools/blktap2/vhd/lib/libvhd.c +++ b/tools/blktap2/vhd/lib/libvhd.c @@ -2188,7 +2188,7 @@ vhd_write_block(vhd_context_t *ctx, uint32_t block, char *data) if (block >= ctx->bat.entries) return -ERANGE; - if ((unsigned long)data & ~(VHD_SECTOR_SIZE -1)) + if ((unsigned long)data & (VHD_SECTOR_SIZE -1)) return -EINVAL; blk = ctx->bat.bat[block];