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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 47188C48BE0 for ; Thu, 10 Jun 2021 17:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 241DB61426 for ; Thu, 10 Jun 2021 17:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbhFJR4C (ORCPT ); Thu, 10 Jun 2021 13:56:02 -0400 Received: from mail-lj1-f180.google.com ([209.85.208.180]:39888 "EHLO mail-lj1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbhFJR4A (ORCPT ); Thu, 10 Jun 2021 13:56:00 -0400 Received: by mail-lj1-f180.google.com with SMTP id c11so6080677ljd.6; Thu, 10 Jun 2021 10:53:49 -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=on0Tnjo9EX+wZkS0PcGQkLK+8ozdHMxgRM2ZPf0mD60=; b=j9utiUZQhGBbTOtjugU9fdt/FXWpsia1oR3qKOXO/TPLUkuvy8TaWMJ5/wiA8q+zGK rNeb/Lo9SaW23+goSZYwxCL81gW4lJ2d8mT/R/NRu3wGbc/KRlVewK+k0Xb/KI26YLLZ Cz27Cvxmt+KcIx3sxWdN1VTqPBcHoO/BqkNz4bhpyD4axCSB4iFhYAMvxuKNOOFgSmZq 9W74zfrKa813xMYFi5ra7SMIN7Y+cZ+aIUMj96Lr5DWGVPUHiAc4QJsseTdfTp221f6e 1fNG4bxiKO5JWNKCJ4Ampld4s8EJ6RLZ1P5vXV/V17ditBBYMdDdswCtE4Y9BLTqyJ7F bvEQ== 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=on0Tnjo9EX+wZkS0PcGQkLK+8ozdHMxgRM2ZPf0mD60=; b=Gnkpj4Kn8pGlOOJhXkoS1wgv59gOQhXoxFLloPZbIlY36i/g/e0P9bZIDnmDY2gs9C gfYnDpS7NQub+SHuo9s2LpNr0V/n9GABTPDqzxO99b+q6HtjmCzfrW4/GCQOPCYvtVnL UMap1R0uV+ibyMN2pM0PlGQTz3eFRrPv1NxoU/byf/ZBQHJ9iOWuakYLAEde5AVh30pr aQna9AtSq5MxW2dForp1rR4AK0JAWKCtpmkbhlWVz+G/zxpWfgZRswkh+n12nPgszdl0 70gbY44PYZgPQ5XlbMcN08FSBmn85953RKtlyJVDTljXDB45WSy3vJvqsd8uYwOj4pMW yusA== X-Gm-Message-State: AOAM530VAoMvcB0/pqkXsHcl42fKQqI16BUkEyudMirCs881JzFeiNGz r9VoQO7n63ZvD6NayGdgbWezAgv8+rTP2FSEKgc= X-Google-Smtp-Source: ABdhPJws5IUcrVuyFh3x8K8w0l/lXTFkf9nHIYvn2dADR0QD7VRdNZF2eqVjHmAmOhded8cSA4fG+o+m8KFwXjKW8mw= X-Received: by 2002:a2e:b5c8:: with SMTP id g8mr3170497ljn.204.1623347568936; Thu, 10 Jun 2021 10:52:48 -0700 (PDT) MIME-Version: 1.0 References: <20210602212726.7-1-fuzzybritches0@gmail.com> <87609-531187-curtm@phaethon> <6a392b66-6f26-4532-d25f-6b09770ce366@fb.com> <202106091119.84A88B6FE7@keescook> <752cb1ad-a0b1-92b7-4c49-bbb42fdecdbe@fb.com> <1aaa2408-94b9-a1e6-beff-7523b66fe73d@fb.com> <202106101002.DF8C7EF@keescook> In-Reply-To: <202106101002.DF8C7EF@keescook> From: Alexei Starovoitov Date: Thu, 10 Jun 2021 10:52:37 -0700 Message-ID: Subject: Re: [PATCH v4] bpf: core: fix shift-out-of-bounds in ___bpf_prog_run To: Kees Cook Cc: Yonghong Song , Dmitry Vyukov , Kurt Manucredo , syzbot+bed360704c521841c85d@syzkaller.appspotmail.com, Andrii Nakryiko , Alexei Starovoitov , bpf , Daniel Borkmann , "David S. Miller" , Jesper Dangaard Brouer , John Fastabend , Martin KaFai Lau , KP Singh , Jakub Kicinski , LKML , Network Development , Song Liu , syzkaller-bugs , nathan@kernel.org, Nick Desaulniers , Clang-Built-Linux ML , linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan , Greg Kroah-Hartman , Kernel Hardening , kasan-dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Jun 10, 2021 at 10:06 AM Kees Cook wrote: > > > > I guess the main question: what should happen if a bpf program writer > > > does _not_ use compiler nor check_shl_overflow()? > > I think the BPF runtime needs to make such actions defined, instead of > doing a blind shift. It needs to check the size of the shift explicitly > when handling the shift instruction. Such ideas were brought up in the past and rejected. We're not going to sacrifice performance to make behavior a bit more 'defined'. CPUs are doing it deterministically. It's the C standard that needs fixing. > Sure, but the point of UBSAN is to find and alert about undefined > behavior, so we still need to fix this. No. The undefined behavior of C standard doesn't need "fixing" most of the time.