lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <581e7d79ed75484beb227672b2695ff14e1f1e34.camel@perches.com>
Date:   Mon, 19 Aug 2019 09:56:20 -0700
From:   Joe Perches <joe@...ches.com>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>,
        Bernard Metzler <bmt@...ich.ibm.com>,
        Doug Ledford <dledford@...hat.com>,
        Jason Gunthorpe <jgg@...pe.ca>
Cc:     linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] RDMA/siw: Fix compiler warnings on 32-bit due to
 u64/pointer abuse

On Mon, 2019-08-19 at 12:05 +0200, Geert Uytterhoeven wrote:
> When compiling on 32-bit:
> 
>     drivers/infiniband/sw/siw/siw_cq.c:76:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>     drivers/infiniband/sw/siw/siw_qp.c:952:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
[]
> Fix this by applying the following rules:
>   1. When printing a u64, the %llx format specififer should be used,
>      instead of casting to a pointer, and printing the latter.
>   2. When assigning a pointer to a u64, the pointer should be cast to
>      uintptr_t, not u64,
>   3. When casting from u64 to pointer, an intermediate cast to uintptr_t
>      should be added,

I think a cast to unsigned long is rather more common.

uintptr_t is used ~1300 times in the kernel.
I believe a cast to unsigned long is much more common.

It might be useful to add something to the Documentation
for this style.  Documentation/process/coding-style.rst

And trivia:

> > diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
[]
> @@ -842,8 +842,8 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
>  			rv = -EINVAL;
>  			break;
>  		}
> -		siw_dbg_qp(qp, "opcode %d, flags 0x%x, wr_id 0x%p\n",
> -			   sqe->opcode, sqe->flags, (void *)sqe->id);
> +		siw_dbg_qp(qp, "opcode %d, flags 0x%x, wr_id 0x%llx\n",
> +			   sqe->opcode, sqe->flags, sqe->id);

Printing possible pointers as %llx is generally not a good idea
given the desire for %p obfuscation.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ