Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2647244imj; Mon, 11 Feb 2019 06:25:50 -0800 (PST) X-Google-Smtp-Source: AHgI3IbQAgDUGFMlE6nZ0I3eBIQcVErU3asUfvRcEBd41xl6d23IB9p5REJ/k0X0Gg4zrUxo1cCj X-Received: by 2002:aa7:80c8:: with SMTP id a8mr36754231pfn.27.1549895150168; Mon, 11 Feb 2019 06:25:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895150; cv=none; d=google.com; s=arc-20160816; b=EzosfrZRKKAmrjWl7C+qE9oC8rmFn7fFrF1iSPqWHElfQZAmYrRz+j6LB2HOsp0IcA qN44WMv5NaRVta+9hWUJV0Yh6SV8LcXgjp7FzB/1qm1UkWTmD7Z1drC6V5ckHYHNjr44 LtcGtR3U2r6YsCiWeAOa150/zqtZN68WaG4hIQ56VDMVRWW8PnP8HPOVTtFcGvZwfy57 3yqWuzaZ9DR3OF91InhdkMuMVRrvL9bmAIUHDyyTw0+HRFwvKcBT7p/FFKV6aBPfSxkw k5TAzNRffM2j1OXB8fNqQQCGaUq1ME4161p6x6wSkkQoGWdcQTe+LYx5YUjOHvUGElm9 +5Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature; bh=LqUzA0haoMVtFXo57c/1ju9sSjnsaaLY1RlWjjtLBYQ=; b=1HswDPt93MpYOwk6+XJvc608CyuPjk/yCwYpfp59PiGsknzLzfrNGdzw3SbadELL2u NoBy0LU71x14JHyQg2Suht25wggNvDiZbjjjC+5KMvBqRX+EdQos8LNN/EUWaZztb+o6 grXPuJIRZju+FZYkbdZQD/9h64c9uYPq8ztamQTS1PcfNw98N2T/MnjJAJraznyed573 ff2uQwTBRJoI2wzKMegFiNUFWOby7OCLgCOIKUeicd+Rk/RnJzs6vUtWiewnkMaY6FAV vAVnxtE1MOCsXQmNcSjh3Y3vR5loGNtcz+RCQmoPeCq2lBz9mjmsV0VeJTJDpkAOt07H t9Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DOVYKPSS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si9351115pgq.144.2019.02.11.06.25.33; Mon, 11 Feb 2019 06:25:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DOVYKPSS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728246AbfBKOSX (ORCPT + 99 others); Mon, 11 Feb 2019 09:18:23 -0500 Received: from mail-pf1-f173.google.com ([209.85.210.173]:43627 "EHLO mail-pf1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726796AbfBKOSX (ORCPT ); Mon, 11 Feb 2019 09:18:23 -0500 Received: by mail-pf1-f173.google.com with SMTP id q17so1953818pfh.10 for ; Mon, 11 Feb 2019 06:18:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=LqUzA0haoMVtFXo57c/1ju9sSjnsaaLY1RlWjjtLBYQ=; b=DOVYKPSSAjEuernO5KShulmYkGFuLI41zzMqN7AG7wO+OIRyQ2w08jbARNCJv8QkkJ Z8TEfULUmhNqcr8TiTIKXuSIzt0vJ6cZiWIvWOfPDzvdMdIhObL+EPYZEWuUJjlFy5Sq cAI2T1zbHxaFfDjAxRktkqOZg6y5Ltg0l3O79iIKfiBkWPWqBbRY7axlRPkInuHploPj rcjYGh1L6ybW2uAfGD/OWRYmvzMX10YUVzmt8gPhamBo0BTbj4+L886dhfv5J0Y35CE4 HxsSnUriCiUMT1MrvJa+vrXbySkohnzVycpSOXDtMICBu2iwHlhF/2ZOVMa98rnxVShS MwZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=LqUzA0haoMVtFXo57c/1ju9sSjnsaaLY1RlWjjtLBYQ=; b=e+leRM859AVzuHlmqTRz7xe+Cbgn5fH2XcBpEUluu4MoRzqT9eBDLN4yFqRXf0fbSC e61bojqFSt3zIihdu05M1QA8Y1h1BJXyjfcy2fUI9KA8ow9dgUT5pVxWFDHL0wbi+dUd m00wrpb4p8Xuf8GIfWf+WKO8cAqRBVsJooz0qkPKZieAnk0od42LvFo5io4Ok3I+A9fD dvUGhKw8V8F1wNZGUffstiP7xw2yRsWsZGcneiZzdTaM1h+bsHkVSehH/lbUDjBoUHbf cIPGUwloWxsMitEPmNzo75N6MTzSiDn5YTPq9M10smi9zMU848KXV/eW60zyH8NlOcxz Rgcw== X-Gm-Message-State: AHQUAuankKn1ruP9z/zCfFP8UhqF0s6FNZdOAjB3FhDdNnmdQCfLmEgf Y1H/v/22Dgt2hTo4eXJi3Oz34YINKHseN+gUjf0sppQT X-Received: by 2002:a62:4188:: with SMTP id g8mr6897722pfd.205.1549894702035; Mon, 11 Feb 2019 06:18:22 -0800 (PST) MIME-Version: 1.0 From: Matej Kupljen Date: Mon, 11 Feb 2019 15:18:11 +0100 Message-ID: Subject: tmpfs inode leakage when opening file with O_TMP_FILE To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, it seems that when opening file on file system that is mounted on tmpfs with the O_TMPFILE flag and using linkat call after that, it uses 2 inodes instead of 1. This is simple test case: #include #include #include #include #include #include #include #include #include #define TEST_STRING "Testing\n" #define TMP_PATH "/tmp/ping/" #define TMP_FILE "file.txt" int main(int argc, char* argv[]) { char path[PATH_MAX]; int fd; int rc; fd = open(TMP_PATH, __O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); rc = write(fd, TEST_STRING, strlen(TEST_STRING)); snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd); linkat(AT_FDCWD, path, AT_FDCWD, TMP_PATH TMP_FILE, AT_SYMLINK_FOLLOW); close(fd); return 0; } I have checked indoes with "df -i" tool. The first inode is used when the call to open is executed and the second one when the call to linkat is executed. It is not decreased when close is executed. I have also tested this on an ext4 mounted fs and there only one inode is used. I tested this on: $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS" $ uname -a Linux Orion 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux If you need any more information, please let me know. And please CC me when replying, I am not subscribed to the list. Thanks and BR, Matej