From patchwork Mon Oct 24 11:29:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp434235wru; Mon, 24 Oct 2022 05:51:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4STKXNuXfwb2InZnfP99fwj3m9BY2qoqDaM9jUuW3C9+VdbTrbY7AU+RWbNmbdi3VyPjMl X-Received: by 2002:a17:907:8a1c:b0:78d:ef44:7759 with SMTP id sc28-20020a1709078a1c00b0078def447759mr28149257ejc.441.1666615904542; Mon, 24 Oct 2022 05:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615904; cv=none; d=google.com; s=arc-20160816; b=I34orKPgLVTYIAIpMz9r4wvlf7jhIcalhKiEXn3ek5IkzsvouQ456uU9iOxOuomk8E QpOvRBBe1wT+xFqn6fDYHIayPfVNYLlK2vvdN+Zd+xDUjhkdylPbDW+lk81IEOOXBg88 20IbilEZxRdwUZko3+5hxWNKi2Qjj5lVM/Y5lVVr5IPc+H3j4OeJovcXV52v1fBINGPx 4HIWViOrQAtRsExeLStFfRjtrBwMjt+zxFT/yyePfNdu8oBCGNIvqOgocxFaOpmYHy6N w2WLbwZFJjymwbFQs42KPjBnRoqzO5y+xHgUazb9uMTKaPp/ylqV87XVx7OKPM3r6Rdb Wp9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=I95kczr1i3O50JqL7+kQwkJ7u+HXg7tyjRo8o1JwSVc=; b=jaj1FN/JwDtUavLVIKeNmE0e1BZZFWhv+9AImlgzk92jHQa78NggZn8KI8xjLloiQf IIFbJ9s4ajYFTZNxee249FUkoTAzSX2fE4C+4VQM1Ltgl+OgqDWgpMJBK1kwFX964o/N 9DoE1ySFtCFBnJw1Vk3K49athsgv0ZfSQfLtip6WVG6Nw5gGiUwbMlYL6yDtN5pod5TB FGYyyFNeS2xpegEC1v4kpEMze4t0KPxYWbsyaU5Yg4j7bTJrVN+DBQj5Sq/W5Up+pqad r3esPKMcfeIOhQ83dYtu+9X84xdoGXWZwRSrdIlIs/NxerS4g1edL8AOx3u59iEB5U0d WIOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="DZto/Zzt"; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xd5-20020a170907078500b007a9fc5516f6si1371840ejb.307.2022.10.24.05.51.12; Mon, 24 Oct 2022 05:51:44 -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=@linuxfoundation.org header.s=korg header.b="DZto/Zzt"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234277AbiJXMuE (ORCPT + 99 others); Mon, 24 Oct 2022 08:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234587AbiJXMpL (ORCPT ); Mon, 24 Oct 2022 08:45:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF82127919; Mon, 24 Oct 2022 05:09:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6EDA1612F3; Mon, 24 Oct 2022 12:07:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 815FBC433D6; Mon, 24 Oct 2022 12:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613263; bh=hURhAdwU43oF0/Pvc6MdAAwY52fvgvgudcuyGiMZYj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DZto/ZztecsvSDsOyb0dDn2aiqz6/YybrN2IhF8XB39nRpyQcKwiCWgitB8kMICe6 FYpsPxh9MrGsp4XiHz/c8WGA5lpcwc2G7PTlXUYLr53Q030h1pUeECh7qbT6TcImYJ +gdOsCrPqLDjqH1KnojjCnY5fZVRji/vuS67AwsM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanislav Fomichev , Lorenz Bauer , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.4 071/255] bpf: btf: fix truncated last_member_type_id in btf_struct_resolve Date: Mon, 24 Oct 2022 13:29:41 +0200 Message-Id: <20221024113004.874478085@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747573438726394925?= X-GMAIL-MSGID: =?utf-8?q?1747573438726394925?= From: Lorenz Bauer [ Upstream commit a37a32583e282d8d815e22add29bc1e91e19951a ] When trying to finish resolving a struct member, btf_struct_resolve saves the member type id in a u16 temporary variable. This truncates the 32 bit type id value if it exceeds UINT16_MAX. As a result, structs that have members with type ids > UINT16_MAX and which need resolution will fail with a message like this: [67414] STRUCT ff_device size=120 vlen=12 effect_owners type_id=67434 bits_offset=960 Member exceeds struct_size Fix this by changing the type of last_member_type_id to u32. Fixes: a0791f0df7d2 ("bpf: fix BTF limits") Reviewed-by: Stanislav Fomichev Signed-off-by: Lorenz Bauer Link: https://lore.kernel.org/r/20220910110120.339242-1-oss@lmb.io Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- kernel/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index b03087f110eb..a28bbec8c59f 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -2148,7 +2148,7 @@ static int btf_struct_resolve(struct btf_verifier_env *env, if (v->next_member) { const struct btf_type *last_member_type; const struct btf_member *last_member; - u16 last_member_type_id; + u32 last_member_type_id; last_member = btf_type_member(v->t) + v->next_member - 1; last_member_type_id = last_member->type;