Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp773551pxb; Wed, 25 Aug 2021 15:00:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKtzwSeWGrzji2ZWf5Cel+o4vKjr69Lid9OKCJN+oqHOMiP4oZZiHRW66WsT6mLmGpnBOA X-Received: by 2002:a02:a1c3:: with SMTP id o3mr537852jah.59.1629928851705; Wed, 25 Aug 2021 15:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629928851; cv=none; d=google.com; s=arc-20160816; b=HBK02EmwDOV+hfs1lH0bN65FfguSHH86vU5MnZpjKaD7rZJJAhxpOxcveeOTm/lWMQ zDEt/Bk5Atw3akldCVWvXrH1/l0TWuNyzOwsa9K6fp/TyMuZ/SErUG5iBcIbMvesycQV +7CdnmKAkbzW5BwX+THvkBhxZaoRBvFDlErHPY4i17bsN6easPl4feyKJyOdyJ9BUwJA ZRH3V1s5LsWzd7XTQ4jqCn3uIFcY54X64B3AQTAYu/EJ5HfyVgWIZ73ORukV4u8KHxba dAh1c25kiH2wWX2a9L6Wn5vKJ0gyn0quTrhQoCQjZEP8GoGF0hXn/GcdCDJFBZ0bGDBC SD7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jEQgN0abaaOBlYJk9+kTEjTwkKHPtenNKxBXd/YeuFg=; b=DdQ42gOkAGDHUhdhqqgXES8em+iiJgM62JSRlSpOdMhF6TErXP9A9MtWXuD8iUDa4r Ck9094pXbFBqMz1Wtagm91uEj+kV2Mc2yAP1gdT9o3YAMigYQQUndpF9DqsXOvDvHlt+ YCErupcs0YRmNZGPBEFIZpXqnLYM+/WwO3rNPjbjtyJZbL9Sg/SCxqCD2rxzNxxDbBGo 3mSCSUdFUDjK79oTLboqMvKRhBJyHthqsCNDk0IRXWYRB4O8YAJu/K0bS6nLjpBdk42i eCdNQdbhtAtAvgcXN1wduEjlDofL7sS5QhoO+pTowX2VS1A7nSex2iQCFHHNaApkQwng WYVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Rwvd09BG; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si858446jaa.25.2021.08.25.15.00.38; Wed, 25 Aug 2021 15:00:51 -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=pass header.i=@google.com header.s=20161025 header.b=Rwvd09BG; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232135AbhHYWAZ (ORCPT + 99 others); Wed, 25 Aug 2021 18:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbhHYWAY (ORCPT ); Wed, 25 Aug 2021 18:00:24 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34596C0613C1 for ; Wed, 25 Aug 2021 14:59:38 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id o10so1933085lfr.11 for ; Wed, 25 Aug 2021 14:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jEQgN0abaaOBlYJk9+kTEjTwkKHPtenNKxBXd/YeuFg=; b=Rwvd09BGu0W8Bf09NgU+o2Bhog1Y+Zu32OYjoMlTXlKtJOJpBecMKuNcLFx0s5W7zz FWDa7ok2PVOhFdJAD1DyBQubxC14BThq1k8VSvpEHgQcajP6D2JWi2VR/S6f1tC5qCaP zp2FbvuX7BaGvNggZvh7H9eqq/vJlBv1KhDDwKYnxaLfZGqewEdyShnaUE2zN5DLrMqX CYqN9boBMs/RWWLoTUz5GhkIf2NOetMelzo7SGFamyxqU5ur8ttDinQeYkLMEY7WCT2E Gp5uljdWnrSP6kH0alI2rMOOUthWb0yeZjebCxQ5rOiJxlNCH+6UYHoxeOqRrdNacdS4 gqgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jEQgN0abaaOBlYJk9+kTEjTwkKHPtenNKxBXd/YeuFg=; b=r6uV1o2a6dg8uLzqPZwu23DOtSPjybl3Yz628Ds3urXul7db/H2cIsPIhDn4j5X9Zo e6Epn2w7+k45eV124yPClncK56wUsiEglHOwOSyYlwxcLcs0uo9WNfpInyxb0OGXo5JJ S4JmJv7wLpplKcKJ6BWCjNeu+3gl2AdpJXg7gu9AhUZhxT5LUBw97hkHfVf2MWLZK6Xr 2RV3Tn8ph5x7kUOd7eno9k081R47LjybVYy6OL7YE8Vogo6ng4lQ30Tgaq7LAcv+nyq/ Hw8ywXicuhbYeWf8NUigjrwh2rRdJ0YsSJWvRLFocChXqUMyE6zzcV1JHehNi4SN7bPH 0WLg== X-Gm-Message-State: AOAM533PGs0Fwwbl/ttGSIr6VSlmDhwaN/iu3BFRR9SKyb4TkSDlrvrQ l1YVvE4710Ewq3O4em5x/jeJL4GP4MSM2BlQteHtGw== X-Received: by 2002:a05:6512:3a84:: with SMTP id q4mr182701lfu.543.1629928776388; Wed, 25 Aug 2021 14:59:36 -0700 (PDT) MIME-Version: 1.0 References: <20210822075122.864511-1-keescook@chromium.org> <20210822075122.864511-16-keescook@chromium.org> In-Reply-To: <20210822075122.864511-16-keescook@chromium.org> From: Nick Desaulniers Date: Wed, 25 Aug 2021 14:59:24 -0700 Message-ID: Subject: Re: [PATCH for-next 15/25] fortify: Move remaining fortify helpers into fortify-string.h To: Kees Cook Cc: linux-kernel@vger.kernel.org, Francis Laniel , Rasmus Villemoes , Daniel Micay , Bart Van Assche , David Gow , linux-mm@kvack.org, clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 22, 2021 at 12:57 AM Kees Cook wrote: > > When commit a28a6e860c6c ("string.h: move fortified functions definitions > in a dedicated header.") moved the fortify-specific code, some helpers > were left behind. Move the remaining fortify-specific helpers into > fortify-string.h so they're together where they're used. This requires > that any FORTIFY helper function prototypes be conditionally built to > avoid "no prototype" warnings. Additionally removes unused helpers. > > Acked-by: Francis Laniel > Signed-off-by: Kees Cook Reviewed-by: Nick Desaulniers > --- > include/linux/fortify-string.h | 7 +++++++ > include/linux/string.h | 9 --------- > lib/string_helpers.c | 2 ++ > 3 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/include/linux/fortify-string.h b/include/linux/fortify-string.h > index c1be37437e77..7e67d02764db 100644 > --- a/include/linux/fortify-string.h > +++ b/include/linux/fortify-string.h > @@ -2,6 +2,13 @@ > #ifndef _LINUX_FORTIFY_STRING_H_ > #define _LINUX_FORTIFY_STRING_H_ > > +#define __FORTIFY_INLINE extern __always_inline __attribute__((gnu_inline)) > +#define __RENAME(x) __asm__(#x) > + > +void fortify_panic(const char *name) __noreturn __cold; > +void __read_overflow(void) __compiletime_error("detected read beyond size of object (1st parameter)"); > +void __read_overflow2(void) __compiletime_error("detected read beyond size of object (2nd parameter)"); > +void __write_overflow(void) __compiletime_error("detected write beyond size of object (1st parameter)"); > > #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) > extern void *__underlying_memchr(const void *p, int c, __kernel_size_t size) __RENAME(memchr); > diff --git a/include/linux/string.h b/include/linux/string.h > index b48d2d28e0b1..9473f81b9db2 100644 > --- a/include/linux/string.h > +++ b/include/linux/string.h > @@ -249,15 +249,6 @@ static inline const char *kbasename(const char *path) > return tail ? tail + 1 : path; > } > > -#define __FORTIFY_INLINE extern __always_inline __attribute__((gnu_inline)) > -#define __RENAME(x) __asm__(#x) > - > -void fortify_panic(const char *name) __noreturn __cold; > -void __read_overflow(void) __compiletime_error("detected read beyond size of object passed as 1st parameter"); > -void __read_overflow2(void) __compiletime_error("detected read beyond size of object passed as 2nd parameter"); > -void __read_overflow3(void) __compiletime_error("detected read beyond size of object passed as 3rd parameter"); > -void __write_overflow(void) __compiletime_error("detected write beyond size of object passed as 1st parameter"); > - > #if !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE) > #include > #endif > diff --git a/lib/string_helpers.c b/lib/string_helpers.c > index e9433caab217..1274f45ffaf4 100644 > --- a/lib/string_helpers.c > +++ b/lib/string_helpers.c > @@ -879,9 +879,11 @@ char *strreplace(char *s, char old, char new) > } > EXPORT_SYMBOL(strreplace); > > +#ifdef CONFIG_FORTIFY_SOURCE > void fortify_panic(const char *name) > { > pr_emerg("detected buffer overflow in %s\n", name); > BUG(); > } > EXPORT_SYMBOL(fortify_panic); > +#endif /* CONFIG_FORTIFY_SOURCE */ > -- > 2.30.2 > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210822075122.864511-16-keescook%40chromium.org. -- Thanks, ~Nick Desaulniers