Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp175046ybk; Tue, 19 May 2020 19:00:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/N7//eST/93jj7xW7kswquXspX8gx9f36+hZ5rsHTfLGCVuVNWECxkgLLtyuHvGtUDPGn X-Received: by 2002:a17:906:328c:: with SMTP id 12mr1948599ejw.69.1589940049304; Tue, 19 May 2020 19:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589940049; cv=none; d=google.com; s=arc-20160816; b=IuUeCrwrexAFcWHuyn7hJTuxuSmyBes2UnhVHu6RAJP6+qq90j3XgKLvOyq5j5vARl V0KLAzpFYR866tIwoFvO90AJUILfl0vJ+NQfWwlhRSAKbtXWeGwnDsiiCCCVWI1r9g6F suGjqVRaX8HaOYveYFurIupVernsw2VxjqAm/mXAzSwhbjLsEUruyf5BXk1L9hpeJ812 VMxCRYffuikKlcFRachhGkJ322zgWOmXZrCXPjLmbMMTyM7Nz1PTx+CXWCEjFc/7OW6u nG4XiAXEVeGlZ1yFEdRepiy0O+tklwAQcNnc0dgXUAmsNbwhoyd3U7tLl9IZkqQ8W+Rh 4d/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=ghTZqejRfgfS5fU2jVg75uMDbgGX4TrDcdfAaAdauPM=; b=ilMGvpCJdpqogs+QEpoK2M8F/wA7eL6atkrekG7UJapjaEppdwnhFnXuuo/5OaDzfm qyNe6iMDupYGik20ybplvewQ4t4twSzn+2BAL6BynPQqoMR33O6GbttUF9ddkkmkgJQH nM1FhX9ea5qlK0yPcwtnMoplZLu8YVHBWrP2ddEksy04uE1YNMP/MXh5cuXF/VJNJYH5 NhNOC+fyTCxKDD3tbajV1NIhEG6/RepwjXb/cG1I1lCSAjNTyfwW8ofZdB+QVaJI0W7j SUbjqRutfeqBz/+k52B689BDViYynMNfDf6h/uLyJPhUpDSJabo4fK3rfF2tMvCtY+SN JBiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=ZOSedoTX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f8si655068edy.149.2020.05.19.19.00.26; Tue, 19 May 2020 19:00:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=ZOSedoTX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728384AbgETBzs (ORCPT + 99 others); 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-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=