2008-07-18 12:15:57

by Jan Beulich

[permalink] [raw]
Subject: [PATCH] cifs: fix compiler warning on 64-bit arch-s

Signed-off-by: Jan Beulich <[email protected]>

---
fs/cifs/asn1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.26/fs/cifs/asn1.c 2008-07-13 23:51:29.000000000 +0200
+++ 2.6.26-cifs-warning/fs/cifs/asn1.c 2008-07-17 15:23:11.000000000 +0200
@@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx,
size = eoc - ctx->pointer + 1;

/* first subid actually encodes first two subids */
- if (size < 2 || size > ULONG_MAX/sizeof(unsigned long))
+ if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
return 0;

*oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);



2008-07-18 12:30:37

by Suresh Jayaraman

[permalink] [raw]
Subject: Re: [PATCH] cifs: fix compiler warning on 64-bit arch-s

Jan Beulich wrote:
> Signed-off-by: Jan Beulich <[email protected]>
>
> ---
> fs/cifs/asn1.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- linux-2.6.26/fs/cifs/asn1.c 2008-07-13 23:51:29.000000000 +0200
> +++ 2.6.26-cifs-warning/fs/cifs/asn1.c 2008-07-17 15:23:11.000000000 +0200
> @@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx,
> size = eoc - ctx->pointer + 1;
>
> /* first subid actually encodes first two subids */
> - if (size < 2 || size > ULONG_MAX/sizeof(unsigned long))
> + if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
> return 0;
>
> *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
>
>

I did see the following patch from David Howells attempting to fix the
same warning posted a little earlier.

Fix the CIFS range check to always use a big enough size variable that
the compiler won't moan about comparing it to ULONG_MAX/8 on a 64-bit
platform.

Signed-off-by: David Howells <[email protected]>
---

fs/cifs/asn1.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index f58e41d..512587d 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -394,8 +394,8 @@ asn1_oid_decode(struct asn1_ctx *ctx,
unsigned char *eoc, unsigned long **oid, unsigned int *len)
{
unsigned long subid;
- unsigned int size;
unsigned long *optr;
+ size_t size;

size = eoc - ctx->pointer + 1;


Thanks,

--
Suresh Jayaraman

2008-07-22 13:06:07

by Steve French

[permalink] [raw]
Subject: Re: [PATCH] cifs: fix compiler warning on 64-bit arch-s

merged into cifs-2.6.git

On Fri, Jul 18, 2008 at 7:16 AM, Jan Beulich <[email protected]> wrote:
> Signed-off-by: Jan Beulich <[email protected]>
>
> ---
> fs/cifs/asn1.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- linux-2.6.26/fs/cifs/asn1.c 2008-07-13 23:51:29.000000000 +0200
> +++ 2.6.26-cifs-warning/fs/cifs/asn1.c 2008-07-17 15:23:11.000000000 +0200
> @@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx,
> size = eoc - ctx->pointer + 1;
>
> /* first subid actually encodes first two subids */
> - if (size < 2 || size > ULONG_MAX/sizeof(unsigned long))
> + if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
> return 0;
>
> *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
>
>
>
>



--
Thanks,

Steve