From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63923C3815B for ; Mon, 20 Apr 2020 17:54:07 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1922A218AC for ; Mon, 20 Apr 2020 17:54:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AJUMCbXH"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AJUMCbXH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1922A218AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 495Z7x40v7zDqSD for ; Tue, 21 Apr 2020 03:54:05 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=eesposit@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AJUMCbXH; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AJUMCbXH; dkim-atps=neutral Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 495SyW3rz6zDqpd for ; Tue, 21 Apr 2020 00:00:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587391232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ap4e89Z5vNdiNiGm/tjhzWgeUaBL0Wv/6U7AnurRbQ0=; b=AJUMCbXHRU49iok0VBo/nAwL9QRz8/I0M81qk8pGkN6lA3aLxUc9SQLlXcFfuezbkk9lZr jr/3TepM9G90YDZ35/SvGNcRcxpM/VGcy2V5duArPHPu1SeCcflKPIV163X/IRqHUXo+ky Y6Lj74NDvbZd+udLR8eyw4znYYV0UOo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587391232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ap4e89Z5vNdiNiGm/tjhzWgeUaBL0Wv/6U7AnurRbQ0=; b=AJUMCbXHRU49iok0VBo/nAwL9QRz8/I0M81qk8pGkN6lA3aLxUc9SQLlXcFfuezbkk9lZr jr/3TepM9G90YDZ35/SvGNcRcxpM/VGcy2V5duArPHPu1SeCcflKPIV163X/IRqHUXo+ky Y6Lj74NDvbZd+udLR8eyw4znYYV0UOo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-vZT2SmNuP4G990-Qi1fgWw-1; Mon, 20 Apr 2020 10:00:25 -0400 X-MC-Unique: vZT2SmNuP4G990-Qi1fgWw-1 Received: by mail-wr1-f70.google.com with SMTP id h95so5719684wrh.11 for ; Mon, 20 Apr 2020 07:00:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ap4e89Z5vNdiNiGm/tjhzWgeUaBL0Wv/6U7AnurRbQ0=; b=kc/RPihnenQ9QAxWQe9BIyr+eI1/LeEw14rCRuHXbbB5BXQGHreyz9RpCwnErYRgPI A9JAaCmqCSaHn1KNT6CD7A/Oq9CsfHsXuxqXQ6epxZWc4sWOc6QyFhsI095DZshMT/1i 1Q6xOgT3QWPlYfoW13m3RAHvbvD5DlDLrbx6HQ8REiiLUeAf+I/TzyDJBG13/xE22liW Jog1HJNCJ2FMevrS2++/Ttg/Agz4AZ6y+rlj87hYOgUsnakNlG9Oaf9kC6rIJrxyCeKK JZllGJtuN6zB0iW8wj4eA+Q8jPRLcESG+8CArVPuZJHdJwJ5MY6+XMn1/OJYmutpc77g XnMQ== X-Gm-Message-State: AGi0PuZzXxZQBAqVoaJDTa4YyIwA+4/ln6CMS+RLgLa6IHzxMbAueIev RA27WbnZ6gBKAa7OwYpisewHRNpTUcdpWxSX4iJfHKaifYSdhk2TJ8fxVGMJw+7meErMQos+xXn USycy3YaiXbtjpoKAHyq/KW668w== X-Received: by 2002:a5d:60ca:: with SMTP id x10mr18569362wrt.407.1587391224625; Mon, 20 Apr 2020 07:00:24 -0700 (PDT) X-Google-Smtp-Source: APiQypLuajiTV7NEgCOZK10Fc0BkrmLxAQ9cfXlRSa6GAO61DcTGLWRq8QjX/dO+TqmoPL2oG86JsA== X-Received: by 2002:a5d:60ca:: with SMTP id x10mr18569290wrt.407.1587391224344; Mon, 20 Apr 2020 07:00:24 -0700 (PDT) Received: from localhost.localdomain ([194.230.155.102]) by smtp.gmail.com with ESMTPSA id p5sm1511446wrg.49.2020.04.20.07.00.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Apr 2020 07:00:23 -0700 (PDT) From: Emanuele Giuseppe Esposito Subject: Re: [PATCH 1/8] apparmor: just use vfs_kern_mount to make .null To: Luis Chamberlain , Goldwyn Rodrigues References: <20200414124304.4470-1-eesposit@redhat.com> <20200414124304.4470-2-eesposit@redhat.com> <20200416064405.GP11244@42.do-not-panic.com> Message-ID: Date: Mon, 20 Apr 2020 16:00:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200416064405.GP11244@42.do-not-panic.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Tue, 21 Apr 2020 03:37:29 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Liu , linux-usb@vger.kernel.org, bpf@vger.kernel.org, "Rafael J. Wysocki" , David Airlie , Heiko Carstens , Alexei Starovoitov , dri-devel@lists.freedesktop.org, "J. Bruce Fields" , Joseph Qi , Hugh Dickins , Paul Mackerras , John Johansen , netdev@vger.kernel.org, linux-s390@vger.kernel.org, Christoph Hellwig , Andrew Donnellan , Matthew Garrett , linux-efi@vger.kernel.org, Arnd Bergmann , Daniel Borkmann , Christian Borntraeger , linux-rdma@vger.kernel.org, Mark Fasheh , Anton Vorontsov , John Fastabend , James Morris , Ard Biesheuvel , Jason Gunthorpe , Doug Ledford , Yonghong Song , Ian Kent , Andrii Nakryiko , Alexey Dobriyan , "Serge E. Hallyn" , Robert Richter , Thomas Zimmermann , Vasily Gorbik , Tony Luck , Kees Cook , "James E.J. Bottomley" , autofs@vger.kernel.org, Maarten Lankhorst , Mike Marciniszyn , Maxime Ripard , linux-fsdevel@vger.kernel.org, "Manoj N. Kumar" , Uma Krishnan , Jakub Kicinski , KP Singh , Trond Myklebust , "Matthew R. Ochs" , "David S. Miller" , Felipe Balbi , linux-nfs@vger.kernel.org, Iurii Zaikin , linux-scsi@vger.kernel.org, "Martin K. Petersen" , linux-mm@kvack.org, Greg Kroah-Hartman , Dennis Dalessandro , Miklos Szeredi , linux-kernel@vger.kernel.org, Anna Schumaker , linux-security-module@vger.kernel.org, Chuck Lever , Jeremy Kerr , Daniel Vetter , Colin Cross , Frederic Barrat , Paolo Bonzini , Andrew Morton , Mike Kravetz , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , Joel Becker , Alexander Viro Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 4/16/20 8:44 AM, Luis Chamberlain wrote: > On Tue, Apr 14, 2020 at 02:42:55PM +0200, Emanuele Giuseppe Esposito wrote: >> aa_mk_null_file is using simple_pin_fs/simple_release_fs with local >> variables as arguments, for what would amount to a simple >> vfs_kern_mount/mntput pair if everything was inlined. Just use >> the normal filesystem API since the reference counting is not needed >> here. > > *Why* is refcounting not needed here? The refcount is a local variable and is always 0 on entry and exit, so it is not necessary to have refcounting across function invocations, such as what simple_pin_fs and simple_release_fs provide. Thank you, Emanuele > > Luis > >> >> Signed-off-by: Emanuele Giuseppe Esposito >> --- >> security/apparmor/apparmorfs.c | 12 ++++++------ >> 1 file changed, 6 insertions(+), 6 deletions(-) >> >> diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c >> index 280741fc0f5f..828bb1eb77ea 100644 >> --- a/security/apparmor/apparmorfs.c >> +++ b/security/apparmor/apparmorfs.c >> @@ -2525,14 +2525,14 @@ struct path aa_null; >> >> static int aa_mk_null_file(struct dentry *parent) >> { >> - struct vfsmount *mount = NULL; >> + struct file_system_type *type = parent->d_sb->s_type; >> + struct vfsmount *mount; >> struct dentry *dentry; >> struct inode *inode; >> - int count = 0; >> - int error = simple_pin_fs(parent->d_sb->s_type, &mount, &count); >> >> - if (error) >> - return error; >> + mount = vfs_kern_mount(type, SB_KERNMOUNT, type->name, NULL); >> + if (IS_ERR(mount)) >> + return PTR_ERR(mount); >> >> inode_lock(d_inode(parent)); >> dentry = lookup_one_len(NULL_FILE_NAME, parent, strlen(NULL_FILE_NAME)); >> @@ -2561,7 +2561,7 @@ static int aa_mk_null_file(struct dentry *parent) >> dput(dentry); >> out: >> inode_unlock(d_inode(parent)); >> - simple_release_fs(&mount, &count); >> + mntput(mount); >> return error; >> } >> >> -- >> 2.25.2 >> >