Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp634298imm; Thu, 13 Sep 2018 05:33:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbSrMEjCPnOwZiLZAJeHP1U2dXcR9WDdmDUccK5JOeCICl1B9gf+Nug+5FvTnGTr3JRZn7k X-Received: by 2002:a63:9551:: with SMTP id t17-v6mr6834389pgn.432.1536842017213; Thu, 13 Sep 2018 05:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536842017; cv=none; d=google.com; s=arc-20160816; b=xuApyXKZFHynnq8Bn6r77Z9Cijyv0KWDxMQZr5ADcDVbtlbpuFJTJlz1Z/Kp1DqJFX VP5okC15omFZTtnQ2UPE67BjPjm4L8IE8KAlWUTxXFC0U26WIUI3yMqY/DOiqnaWZfIy VsVYD0XYhLqGi0dx4XU80NuUjs/o8dnRyHNbFLz2t1qHWScoUiimXZycfT6tGMpE265H EzceI3uoIvnfTDQN1ZR1FYW4SeN+HzTTQSQKZElApu4m+TRQTtj4D84eZ91uHDpe5VSi yUwjV5n2lM6EumIdnRUcmII8Sy3L5enx/QHFcYMWlz+QsFhuCbsgnvjCDkGRSQcljgkt +JsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LIspygbBKjgywJ6fd0g0bpGlzgsVSuJpH7pUxXvDb+0=; b=TcCjCpSyVR690Ht9sxHfTP3gmcUOQroCpQ95sQ591BcgMbKlIDu6I2zq6OC/bWG6V2 NlF4Pm60f+POrw4reQPnTuxEVn8KBA9SEV8jYccT/mnLXAjZMbpLKEaXQasBmK4eETb3 gllCZJzEGmrKq84X0pIdPAfO4sxO1YlnzFHQnZRXdpb4wBY5dOFOYdZ4E27e0zcr9F53 0geYkLbD695IJw9TixgoFcStQipBUz/rcvd3ZUcKCxPD2+Yu9wDLA8zjWggoGrxKRu20 90I+rqQ7oQvHRP8e57ELHexaxw/Dx19QHt+fj7GQ3owdHZchQVfW+9eo7LBwPkQDTs9G xVTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TzeBlIQR; 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 h7-v6si4005583plt.258.2018.09.13.05.33.21; Thu, 13 Sep 2018 05:33:37 -0700 (PDT) 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=TzeBlIQR; 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 S1727403AbeIMRlK (ORCPT + 99 others); Thu, 13 Sep 2018 13:41:10 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:45303 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbeIMRlK (ORCPT ); Thu, 13 Sep 2018 13:41:10 -0400 Received: by mail-yw1-f68.google.com with SMTP id p206-v6so1063585ywg.12; Thu, 13 Sep 2018 05:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LIspygbBKjgywJ6fd0g0bpGlzgsVSuJpH7pUxXvDb+0=; b=TzeBlIQRwS8fqYznvTzCeIbo9iM+y9nzYl3MNzWCJyWg9FOd0oRBpb8FepKRtHFpVD EAKEyPcXGbnXsxzjdUuHqauiSb7vPRg+XC53qAxmS8PtHh0eZb6zBRdaVRXdUSDKWSxV dJrATqREJmd2bUIuYE9nBD3mPijSlhH7iJk6P+L3NawEKzVBNB7HSkcCgzC58Cgod0T3 sXPebfcVoEED2mNQ5sgmHooqTkHZI2Xo9mRA1MOWUcdc8NFANZkr2g5rb01q8aJkOZDg Nx91JTU2kYMDkQssvv+lOl3EfR17XdKz7dEnHckMOZmSnsqx2tAslHYlALwwqq3Hlelk 08rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LIspygbBKjgywJ6fd0g0bpGlzgsVSuJpH7pUxXvDb+0=; b=FG1olIpiTcI5lKqSwqrGMjEKgceocGYni2yxrsOERbND+YQQpAMK6GhYycM38U8bi5 wtSbhM+0JxrqjFoAmP5WSkPw0XCXPeEf0n9YmdQpqm2NZnXpt1oIA5UtKqi7q7q7gyBt FsgpK93xf0F7Prs2HFQtOkc+9nH9wYwiG/uTA0zS317HLHu3lXryt7XRC/JhGT8mcxn/ GzQUmhR90208ar6WcBRwkgunKc1OSb44EgCIfjk8r3TkgRkwBtLBvbSXyFzPUqvWupdi xXkzSBkWYWJVAZRa8qDr7zzqEd/6OuEDzNlLC3HXpytxNlbTEEAjTI47YBiFhROZmmdv 45bA== X-Gm-Message-State: APzg51AfrRPiwOJ023Ios+HfEX2B+GWwhaaRyw6ncb+6ziRfIEFPOt/y VU0mNg1gqN47HUiKojxL3DAwOoBHB3p9nqglinI= X-Received: by 2002:a81:ac09:: with SMTP id k9-v6mr3349578ywh.409.1536841913575; Thu, 13 Sep 2018 05:31:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amir Goldstein Date: Thu, 13 Sep 2018 15:31:42 +0300 Message-ID: Subject: Re: Is it possible to add pid and comm members to the event structure to increase the display of user and thread information? To: nixiaoming@huawei.com Cc: Eric Paris , Robert Love , John McCutchan , Jan Kara , Al Viro , linux-kernel , linux-fsdevel 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 On Thu, Sep 13, 2018 at 2:25 PM Nixiaoming wrote: > > On Tue, Sep 11, 2018 at 11:12 PM Amir Goldstein wrote: > >On Tue, Sep 11, 2018 at 9:51 AM Nixiaoming wrote: > >> > >> Inotify api cannot display information about users and processes. > >> That is, you can only know that the file event is generated, but you don't know who triggered the event, which is not conducive to fault location. > >> Is it possible to add pid and comm members to the event structure to increase the display of user and thread information? > >> > > > >"Is it possible?" is not the only relevant question. > >I suppose your patch can sort of works, but it exposes information to > >potentially unpriveleged > >processes, even exposes pid values outside of the process pid namespace. > > > >While those issues could be addressed, you can't change the format > >struct inotify_event > >without breaking existing applications. > > > In order to improve the fault location capability, can we make incompatible interface changes? Not unless application/sysadmin/distro opts-in for the incompatible change. > > >I guess you are not using fanotify API, which already provides pid > >information (albiet tgid), > >because it lacks other functionality that you need? Which > >functionality might that be? > >Is it directory modification events? > >If so than you might be interested in my effort to add support for > >those events to fanotify: > >https://github.com/amir73il/fsnotify-utils/wiki/Super-block-root-watch > > > The fanotify API does not support monitoring file deletion events Yes, I am working toward that goal. > The fanotify API supports tgid display, > but for multi-threaded programs, > it still cannot accurately identify which thread triggered the event. > Can I modify tgid to pid? > - event->tgid = get_pid(task_tgid(current)); > + event->tgid = get_pid(task_pid(current)); > So if you would like to change that you need to add a new flag to fanotify_init (e.g. FAN_EVENT_INFO_TID) new applications that would opt-in for the flag will get task_pid() while existing application will keep getting task_tgid() new applications will get -EINVAL when passing FAN_EVENT_INFO_TID to fanotify_init() on an old kernel and they could then fall back to getting tgid in events and be aware of that fact. Thanks, Amir.