From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755802AbcETQpT (ORCPT ); Fri, 20 May 2016 12:45:19 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:50833 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751331AbcETQpR (ORCPT ); Fri, 20 May 2016 12:45:17 -0400 Date: Fri, 20 May 2016 09:45:15 -0700 (PDT) Message-Id: <20160520.094515.288573467665398547.davem@davemloft.net> To: vegard.nossum@gmail.com Cc: jslaby@suse.cz, stable@vger.kernel.org, linux-kernel@vger.kernel.org, kangjielu@gmail.com, kjlu@gatech.edu Subject: Re: [PATCH 3.12 69/76] net: fix infoleak in rtnetlink From: David Miller In-Reply-To: References: <3248734d04fe4140b66aca5ce0372d7eae093293.1463648873.git.jslaby@suse.cz> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 20 May 2016 09:45:16 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vegard Nossum Date: Fri, 20 May 2016 14:04:54 +0200 > Just out of curiosity, was this observed in practice? I could be > wrong, but I was under the impression that using designated > initializers would zero the rest of the struct, including padding. I compiled testcases and found that the compiler does not zero out padding when using designated initializers. You can do the same. For example, on sparc 32-bit, this code: struct foo { int a; short b; int c; }; extern void foo(struct foo *); void bar(void) { struct foo f = { .a = 1, .b = 2, .c = 3 }; foo(&f); } gives: mov 1, %g1 st %g1, [%fp-12] mov 2, %g1 sth %g1, [%fp-8] mov 3, %g1 st %g1, [%fp-4] It does not initialize the padding between 'b' and 'c'.