Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp7339022pxv; Fri, 30 Jul 2021 16:31:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDFuh4epXs7UQe0NmE2q21CGocNfX/tRJkCXOoNnURMg2qO7K7fwPSm94GkavzSbwks9KA X-Received: by 2002:a17:907:1c08:: with SMTP id nc8mr5237011ejc.514.1627687874581; Fri, 30 Jul 2021 16:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627687874; cv=none; d=google.com; s=arc-20160816; b=YdT3jzjG/SfpVFhoovXJ9pOPZo7aHyfFgBzc8Hu71SZ1JzZHOB2IkwXEx5fI28DHfJ XsBOLAnU867Xg9sFtO8Wnq6ZHMtNwnfJgiryhNN4AyCJgsm/irrHdGaa1RuqXj3ggRXL lAkMdtEPhMfMUAMqb+q8L1r8gIaRm1WI+i6BTY9B80PCou18scVdC6vTloZ0+l+eOLkI Zq2oA73EsUiVI2YKVq8zO/M0Kvq3TR9F5tsNznT959uo+snZ2M2vXXW8zUVaBI5OIdGd 6FFcI82b9zC12XrlbqNjnZKExhC2pMwtDWop4CQ3t8JfWB4UjcL+1dt4SP9ecktS7AO1 rJLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=R2NzCKKbyRjZX2qftJHyl3+a3Qvsi60rhgsy0EBiLdU=; b=0evWQxXm1BDgsuCAnwtNYFPlgf5ibKfkokEsBqjwAwer0V+V3auIc2Pn9vaizG8eQ2 HOpnbYdxC0nidrEQC5UfMVYadEz0Gkx3/XCIULC5ru7HCTp39nA6De6XZ7gtd8bACpHY OlrFVkF8rn3DR3E6QlhYXkqo9GR7oOBOBKCl5L0GSon6DLaRCiXtI58lCLA1nfjn+QFC JnvvBpPFuS0zFfeXjk2CRvMy6/t1zw2NTR6fEiq0Luqq8vwKxc817/3iJ4qbaWLRVKlX TiH+DuXvZWrXWM6OHRwDcDaAyn6NQnSprK14CrFadPLmvVKR2NezPd1xrjNGJnfNiYIy msmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=qCjCqQe+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si3448995ejm.0.2021.07.30.16.30.37; Fri, 30 Jul 2021 16:31:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=qCjCqQe+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233654AbhG3XZH (ORCPT + 99 others); Fri, 30 Jul 2021 19:25:07 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:38584 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233500AbhG3XZG (ORCPT ); Fri, 30 Jul 2021 19:25:06 -0400 Received: from [192.168.192.153] (unknown [50.53.57.186]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id BD8333F0B9; Fri, 30 Jul 2021 23:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1627687499; bh=R2NzCKKbyRjZX2qftJHyl3+a3Qvsi60rhgsy0EBiLdU=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=qCjCqQe+AR3SYMVkzD5FHOL3Hgcyd2Gmjtcbk6UTTQqFajgm+oF26shEi4YFCMntw WuvcZG9ULRWh2yHqtybWEj0Lp6eT8JyN7hkJckTUTZX0mslW2yzR1pt18TmwpWgrfF RhFzUr/dxsxa1aazt1X9VxFcVoV7xwe5GO339bfuQYp7SmNjrNz40RMotnhegRqUwt TGQKyBedoJ8p4AkzUSE21wD1ywyO0O9K681Qa2FMI779q6Y4Ri3sLOpa+c3ImdIjAF csOhu7j5Z+uP6wV8qP19hzZNsQm+ID4TLSvzaZs1HczbV3DEmeY9SnZV3i5zfhmvS6 dA7oh3n+nxn5g== Subject: Re: [PATCH] apparmor: use per file locks for transactional queries To: Hamza Mahfooz , linux-kernel@vger.kernel.org Cc: James Morris , "Serge E. Hallyn" , linux-security-module@vger.kernel.org References: <20210730052355.77289-1-someguy@effective-light.com> From: John Johansen Organization: Canonical Message-ID: Date: Fri, 30 Jul 2021 16:24:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210730052355.77289-1-someguy@effective-light.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/29/21 10:23 PM, Hamza Mahfooz wrote: > As made mention of in commit 1dea3b41e84c5 ("apparmor: speed up > transactional queries"), a single lock is currently used to synchronize > transactional queries. We can, use the lock allocated for each file by > VFS instead. > > Signed-off-by: Hamza Mahfooz Acked-by: John Johansen I'll pull this into my tree asap > --- > security/apparmor/apparmorfs.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c > index 2ee3b3d29f10..c0b626a271a0 100644 > --- a/security/apparmor/apparmorfs.c > +++ b/security/apparmor/apparmorfs.c > @@ -812,8 +812,6 @@ struct multi_transaction { > }; > > #define MULTI_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct multi_transaction)) > -/* TODO: replace with per file lock */ > -static DEFINE_SPINLOCK(multi_transaction_lock); > > static void multi_transaction_kref(struct kref *kref) > { > @@ -847,10 +845,10 @@ static void multi_transaction_set(struct file *file, > AA_BUG(n > MULTI_TRANSACTION_LIMIT); > > new->size = n; > - spin_lock(&multi_transaction_lock); > + spin_lock(&file->f_lock); > old = (struct multi_transaction *) file->private_data; > file->private_data = new; > - spin_unlock(&multi_transaction_lock); > + spin_unlock(&file->f_lock); > put_multi_transaction(old); > } > > @@ -879,9 +877,10 @@ static ssize_t multi_transaction_read(struct file *file, char __user *buf, > struct multi_transaction *t; > ssize_t ret; > > - spin_lock(&multi_transaction_lock); > + spin_lock(&file->f_lock); > t = get_multi_transaction(file->private_data); > - spin_unlock(&multi_transaction_lock); > + spin_unlock(&file->f_lock); > + > if (!t) > return 0; > >