From: Yupeng Li <liyupeng@zbhlos.com>
To: tariqt@nvidia.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org, Yupeng Li <liyupeng@zbhlos.com>,
Caicai <caizp2008@163.com>
Subject: [PATCH 1/1] net/mlx4: Fix build error use array_size() helper in copy_to_user()
Date: Sat, 7 Jan 2023 15:27:25 +0800 [thread overview]
Message-ID: <20230107072725.673064-1-liyupeng@zbhlos.com> (raw)
When CONFIG_64BIT was disabled, check_copy_size() was declared with
attribute error: copy source size is too small, array_size() for 32BIT
was wrong size, some compiled msg with error like:
CALL scripts/checksyscalls.sh
CC [M] drivers/net/ethernet/mellanox/mlx4/cq.o
In file included from ./arch/x86/include/asm/preempt.h:7,
from ./include/linux/preempt.h:78,
from ./include/linux/percpu.h:6,
from ./include/linux/context_tracking_state.h:5,
from ./include/linux/hardirq.h:5,
from drivers/net/ethernet/mellanox/mlx4/cq.c:37:
In function ‘check_copy_size’,
inlined from ‘copy_to_user’ at ./include/linux/uaccess.h:168:6,
inlined from ‘mlx4_init_user_cqes’ at drivers/net/ethernet/mellanox/mlx4/cq.c:317:9,
inlined from ‘mlx4_cq_alloc’ at drivers/net/ethernet/mellanox/mlx4/cq.c:394:10:
./include/linux/thread_info.h:228:4: error: call to ‘__bad_copy_from’ declared with attribute error: copy source size is too small
228 | __bad_copy_from();
| ^~~~~~~~~~~~~~~~~
make[6]: *** [scripts/Makefile.build:250:drivers/net/ethernet/mellanox/mlx4/cq.o] 错误 1
make[5]: *** [scripts/Makefile.build:500:drivers/net/ethernet/mellanox/mlx4] 错误 2
make[5]: *** 正在等待未完成的任务....
make[4]: *** [scripts/Makefile.build:500:drivers/net/ethernet/mellanox] 错误 2
make[3]: *** [scripts/Makefile.build:500:drivers/net/ethernet] 错误 2
make[3]: *** 正在等待未完成的任务....
make[2]: *** [scripts/Makefile.build:500:drivers/net] 错误 2
make[2]: *** 正在等待未完成的任务....
make[1]: *** [scripts/Makefile.build:500:drivers] 错误 2
make: *** [Makefile:1992:.] 错误 2
Signed-off-by: Yupeng Li <liyupeng@zbhlos.com>
Reviewed-by: Caicai <caizp2008@163.com>
---
drivers/net/ethernet/mellanox/mlx4/cq.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c
index 4d4f9cf9facb..7dadd7227480 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cq.c
@@ -315,7 +315,11 @@ static int mlx4_init_user_cqes(void *buf, int entries, int cqe_size)
}
} else {
err = copy_to_user((void __user *)buf, init_ents,
+#ifdef CONFIG_64BIT
array_size(entries, cqe_size)) ?
+#else
+ entries * cqe_size) ?
+#endif
-EFAULT : 0;
}
--
2.25.1
next reply other threads:[~2023-01-07 7:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-07 7:27 Yupeng Li [this message]
2023-01-09 13:51 ` Jason Gunthorpe
2023-01-13 18:41 ` Kees Cook
2023-01-13 23:01 ` Kees Cook
[not found] ` <11689498.158e.185b5471bad.Coremail.caizp2008@163.com>
2023-01-18 20:54 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230107072725.673064-1-liyupeng@zbhlos.com \
--to=liyupeng@zbhlos.com \
--cc=caizp2008@163.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®