From patchwork Mon Oct 24 11:29:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp423128wru; Mon, 24 Oct 2022 05:24:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QcL8oI7kKq7QLnSvbKq9ESlK2GaBXHXS2L6eW3LEMBtQ53B5wgJS75vfpyQnCAGoCaVJp X-Received: by 2002:a05:6402:380a:b0:451:ae08:7a6c with SMTP id es10-20020a056402380a00b00451ae087a6cmr29664421edb.161.1666614250111; Mon, 24 Oct 2022 05:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614250; cv=none; d=google.com; s=arc-20160816; b=MKCMuLuL7serY/CtIMPH6PcNf67m5FenkVCpprqs+ZwKZXG51iB1RiB7lgoQUj7H8c PqZJU5RjAZBPSawEkRzma6ReBJi9C52/oFY9mSTCSQL+L9wJWL/pHj727VNv8LNnXic2 Dlz+keHsT6njaBa0tm7AIYZGnwJj4SJt6sgLN0K6UzborvjpEBWMLgmJPkuoCPS3WMuJ gTvWkVXVWrINrkIJKYOj/0tpjSQW1aEpOBB43MojMNVtferklD8fMnZIDyZubRYInMJD 5BIsy7bCcuLhKbTPpcPEzUVWXPSVSwncVL+NQ512ca1XcDla15ZeM2W7Gn/Jy3qB8fBO bkAQ== 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=GuY8afL5pN2SYI0faU62yLXnulX5b35r9uAlsCLvo0s=; b=MnKGiwj7dwMpUH05gECssQalErZXNt+dWA4iBCnIdFj9A7C+AKelETV6fjeAEd9YoC lE6lmm7tHM4+MpJG9IO236Z9BzXeIleMFvfxP2xQvbInzrxB3mEu1P2cW2qI2fpah7ZZ stKQz3NAzMwjBbMxkxUagtFKltl/d9XRBYuwWWrQROoEzfS/v9e4wF84/D7+QhA/Vd7z 2i4yyaUCldk5ojfiW5fXlEQPDL7pN35sPQabL06D6x1v/A5JlPT61Q3ozYZLmPfVaRfL IcC8HQsvXiUKJ67ldZeGYnn82RkWuNeR3ID73LdcEWjtw4ip8dz3szDwBoOj+jINIoVE S0bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PXVcrBkg; 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 e22-20020a1709067e1600b0073da5c8de1asi25730282ejr.178.2022.10.24.05.23.44; Mon, 24 Oct 2022 05:24:10 -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=PXVcrBkg; 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 S233527AbiJXMWo (ORCPT + 99 others); Mon, 24 Oct 2022 08:22:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233242AbiJXMUT (ORCPT ); Mon, 24 Oct 2022 08:20:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C91E7C1AD; Mon, 24 Oct 2022 04:59:02 -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 A468A612C5; Mon, 24 Oct 2022 11:58:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5CAAC433D6; Mon, 24 Oct 2022 11:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612685; bh=mjCwChMoj0gYfMSKB/1bs/M2Mqi6HjkqAeGsiTHVQ1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PXVcrBkg3n+V3dfWIyv7JHmlwjjuKH37UFD9s9DuulHuqay6Zdn73E3b3eX8BG/8U XtJ0YE+Wi8QIXdLx1Gah1k2CU9Ek53YAxMIRE/o8t7R8q6EvbSFMOE2VtIp0RhlYSM sM0D1f/SmTLnSHqJ+DGXvTbGlujEQOhWuRmxxpQE= 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 4.19 079/229] bpf: btf: fix truncated last_member_type_id in btf_struct_resolve Date: Mon, 24 Oct 2022 13:29:58 +0200 Message-Id: <20221024113001.628698887@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747571704246651247?= X-GMAIL-MSGID: =?utf-8?q?1747571704246651247?= 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 471cc5c117a5..62e05b6283c0 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -1660,7 +1660,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;