From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50558C4332D for ; Fri, 20 Mar 2020 15:46:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18B6520781 for ; Fri, 20 Mar 2020 15:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584719197; bh=vGKLtExp+TztSBVJmqOiwJhtSCSDjoH/BogaZKD2yIM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=d+itYb/jSSo7o6wvotKTmM3QPQH5TljLFXTT4CMoKhN/Ce8a9oMEmFWIE64qno6bq tRdw89tU7aduwj3+aIzdXyI/o/+OUU9F1wmgc40UZXOP6SpZ9sKnnDFw505pPgA8Ut ssVI7L7xZQk+LaDPj+tGiMS1f4H2yrwtpw6tcxLI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbgCTPqg (ORCPT ); Fri, 20 Mar 2020 11:46:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:39338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbgCTPqg (ORCPT ); Fri, 20 Mar 2020 11:46:36 -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 8A9FA2070A; Fri, 20 Mar 2020 15:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584719196; bh=vGKLtExp+TztSBVJmqOiwJhtSCSDjoH/BogaZKD2yIM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mMnfAdxQ8RgtNr+kx0OS0w+LnS2wzxEm0xMsW9/nqpCR8sP7FQvkjy9HpshXTFsYS UZ57JlyU3Euog+h3fcumSH+k0Dm9dacH8xMo8L1JTjF9A26Cj5hjPxlUkGreNH/Nzy ry9eMyzvl0/XO4ysV3oBGXd8UsqVkdYn8YXNWEs0= Date: Fri, 20 Mar 2020 16:46:33 +0100 From: Greg Kroah-Hartman To: Yonghong Song Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Andrii Nakryiko , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Maciej =?utf-8?Q?=C5=BBenczykowski?= , John Stultz , Alexander Potapenko , Alistair Delva Subject: Re: [PATCH] bpf: explicitly memset the bpf_attr structure Message-ID: <20200320154633.GB765793@kroah.com> References: <20200320094813.GA421650@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Fri, Mar 20, 2020 at 08:23:57AM -0700, Yonghong Song wrote: > > > On 3/20/20 2:48 AM, Greg Kroah-Hartman wrote: > > 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. > > Maybe add more contexts about the failure itself so it could be clear > why we need this patch. I didn't have the full details, I think Maciej has them though. > As far as I know from the link below, the failure happens in > CHECK_ATTR() which checks any unused *area* for a particular subcommand > must be 0, and this patch tries to provide this guarantee beyond > area beyond min(uattr_size, sizeof(attr)). That macro also will get tripped up if padding is not zeroed out as well, so this is good to fix up. thanks for the review. greg k-h