From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 204323858D20 for ; Wed, 9 Feb 2022 09:18:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 204323858D20 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-e_wAypI4MXmAvC_e4zGUpA-1; Wed, 09 Feb 2022 04:18:20 -0500 X-MC-Unique: e_wAypI4MXmAvC_e4zGUpA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 764C33E753; Wed, 9 Feb 2022 09:18:19 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD16A27BCB; Wed, 9 Feb 2022 09:18:18 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 2199IFAS1086165 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 9 Feb 2022 10:18:16 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 2199IE4b1086164; Wed, 9 Feb 2022 10:18:14 +0100 Date: Wed, 9 Feb 2022 10:18:14 +0100 From: Jakub Jelinek To: Richard Biener Cc: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] ubsan: Separate -f{,no-}delete-null-pointer-checks from -fsanitize={null,{,returns-}nonnull-attribute} [PR104426] Message-ID: <20220209091814.GM2646553@tucnak> Reply-To: Jakub Jelinek References: <20220209084713.GK2646553@tucnak> <24n8422o-osp8-4s44-n9r6-p76sq33444ns@fhfr.qr> MIME-Version: 1.0 In-Reply-To: <24n8422o-osp8-4s44-n9r6-p76sq33444ns@fhfr.qr> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Feb 2022 09:18:23 -0000 On Wed, Feb 09, 2022 at 10:03:02AM +0100, Richard Biener wrote: > I see there are still targets doing sth like > > static void > msp430_option_override (void) > { > /* The MSP430 architecture can safely dereference a NULL pointer. In > fact, > there are memory mapped registers there. */ > flag_delete_null_pointer_checks = 0; Sure, that is the typical embedded target case. And the user option is in case users are using a typically non-embedded target case in an embedded way, even on x86_64-linux one can mmap something at address 0 if one tweaks some kernel config parameters. I guess I could change default_addr_space_zero_address_valid from return false; to if (!flag_delete_null_pointer_checks) return true; if (folding_initializer) return false; if (current_function_decl && sanitize_flags_p (SANITIZE_NULL | SANITIZE_NONNULL_ATTRIBUTE | SANITIZE_RETURNS_NONNULL_ATTRIBUTE, current_function_decl)) return true; return false; and change the i386 one to also call the default version. Replacing all the flag_delete_null_pointer_checks uses with some wrappers around the target hook will be less fun, not sure if the pointer type will be always visible there... > Did you replace all flag_delete_null_pointer_checks uses? I did. > Can you rename the flag just to be sure? Sure. Jakub