From nobody Sat Jul 25 20:48:45 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 ED068348C5A for ; Mon, 13 Jul 2026 17:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783963836; cv=none; b=hFSxZ3N/t1dVqiUlSv1dJWtzMHkaVzCE6mxkCtdig/0+sQj2cIBNXRTh99Z5oyaerJzSIFFztaq6lKNal7XDKy9fO5T7WszjVszR1H+1LxtXURPz6IMO88b8lblIRRAwtdj0qezLF1d1pdjdKaVOAswmMCdRujKAZKLgNL+dHBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783963836; c=relaxed/simple; bh=PcyM4CQHbO5KMJ3N1bAHLttCr4/v1lxQVOiHVJpdnVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NDiicGHfaKJywAOh8Uryl79MAQlfG7gzF4HwEBWaP5+IHxOlTguxW0JIXTfE5kUPk0G/fOcAiWnSW4o3rxCNRfIL41JRRHI8F0xX/I24Dszorqfd+Sjwfd2cQg7mL/QQZ/CwXOKPMFcd6kZzdRMkHTwdF4LpgNisbEU6qSVABG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai; spf=pass smtp.mailfrom=0sec.ai; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b=FD7eTgtL; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0sec.ai Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b="FD7eTgtL" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-493b7612475so27091465e9.3 for ; Mon, 13 Jul 2026 10:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1783963833; x=1784568633; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=h1VuKaNm+FCqQ0Qgm5d1hgzA1jRjKkQpwwjQu1kdhRU=; b=FD7eTgtLx1xYBziB8cjCjHw76SBRlr5EkIuG2xN13drGz1IXuwzxKPCctip4XpOXV4 aZBb0cyoeQQzQUCQERwH4bn8alBHKHeFxDyMnlyKIW9IM3qfRUV27WsfDV0j7yd6K5Nd jlDiXOzuyaCqZiMsBEnCUtBxqhW1JKlibPJvHBBNU34T4Ac4mYTWxjLwZ4G0hbMeH62i tJbrphRTxiee6IAjM1IBZod6woMIaw89z/YHTXkPkLoJWhMJ8czVxl7TeSVrUaVGCQ51 5ukff30spfuF/bm6ueEPVvfuHjInhSpsdUOI3dKrI811q/CAtqsfRz0snTHMMsYGRMn2 UfFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783963833; x=1784568633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=h1VuKaNm+FCqQ0Qgm5d1hgzA1jRjKkQpwwjQu1kdhRU=; b=gVKvEI6ncxh67aEa9IctF8DMmX4Jt71kT+ZKyxoiUcTRZAjQuMtB332wN4xbp39bqK nivAkSSHTuZasD7CLmV0CDsrden/VmEWm5bL2nszqBtCk7RSVOriuom14Y3v6xZbXBMv xxvUbTpXQRpCdzjC16MQBQ/GGxFPwg4ncuGwNvkUJEPyzT+wtKa+j610BTLEI8kHfvBa RZXp60rogRTdB5xhphEG+IwasaAf5tiOCwFKx3gb+BBkj0HuoQ32ks6GAOpTQ8Lza2VV 9VCBwlRDwtwWdijl1yqSd30hisU7hDHIfzUmiSr6W0sMpcTJGWcpiiWfJegUVGc4UO+r wkVA== X-Forwarded-Encrypted: i=1; AHgh+RrHQHzAjS61yJVrOj/yYlMRUcmvMnp7JUNLFrrvA+w+Qq8/doE/e8fHISwgJKKM0YKBFYk05BZXeshblcU=@vger.kernel.org X-Gm-Message-State: AOJu0YyByIl36Oj1g2sgrUjgnXvHysbeGVXhKLxbi2FT3ZvDcCDmAGM6 uTb4nC0IS4ErveIGyO/JmW1/evQGcZmteT/ebxK0Oj1AycMy79BupkXtgq5gC/p/MgIM X-Gm-Gg: AfdE7ck9kQdAN1QF18ztewyUgRt5EHGOASUsyzpFCpYz3YusPlW/ogSkORpMl/rrKSg MWwH820Wli8+Bws2GWVCIu9J3TIXbat9MT4zA56uXcHtDTjbydwMvLbUiwwS3d9BQObxsbKlWZg HPK39i0FvL8/k0aspqt7fWWP/Vk785yeKWpBpCHhZ8tG0j6La3Gkw0xOg/MJJOKr2fpGESETR4H TegjKUdFLcGXYRz7Y+FdcttQJIzCMLEboaZtWIDhS6sY+y/QuS4CLirKmDwMJrqocBzxTGdBvX7 lZxua9M6xTPi4NOiHuYmAYsmbjeZjfb6UWlx7oB0cuup5A5NR4t72KLaL1NiPohxzuPKw6lc0Hj sLommaX27w3LrrklB/jLSq5LRT+AKp8mcZKyMCZde4quCBiliP9Ycujo2s1OUlmSPpYqKfXbAIY iSc2XKQh4kHkMVE6QfV21XI1GN6j1qSculmkEMguJ2VpXyl3kgZC1p56BNHz9REW0uZlImyQvxe kh1wVT8gBNByHaOu3NztWjAWVYlFCse9cX5j02amwwvOA== X-Received: by 2002:a05:600c:6303:b0:493:cfe8:5b36 with SMTP id 5b1f17b1804b1-495158c6a1bmr3362305e9.8.1783963833325; Mon, 13 Jul 2026 10:30:33 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.218.188]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493f3a60404sm260075855e9.1.2026.07.13.10.30.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Jul 2026 10:30:32 -0700 (PDT) From: Doruk Tan Ozturk To: Min Ma , Lizhi Hou , Oded Gabbay Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Doruk Tan Ozturk , stable@vger.kernel.org Subject: [PATCH 1/2] accel/amdxdna: reject user command submission without a command BO Date: Mon, 13 Jul 2026 19:30:28 +0200 Message-ID: <20260713173030.87541-2-doruk@0sec.ai> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260713173030.87541-1-doruk@0sec.ai> References: <20260713173030.87541-1-doruk@0sec.ai> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" amdxdna_drm_submit_execbuf() passes the user-supplied command BO handle straight into amdxdna_cmd_submit() with drv_cmd =3D=3D NULL. When the handle is AMDXDNA_INVALID_BO_HANDLE (0), the block that fetches job->cmd_bo is skipped, leaving it NULL, and no check rejects it on the user path (the !job->cmd_bo guard lives inside the !=3D INVALID branch). The job is then armed and pushed to the DRM scheduler. aie2_sched_job_run() takes the drv_cmd =3D=3D NULL path and calls amdxdna_cmd_set_state(job->cmd_bo) -> amdxdna_gem_vmap(NULL) -> to_gobj(NULL)->dev, a NULL pointer dereference in the drm_sched worker. A process with access to the accel node on a system with a probed AMD NPU can trigger a kernel oops with a single AMDXDNA_EXEC_CMD ioctl (cmd_handles =3D 0). Only internal driver commands (SYNC_DEBUG_BO / ATTACH_DEBUG_BO) legitimately pass AMDXDNA_INVALID_BO_HANDLE, and they always set drv_cmd. Reject the invalid handle for user submissions (drv_cmd =3D=3D NULL) at the submit choke point so every user path is covered. Fixes: aac243092b70 ("accel/amdxdna: Add command execution") Cc: stable@vger.kernel.org Found by 0sec automated security-research tooling (https://0sec.ai). Assisted-by: 0sec:claude-opus-4-8 Signed-off-by: Doruk Tan Ozturk Reviewed-by: Lizhi Hou --- drivers/accel/amdxdna/amdxdna_ctx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/am= dxdna_ctx.c index 8f8df9d04ec5..a5c8c2c4de6d 100644 --- a/drivers/accel/amdxdna/amdxdna_ctx.c +++ b/drivers/accel/amdxdna/amdxdna_ctx.c @@ -603,6 +603,16 @@ int amdxdna_cmd_submit(struct amdxdna_client *client, ret =3D -EINVAL; goto free_job; } + } else if (!drv_cmd) { + /* + * Only internal driver commands (drv_cmd !=3D NULL) may omit a + * command BO. A user command submission with the invalid handle + * would leave job->cmd_bo NULL and later fault when the scheduler + * dereferences it in amdxdna_cmd_set_state(). + */ + XDNA_DBG(xdna, "Command BO handle required for user submission"); + ret =3D -EINVAL; + goto free_job; } =20 ret =3D amdxdna_arg_bos_lookup(client, job, arg_bo_hdls, arg_bo_cnt); --=20 2.43.0 From nobody Sat Jul 25 20:48:45 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 1BC6D349AE6 for ; Mon, 13 Jul 2026 17:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783963848; cv=none; b=Uu9CwRSgv4KO+Uk9UpdCGvZMtjcei9EiHoImWCRuJOjw2KcSLrl3sZlVxafHC3YrgA2vgq94SkL0u82n0bm9O9FOtfaZaayq3JjaZE/HMIvnURl6ExCuM5kOKgZIZigwAcd0Mmxo3plDnROnAyeauvOo5HrGmIRfyqJWrIFUc5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783963848; c=relaxed/simple; bh=1die7bI0OcCIcn1bppUSBazJU6X5SGKun1KXOThfxSQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gta8B6KrtferRPIRng7Np9rv+3cawv13MpEKauLb4seG0Jvmnpg127flbd1rgISfpwtXMDuzyIJAc/3dwBWW8evQww1y7jyvgRUTl8L5bFxMrC6WqReMfNPeuwnLfjX1bzzHIiS/h4Ae3ZcAlWxI8ae0KZiQR2i1OviwQMNQu08= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai; spf=pass smtp.mailfrom=0sec.ai; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b=PXUAqGMG; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0sec.ai Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b="PXUAqGMG" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-493f140ca8eso21420605e9.1 for ; Mon, 13 Jul 2026 10:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1783963835; x=1784568635; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bhFRmtEAl63b5XEQYkBemzUeown6Ez5I0lj5DtalopQ=; b=PXUAqGMGt9VdATqyXceiAh1SejsxG5hJ3b/DFrxKlOMynHIb7j1rxTZudsGZu6laFG kTZRi1Ml3G7gDQXTgrjfd1oN+qZZBew6/oQSx+HuPI9tzzZ8eEtGJthJNn5yyZRbqefK 3nFkELcDsNxCOVAsDf4Er8Lx5trgNdtRM/+ZY419GOnhlbOVunb+itoM4Cwvhk4R2XtM AAhDllS39/XpSku1k44zwf5qnP5+V79OJYzqTokB41U75PcEYq4WYD2q8pVYR92fz5pD a6uTw7Vx+NkqjXk/tKcDqKqXdlL9MK+TJ5+TRcUG8OQipWT5o10Pm5878M0gVh0HttiB A+ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783963835; x=1784568635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bhFRmtEAl63b5XEQYkBemzUeown6Ez5I0lj5DtalopQ=; b=Tgsq1oeFhqweb3dcQ+lmOppBCUCbi7lZoAFtjm7zXae1d7AkUjVPoqoN2IhX/II3m1 4AJRjkEE9omET6kvWrFDVrKeVcubdLBF4S5CZy4roXgmQFKNai88Ez7iNV/ZCXueua0g BmR/n7S2AiLL1pF9ch3HiNMbGIPOezKO/wGxeerBY5MUMqviBXqKnY7t5lfj18W9Prnw 9Xt3gNa2Eg6/2nGBtOZT5ig3Sn49QCQ5ksukfTHRYx4Ih809XI5CfzF30a9Pq6uY7CBx eMhLOsABb+oTFsQgjR1xjZkLhZ1oF7Iv07CF4Qiremc7VA3tPBRs+Px47KpI/ChSKptr r3Xg== X-Forwarded-Encrypted: i=1; AHgh+RpWqUPTA0ZmBaeLqMI2pC92xxv2G76V85fowqyyUq6RcBmcT/KhYjdfMCDVMfw9wE9nuTIQOg4H3jeJc+M=@vger.kernel.org X-Gm-Message-State: AOJu0Yyd8h64KJ1Ij8iKrRlOyD+oNYa/IKZvpflObybqadfNl8h1Zt0i dRgSHJcuHVOJrrIqsfzoNP2788lZ7PAw4KIht5qlNGS4zF/m9JTIEfK2Ume7aVH1deSw8mVO5Yt 3Cik83f0+ X-Gm-Gg: AfdE7ckgtMXVoBTOvDG++0Dgcjmp9LBrxRyFp8PFi3OsKGTx0TUiLa+jRIbrbbc6rcP jOz/ZuvOY+2lZvBB87Xyyemt6dfFV7hvxdl/1swc1bsafbAcgCZHvOGkxOZzltHUqdOJ5bhFwlD hXF+LVHVYxKkr1NvXB4In1K7V6cSpgwJ7s951h8tq/1VcJsZxLbXJw5WlBJU6mrOeYTF7YD/SSA ZFQYhtG+lylG5bK22gc0Q0GD9u/WxV9tDshxLhzE4dqym9cwaQvflMGdEtho9/TFAPxnc9YYPDy RSZTIBfAifflh+7+iLqWW4Dza+02ppwqChFSNm08n+DnnrV/nIyHtUDZVm+cnzATgd+7qa0+fjs wdbzb3QPWm6PV+uBtAH8SwPrQ10X19FglsIaoQ7yni+nyrRZKYneXv0ZmifXqg2w2TlHUgFMMHM BGJKwmd/P4OA5zy2zuHw5i37yDT5HgJCQqM2WtNIcxvU0BsmVGGRyUVr7vkOML3jJDnrz3aHW7l bMnKXw0Ow0TyPR9mWgf26dBal28igz7E0ciASq9WNETeg== X-Received: by 2002:a05:600c:8718:b0:493:c1a1:68f0 with SMTP id 5b1f17b1804b1-493f881f0f1mr96584005e9.20.1783963834676; Mon, 13 Jul 2026 10:30:34 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.218.188]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493f3a60404sm260075855e9.1.2026.07.13.10.30.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Jul 2026 10:30:34 -0700 (PDT) From: Doruk Tan Ozturk To: Min Ma , Lizhi Hou , Oded Gabbay Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Doruk Tan Ozturk , stable@vger.kernel.org Subject: [PATCH 2/2] accel/amdxdna: reject command submission on devices without a submit op Date: Mon, 13 Jul 2026 19:30:29 +0200 Message-ID: <20260713173030.87541-3-doruk@0sec.ai> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260713173030.87541-1-doruk@0sec.ai> References: <20260713173030.87541-1-doruk@0sec.ai> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" amdxdna_cmd_submit() calls xdna->dev_info->ops->cmd_submit() unconditionally, but only aie2_dev_ops defines that callback. aie4_vf_ops (the AIE4 SR-IOV virtual function) does not, so a user AMDXDNA_EXEC_CMD ioctl on an AIE4 device reaches a NULL function-pointer call and oopses the kernel. AIE4 submits work through a mapped user queue and doorbell, not this ioctl path. Reject the submission early with -EOPNOTSUPP when the device provides no cmd_submit op, so the shared EXEC ioctl is a clean no-op on such devices. Fixes: aac243092b70 ("accel/amdxdna: Add command execution") Cc: stable@vger.kernel.org Found by 0sec automated security-research tooling (https://0sec.ai). Assisted-by: 0sec:claude-opus-4-8 Signed-off-by: Doruk Tan Ozturk Reviewed-by: Lizhi Hou --- drivers/accel/amdxdna/amdxdna_ctx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/am= dxdna_ctx.c index a5c8c2c4de6d..bdbd3db12a6c 100644 --- a/drivers/accel/amdxdna/amdxdna_ctx.c +++ b/drivers/accel/amdxdna/amdxdna_ctx.c @@ -590,6 +590,10 @@ int amdxdna_cmd_submit(struct amdxdna_client *client, int ret, idx; =20 XDNA_DBG(xdna, "Command BO hdl %d, Arg BO count %d", cmd_bo_hdl, arg_bo_c= nt); + + if (!xdna->dev_info->ops->cmd_submit) + return -EOPNOTSUPP; + job =3D kzalloc_flex(*job, bos, arg_bo_cnt); if (!job) return -ENOMEM; --=20 2.43.0