Message ID | 20221221140621.2579555-1-roberto.sassu@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3544787wrn; Wed, 21 Dec 2022 06:11:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXtykh2p1O14LtkT8VSAnMJ8o0+1InRd5Kz3kXyipuc0Fm7AFSitjKpf3m2oWjE9FnrMpugE X-Received: by 2002:a05:6a20:d80c:b0:a3:9127:98e6 with SMTP id iv12-20020a056a20d80c00b000a3912798e6mr21614104pzb.11.1671631892478; Wed, 21 Dec 2022 06:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671631892; cv=none; d=google.com; s=arc-20160816; b=av4JpazvzmbrEuUGoXqT22zAyQEpZUslMDSMtao0T0N0LnRNq2z8YU+nHParZYP56L hbXRGjVVqALCR9UJNgkQ4LIqdH/dCU29FnwB4QHnsE8Z+FeiJJodLvbEe0pujAcWmGUJ B6Ga+j6WDpcLtfPYjzeCoh2qQDXvSznSjPQhR4PhRcRCyDwAXx5+wB1KL3gncI1UgmjZ RM+SitP6OqgYTtFvSct1xjtIVnlFhayJKpKQcFUh+uSM0rqcxg61w6sDX+hvNKe55HCy xhZWDtOLU/BArb4MPz03B+citrDTbR/JY5hUJWiOQBTJo8wR/dF3IT88k83UiN2+y4Tz GsPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=TYsmJFIkEqBc6f5ijLRmb7auunzduzAFlwiwrxjW0F0=; b=L+QmGWU6I4U6p2wYhYXSS+sNyL4bgZT0u3GPgh0GL5SOGg0HMNyud9FH7Jm/4HGNI1 k3nQAHDBr+EIL6PST8c6ha9y9pquyu6ZVWSIpcCwRMfCKsA2NZQbJ3LtByHT8Pu+01uT qYLYJHjy2Qz+8evGcuw5NF/9wZzWE5/q35Y4mnaK/hTaw6cvCgcnLJ24g3iHRi0dBJ2h 8ljrNgM8nGps9KT7Uz0VSoPF3Un8M65/uMity+4IDgSZbBlWhnF9Cw4jtCsbf9MzoqG4 H72dMI5HSaPPoH0ycNxjLXF+FF+/u2nAQAnTK5DrQZKurqRKI6fxyjQsMYyLlgthT6EU w9TQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q196-20020a632acd000000b00434ffe3cc11si16781376pgq.870.2022.12.21.06.11.16; Wed, 21 Dec 2022 06:11:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231871AbiLUOG6 (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Wed, 21 Dec 2022 09:06:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiLUOG5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 21 Dec 2022 09:06:57 -0500 Received: from frasgout13.his.huawei.com (frasgout13.his.huawei.com [14.137.139.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E2642182F; Wed, 21 Dec 2022 06:06:54 -0800 (PST) Received: from mail02.huawei.com (unknown [172.18.147.227]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4NcZnF6NNMz9v7Hl; Wed, 21 Dec 2022 21:59:29 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwAH113oEqNjseIvAA--.8235S2; Wed, 21 Dec 2022 15:06:40 +0100 (CET) From: Roberto Sassu <roberto.sassu@huaweicloud.com> To: paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, Roberto Sassu <roberto.sassu@huawei.com>, stable@vger.kernel.org Subject: [PATCH] security: Restore passing final prot to ima_file_mmap() Date: Wed, 21 Dec 2022 15:06:21 +0100 Message-Id: <20221221140621.2579555-1-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GxC2BwAH113oEqNjseIvAA--.8235S2 X-Coremail-Antispam: 1UD129KBjvJXoW7AFW7AF45ArW3Gw1DKFyDKFg_yoW8Xr15pa y5t3WUKrs5JFyFvFn7WFW7CF1Sk39xKFWUWan2gryjv3Z8XFnYkr15AFW09ry8Xrn5JFyF qw12k3y3A3Wqy3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvqb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxkF7I0E n4kS14v26r4a6rW5MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I 0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWU tVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcV CY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3Jr1lIxAIcVC2z280 aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0x ZFpf9x07jxqXdUUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQANBF1jj4bklgADsO X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752833082953151010?= X-GMAIL-MSGID: =?utf-8?q?1752833082953151010?= |
Series |
security: Restore passing final prot to ima_file_mmap()
|
|
Commit Message
Roberto Sassu
Dec. 21, 2022, 2:06 p.m. UTC
From: Roberto Sassu <roberto.sassu@huawei.com> Commit 98de59bfe4b2f ("take calculation of final prot in security_mmap_file() into a helper") moved the code to update prot with the actual protection flags to be granted to the requestor by the kernel to a helper called mmap_prot(). However, the patch didn't update the argument passed to ima_file_mmap(), making it receive the requested prot instead of the final computed prot. A possible consequence is that files mmapped as executable might not be measured/appraised if PROT_EXEC is not requested but subsequently added in the final prot. Replace prot with mmap_prot(prot) as the second argument of ima_file_mmap() to restore the original behavior. Cc: stable@vger.kernel.org Fixes: 98de59bfe4b2 ("take calculation of final prot in security_mmap_file() into a helper") Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> --- security/security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/security.c b/security/security.c index d1571900a8c7..0d2359d588a1 100644 --- a/security/security.c +++ b/security/security.c @@ -1666,7 +1666,7 @@ int security_mmap_file(struct file *file, unsigned long prot, mmap_prot(file, prot), flags); if (ret) return ret; - return ima_file_mmap(file, prot); + return ima_file_mmap(file, mmap_prot(file, prot)); } int security_mmap_addr(unsigned long addr)