Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2691rdh; Fri, 22 Sep 2023 22:18:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFx1nie05K+hqpDUakZLWT6u9ja8FyUxwkUT7UgvvAdS29xJlmCzSO7AI5jbii9MxcS8+bA X-Received: by 2002:a05:6a20:244a:b0:14c:f16a:2b78 with SMTP id t10-20020a056a20244a00b0014cf16a2b78mr1750879pzc.45.1695446291560; Fri, 22 Sep 2023 22:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695446291; cv=none; d=google.com; s=arc-20160816; b=tVnM28YOWitwhQ4NiGXCUn3fIU9WtGlv0pzELEq/Jhm+EC/eMdvTmvlk4Gg8TyAELo tXfxqyqlBt11qgKkBwbOkPd21npBT4tFc0xfUh8Ckeu2iSZPnQkLIAcjXPdleabYsy6u bZwKrlgPSpWFv5vmFgN540lkYSWvxtRaR0XokMegJb3OZEkO5Bfzqy5lZAwBV4M7fOuC crWmVa8ZGRNTjLwKWqOk6pMDw9x2XzdJXDWDsaaVL/AfKMa3F7R8IC5LuF93n9K3w3dI iC14Kp57jZ23eKBii1MyBEwkYEURFECQ/diyNASQvXQMoN5Mlsn4fA3Pxpxnghi5IPUY sVYA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Yr/T9kX37mjruI2YODshHpmgcsopLzBXqNS+RBfjBUE=; fh=U+GFGd3GBVicrDckRrRBgwNRqCKWz+gDBpp1HVYp59I=; b=TrA/b38lCbpIZ/MlCiNnFZXsC9DpWq8ckZTom2Jxc1gjWUFPZZhXTqPHKRfdYWoOpB lpEPKIKX7ogsmfvpxAcfE624CUI2VErIOFGlVt+5quOkzQaYB+bqzsS2Wf1HjP1/tUIR W5yINvZ99k6lMUv/Qqo8TlwZyUi+KvPB2N3gWnT6xJdPC7V2FUE82getamBm5vjuOY4i bHaj493+h7S4k4IwyZzXk/5OI68xLYLIoHlGIrM6FfiFA/FGzaOCtIDEOcPzQjEmsCck t/0uJPMPnW9D4qaXZZxUZ2B1BrYpxloDo5fMK0CuqRLBZvJjtDDZ4DKilrfxinM8XGpE syWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20230601.gappssmtp.com header.s=20230601 header.b=oH0bnqHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=networkplumber.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id pg1-20020a17090b1e0100b00271a9dda68csi4469048pjb.131.2023.09.22.22.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 22:18:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@networkplumber-org.20230601.gappssmtp.com header.s=20230601 header.b=oH0bnqHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=networkplumber.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0915182D7649; Thu, 21 Sep 2023 11:16:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjIUSQM (ORCPT + 99 others); Thu, 21 Sep 2023 14:16:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjIUSP2 (ORCPT ); Thu, 21 Sep 2023 14:15:28 -0400 Received: from mail-vk1-xa30.google.com (mail-vk1-xa30.google.com [IPv6:2607:f8b0:4864:20::a30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACD2E08A for ; Thu, 21 Sep 2023 10:49:05 -0700 (PDT) Received: by mail-vk1-xa30.google.com with SMTP id 71dfb90a1353d-493545b4eaeso516830e0c.0 for ; Thu, 21 Sep 2023 10:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1695318544; x=1695923344; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Yr/T9kX37mjruI2YODshHpmgcsopLzBXqNS+RBfjBUE=; b=oH0bnqHw0clAFiDJdW/EOS96QC+LBG1gi+rzGK/Z3Ek20naaXRsRLYXZ9Ji4YUDnmq 8s5NV3n16B4KgKOLMoFKT4AZRZ5rdqPf6lqwE4zpWlkBZ6L5sZ5btzqT1eQPMqSkx86f iHoeTJW2g0GPvuMcM4rXc7CgYo4cy/tB6SA7ozEF8TNPk5HMJ4zH8v4qAihhXVvfHso2 7fF0SYPO8DGO6x0ZyGMdKoOfjpEjAAoh5KzKSE5MhMJlTe/6IvaIw6KwPb+n2aPBEkzl 3e3jXsR761rRt1k8cNUgESQrR5k8lDEyym07vcZ0JdVICilff5Z34UIk5ny4vnfdjgS7 mebg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695318544; x=1695923344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yr/T9kX37mjruI2YODshHpmgcsopLzBXqNS+RBfjBUE=; b=OlT/dEe6Dg8fkENm+cbSTcri3pAP58tmlC402jaYQKXPuTsHwWQdlWTPKLWDrcO13Y WUHA9/8BJtLyiDw7iCz+g5AHFITo3NtOYJPxkAXAUAAVtZXXMzfMCDwfvgS0uqiR8hDv AvXJEVfegT8w8aha90UTPK8kWMo1wFJBhIFdcxiC1ZB+OzXPIZbhzYV6kQo7VFEsq6Ur O8H9sMjZamDPHRIUiblws8BWOJthpNQav/z7s8zuHCbaNsrPkzhcJEyVOxvYXmOxuw0M m/aVULsA2sBPi9/RE2AUf6kx7p5ymApj7hGzht+Frxs6F/nW6MXq9Rq6BLKp0TTsuan1 cMUw== X-Gm-Message-State: AOJu0YxgdlTEtixcDM5STWfjU9pwRGZlRvom+yIPwCS1Ae2AQDjUBGFc 6dp9/kXL/dyN2nMJoDJg1cpADp1jwDjRv+/K7I2z3Q== X-Received: by 2002:a05:6a20:914e:b0:14b:e604:9f0a with SMTP id x14-20020a056a20914e00b0014be6049f0amr5003289pzc.20.1695267460994; Wed, 20 Sep 2023 20:37:40 -0700 (PDT) Received: from hermes.local (204-195-112-131.wavecable.com. [204.195.112.131]) by smtp.gmail.com with ESMTPSA id jc10-20020a17090325ca00b001b9be3b94d3sm251294plb.140.2023.09.20.20.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 20:37:40 -0700 (PDT) Date: Wed, 20 Sep 2023 20:37:38 -0700 From: Stephen Hemminger To: Kees Cook Cc: Mirko Lindner , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, kernel test robot , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] sky2: Make sure there is at least one frag_addr available Message-ID: <20230920203738.7e2c58c6@hermes.local> In-Reply-To: <20230920202509.never.299-kees@kernel.org> References: <20230920202509.never.299-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 21 Sep 2023 11:16:17 -0700 (PDT) On Wed, 20 Sep 2023 13:25:13 -0700 Kees Cook wrote: > In the likely pathological case of building sky2 with 16k PAGE_SIZE, > make sure there is at least 1 frag_addr in struct rx_ring_info: > > In file included from include/linux/skbuff.h:28, > from include/net/net_namespace.h:43, > from include/linux/netdevice.h:38, > from drivers/net/ethernet/marvell/sky2.c:18: > drivers/net/ethernet/marvell/sky2.c: In function 'sky2_rx_unmap_skb': > include/linux/dma-mapping.h:416:36: warning: array subscript i is outside array bounds of 'dma_addr_t[0]' {aka 'long long unsigned int[]'} [-Warray-bounds=] > 416 | #define dma_unmap_page(d, a, s, r) dma_unmap_page_attrs(d, a, s, r, 0) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/marvell/sky2.c:1257:17: note: in expansion of macro 'dma_unmap_page' > 1257 | dma_unmap_page(&pdev->dev, re->frag_addr[i], > | ^~~~~~~~~~~~~~ > In file included from drivers/net/ethernet/marvell/sky2.c:41: > drivers/net/ethernet/marvell/sky2.h:2198:25: note: while referencing 'frag_addr' > 2198 | dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT]; > | ^~~~~~~~~ > > With CONFIG_PAGE_SIZE_16KB=y, PAGE_SHIFT == 14, so: > > #define ETH_JUMBO_MTU 9000 > > causes "ETH_JUMBO_MTU >> PAGE_SHIFT" to be 0. Use "?: 1" to solve this build warning. > > Cc: Mirko Lindner > Cc: Stephen Hemminger > Cc: "David S. Miller" > Cc: Eric Dumazet > Cc: Jakub Kicinski > Cc: Paolo Abeni > Cc: netdev@vger.kernel.org > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-kbuild-all/202309191958.UBw1cjXk-lkp@intel.com/ > Signed-off-by: Kees Cook > --- With page size of 16K the frag_addr[] array would never be used, so the original code was correct that size should be 0. But the compiler now gets upset with 0 size arrays thinking this is some flex array leftover? Or can't figure out that in this case an rx skb with fragments would never be created. The workaround is fine, but could you add an explanatory comment?