Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1360483rwb; Fri, 13 Jan 2023 11:08:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWkDiwhWYtEQ32FX5+bET8njGNlj7tWnjavSDgk7kq9LjXB1eBthUzOMaOX/z9cOin8iO/ X-Received: by 2002:a05:6402:548b:b0:49c:869e:6134 with SMTP id fg11-20020a056402548b00b0049c869e6134mr2563200edb.8.1673636883997; Fri, 13 Jan 2023 11:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673636883; cv=none; d=google.com; s=arc-20160816; b=kipaUlGcfQRKCN2Pt0QdMPuemC+lFSDmA4iz9C8KpzFSgDfx2ZQv+v0uxoUF8f1c6J aFUXMqRkl+D+3PBCEyvmCokofYbhoGEdPZGvhEWzDNW1o1+iwLe15YMEkXs80GfKD7QN umF1eY9SZTISEZ/x4b5ctF3i8ZoW6z9LLSaeOlz/ZGIDhDiKzD04BLsPAOcfYGkSFrEh cQ8Kyj+73tBSXAkllkEUVYnXpyNgTdwJ10zXdpyGQ5dNw9Lu3BhVagQXJTy6P5aHEeBU Ujyb1YuVa0r9eyRw2NyuR8EPyo693+8yD1LJJan6tgbqvpvrIZlJOTg41HWwR3SdhHRx 6dMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=c0+Sdo0KEI7o1bohHc1jHwiM206A+991wKrqsl42gBA=; b=Skt7QY1op5aMLrEtIvMqt+UVHfb5KDp9SyO/lHigbnmvUnc3w42AK1FU1NaaRhfTaN nkrQ1ihJTZGqHr7h1deMS6jZlGZMkodbj8qXDxnchtWe8MiOrxr8boLEnd4Qr9CrjEzO +hHW8m2IqZNpXT36TtLDrIWp1Ra7OHLlELgZaDdDdI41j8FRE4oSm4wcmso8GRopLhz/ Y+Op0lxdOERHeEhtvs0BnB3F9/llBV6BkYSu3v6rfTzC7cKMHzvZMhOwKiI75m+QEvO0 kys3V+wjwFFZtuWFIXcyMJtVjH2SiXYmdQm4biPbkjbjBDBHABq7jXnKyrSmcRYlWLku XnJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PBjE6fpa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb7-20020a0564020d0700b0048793b0993asi13180759edb.390.2023.01.13.11.07.51; Fri, 13 Jan 2023 11:08:03 -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; dkim=pass header.i=@chromium.org header.s=google header.b=PBjE6fpa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbjAMSlO (ORCPT + 52 others); Fri, 13 Jan 2023 13:41:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjAMSlK (ORCPT ); Fri, 13 Jan 2023 13:41:10 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F3961ADBC for ; Fri, 13 Jan 2023 10:41:03 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id dw9so21836310pjb.5 for ; Fri, 13 Jan 2023 10:41:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=c0+Sdo0KEI7o1bohHc1jHwiM206A+991wKrqsl42gBA=; b=PBjE6fpa3XZ0R5lmeJaHS88HKwQd9U/loRunVFiGhmLwRqhpknZ9+P6RbsMgk3PDL1 PgLj8+ehJmtj4zrs/d19QRniRQHhylp9ECRge3nOAok3HgG/eSF5Ym1Nqq+DUSeyVh9J GXuA9hPbl/TGZTbC4iwiqwta7/olfZdvm9dJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c0+Sdo0KEI7o1bohHc1jHwiM206A+991wKrqsl42gBA=; b=Gil4vlJ/UJoe3kcjn+iqrGBPs5A2nCcmp2Jfi9y5Qd0vqYd3f97DYck1SbZYPgXI/A PGivjM/0K7pCu0jvHGKenz6AwbyEmEAVpi7d6MArb+q2rK86maHlBgk4Wdvm40CY2ziR NY9bAc+moV2VSn4res9Ou4TJqoPc92c7Jyavwv7mSKfX2YLGGtJAiXoHUTAHx9Y1RCiu LYGGvaSQAEVzRXS5H9xt+wEZHkBXUEvMSolrmyqzY4H/wYAZO6GT7gRrkeMivwgCzeke J5kGGmHtpxAFhzZdJvhpoIE4dNCdalAJJegl/T6AtkDU6+lcMoAD6C52yWKrS+xF0aEw xrtQ== X-Gm-Message-State: AFqh2kqEWb90FXPKZtifDvgLc4nwyRf9bXz2uMcSlklOgmevMoIBfzBh cxL2VW/K1cjfoieZ4WWAxtYKSA== X-Received: by 2002:a17:90a:7e14:b0:219:eeb9:943f with SMTP id i20-20020a17090a7e1400b00219eeb9943fmr82718118pjl.49.1673635262948; Fri, 13 Jan 2023 10:41:02 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w1-20020a17090a1b8100b0022721df27e9sm1724684pjc.11.2023.01.13.10.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 10:41:02 -0800 (PST) Date: Fri, 13 Jan 2023 10:41:01 -0800 From: Kees Cook To: Jason Gunthorpe Cc: Yupeng Li , tariqt@nvidia.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Caicai Subject: Re: [PATCH 1/1] net/mlx4: Fix build error use array_size() helper in copy_to_user() Message-ID: <202301131039.7354AD35CF@keescook> References: <20230107072725.673064-1-liyupeng@zbhlos.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 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 > > Reviewed-by: Caicai > > --- > > 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. -- Kees Cook