From patchwork Tue Apr 21 13:51:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 11501463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DE41913 for ; Tue, 21 Apr 2020 13:52:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15B53206D5 for ; Tue, 21 Apr 2020 13:52:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HfUMLZrT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbgDUNws (ORCPT ); Tue, 21 Apr 2020 09:52:48 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:53147 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726018AbgDUNwr (ORCPT ); Tue, 21 Apr 2020 09:52:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587477166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ctzOqm9dtwbhRf44FvKp72RdNODJeokpu4mABLVWWLc=; b=HfUMLZrTsjJZ5MTWakU6Ip/201mGT2WMl9QcFjlTe7A6HddnNMDK6nP8DbQiHilQZFLO7H MSr0IMDYxDVsPl6FsG8MICACavx314Be1Z0M4Z4mTVXsAQOSCIbIvuQqXqCqpDp+m0khtM MNs339MOGa196tWdeqdCnYlgi6Q5iow= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-cxI5wA78NOecVC8zStXncg-1; Tue, 21 Apr 2020 09:52:43 -0400 X-MC-Unique: cxI5wA78NOecVC8zStXncg-1 Received: by mail-wm1-f72.google.com with SMTP id b203so1392314wmd.6 for ; Tue, 21 Apr 2020 06:52:43 -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:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ctzOqm9dtwbhRf44FvKp72RdNODJeokpu4mABLVWWLc=; b=HN35cKR7mvp9R60ir5cRj329xIi/H/mBOqsoYgdSrKe/hyU0jQm9vyD1tn3+EQ7l1u nAxW+5WuDckwnZXFZ/sVV+5dpcYFc9KNG7/mv8SUgkz/pY4TAf1ckxHakGeEwArMKE3f F1z/q3oJoIB3YGSWsCohnT9LJgLE38+vMZtx8DDiNshIGrdNZiKKvWfu9Kz8g1lKt1la X+ukSiGqQqDBUgmn6WkXxxKLU/6MKIMHaRyOlCcFVy+qRjKPkhA2+ndHDPtm9FxSpyXt fFU4ejx2FFfFkrokEgAuzs7o4a2IoHDS3m43z9Zy39ib4ms2klJeuWUZhkF+u18kntZZ 0gyQ== X-Gm-Message-State: AGi0PubS3oVYw7gCZP15XZ4bJg16c4Z+LLeEA7UZO6XaUS1zzM9Iktlb tr8Il2iC0vtBCg6YrKnm9H88+iDAoVkewqKJ0hOk0N7AdHIwS+Hes9pTba8/jK63OQf6t8uhW+Z YTBuuJPVDEHRz6FD3F1Xijg== X-Received: by 2002:adf:fd0a:: with SMTP id e10mr23759627wrr.160.1587477102566; Tue, 21 Apr 2020 06:51:42 -0700 (PDT) X-Google-Smtp-Source: APiQypKYYb14rVpuN5IdJGjcztA4u7H/3dUDNtMGXdL7LsdIhh9n0qcoiv0NvYygrC3tIbBHwPH97A== X-Received: by 2002:adf:fd0a:: with SMTP id e10mr23759618wrr.160.1587477102414; Tue, 21 Apr 2020 06:51:42 -0700 (PDT) Received: from localhost.localdomain.com ([194.230.155.194]) by smtp.gmail.com with ESMTPSA id a187sm3565830wmh.40.2020.04.21.06.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:51:41 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-fsdevel@vger.kernel.org Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro , Joel Becker , Christoph Hellwig , "Rafael J. Wysocki" , John Johansen , James Morris , "Serge E. Hallyn" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-scsi@vger.kernel.org, linux-security-module@vger.kernel.org, Paolo Bonzini , Emanuele Giuseppe Esposito Subject: [PATCH v2 1/7] apparmor: just use vfs_kern_mount to make .null Date: Tue, 21 Apr 2020 15:51:13 +0200 Message-Id: <20200421135119.30007-2-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com> References: <20200421135119.30007-1-eesposit@redhat.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 (it is a local variable and always 0 on entry and on exit). There is no functional change intended. Signed-off-by: Emanuele Giuseppe Esposito --- security/apparmor/apparmorfs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 280741fc0f5f..36f848734902 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -2525,14 +2525,15 @@ 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); + int error; - 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 +2562,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; }