Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3064942ybk; Mon, 18 May 2020 16:58:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOXQpDHbmYWAdcr/BMkm5gH3kPl1Slzfo9vJu4Xv7aSNF6edDQ8SicQ2kTXlLKwx1a89/g X-Received: by 2002:a05:6402:a48:: with SMTP id bt8mr16646689edb.197.1589846286472; Mon, 18 May 2020 16:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589846286; cv=none; d=google.com; s=arc-20160816; b=RLyYdrXmIwr3VzBqwCruMxtAstwU46Nrqip3PHtsstTT28tou2CPo9D0iThTAAKaYg 5Sli6HbNKezuzKt/2QsuPeewvfdBBDvSxkVmU/M5ZflOQ5kqp/2Udi/yoWbrKcb5crDd XGeij3Pu9ib3E2lrc3dRM6VTn4mZUIMfEQWUXn6+uw1AUCRYjTUBcJtFkRmEs0uQevH6 Qr9SWUwkNezeAWb8gnd5JVq/alUhaTjOLNtplxYMl1nmzsu8dhOQ6uum47QjppMIOIbz S0BOsHk+9DiSRmCJzKLTjlTE6ugwVkgA27Ex9q9LtK0CbAHPbNhyJaQMoPwic59gtgFw cG5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qAA3OKl6AVtvhmTV5S8FL74OsHN/DYWammXE/OmRhwk=; b=oqkrr4nhZi2RR+wGb7A+TZgPpmJbRH1qPLEYamkgwOoRLeXt0uIEIulHAUv80wBKbK 09IiN0l0OR0za+SoUigLvA9OM9qpZWgMmykx3hLUbLQUwwAhESjVT/Nzv42HUWdzvQRz O/nXVRBEfXo9nbCMeYUEDkL7R/yKRZxSPG0+peSpaza5i2CkTVtF5DWRMSbnhxeJld93 BD2ORKqrneMuUq3QJ2frTUdPbLkcVURWgksnXHVUB6HT2BNszNNOZctO42R0oF5OHXhE hZhxZdeM6qRvv4AtYOWgWiuhTWN8U0DF7WJ/W0SEN3LkyHRvPVXtbC2iROr/BPWUbvpT uXsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=of7AbYv0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j2si5667742edt.227.2020.05.18.16.57.43; Mon, 18 May 2020 16:58:06 -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=@gmail.com header.s=20161025 header.b=of7AbYv0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbgERXzd (ORCPT + 99 others); Mon, 18 May 2020 19:55:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgERXzd (ORCPT ); Mon, 18 May 2020 19:55:33 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26071C061A0C; Mon, 18 May 2020 16:55:33 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id f189so12534425qkd.5; Mon, 18 May 2020 16:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qAA3OKl6AVtvhmTV5S8FL74OsHN/DYWammXE/OmRhwk=; b=of7AbYv0K2/b2seTUWM/TCubCj3XxMuDVafKnxmHkJ5qKedufmFbUg/4MMwe4PweiG 6QojRewkL4NlTCXCkYG8wpCvaCiYXBYocBMwbJb/zweokGRWLpmqLgvQ4sJ2XcgmoECt ebW/k42dOPj0mVvwtLOxBNanjNzbqVAkow7SHuOVXBHJJbt5V+DwOJfw3BPGvEnify2Q KY060T/ZVjDBthFiAldmSGjvzLI0GaVkLRfU17VG1d3doEHlcYIg/gzgpBdoQSsP05YV jZ33AnHXQwB94XLYtyohTkCRzAQck5ygfcQT7BAtC3zKIJlS6vuvJoCCfqKxEp0HTb8+ K8kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qAA3OKl6AVtvhmTV5S8FL74OsHN/DYWammXE/OmRhwk=; b=Qg9tkg7uIsMaNWF6+r+nz9SSM0wn11mpXeK5lA8z3Rdi7zY1HBcqMIH6PTbIKt1tst qbqSbWTgevPX17m8inUodj1rhyi5CEUNJFhVCT2pMBlH5c1WFPS7GtflPRmvp2nBLef+ HIcXSQ11WH5BZY3In+XM6ofkdYRX3rIJCrUSLIGwzCeX/E+siSeRq0wh80eLpN3N+wjT VDC9smpry1gAn+Prcdpy1tfRD3wMuSH37qiaA1x/XVjsdkfuREBuZyxNAk2JMom8Yuew G+3yTPHp3gIrTSD9BjMboV+XVhPVV4SsocBWXk4SGXqMSZezQ/LUwhg3a5pMFZS2vv+h Dzsw== X-Gm-Message-State: AOAM530A2ze2t8OlB9cKsa33dnLJifuW2bkxLSTqQpKJ996FoEkLfiBs A6HvRvxCta0lD+ZnK9O6ozdQc5+8Q/CwMEaUS64= X-Received: by 2002:ae9:efc1:: with SMTP id d184mr19648194qkg.437.1589846132391; Mon, 18 May 2020 16:55:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrii Nakryiko Date: Mon, 18 May 2020 16:55:21 -0700 Message-ID: Subject: Re: UBSAN: array-index-out-of-bounds in kernel/bpf/arraymap.c:177 To: Qian Cai 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 17, 2020 at 7:45 PM Qian Cai wrote: > > With Clang 9.0.1, > > return array->value + array->elem_size * (index & array->index_mask); > > but array->value is, > > char value[0] __aligned(8); This, and ptrs and pptrs, should be flexible arrays. But they are in a union, and unions don't support flexible arrays. Putting each of them into anonymous struct field also doesn't work: /data/users/andriin/linux/include/linux/bpf.h:820:18: error: flexible array member in a struct with no named members struct { void *ptrs[] __aligned(8); }; So it probably has to stay this way. Is there a way to silence UBSAN for this particular case?