Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38422694rwd; Wed, 12 Jul 2023 07:30:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcZ7T1dbSxdVG6EeoCf5T1zip7ZxC4QosnzVT001UHm948TPPjv0pFyrgFMtuqsZAWVTJc X-Received: by 2002:a17:907:8014:b0:974:32e:7de9 with SMTP id ft20-20020a170907801400b00974032e7de9mr17398740ejc.56.1689172207903; Wed, 12 Jul 2023 07:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689172207; cv=none; d=google.com; s=arc-20160816; b=NqvcdLRd3DTYjMRsEFC+ZGMkoL5J9ZO+ujGEaJZGm1Oou8oWzzNrr3GiE0L09RHJF8 vTOjdUPCEoCS2kpHNfceA0ZAFsxsG6tkzESodV2Q9OSAHiJsKRocRkr5V+xmpc/ql1/n plDaWP7O4J7jDyzHYDuawk2aIAVMVJpKl4BIAlcWxcNEnmso9HBX37zDpiAZwBh/MOD0 TY0LI7XeAOuse87FLz/99AYNiGTQggPMNiWhqm3Gp90gNTBAcjayduGoq4Uv4SOpuKDs 5BjHAQdPiPGw6VkqMURvWCaZcWhARwfTBGJjq6CWHjxWaEJA9SUWVT0kncvdfOl/dPGW oquw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cog3zFED0zqk0ayh/5AST+3VWG2EFfyBo0064QrevtA=; fh=FRon72YwFeIVU/LlfmPNxuVFiduvQKfa+Ydvnh8xLfc=; b=nzL63ztNOed+mrhxHRb6tta3E2HAlYUsW/VhbNBAmFCFquQht/pVbc+ZZVSLxr+Jeq cQv9AtflZksex6tI7BjxIAGDv0WlP6Gi3NZDs9dQkFgo/LKEgj3HyamcI5IWGbHzULn2 CdRuNYBhyj9Eg0oKwpLqqYjr3wNmJ3F78Q1l7ShMKYYNyp0v9H57mDqrntaMc3TZ22k9 SdFPxm2GouUVUoG9AVg88k5FEgFDbizr4QN4UtOMfdjU/C1If9wYwXqIA2XSc8omu9Kf jNJGfgDcIt1i7XWC+TX0zdlCaGkPhGkLLCHdLxOAYEHEjJfMkUjgYaApvOe/6DD91UG7 SuvA== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b27-20020a170906491b00b00982a3005cf7si4374079ejq.605.2023.07.12.07.29.42; Wed, 12 Jul 2023 07:30:07 -0700 (PDT) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbjGLOZ1 (ORCPT + 99 others); Wed, 12 Jul 2023 10:25:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjGLOZV (ORCPT ); Wed, 12 Jul 2023 10:25:21 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4B619BE; Wed, 12 Jul 2023 07:25:16 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R1KhZ0q0bzPk8H; Wed, 12 Jul 2023 22:22:54 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 12 Jul 2023 22:25:13 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , , , Kefeng Wang Subject: [PATCH 4/5] selinux: use vma_is_stack() and vma_is_heap() Date: Wed, 12 Jul 2023 22:38:30 +0800 Message-ID: <20230712143831.120701-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712143831.120701-1-wangkefeng.wang@huawei.com> References: <20230712143831.120701-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Use the helpers to simplify code. Signed-off-by: Kefeng Wang --- security/selinux/hooks.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 4e46cf3d67b6..289ef2d6a427 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3775,13 +3775,10 @@ static int selinux_file_mprotect(struct vm_area_struct *vma, if (default_noexec && (prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) { int rc = 0; - if (vma->vm_start >= vma->vm_mm->start_brk && - vma->vm_end <= vma->vm_mm->brk) { + if (vma_is_heap(vma)) { rc = avc_has_perm(sid, sid, SECCLASS_PROCESS, PROCESS__EXECHEAP, NULL); - } else if (!vma->vm_file && - ((vma->vm_start <= vma->vm_mm->start_stack && - vma->vm_end >= vma->vm_mm->start_stack) || + } else if (!vma->vm_file && vma_is_stack(vma) || vma_is_stack_for_current(vma))) { rc = avc_has_perm(sid, sid, SECCLASS_PROCESS, PROCESS__EXECSTACK, NULL); -- 2.41.0