Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4473841pxf; Tue, 30 Mar 2021 08:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuMbThFNyVpbU2cB4J4zVmD+Inj7u7VcU5BPq+8cap0KzzJdnQgm5MJd+3zumzjpWCKAuZ X-Received: by 2002:a17:906:16da:: with SMTP id t26mr33892164ejd.270.1617118760893; Tue, 30 Mar 2021 08:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617118760; cv=none; d=google.com; s=arc-20160816; b=dOHy8B4yCmb73ndw8kqJLJm2npiSxwFoAUGygBbL6PgjWCdpy1GPO5rL4lEHoBOl/x VL2aeBAvtUo9t+MId8Qwpij1VHhCMxf42y85ar0rnjAU39gyPHzza5XFsS3Vf/qM4HA4 ft/QiCg5a6xQvk5c534QQ+0BynFYIPHAwgySSAXBeKSZ3WRn5k5krCSkU6R5228OuIuZ OXuIBWTNOnV9zMF/IZQ82j3bGDi7egWu3jMkwqNL/aHEzz8mQfgVKNOD9aYzpvk9vHeP ze/i2wVEgwsfhhU4vO84WPusgTkyJn+FPVfZtPve5ARGFXQfafgwMXWlmOS6HvLsFRMh bZvg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6hwekqUNLmFAHbwCnBsnIYIhL6K9vbJddnyV52qZ7VU=; b=Z+5PzqF9lqrOxu8e8WtvbzhzSyBgPpNCuEf3/BXg/90UunbACiXyf6DEHOgCg1ar5G XInD5GiaUjwMRd69Q1iu9F4b1E650QZwiKImCTd7JNIpS2fZfP5v6W4sU3h1tGstH3DD MnkxGSb7bqyNYjiKYcd9PWXtNDbhXtZYAXPMvq4J9dyoUEGnRwUeTPM+qNJnxEpxoQTy AbiuPzylU+gkg5dJ+fDGtuHg9RKKBVO5XHPrdhBwTBQAvgjofhRt/L/+xM8tTkI4l79c hYgPI7vHX8FRxD6rRGZYp/lBbwX6Id1KwBOaCIKsfU6BY9UfMU/7mu2nfqB3hO5jKVeQ vnHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mengyan1223.wang header.s=mail header.b=IBlcto60; 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=mengyan1223.wang Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si10648803edf.408.2021.03.30.08.38.43; Tue, 30 Mar 2021 08:39:20 -0700 (PDT) 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; dkim=pass header.i=@mengyan1223.wang header.s=mail header.b=IBlcto60; 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=mengyan1223.wang Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232388AbhC3PgU (ORCPT + 99 others); Tue, 30 Mar 2021 11:36:20 -0400 Received: from mengyan1223.wang ([89.208.246.23]:33078 "EHLO mengyan1223.wang" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232245AbhC3Pfq (ORCPT ); Tue, 30 Mar 2021 11:35:46 -0400 Received: from xry111-X57S1.. (unknown [IPv6:240e:35a:1037:8a00:70b2:e35d:833c:af3e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id 7A01465C16; Tue, 30 Mar 2021 11:35:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mengyan1223.wang; s=mail; t=1617118546; bh=6hwekqUNLmFAHbwCnBsnIYIhL6K9vbJddnyV52qZ7VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBlcto603Rok3cEFYhm+DEkFAOXJLWxwbTWKUvDacKdmmlPPi99UjPLQpwNY9uELa rQoqFqjkzJQNlD8EHsHyT1kLO64kI6myoGEWZ9K/ukUGdUKFnXPXxoPpWO9cCKD/W2 PcTT5e87isMm+fGzRrdVUmRUoIUa8pOpYrNFSn6DGvCqPjgGl5eog21zKpi0qDk/u/ d92bwRKT9QiO/Tw+MotqRjLAoJcXj7BNM4ZYHjZBx8fyYGeDS7p2PWkHDUT572wT8I 0IqM09myjwXWy4fz4pUxmdjIb5vwDbRRuCaarJXDD68/Ys599aePbmJ6ezPEwU6y+j rgXaZ19r+Syzg== From: =?UTF-8?q?X=E2=84=B9=20Ruoyao?= To: amd-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Huacai Chen , =?UTF-8?q?Dan=20Hor=C3=A1k?= , Alex Deucher , David Airlie , =?UTF-8?q?X=E2=84=B9=20Ruoyao?= Subject: [PATCH 2/2] drm/amdgpu: check alignment on CPU page for bo map Date: Tue, 30 Mar 2021 23:33:34 +0800 Message-Id: <20210330153334.44570-3-xry111@mengyan1223.wang> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210330153334.44570-1-xry111@mengyan1223.wang> References: <20210330153334.44570-1-xry111@mengyan1223.wang> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The page table of AMDGPU requires an alignment to CPU page so we should check ioctl parameters for it. Return -EINVAL if some parameter is unaligned to CPU page, instead of corrupt the page table sliently. Signed-off-by: Xi Ruoyao --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index dc4d6ae71476..a01c158bc29f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2198,8 +2198,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, uint64_t eaddr; /* validate the parameters */ - if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK || - size == 0 || size & AMDGPU_GPU_PAGE_MASK) + if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK || + size == 0 || size & ~PAGE_MASK) return -EINVAL; /* make sure object fit at this offset */ @@ -2264,8 +2264,8 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev, int r; /* validate the parameters */ - if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK || - size == 0 || size & AMDGPU_GPU_PAGE_MASK) + if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK || + size == 0 || size & ~PAGE_MASK) return -EINVAL; /* make sure object fit at this offset */ -- 2.31.1