Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934575AbZJIXSh (ORCPT ); Fri, 9 Oct 2009 19:18:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761804AbZJIXSL (ORCPT ); Fri, 9 Oct 2009 19:18:11 -0400 Received: from kroah.org ([198.145.64.141]:36867 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761791AbZJIXSJ (ORCPT ); Fri, 9 Oct 2009 19:18:09 -0400 X-Mailbox-Line: From gregkh@mini.kroah.org Fri Oct 9 16:10:03 2009 Message-Id: <20091009231003.148054572@mini.kroah.org> User-Agent: quilt/0.48-1 Date: Fri, 09 Oct 2009 16:09:00 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: stable-review@kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Mimi Zohar , James Morris Subject: [patch 24/26] IMA: open new file for read References: <20091009230836.316410305@mini.kroah.org> Content-Disposition: inline; filename=ima-open-new-file-for-read.patch In-Reply-To: <20091009231249.GA31084@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1251 Lines: 30 2.6.31-stable review patch. If anyone has any objections, please let us know. ------------------ From: Mimi Zohar commit 6c1488fd581a447ec87c4b59f0d33f95f0aa441b upstream. When creating a new file, ima_path_check() assumed the new file was being opened for write. Call ima_path_check() with the appropriate acc_mode so that the read/write counters are incremented correctly. Signed-off-by: Mimi Zohar Signed-off-by: James Morris Signed-off-by: Greg Kroah-Hartman --- a/fs/namei.c +++ b/fs/namei.c @@ -1533,9 +1533,11 @@ int may_open(struct path *path, int acc_mode, int flag) if (error) return error; - error = ima_path_check(path, - acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC), + error = ima_path_check(path, acc_mode ? + acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) : + ACC_MODE(flag) & (MAY_READ | MAY_WRITE), IMA_COUNT_UPDATE); + if (error) return error; /* -- 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/