From patchwork Mon Jun 4 08:15:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 162673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D81C0B707C for ; Mon, 4 Jun 2012 18:16:11 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1339402572; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=djaOSRJ h+VUrxmLMk9flsEIkoWs=; b=sOmhbGkXOYufWJlEpwBQp+Z9/UGlyX95Qai1AgX xMYpU11ILX01WEZrE9uSgmc8jnJrQ3+y+WnaRVY65nG1awQby11TEw4t67YuoYM9 uaRzF9yFJzX4E9FyB6bX7yUsSy+u3a1i7RImZ2dLYmUpuNIB5oR/kQ/VKwn+p5kA A7RA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Bav2L56rwUDwijYr8jhUKe/jI5ihAAGdyKPlSbrG5OIyd4ula8BgYJcQCdOn6j NHAZBuvTSlYZSQ5im4yyXJvxfYMPZrLzaeSKdgIUE/bcUFhAHqYVaGAWAitGjklW liX5DmtGtmfSAgUlkaUq7uQ2sjCj7sOccdsyDONrTaCJo=; Received: (qmail 741 invoked by alias); 4 Jun 2012 08:16:05 -0000 Received: (qmail 721 invoked by uid 22791); 4 Jun 2012 08:16:03 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Jun 2012 08:15:38 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q548FbaB030725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Jun 2012 04:15:38 -0400 Received: from dhcp-5-241.str.redhat.com (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q548FaMw019605 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 4 Jun 2012 04:15:37 -0400 Message-ID: <4FCC6EA7.4060507@redhat.com> Date: Mon, 04 Jun 2012 10:15:35 +0200 From: Florian Weimer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [Doc] Add caveat to __builtin_object_size X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch adds a cross-reference to GNU libc and _FORTIFY_SOURCE (which needs to be documented there) and mentions the optimization level requirements. Okay for trunk? 2012-06-04 Florian Weimer * doc/extend.texi (Object Size Checking): Mention _FORTIFY_SOURCE, add caveat. Index: gcc/doc/extend.texi =================================================================== --- gcc/doc/extend.texi (revision 187951) +++ gcc/doc/extend.texi (working copy) @@ -7376,8 +7376,15 @@ @findex __builtin___vfprintf_chk GCC implements a limited buffer overflow protection mechanism -that can prevent some buffer overflow attacks. +that can prevent some buffer overflow attacks. GNU libc uses it +in the implementation of the @code{_FORTIFY_SOURCE} functionality. +This protection mechanism is only a last resort. As a programmer, you +must not rely on its presence, but use explicit buffer length checks +to avoid buffer overflows. GCC may not be able to determine buffer +sizes accurately, and the accuracy depends on compiler version and +optimization level (currently, at least @option{-O2} is required). + @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type}) is a built-in construct that returns a constant number of bytes from @var{ptr} to the end of the object @var{ptr} pointer points to