Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp827565iob; Wed, 18 May 2022 14:01:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvwblL8lIwYXQUUdZbt3UVT1rvLaANe4JsuxLNo/tgG6nxw5otqrOu1Se4MlC/em1cv+lG X-Received: by 2002:a63:fd51:0:b0:3c1:977e:1fed with SMTP id m17-20020a63fd51000000b003c1977e1fedmr1085079pgj.246.1652907701782; Wed, 18 May 2022 14:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652907701; cv=none; d=google.com; s=arc-20160816; b=WMAyvTuRFDdHCNl3clgk/Hv24AsUgkGGiXv8ISguHh1iHt6QxMT0vnnVAY/7CG7ypR L6tIfHOhhTNCk81546GTO0AkMdWsUpPfix+0vfLG+w+RmS76a19N69hPTVD9NoGxDDT5 QELZGt+vNrHK5AdxTaEq5+fLxLM/ey5CA5jO4VAmIbryhtDE/UrdXhAy4aA8pf5JLzdU YRn2rviQLW/prF0gJF/1naE0tDqxOjGrqznN8xDIy8PtfjFa4MM7vZ0lW4ZOkIkEyPFp O4i68GIEOr5pV5oNglodZ4VIONn+PYdgJjchVH3I8iZ+JFLT8OMrS3WaGo/Y6QX+0nKi OfSg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3kr3uQhH8H7v2Urw3FpWKFbWd5aXnjEzAqaG3LQw9fE=; b=qUSAyhyB1GQloq9QC1amygEY4CnnrdQ3811sWnGF+/pwSnR9G4ykIK0uNLxiyU2v5G 2w4Rzjwthkl1wbCHSkBd6mckUZGBRD4DolBTbVOk5FfUXFVI+t1BH7KoH02WColGme7T 491Aelq38sQwNiOBSjlhBuAOPGBoAR0QYH7ZTDpH3vYPILtmRrPI486tp+wiyiTzxGM/ 2JNhMYvg42TUtf0qi8iCLLadF7bMXBgSnmrAYTIJDic3KkgNfa4vYEs/H581de9sQs2t LdkxhJG5/0il1kaOVQY3bxcZP7T34Te+v6CWTIWIssT7VteRPIulIcmkpx9aTFTYGSuM 5YPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H+gqWzD+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x3-20020a170902b40300b00161be2005a4si3781136plr.255.2022.05.18.14.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 14:01:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H+gqWzD+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3B522555BB; Wed, 18 May 2022 14:00:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242905AbiERVAA (ORCPT + 99 others); Wed, 18 May 2022 17:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242803AbiERU7v (ORCPT ); Wed, 18 May 2022 16:59:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5BC14253A88 for ; Wed, 18 May 2022 13:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652907589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3kr3uQhH8H7v2Urw3FpWKFbWd5aXnjEzAqaG3LQw9fE=; b=H+gqWzD+6i2mjmFYHXKXguunnjwdi14LogFh9xk+Pj+FZ9tqj6aGZRGy8WGgeRaRFSLuhK 0VuXNWjpvI8H8sqxc9SqrhiBE/PJsar/htqJ3sUThg87JIfnraNrF0tKDheDv1ry5COLdb Si3UH8fMABkNDTzc858kESkXkYt8ZYQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-OPEu05RCM36iCdv6qps4Fg-1; Wed, 18 May 2022 16:59:44 -0400 X-MC-Unique: OPEu05RCM36iCdv6qps4Fg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 870953C0D18D; Wed, 18 May 2022 20:59:43 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.192.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA4CE2166B25; Wed, 18 May 2022 20:59:39 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Jonathan Corbet Cc: Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Benjamin Tissoires Subject: [PATCH bpf-next v5 03/17] bpf: prepare for more bpf syscall to be used from kernel and user space. Date: Wed, 18 May 2022 22:59:10 +0200 Message-Id: <20220518205924.399291-4-benjamin.tissoires@redhat.com> In-Reply-To: <20220518205924.399291-1-benjamin.tissoires@redhat.com> References: <20220518205924.399291-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add BPF_MAP_GET_FD_BY_ID and BPF_MAP_DELETE_PROG. Signed-off-by: Benjamin Tissoires --- new in v5 --- kernel/bpf/syscall.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 72e53489165d..807e5596f56c 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1417,9 +1417,9 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) #define BPF_MAP_DELETE_ELEM_LAST_FIELD key -static int map_delete_elem(union bpf_attr *attr) +static int map_delete_elem(union bpf_attr *attr, bpfptr_t uattr) { - void __user *ukey = u64_to_user_ptr(attr->key); + bpfptr_t ukey = make_bpfptr(attr->key, uattr.is_kernel); int ufd = attr->map_fd; struct bpf_map *map; struct fd f; @@ -1439,7 +1439,7 @@ static int map_delete_elem(union bpf_attr *attr) goto err_put; } - key = __bpf_copy_key(ukey, map->key_size); + key = ___bpf_copy_key(ukey, map->key_size); if (IS_ERR(key)) { err = PTR_ERR(key); goto err_put; @@ -4893,7 +4893,7 @@ static int __sys_bpf(int cmd, bpfptr_t uattr, unsigned int size) err = map_update_elem(&attr, uattr); break; case BPF_MAP_DELETE_ELEM: - err = map_delete_elem(&attr); + err = map_delete_elem(&attr, uattr); break; case BPF_MAP_GET_NEXT_KEY: err = map_get_next_key(&attr); @@ -5028,8 +5028,10 @@ BPF_CALL_3(bpf_sys_bpf, int, cmd, union bpf_attr *, attr, u32, attr_size) switch (cmd) { case BPF_MAP_CREATE: + case BPF_MAP_DELETE_ELEM: case BPF_MAP_UPDATE_ELEM: case BPF_MAP_FREEZE: + case BPF_MAP_GET_FD_BY_ID: case BPF_PROG_LOAD: case BPF_BTF_LOAD: case BPF_LINK_CREATE: -- 2.36.1