From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5016A2F28 for ; Thu, 3 Feb 2022 20:45:38 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id g15-20020a17090a67cf00b001b7d5b6bedaso4123184pjm.4 for ; Thu, 03 Feb 2022 12:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ax+zgGQyyKWqqmUNa+Gr/NFN1a356webih9nQCbtRlA=; b=lq4mnyUfUnu0BzR6Wiz2LqRbI6UXI+AlM29AzDRsgBJJEGxcudKiSVmcZVkBdH1V5R H9ihEHFWxShy/iMqODNdF03wxTXBQYKV/ZiBFz64MRdzRlBLWokuqPF3y8/2M49e7xEO 8cpdAI1hx+7n5zGDn6/weEZdRv67FbbRqt0zI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ax+zgGQyyKWqqmUNa+Gr/NFN1a356webih9nQCbtRlA=; b=bpmtWy5LGJFqlDDrNRKXGR0FoOwa939k4Edhd2kU+56XxktZRTxfiSeBlQOCLFvFqu aEtlxaHnURkNZehat+FYoCnhacAZ9lKEEMm8zISBLhxTEXeaDlHUvh+hwbvg3JCDLuqF nlwET118ZOCwKr+nvgx/Am/dWtzPOE3897Znk/m0tbiwHsTDysli6gvnzwraz1mRGrbU svLaOCw/1EApqaJENA+Pta2lFgKG2FaOipXVIFQF0RLIURWbcYTcdosp/xSXc/XXYG4c UrcefiBrmMB+qoI+Qsgal8zeny8KrjNJ4tlMWJ87pP15ljxYmGcrU0+Yj8F3j3VBJN97 CtNg== X-Gm-Message-State: AOAM531WOEL1dyl9V+oA81y/AYB4AY3COtE0nnra2yP+WXgSUN7Mk8lu 86EMEEFaAxkGYotTb1Ls9V+8IQ== X-Google-Smtp-Source: ABdhPJzyIjueAdPLPELPYzMN0XC6MvF7sAwGHIqciSmxWkbnOpbPZS4x4gmcwTPLeXlwCj4QQRQGWA== X-Received: by 2002:a17:902:6903:: with SMTP id j3mr37649101plk.137.1643921137797; Thu, 03 Feb 2022 12:45:37 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j10sm30543226pfu.93.2022.02.03.12.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 12:45:37 -0800 (PST) Date: Thu, 3 Feb 2022 12:45:36 -0800 From: Kees Cook To: Nick Desaulniers Cc: Geert Uytterhoeven , Guenter Roeck , Peter Rosin , Andy Shevchenko , Matteo Croce , Nathan Chancellor , Linux Kernel Mailing List , llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] lib/test_string.c: Add test for strlen() Message-ID: <202202031242.45A7F5704@keescook> References: <20220130183653.491292-1-keescook@chromium.org> <20220202160149.GA2322037@roeck-us.net> <202202021237.487D3DE73@keescook> <5ff18cff-6cfd-1f85-da74-1e5660a1a250@roeck-us.net> <202202030911.4914709E@keescook> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Feb 03, 2022 at 11:50:34AM -0800, Nick Desaulniers wrote: > The kernel does not link against a libc; but it does provide many > symbols that libc would provide, with the same or similar enough > semantics that I would strongly recommend we _don't_ use > -ffreestanding in order to get such libcall optimizations (there are a > lot; see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp > for some examples) and simply use -fno-builtin-* when necessary, or > fix the kernel implementations individually. Right, we really don't want -ffreestanding. Rather, we want to not link against libgcc. This is mostly true already, though some of the smaller architectures still do: $ git grep print-libgcc arch/arc/Makefile:LIBGCC = $(shell $(CC) $(cflags-y) --print-libgcc-file-name) arch/csky/Makefile: $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name) arch/h8300/boot/compressed/Makefile:LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name 2>/dev/null) arch/nios2/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name) arch/openrisc/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) arch/parisc/Makefile:LIBGCC := $(shell $(CC) -print-libgcc-file-name) arch/xtensa/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) arch/xtensa/boot/boot-redboot/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) -- Kees Cook