Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3288375ybb; Tue, 31 Mar 2020 02:10:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vub9j0AnvWeh2FFUVU7I3khuPylhXl31rT/fxKYSh4IRQLmJzL5A3R9DC3ZLzEOAcWW6dWl X-Received: by 2002:aca:4843:: with SMTP id v64mr1354876oia.13.1585645807669; Tue, 31 Mar 2020 02:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645807; cv=none; d=google.com; s=arc-20160816; b=wC4niHz+2IsTMRvZIUZoyRUiVLPvcgpe7dix2aJRt30w9b25WiK9qzzXKQ/V+vL3Wq 1zHL1YLMpegTY+LEt1vBzp7NdSKs8w9GgMP3t+FAg+KIPEMQke7RR7sxtR7eVVht2Sfa O2BqOXOsUv/BqFUlIwn0UoaLe4neKV+zSEfVMHoWj5Tw9hKtuusWnc/f+RzzaRQNcG49 X9TUTrY0S249xlKbOIjJa9+/GxHllZAWKssVsAnf4M6sEU48e7VKbqHxYbiNh+V57t5x GeABqqjbkNiYvVcbzspGk+QX9BlJAcGIqASCP2UltOqz7OvCZ5VIOpTbVlOsc1g7187Y jZ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+mF4q6zEXvqKMTKnFHosHE6b1JjE+DqJZR78qKMcDpo=; b=WuBaS4ettwixs/ReZmPabOPpoiM+TV77piNLRk+UKn/EZLzeV9urJHV5pVlaucK8Xz jM1P7bcEHt63OB6Yd+5WQZRPF/kDCwHftY7cmmJ+WP4GZ4IVgb9nYS/r7Hox29I/RI4Z sKLJyRY0RTX08AkETq0KE5CwzoGPiL0PTPedUGVAbhmWt7EwQlwXwGIeNr8Mv8NttiCb NvXb9ZbHTs+udBROuwORWIkFmk9B8vWQwiL/toHJo2lAGxumZV4QIbHHPdLeSdnV0d/Q 8hEEJ8O++a3b10p0GutlPAfLl4awYP2ZALwYfAFM+mIpaWfVWew+G0FimXLvZ4QrhLK5 EhCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CCfPeCgN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s199si6833140oih.169.2020.03.31.02.09.55; Tue, 31 Mar 2020 02:10:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CCfPeCgN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731359AbgCaJIl (ORCPT + 99 others); Tue, 31 Mar 2020 05:08:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730570AbgCaJIj (ORCPT ); Tue, 31 Mar 2020 05:08:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 139DE20787; Tue, 31 Mar 2020 09:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645719; bh=5lEnXrhdbHoYrpi5vExKkw+JGG6lV/ILVTNMrG4/8NI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CCfPeCgNkk9iW0unTynbj6GLFXbTE0Qfe9vQbVkiwtN+y34LV2gs/wBy+iDUhxcwP BC7cpBRZAHYFQQ+WXWN1/UfpJn6G9FTTTW1NEMXbaVyXunMXPoAqsIv9qh2SAax+Ob G0rttMkxCbvwoxU6O1lI2LcIvi4I+VSGcZP7Rlcs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yoshiki Komachi , Alexei Starovoitov Subject: [PATCH 5.5 142/170] bpf/btf: Fix BTF verification of enum members in struct/union Date: Tue, 31 Mar 2020 10:59:16 +0200 Message-Id: <20200331085438.478750978@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yoshiki Komachi commit da6c7faeb103c493e505e87643272f70be586635 upstream. btf_enum_check_member() was currently sure to recognize the size of "enum" type members in struct/union as the size of "int" even if its size was packed. This patch fixes BTF enum verification to use the correct size of member in BPF programs. Fixes: 179cde8cef7e ("bpf: btf: Check members of struct/union") Signed-off-by: Yoshiki Komachi Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/1583825550-18606-2-git-send-email-komachi.yoshiki@gmail.com Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -2383,7 +2383,7 @@ static int btf_enum_check_member(struct struct_size = struct_type->size; bytes_offset = BITS_ROUNDDOWN_BYTES(struct_bits_off); - if (struct_size - bytes_offset < sizeof(int)) { + if (struct_size - bytes_offset < member_type->size) { btf_verifier_log_member(env, struct_type, member, "Member exceeds struct_size"); return -EINVAL;