From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH bpf-next v4 03/10] bpf: btf: Check members of struct/union Date: Wed, 18 Apr 2018 11:30:25 -0700 Message-ID: <20180418113025.4ad5b9bd@cakuba.netronome.com> References: <20180417204243.4028831-1-kafai@fb.com> <20180417204243.4028831-4-kafai@fb.com> <20180418102210.5fbbb05e@cakuba.netronome.com> <20180418180101.6tdt5hr3ned25gu3@kafai-mbp> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: , Alexei Starovoitov , Daniel Borkmann , To: Martin KaFai Lau Return-path: Received: from mx4.wp.pl ([212.77.101.11]:46933 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751232AbeDRSad (ORCPT ); Wed, 18 Apr 2018 14:30:33 -0400 In-Reply-To: <20180418180101.6tdt5hr3ned25gu3@kafai-mbp> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 18 Apr 2018 11:01:15 -0700, Martin KaFai Lau wrote: > On Wed, Apr 18, 2018 at 10:22:10AM -0700, Jakub Kicinski wrote: > > On Tue, 17 Apr 2018 13:42:36 -0700, Martin KaFai Lau wrote: > > > This patch checks a few things of struct's members: > > > > > > 1) It has a valid size (e.g. a "const void" is invalid) > > > 2) A member's size (+ its member's offset) does not exceed > > > the containing struct's size. > > > 3) The member's offset satisfies the alignment requirement > > > > Could we also introduce a requirement for members to have different > > names? Maybe it's there but I missed it. Would BTF with duplicated > > member names be considered valid? > > It could check but I don't see BTF needs to check everything > that clang does. Agreed, I don't think correct tooling should ever generate duplicated members. Should the BTF forbid it then? It could help catch bugs and avoid problems. I was thinking about JSON where duplicated field names will result in invalid JSON potentially leading to issues in user space stacks...