From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yonghong Song Subject: Re: [PATCH bpf] bpf: fix bpffs non-array map seq_show issue Date: Wed, 8 Aug 2018 20:55:20 -0700 Message-ID: References: <20180809012519.3534824-1-yhs@fb.com> <20180809022530.yprizizentv7frmt@ast-mbp> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Cc: , , , To: Alexei Starovoitov Return-path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:33612 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbeHIGTC (ORCPT ); Thu, 9 Aug 2018 02:19:02 -0400 In-Reply-To: <20180809022530.yprizizentv7frmt@ast-mbp> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 8/8/18 7:25 PM, Alexei Starovoitov wrote: > On Wed, Aug 08, 2018 at 06:25:19PM -0700, Yonghong Song wrote: >> In function map_seq_next() of kernel/bpf/inode.c, >> the first key will be the "0" regardless of the map type. >> This works for array. But for hash type, if it happens >> key "0" is in the map, the bpffs map show will miss >> some items if the key "0" is not the first element of >> the first bucket. >> >> This patch fixed the issue by guaranteeing to get >> the first element, if the seq_show is just started, >> by passing NULL pointer key to map_get_next_key() callback. >> This way, no missing elements will occur for >> bpffs hash table show even if key "0" is in the map. Currently, map_seq_show_elem callback is only implemented for arraymap. So the problem actually is not exposed. The issue is discovered when I tried to implement map_seq_show_elem for hash maps, and I will have followup patches for it. So this patch probably should apply to bpf-next or I can include this patch in my later patch set which implements map_seq_show_elem for hash map which can demonstrate the problem. Please let me know. >> >> Fixes: a26ca7c982cb5 ("bpf: btf: Add pretty print support to the basic arraymap") >> Signed-off-by: Yonghong Song > > Acked-by: Alexei Starovoitov >