linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem
@ 2019-06-18 11:49 Puranjay Mohan
  2019-06-18 12:07 ` Christoph Hellwig
  2019-06-18 16:08 ` [Linux-kernel-mentees] " Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Puranjay Mohan @ 2019-06-18 11:49 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Puranjay Mohan, linux-kernel-mentees, linux-kernel, hch

Fix CRAMFS_BLK_FLAG_UNCOMPRESSED to use "U" cast to avoid shifting signed
32-bit value by 31 bits problem. This isn't a problem for kernel builds
with gcc.

This could be problem since this header is part of public API which
could be included for builds using compilers that don't handle this
condition safely resulting in undefined behavior.

Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
---
V2 - use the unsigned constants for all flags, not just one

 include/uapi/linux/cramfs_fs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/cramfs_fs.h b/include/uapi/linux/cramfs_fs.h
index 6713669aa2ed..71cb602d4198 100644
--- a/include/uapi/linux/cramfs_fs.h
+++ b/include/uapi/linux/cramfs_fs.h
@@ -98,8 +98,8 @@ struct cramfs_super {
  *
  * That leaves room for 3 flag bits in the block pointer table.
  */
-#define CRAMFS_BLK_FLAG_UNCOMPRESSED	(1 << 31)
-#define CRAMFS_BLK_FLAG_DIRECT_PTR	(1 << 30)
+#define CRAMFS_BLK_FLAG_UNCOMPRESSED	(1U << 31)
+#define CRAMFS_BLK_FLAG_DIRECT_PTR	(1U << 30)
 
 #define CRAMFS_BLK_FLAGS	( CRAMFS_BLK_FLAG_UNCOMPRESSED \
 				| CRAMFS_BLK_FLAG_DIRECT_PTR )
-- 
2.21.0


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

* Re: [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem
  2019-06-18 11:49 [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem Puranjay Mohan
@ 2019-06-18 12:07 ` Christoph Hellwig
  2019-06-18 16:08 ` [Linux-kernel-mentees] " Greg KH
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2019-06-18 12:07 UTC (permalink / raw)
  To: Puranjay Mohan; +Cc: Shuah Khan, linux-kernel-mentees, linux-kernel, hch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [Linux-kernel-mentees] [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem
  2019-06-18 11:49 [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem Puranjay Mohan
  2019-06-18 12:07 ` Christoph Hellwig
@ 2019-06-18 16:08 ` Greg KH
  2019-06-18 16:15   ` Shuah Khan
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2019-06-18 16:08 UTC (permalink / raw)
  To: Puranjay Mohan; +Cc: Shuah Khan, hch, linux-kernel-mentees, linux-kernel

On Tue, Jun 18, 2019 at 05:19:47PM +0530, Puranjay Mohan wrote:
> Fix CRAMFS_BLK_FLAG_UNCOMPRESSED to use "U" cast to avoid shifting signed
> 32-bit value by 31 bits problem. This isn't a problem for kernel builds
> with gcc.
> 
> This could be problem since this header is part of public API which
> could be included for builds using compilers that don't handle this
> condition safely resulting in undefined behavior.
> 
> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

You should resend this and cc: Nicolas Pitre <nico@fluxnic.net> as he is
the cramfs maintainer.

thanks,

greg k-h

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

* Re: [Linux-kernel-mentees] [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem
  2019-06-18 16:08 ` [Linux-kernel-mentees] " Greg KH
@ 2019-06-18 16:15   ` Shuah Khan
  2019-06-18 16:38     ` Puranjay Mohan
  0 siblings, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2019-06-18 16:15 UTC (permalink / raw)
  To: Greg KH, Puranjay Mohan
  Cc: hch, linux-kernel-mentees, linux-kernel, skh >> Shuah Khan

On 6/18/19 10:08 AM, Greg KH wrote:
> On Tue, Jun 18, 2019 at 05:19:47PM +0530, Puranjay Mohan wrote:
>> Fix CRAMFS_BLK_FLAG_UNCOMPRESSED to use "U" cast to avoid shifting signed
>> 32-bit value by 31 bits problem. This isn't a problem for kernel builds
>> with gcc.
>>
>> This could be problem since this header is part of public API which
>> could be included for builds using compilers that don't handle this
>> condition safely resulting in undefined behavior.
>>
>> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
> 
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> You should resend this and cc: Nicolas Pitre <nico@fluxnic.net> as he is
> the cramfs maintainer.
> 

Puranjay! You can add all the Reviewed-by tags when you resend the patch
with Nicolas Pitre <nico@fluxnic.net> on the thread.


Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

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

* Re: [Linux-kernel-mentees] [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem
  2019-06-18 16:15   ` Shuah Khan
@ 2019-06-18 16:38     ` Puranjay Mohan
  0 siblings, 0 replies; 5+ messages in thread
From: Puranjay Mohan @ 2019-06-18 16:38 UTC (permalink / raw)
  To: Shuah Khan; +Cc: hch, linux-kernel-mentees, linux-kernel, gregkh

On Tue, Jun 18, 2019 at 10:15:11AM -0600, Shuah Khan wrote:
> On 6/18/19 10:08 AM, Greg KH wrote:
> > On Tue, Jun 18, 2019 at 05:19:47PM +0530, Puranjay Mohan wrote:
> > > Fix CRAMFS_BLK_FLAG_UNCOMPRESSED to use "U" cast to avoid shifting signed
> > > 32-bit value by 31 bits problem. This isn't a problem for kernel builds
> > > with gcc.
> > > 
> > > This could be problem since this header is part of public API which
> > > could be included for builds using compilers that don't handle this
> > > condition safely resulting in undefined behavior.
> > > 
> > > Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
> > 
> > Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > 
> > You should resend this and cc: Nicolas Pitre <nico@fluxnic.net> as he is
> > the cramfs maintainer.
> > 
> 
> Puranjay! You can add all the Reviewed-by tags when you resend the patch
> with Nicolas Pitre <nico@fluxnic.net> on the thread.
> 
> 
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
> 
> thanks,
> -- Shuah

Thanks, I have sent the mail with Nicolas Pitre in CC.

--Puranjay

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

end of thread, other threads:[~2019-06-18 16:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 11:49 [PATCH v2] fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem Puranjay Mohan
2019-06-18 12:07 ` Christoph Hellwig
2019-06-18 16:08 ` [Linux-kernel-mentees] " Greg KH
2019-06-18 16:15   ` Shuah Khan
2019-06-18 16:38     ` Puranjay Mohan

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