From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6563FA92C for ; Thu, 9 Feb 2023 20:05:47 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id rm7-20020a17090b3ec700b0022c05558d22so3405103pjb.5 for ; Thu, 09 Feb 2023 12:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=CIfREX/YQWh4b/q/oQJmrJNs03C5pbZw938goHZ0As0=; b=C3LGkKaZ/egq9pyVVyVUA/uUoyAfyHfgHZtTpDQ42GhMZ5h6GZ1iZ4R7W9FnEMNf+W z273Vxq5Fu0FUidkreu9oK0Il3x8I5FgMMlY9mplRGsomy2jRPQb6DoZhFjQg4KbSjlH TpGfM2kAFHBlSy0ig7CVp38EvJMZ6MCsrLsik= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CIfREX/YQWh4b/q/oQJmrJNs03C5pbZw938goHZ0As0=; b=R78wBOE81lQVQCykTqUKovdAvwvmt1N47M17FUG17gL8kZclBNvf6US5eAoUu1/nMl wmcr4NCLycSpI08jIfuj51p/IPMquCQep1+gA89NkeBjPT0t1jBjhk/4/2On9xwiB1XP lNcCeakTCSnImqVwPVr8+I+iGqJxvvGNCenBNtTn7gDb9EhhTvpgdphgvQvvOB5VgPVY cXUBa+JDFb4SCZRWGVUPkquzC99D7OlC96HBbql+Qmuw1Gfmqbu6Gamiw0IKnhF3Q54f 7U9m8+BiYoQp/NAuwiZjFyWk2LX0bnx1cK9opFpRWYYRL1xOQi01hsutdGvL1XOk62yA Ocjw== X-Gm-Message-State: AO0yUKVXr1KT96lkDlE65UUYuqV6ms8vTPI0wBdiv7dQm5Ez2agG/zVw joOYTdRIDwGcKgh1q3RKTFNskg== X-Google-Smtp-Source: AK7set/V2FOS5XFwG1dSzxjyTU/evZqkEa4kdYXJ7FE1Q2EBIaFEC8a8SbHRIQBi30Xmq4fgtz7Mzg== X-Received: by 2002:a17:902:e5ce:b0:197:19f7:52b4 with SMTP id u14-20020a170902e5ce00b0019719f752b4mr14816901plf.42.1675973146806; Thu, 09 Feb 2023 12:05:46 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id jm13-20020a17090304cd00b001948ff5cc32sm1883026plb.215.2023.02.09.12.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 12:05:46 -0800 (PST) Message-ID: <63e5521a.170a0220.297d7.3a80@mx.google.com> X-Google-Original-Message-ID: <202302091202.@keescook> Date: Thu, 9 Feb 2023 12:05:45 -0800 From: Kees Cook To: Andrii Nakryiko Cc: Alexei Starovoitov , Stanislav Fomichev , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Haowen Bai , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] bpf: Deprecate "data" member of bpf_lpm_trie_key References: <20230209192337.never.690-kees@kernel.org> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Feb 09, 2023 at 11:52:10AM -0800, Andrii Nakryiko wrote: > Do we need to add a new type to UAPI at all here? We can make this new > struct internal to kernel code (e.g. struct bpf_lpm_trie_key_kern) and > point out that it should match the layout of struct bpf_lpm_trie_key. > User-space can decide whether to use bpf_lpm_trie_key as-is, or if > just to ensure their custom struct has the same layout (I see some > internal users at Meta do just this, just make sure that they have > __u32 prefixlen as first member). The uses outside the kernel seemed numerous enough to justify a new UAPI struct (samples, selftests, etc). It also paves a single way forward when the userspace projects start using modern compiler options (e.g. systemd is usually pretty quick to adopt new features). > This whole union work-around seems like just extra cruft that we don't > really need in UAPI. The union is really only there so that possible uses of container_of() would be happy. But I did add a BUILD_BUG_ON() test for member offset equality, so a hard cast would be safe too. I'm happy to drop it if that's preferred? -- Kees Cook