Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3586372pxb; Sun, 7 Feb 2021 15:12:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeyGRYZyC8LuTj4Z6U3rn6+Wmxq0wO/TQ0TC55MTdtwHkzMcEtBGNRkcqylcZTHXQnr1dk X-Received: by 2002:a17:906:33c5:: with SMTP id w5mr14412048eja.319.1612739526139; Sun, 07 Feb 2021 15:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612739526; cv=none; d=google.com; s=arc-20160816; b=Tej43mE4phu7JWWYw98/7b96CnhyLm+ZGm1F92NW25bjpDCutsnuixc8CIqaZtgEqR y7nt5NK2759n6c89m8WlirbuKA4FsnrTdWo4Tqpxlz9D800vOMtl/3XONknADsf0KMvB LBLIheWX7AQpENFrro5PRHIlFRL4QNBgvBH8SOCPPf7tGtsA9tDdt2pD+v+xImVXmByg HFsTOyEKQXGAGN2ilADXc0uNAhOC8ofVlkG0JXY7u686p3B7d09gyOu2TC/YgyQKVaKy GJyLNX4ydF9a1uHOfAdS6Du1QQjJXQTwZMXFRQaMd6/2b+Spxr9Nn6hYeCrNsRDDF+47 Mk2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=1evonit2OvppCvIPi3HAAUxfRVr6ZJgBHdyNkKbNhaw=; b=GzhpjOAHRHFEBNOKZd3v0bv7clO1Vpg0kKnVRKnmsvpN2r8aEy+mQblhm2tSop/Mus dAonuAXtud8Cl+YR1xnPG3wX/Q72rVxRyTlaXbX1ZNifBcQSjcm0niQ37a8lQF3okDHy BAa6ODa3OPFaHWUT80MikN7ABAqmlFd3mpSWdh2a1cHp2+NGWrq16tMmlfhueaypwXhs bec5EyQu4Cui8+echZr/bSzJuhDpru+9IbIQ8jWCT6+ms/K5REa0eGQkz+s59PgD8ycX DSqHY2CFG7BJ43/sZfgTWN49eImmvGE8R5vfN7lrPlY5IRL/n5LCRhuDH74xIExDNfQH 4ubg== 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k25si9054276eja.702.2021.02.07.15.11.25; Sun, 07 Feb 2021 15:12:06 -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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229590AbhBGXIg (ORCPT + 99 others); Sun, 7 Feb 2021 18:08:36 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:36436 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbhBGXIf (ORCPT ); Sun, 7 Feb 2021 18:08:35 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l8t9j-0000D0-N5; Sun, 07 Feb 2021 23:07:51 +0000 From: Colin King To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Daniel Vetter , Huang Rui , Junwei Zhang , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amdgpu: fix potential integer overflow on shift of a int Date: Sun, 7 Feb 2021 23:07:51 +0000 Message-Id: <20210207230751.8576-1-colin.king@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The left shift of int 32 bit integer constant 1 is evaluated using 32 bit arithmetic and then assigned to an unsigned 64 bit integer. In the case where *frag is 32 or more this can lead to an oveflow. Avoid this by shifting 1ULL. Addresses-Coverity: ("Unintentional integer overflow") Fixes: dfcd99f6273e ("drm/amdgpu: meld together VM fragment and huge page handling") Signed-off-by: Colin Ian King --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 9d19078246c8..53a925600510 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1412,7 +1412,7 @@ static void amdgpu_vm_fragment(struct amdgpu_vm_update_params *params, *frag = max_frag; *frag_end = end & ~((1ULL << max_frag) - 1); } else { - *frag_end = start + (1 << *frag); + *frag_end = start + (1ULL << *frag); } } -- 2.29.2