Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3012823pxb; Tue, 12 Jan 2021 04:19:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxagSJyY8itpVcXVUgv2sv4xV+VZOUk1gNFa6iDjOCOThgXE3EumPkG4VqUCc0UkoNXXsIB X-Received: by 2002:a17:906:a8e:: with SMTP id y14mr2944077ejf.47.1610453959891; Tue, 12 Jan 2021 04:19:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610453959; cv=none; d=google.com; s=arc-20160816; b=amHpcFyjOKNEkH9pfXnRquNoYwBzVC0MdEKLSIGtSnkvgMoi+L34f8e6dHFohKwXkF RLfzhiV7yXTLGj6RaLDEexfpwyNwPTNXYmJUVKC8d0Gbnk/hs9Gc8THwhziv1Rwtt7IW F6b4sm5Ezjl05T2RqkrTdPaCmJoiovzAZE4+XiLS3bMsve0QvaxuVOHCbEGSycW1fc4m x0TBZ+TjOdMfsHbQuugsNuwf62pgT+eqZAmuHI/MLspjfSYMCtLQwGPw4B6aRFosIahC M88vaLfMQxhrkPIF76Mp18YLpYP9jXx2UaeC7GOmFE996YeoOawSdKC9wB8BpGLDHJQj WVJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=aLveLxeFrNvjHmoCR9A2oV0J+t8vyyrnKRnubdghhuU=; b=T07F5LOoai1NTeOjeCbq1JE5vcxVTzdxHDDsPT5gg20xmZDQzdVx+a04mSRz+BUMG8 7SH8uR8ekZITK7oC5USqJrSlMzZUQgUcfT4pjoIA7ZTwhvph+eHHOKocBAASwFKFGLDE NsKVcjtnGKrC3OVUQt1XmSdNXxNe4c2Zgc4nj4vsUuuOkkwsunV9GQKLMYoPEZjyk+tO lwEMbo6rKjDuY55rfdGi9Euv6Msn1X90U+kPv7CZadt36GOppz5vO8O7zcTTc25eo8wh M20e2F4vvoMYzClSW4czOla1BA3CEiz34r5Fle72dl0HezzDv3/rzFB9MMH75/B1/zhK u1zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r2ZJ4ok+; 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 p12si1015839eji.735.2021.01.12.04.18.56; Tue, 12 Jan 2021 04:19:19 -0800 (PST) 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=r2ZJ4ok+; 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 S2389756AbhALJO5 (ORCPT + 99 others); Tue, 12 Jan 2021 04:14:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729821AbhALJO5 (ORCPT ); Tue, 12 Jan 2021 04:14:57 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6BCCC061794; Tue, 12 Jan 2021 01:14:16 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id d26so1612780wrb.12; Tue, 12 Jan 2021 01:14:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aLveLxeFrNvjHmoCR9A2oV0J+t8vyyrnKRnubdghhuU=; b=r2ZJ4ok+qcVmu0I2jzjZu0MSgognlZXsiDDUsoUpv+1D3BJAYs2T5/ZLUOcUkxWsgE eGOhsrXNXqcK2NNQObqqK3PuK/Gc9ptXmTSGsNkAC6LZ3hN65ldOXqBri/TAxN5xy3B/ h8/4GHSJu7p9xOEoZkyqaLKUaSrHkmIlOtkNAmaBLM39TOz6tfoyxbk6d9EZ8NmV0gCe y38QmY6dKD/wQvpI9nDJqRUJQcmFg9lQpSGaKUCRaYRchqHRzZX5RB84YQYpnixKDmuF HDr2uw9847Ky3yKFsKZlQUnXK2nUYJXSu3YKUQ/Mj5wJsNXlgnzFjOU1soU2/EpbuTNe L7VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aLveLxeFrNvjHmoCR9A2oV0J+t8vyyrnKRnubdghhuU=; b=lgaXN//BaqHvzMxNXUQOBU4rXZe5cRyTLc+1YX6vrOUsmaPqcjeSwMvBGjuYfPxOE1 ugdpfRoE19cMEOyjoK+GHgpLDiSLIDJEommmsdsswGLqITPhweWh9Vt47UXVKjVNnwvq H3aXCsMYy0iTjUt175N/vS7OueSNVPwStC0oyvyTykei4zqxzLkyIgMqqnKp3v+8CAYP s33YMxefCdzoxOcPDjV7Zqr4JFHV7Yy7ZKrIbE5NsIqlsWSfXEFbOpHpqC2+H5gyvSdq SlPFwRaARELs+A/eeDpBcdCbjhQUq9M78zijuWKWwqS7zVz3UiU+/zvDzSQu3ADKG+4A 61Og== X-Gm-Message-State: AOAM5332ZiOSLm2BOrI0Q0BShraZGE2MvOndwrTGMI6Up/QAnz/seJbT pSmrgZIpdmxcKkeWY+VWJsyF8bn0qcMlLpsu X-Received: by 2002:a05:6000:18a3:: with SMTP id b3mr234261wri.373.1610442855164; Tue, 12 Jan 2021 01:14:15 -0800 (PST) Received: from ubuntu.localdomain (bzq-233-168-31-62.red.bezeqint.net. [31.168.233.62]) by smtp.googlemail.com with ESMTPSA id b10sm3085995wmj.5.2021.01.12.01.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 01:14:14 -0800 (PST) From: Gilad Reti To: bpf@vger.kernel.org Cc: gilad.reti@gmail.com, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf 1/2] bpf: support PTR_TO_MEM{,_OR_NULL} register spilling Date: Tue, 12 Jan 2021 11:14:03 +0200 Message-Id: <20210112091403.10458-1-gilad.reti@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for pointer to mem register spilling, to allow the verifier to track pointer to valid memory addresses. Such pointers are returned for example by a successful call of the bpf_ringbuf_reserve helper. This patch was suggested as a solution by Yonghong Song. The patch was partially contibuted by CyberArk Software, Inc. Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it") Signed-off-by: Gilad Reti --- kernel/bpf/verifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 17270b8404f1..36af69fac591 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -2217,6 +2217,8 @@ static bool is_spillable_regtype(enum bpf_reg_type type) case PTR_TO_RDWR_BUF: case PTR_TO_RDWR_BUF_OR_NULL: case PTR_TO_PERCPU_BTF_ID: + case PTR_TO_MEM: + case PTR_TO_MEM_OR_NULL: return true; default: return false; -- 2.27.0