From patchwork Thu Jun 22 17:20:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13289491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23FC7EB64DC for ; Thu, 22 Jun 2023 17:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjFVRUr (ORCPT ); Thu, 22 Jun 2023 13:20:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230449AbjFVRUq (ORCPT ); Thu, 22 Jun 2023 13:20:46 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AEBB1FF6; Thu, 22 Jun 2023 10:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1687454439; bh=+/aNz4y+AbrUpY8/J4QV4+dsn+DjkqAo9OG0y4IXBZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YripPpPCn2et5Ls8aO59zAzUGY3GNlUgfimz8udbjwCD+bP9BKvW7LSjfuGyXpiSw 1czeUWM5O79iYygjEJ4Hg/qAw4g99tsohoPaynvTODErOK6FqzY92qXUNGq7XjBOEP dcU36S1cpctrpKY6ILFmO0DyWHW+4VM6awvPb+KXkiqOhBw/Q3l+9fiv85WT19efyY 0zfm5lgJe5HFnO/0LgR537lEEs6ZGYT8t1qgaE+9h9cIPxHibVpKwxLh7mxqJO0AAf SmVGH/Py0J/WBtKTzdg1i/B9xXLpTrFtMvKT3PCBArm7/9+33K29rKmvWuYT4Zsz3T 6WG9226yCfK0w== Received: from integral2.. (unknown [68.183.184.174]) by gnuweeb.org (Postfix) with ESMTPSA id DA9DC249D78; Fri, 23 Jun 2023 00:20:36 +0700 (WIB) From: Ammar Faizi To: Jens Axboe Cc: Alviro Iskandar Setiawan , Guillem Jover , Jeff Moyer , Stefan Hajnoczi , Michael William Jonathan , Matthew Patrick , io-uring Mailing List , Linux Kernel Mailing List , GNU/Weeb Mailing List Subject: [RFC PATCH liburing v1 1/3] configure: Remove --nolibc option Date: Fri, 23 Jun 2023 00:20:27 +0700 Message-Id: <20230622172029.726710-2-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622172029.726710-1-ammarfaizi2@gnuweeb.org> References: <20230622172029.726710-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This option was deprecated and planned to be removed. Now remove it. Co-authored-by: Alviro Iskandar Setiawan Signed-off-by: Alviro Iskandar Setiawan Signed-off-by: Ammar Faizi --- configure | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/configure b/configure index 28f3eb0aee24f9ea..a16ffca83d678364 100755 --- a/configure +++ b/configure @@ -5,22 +5,6 @@ set -e cc=${CC:-gcc} cxx=${CXX:-g++} -# -# TODO(ammarfaizi2): Remove this notice and `--nolibc` option. -# -nolibc_deprecated() { - echo ""; - echo "================================================================="; - echo ""; - echo " --nolibc option is deprecated and has no effect."; - echo " It will be removed in a future liburing release."; - echo ""; - echo " liburing on x86-64, x86 (32-bit) and aarch64 always use CONFIG_NOLIBC."; - echo ""; - echo "================================================================="; - echo ""; -} - for opt do optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)' || true) case "$opt" in @@ -42,8 +26,6 @@ for opt do ;; --cxx=*) cxx="$optarg" ;; - --nolibc) nolibc_deprecated - ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -91,7 +73,6 @@ Options: [defaults in brackets after descriptions] --datadir=PATH install shared data in PATH [$datadir] --cc=CMD use CMD as the C compiler --cxx=CMD use CMD as the C++ compiler - --nolibc build liburing without libc EOF exit 0 fi From patchwork Thu Jun 22 17:20:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13289492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1216EB64DC for ; Thu, 22 Jun 2023 17:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230471AbjFVRUu (ORCPT ); Thu, 22 Jun 2023 13:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbjFVRUr (ORCPT ); Thu, 22 Jun 2023 13:20:47 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B5B32122; Thu, 22 Jun 2023 10:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1687454443; bh=BRDGujV5bASaXtU4sheMv8CYwhxietJD+x2yxoDCxrU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pm4EJdOucz/QFIs9qx8AhSqVSkcNTrceYPjxeRkf5mWBx/zlgPp/7qB4g2jIyAL2f 5erRWGGOrF9hmU60mA7EHt/hTsxOczh8vmbwhR4WQuyNAWBQULOKk4IEOfhvW9qfyL BnIqudSH/5s/2Yg23Dv7GHn0nvPb7l6u30yU+UrC4u7PhdsG1XPimEDQWcWAMlTQ2m lzL0anzjOmJyoqRhyB4nGRVS+zMXBlAmngtKnLUEo2sYbb1G63met3FH4CWKZWf2JV aqeI79+C2po8v+CsTeUCy0AwPMLv7DLF36WmsqsuK+6PdBaEcD4VhGdYhuXIg/Gru7 AEr5/1J/Mo7gw== Received: from integral2.. (unknown [68.183.184.174]) by gnuweeb.org (Postfix) with ESMTPSA id 77D11249C7A; Fri, 23 Jun 2023 00:20:40 +0700 (WIB) From: Ammar Faizi To: Jens Axboe Cc: Alviro Iskandar Setiawan , Guillem Jover , Jeff Moyer , Stefan Hajnoczi , Michael William Jonathan , Matthew Patrick , io-uring Mailing List , Linux Kernel Mailing List , GNU/Weeb Mailing List Subject: [RFC PATCH liburing v1 2/3] configure: Introduce '--use-libc' option Date: Fri, 23 Jun 2023 00:20:28 +0700 Message-Id: <20230622172029.726710-3-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622172029.726710-1-ammarfaizi2@gnuweeb.org> References: <20230622172029.726710-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Currently, when compiling liburing on x86, x86-64, and aarch64 architectures, the resulting binary lacks the linkage with the standard C library (libc). To address the concerns raised by Linux distribution package maintainers regarding security, it is necessary to enable the linkage of libc to liburing. Especially right now, when the security of io_uring is being scrutinized. By incorporating the '--use-libc' option, developers can now enhance the overall hardening of liburing by utilizing compiler features such as the stack protector and address sanitizer. Link: https://security.googleblog.com/2023/06/learnings-from-kctf-vrps-42-linux.html Link: https://lore.kernel.org/io-uring/20230621100447.GD2667602@fedora Link: https://lore.kernel.org/io-uring/ZJLkXC7QffsoCnpu@thunder.hadrons.org Cc: Stefan Hajnoczi Cc: Guillem Jover Co-authored-by: Alviro Iskandar Setiawan Signed-off-by: Alviro Iskandar Setiawan Signed-off-by: Ammar Faizi --- configure | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/configure b/configure index a16ffca83d678364..46afb7285a1ea8d0 100755 --- a/configure +++ b/configure @@ -26,6 +26,8 @@ for opt do ;; --cxx=*) cxx="$optarg" ;; + --use-libc) use_libc=yes + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -73,6 +75,7 @@ Options: [defaults in brackets after descriptions] --datadir=PATH install shared data in PATH [$datadir] --cc=CMD use CMD as the C compiler --cxx=CMD use CMD as the C++ compiler + --use-libc use libc for liburing (useful for hardening) EOF exit 0 fi @@ -382,10 +385,13 @@ fi print_config "NVMe uring command support" "$nvme_uring_cmd" ############################################################################# -# -# Currently, CONFIG_NOLIBC is only enabled on x86-64, x86 (32-bit) and aarch64. -# -cat > $TMPC << EOF +liburing_nolibc="no" +if test "$use_libc" != "yes"; then + + # + # Currently, CONFIG_NOLIBC only supports x86-64, x86 (32-bit) and aarch64. + # + cat > $TMPC << EOF int main(void){ #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) return 0; @@ -394,10 +400,13 @@ int main(void){ #endif } EOF -if compile_prog "" "" "nolibc support"; then - liburing_nolibc="yes" + + if compile_prog "" "" "nolibc"; then + liburing_nolibc="yes" + fi fi -print_config "nolibc support" "$liburing_nolibc"; + +print_config "nolibc" "$liburing_nolibc"; ############################################################################# #################################################### From patchwork Thu Jun 22 17:20:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13289493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEACAEB64D8 for ; Thu, 22 Jun 2023 17:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbjFVRVB (ORCPT ); Thu, 22 Jun 2023 13:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbjFVRUt (ORCPT ); Thu, 22 Jun 2023 13:20:49 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 673BA19AF; Thu, 22 Jun 2023 10:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1687454447; bh=+XRDjI36PEd0caHlici2GUhkWoB0ec/qz+50JPGebKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SsVgkH/skY1v3CBQPy8YxPB6zH2PSH6cl5wZBHVUzgHJ5Pe5jlPkRaW7VNIe5OKAo 5umKypCl5cmKqqa1lNVqwijyq+27ib9x4PjOyRCdXLQfk1hnzTi/C9gkPyN1ZAIHbp feTSdwiDUrNvD9XQpski4z3VmbEoWMm0ck+OJa5M+FKTpvxgjDpVL5NSQr5mu38GIg OFzVve1ZhMjZvaA8kUgwfBxZ4J8z0uOtk1akdSJcbaLg/6Px4I+ibUT0Y/mA88au87 t0zoR/q0drsQTbEywHwHuzXuOwrclHLaW0+Z+QKoHuxAxdYGP0mH+B7J/slThQ+9xN +3o2Hn9pFapSQ== Received: from integral2.. (unknown [68.183.184.174]) by gnuweeb.org (Postfix) with ESMTPSA id 18B5A249D86; Fri, 23 Jun 2023 00:20:43 +0700 (WIB) From: Ammar Faizi To: Jens Axboe Cc: Alviro Iskandar Setiawan , Guillem Jover , Jeff Moyer , Stefan Hajnoczi , Michael William Jonathan , Matthew Patrick , io-uring Mailing List , Linux Kernel Mailing List , GNU/Weeb Mailing List Subject: [RFC PATCH liburing v1 3/3] src/Makefile: Allow using stack protector with libc Date: Fri, 23 Jun 2023 00:20:29 +0700 Message-Id: <20230622172029.726710-4-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622172029.726710-1-ammarfaizi2@gnuweeb.org> References: <20230622172029.726710-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Currently, the stack protector is forcefully disabled. Let's allow using the stack protector feature only if libc is used. The stack protector will remain disabled by default if no custom CFLAGS are provided. This ensures the default behavior doesn't change while still offering the option to enable the stack protector. Cc: Stefan Hajnoczi Cc: Guillem Jover Co-authored-by: Alviro Iskandar Setiawan Signed-off-by: Alviro Iskandar Setiawan Signed-off-by: Ammar Faizi --- src/Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index 951c48fc6797be75..c4c28cbe87c7a8de 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,9 +10,8 @@ CPPFLAGS ?= override CPPFLAGS += -D_GNU_SOURCE \ -Iinclude/ -include ../config-host.h \ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -CFLAGS ?= -g -O3 -Wall -Wextra +CFLAGS ?= -g -O3 -Wall -Wextra -fno-stack-protector override CFLAGS += -Wno-unused-parameter \ - -fno-stack-protector \ -DLIBURING_INTERNAL \ $(LIBURING_CFLAGS) SO_CFLAGS=-fPIC $(CFLAGS) @@ -46,8 +45,8 @@ liburing_srcs := setup.c queue.c register.c syscall.c version.c ifeq ($(CONFIG_NOLIBC),y) liburing_srcs += nolibc.c - override CFLAGS += -nostdlib -nodefaultlibs -ffreestanding -fno-builtin - override CPPFLAGS += -nostdlib -nodefaultlibs -ffreestanding -fno-builtin + override CFLAGS += -nostdlib -nodefaultlibs -ffreestanding -fno-builtin -fno-stack-protector + override CPPFLAGS += -nostdlib -nodefaultlibs -ffreestanding -fno-builtin -fno-stack-protector override LINK_FLAGS += -nostdlib -nodefaultlibs endif