Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2684282pxa; Mon, 17 Aug 2020 16:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAlxVtztPVT5EafInhGk1+ZuJAi7Q4Iro3ht2TYCmwDxljONLlny/jKndOJSN4wYGU9OVA X-Received: by 2002:a17:906:3e4f:: with SMTP id t15mr18490889eji.368.1597707293797; Mon, 17 Aug 2020 16:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597707293; cv=none; d=google.com; s=arc-20160816; b=uBQwY5/C+403eM3fA8VB7zGPm2jPiKI5RuA/RVhWvauz1wi4LDWs5XeS+1wF7cSa47 xhnIAg0c2yxQMFeNalJ3f0AIbGMeN26XIP/gZUDTqomGWj6I1Hy5xEkPGYKOCV+ZMyB0 T8nLgByHopnn1HZ5nmCzhizBFlTYhBS+0H9mVwkjnLZ2M9PWEfkLszdYtqjgFShosDCm 8h2G22HUVtifPLNWj+UjSi3xBOiQlnRaTc12Cc/yxINbXQcBKHsp7C51HRkfCxU6Ry+c R01gP+Fk9+JMCXsl1wVZvGv+YLTHB0EFbM7DnD5tFaviF6o5NO9hYQqAmdA3Q2kUTvNY PALA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=2iB7Xz00n5+0Lgu+wndRSafBvCLWjlpZRZyNPVeU2aE=; b=wmLv7ur+tRb11NzWvbz8kBtClQrGIp9urvXFfGYGKc+pFsBcPq4HPGwTlOSC6wgQ5Z GwAJtj7pSZOhk7sS3uvTsc7V9pNY2ipkbHGjXVHe5jkNmybFNv30YXYaNJGKBTdi3rz9 9xH0Ual/Jhja3atnIA88yKCpgdHdLnt4TQalUXDgD8hqMcp+4GjBG7yrzNm31roSJnVN hdkKFNzIvtRS4KA7ZlsS3crSaYLfPDnL63+dgo3aY5+oIZuMsgJNv8EkRY6U6M+BoN3K YbSr5DvfxldKM5svP2hL7PB+tNUSsnKOLi2WWZtDtDJP2JSFBURkZKcmNVUU8tRuPMl1 WzKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=FqbjGe9U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mh23si11874103ejb.493.2020.08.17.16.34.30; Mon, 17 Aug 2020 16:34:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=FqbjGe9U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726792AbgHQUOD (ORCPT + 99 others); Mon, 17 Aug 2020 16:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbgHQUNz (ORCPT ); Mon, 17 Aug 2020 16:13:55 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30092C061389; Mon, 17 Aug 2020 13:13:55 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id 77so16189286qkm.5; Mon, 17 Aug 2020 13:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2iB7Xz00n5+0Lgu+wndRSafBvCLWjlpZRZyNPVeU2aE=; b=FqbjGe9U5+KoOmxxjyJUB/RZzrdUONjZiYMyDKoUkuh/2yHKnD6zT2Uj7I8UbYuYAG QKES7m4drXles2frxuunVXJFU1vO1nTqmKZtt9pWAP++iA9oQf2C6rcqPgkgJq3LFSBX lcHri0k4ctEipOVQzk2ZLIF4Zno7KvX8T8mxizBKLaRryyosyhgMbAVe5l5ZNGawNZcB JMeGxi8/ZTYXacW+5uXhoZSwXrvm3+V8etyM/j7swCB+x8Eyz25aPf+13K1O9qptwy0f Wu+weqYJRxwBupy6n1sgAadO/uIXEAL/BHeBAw1uDn6HckGZAQ45nlUhdDG2KSNvUAI9 41fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=2iB7Xz00n5+0Lgu+wndRSafBvCLWjlpZRZyNPVeU2aE=; b=j5D2bvwczN7VvQMNm3359TiFjXDcaMiTr8oqJe5WD8PyFtrsgbWEhjJqjzzNmgD8qR f8UoPWozBwCBPKN+B3W18ef8pzDqBCE9kVC1AWEtwzaBgj0+QEVWOC5TXAVybQSjrnU3 gifrBKID06Q+qAMgw9Q+6lz4NknA6OdeqK5h07VauyDfocviKACmCPNalLjfNjEFsl5a uTEiGJRRhsjvaol1qjW7KmjsxzKKFmGSJyxRvobkwoiyEFgjbyLT8ES+wcaskfnzwz2M u9vMt3VcPiMudOTDY9EObXk5qw950Za9813RRqBiK72VixtKILm+cGDMOsrCyWzuPLyu YXaA== X-Gm-Message-State: AOAM530fHNLLhO/nFMbue+akz0cvC97BKHT4kS5r82Tlo2oA/jkvhBov EAem/LSZ+uY3XeHUxLNvVzg= X-Received: by 2002:a37:6cc1:: with SMTP id h184mr14674031qkc.101.1597695234334; Mon, 17 Aug 2020 13:13:54 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id k5sm18742660qke.18.2020.08.17.13.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 13:13:53 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Mon, 17 Aug 2020 16:13:51 -0400 To: Nick Desaulniers Cc: Sami Tolvanen , Arvind Sankar , Kees Cook , Sedat Dilek , Fangrui Song , Joe Perches , Andrew Morton , =?utf-8?B?RMOhdmlkIEJvbHZhbnNrw70=?= , Eli Friedman , "# 3.4.x" , Vishal Verma , Dan Williams , Andy Shevchenko , "Joel Fernandes (Google)" , Daniel Axtens , Ingo Molnar , Yury Norov , Alexandru Ardelean , LKML , clang-built-linux , Rasmus Villemoes , Nathan Chancellor Subject: Re: [PATCH v2] lib/string.c: implement stpcpy Message-ID: <20200817201351.GA2246446@rani.riverdale.lan> References: <457a91183581509abfa00575d0392be543acbe07.camel@perches.com> <20200816001917.4krsnrik7hxxfqfm@google.com> <20200816150217.GA1306483@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 17, 2020 at 11:36:49AM -0700, Nick Desaulniers wrote: > > > Though I don't understand the original issue, with -ffreestanding, > > > sprintf shouldn't have been turned into strcpy in the first place. > > Huh? The original issue for this thread is because `-ffreestanding` > *isn't* being used for most targets (oh boy, actually mixed usage by > ARCH. Looks like MIPS, m68k, superH, xtensa, and 32b x86 use it?); and > I'm not suggesting it be used. > Sorry, I meant the issue mentioned in the commit that removed -ffreestanding, not the stpcpy one you're solving now. It says that sprintf got converted into strcpy, which caused failures because back then, strcpy was #define'd to __builtin_strcpy, and the default implementation was actually of a function called __builtin_strcpy o_O, not strcpy. Anyway, that's water under the bridge now. 6edfba1b33c7 ("x86_64: Don't define string functions to builtin") gcc should handle this anyways, and it causes problems when sprintf is turned into strcpy by gcc behind our backs and the C fallback version of strcpy is actually defining __builtin_strcpy