Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp285499rwd; Wed, 17 May 2023 18:45:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6W5IIKO9dwalqIfCWRb0KvL7W+hMvxDW+dhd1WLaHC61c89yMwEsjYWqXyChjh4w3LJH9q X-Received: by 2002:a05:6a20:e19b:b0:103:c059:9371 with SMTP id ks27-20020a056a20e19b00b00103c0599371mr292815pzb.38.1684374311469; Wed, 17 May 2023 18:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684374311; cv=none; d=google.com; s=arc-20160816; b=IFXN4+ynEDgXbew/S66ZLzjcW/tGKZlmuxGtRZNZtk4ClwhDOFRuz+UcHow3fjn6NE ZEY719rTOzo6+3ya+pBNpF8r+a01s6MgeG0ZNRWzhhFLqy/5cYOcdPKd3Yaoavr+0fq/ SQpYbnUOmv27Y7cALIkmYa7ITda9KFtS6O2FurbPrQWgam9wxDS1EELsOaXhZvpZm4X5 V3HCAdywWQ1xsJMKHhlEZSBYzbhjuToz+GCruJyRvBoyojNPG4LvhgDSo/3cmUwWCSCR RuilA0WXQB/3139OUqYRr1Q9RXJubOH/gHHvsDEv+72RlJhpKxthLuXAPxqgGXxYXPcy aA/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=n3gOJF+MXOBVq1iRu2W9W0FS9rlAZbKgdHYpF5mdLYw=; b=O2xH4EvYEvdiAZ1aVCUww80R4BsRPuqCkeYRl7zoz+6mEKzWrW57M7GnlPE5wcWDhv MGfQzNO8HrtnKv1dTqLZkNqXMG8oTINA/tQ06EoxpLAvm3T07nQXguqP40t3FOb4BW0/ eZheCrhUj82sqKwyc1nhmlAEeP8KyeiMp94ZgyQW9tPBTkeuwzY/Y+ZPrjtTyYc3w2yw zrcWDDfH5CsDtsSKArXLOPnocLZoL3tv1AfKYnwhJtfx7kjF8oRGLyOdsT6+wOiWF3eF /D0eeykAbmUjLx7MkOIlTxSDWc2H0QF/XO6w3L4frrox7ru/SuIFFzfUi8FoxdO/WyaN 6+Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=RwU0TiOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i66-20020a625445000000b00628217e3ea6si400630pfb.316.2023.05.17.18.44.59; Wed, 17 May 2023 18:45:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=RwU0TiOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbjERBmS (ORCPT + 99 others); Wed, 17 May 2023 21:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjERBmR (ORCPT ); Wed, 17 May 2023 21:42:17 -0400 Received: from out-29.mta1.migadu.com (out-29.mta1.migadu.com [95.215.58.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1D4F123 for ; Wed, 17 May 2023 18:42:15 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684374130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n3gOJF+MXOBVq1iRu2W9W0FS9rlAZbKgdHYpF5mdLYw=; b=RwU0TiOxw2327F+kMmXihTAd02Cf701OOjP6FIfyfSwLCMe+5ycqEHxO7MkapmNHhUgOod AcQ0y+gwx7ckF42fBknrcDX8s3rp+wiyro0mZdGDtyrqe2EtxncGed5ryW6E2oxtBs5VDX j2+9myDtAVqH1UktlLEJFbwifSlgY7E= Date: Wed, 17 May 2023 18:42:06 -0700 MIME-Version: 1.0 Subject: Re: [PATCH bpf-next] bpf: btf: restore resolve_mode when popping the resolve stack Content-Language: en-US To: Lorenz Bauer Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa References: <20230515121521.30569-1-lmb@isovalent.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 5/17/23 2:01 AM, Lorenz Bauer wrote: > On Wed, May 17, 2023 at 7:26 AM Martin KaFai Lau wrote: >> >> On 5/15/23 5:15 AM, Lorenz Bauer wrote: >>> In commit 9b459804ff99 ("btf: fix resolving BTF_KIND_VAR after ARRAY, STRUCT, UNION, PTR") >>> I fixed a bug that occurred during resolving of a DATASEC by strategically resetting >>> resolve_mode. This fixes the immediate bug but leaves us open to future bugs where >>> nested types have to be resolved. >> >> hmm... future bugs like when adding new BTF_KIND in the future? > > It could just be refactoring of the codebase? What is the downside of > restoring the mode when popping the item? It also makes push and pop > symmetrical. I can see your point to refactor it to make it work for all different BTF_KIND. Other than BTF_KIND_DATASEC, env->resolve_mode stays the same for all other kinds once it is decided. It is why resolve_mode is in the "env" instead of "v". My concern is this will hide some bugs (existing or future) that accidentally changed the resolve_mode in the middle. If there is another legit case that could be found other than BTF_KIND_DATASEC, that will be a better time to do this refactoring with a proper test case considering most bpf progs need btf to load nowadays and probably need to veristat test also. If it came to that, might as well consider moving resolve_mode from "env" to "v". btf_datasec_resolve() is acting as a very top level resolver like btf_resolve(), so it reset env->resolve_mode before resolving its var member like how btf_resolve() does. imo, together with env->resolve_mode stays the same for others, it is more straight forward to reason. I understand that it is personal preference and could argue either way.