Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5729682rwj; Wed, 21 Dec 2022 06:24:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXuRqxuv28pmmBw4uehHuxlb8DtOX5OCJs7M9QEqMEKwNJ8+Ux1NvoiExLN1IidP2DgRzXLB X-Received: by 2002:a05:6a21:6da5:b0:b0:4c16:10a6 with SMTP id wl37-20020a056a216da500b000b04c1610a6mr3922526pzb.0.1671632698490; Wed, 21 Dec 2022 06:24:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671632698; cv=none; d=google.com; s=arc-20160816; b=DJ9O3Uc+TUzIJeVt+5jAqK9hsXwH6YAZz5Zxw166SBOEY7E7KCKdclMZ1Yazu1KsvC VVUAJ8jy+FklD2PMZuJHDQDuikuNpt2j9J5yGb6CnW3qIziFLMtsPfegtVscD1mhzKXh iWnjTCuvNiR5/Q813iWp4MQYapChe0VbHbIhLEsFarPc8gMuUPqtNoOZG7rBsj5G36U2 dsuJLzWR/PMbJ51h2xJxW+mmfDsjXC5BqKeyDmywiSfFg1Fth/l6GLzc1Ot6fSpC6GZa PcTh8huCNN3ov6R8iVcBYrGHp6Ev0vDt8tCud736H7j8KRNM9TRUixRifQKqIc0/IsTG jjDw== 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=cSgqnB02qKCdcgsVc/dGOApJfyvE/aTaE0T41fXXOEA=; b=A7WGtKb8eoASAaRW+K3Vdwye3IVZD12VVfoaUAoEpJ+2sYEtfrb34uDt9Kx7UQhPPI RLQfH83nRR4Y++z/BqJAPAs9BxsQy9AC/PDo3llq8mvSdsYTYZZi37i+lQzU2aRbYGay Jdev9WhaKX5kHYwcMMCS07wsJME5j5V6XkY+dAX8V4iGEvbcIvSKvt+RsdQMWpicvkrM 0P6NZSx3LdXScItduFcq4OaLOeR41ioqw7jg/dZgoP+0cctkdIdNKbD6GyNB/H5Edic4 bLa3rBMYBfiT9kv3GSsqj8A9VZyvbKVX6duf1hr6SZENICof6tMWLz3Gcz8MTHRiX8/O EjLw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a6567c2000000b0046b2ec0de65si16315143pgs.789.2022.12.21.06.24.49; Wed, 21 Dec 2022 06:24:58 -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 S231986AbiLUOKh (ORCPT + 68 others); Wed, 21 Dec 2022 09:10:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiLUOKf (ORCPT ); Wed, 21 Dec 2022 09:10:35 -0500 Received: from frasgout12.his.huawei.com (frasgout12.his.huawei.com [14.137.139.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDCD423BEC; Wed, 21 Dec 2022 06:10:31 -0800 (PST) Received: from mail02.huawei.com (unknown [172.18.147.227]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4NcZsm2fxLz9xFrp; Wed, 21 Dec 2022 22:03:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwAH2F7DE6NjUuUvAA--.8166S2; Wed, 21 Dec 2022 15:10:18 +0100 (CET) From: Roberto Sassu 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 , stable@vger.kernel.org Subject: [PATCH v2] security: Restore passing final prot to ima_file_mmap() Date: Wed, 21 Dec 2022 15:10:07 +0100 Message-Id: <20221221141007.2579770-1-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GxC2BwAH2F7DE6NjUuUvAA--.8166S2 X-Coremail-Antispam: 1UD129KBjvJXoW7AFW7AF45ArW3Gw1kGF1rJFb_yoW8Xr1fpa y5t3WUKrs5JFyFqFn7WFW7CF1Sk39xKFWUWan2gryj93Z8XFnYkr15AFWj9ry8Xrn5JFyF qw12k3y3A3Wqy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk2b4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28I cxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2 IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI 42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42 IY6xAIw20EY4v20xvaj40_Zr0_Wr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjxUOyCJDUUUU X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAgANBF1jj4LnoQAAs+ 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Roberto Sassu 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(file, 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 --- 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) -- 2.25.1