Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6892088rwb; Tue, 22 Nov 2022 22:01:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4EFWCLpjlihvQi5D6+1yvCW90Nm0hnjNLA2+APnSdNoqWay7lQ6n2topHoK/P/imbSEoZZ X-Received: by 2002:a17:906:791:b0:7ad:14f8:7583 with SMTP id l17-20020a170906079100b007ad14f87583mr10004882ejc.185.1669183293712; Tue, 22 Nov 2022 22:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183293; cv=none; d=google.com; s=arc-20160816; b=VOqki071JGHG2wQS/QxcO/aiXAXLGFScTPRcRLHMsX2V/IpkwmLQeFxnlSuLdIwe0d SAlmWmJE80zco2lbPDwZimP60rnrQWiNDPwzJrakn3w3I9U6LZ+RrPI/ZCwVVpEhdrov dzkL6eGfkaPza4D1qIx8xzMkPIG3h9Ejs4x7IhKdbDbtokr0DKF+vSAUzL+eg9rJxZ+M Ue8ZpRQhQSRJFNa69RXqY33xVbBVSU6yUV5D24J/dqHkzErRz2NsyKHHVnIuI77I82cQ lzHWzPPJX0P6ujwVMlxg0xHPZteo2ZEZIZH3wAJX2wy3gfXGlZDTmezlmvbYSMIzXiJ3 yTcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SpV9LZG6lum2+mJs6hiaJhY/GA7UnSa+zZbSm43A0ug=; b=AY94j0/JESmBOMCazxxZRmBmkeGpgHkA+7beMt+lthEBQIESbd/YuhoRYSxX3vxlrA 9KAWWSHgrM0Kfjw+Xu3SFe5qND0wxLILQCbkM8rdutFrEA/eeJdwp4FfP2ut8Fa0sIHk 5j3SR2GRMQx/GovRXdcaKbt63QqiHHArT1nsDGVA/eH8fPJI2g7x0Q44IZOaIROYTKs0 F6B+ETjHZUtb/FHT1Yc5/pyIzD/eMaGAqp2xD4OUY8e94ir/sPF+w0Vynb7OZPE4lkRZ dGs9GZZCVSVwAPiP53iin8d67Uyv8IR4GV1GH2ZJZZ0eYUCI5uljEXXo7VoCHhxSi8lV KxLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cDeVvprP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ml21-20020a170906cc1500b00780a3097d20si10010129ejb.180.2022.11.22.22.01.10; Tue, 22 Nov 2022 22:01:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cDeVvprP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235735AbiKWFP6 (ORCPT + 89 others); Wed, 23 Nov 2022 00:15:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235649AbiKWFPz (ORCPT ); Wed, 23 Nov 2022 00:15:55 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B371FECCCC for ; Tue, 22 Nov 2022 21:15:54 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id b62so15918059pgc.0 for ; Tue, 22 Nov 2022 21:15:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SpV9LZG6lum2+mJs6hiaJhY/GA7UnSa+zZbSm43A0ug=; b=cDeVvprPd40bk4/tjBwKAlkCE7CYWPe+LHBDXgCiAgsBMQBPE6TpXcNgWUk3jEhejY JGf+qknBzyWA481RCia2iuQpJZtg0muVzCUri5xXZk1KHO/zAwZy0qft9gdlIZMQLONN br2iEl5Zwjuz3zGFjCIRK0CksLz8BBUUnyhqI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SpV9LZG6lum2+mJs6hiaJhY/GA7UnSa+zZbSm43A0ug=; b=j4ihsdT4FeP7pVKbrrZgiXJfI356BkOMWb0/56a3tVmzHD0UA7yS5/txNvk+uXx9qX d1kapIph8gv+Q39OVyKOoh/UgrlIAYZvemPIMKwceA3z+qIbP8wfRcbOFxKxW44Rm6Nz es6TZVetdx12Kdozql5OPFlaQze0tWQdkVmrWbkG4+8Mpalt8+CW0+5HjKPvUooYCx3L 52GAyF5F6Aq6jv9dOGAWO6SoM9FWG59Nx9llAbClsrsJL5gUjz/dUZ8YMCOKzo0dPTPv w59EuFtjVX5GP/FMl5FV4obWUCJv+oeN7YJs1YsaDfsSW4WwRmotTpi4J4jw30PrLR86 Or8A== X-Gm-Message-State: ANoB5ploKBR2FFCqgMoFlHiKGJdUYNKYycjSm6DKcEzkWUqKYZ6kStas 6MVScq1/76z4UwUz7gdTi4FKRJKGNgt3BOlT X-Received: by 2002:a63:5153:0:b0:41a:4bd4:f43f with SMTP id r19-20020a635153000000b0041a4bd4f43fmr7621643pgl.460.1669180554101; Tue, 22 Nov 2022 21:15:54 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 11-20020a17090a1a0b00b00218cd71781csm451793pjk.51.2022.11.22.21.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 21:15:52 -0800 (PST) Date: Tue, 22 Nov 2022 21:15:51 -0800 From: Kees Cook To: Siddhesh Poyarekar Cc: linux-hardening@vger.kernel.org, Miguel Ojeda , Arnd Bergmann , Nick Desaulniers , Nathan Chancellor , Tom Rix , llvm@lists.linux.dev, Juergen Gross , Boris Ostrovsky , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] fortify: Use __builtin_dynamic_object_size() when available Message-ID: <202211222113.10003CF8FD@keescook> References: <20220920192202.190793-1-keescook@chromium.org> <20220920192202.190793-5-keescook@chromium.org> <0da67f73-dd73-7e6d-74c2-14aec5d79902@gotplt.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0da67f73-dd73-7e6d-74c2-14aec5d79902@gotplt.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 22, 2022 at 05:20:37AM -0500, Siddhesh Poyarekar wrote: > On 2022-09-20 15:22, Kees Cook wrote: > > Since the commits starting with c37495d6254c ("slab: add __alloc_size > > attributes for better bounds checking"), the compilers have runtime > > allocation size hints available in some places. This was immediately > > available to CONFIG_UBSAN_BOUNDS, but CONFIG_FORTIFY_SOURCE needed > > updating to explicitly make use the hints via the associated > > __builtin_dynamic_object_size() helper. Detect and use the builtin when > > it is available, increasing the accuracy of the mitigation. When runtime > > sizes are not available, __builtin_dynamic_object_size() falls back to > > __builtin_object_size(), leaving the existing bounds checking unchanged. > > > > Additionally update the VMALLOC_LINEAR_OVERFLOW LKDTM test to make the > > hint invisible, otherwise the architectural defense is not exercised > > (the buffer overflow is detected in the memset() rather than when it > > crosses the edge of the allocation). > > > > Cc: Miguel Ojeda > > Cc: Siddhesh Poyarekar > > Cc: Arnd Bergmann > > Cc: Nick Desaulniers > > Cc: Nathan Chancellor > > Cc: Tom Rix > > Cc: linux-hardening@vger.kernel.org > > Cc: llvm@lists.linux.dev > > Signed-off-by: Kees Cook > > --- > > drivers/misc/lkdtm/heap.c | 1 + > > include/linux/compiler_attributes.h | 5 +++++ > > include/linux/fortify-string.h | 7 +++++++ > > 3 files changed, 13 insertions(+) > > Hi Kees, > > Circling back on this, I noticed that all but this patch got pulled into > Linus' tree. Is there a reason why this has been held back? Hi! Yeah, it depended on a bunch of various clean-ups, which have finally managed to land. It's late enough in the devel cycle that I suspect I will hold this one back until after the merge window and then make sure it has plenty of time to bake in -next. If the rest of the patches continue to behave, I may change my mind... :) -Kees -- Kees Cook