From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: Re: [PATCH bpf] bpf: btf: Use exact btf value_size match in map_check_btf() Date: Fri, 27 Jul 2018 03:46:47 +0200 Message-ID: <32cdc385-c7a5-7e40-2d92-4ae8d370b782@iogearbox.net> References: <20180726165759.3788287-1-kafai@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Alexei Starovoitov , kernel-team@fb.com To: Martin KaFai Lau , netdev@vger.kernel.org Return-path: Received: from www62.your-server.de ([213.133.104.62]:59068 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731933AbeG0DGS (ORCPT ); Thu, 26 Jul 2018 23:06:18 -0400 In-Reply-To: <20180726165759.3788287-1-kafai@fb.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 07/26/2018 06:57 PM, Martin KaFai Lau wrote: > The current map_check_btf() in BPF_MAP_TYPE_ARRAY rejects > '> map->value_size' to ensure map_seq_show_elem() will not > access things beyond an array element. > > Yonghong suggested that using '!=' is a more correct > check. The 8 bytes round_up on value_size is stored > in array->elem_size. Hence, using '!=' on map->value_size > is a proper check. > > This patch also adds new tests to check the btf array > key type and value type. Two of these new tests verify > the btf's value_size (the change in this patch). > > It also fixes two existing tests that wrongly encoded > a btf's type size (pprint_test) and the value_type_id (in one > of the raw_tests[]). However, that do not affect these two > BTF verification tests before or after this test changes. > These two tests mainly failed at array creation time after > this patch. > > Fixes: a26ca7c982cb ("bpf: btf: Add pretty print support to the basic arraymap") > Suggested-by: Yonghong Song > Acked-by: Yonghong Song > Signed-off-by: Martin KaFai Lau Applied to bpf, thanks Martin!