From owner-freebsd-arch@FreeBSD.ORG Fri May 6 19:44:17 2005 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 274A916A4D4 for ; Fri, 6 May 2005 19:44:17 +0000 (GMT) Received: from isilon.com (isilon.com [65.101.129.58]) by mx1.FreeBSD.org (Postfix) with SMTP id A988A43D8B for ; Fri, 6 May 2005 19:44:16 +0000 (GMT) (envelope-from neal@isilon.com) Received: (qmail 86285 invoked by uid 1001); 6 May 2005 19:43:51 -0000 Date: Fri, 6 May 2005 12:43:51 -0700 From: Neal Fachan To: Alexander Kabaev Message-ID: <20050506194351.GB68900@isilon.com> References: <20050504180112.M18611@mail.chesapeake.net> <20050505025509.GA3120@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050505025509.GA3120@freefall.freebsd.org> User-Agent: Mutt/1.4.1i cc: arch@freebsd.org Subject: Re: printflike vs kprintflike X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2005 19:44:17 -0000 On Thu, May 05, 2005 at 02:55:10AM +0000, Alexander Kabaev wrote: > On Wed, May 04, 2005 at 06:16:06PM -0400, Jeff Roberson wrote: > > I have a patch from Neal Fachan of isilon that implements a new gcc > > attribute 'kprintflike' that is used in place of 'printflike' in the > > kernel. This is done to stop us from leaking kernel printf formats into > > userspace. Apparently -fformat-extensions is broken in gcc3. This also > > stops our formats from leaking into any other custom formats defined in > > gcc. > > > > I would like to avoid introduction of a new printf attribute if possible. > Does fixed -fformat-extensions suffice your needs? If so, can you try the > patch below instead? I assume that you're interested in not changing all the __printflike's to __kprintflike's? That seems like a good goal, and it certainly eases upgrading. The are a few problems with your patch. First, as Bruce points out, there are other differences between the kernel's printf and userspace's printf. One difference is that the floating point formats aren't supported. Another is that some of the flags are different (' ' isn't supported, for example). The second problem is the explicit checks for 'b' and 'D' later in check_format_info_main. These checks remove the first argument (of two) for these format specifiers. However, if there is another format type which also uses either of these characters, there will be a conflict (strftime's %D, for example). How about the approach of having two different format tables (format_kind_info's), one for kprintf and one for printf, and then choosing the appropriate one based on the flag_format_extensions? I'll code something up today and send a patch. Thanks. -Neal -- Neal Fachan neal@isilon.com