Skip to contentSkip to conversation

uapi: linux: Fix undefined behavior in bit shift

PATCH New Jiunn Chang 6 participants 29 messages Jun 27, 2019 – Jul 4, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uapi: linux: Fix undefined behavior in bit shift

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
 include/uapi/linux/if_packet.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/if_packet.h +1 -1
index 467b654bd4c7..3d884d68eb30 100644
@@ -123,7 +123,7 @@ struct tpacket_auxdata {
 /* Rx and Tx ring - header status */
 #define TP_STATUS_TS_SOFTWARE		(1 << 29)
 #define TP_STATUS_TS_SYS_HARDWARE	(1 << 30) /* deprecated, never set */
-#define TP_STATUS_TS_RAW_HARDWARE	(1 << 31)
+#define TP_STATUS_TS_RAW_HARDWARE	(1U << 31)
 
 /* Rx ring - feature request bits */
 #define TP_FT_REQ_FILL_RXHASH	0x1
Signature · 1 line
2.22.0
#1 lore raw

PATCH 1/1 uapi: linux: Fix undefined behavior in bit shift

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
 include/uapi/linux/if_packet.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/if_packet.h +1 -1
index 467b654bd4c7..3d884d68eb30 100644
@@ -123,7 +123,7 @@ struct tpacket_auxdata {
 /* Rx and Tx ring - header status */
 #define TP_STATUS_TS_SOFTWARE		(1 << 29)
 #define TP_STATUS_TS_SYS_HARDWARE	(1 << 30) /* deprecated, never set */
-#define TP_STATUS_TS_RAW_HARDWARE	(1 << 31)
+#define TP_STATUS_TS_RAW_HARDWARE	(1U << 31)
 
 /* Rx ring - feature request bits */
 #define TP_FT_REQ_FILL_RXHASH	0x1
Signature · 1 line
2.22.0
#2 lore raw

PATCH 1/1 uapi: linux: Fix undefined behavior in bit shift

In reply to Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
 include/uapi/linux/kfd_ioctl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/kfd_ioctl.h +1 -1
index dc067ed0b72d..ae5669272303 100644
@@ -339,7 +339,7 @@ struct kfd_ioctl_acquire_vm_args {
 #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR		(1 << 2)
 #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL	(1 << 3)
 /* Allocation flags: attributes/access options */
-#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1 << 31)
+#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1U << 31)
 #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE	(1 << 30)
 #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC		(1 << 29)
 #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE	(1 << 28)
Signature · 1 line
2.22.0
#3 lore raw

PATCH 1/1 uapi: linux: Fix undefined behavior in bit shift

Quoted 14 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
  include/uapi/linux/kfd_ioctl.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/kfd_ioctl.h +0 -0
index dc067ed0b72d..ae5669272303 100644

include/uapi/linux/kfd_ioctl.h struct kfd_ioctl_acquire_vm_args { · line 345

Quoted 8 lines
include/uapi/linux/kfd_ioctl.h +1 -1
@@ -339,7 +339,7 @@ struct kfd_ioctl_acquire_vm_args {
  #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR		(1 << 2)
  #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL	(1 << 3)
  /* Allocation flags: attributes/access options */
-#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1 << 31)
+#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1U << 31)
  #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE	(1 << 30)
  #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC		(1 << 29)
  #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE	(1 << 28)

Hi Jiunn,

cc mailing lists.

-- Shuah

#4 lore raw

PATCH v2 1/1 drm/amdkfd: Fix undefined behavior in bit shift

In reply to Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

---
 include/uapi/linux/kfd_ioctl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/kfd_ioctl.h +1 -1
index dc067ed0b72d..ae5669272303 100644
@@ -339,7 +339,7 @@ struct kfd_ioctl_acquire_vm_args {
 #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR		(1 << 2)
 #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL	(1 << 3)
 /* Allocation flags: attributes/access options */
-#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1 << 31)
+#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1U << 31)
 #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE	(1 << 30)
 #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC		(1 << 29)
 #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE	(1 << 28)
Signature · 1 line
2.22.0
#5 lore raw

Re: [Linux-kernel-mentees][PATCH v2] drm/amdkfd: Fix undefined behavior in bit shift

Quoted 9 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

---

Move version change lines here.

Quoted 9 lines
  include/uapi/linux/kfd_ioctl.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/kfd_ioctl.h +0 -0
index dc067ed0b72d..ae5669272303 100644

include/uapi/linux/kfd_ioctl.h struct kfd_ioctl_acquire_vm_args { · line 345

Quoted 8 lines
include/uapi/linux/kfd_ioctl.h +1 -1
@@ -339,7 +339,7 @@ struct kfd_ioctl_acquire_vm_args {
  #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR		(1 << 2)
  #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL	(1 << 3)
  /* Allocation flags: attributes/access options */
-#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1 << 31)
+#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1U << 31)
  #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE	(1 << 30)
  #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC		(1 << 29)
  #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE	(1 << 28)

thanks,
-- Shuah

#6 lore raw

PATCH v3 1/1 drm/amdkfd: Fix undefined behavior in bit shift

In reply to Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

---
Changes included in v3:
- remove change log from patch description

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

 include/uapi/linux/kfd_ioctl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/kfd_ioctl.h +1 -1
index dc067ed0b72d..ae5669272303 100644
@@ -339,7 +339,7 @@ struct kfd_ioctl_acquire_vm_args {
 #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR		(1 << 2)
 #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL	(1 << 3)
 /* Allocation flags: attributes/access options */
-#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1 << 31)
+#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE	(1U << 31)
 #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE	(1 << 30)
 #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC		(1 << 29)
 #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE	(1 << 28)
Signature · 1 line
2.22.0
#7 lore raw

PATCH 1/1 uapi: linux: Fix undefined behavior in bit shift

In reply to Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
 include/uapi/linux/nl80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/nl80211.h +1 -1
index 6f09d1500960..fa7ebbc6ff27 100644
@@ -5314,7 +5314,7 @@ enum nl80211_feature_flags {
 	NL80211_FEATURE_TDLS_CHANNEL_SWITCH		= 1 << 28,
 	NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR		= 1 << 29,
 	NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR	= 1 << 30,
-	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1 << 31,
+	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1U << 31,
 };
 
 /**
Signature · 1 line
2.22.0
#8 lore raw

PATCH 1/1 uapi: linux: Fix undefined behavior in bit shift

Quoted 14 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
  include/uapi/linux/nl80211.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/nl80211.h +0 -0
index 6f09d1500960..fa7ebbc6ff27 100644

include/uapi/linux/nl80211.h enum nl80211_feature_flags { · line 5320

Quoted 8 lines
include/uapi/linux/nl80211.h +1 -1
@@ -5314,7 +5314,7 @@ enum nl80211_feature_flags {
  	NL80211_FEATURE_TDLS_CHANNEL_SWITCH		= 1 << 28,
  	NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR		= 1 << 29,
  	NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR	= 1 << 30,
-	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1 << 31,
+	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1U << 31,
  };
 
  /**

cc mailing lists.

-- Shuah

#9 lore raw

PATCH v2 1/1 nl80211: Fix undefined behavior in bit shift

In reply to c0d1n61at3 at gmail.com (Jiunn Chang)

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
 include/uapi/linux/nl80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/nl80211.h +1 -1
index 6f09d1500960..fa7ebbc6ff27 100644
@@ -5314,7 +5314,7 @@ enum nl80211_feature_flags {
 	NL80211_FEATURE_TDLS_CHANNEL_SWITCH		= 1 << 28,
 	NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR		= 1 << 29,
 	NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR	= 1 << 30,
-	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1 << 31,
+	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1U << 31,
 };
 
 /**
Signature · 1 line
2.22.0
#10 lore raw

Re: [Linux-kernel-mentees][PATCH v2] nl80211: Fix undefined behavior in bit shift

Quoted 9 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

---

Move version change lines here. They don't belong in the commit log.

Quoted 9 lines
  include/uapi/linux/nl80211.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/nl80211.h +0 -0
index 6f09d1500960..fa7ebbc6ff27 100644

include/uapi/linux/nl80211.h enum nl80211_feature_flags { · line 5320

Quoted 8 lines
include/uapi/linux/nl80211.h +1 -1
@@ -5314,7 +5314,7 @@ enum nl80211_feature_flags {
  	NL80211_FEATURE_TDLS_CHANNEL_SWITCH		= 1 << 28,
  	NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR		= 1 << 29,
  	NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR	= 1 << 30,
-	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1 << 31,
+	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1U << 31,
  };
 
  /**

thanks,
-- Shuah

maintainer
#11 lore raw

Re: [Linux-kernel-mentees][PATCH v2] nl80211: Fix undefined behavior in bit shift

Quoted 4 lines · Shuah Khan
Quoted 3 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Quoted 8 lines
Quoted 6 lines

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

---

Move version change lines here. They don't belong in the commit log.

FWIW, in many cases people (maintainers) now *do* want them in the commit log. Here, they're just editorial, so agree, but if real technical changes were made due to reviews, they can indeed be useful.

johannes

#12 lore raw

Re: [Linux-kernel-mentees][PATCH v2] nl80211: Fix undefined behavior in bit shift

Quoted 12 lines · Johannes Berg
Quoted 11 lines · Shuah Khan
Quoted 9 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

---

Quoted 8 lines
Quoted 1 line

Move version change lines here. They don't belong in the commit log.

FWIW, in many cases people (maintainers) now *do* want them in the commit log. Here, they're just editorial, so agree, but if real technical changes were made due to reviews, they can indeed be useful.

johannes

I went looking in the git log. Looks like there are several commits with "Changes since" included in the commit log. It still appears to be maintainer preference. Probably from networking and networking related areas - wireless being one of them. This trend is recent it appears in any case.

There is a value to seeing changes as the work evolves. However, there is the concern that how log should it be.

This example commit has history from RFC stage and no doubt very useful since this is a new driver.

8ef988b914bd449458eb2174febb67b0f137b33c

If we make this more of a norm, we do want to make sure, we evolve from informal nature of these "Changes since", to "Commit log" text.

thanks,
-- Shuah

maintainer
#13 lore raw

Re: [Linux-kernel-mentees][PATCH v2] nl80211: Fix undefined behavior in bit shift

Hi Shuah,

Quoted 5 lines

I went looking in the git log. Looks like there are several commits with "Changes since" included in the commit log. It still appears to be maintainer preference. Probably from networking and networking related areas - wireless being one of them. This trend is recent it appears in any case.

Yeah. I was really just observing that I'd seen this, and some people (I guess 'many' was an exaggeration) actively request it to be in the commit log. I "grew up" with "changelog after ---" too ;-)

Quoted 2 lines

There is a value to seeing changes as the work evolves. However, there is the concern that how log should it be.

That doesn't parse, what did you mean?

Quoted 7 lines

This example commit has history from RFC stage and no doubt very useful since this is a new driver.

8ef988b914bd449458eb2174febb67b0f137b33c

If we make this more of a norm, we do want to make sure, we evolve from informal nature of these "Changes since", to "Commit log" text.

Not sure it's really worth it, but I guess some recommendations could be useful. If it is indeed to become the norm, and there aren't some people who strongly feel it should *not* be included.

johannes

#14 lore raw

Re: [Linux-kernel-mentees][PATCH v2] nl80211: Fix undefined behavior in bit shift

Quoted 8 lines · Johannes Berg

Hi Shuah,

Quoted 5 lines

I went looking in the git log. Looks like there are several commits with "Changes since" included in the commit log. It still appears to be maintainer preference. Probably from networking and networking related areas - wireless being one of them. This trend is recent it appears in any case.

Quoted 8 lines

Yeah. I was really just observing that I'd seen this, and some people (I guess 'many' was an exaggeration) actively request it to be in the commit log. I "grew up" with "changelog after ---" too ;-)

Quoted 2 lines

There is a value to seeing changes as the work evolves. However, there is the concern that how log should it be.

That doesn't parse, what did you mean?

Say we are on version 16 of a patch series, when does the commit log become too long to be useful?

Quoted 6 lines
Quoted 6 lines

This example commit has history from RFC stage and no doubt very useful since this is a new driver.

8ef988b914bd449458eb2174febb67b0f137b33c

This commit has a very long commit log starting from RFC stage. It is very informative.

Quoted 7 lines
Quoted 2 lines

If we make this more of a norm, we do want to make sure, we evolve from informal nature of these "Changes since", to "Commit log" text.

Not sure it's really worth it, but I guess some recommendations could be useful. If it is indeed to become the norm, and there aren't some people who strongly feel it should *not* be included.

Yeah. If it becomes a norm, we probably will have to set some limits how long, and reads like part of the commit log as opposed to something slapped on at the end.

thanks,
-- Shuah

#15 lore raw

Re: [Linux-kernel-mentees][PATCH v2] nl80211: Fix undefined behavior in bit shift

In reply to Johannes Berg
Quoted 12 lines · Johannes Berg
Quoted 11 lines · Shuah Khan
Quoted 9 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

---

Quoted 8 lines
Quoted 1 line

Move version change lines here. They don't belong in the commit log.

FWIW, in many cases people (maintainers) now *do* want them in the commit log. Here, they're just editorial, so agree, but if real technical changes were made due to reviews, they can indeed be useful.

johannes

Hello Johannes,

Would you like me to send v3 with the change log in the patch description?

THX,

Jiunn

maintainer
#16 lore raw

Re: [Linux-kernel-mentees][PATCH v2] nl80211: Fix undefined behavior in bit shift

Quoted 2 lines · Jiunn Chang

Would you like me to send v3 with the change log in the patch description?

No no, like I said, it's not very useful in this case anyway.

johannes

#17 lore raw

PATCH v3 1/1 nl80211: Fix undefined behavior in bit shift

In reply to Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

---
Changes included in v3:
- remove change log from patch description

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

 include/uapi/linux/nl80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/nl80211.h +1 -1
index 6f09d1500960..fa7ebbc6ff27 100644
@@ -5314,7 +5314,7 @@ enum nl80211_feature_flags {
 	NL80211_FEATURE_TDLS_CHANNEL_SWITCH		= 1 << 28,
 	NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR		= 1 << 29,
 	NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR	= 1 << 30,
-	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1 << 31,
+	NL80211_FEATURE_ND_RANDOM_MAC_ADDR		= 1U << 31,
 };
 
 /**
Signature · 1 line
2.22.0
#18 lore raw

PATCH 1/1 uapi: linux: Fix undefined behavior in bit shift

In reply to Jiunn Chang
Quoted 14 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
  include/uapi/linux/if_packet.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/if_packet.h +0 -0
index 467b654bd4c7..3d884d68eb30 100644

include/uapi/linux/if_packet.h struct tpacket_auxdata { · line 129

Quoted 8 lines
include/uapi/linux/if_packet.h +1 -1
@@ -123,7 +123,7 @@ struct tpacket_auxdata {
  /* Rx and Tx ring - header status */
  #define TP_STATUS_TS_SOFTWARE		(1 << 29)
  #define TP_STATUS_TS_SYS_HARDWARE	(1 << 30) /* deprecated, never set */
-#define TP_STATUS_TS_RAW_HARDWARE	(1 << 31)
+#define TP_STATUS_TS_RAW_HARDWARE	(1U << 31)
 
  /* Rx ring - feature request bits */
  #define TP_FT_REQ_FILL_RXHASH	0x1

Hi Jiunn,

You will have to cc mailing lists. You sent two patches for two changes in this file. Combining them in one patch might be a good idea.

btw. I just sent email with some tips and guidelines. Please refer to them before sending patches.

thanks,
-- Shuah

#19 lore raw

PATCH v2 1/1 packet: Fix undefined behavior in bit shift

In reply to Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>
---
 include/uapi/linux/if_packet.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/if_packet.h +1 -1
index 467b654bd4c7..3d884d68eb30 100644
@@ -123,7 +123,7 @@ struct tpacket_auxdata {
 /* Rx and Tx ring - header status */
 #define TP_STATUS_TS_SOFTWARE		(1 << 29)
 #define TP_STATUS_TS_SYS_HARDWARE	(1 << 30) /* deprecated, never set */
-#define TP_STATUS_TS_RAW_HARDWARE	(1 << 31)
+#define TP_STATUS_TS_RAW_HARDWARE	(1U << 31)
 
 /* Rx ring - feature request bits */
 #define TP_FT_REQ_FILL_RXHASH	0x1
Signature · 1 line
2.22.0
#20 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

Quoted 7 lines · Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

These version change lines don't belong in the change log.

Quoted 2 lines
Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

---

Move them here.

Quoted 9 lines
  include/uapi/linux/if_packet.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/if_packet.h +0 -0
index 467b654bd4c7..3d884d68eb30 100644

include/uapi/linux/if_packet.h struct tpacket_auxdata { · line 129

Quoted 8 lines
include/uapi/linux/if_packet.h +1 -1
@@ -123,7 +123,7 @@ struct tpacket_auxdata {
  /* Rx and Tx ring - header status */
  #define TP_STATUS_TS_SOFTWARE		(1 << 29)
  #define TP_STATUS_TS_SYS_HARDWARE	(1 << 30) /* deprecated, never set */
-#define TP_STATUS_TS_RAW_HARDWARE	(1 << 31)
+#define TP_STATUS_TS_RAW_HARDWARE	(1U << 31)
 
  /* Rx ring - feature request bits */
  #define TP_FT_REQ_FILL_RXHASH	0x1

thanks,
-- Shuah

maintainer
#21 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

From: Shuah Khan <skhan at linuxfoundation.org>
Date: Wed, 26 Jun 2019 21:32:52 -0600

Quoted 9 lines · Jiunn Chang
Quoted 6 lines

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.
Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

These version change lines don't belong in the change log.

For networking changes I actually like the change lines to be in the commit log. So please don't stray people this way, thanks.

#22 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

Quoted 11 lines · David Miller

From: Shuah Khan <skhan at linuxfoundation.org>
Date: Wed, 26 Jun 2019 21:32:52 -0600

Quoted 8 lines · Jiunn Chang
Quoted 6 lines

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.
Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Quoted 5 lines
Quoted 1 line

These version change lines don't belong in the change log.

For networking changes I actually like the change lines to be in the commit log. So please don't stray people this way, thanks.

As a general rule, please don't include change lines in the commit log. For networking changes that get sent to David and netdev, as David points out here, he likes them in the commit log, please include them in the commit log.

I am working on FAQ (Frequently Answered Questions) section for mentees. I will add this to it.

thanks,
-- Shuah

#23 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

Quoted 19 lines · Shuah Khan
Quoted 11 lines · David Miller

From: Shuah Khan <skhan at linuxfoundation.org>
Date: Wed, 26 Jun 2019 21:32:52 -0600

Quoted 8 lines · Jiunn Chang
Quoted 6 lines

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.
Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Quoted 5 lines
Quoted 1 line

These version change lines don't belong in the change log.

For networking changes I actually like the change lines to be in the commit log. So please don't stray people this way, thanks.

Quoted 7 lines

As a general rule, please don't include change lines in the commit log. For networking changes that get sent to David and netdev, as David points out here, he likes them in the commit log, please include them in the commit log.

I am working on FAQ (Frequently Answered Questions) section for mentees. I will add this to it.

Same for bpf trees.
We prefer developers put as much as info as possible into commit logs and cover letters.
Explanation of v1->v2->v3 differences is invaluable not only at the point of code review, but in the future.

#24 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

Quoted 25 lines · Alexei Starovoitov
Quoted 24 lines · Shuah Khan
Quoted 11 lines · David Miller

From: Shuah Khan <skhan at linuxfoundation.org>
Date: Wed, 26 Jun 2019 21:32:52 -0600

Quoted 8 lines · Jiunn Chang
Quoted 6 lines

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.
Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Quoted 5 lines
Quoted 1 line

These version change lines don't belong in the change log.

For networking changes I actually like the change lines to be in the commit log. So please don't stray people this way, thanks.

As a general rule, please don't include change lines in the commit log. For networking changes that get sent to David and netdev, as David points out here, he likes them in the commit log, please include them in the commit log.

Quoted 9 lines
Quoted 2 lines

I am working on FAQ (Frequently Answered Questions) section for mentees. I will add this to it.

Same for bpf trees.
We prefer developers put as much as info as possible into commit logs and cover letters.
Explanation of v1->v2->v3 differences is invaluable not only at the point of code review, but in the future.

Thanks Alex. I will add that to the FAQ.

-- Shuah

#25 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

In reply to David Miller
Quoted 11 lines · David Miller

From: Shuah Khan <skhan at linuxfoundation.org>
Date: Wed, 26 Jun 2019 21:32:52 -0600

Quoted 8 lines · Jiunn Chang
Quoted 6 lines

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.
Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Quoted 4 lines
Quoted 1 line

These version change lines don't belong in the change log.

For networking changes I actually like the change lines to be in the commit log. So please don't stray people this way, thanks.

Hello David,

Would you like me to send v3 with the change log in the patch description?

I would be happy to do that.

THX,

Jiunn

maintainer
#26 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

From: Jiunn Chang <[email protected]>
Date: Thu, 27 Jun 2019 11:57:28 -0500

Quoted 12 lines · David Miller
Quoted 11 lines

From: Shuah Khan <skhan at linuxfoundation.org>
Date: Wed, 26 Jun 2019 21:32:52 -0600

Quoted 8 lines · Jiunn Chang
Quoted 6 lines

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.
Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

These version change lines don't belong in the change log.

For networking changes I actually like the change lines to be in the commit log. So please don't stray people this way, thanks.

Hello David,

Would you like me to send v3 with the change log in the patch description?

I'll use v2 which had this done correctly.

#27 lore raw

PATCH v3 1/1 packet: Fix undefined behavior in bit shift

In reply to Jiunn Chang

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

---
Changes included in v3:
- remove change log from patch description

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

 include/uapi/linux/if_packet.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/if_packet.h +1 -1
index 467b654bd4c7..3d884d68eb30 100644
@@ -123,7 +123,7 @@ struct tpacket_auxdata {
 /* Rx and Tx ring - header status */
 #define TP_STATUS_TS_SOFTWARE		(1 << 29)
 #define TP_STATUS_TS_SYS_HARDWARE	(1 << 30) /* deprecated, never set */
-#define TP_STATUS_TS_RAW_HARDWARE	(1 << 31)
+#define TP_STATUS_TS_RAW_HARDWARE	(1U << 31)
 
 /* Rx ring - feature request bits */
 #define TP_FT_REQ_FILL_RXHASH	0x1
Signature · 1 line
2.22.0
maintainer Applied
#28 lore raw

Re: [Linux-kernel-mentees][PATCH v2] packet: Fix undefined behavior in bit shift

In reply to Jiunn Chang

From: Jiunn Chang <c0d1n61at3 at gmail.com>
Date: Wed, 26 Jun 2019 22:25:30 -0500

Quoted 8 lines

Shifting signed 32-bit value by 31 bits is undefined. Changing most significant bit to unsigned.

Changes included in v2:
- use subsystem specific subject lines
- CC required mailing lists

Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>

Applied.