Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2255275iof; Wed, 8 Jun 2022 00:36:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWhEl9yXncF1V5fX4ebXRcaQNxhe9nJXUOwAscPKTfWdJrAUY9DYEo4NKNJf6g00B+58kk X-Received: by 2002:aa7:8008:0:b0:51a:cae3:7563 with SMTP id j8-20020aa78008000000b0051acae37563mr56548143pfi.16.1654673780821; Wed, 08 Jun 2022 00:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654673780; cv=none; d=google.com; s=arc-20160816; b=RiU2b04+eZBJEvHW8xA9CtEjYyo3jGgAp8QdpJW12i1Tko+DZNCV+U/falA1UKbmY0 W4UcmIKajYeMmteBOEZeXECknDr7h2gFXy7eHn7Oth33Z6+jgLnd2V9CCiqfp4DR1HBL pSjCj0/Kih58SpcOIkeQjvBBiIImu2ifmV4jM7lAwkFX7H80bigN9wSDHqVcV6Z2x4sj YrXurWxGK3G+RT7yrgSvTx8SLNAfcuBC2U9reWQaj18H5bLz+Bh9O3m1eBTsk7i3UKqr QvxqTAmS1a5qsmOO1b6W+0mGUoc9ybJ/jarrq+upTr0fQTkYWEAza0qw8KG3KHbaQqpl qOpw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e7H1PKwMJXY3779XC8Gf2LhowJV0m0NB0iAMB7NLB8A=; b=C6d4k0wWuwQolT91rzZmegEasvQNGlORXlxZdSILQZjgQaSoLV3GB6gebRGuD2KoP3 IeyL3PiphHobxoF9qbIIShBwCix2K4IsYh8BvyXxI+CQw432oad+HyvjO8ZWZEmBkjiS iA5QPV+R440YuSFKsba4342mo+J6eGKPV/Dm4Uh9lE2Mc29I5nZ3q3cXLEQMfCjtnjrg /MvgA0oxbZcoVD5BfHRuJiicyAaYMiJ0KTI+AQXutaB2UAvtXM24ozV6P4VmBZQDLwP8 KN/tMVj0jJJ36f2fpowGAukuz9Qa8t/lf1LVoSQVnHMm8sUFK37MMnunhILCi9v8Lk4z xuwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cfj3+e1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f12-20020a63510c000000b003c67a4e3e22si25915848pgb.138.2022.06.08.00.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:36:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cfj3+e1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6EB0523D571; Wed, 8 Jun 2022 00:07:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381741AbiFGVly (ORCPT + 99 others); Tue, 7 Jun 2022 17:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378294AbiFGUvh (ORCPT ); Tue, 7 Jun 2022 16:51:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93B771FE8F0; Tue, 7 Jun 2022 11:42:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D451AB82239; Tue, 7 Jun 2022 18:41:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27F11C385A5; Tue, 7 Jun 2022 18:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627317; bh=WFWag3G3r7NILMBL5Q25K81ZLI+l1okE9PH2R2dGTgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfj3+e1fNNKJB5c2fEP1gAOtSOHBLRz2u7MJinJgNPVTWn7OF0VHSQ+p6RpwemU0v g9oItqrio1IAoQMhBqADswxZbJqL+YzbNdP5WRPKciApVh/hNANhIG4Ec9G+TFeDU4 d0jYeCeJNvSC6G2yOCpe7OsIrbGkXcZ43cqZGW/s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Airlie , Alex Deucher Subject: [PATCH 5.17 689/772] drm/amdgpu/cs: make commands with 0 chunks illegal behaviour. Date: Tue, 7 Jun 2022 19:04:41 +0200 Message-Id: <20220607165009.357253473@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Airlie commit 31ab27b14daaa75541a415c6794d6f3567fea44a upstream. Submitting a cs with 0 chunks, causes an oops later, found trying to execute the wrong userspace driver. MESA_LOADER_DRIVER_OVERRIDE=v3d glxinfo [172536.665184] BUG: kernel NULL pointer dereference, address: 00000000000001d8 [172536.665188] #PF: supervisor read access in kernel mode [172536.665189] #PF: error_code(0x0000) - not-present page [172536.665191] PGD 6712a0067 P4D 6712a0067 PUD 5af9ff067 PMD 0 [172536.665195] Oops: 0000 [#1] SMP NOPTI [172536.665197] CPU: 7 PID: 2769838 Comm: glxinfo Tainted: P O 5.10.81 #1-NixOS [172536.665199] Hardware name: To be filled by O.E.M. To be filled by O.E.M./CROSSHAIR V FORMULA-Z, BIOS 2201 03/23/2015 [172536.665272] RIP: 0010:amdgpu_cs_ioctl+0x96/0x1ce0 [amdgpu] [172536.665274] Code: 75 18 00 00 4c 8b b2 88 00 00 00 8b 46 08 48 89 54 24 68 49 89 f7 4c 89 5c 24 60 31 d2 4c 89 74 24 30 85 c0 0f 85 c0 01 00 00 <48> 83 ba d8 01 00 00 00 48 8b b4 24 90 00 00 00 74 16 48 8b 46 10 [172536.665276] RSP: 0018:ffffb47c0e81bbe0 EFLAGS: 00010246 [172536.665277] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [172536.665278] RDX: 0000000000000000 RSI: ffffb47c0e81be28 RDI: ffffb47c0e81bd68 [172536.665279] RBP: ffff936524080010 R08: 0000000000000000 R09: ffffb47c0e81be38 [172536.665281] R10: ffff936524080010 R11: ffff936524080000 R12: ffffb47c0e81bc40 [172536.665282] R13: ffffb47c0e81be28 R14: ffff9367bc410000 R15: ffffb47c0e81be28 [172536.665283] FS: 00007fe35e05d740(0000) GS:ffff936c1edc0000(0000) knlGS:0000000000000000 [172536.665284] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [172536.665286] CR2: 00000000000001d8 CR3: 0000000532e46000 CR4: 00000000000406e0 [172536.665287] Call Trace: [172536.665322] ? amdgpu_cs_find_mapping+0x110/0x110 [amdgpu] [172536.665332] drm_ioctl_kernel+0xaa/0xf0 [drm] [172536.665338] drm_ioctl+0x201/0x3b0 [drm] [172536.665369] ? amdgpu_cs_find_mapping+0x110/0x110 [amdgpu] [172536.665372] ? selinux_file_ioctl+0x135/0x230 [172536.665399] amdgpu_drm_ioctl+0x49/0x80 [amdgpu] [172536.665403] __x64_sys_ioctl+0x83/0xb0 [172536.665406] do_syscall_64+0x33/0x40 [172536.665409] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2018 Signed-off-by: Dave Airlie Cc: stable@vger.kernel.org Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -115,7 +115,7 @@ static int amdgpu_cs_parser_init(struct int ret; if (cs->in.num_chunks == 0) - return 0; + return -EINVAL; chunk_array = kvmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL); if (!chunk_array)