From patchwork Sat Oct 22 07:21:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1093787wrr; Sat, 22 Oct 2022 00:58:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4558gJrC+lyerTyzE/WwQK3jy+1zWWjbxJdxpJbtTAsAj1+blbTeHhUKhhEzqLUxZYjqgG X-Received: by 2002:a63:5761:0:b0:46e:b96b:e76 with SMTP id h33-20020a635761000000b0046eb96b0e76mr6090236pgm.534.1666425507650; Sat, 22 Oct 2022 00:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425507; cv=none; d=google.com; s=arc-20160816; b=ZrxnzQiVS0r6JGMnWJBnkTAZqXnQNwlwsipnaNJoozU9s1KfXMvkayH03XvJ7WC2Cu 5G+5yUHTjBp8Jwn0nkNXY4MUtd6KMKgu0ptHLjlaxrs03GaQVEHvub6nFpI0ISM+ZuI4 JxhbclYVBF2VmqXU4pYIP6ngtPvCwmMZceNVVVx0KMTM7Oy1hpJH8BNaRUcbqy4HeJYe EQKwKnrcKLugHebZsgZS9PpdwJDYzVUP8Py5EvuFF2fzjpoU3QPyVzA31gbkMU3AP99i 1HWyOdZVjQJVOXvIH6gDPaxg+d1Ubtye6JZgaT/MgmP1nRvgwOXzZVEgMYAi2aoYZ+2t Bvig== 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=M1IPAKMUprGqsVJstMfZhbO18vPQhnjxgASwvhxA6hg=; b=PpQTNFCzoIQZ/u6rriIs5Nb+9ID+T4puWQGnrocITqx0zjaci9nLrKNx4ND7kTBbhE +AtyXD0u4OLhI93eUGyrS6MvAQDs1rQj7njncn9gQe+o74Z5DfHrpg+tcyAR84tqYYMb YyFpmSMgWoZpy09kE4Zmj44FrWNAyXEPLMsh0ehT4E7Gs4WNx5ftLJ3vRNg6GfxeBTGK pZQw0HicgZmKQyOhDhFS1V3bkztE/ay7NG6l9v+CguaDdL+rFe/P+TmpoxwFRJf0dApl bMkX91Z9bWf3OlBNIb24BM26bwcFNbw11nfp1KT0Tx5uJFdlRpHp3xTpY75T9sUrHuZo tbDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SlsCcCqz; 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 x15-20020a056a00188f00b00542f9f272ffsi31892495pfh.18.2022.10.22.00.58.14; Sat, 22 Oct 2022 00:58:27 -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=SlsCcCqz; 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 S232341AbiJVH5l (ORCPT + 99 others); Sat, 22 Oct 2022 03:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbiJVHxn (ORCPT ); Sat, 22 Oct 2022 03:53:43 -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 EAB4F2CA7F8; Sat, 22 Oct 2022 00:47:01 -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 F20B760B43; Sat, 22 Oct 2022 07:45:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14033C433D6; Sat, 22 Oct 2022 07:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424753; bh=TJ2z8sKjOboAwl+iRlgwNORc3olWsnilEuqNtwDNJQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SlsCcCqzXltBBqs9UpK62k9WOji7a/dSaXd/Jad8/4XT4frmFyMetkyH+vvakEgN4 +AQLQboNSjYwq9/wCKkVGzRJllnGSdvbtXFa+8kvxpolXWf4P364Ikyp0mm4oLZaJo Lx/QOB7RD8ZDCRvm6OQbtm7tienOY8H8mAGoE50I= 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.19 234/717] bpf: btf: fix truncated last_member_type_id in btf_struct_resolve Date: Sat, 22 Oct 2022 09:21:53 +0200 Message-Id: <20221022072456.420768790@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373793228365356?= X-GMAIL-MSGID: =?utf-8?q?1747373793228365356?= 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 eb12d4f705cc..ff4a2c0b14ea 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -3120,7 +3120,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;