From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Am=C3=A9rico?= Wang Subject: Re: [PATCH v2] fs: select: fix information leak to userspace Date: Tue, 23 Nov 2010 22:01:11 +0800 Message-ID: <20101123140111.GA3816@hack> References: <1289421483-23907-1-git-send-email-segooon@gmail.com> <20101112120834.33062900.akpm@linux-foundation.org> <8D90F8B2-EA29-4EB9-9807-294CE0D5523B@dilger.ca> <20101114092533.GB5323@albatros> <20101114180643.593d19ac.akpm@linux-foundation.org> <1289848341.2607.125.camel@edumazet-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Andrew Morton , Vasiliy Kulikov , Andreas Dilger , kernel-janitors@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Jelinek To: Eric Dumazet Return-path: Received: from mail-gx0-f174.google.com ([209.85.161.174]:40799 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456Ab0KWN6O (ORCPT ); Tue, 23 Nov 2010 08:58:14 -0500 Content-Disposition: inline In-Reply-To: <1289848341.2607.125.camel@edumazet-laptop> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Nov 15, 2010 at 08:12:21PM +0100, Eric Dumazet wrote: >Le dimanche 14 novembre 2010 =C3=A0 18:06 -0800, Andrew Morton a =C3=A9= crit :=20 >> On Sun, 14 Nov 2010 12:25:33 +0300 Vasiliy Kulikov wrote: >> > =20 >> > if (timeval) { >> > - rtv.tv_sec =3D rts.tv_sec; >> > - rtv.tv_usec =3D rts.tv_nsec / NSEC_PER_USEC; >> > + struct timeval rtv =3D { >> > + .tv_sec =3D rts.tv_sec, >> > + .tv_usec =3D rts.tv_nsec / NSEC_PER_USEC >> > + }; >> > =20 >> > if (!copy_to_user(p, &rtv, sizeof(rtv))) >> > return ret; >>=20 >> Please check the assembly code - this will still leave four bytes of >> uninitalised stack data in 'rtv', surely. > >Thats a good question. > >In my understanding, gcc should initialize all holes (and other not >mentioned fields) with 0, even for automatic storage [C99 only mandate= s >this on static storage] > >I tested on x86_64 and this is the case, but could not find a definiti= ve >answer in gcc documentation. > Yeah, this is not clearly defined by C99 I think, but we can still find some clues in 6.2.6.1, Paragraph 6, " When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified values. " So we can't rely on the compiler to initialize the padding bytes too. --=20 Live like a child, think like the god. =20 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html