Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp908188rdg; Wed, 11 Oct 2023 08:44:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIwmza3lxWSvIoLL935G3f+D+fnMnTesg6OIqmpsili2YH5ojTB65ozC9xFYll4ObnAHLQ X-Received: by 2002:a05:6e02:156b:b0:352:6fff:ccb2 with SMTP id k11-20020a056e02156b00b003526fffccb2mr26266589ilu.16.1697039045108; Wed, 11 Oct 2023 08:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697039045; cv=none; d=google.com; s=arc-20160816; b=ylxI1swNw/QXaedWErwy65etfMli7osKmQeNNqP7t5YN9Yw35C+v5Yy8ucd6VYI7gP ombb+e+EVB4Tb2FY0MGKm6mcn+aVo9Ni/alHd5dbo0bee37X9D+OhUlJe5JL/qxertLt unQCYE4D06xC+xmhQ0zFRktC0pk5BfLH6EF0Ucer/uTBiv9jJOPcjMXF8Vrb/ob14RL8 Fv+XKDmX1+6O4buiPX2ZqnUnsRv6QLNZtVD9BDo4N+r+69BnbbLKcBWcCxhZa/KoEQMs UG5WNSXR9mcYc1OIK32HF7qG3l5Ufi1Qb0Il1N3hsmcuRGDwHwrYnmnrCpCmMuMZlzI7 /57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=CRqUT1vfLdQGfGcEYnloJtMkszKTucZ2dt5hlRIbC8g=; fh=BMDISS925nv2s85ZxrxzXkDi/5o9WlHacydApPuatVA=; b=qKH0IH77OrcvstX2IPUVlDatvGJnkQEst4fiz4iIjnlr4pLMct5HkX4QFRhygLhCz7 eygHAO9Ld0raVJyrCTgYLNTpcyAVQtQcGxJhmrmyzMuPlwlQZXCHvp9Jv6qGJfi9M861 ojooV1pk05KdIq/B4A3mFTXW/goUZrN+XPu/OfmA5RaDIkTAqVMpCJL8dJXZ54tuBUlw 1dmU9nPcv1pzNQECsiURhEfUg9/MUEvdqClsadrWPSQz3Sfdhz1lGj1WDuFVQ6oSAFuN soo01rvsO3xFvy6JAQSkUQIDaOC2oTzUQd4Oe5v95k8o5JbKFY5kSlwqML/6Hyz0Ds30 e1lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i70-20020a638749000000b0056949ba3f3fsi32768pge.253.2023.10.11.08.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 08:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7939B8160389; Wed, 11 Oct 2023 08:44:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235075AbjJKPn7 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Oct 2023 11:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346776AbjJKPn5 (ORCPT ); Wed, 11 Oct 2023 11:43:57 -0400 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C468F; Wed, 11 Oct 2023 08:43:54 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.227]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4S5Gv93w7mz9yGdg; Wed, 11 Oct 2023 23:31:01 +0800 (CST) Received: from [127.0.0.1] (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwCX8JGOwiZl4p0FAg--.29227S2; Wed, 11 Oct 2023 16:43:25 +0100 (CET) Message-ID: Subject: Re: [PATCH v3 04/25] ima: Align ima_file_mprotect() definition with LSM infrastructure From: Roberto Sassu To: Mimi Zohar , viro@zeniv.linux.org.uk, brauner@kernel.org, chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, kolga@netapp.com, Dai.Ngo@oracle.com, tom@talpey.com, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, dhowells@redhat.com, jarkko@kernel.org, stephen.smalley.work@gmail.com, eparis@parisplace.org, casey@schaufler-ca.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, selinux@vger.kernel.org, Roberto Sassu , Stefan Berger Date: Wed, 11 Oct 2023 17:43:07 +0200 In-Reply-To: <443fb4da33eb0ac51a580e8fd51fa271a59172ef.camel@linux.ibm.com> References: <20230904133415.1799503-1-roberto.sassu@huaweicloud.com> <20230904133415.1799503-5-roberto.sassu@huaweicloud.com> <443fb4da33eb0ac51a580e8fd51fa271a59172ef.camel@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 X-CM-TRANSID: LxC2BwCX8JGOwiZl4p0FAg--.29227S2 X-Coremail-Antispam: 1UD129KBjvJXoWxAF1ftrW5Xr45Kr13urW7Jwb_yoW5Kr4DpF s8Ka47GrWxJFy09ryIqa47ua43K3yIgw1UXa9Ig34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ILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 08:44:00 -0700 (PDT) X-Spam-Level: ** On Wed, 2023-10-11 at 10:51 -0400, Mimi Zohar wrote: > On Mon, 2023-09-04 at 15:33 +0200, Roberto Sassu wrote: > > From: Roberto Sassu > > > > Change ima_file_mprotect() definition, so that it can be registered > > as implementation of the file_mprotect hook. > > > > Signed-off-by: Roberto Sassu > > Reviewed-by: Stefan Berger > > --- > > include/linux/ima.h | 5 +++-- > > security/integrity/ima/ima_main.c | 6 ++++-- > > security/security.c | 2 +- > > 3 files changed, 8 insertions(+), 5 deletions(-) > > > > diff --git a/include/linux/ima.h b/include/linux/ima.h > > index 893c3b98b4d0..56e72c0beb96 100644 > > --- a/include/linux/ima.h > > +++ b/include/linux/ima.h > > @@ -24,7 +24,8 @@ extern void ima_post_create_tmpfile(struct mnt_idmap *idmap, > > extern void ima_file_free(struct file *file); > > extern int ima_file_mmap(struct file *file, unsigned long reqprot, > > unsigned long prot, unsigned long flags); > > -extern int ima_file_mprotect(struct vm_area_struct *vma, unsigned long prot); > > +int ima_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, > > + unsigned long prot); > > "extern" is needed here and similarly in 5/25. I removed because of a complain from checkpatch.pl --strict. Roberto > Mimi > > > extern int ima_load_data(enum kernel_load_data_id id, bool contents); > > extern int ima_post_load_data(char *buf, loff_t size, > > enum kernel_load_data_id id, char *description); > > @@ -88,7 +89,7 @@ static inline int ima_file_mmap(struct file *file, unsigned long reqprot, > > } > > > > static inline int ima_file_mprotect(struct vm_area_struct *vma, > > - unsigned long prot) > > + unsigned long reqprot, unsigned long prot) > > { > > return 0; > > } > > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > > index 52e742d32f4b..e9e2a3ad25a1 100644 > > --- a/security/integrity/ima/ima_main.c > > +++ b/security/integrity/ima/ima_main.c > > @@ -441,7 +441,8 @@ int ima_file_mmap(struct file *file, unsigned long reqprot, > > /** > > * ima_file_mprotect - based on policy, limit mprotect change > > * @vma: vm_area_struct protection is set to > > - * @prot: contains the protection that will be applied by the kernel. > > + * @reqprot: protection requested by the application > > + * @prot: protection that will be applied by the kernel > > * > > * Files can be mmap'ed read/write and later changed to execute to circumvent > > * IMA's mmap appraisal policy rules. Due to locking issues (mmap semaphore > > @@ -451,7 +452,8 @@ int ima_file_mmap(struct file *file, unsigned long reqprot, > > * > > * On mprotect change success, return 0. On failure, return -EACESS. > > */ > > -int ima_file_mprotect(struct vm_area_struct *vma, unsigned long prot) > > +int ima_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, > > + unsigned long prot) > > { > > struct ima_template_desc *template = NULL; > > struct file *file; > > diff --git a/security/security.c b/security/security.c > > index 96f2c68a1571..dffb67e6e119 100644 > > --- a/security/security.c > > +++ b/security/security.c > > @@ -2721,7 +2721,7 @@ int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, > > ret = call_int_hook(file_mprotect, 0, vma, reqprot, prot); > > if (ret) > > return ret; > > - return ima_file_mprotect(vma, prot); > > + return ima_file_mprotect(vma, reqprot, prot); > > } > > > > /** >