linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3 0/3]posix_acl: add the pointer check into fs/posix_acl.c
@ 2009-12-28 14:59 liu weni
  2009-12-28 15:00 ` [PATCHv3 1/3]posix_acl: " liu weni
  0 siblings, 1 reply; 6+ messages in thread
From: liu weni @ 2009-12-28 14:59 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, viro

Hi all:
    Many filesystems have their own way to check the acl pointer, and
others not. It have something wrong while calling FOREACH_ACL_ENTRY.
Then, I wanna add a pointer check before the Macro of FOREACH_ACL_ENTRY.



---
Best Regards,
Liuwenyi
2009-12-29

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCHv3 1/3]posix_acl: add the pointer check into fs/posix_acl.c
  2009-12-28 14:59 [PATCHv3 0/3]posix_acl: add the pointer check into fs/posix_acl.c liu weni
@ 2009-12-28 15:00 ` liu weni
  2009-12-28 15:01   ` [PATCHv3 2/3]posix_acl: " liu weni
  2009-12-28 15:32   ` [PATCHv3 1/3]posix_acl: " Américo Wang
  0 siblings, 2 replies; 6+ messages in thread
From: liu weni @ 2009-12-28 15:00 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, viro

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 <qingshenlwy@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
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..45f8afa 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)
+		return PTR_ERR(acl);
+
 	FOREACH_ACL_ENTRY(pa, acl, pe) {
 		if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
 			return -EINVAL;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHv3 2/3]posix_acl: add the pointer check into fs/posix_acl.c
  2009-12-28 15:00 ` [PATCHv3 1/3]posix_acl: " liu weni
@ 2009-12-28 15:01   ` liu weni
  2009-12-28 15:02     ` [PATCHv3 3/3]posix_acl: " liu weni
  2009-12-28 15:32   ` [PATCHv3 1/3]posix_acl: " Américo Wang
  1 sibling, 1 reply; 6+ messages in thread
From: liu weni @ 2009-12-28 15:01 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, viro

Add two acl pointer checks before this function.

---

Signed-off-by: Liuwenyi <qingshenlwy@gmail.com>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
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..0d2a7a2 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -150,6 +150,12 @@ posix_acl_equiv_mode(const struct posix_acl *acl,
mode_t *mode_p)
 	mode_t mode = 0;
 	int not_equiv = 0;

+	if (!acl)
+		return -EINVAL;
+
+	if (IS_ERR(acl))
+		return PTR_ERR(acl);
+
 	FOREACH_ACL_ENTRY(pa, acl, pe) {
 		switch (pa->e_tag) {
 			case ACL_USER_OBJ:

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCHv3 3/3]posix_acl: add the pointer check into fs/posix_acl.c
  2009-12-28 15:01   ` [PATCHv3 2/3]posix_acl: " liu weni
@ 2009-12-28 15:02     ` liu weni
  0 siblings, 0 replies; 6+ messages in thread
From: liu weni @ 2009-12-28 15:02 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, viro

While the acl pointer is IS_ERR, We cannot get the correct return.

And the acl pointer is NULL. Oh, my god! The FOREACH_ACL_ENTRY will
call that.

---

Signed-off-by: Liuwenyi <qingshenlwy@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
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..4e0261b 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -213,6 +213,12 @@ posix_acl_permission(struct inode *inode, const
struct posix_acl *acl, int want)
 	const struct posix_acl_entry *pa, *pe, *mask_obj;
 	int found = 0;

+	if (!acl)
+		return -EINVAL;
+
+	if (IS_ERR(acl))
+		return PTR_ERR(acl);
+
 	FOREACH_ACL_ENTRY(pa, acl, pe) {
                 switch(pa->e_tag) {
                         case ACL_USER_OBJ:

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHv3 1/3]posix_acl: add the pointer check into fs/posix_acl.c
  2009-12-28 15:00 ` [PATCHv3 1/3]posix_acl: " liu weni
  2009-12-28 15:01   ` [PATCHv3 2/3]posix_acl: " liu weni
@ 2009-12-28 15:32   ` Américo Wang
  2009-12-28 23:29     ` liu weni
  1 sibling, 1 reply; 6+ messages in thread
From: Américo Wang @ 2009-12-28 15:32 UTC (permalink / raw)
  To: liu weni; +Cc: linux-kernel, linux-fsdevel, viro

On Mon, Dec 28, 2009 at 11:00:58PM +0800, liu weni wrote:
>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 <qingshenlwy@gmail.com>
>Cc: Alexander Viro <viro@zeniv.linux.org.uk>
>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..45f8afa 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)

Did you even do a compile test?
I don't think this line will work...


>+		return PTR_ERR(acl);
>+
> 	FOREACH_ACL_ENTRY(pa, acl, pe) {
> 		if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
> 			return -EINVAL;
>--
>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/

-- 
Live like a child, think like the god.
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv3 1/3]posix_acl: add the pointer check into fs/posix_acl.c
  2009-12-28 15:32   ` [PATCHv3 1/3]posix_acl: " Américo Wang
@ 2009-12-28 23:29     ` liu weni
  0 siblings, 0 replies; 6+ messages in thread
From: liu weni @ 2009-12-28 23:29 UTC (permalink / raw)
  To: Américo Wang; +Cc: linux-kernel, linux-fsdevel, viro

Sorry. I forgot diff it again.

2009/12/28 Américo Wang <xiyou.wangcong@gmail.com>:
> On Mon, Dec 28, 2009 at 11:00:58PM +0800, liu weni wrote:
>>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 <qingshenlwy@gmail.com>
>>Cc: Alexander Viro <viro@zeniv.linux.org.uk>
>>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..45f8afa 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)
>
> Did you even do a compile test?
> I don't think this line will work...
>
>
>>+              return PTR_ERR(acl);
>>+
>>       FOREACH_ACL_ENTRY(pa, acl, pe) {
>>               if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
>>                       return -EINVAL;
>>--
>>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/
>
> --
> Live like a child, think like the god.
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-28 23:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-28 14:59 [PATCHv3 0/3]posix_acl: add the pointer check into fs/posix_acl.c liu weni
2009-12-28 15:00 ` [PATCHv3 1/3]posix_acl: " liu weni
2009-12-28 15:01   ` [PATCHv3 2/3]posix_acl: " liu weni
2009-12-28 15:02     ` [PATCHv3 3/3]posix_acl: " liu weni
2009-12-28 15:32   ` [PATCHv3 1/3]posix_acl: " Américo Wang
2009-12-28 23:29     ` liu weni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).