From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9DC5C433E0 for ; Wed, 20 May 2020 01:55:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD65620708 for ; Wed, 20 May 2020 01:55:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="ZOSedoTX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbgETBzs (ORCPT ); Tue, 19 May 2020 21:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbgETBzr (ORCPT ); Tue, 19 May 2020 21:55:47 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70AAC061A0F for ; Tue, 19 May 2020 18:55:47 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id g20so627642qvb.9 for ; Tue, 19 May 2020 18:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=ghTZqejRfgfS5fU2jVg75uMDbgGX4TrDcdfAaAdauPM=; b=ZOSedoTXRdCITrmaNoTnIMCXK7FvETKzbgoMB6JrmV4a5WGgI4bUyJioFolzQmGVrq o84jZ9Q029nIsm59ickCSKRAQ01KYsQEUK+O0c4WczRv54WM0OVp426vCrLLCpKR37Mw m5+8b6DcRSebQJ0RTOCsPoR2ZIbKjuquYzCasav1Nxy8+/U0kUkQUoatHY5OrIxy9YtL yAVmCyNuLc+1DjGAfNtUnT7YgFJbNpFsbuQn2zlgnGL6qXiPYNQ0+P32QGnABRJpe8HR nVBWLJcjfkd+mQxUSjqqoCgfYXpimBamkomH/UGmqkYwxDWuFhnC7r08aRZk4wq13M7K eJcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=ghTZqejRfgfS5fU2jVg75uMDbgGX4TrDcdfAaAdauPM=; b=n3tBGyOqWrIWo5OEB8Y0ObyNNBH1Teqgbqe9fYUomHL7LUSwXYCabyPfpQ+iFYwMZv uID98L1/ETeswZIgYF/W/RoyaPczY5l4g7AMK87KOHzcAkh/mR2z463iByhlsjRU1jmA NxzoY0UwNNw5Er0eMRCpvxkbtzVKDJRzrMjBRRcee55CBDHSD3iB9oTF5Nz87621lYsz I3TT7ugK0C4yr692uRRWx8Wt3ahToFRRmNoWVexY+X1pxzzh57ZOI/x3wU1GZoosYlHl YfshO9JbmSeOUynzV5t2KSs/0544BAlOkuxwviQ5UU/n/d4igtuB7MMo8fEyr+JUjFkS Wq3w== X-Gm-Message-State: AOAM530IXX4T7o92MR3xzUcsqXu3FI3udoEKFFpVCE/tAD1tNCSA4hKV ReGzBYzyoQ5Okac4dYFUbBU9xA== X-Google-Smtp-Source: ABdhPJyy1uyJk+Gqjg5bwcSBKIbQNOr6J5nfgaVGYYnWbcx1hDrSKyd/Hr8zTt2MLIvCkn1/+n7iIQ== X-Received: by 2002:ad4:466f:: with SMTP id z15mr2750441qvv.101.1589939746442; Tue, 19 May 2020 18:55:46 -0700 (PDT) Received: from [192.168.1.183] (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id j3sm1007064qkf.9.2020.05.19.18.55.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 May 2020 18:55:45 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable From: Qian Cai Mime-Version: 1.0 (1.0) Subject: Re: UBSAN: array-index-out-of-bounds in kernel/bpf/arraymap.c:177 Date: Tue, 19 May 2020 21:55:45 -0400 Message-Id: References: Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Linux Netdev List , bpf , Linux Kernel Mailing List , clang-built-linux , Kees Cook In-Reply-To: To: Andrii Nakryiko X-Mailer: iPhone Mail (17E262) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 19, 2020, at 7:23 PM, Andrii Nakryiko w= rote: >=20 > I agree, it's bad to have this noise. But again, there is nothing > wrong with the way it's used in BPF code base. We'd gladly use > flexible array, if we could. But given we can't, I'd say the proper > solution (in order of my preference) would be: >=20 > - don't trigger false error, if zero-sized array is the member of union; > - or have some sort of annotation at field declaration site (not a > field access site). >=20 > Is that possible? I am not a compiler expert, but with my experience with all those compiler i= nstrumental technology like KCSAN, KASAN and UBSAN, it seems both options yo= u prop need to modify compilers, i.e., -fsanitize=3Dundefined=