Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp719039pxj; Thu, 10 Jun 2021 10:57:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAIXRrjWLER8ZIkshl9OtJV0/Us/LTsBMn7d6yDPsGZzRDg+Y2/xhvrMVL6lHf6RvjFvVp X-Received: by 2002:aa7:dd14:: with SMTP id i20mr736827edv.110.1623347851841; Thu, 10 Jun 2021 10:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623347851; cv=none; d=google.com; s=arc-20160816; b=wPvBSjPW6ZuXeS/rVKE0zDB8TjymXUoq9lckzctgrAMbIAWQQhkgZNE9HQIntnHrta 58TxHW2lgniumJJyfMPdSn3xyiIwigyqnw46vZlhi/zKYOX+tB5yqfEfP06mQcYlO1As B6XdC3CPsg7F1fiDXU+5XRybIbkGf30LhlQVYcjvUwACmJhStYWCDSu8PnIGKnywQ5hs lz4upTmdYiLgVO+AazeFriBxUCF9KeNNncuAIbz0ozOzjI8JikyNHrb4Dh4jt1vP3nly nzKVrsidpZ/USVwBzCBkoz/KrtYJVXgx45qnF+juyKMszNJ+DOSN4bgGm68QDH5bXfQk RaAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=on0Tnjo9EX+wZkS0PcGQkLK+8ozdHMxgRM2ZPf0mD60=; b=pFuXlwtZWbOJfGC26PGt6b5H5Ns51yh4X3in88mJz44uyUijeluY23eMYqHL4a7+Bg vXe43C2FaNmR/5Gs/4uGdjON1462tT5Gd52VB0WYOcd5Z3CXlw4e9BBnYODfvpjs8bhV 5Mu9ScPp0Jw32NWzts2fzeU4JB2d4PC7f7P23Ap2hZbe7bNYWifATpettmeEBNxIhT+H tWIqwUKuIdtTBrsj5lTXncqZUqkUFzoun0TwG1Rj4/yZWbBOcPe8Q34WRu5d1dsuzqhK oumciXosS1siXLrEhDZzyd8lSBQCcPATZ0IvwOupdu5M9Bztk0PS0gl0hu7lgSiCFc5p H5zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j9utiUZQ; 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 i11si3250119edb.418.2021.06.10.10.57.07; Thu, 10 Jun 2021 10:57:31 -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=j9utiUZQ; 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 S230305AbhFJR4C (ORCPT + 99 others); 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-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: linux-kernel@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.