From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 023291F454 for ; Fri, 8 Nov 2019 17:00:47 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version:content-type; q=dns; s=default; b=PKYtX zM9mB2VVXh9y9ziXSIPTUGktKFXLYZ41sr8COM7vTp+WzUrgymNHN8l2pSgSyEiy QeWexJjzf25g8W03BPE5zhC0ewq/p1KA+5QW0DOR9kLSBKJIPOAgVC2iUDzqlVqx 81UipGNK9CYzI32kDE09kP4/2xMPlWJumK7rUQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version:content-type; s=default; bh=gpNB+Mi3P63 KAK0XQfK6yOT8aDc=; b=NzZWCqBY2S+CarB3oCs37V4f2W/WWOS1f8xf7yxTgmt hDEY+PKZJZfgGOxXb9DoMxQAzNLSbaUthPwJVJoum9di2TmtQT4wq9SFL9gG9WBB 15XqrkLUm+zMZHeoTlMaXRgZakUtN/ysDzFY09tbD0jteyCqpQWMvM9meEvErx9s = Received: (qmail 64676 invoked by alias); 8 Nov 2019 17:00:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 64658 invoked by uid 89); 8 Nov 2019 17:00:45 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: esa2.mentor.iphmx.com IronPort-SDR: 3NorXNWJPlxoEhids95gSHTXpIlfy6SHlkHzYZxIvhwtgiMin2yw0IePVMRwT5cs0p6iSWRIEF 11A9ycxfjARR0xf3k/sy3+6LWBuiwjwGXPt1vWRHelST68zxox/Q/aYbf27OQO4xZLRyMi32/d bMls8+pfXpaeljwAtx4Wm2Whl5Nfgrud+Lpgk3egs37vEHk70EJe4TwYAeHeQ23BpSBh3R2Tut 180x48VntcCq/stXytKAaBoRm4Y7eJgx/xB+qTAKkrUUWvekCIBiHnF5UkL3B/PkK2LPyUi8W/ 4RQ= IronPort-SDR: 2kx8q33un5D9Wsu7ebzP/4yEiHDoQ/aQMD47+0PHq07xjA7cFWa3Z7pov44mmUPJAzqJXI5iMY dSeTZvg6VsHC84d7zLZq4mkepEZ13WAtsMGDYxy8ZU9ykZoIVPVQZlSp9TG2299HrpXmNxuefK CkLEWDH4HzRuC+6+1tCDlIMYRz9C08ncRvNJXlGaNK4HtvJeOCChLE3uOKR6saHuRwFZFPVLfi 4e7/2LPW+uBVchjWJqBim/9R+Gu6g7TabQh45iH8rXy2DRuo6Zhd+2KUKFgbypgiTpAWeAol1O Eh0= Date: Fri, 8 Nov 2019 17:00:35 +0000 From: Joseph Myers To: Alistair Francis CC: Lukasz Majewski , Paul Eggert , Alistair Francis , GNU C Library , Adhemerval Zanella , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell Subject: Re: [PATCH 2/2] linux: clock_settime: Return proper value when passing NULL pointer In-Reply-To: Message-ID: References: <20191108153344.10949-1-lukma@denx.de> <20191108153344.10949-2-lukma@denx.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" On Fri, 8 Nov 2019, Alistair Francis wrote: > On Fri, Nov 8, 2019 at 7:34 AM Lukasz Majewski wrote: > > > > When in __clock_settime function (__TIMESIZE != 64) the const struct > > timespec's *tp pointer is NULL, the Linux kernel syscall returns > > -EFAULT. > > Without this patch the glibc crashes (when dereferencing NULL pointer) > > as the Linux kernel syscall is not reached at all. > > > > There is no need for such check in the __clock_settime64, as this > > pointer either goes directly to Linux kernel or the pointer to local > > copy is used (ts64). > > Reviewed-by: Alistair Francis This patch is contrary to glibc conventions. There is explicitly no guarantee of whether a segfault or EFAULT occurs when a function is called with invalid arguments. There should be no explicit checks for NULL pointers in cases where a segfault will reliably occur otherwise and any existing such checks should be removed from glibc. https://sourceware.org/glibc/wiki/Style_and_Conventions#Invalid_pointers (And note the POSIX specification of EFAULT, "The reliable detection of this error cannot be guaranteed, and when not detected may result in the generation of a signal, indicating an address violation, which is sent to the process.".) -- Joseph S. Myers joseph@codesourcery.com