Message ID | 20230107072725.673064-1-liyupeng@zbhlos.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1200568wrt; Fri, 6 Jan 2023 23:49:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXtFWSadd7Nr5J1E0YByUGqPylboTxDnI8iV8hkotF5t/COu3WLItMnNDF6bMbQLO9rQJ+8w X-Received: by 2002:a17:902:aa96:b0:18e:8223:6447 with SMTP id d22-20020a170902aa9600b0018e82236447mr56916367plr.22.1673077753170; Fri, 06 Jan 2023 23:49:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673077753; cv=none; d=google.com; s=arc-20160816; b=Dc9htOS0BF9ft3VnNweiJlVVLUEtLN+z4cav+d0/8OcyCpWRtzkzBqUA085buPuFi9 /X+mQU3klv6sPUUw2pJxxpFP3N8h+6VnQ6w/B7iJQP7PEy+MvLicJyjsPCppaZSVGWdQ j02tC7AD/GMkIRV+no18pPz++PtIKP9Ztl7g0rdM9pGbEUcuHdASbaGbT6GrFUmvRshv xeMP7hD3xxdLMaibaK78QPtHJSbkL6iD9nhhKr3iCuquT+CMtmaSaJ2QbdQOD89wR+p1 YisJXE3bWrPvQkKnohX+XwwoG6qD39XmYEq20qZfINJzivNYngd59xqGGh2Y/E+ZFATE 4ceQ== 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 :message-id:date:subject:cc:to:from; bh=IeitfpB/2iVJ+MwwNVwzVhr6C83cpBcQonQR4rIbDbc=; b=oiSCnJ/jWFJR6BgyWy3SI+zEDwnNxOrjygKyi99uyW9v8mqxBb9iDXs5ZDMmizUqmg 269LMtnzpju04/Un+sUn0qbWW5I/iXsN/g0DvAXzADFEvCHOP0Fb+JZBcIqw1BEWupQe mhmtCHiomyGjVl346D71xEXkZiZvSQIhgBJJO8lZr6OOyHHcr9gnRf/JLIWyED6Vozo1 rsdQp/jtJt3gDGoH7vYKPwxSf6tpRxbdpuhZjxggvzO831OCiIj/JLPjvgbRSdIct/5F XVhGqG/VpmjZ/DmWisGp8Elu1xa7DoVE1EZcxdEotwpsFkni+pAgWLKPaUtiQsuGDLjx HORw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zbhlos.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p23-20020a170902a41700b001890c6feffasi3024550plq.568.2023.01.06.23.48.59; Fri, 06 Jan 2023 23:49:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zbhlos.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230439AbjAGHew (ORCPT <rfc822;dolce.eric@gmail.com> + 99 others); Sat, 7 Jan 2023 02:34:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjAGHet (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 7 Jan 2023 02:34:49 -0500 X-Greylist: delayed 415 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 06 Jan 2023 23:34:46 PST Received: from mail-m11880.qiye.163.com (mail-m11880.qiye.163.com [115.236.118.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AE47CBE5; Fri, 6 Jan 2023 23:34:46 -0800 (PST) Received: from caicai-HWPC.. (unknown [IPV6:240e:36a:145d:dd00:75ba:b6bd:3f9b:b978]) by mail-m11880.qiye.163.com (Hmail) with ESMTPA id E560C2020C; Sat, 7 Jan 2023 15:27:44 +0800 (CST) 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 Message-Id: <20230107072725.673064-1-liyupeng@zbhlos.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCSkoYVhpCH09MTksYGU9CTVUTARMWGhIXJBQOD1 lXWRgSC1lBWUlPSx5BSE0aQUpPTh9BHx9LS0FMThkaQRlNGR9BSB1CGUEZQkxDWVdZFhoPEhUdFF lBWU9LSFVKSktPSEhVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PS46TCo*Gj0aHRY4FB8VLz1O OjMaFDhVSlVKTUxIS0xNT01OTkpJVTMWGhIXVRcSAg4LHhUcOwEZExcUCFUYFBZFWVdZEgtZQVlJ T0seQUhNGkFKT04fQR8fS0tBTE4ZGkEZTRkfQUgdQhlBGUJMQ1lXWQgBWUFITUtKNwY+ X-HM-Tid: 0a858b20dde52eb6kusne560c2020c X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754349177837436786?= X-GMAIL-MSGID: =?utf-8?q?1754349177837436786?= |
Series |
[1/1] net/mlx4: Fix build error use array_size() helper in copy_to_user()
|
|
Commit Message
Yupeng Li
Jan. 7, 2023, 7:27 a.m. UTC
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(+)
Comments
On Sat, Jan 07, 2023 at 03:27:25PM +0800, Yupeng Li wrote: > 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; This can't possibly make sense, Kees? Jason
On Mon, Jan 09, 2023 at 09:51:18AM -0400, Jason Gunthorpe wrote: > On Sat, Jan 07, 2023 at 03:27:25PM +0800, Yupeng Li wrote: > > 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; > > This can't possibly make sense, Kees? Uuuuh, that's really weird. What compiler version and arch? I'll see if I can reproduce this.
On Fri, Jan 13, 2023 at 10:41:01AM -0800, Kees Cook wrote: > On Mon, Jan 09, 2023 at 09:51:18AM -0400, Jason Gunthorpe wrote: > > On Sat, Jan 07, 2023 at 03:27:25PM +0800, Yupeng Li wrote: > > > 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; > > > > This can't possibly make sense, Kees? > > Uuuuh, that's really weird. What compiler version and arch? I'll see if > I can reproduce this. I can't reproduce this. I'm assuming this is being seen on a 32-bit loongarch build? I have no idea how to get that compiler. Neither Debian nor Fedora seem to package it. (It looks like it was added in GCC 12?) Perhaps it's just "mips"? But I also can't figure out how to choose a 32-bit mips build. Wheee. Anyway, I would assume this is a compiler bug around inlining or the check_mul_overflow implementation? static inline size_t __must_check size_mul(size_t factor1, size_t factor2) { size_t bytes; if (check_mul_overflow(factor1, factor2, &bytes)) return SIZE_MAX; return bytes; } #define array_size(a, b) size_mul(a, b) -Kees
On Sun, Jan 15, 2023 at 07:53:34PM +0800, caizp2008 wrote:
> my kernel config is config-mlx4-error.
Where can I find this config?
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; }