From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id 714113858C1F for ; Tue, 5 Sep 2023 13:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 714113858C1F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-57355a16941so1638495eaf.2 for ; Tue, 05 Sep 2023 06:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693919684; x=1694524484; darn=sourceware.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q4OZvohENuDEsxWGeQaHwOw1hRZ+N+GiYfXOcSuacCU=; b=ig21OxRJ/zYwhfmUvp9fWRwSUQNu2jHwXWFmx5O5lOi7BmLf43fEfgX2OS0O/+tiZQ W2ImembYveg8OUFMok3OBMDzLhUGpyr3hDstO5be2C1NotTrTcIDjaFIoEzaUf9xxJ0w yJw17riG1o+4+obA4NGL/1FMpBEIqybYyRtB4rYNRNzvmOuy0MPD9N5en7zddn8uEhr/ /RXyjHVJT08zWYrLi54lQ/0xXBc4H6jYEaGANXW2+SCb2EuANpluRspPsA+lVWisjlgQ Pbw9I/KjkxuGXLKSBZEI2PYIYM1qBpCkMVWKdM7V8FiOqHCgWtCwEOoAG70pp+RCWASx at2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693919684; x=1694524484; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q4OZvohENuDEsxWGeQaHwOw1hRZ+N+GiYfXOcSuacCU=; b=BsXC8rJqQlExgoC1N7H9ppS0GrBIRfJt008bE/NgSjAAMHdCYWdwP2ExUTwMCsq1aW ILEhCP84Yozoj0hsCgcleissavD2xyFbF1XsqNvFLa+BxNgSIDIo7XZ7hSAL8DLNrl7a iH8CQar5aP/SMfEFRlebPpWL8XHHLkjKxg7RRifD2i/xQGlrqWTyy2q7z+6UUtlCTYhr etKMIHqNd+H2YhP43xwuXqbKhMkRFOzue7DZZ1z6vGt5mpf7GSavr7qYVHya2MZdKPi2 I17LH4SJaKnB+Ix4VOPPpblCzS0Gs6bXn9N40AypNwhp0Hi5PP1ojsGNvsutSkZqPnwA T03w== X-Gm-Message-State: AOJu0Yx7dnchvlphR/MXTgACPUe82v7Qaiq/0Nht0nZ9rnkAkmn7wD6i TDCAds6+zPoT+MPtkDeLnew/Hl7DaVxWVRrMpQI= X-Google-Smtp-Source: AGHT+IG88KqozIUHFuu1wgLPoItpRVYkUJ49PrkdD1sOmu0PIO8CCmQMms/ODfxoCz9eKUHgMb5OvtMVLpSniJUlztc= X-Received: by 2002:a4a:d212:0:b0:573:4da2:4427 with SMTP id c18-20020a4ad212000000b005734da24427mr11223177oos.7.1693919683622; Tue, 05 Sep 2023 06:14:43 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:60c:0:b0:4f0:1250:dd51 with HTTP; Tue, 5 Sep 2023 06:14:43 -0700 (PDT) In-Reply-To: <680b330d-6ef3-adc5-9ba6-cf74dd53e422@linaro.org> References: <680b330d-6ef3-adc5-9ba6-cf74dd53e422@linaro.org> From: Mateusz Guzik Date: Tue, 5 Sep 2023 15:14:43 +0200 Message-ID: Subject: Re: fstat(2) penalized by using newfstatat(6, "", buf, AT_EMPTY_PATH) To: Adhemerval Zanella Netto Cc: Andreas Schwab , Rich Felker , Mateusz Guzik via Libc-alpha , Linus Torvalds Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 9/5/23, Adhemerval Zanella Netto wrote: > If I understand correctly, the issue seems to be the usage of a empty string > > sentinel ("") to indicate the argument it not really used (which trigger > all > the SMAP issues since kernel will always try to copy the argument from > userland). This also means on x86_64 you will also have this performance > penalty on syscalls that use AT_EMPTY_PATH (i.e, execveat, > name_to_handle_at, > open_tree, faccessat, etc.). I really think it would better fixed in the > kernel instead of adding extra constraints for the userland. > I completely agree this is a problem going way past fstat. One could be tempted to allow NULL with the flag, but that wont work -- I know of code out there which checks for statx availability by deliberately passing a NULL path. I would not be shocked if there was more of the sort and passing the AT_EMPTY_PATH flag on top. I am considering proposing a new flag which combined with NULL path would indicate there is only a fd lookup to perform -- fuly backwards compatible and avoiding the problem. Then syscalls could start supporting it over time as people get around to it. However, the fstab stub in glibc does not have to suffer it regardless of what happens with the above. -- Mateusz Guzik