Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp849282pja; Wed, 1 Apr 2020 09:48:28 -0700 (PDT) X-Google-Smtp-Source: APiQypLi5CWLStCc0g91DmbTTcp/ORP5lrF/8fq0BdWwS4PDKwJqKIvBnco4Bb074+HODZSQEC63 X-Received: by 2002:aca:1303:: with SMTP id e3mr3449597oii.36.1585759708838; Wed, 01 Apr 2020 09:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585759708; cv=none; d=google.com; s=arc-20160816; b=kQ2QS+0igbdGT3l7cBbRJ+rh4xHRGw5qx0Gm+TD9aMd7gnEclAV5ABd0Y9Tk0Z0LvY 0vNYC/QiNyhunN8AllkmAbIsqzulAhItlfzrVS+kyY+iaY49v0RqlTY5YPOcNf+ozYk/ HkZpG+YENqN3+kerG3TRuuflX+IiWZDC03H/hLxjSxf3R1qch/8hO/G+0pU3P6x8lX/b Sai1prEGmys9AaHQp+56FQe6+NCdm4KbxPrzyzkc4GHfNc/S9FjuQSHTDd9LUwtfqWwt i0ymHF/+6yyNF2862mAGsZa0xaUqz25uGNezNxpthLKZazBExSPlb10Gliw/4MuKn+M0 ZPXw== 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=x/G9oHSAF+boh1MsvSFTJYkz3jTDwvBjbeRvE6+vagg=; b=cGEi6zNO/7YlDEwZb6VZjxldJ4SEGuz06qJUZ/27PHImz4/z13PFXK5NxxRYRVOOJN nrAF+2Wfqs2YIGROzmy5Lt50FT4RrBGoC0dAldZ0iPt6LusPtQ3ppMEwvJN7YITnUt+j V98EvL/fhtSnqV6JB6d98YqIhtO0AWiPSsr5yZuNA4NlqDJdFaTYAj53l6GfC0tG6evY h9uTFqZ3fT6sg2HnEu0lJh+CvniQrEsV4KCqhOSOHsg4ptPsY5yGfdWk6xOn1WrfdNT4 yDxFYQ4lKFGjW6f8i3FhCuwu6c7O7a6KuZqxM9zo0op2ka+q0fAoex/j1ZnFdP4/gE0t lSxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rSQQo2D7; 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 n4si1081551oie.121.2020.04.01.09.48.15; Wed, 01 Apr 2020 09:48:28 -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=rSQQo2D7; 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 S2389690AbgDAQrK (ORCPT + 99 others); Wed, 1 Apr 2020 12:47:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:48858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389723AbgDAQrK (ORCPT ); Wed, 1 Apr 2020 12:47:10 -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 E652B206E9; Wed, 1 Apr 2020 16:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759629; bh=JlDBYbueVX9HaVgltnLZvM2z5YurHeXCEuSgcZCEEo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rSQQo2D78EaxdV/vS1drZWM4tLPJS3BePf0CKsz84TXOePOKHMZNNTENRH0Y4jaCW kXbAlEl2TB9x87uRdxS3vKLLsB3sYVQ9SQg8ggh+5TPzsRiyDhBQXRK2DhlGPi1xfk aLixAqFJUmmIFXrmRY8oW2vFJ92KpHwmwpFWPuxo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Borkmann , Yonghong Song Subject: [PATCH 4.14 140/148] bpf: Explicitly memset some bpf info structures declared on the stack Date: Wed, 1 Apr 2020 18:18:52 +0200 Message-Id: <20200401161605.620622049@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161552.245876366@linuxfoundation.org> References: <20200401161552.245876366@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: Greg Kroah-Hartman commit 5c6f25887963f15492b604dd25cb149c501bbabf upstream. Trying to initialize a structure with "= {};" will not always clean out all padding locations in a structure. So be explicit and call memset to initialize everything for a number of bpf information structures that are then copied from userspace, sometimes from smaller memory locations than the size of the structure. Reported-by: Daniel Borkmann Signed-off-by: Greg Kroah-Hartman Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20200320162258.GA794295@kroah.com Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/syscall.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1364,7 +1364,7 @@ static int bpf_prog_get_info_by_fd(struc union bpf_attr __user *uattr) { struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info); - struct bpf_prog_info info = {}; + struct bpf_prog_info info; u32 info_len = attr->info.info_len; char __user *uinsns; u32 ulen; @@ -1375,6 +1375,7 @@ static int bpf_prog_get_info_by_fd(struc return err; info_len = min_t(u32, sizeof(info), info_len); + memset(&info, 0, sizeof(info)); if (copy_from_user(&info, uinfo, info_len)) return -EFAULT; @@ -1420,7 +1421,7 @@ static int bpf_map_get_info_by_fd(struct union bpf_attr __user *uattr) { struct bpf_map_info __user *uinfo = u64_to_user_ptr(attr->info.info); - struct bpf_map_info info = {}; + struct bpf_map_info info; u32 info_len = attr->info.info_len; int err; @@ -1429,6 +1430,7 @@ static int bpf_map_get_info_by_fd(struct return err; info_len = min_t(u32, sizeof(info), info_len); + memset(&info, 0, sizeof(info)); info.type = map->map_type; info.id = map->id; info.key_size = map->key_size;