From nobody Wed Dec 17 19:06:38 2025 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56BB41CA92 for ; Sat, 4 May 2024 11:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823317; cv=none; b=fXRs+2Sp/XmjMl+zhRzehFydUyclKyD0AMkYGniZiUZtIUc1FvGewxPKfrQlr65CEio0uxXBwWNunrj7ewbp38kEZPqT+ezrA2HS47aeFvIxJ5jPSlx5u9X5PvfWAUmOhLzZuai0zD7GhbXVPcBvyilTF/K3nh9yQ5pKQLpDNaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823317; c=relaxed/simple; bh=ay0zDLWkAM5SYW7rwZ+Fv5dRHspwnhKlbbetXkIoI2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pcyrL7APdMIMcGjpC3Hkv1XDFyetX1M0TVe5kjiSSGw1ZLA9lgFmy36nj9WGTEPhV6CZ5LCBNmEFkXI6Dpqq95dtLNrzFa6glTWoO53iNFgKKsUdW/LKGWXxlYz7hFym2kWonEQgkhIBZY+AkoysxK1bqnGf1aEV9tyKrPBtzEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=UM7bt6y7; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="UM7bt6y7" Received: from localhost.localdomain (unknown [5.228.116.47]) by mail.ispras.ru (Postfix) with ESMTPSA id 2F1264078517; Sat, 4 May 2024 11:48:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 2F1264078517 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1714823312; bh=/uIIVEFe8eesxRelQeBiidx05umI8tLYckMVbIe9Bf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UM7bt6y7JQ8GsazyiVpAh4KGpiuvHBD24Oj+UHlqDMdGpPfA0VJh9xyH/a7Ic71Pm mNicUdCmKQryFDFuHgrd2aEQTx3zU58NcVqdsgHqFYVafGrAz5Z1sUi/JqxWhHZEmq pGfySbh+QsCIk295vp5i3Q46f1r1gaLgWy/pPvCI= From: Fedor Pchelkin To: Xiang Chen , Barry Song <21cnbao@gmail.com> Cc: Fedor Pchelkin , Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH v2 1/4] dma-mapping: benchmark: fix up kthread-related error handling Date: Sat, 4 May 2024 14:47:01 +0300 Message-ID: <20240504114713.567164-2-pchelkin@ispras.ru> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240504114713.567164-1-pchelkin@ispras.ru> References: <20240504114713.567164-1-pchelkin@ispras.ru> 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" kthread creation failure is invalidly handled inside do_map_benchmark(). The put_task_struct() calls on the error path are supposed to balance the get_task_struct() calls which only happen after all the kthreads are successfully created. Rollback using kthread_stop() for already created kthreads in case of such failure. In normal situation call kthread_stop_put() to gracefully stop kthreads and put their task refcounts. This should be done for all started kthreads. Found by Linux Verification Center (linuxtesting.org). Fixes: 65789daa8087 ("dma-mapping: add benchmark support for streaming DMA = APIs") Suggested-by: Robin Murphy Signed-off-by: Fedor Pchelkin Reviewed-by: Robin Murphy --- kernel/dma/map_benchmark.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c index 02205ab53b7e..2478957cf9f8 100644 --- a/kernel/dma/map_benchmark.c +++ b/kernel/dma/map_benchmark.c @@ -118,6 +118,8 @@ static int do_map_benchmark(struct map_benchmark_data *= map) if (IS_ERR(tsk[i])) { pr_err("create dma_map thread failed\n"); ret =3D PTR_ERR(tsk[i]); + while (--i >=3D 0) + kthread_stop(tsk[i]); goto out; } =20 @@ -139,13 +141,17 @@ static int do_map_benchmark(struct map_benchmark_data= *map) =20 msleep_interruptible(map->bparam.seconds * 1000); =20 - /* wait for the completion of benchmark threads */ + /* wait for the completion of all started benchmark threads */ for (i =3D 0; i < threads; i++) { - ret =3D kthread_stop(tsk[i]); - if (ret) - goto out; + int kthread_ret =3D kthread_stop_put(tsk[i]); + + if (kthread_ret) + ret =3D kthread_ret; } =20 + if (ret) + goto out; + loops =3D atomic64_read(&map->loops); if (likely(loops > 0)) { u64 map_variance, unmap_variance; @@ -170,8 +176,6 @@ static int do_map_benchmark(struct map_benchmark_data *= map) } =20 out: - for (i =3D 0; i < threads; i++) - put_task_struct(tsk[i]); put_device(map->dev); kfree(tsk); return ret; --=20 2.45.0 From nobody Wed Dec 17 19:06:38 2025 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69F1E1CFB2 for ; Sat, 4 May 2024 11:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823317; cv=none; b=Yn1zzacRb9Zx9NVD2ce9j9zexU9rR3hKiwDTn4opsaENHY7CFE7STn+Z5XADilLUR/zhDXyQLiqN6Ygu/fS5akZin00z/Mnen8DmDoz2YLsjMTEqQ8hE543ujTXVieAg9fjrVdZLyhOiSvpncKTC7KO0UbADspF2C0jjLDRemsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823317; c=relaxed/simple; bh=fPq6/+9ia0iO90JlhZ9KJBgh1cJ1I7wEf7WY1evowZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LtUDHnPServM2kNjW+JIZhPi+4A8RxEI4xjYDVZkkT0HS3WDKe4RDl+eJjgwBpDxuFvyZK7OBN+/SGemmDhvvL0x7zuRMgdgljLKWBskNZ9SqkNPefPy2rPPVQJgGaSHD8I7laJda+I3UmCEAeGvuDDXxS0zERG9T2JYgEEpLx8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=co6PozTW; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="co6PozTW" Received: from localhost.localdomain (unknown [5.228.116.47]) by mail.ispras.ru (Postfix) with ESMTPSA id 4DEDD4078539; Sat, 4 May 2024 11:48:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 4DEDD4078539 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1714823313; bh=epd4DMs36vx3k89bFNW7QgexA26iuS1BkPzE4xfNr8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=co6PozTWA52C1QDPaPlf+PV9N3EXqFu/i0LWcterYxQNvZ+z2BfRD15EyEjdUnJ3h 6WRCRybwnA4deRTtqSf2khGiquIf8PkKhl0u7iHuL4pRpF/H/8hz4IKXwjFLuCQgYW 2PY7720RgojzvAPUlSnGNY5diHmcIYGxknlBEDYg= From: Fedor Pchelkin To: Xiang Chen , Barry Song <21cnbao@gmail.com> Cc: Fedor Pchelkin , Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH v2 2/4] dma-mapping: benchmark: avoid needless copy_to_user if benchmark fails Date: Sat, 4 May 2024 14:47:02 +0300 Message-ID: <20240504114713.567164-3-pchelkin@ispras.ru> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240504114713.567164-1-pchelkin@ispras.ru> References: <20240504114713.567164-1-pchelkin@ispras.ru> 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" If do_map_benchmark() has failed, there is nothing useful to copy back to userspace. Suggested-by: Barry Song <21cnbao@gmail.com> Signed-off-by: Fedor Pchelkin Acked-by: Robin Murphy --- kernel/dma/map_benchmark.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c index 2478957cf9f8..a6edb1ef98c8 100644 --- a/kernel/dma/map_benchmark.c +++ b/kernel/dma/map_benchmark.c @@ -256,6 +256,9 @@ static long map_benchmark_ioctl(struct file *file, unsi= gned int cmd, * dma_mask changed by benchmark */ dma_set_mask(map->dev, old_dma_mask); + + if (ret) + return ret; break; default: return -EINVAL; --=20 2.45.0 From nobody Wed Dec 17 19:06:38 2025 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 532141CF8D for ; Sat, 4 May 2024 11:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823318; cv=none; b=Z4277TSv9xWv+G8jS4tmTTJ4iAj3oiXot3O/sqtU2XXQlI54CotPQfRozc4E3mAy9ZGOswmBdRcuqb78YlXEvK1SP4vepePfsEswvQ7H8p7ndptB9YMtJp/pO2xdNXfwmGPJd5W42finyB/+LVcvO0AdE6qczbXRLFhKozsiACk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823318; c=relaxed/simple; bh=xsMnbetbaA6N60UIuK1PGPqnCkrYW2OZDNDQUCQJiik=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jRUB24my/VWexNjFu8mIC+z0pIxAAGXWRx2bpWzdsidEz9k7ot9k0y3rq7Ehh6eVWkLxsaN5m1jsvjKDvKDV8OCSkOZevvsqzOWr5pviDqcftrEExeHY4qK70yA6sGHzuBf9diIAklw3JWEdhUjwDsxdk6WLdmpELOaGXUHpVpg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=tTrZp7Rb; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="tTrZp7Rb" Received: from localhost.localdomain (unknown [5.228.116.47]) by mail.ispras.ru (Postfix) with ESMTPSA id 53815407853E; Sat, 4 May 2024 11:48:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 53815407853E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1714823314; bh=AyOAQh51mv55YIgMY/k1FQiKpIRNr3blalne69QuC+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tTrZp7Rb+mTbpIepijeU70Eo/z8/+WeC7DfFuuUhfvWBS5L2BlrxGl10TRnqPE+Bj DWop4vm/hZDxSpGRlHXU+B6pdHZVsC/wv//Jtc4kCdGObOX5S5iyGAzRritoOmMJT7 IQDJvTWNppJd+7Wf65Tn4JANdrIyn8XdfNSQR4x0= From: Fedor Pchelkin To: Xiang Chen , Barry Song <21cnbao@gmail.com> Cc: Fedor Pchelkin , Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH v2 3/4] dma-mapping: benchmark: fix node id validation Date: Sat, 4 May 2024 14:47:03 +0300 Message-ID: <20240504114713.567164-4-pchelkin@ispras.ru> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240504114713.567164-1-pchelkin@ispras.ru> References: <20240504114713.567164-1-pchelkin@ispras.ru> 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" While validating node ids in map_benchmark_ioctl(), node_possible() may be provided with invalid argument outside of [0,MAX_NUMNODES-1] range leading to: BUG: KASAN: wild-memory-access in map_benchmark_ioctl (kernel/dma/map_bench= mark.c:214) Read of size 8 at addr 1fffffff8ccb6398 by task dma_map_benchma/971 CPU: 7 PID: 971 Comm: dma_map_benchma Not tainted 6.9.0-rc6 #37 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) Call Trace: dump_stack_lvl (lib/dump_stack.c:117) kasan_report (mm/kasan/report.c:603) kasan_check_range (mm/kasan/generic.c:189) variable_test_bit (arch/x86/include/asm/bitops.h:227) [inline] arch_test_bit (arch/x86/include/asm/bitops.h:239) [inline] _test_bit at (include/asm-generic/bitops/instrumented-non-atomic.h:142) [in= line] node_state (include/linux/nodemask.h:423) [inline] map_benchmark_ioctl (kernel/dma/map_benchmark.c:214) full_proxy_unlocked_ioctl (fs/debugfs/file.c:333) __x64_sys_ioctl (fs/ioctl.c:890) do_syscall_64 (arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) Compare node ids with sane bounds first. NUMA_NO_NODE is considered a special valid case meaning that benchmarking kthreads won't be bound to a cpuset of a given node. Found by Linux Verification Center (linuxtesting.org). Fixes: 65789daa8087 ("dma-mapping: add benchmark support for streaming DMA = APIs") Signed-off-by: Fedor Pchelkin Reviewed-by: Robin Murphy --- kernel/dma/map_benchmark.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c index a6edb1ef98c8..9f6c15f3f168 100644 --- a/kernel/dma/map_benchmark.c +++ b/kernel/dma/map_benchmark.c @@ -212,7 +212,8 @@ static long map_benchmark_ioctl(struct file *file, unsi= gned int cmd, } =20 if (map->bparam.node !=3D NUMA_NO_NODE && - !node_possible(map->bparam.node)) { + (map->bparam.node < 0 || map->bparam.node >=3D MAX_NUMNODES || + !node_possible(map->bparam.node))) { pr_err("invalid numa node\n"); return -EINVAL; } --=20 2.45.0 From nobody Wed Dec 17 19:06:38 2025 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD4DD210EC for ; Sat, 4 May 2024 11:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823320; cv=none; b=sZPmjQ75oPLBGZ0UEkHmHdCIrXHcfi3R3dIM9ISAKlT40FGwGkOXGd+Zky+6L4x5VxMjy6Op/e7hhus9iOoU2zp4ImrU7fJY71KvIC+GomKsv1isORzzlIGaDo9E8sws9sCYZ9DIublIKkeOhe52GUXTQVppBC3AmiNbaU5WexU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823320; c=relaxed/simple; bh=cDHnzaVmZj1P/Yo5aKbOtea9ZLJDWirFLzj/JIj75tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RjjkeKDeUwHwoOoLt472jJdWc2z48gm8T7PNp21u3ofBH2Q/vg60WUngDOVm7zUkTvsZMdFtnKR+rGE32rimngwI4tpBzDs9oYQQm8aOElDRaczeTutVufo2d4/E6dKjZ2EtvNC6UALHdkpF23jgWnPgLu47HLSz+nX2EAZPqK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=XdSKjOKx; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="XdSKjOKx" Received: from localhost.localdomain (unknown [5.228.116.47]) by mail.ispras.ru (Postfix) with ESMTPSA id BD9D240737B5; Sat, 4 May 2024 11:48:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru BD9D240737B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1714823315; bh=RxA857iBR0FODbLGi/CqJrg5YTNv0+6aonrAsG0UTyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XdSKjOKxtwI6PpBHM1CliTSnQeqoNF+HV7nzw/rD2j9XZKWwXMgw7DqxB8bUBtX1j T/AZ4xXOs/hptpzKwgFNUWR3DYP2Vm6DuW8jYV6iqNXXB5/XlXWCNY2g8SQp47/iBh Aqq0eljU1+MkOGPnuGzHWGspTCCyVAS0Rv+voFOg= From: Fedor Pchelkin To: Xiang Chen , Barry Song <21cnbao@gmail.com> Cc: Fedor Pchelkin , Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH v2 4/4] dma-mapping: benchmark: handle NUMA_NO_NODE correctly Date: Sat, 4 May 2024 14:47:04 +0300 Message-ID: <20240504114713.567164-5-pchelkin@ispras.ru> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240504114713.567164-1-pchelkin@ispras.ru> References: <20240504114713.567164-1-pchelkin@ispras.ru> 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" cpumask_of_node() can be called for NUMA_NO_NODE inside do_map_benchmark() resulting in the following sanitizer report: UBSAN: array-index-out-of-bounds in ./arch/x86/include/asm/topology.h:72:28 index -1 is out of range for type 'cpumask [64][1]' CPU: 1 PID: 990 Comm: dma_map_benchma Not tainted 6.9.0-rc6 #29 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) Call Trace: dump_stack_lvl (lib/dump_stack.c:117) ubsan_epilogue (lib/ubsan.c:232) __ubsan_handle_out_of_bounds (lib/ubsan.c:429) cpumask_of_node (arch/x86/include/asm/topology.h:72) [inline] do_map_benchmark (kernel/dma/map_benchmark.c:104) map_benchmark_ioctl (kernel/dma/map_benchmark.c:246) full_proxy_unlocked_ioctl (fs/debugfs/file.c:333) __x64_sys_ioctl (fs/ioctl.c:890) do_syscall_64 (arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) Use cpumask_of_node() in place when binding a kernel thread to a cpuset of a particular node. Note that the provided node id is checked inside map_benchmark_ioctl(). It's just a NUMA_NO_NODE case which is not handled properly later. Found by Linux Verification Center (linuxtesting.org). Fixes: 65789daa8087 ("dma-mapping: add benchmark support for streaming DMA = APIs") Signed-off-by: Fedor Pchelkin Acked-by: Barry Song --- kernel/dma/map_benchmark.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c index 9f6c15f3f168..4950e0b622b1 100644 --- a/kernel/dma/map_benchmark.c +++ b/kernel/dma/map_benchmark.c @@ -101,7 +101,6 @@ static int do_map_benchmark(struct map_benchmark_data *= map) struct task_struct **tsk; int threads =3D map->bparam.threads; int node =3D map->bparam.node; - const cpumask_t *cpu_mask =3D cpumask_of_node(node); u64 loops; int ret =3D 0; int i; @@ -124,7 +123,7 @@ static int do_map_benchmark(struct map_benchmark_data *= map) } =20 if (node !=3D NUMA_NO_NODE) - kthread_bind_mask(tsk[i], cpu_mask); + kthread_bind_mask(tsk[i], cpumask_of_node(node)); } =20 /* clear the old value in the previous benchmark */ --=20 2.45.0