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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 C182FC433E3 for ; Fri, 31 Jul 2020 14:22:06 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 929F2208E4 for ; Fri, 31 Jul 2020 14:22:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="A4AXijss" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 929F2208E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4A5F98869E; Fri, 31 Jul 2020 14:22:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z4Angyj+bhZj; Fri, 31 Jul 2020 14:22:05 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id AD6688868D; Fri, 31 Jul 2020 14:22:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 98311C004F; Fri, 31 Jul 2020 14:22:05 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id B0CDCC004D for ; Fri, 31 Jul 2020 14:22:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 98267203C2 for ; Fri, 31 Jul 2020 14:22:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n6CcQjB9SHBp for ; Fri, 31 Jul 2020 14:22:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by silver.osuosl.org (Postfix) with ESMTPS id C8B0320385 for ; Fri, 31 Jul 2020 14:22:02 +0000 (UTC) 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 DF1D2208E4; Fri, 31 Jul 2020 14:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596205322; bh=xOTUdTDtgFUE4tg3a96EHIpYVqLyrjXL2vfmrZmnmXk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A4AXijssIn9cJbmiigc2HnNHygj6LDX7SwRcO35y32gJ28dLyviyTLEowdbRQMFJH BICWi9NGqq7lv+plJy4BfbNlrvKnXbC3cv6D8jG5Iz7ArVn3YkA56UJKbZaespigHT izydEL7WKrOkda8awf2v5WwNko1uMTUmGdcPFhDk= Date: Fri, 31 Jul 2020 16:21:48 +0200 From: Greg Kroah-Hartman To: Jason Gunthorpe Message-ID: <20200731142148.GA1718799@kroah.com> References: <20200730192026.110246-1-yepeilin.cs@gmail.com> <20200731045301.GI75549@unreal> <20200731053306.GA466103@kroah.com> <20200731053333.GB466103@kroah.com> <20200731140452.GE24045@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200731140452.GE24045@ziepe.ca> Cc: rds-devel@oss.oracle.com, Arnd Bergmann , Leon Romanovsky , linux-rdma@vger.kernel.org, netdev@vger.kernel.org, Santosh Shilimkar , linux-kernel@vger.kernel.org, "David S. Miller" , Jakub Kicinski , linux-kernel-mentees@lists.linuxfoundation.org, Peilin Ye , Dan Carpenter Subject: Re: [Linux-kernel-mentees] [PATCH net] rds: Prevent kernel-infoleak in rds_notify_queue_get() X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" On Fri, Jul 31, 2020 at 11:04:52AM -0300, Jason Gunthorpe wrote: > On Fri, Jul 31, 2020 at 07:33:33AM +0200, Greg Kroah-Hartman wrote: > > On Fri, Jul 31, 2020 at 07:33:06AM +0200, Greg Kroah-Hartman wrote: > > > On Fri, Jul 31, 2020 at 07:53:01AM +0300, Leon Romanovsky wrote: > > > > On Thu, Jul 30, 2020 at 03:20:26PM -0400, Peilin Ye wrote: > > > > > rds_notify_queue_get() is potentially copying uninitialized kernel stack > > > > > memory to userspace since the compiler may leave a 4-byte hole at the end > > > > > of `cmsg`. > > > > > > > > > > In 2016 we tried to fix this issue by doing `= { 0 };` on `cmsg`, which > > > > > unfortunately does not always initialize that 4-byte hole. Fix it by using > > > > > memset() instead. > > > > > > > > Of course, this is the difference between "{ 0 }" and "{}" initializations. > > > > > > Really? Neither will handle structures with holes in it, try it and > > > see. > > > > And if true, where in the C spec does it say that? > > The spec was updated in C11 to require zero'ing padding when doing > partial initialization of aggregates (eg = {}) > > """if it is an aggregate, every member is initialized (recursively) > according to these rules, and any padding is initialized to zero > bits;""" But then why does the compilers not do this? > The difference between {0} and the {} extension is only that {} > reliably triggers partial initialization for all kinds of aggregates, > while {0} has a number of edge cases where it can fail to compile. > > IIRC gcc has cleared the padding during aggregate initialization for a > long time. Huh? Last we checked a few months ago, no, it did not do that. > Considering we have thousands of aggregate initializers it > seems likely to me Linux also requires a compiler with this C11 > behavior to operate correctly. Note that this is not an "operate correctly" thing, it is a "zero out stale data in structure paddings so that data will not leak to userspace" thing. > Does this patch actually fix anything? My compiler generates identical > assembly code in either case. What compiler version? thanks, greg k-h _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees