Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754003AbbLVNv5 (ORCPT ); Tue, 22 Dec 2015 08:51:57 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:50162 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751299AbbLVNvy (ORCPT ); Tue, 22 Dec 2015 08:51:54 -0500 From: Sasha Levin To: zohar@linux.vnet.ibm.com, dmitry.kasatkin@gmail.com, james.l.morris@oracle.com, serge@hallyn.com Cc: linux-ima-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, petkan@mip-labs.com, Sasha Levin Subject: [PATCH] IMA: policy can be updated zero times Date: Tue, 22 Dec 2015 08:51:23 -0500 Message-Id: <1450792283-8702-1-git-send-email-sasha.levin@oracle.com> X-Mailer: git-send-email 2.5.0 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1165 Lines: 34 Commit "IMA: policy can now be updated multiple times" assumed that the policy would be updated at least once. If there are zero updates, the temporary list head object will get added to the policy list, and later dereferenced as an IMA policy object, which means that invalid memory will be accessed. Signed-off-by: Sasha Levin --- security/integrity/ima/ima_policy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index ba5d2fc..9b958b8 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -431,6 +431,9 @@ void ima_update_policy(void) { struct list_head *first, *last, *policy; + if (list_empty(&ima_temp_rules)) + return; + /* append current policy with the new rules */ first = (&ima_temp_rules)->next; last = (&ima_temp_rules)->prev; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/