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=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 37F5FC636C9 for ; Mon, 19 Jul 2021 09:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 241146115B for ; Mon, 19 Jul 2021 09:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235731AbhGSIa1 (ORCPT ); Mon, 19 Jul 2021 04:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235459AbhGSIaW (ORCPT ); Mon, 19 Jul 2021 04:30:22 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B9AC061766 for ; Mon, 19 Jul 2021 01:12:04 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id a13so21071952wrf.10 for ; Mon, 19 Jul 2021 02:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u5FkYygAP5aYXKhiToJncjQ4pnqt1axbUfxSA6M106E=; b=RUoz3S+OzJer2hQ2zynaEh0ahbOByD6Ye2U9E+aySsu09fb59vHB8xqBnMBTNjooXK J48srP6gvu9447896+hKmxhF7Yn3jmLZiyQCnSf7eqMm4aPtsMJWS8efN62jjFn9mbAr AQL95z7CfrzZnBYbnITt4xTYVjHmXWcnLWPNA= 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=u5FkYygAP5aYXKhiToJncjQ4pnqt1axbUfxSA6M106E=; b=DRadIpQak0j2bsPyTNr5kKmp9gEQ8imynSOjRV++Lndmy7yK1Zb8vumo2paf+KUiJj lT+FyaTqy+QPR9dL4h5cy5kv4iHmMX8tq+Xpmmo+1rsnyb4Dniwy7h0rhezUXsAv7e3n QwffhF3o1wwOaMSeSSWFGXjjaZICm20NIbAGRw0/gJ3aV9/9cvZvsxaybMBU6zXxMO/M OogUBSrmSZyTZCDx8nU9keqVlzpKSzWOgSZP/gSgPAeqpUjcUsSlOs7+o74Eib5Gildv g7Jgww7juQKyX9JePqaDcqjdSrjHIvCPDwz8oOd4mWqKJIjZji2YHQktQRYkO6JKtu5L zaLA== X-Gm-Message-State: AOAM531wgX1N6baPnIwZ+vKdBqUli+j2WOe45FMY+GR6O1QPxrmyd45L Y2zAqhsvxyOciQPO32PSrKN42ZflEpBMet6vHzHNGXmiMhc= X-Google-Smtp-Source: ABdhPJzlxqfFGaZrZ/5HCQxqAtoUQFd+tAAHV7lDvF2Cb/wf0Cnc0joQvV4k+SOZgE1RrpeWhEROVb9+ifjTZjQ6mgs= X-Received: by 2002:ac2:43d4:: with SMTP id u20mr17544633lfl.451.1626684328396; Mon, 19 Jul 2021 01:45:28 -0700 (PDT) MIME-Version: 1.0 References: <20210716100452.113652-1-lmb@cloudflare.com> In-Reply-To: From: Lorenz Bauer Date: Mon, 19 Jul 2021 09:45:16 +0100 Message-ID: Subject: Re: [PATCH bpf] bpf: fix OOB read when printing XDP link fdinfo To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , kernel-team , Andrii Nakryiko , Networking , bpf , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 16 Jul 2021 at 21:44, Andrii Nakryiko wrote: > > Well, oops. Thanks for the fix! > > Acked-by: Andrii Nakryiko > > It would be great to have a compilation error for something like this. > I wonder if we can do something to detect this going forward? I had a second patch that introduced MAX_BPF_LINK_TYPE, etc. and then added explicit array initializers: [MAX_BPF_LINK_TYPE] = NULL, That turns the OOB read into a NULL read. But it has to be done for every inclusion of bpf_types.h so it's a bit cumbersome. Maybe add MAX_BPF_LINK_TYPE and then add an entry in bpf_types.h for it as well? -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com