linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: fix d_path() with zero-length input buffer
@ 2014-02-05 17:34 Denys Vlasenko
  2014-02-05 17:42 ` Oleg Nesterov
  0 siblings, 1 reply; 2+ messages in thread
From: Denys Vlasenko @ 2014-02-05 17:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Denys Vlasenko, Al Viro, Oleg Nesterov, Jan Kratochvil,
	Amerigo Wang, Jonathan M. Foote, Roland McGrath, Pedro Alves,
	Fengguang Wu, Stephen Rothwell

In prepend_name(), *buflen < dlen + 1 comparison is buggy
because dlen has unsigned data type, and we can reach this location
with *buflen == -1.

The fix casts dlen to int.

Bug reports:
https://bugzilla.redhat.com/show_bug.cgi?id=1050964
https://bugzilla.redhat.com/show_bug.cgi?id=1060384

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Amerigo Wang <amwang@redhat.com>
Cc: "Jonathan M. Foote" <jmfoote@cert.org>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: Pedro Alves <palves@redhat.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
---
 fs/dcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 265e0ce..40ded0c 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2833,7 +2833,7 @@ static int prepend_name(char **buffer, int *buflen, struct qstr *name)
 	u32 dlen = ACCESS_ONCE(name->len);
 	char *p;
 
-	if (*buflen < dlen + 1)
+	if (*buflen < (int)dlen + 1)
 		return -ENAMETOOLONG;
 	*buflen -= dlen + 1;
 	p = *buffer -= dlen + 1;
-- 
1.8.1.4


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

* Re: [PATCH] fs: fix d_path() with zero-length input buffer
  2014-02-05 17:34 [PATCH] fs: fix d_path() with zero-length input buffer Denys Vlasenko
@ 2014-02-05 17:42 ` Oleg Nesterov
  0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2014-02-05 17:42 UTC (permalink / raw)
  To: Denys Vlasenko
  Cc: linux-kernel, Al Viro, Jan Kratochvil, Amerigo Wang,
	Jonathan M. Foote, Roland McGrath, Pedro Alves, Fengguang Wu,
	Stephen Rothwell

On 02/05, Denys Vlasenko wrote:
>
> In prepend_name(), *buflen < dlen + 1 comparison is buggy
> because dlen has unsigned data type, and we can reach this location
> with *buflen == -1.

because, say, path_with_deleted() doesn't check the result of
prepend(), and prepend() updates *buflen unconditionally. I am
wondering if it should be changed too just for consistency.

> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -2833,7 +2833,7 @@ static int prepend_name(char **buffer, int *buflen, struct qstr *name)
>  	u32 dlen = ACCESS_ONCE(name->len);
>  	char *p;
>
> -	if (*buflen < dlen + 1)
> +	if (*buflen < (int)dlen + 1)

perhaps it would be better to simply make dlen "int" ?

Oleg.


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

end of thread, other threads:[~2014-02-05 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 17:34 [PATCH] fs: fix d_path() with zero-length input buffer Denys Vlasenko
2014-02-05 17:42 ` Oleg Nesterov

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).