From patchwork Thu May 31 17:12:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 137432 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6870757lji; Thu, 31 May 2018 10:37:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLzoxYqFGxgvbwD81l+rbcUWbExE/jluR6jX9UXcKxM4DTjdVd3XU8tfhn4Qu9ySrNjrPC2 X-Received: by 2002:aed:3534:: with SMTP id a49-v6mr7205845qte.47.1527788229319; Thu, 31 May 2018 10:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527788229; cv=none; d=google.com; s=arc-20160816; b=S+PBcU7N6JT8kL8EvXQ7PFpN+NX0SCvsJawFYRNJt6sCkZkIB/NTgxdbXPd9+T4iAZ 1ISxbWNa5Hzg/930LIJd3kr8lmkzel9/NbX72S6+VOo4PXJcmAdw6P/gVoBmOXw2m4cx wx5bI4vplCvuTIR/IyN8k1QLfTLNJmlupHQGYov4QjRQcStvEYNs0gOOUYNGbk/Mjj/k xYdrENEO588wEy5JOtYoRd5MwO1wIds7QtUqLa9lsxrb693sd//ITcP3JsRkKeT633yC hLGj2PSbDd9RypsTaenQZX1Z4PRowyGsFvTLnNihPZrCuMXuYfszYF9NAv/U1hTnZjRI W5zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=hyIpj2QmU6rMIZ5f05Wp80mBm+6IuPpnKv2y6gPWHaA=; b=I5gXYMi7IFG91gSW1AVReCqrqQoGlb00tkMeiuIXJod79PWl8pOVWoFOqZHJOC+1+t 2EkmrNeK0wBA5RAq6+OCw8+mnHZxyP6ucxyxcCDC+D/+gp6dWggOsw/FVDs+1H48XJ/L 9oVAazme0rSZkQbO8vVVdwWP+o2F+h+cAgB4pSKL4ca/4diL/rb/EE/zJLsghcBWJrB0 B0b+6WDynV3JNvPpwedJBh6VlWKM1SVctGqHIPX3JE4bSl5rjXKodmdp+SXk878cDpJz Ct5IzifJn+nfkRZ0JYrC/E96+9wmog9kF2xDIevCGSo6WznbMIFiTSdGvXGDabMUcvOa 8rFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r17-v6si144255qvm.9.2018.05.31.10.37.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 31 May 2018 10:37:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:45387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fORVc-0004yg-Pm for patch@linaro.org; Thu, 31 May 2018 13:37:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOR8g-0003ny-HM for qemu-devel@nongnu.org; Thu, 31 May 2018 13:13:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOR8f-0000Kb-E9 for qemu-devel@nongnu.org; Thu, 31 May 2018 13:13:26 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45850 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOR8f-0000Jq-89 for qemu-devel@nongnu.org; Thu, 31 May 2018 13:13:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E427BBB40D; Thu, 31 May 2018 17:13:24 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-47.ams2.redhat.com [10.36.117.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D2772026DEF; Thu, 31 May 2018 17:13:24 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 19:12:32 +0200 Message-Id: <20180531171253.21012-33-pbonzini@redhat.com> In-Reply-To: <20180531171253.21012-1-pbonzini@redhat.com> References: <20180531171253.21012-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 31 May 2018 17:13:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 31 May 2018 17:13:24 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 32/53] memfd: Avoid Coverity warning about integer overflow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Coverity complains about qemu_memfd_create() (CID 1385858) because we calculate a bit position htsize which could be up to 63, but then use it in "1 << htsize" which is a 32-bit integer calculation and could push the 1 off the top of the value. Silence the complaint bu using "1ULL"; this isn't a bug in practice since a hugetlbsize of 4GB is not very plausible. Signed-off-by: Peter Maydell Message-Id: <20180515172729.24564-1-peter.maydell@linaro.org> Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- util/memfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.0 diff --git a/util/memfd.c b/util/memfd.c index b3ecbac19e..d248a53c3c 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -66,7 +66,7 @@ int qemu_memfd_create(const char *name, size_t size, bool hugetlb, { int htsize = hugetlbsize ? ctz64(hugetlbsize) : 0; - if (htsize && 1 << htsize != hugetlbsize) { + if (htsize && 1ULL << htsize != hugetlbsize) { error_setg(errp, "Hugepage size must be a power of 2"); return -1; }