From mboxrd@z Thu Jan 1 00:00:00 1970 From: liu weni Subject: [PATCHv4 1/3]posix_acl: Add the acl pointer check Date: Tue, 29 Dec 2009 07:35:48 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 To: viro , linux-kernel , linux-fsdevel Return-path: Received: from mail-iw0-f171.google.com ([209.85.223.171]:41726 "EHLO mail-iw0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751924AbZL1Xft (ORCPT ); Mon, 28 Dec 2009 18:35:49 -0500 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: If the acl pointer is NULL or have some error, the acl is invalid. The Macro of FOREACH_ACL_ENTRY will make some error. --- Signed-off-by: Liuwenyi Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 39df95a..d4bacb9 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -76,6 +76,12 @@ posix_acl_valid(const struct posix_acl *acl) unsigned int id = 0; /* keep gcc happy */ int needs_mask = 0; + if (!acl) + return -EINVAL; + + if (IS_ERR(acl)) + return PTR_ERR(acl); + FOREACH_ACL_ENTRY(pa, acl, pe) { if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE)) return -EINVAL;