Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964843AbbLVT5e (ORCPT ); Tue, 22 Dec 2015 14:57:34 -0500 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:52079 "EHLO e23smtp05.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932184AbbLVT53 (ORCPT ); Tue, 22 Dec 2015 14:57:29 -0500 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: zohar@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org;linux-security-module@vger.kernel.org Message-ID: <1450814188.2774.9.camel@linux.vnet.ibm.com> Subject: Re: [PATCH] IMA: policy can be updated zero times From: Mimi Zohar To: Sasha Levin Cc: dmitry.kasatkin@gmail.com, james.l.morris@oracle.com, serge@hallyn.com, linux-ima-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, petkan@mip-labs.com Date: Tue, 22 Dec 2015 14:56:28 -0500 In-Reply-To: <1450792283-8702-1-git-send-email-sasha.levin@oracle.com> References: <1450792283-8702-1-git-send-email-sasha.levin@oracle.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 (3.12.11-1.fc21) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15122219-0017-0000-0000-00000270D800 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1519 Lines: 40 On Tue, 2015-12-22 at 08:51 -0500, Sasha Levin wrote: > 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; Thanks, Sasha. By the time ima_update_policy() is called ima_release_policy() has already output the policy update status message. I guess an empty policy could be considered a valid policy. Could you add a msg indicating that the new policy was empty? Mimi -- 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/