Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4552519pxf; Tue, 16 Mar 2021 17:12:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL5DaWBpc7FTo5BnuHDLCCj4rxsIKNGS1IB1PZIe1w5lob5wEflT7b+Jt6v3o+GdRAqa56 X-Received: by 2002:a17:907:75d9:: with SMTP id jl25mr31905578ejc.452.1615939940309; Tue, 16 Mar 2021 17:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615939940; cv=none; d=google.com; s=arc-20160816; b=BZ5clEVNXXnNWFAlV+A4OfyhC47i/ywqlYGMmyRunwBcT/Lptm8YoXMugYqr9zvY8M 4a3H04LfFu6MBbJdeDS1JqXUzJJ3PUB/dbBkBumk+JNX25S2I2aOHHLh0SRn1RXw1z7L ef1G9D45RTKClcfUWrCMmhCAsZ9u2Uiq+kjA5LMD9aFWJr6YhmaJZZcM2YKT+0ndfOBS ZHG5AUCuPhI13WW1po10u/BgKI+m1rC3MKFKRGg5BWTVduB85NaoH85yh0jwav1QmWf5 MmoPBH/RuqmgxHNdDi/qBUJH0zphwXyiZlnSkSbYdTxmtFmqyB1G1HDz2KzLloYMCJ5G GwBQ== 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=/IklMf9X34RfFB2tD5VBL6tlFQuCAFSd3dj+6sxly+A=; b=h070z1yySfAyfY94B0ZphdP5mqxZYwrbo/uKL69uKE82OCREI0IFbP4AU7LYplzpIe Mm32nDkb5Kn9To9vDVrLinEknpkSfep9FqTR2afcp+oh1Gw+1kMY2SH5EqFOHphUWaZF 3hgjQIjC6PKoHvhxuz9JlHSFSy//WrK67vpqbcVdzVRzcGtGSAvEtr1PqJbV+YGrm70t 9rrLB9XyJHiGu4ZnO+m5F/JEpLPcxCRfH8bobkE3gkz0chgULNHV5HMLpaURjSJV8vVg pvd3xsnpp82GM03PPU5mfEKaLtHZschit/z9qLnNilFhJbIgVj1DMn1jInOqP5jX3dmr P0eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NCG+NcBX; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c13si14945360ede.115.2021.03.16.17.11.57; Tue, 16 Mar 2021 17:12:20 -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=@chromium.org header.s=google header.b=NCG+NcBX; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbhCPX65 (ORCPT + 99 others); Tue, 16 Mar 2021 19:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbhCPX6q (ORCPT ); Tue, 16 Mar 2021 19:58:46 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03229C06174A for ; Tue, 16 Mar 2021 16:58:41 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id z13so39133460iox.8 for ; Tue, 16 Mar 2021 16:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/IklMf9X34RfFB2tD5VBL6tlFQuCAFSd3dj+6sxly+A=; b=NCG+NcBXFzlueVVDEW9J9YjBNnzPpY5Cjw5qCl393AdvUcFzcbdxlqKkHcdGk52iF+ d5X6yUChO9YoSWyrJgZkuSz7LLF9OFDpxZJWuhuoONPWaw+rK9MYe1L94r+C+f2ukCEW T9c9N9+UJN1DZGpv7/94RHbfAzbSQXqV3e+lI= 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=/IklMf9X34RfFB2tD5VBL6tlFQuCAFSd3dj+6sxly+A=; b=BgSuS0sgA3BRuSADxiCBAQKhZwMKUeRZXv2Up9F4aAKTMxYtQCkQYeqjCkZc588QdT DW+84qZ2nyDfL07Ozsnx1ZQVDML8xf/DM8aRYPVR08HTxhGTxbT7dYlRK9fkrSpaDYaG 4wbcQ2CjXELmagST4wWsxUd5B56JigCKzMGoSQsqeLcSTSjMyibN0hXNIao0fRzdp+Sz H6gd0Qayjnkvtqzzxq7aZLAoSjBq0krrhIqLEEjKB8t8hlm1lCSaHYAB1GeLdC6dnTFL zJuu5H4LLALrxX9ESnxKb3IApctrJOk5q0bnMDwkz6riwgLXmBOcBi8Whe7c9SccTioi yYmQ== X-Gm-Message-State: AOAM530xTYSyYzdgnAG45+aYahR6aM42RVcGSnE2q1BV1aeymSP1Ic+/ fs18YBxnFF3SF6QlKpyn1ON3zzHIdOlv8yiZqs/uKg== X-Received: by 2002:a02:cb48:: with SMTP id k8mr900560jap.52.1615939121345; Tue, 16 Mar 2021 16:58:41 -0700 (PDT) MIME-Version: 1.0 References: <20210310220211.1454516-1-revest@chromium.org> <20210310220211.1454516-2-revest@chromium.org> In-Reply-To: From: Florent Revest Date: Wed, 17 Mar 2021 00:58:30 +0100 Message-ID: Subject: Re: [PATCH bpf-next 1/5] bpf: Add a ARG_PTR_TO_CONST_STR argument type To: Andrii Nakryiko Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Yonghong Song , KP Singh , Brendan Jackman , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 2:03 AM Andrii Nakryiko wrote: > On Wed, Mar 10, 2021 at 2:02 PM Florent Revest wrote: > > + } else if (arg_type == ARG_PTR_TO_CONST_STR) { > > + struct bpf_map *map = reg->map_ptr; > > + int map_off, i; > > + u64 map_addr; > > + char *map_ptr; > > + > > + if (!map || !bpf_map_is_rdonly(map)) { > > + verbose(env, "R%d does not point to a readonly map'\n", regno); > > + return -EACCES; > > + } > > + > > + if (!tnum_is_const(reg->var_off)) { > > + verbose(env, "R%d is not a constant address'\n", regno); > > + return -EACCES; > > + } > > + > > + if (!map->ops->map_direct_value_addr) { > > + verbose(env, "no direct value access support for this map type\n"); > > + return -EACCES; > > + } > > + > > + err = check_helper_mem_access(env, regno, > > + map->value_size - reg->off, > > + false, meta); > > you expect reg to be PTR_TO_MAP_VALUE, so probably better to directly > use check_map_access(). And double-check that register is of expected > type. just the presence of ref->map_ptr might not be sufficient? Sorry, just making sure I understand your comment correctly, are you suggesting that we: 1- skip the check_map_access_type() currently done by check_helper_mem_access()? or did you implicitly mean that we should call it as well next to check_map_access() ? 2- enforce (reg->type == PTR_TO_MAP_VALUE) even if currently guaranteed by compatible_reg_types, just to stay on the safe side ?