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 74159C7EE2D for ; Fri, 3 Mar 2023 17:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231478AbjCCRy2 (ORCPT ); Fri, 3 Mar 2023 12:54:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbjCCRyZ (ORCPT ); Fri, 3 Mar 2023 12:54:25 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D7A5B5F2 for ; Fri, 3 Mar 2023 09:54:19 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id g3so13643144eda.1 for ; Fri, 03 Mar 2023 09:54:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1677866058; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2o3rQetZgv6ewfCPpQy7L56u60VboNrnPcXuCAU8c9I=; b=e2Ior9ml2a6sA3xqp7/mjoi0eleFZCbAWkfIeYEfktk8tXziMAOZD/rb60OwD1S8Tq 0ZKD5Fv3R1sSQd0bkxwWKqa3qP3F6K54E1OHOetzjSw1or205pyp9m8SbKstEClDabn9 z96OmJ2w4kxlFMTrccZmn1jsSCSNXTRtfFVQs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677866058; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2o3rQetZgv6ewfCPpQy7L56u60VboNrnPcXuCAU8c9I=; b=sU146MQwo5M3w/XdEYr0Ks1SAQSLGFM82iArM03o5Nxz3Wad23UD0ejnQFcmbdvcIH W37DClVPYz8OGNC/RrsQGV54V4BMLElhI58l+PsYNjMAf/8pNn0WFAohWqRTb6ujod7E g0ctrUTzGK5zDqolUW8L6no3Z8aMDa+BW3KAZoNDqt9xd7TO7e5b7TRzf1+eLF9Nl9Xj FjjNFvcgkKflqKzXQRES1bbHSUB51qkT+Zoy5IviUtMFfvKdskcFeMTyZBXiIMnteogt Qj6mQiUflKAq9vzl8oHKJvAWbMQfCXZgNBgAkpHGuU2JqOIMYbytAsq++qBwJPAC+2Cf 5W4g== X-Gm-Message-State: AO0yUKUoSYIKJeWL7Wz9iyFafAE/te7yzGtfsqjEcXGAd7zqkAn2Gn1G 2wuUJk4ab9Ug66eaqokggfHGRmr8/918Z4LzHIkJUQ== X-Google-Smtp-Source: AK7set8BHZI14OzZncCww7YWnP5zUTBZKCEkVTp3nAKw8PnDAkyA6b9GubeHU20zg1L+hkSx3EhU8Q== X-Received: by 2002:a17:907:8d02:b0:8ee:babc:d40b with SMTP id tc2-20020a1709078d0200b008eebabcd40bmr2775139ejc.58.1677866057923; Fri, 03 Mar 2023 09:54:17 -0800 (PST) Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com. [209.85.208.53]) by smtp.gmail.com with ESMTPSA id kq17-20020a170906abd100b008e82cb55195sm1161112ejb.203.2023.03.03.09.54.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Mar 2023 09:54:17 -0800 (PST) Received: by mail-ed1-f53.google.com with SMTP id i34so13519909eda.7 for ; Fri, 03 Mar 2023 09:54:17 -0800 (PST) X-Received: by 2002:a17:906:b281:b0:8b8:aef3:f2a9 with SMTP id q1-20020a170906b28100b008b8aef3f2a9mr1190087ejz.0.1677866056901; Fri, 03 Mar 2023 09:54:16 -0800 (PST) MIME-Version: 1.0 References: <20230302083025.khqdizrnjkzs2lt6@wittgenstein> <6400fedb.170a0220.ece29.04b8@mx.google.com> In-Reply-To: From: Linus Torvalds Date: Fri, 3 Mar 2023 09:54:00 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 2/2] vfs: avoid duplicating creds in faccessat if possible To: Mateusz Guzik Cc: Alexander Potapenko , Al Viro , Kees Cook , Eric Biggers , Christian Brauner , serge@hallyn.com, paul@paul-moore.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 3, 2023 at 9:39=E2=80=AFAM Mateusz Guzik wr= ote: > > So the key is: memset is underperforming at least on x86-64 for > certain sizes and the init-on-alloc thingy makes it used significantly > more, exacerbating the problem One reason that the kernel memset isn't as optimized as memcpy, is simply because under normal circumstances it shouldn't be *used* that much outside of page clearing and constant-sized structure initialization. Page clearing is fine, and constant-sized structure inits are also generally fine (ie the compiler does the small ones directly). So this is literally a problem with pointless automated memset, introduced by that hardening option. And hardening people generally simply don't care about performance, and the people who _do _care about performance usually don't enable the known-expensive crazy stuff. Honestly, I think the INIT_ONCE stuff is actively detrimental, and only hides issues (and in this case adds its own). So I can't but help to say "don't do that then". I think it's literally stupid to clear allocations by default. I'm not opposed to improving memset, but honestly, if the argument is based on the stupid hardening behavior, I really think *that* needs to be fixed first. Linus