Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp836560pja; Wed, 1 Apr 2020 09:35:04 -0700 (PDT) X-Google-Smtp-Source: APiQypKCx5dajKeQm3h7JcvDD54yN/zAHmqB+KqZu9dbBNwgWYeOnOHoUHRpdBz8rdrPgPv6O7oV X-Received: by 2002:a54:478a:: with SMTP id o10mr3540752oic.45.1585758904643; Wed, 01 Apr 2020 09:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585758904; cv=none; d=google.com; s=arc-20160816; b=MZwLsFu8AGAzzAxGLBiADt6w+tTxhFtuy1RQAv2CvKdMa+PPQCnPlETdvBZWRcNpF+ UpjO8PVvad2R3488vvs/pRphuNuznGto4tI584goy1MojcU/JK2eUXhIRxa9xQsCvDsv 9azV2CJp/7kBKxEySvvP8SbOi+8yU/a7Vk9CvN7KtzK2/NswY13rBpm0BKZlXnJINMGy rp2J/T/l18u5gdC52LDAIHb1mkrE3S+vx3mtWC/zpFyywPHBEAjL/OBJJ36yJM9/vcYi j3mEOWdh7cEJbQh/OppTzQbTBVwd+avB8bYVqdfln9CFtuGaZFgeFcjtmuWYuFMPJOb5 c4fw== 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=Ik3d7qZglUrFJXlV2Qh1nqUICTPDgQvo9BNCtLU42sc=; b=kfY0IJDWQIWsoTQ4xFTy75CKHJW+UFU28hOnb6BJDQO19w8pe3ZfT3hO+g91C47JIQ Z09VBkDEnLqSFi89tMU6/yN78ejHZ0pe3FUsv0MxF+pzBIHqe+t16qBR/AnnJGia6gEB +83p4n0SrDdvNRlnCJAdyszRr7BEC/A2644JML/CkgrpS8RsZUVWBIqocR2i++FCK3EZ YiO5FM5VRREt5fp3IjMjMnuiw9Y697HI4vdtWcf/R/rmaVlajFkmtJuFckyzP0hMsnb4 T3QK21AmNJTt8hyA3Vsou4otugpA1SIXc5iN8/CU9OvoSpz1WbwA8/DHfhQz32kaxZC3 kfJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=djLpVWer; 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 l4si924063otf.195.2020.04.01.09.34.51; Wed, 01 Apr 2020 09:35:04 -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=djLpVWer; 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 S2388610AbgDAQd6 (ORCPT + 99 others); Wed, 1 Apr 2020 12:33:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:60560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388359AbgDAQd4 (ORCPT ); Wed, 1 Apr 2020 12:33:56 -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 C65E920658; Wed, 1 Apr 2020 16:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758835; bh=yXadSQ9F2tnMwUrUijn2sYpFTDOy+4AoejV+z9xvtvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djLpVWerAgXAmcUJoHUpPBHeiGiFRhlMm4B0OT8QarckTuAhyFqlDxMtRJOMZqgFZ Tjb5Od8B6tv5TIBvkMPdBGL+mtNRT8tJ1Ptjyz7uSq+nYS/3dnfVVEsbMBSzf48QEG vBYD9Zsan24b2EMJVV2EMdfgKbT5o9Je6SWV0MFQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Maciej=20=C5=BBenczykowski?= , John Stultz , Alexander Potapenko , Alistair Delva , Daniel Borkmann , Yonghong Song Subject: [PATCH 4.4 89/91] bpf: Explicitly memset the bpf_attr structure Date: Wed, 1 Apr 2020 18:18:25 +0200 Message-Id: <20200401161540.336640428@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161512.917494101@linuxfoundation.org> References: <20200401161512.917494101@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 8096f229421f7b22433775e928d506f0342e5907 upstream. For the bpf syscall, we are relying on the compiler to properly zero out the bpf_attr union that we copy userspace data into. Unfortunately that doesn't always work properly, padding and other oddities might not be correctly zeroed, and in some tests odd things have been found when the stack is pre-initialized to other values. Fix this by explicitly memsetting the structure to 0 before using it. Reported-by: Maciej Żenczykowski Reported-by: John Stultz Reported-by: Alexander Potapenko Reported-by: Alistair Delva Signed-off-by: Greg Kroah-Hartman Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Link: https://android-review.googlesource.com/c/kernel/common/+/1235490 Link: https://lore.kernel.org/bpf/20200320094813.GA421650@kroah.com Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -667,7 +667,7 @@ static int bpf_obj_get(const union bpf_a SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size) { - union bpf_attr attr = {}; + union bpf_attr attr; int err; if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN)) @@ -703,6 +703,7 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf } /* copy attributes from user space, may be less than sizeof(bpf_attr) */ + memset(&attr, 0, sizeof(attr)); if (copy_from_user(&attr, uattr, size) != 0) return -EFAULT;