From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78E0F3FD96E for ; Mon, 29 Jun 2026 15:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782746931; cv=none; b=GT1FrU5mcls/2lgCUxp5UNezKu4Uja6pFFagXhmCJTnu7xeQ4q82HzA2pLKGXDNbVLNVO+pFhEZ3OIylYyr6Xp4euk9G7AoToDb2vX/hu8/rgPwDx+ekQxAID2IX+5E8wrxa4aQL/z5aQcw9PPfiWfIN9+RJguYfYFgX8Nm2ArE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782746931; c=relaxed/simple; bh=8ScX8kCkQmOTxoiTgZptb0qqtXyIrfGCyf55cFBczD4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=u2IfAPTDsEzddVQJQBcOxeM/AKV0Yh2GoyvvECQWEa4+WjdtqHd0pO79PTB72uNz+/ymFFAi3i5Gmq2T5pLGDjXqEIeE5R5OKmhCm/0vgbcCwi9I09ya5iP08ClfCCskyQxm6ptS4AG8xy9fU/HTyo/QlFMaHCICfNStv8qpdp0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UQclfqfd; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UQclfqfd" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4938d60c035so19080745e9.0 for ; Mon, 29 Jun 2026 08:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782746928; x=1783351728; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HFhwRQO/XnDqnsNCNRMiUIQQuhF/q4kw4HCjqPfc1vw=; b=UQclfqfdIeh8L0ubgFQKsno6u0q6EUgZ1XMelK7OO1uAa8eabAtVqtlxW4hPXnxWIx LjHNrZhx/lWsWqumG2VIurF0Mxjw9ttHaTUosv4WYwIOr3yCJuA+kP2IWuPJ8N7vh1Ac sVc6s4A/rxJDIStKOXfLUTLS4YT98+BLbgkhA5CDza+U7Nt4RC2YhKgMRFRZb6Qfwdib KVcscRICm/YIsN5o/Ez//YkNA5soX8CFl9QV1U1f5yy3aNR+Hb9skpBOBHk4q3wS4BQ4 SmWEkVgygIYizjs7Zie7fjJA2WSl3rXjMFtJBL6M7/3v2IQuH20RekwUsyOnqoEa1LNY PnLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782746928; x=1783351728; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HFhwRQO/XnDqnsNCNRMiUIQQuhF/q4kw4HCjqPfc1vw=; b=Ws98yf/leCDwjYlT4e4/jzyxM/jZTFvNuA/xyPmryHXQDb7dDkitVGVF2n7fbDtK6Z wQEqJgqszTKJdo4+16sV23UqdsrMq5a2ry1VEdAPnQmVdvRrriYmmldaZ6j070sA11za jstIu5Al8pPH9X6ZQUEjc5DCvd1E/MfFIZ9jGDKqrJ9dHNqwKisTfUvUT2P13f4pWtmE imK0Zr7Y7u+SkAuIa5xv10diEF0uyWpmKzRcr76p/NNb2fg5lnJDr8rUYo1/UG/bi4RU le2FsdR1ysDM82mfhggFcudqwCkUOhmGchVhovHdlUDgQWd3c+QRQJJxSjoIkvGxp01Z I8IA== X-Forwarded-Encrypted: i=1; AFNElJ/uAygu6QNJOkjfAPWjeeBJKBJgbquC+wQC+Nz6UBx2DMUVLgsy0Y8cVm2FWq/lum5Zfamkzzz40tG19AI=@vger.kernel.org X-Gm-Message-State: AOJu0YwAFOGDTYWE29v0/vIwV2sFjNd9o0hOXB5+lMcvUr173+Aisr0P C3HVtPqXxR4Is9ywsbNbecCqlRoyw7OQwtsrfMMrqjW2Y6c78GlyL37R X-Gm-Gg: AfdE7cnhyb6DNAjShMSCujrhtfgd5g8DyoIVPdSDQRfjeF5F7otwlZ5pRStTnWqpggc kz9HoJjHVTN9kCKhFL9zBxz+7bPrUlwfJQMF0BDtbPpSP9LNrKvbbAd0XipkD2pwDOH47XYsd+k d+mbn66kA14twh0/bvKZZaxYp3ZP4zQXw7k0AFyTU5ArjFf0WD6x74MZIJFZVyt3QX1EPYQKhkE twIqlhPK6VbxRw/WW4pQbGFnviHyQFHGSOuWAdS3AsRNxxYgqudClhUSZ0J2O3f4lzr0Vz8FqbE AEVanR7JEMpvrILgDaipQDqLqtuAmKlaGMBzOVHX6pwLG3kh25rP1mC7kPEZRYknCZqdlV5ZvqZ edFPiafthKnmtx+KaqOgJgstf7hIK5IqyQZmrAlNH4H2Mjm/FaGQMHOn76AEHKmzbkccMCuwS0V K4JRV+xWGxIG4i2nmLuFWXdltAXA== X-Received: by 2002:a7b:cd96:0:b0:490:6237:5200 with SMTP id 5b1f17b1804b1-493b828c480mr1572865e9.10.1782746927577; Mon, 29 Jun 2026 08:28:47 -0700 (PDT) Received: from Dev-Null-MSI ([2a0d:3344:52ac:a808:98a4:4381:be45:536f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268f700c0sm371321555e9.0.2026.06.29.08.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 08:28:46 -0700 (PDT) From: Yousef Alhouseen To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: David Airlie , Simona Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Yousef Alhouseen Subject: [PATCH v3] drm/amdgpu: reject mapping info when BO VA is gone Date: Mon, 29 Jun 2026 17:28:07 +0200 Message-ID: <20260629152807.13492-1-alhouseenyousef@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AMDGPU_GEM_OP_GET_MAPPING_INFO looks up the GEM object before taking the object and VM locks. The object reference keeps the BO alive, but a concurrent handle close can remove the per-file BO VA before amdgpu_vm_bo_find() runs. The mapping-list walks then dereference the NULL BO VA. Return -EINVAL when the BO is no longer associated with the VM. Suggested-by: Christian König Signed-off-by: Yousef Alhouseen --- Changes in v3: - Generate a clean patch against drm-misc-next instead of stacking on v1. - Keep only the intended !bo_va guard for the handle-close race. - Clarify the v2 withdrawal confusion in thread replies. Changes in v2: - Describe the handle-close race instead of an initially unmapped BO. - Return -EINVAL instead of -ENOENT. drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 27be5083f2af..83ec994ad36b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -1087,6 +1087,12 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, struct drm_amdgpu_gem_vm_entry *vm_entries; struct amdgpu_bo_va_mapping *mapping; int num_mappings = 0; + + if (!bo_va) { + r = -EINVAL; + goto out_exec; + } + /* * num_entries is set as an input to the size of the user-allocated array of * drm_amdgpu_gem_vm_entry stored at args->value. -- 2.54.0