Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1953747pxb; Thu, 28 Oct 2021 13:16:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW1ApesZioEScmR9zXbGbNodXltXUoJOxnMWTUGzGluqhPNpEaRKsEdHv34gdERqcABwtW X-Received: by 2002:a17:903:183:b0:140:47c1:1f2e with SMTP id z3-20020a170903018300b0014047c11f2emr5841601plg.69.1635452201983; Thu, 28 Oct 2021 13:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635452201; cv=none; d=google.com; s=arc-20160816; b=pssR2DUSVlvhQJtV2LaBpGDa0C0XmbSZ7WxgogEAftgB1KkYnqt34d6d9bFvFxoQ7g zbWQluWVDI9k1/Xx8BplB9HuLi3yXhwkxwXxPmNfcu1X4xspYuqpDlQmECBj6N/W55Vr x5xl25V6gyC8HSc7sHR4eU4wzLqpHPZOrLySXv7B6vXmNlOiboAVrXf69Ouu51ZhrFdu OWgkkD9jFUR9c6/0HyFnSISfJ4hsG547rwTvCUCgZkdoX7o5RZ9pE7H+fKtIyeorjTSA zj/tLI2xNsRW4ePtVxj3c6umZbWbpeY4F2wKIXvRsLgwPMLCHzeZjq3Imqha2o6uIhBH SThQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=GiTi7nDoySXy4f2PLFxAq0NLcyBFUDniERnyM8cVKPs=; b=gYQskJ1oSRN/zpNS3ZAHZrqEWbft9c+WxzL0GTr52A13P+88U+a528+fFaqWJ1VeFs pm6E1cJe22BQVmYlmCiRmR2VohF8tDlzrIAo2EZ806ItJQh4qvViHJNAGlKgsyAcEwSD kpZLB0YLsfhyNRC8Rr5TuQ2dSvxJ9xp1HPl48tym1w3qeoL2RZeDTXtK9h81KlZNuDUk 31zN4rcPxYsY80RslhgeiRfUquZ7uq6SddweEo9F2cuXhzQdlp5J4OefgIKw39nr8dHG uGAk2mgFb0TwhQBk3rqAXqAhSjgYLuf5NnB12WRnxh64mcQLONVJQxFAHZXpKJ9APL6k Rv1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=gdwBhM8a; 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 oc15si12028807pjb.39.2021.10.28.13.16.29; Thu, 28 Oct 2021 13:16:41 -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=@linux-foundation.org header.s=korg header.b=gdwBhM8a; 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 S231221AbhJ1UR7 (ORCPT + 99 others); Thu, 28 Oct 2021 16:17:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:57980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231178AbhJ1UR5 (ORCPT ); Thu, 28 Oct 2021 16:17:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A5F660C4A; Thu, 28 Oct 2021 20:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1635452129; bh=hgkulfjy2lu/2Pn+/4MoUzzaOqJpiylsYL8YeU6rj6w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gdwBhM8acmkSuTfLv7h32T6XXK6nvsZa3HwDi1umz5MmVL4oek/V6ZW1xcGAuq6b5 bSFcEMEW4CL4ZjZAgkaJsH8DpJ/XG4Fi2jHDYmdmqoq5faO4hn3iy+Gx4QBj2VkXaV sLHY+toZ0Q8gK/GJSdJody6HLZwewK5biCNDxOSw= Date: Thu, 28 Oct 2021 13:15:26 -0700 From: Andrew Morton To: Kees Cook Cc: Vincenzo Frascino , Arnd Bergmann , linux-hardening@vger.kernel.org, Kees Cook , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , kasan-dev@googlegroups.com, Arnd Bergmann , Marco Elver , Catalin Marinas , Peter Collingbourne , Patricia Alfonso , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] kasan: test: use underlying string helpers Message-Id: <20211028131526.d63d1074a8faa20e1de5e209@linux-foundation.org> In-Reply-To: <721BDA47-9998-4F0B-80B4-F4E4765E4885@chromium.org> References: <20211013150025.2875883-1-arnd@kernel.org> <721BDA47-9998-4F0B-80B4-F4E4765E4885@chromium.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Oct 2021 19:40:45 -0700 Kees Cook wrote: > > > On October 14, 2021 1:12:54 AM PDT, Vincenzo Frascino wrote: > > > > > >On 10/13/21 5:00 PM, Arnd Bergmann wrote: > >> From: Arnd Bergmann > >> > >> Calling memcmp() and memchr() with an intentional buffer overflow > >> is now caught at compile time: > >> > >> In function 'memcmp', > >> inlined from 'kasan_memcmp' at lib/test_kasan.c:897:2: > >> include/linux/fortify-string.h:263:25: error: call to '__read_overflow' declared with attribute error: detected read beyond size of object (1st parameter) > >> 263 | __read_overflow(); > >> | ^~~~~~~~~~~~~~~~~ > >> In function 'memchr', > >> inlined from 'kasan_memchr' at lib/test_kasan.c:872:2: > >> include/linux/fortify-string.h:277:17: error: call to '__read_overflow' declared with attribute error: detected read beyond size of object (1st parameter) > >> 277 | __read_overflow(); > >> | ^~~~~~~~~~~~~~~~~ > >> > >> Change the kasan tests to wrap those inside of a noinline function > >> to prevent the compiler from noticing the bug and let kasan find > >> it at runtime. > >> > >> Signed-off-by: Arnd Bergmann > > > >Reviewed-by: Vincenzo Frascino > > How about just explicitly making the size invisible to the compiler? > > I did this for similar issues in the same source: > > https://lore.kernel.org/linux-hardening/20211006181544.1670992-1-keescook@chromium.org/T/#u > Arnd?