Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2687739yba; Mon, 6 May 2019 10:00:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyr5jFAhDiscK+ehVhed0LQ/I9chFDyU8Am43/cyyHlICHeLaBHCTMg/CCQnl40vYni8xR+ X-Received: by 2002:a63:5c25:: with SMTP id q37mr34152767pgb.263.1557162036286; Mon, 06 May 2019 10:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557162036; cv=none; d=google.com; s=arc-20160816; b=xpNPsU1dEx/5lPHcceqff7VatJAfhRjItjC8EvczrCE3edHnOmAo5WDhGNiMe7rZjr 7/hn87YpH7GAyeGJHjcyLC6d/cJS7g7FeRsChiDlt7zziwVTivnRAdSu4vPXMcjjSZYO iR3oVEbMrnjH1dgKl/YndFagw02QEmbBP7eHyU4iE/LoHrT5Yz31bxSnaG30r8YcW1ZB UwSZ/I/5OD/VfAfq7UjmlFtSxGOIQbK7kTCJ9f/7boGJulatrDcH5TgSaJAY+Qxj80ar ahnDBT3afJR0d0iwMUUL9g9D4gKPGrIcpBfwzIQeGpuR7Q9t3BD5+bzDh87rBPSZmPH1 3JFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=NOr/1KSYMcf+1MtS5k5jEjscZGTZkj+oq+2jViXfAgk=; b=MBL78svfBEBGnag5axEqLKe4gwSnPw6yYnrlJ0HlKQr86YcxXFutzeaUPkyPwhed8R li275On7cD33dlRtBajxU7MDgw9EAsPOGGkRP+IWJymt29KiAv+G/xC42SRQKkN29PtE PlXffFsISRONcuiP0FQcd98pTAg9156qHlOsao6yIIjonxoy13htspMQ+3kRAsJyP4n3 WsFpNZAxWaumflPKooAjlwT8ngc22yEEt7cSN74CTVEJgrQ+TPPkHWlLV8Wb06u9A3Y0 1yYw8Q2tUT0Nc6IZF52a42eObS/eLAg5ozQSzw6L5L5SbM/vrJDexl3mdymcT5Zc28b8 me4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si16884385plg.156.2019.05.06.10.00.19; Mon, 06 May 2019 10:00:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbfEFQ54 (ORCPT + 99 others); Mon, 6 May 2019 12:57:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:47656 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726094AbfEFQ5y (ORCPT ); Mon, 6 May 2019 12:57:54 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x46GqMRa057488 for ; Mon, 6 May 2019 12:57:53 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2sar28a6jc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 May 2019 12:57:52 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 May 2019 17:57:50 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 6 May 2019 17:57:48 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x46GvlVs43843706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 May 2019 16:57:47 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05750A4059; Mon, 6 May 2019 16:57:47 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14EB6A4051; Mon, 6 May 2019 16:57:46 +0000 (GMT) Received: from localhost.ibm.com (unknown [9.80.95.145]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 6 May 2019 16:57:45 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Igor Zhbanov , Jordan Glover , Al Viro , Mimi Zohar Subject: [PATCH 1/3] ima: verify mprotect change is consistent with mmap policy Date: Mon, 6 May 2019 12:57:02 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1557161824-6623-1-git-send-email-zohar@linux.ibm.com> References: <1557161824-6623-1-git-send-email-zohar@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19050616-0028-0000-0000-0000036AE60D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19050616-0029-0000-0000-0000242A5C11 Message-Id: <1557161824-6623-2-git-send-email-zohar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-06_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=768 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905060144 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org IMA can be configured to measure and appraise a file's integrity being mmap'ed execute. Files can be mmap'ed read/write and later changed to execute to circumvent IMA's mmap measurement and appraisal policy rules. To prevent this from happening, this patch similarly calls ima_file_mmap() for mprotect changes. Suggested-by: Stephen Smalley Signed-off-by: Mimi Zohar --- security/security.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/security/security.c b/security/security.c index 23cbb1a295a3..98ce27933e72 100644 --- a/security/security.c +++ b/security/security.c @@ -1411,7 +1411,12 @@ int security_mmap_addr(unsigned long addr) int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, unsigned long prot) { - return call_int_hook(file_mprotect, 0, vma, reqprot, prot); + int ret; + + ret = call_int_hook(file_mprotect, 0, vma, reqprot, prot); + if (ret) + return ret; + return ima_file_mmap(vma->vm_file, prot); } int security_file_lock(struct file *file, unsigned int cmd) -- 2.7.5