+ net-ipv4-tcpc-fix-warning.patch added to -mm tree
Subsystems (3)
[email protected]
tree noticeThe patch titled
net/ipv4/tcp.c: fix warning
has been added to the -mm tree. Its filename is
net-ipv4-tcpc-fix-warning.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject: net/ipv4/tcp.c: fix warning
From: Andrew Morton <[email protected]>
x86_64 allmodconfig:
net/ipv4/tcp.c: In function 'do_tcp_getsockopt':net/ipv4/tcp.c:2544: warning: comparison is always false due to limited range of data type
sizeof(tcpct_value) is 536, which can never be less than a value which is held in a u8.
This fix is stupid - just delete the code?
btw, what does "return as nonce" try to mean?
---
net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/tcp.c renamed from net/ipv4/tcp.c~net-ipv4-tcpc-fix-warning +2 -0
@@ -2540,11 +2540,13 @@ static int do_tcp_getsockopt(struct sock ctd.tcpct_cookie_desired = cvp->cookie_desired; ctd.tcpct_s_data_desired = cvp->s_data_desired; +#if TCP_MSS_DEFAULT <256 /* Cookie(s) saved, return as nonce */ if (sizeof (ctd.tcpct_value) < cvp->cookie_pair_size) {/* impossible? */ return -EINVAL ; } +#endif memcpy (&ctd.tcpct_value[0 ], &cvp->cookie_pair[0 ], cvp->cookie_pair_size); ctd.tcpct_used = cvp->cookie_pair_size;
_
Patches currently in -mm which might be from [email protected] are
origin.patch
linux-next.patch
linux-next-git-rejects.patch
next-remove-localversion.patch
i-need-old-gcc.patch revert-input-wistron_btns-switch-to-using-sparse-keymap-library.patch makefile-fix-find-args.patch
drivers-gpu-drm-i915-i915_dmac-fix-unused-var.patch arch-x86-kernel-cpu-cpufreq-acpi-cpufreqc-avoid-cross-cpu-interrupts-by-using-smp_call_function_any.patch acpi-remove-nid_inval.patch
drivers-acpi-acpi_padc-squish-warning.patch cmpc_acpi-add-support-for-classmate-pc-acpi-devices.patch cmpc_acpi-add-support-for-classmate-pc-acpi-devices-checkpatch-fixes.patch drivers-gpu-drm-radeon-radeon_combiosc-fix-warning.patch drivers-media-video-pmsc-needs-versionh.patch timer-stats-fix-del_timer_sync-and-try_to_del_timer_sync.patch drivers-leds-leds-ss4200c-fix-return-statement.patch
net-sctp-socketc-fix-warning.patch
net-ipv4-tcpc-fix-warning.patch
proc_fops-convert-drivers-isdn-to-seq_file-fix2.patch 3x59x-fix-pci-resource-management.patch bluetooth-fix-for-acer-bluetooth-optical-rechargeable-mouse.patch atmel_serial-add-poll_get_char-and-poll_put_char-uart_ops.patch scsi-add-hpsa-driver-for-hp-smart-array-controllers.patch aoe-switch-to-the-new-bio_flush_dcache_pages-interface.patch drivers-staging-wlags49_h2-remove-cvs-metadata.patch wusb-use-sizeof-struct-rather-than-pointer.patch raw-fix-rawctl-compat-ioctls-breakage-on-amd64-and-itanic.patch fs-improve-remountro-vs-buffercache-coherency.patch percpu-avoid-calling-__pcpu_ptr_to_addrnull.patch readahead-add-blk_run_backing_dev.patch mmap-dont-return-enomem-when-mapcount-is-temporarily-exceeded-in-munmap-checkpatch-fixes.patch dev-mem-cleanup-unxlate_dev_mem_ptr-calls-fix.patch dev-mem-cleanup-unxlate_dev_mem_ptr-calls-fix-fix.patch oom-kill-show-virtual-size-and-rss-information-of-the-killed-process-fix.patch oom-kill-fix-numa-consraint-check-with-nodemask-v42-checkpatch-fixes.patch mm-mlocking-in-try_to_unmap_one-fix-fix.patch mm-memory_hotplug-make-offline_pages-static.patch mm-hugetlb-fix-hugepage-memory-leak-in-mincore-cleanup.patch frv-duplicate-output_buffer-of-e03-checkpatch-fixes.patch procfs-allow-threads-to-rename-siblings-via-proc-pid-tasks-tid-comm-cleanup.patch floppy-add-an-extra-bound-check-on-ioctl-arguments-fix.patch drivers-misc-add-driver-for-texas-instruments-dac7512-update.patch rwsem-fix-rwsem_is_locked-bugs-fix.patch kernelh-add-printk_ratelimited-and-pr_level_rl-checkpatch-fixes.patch kernelh-add-printk_ratelimited-and-pr_level_rl-rename.patch errh-add-helper-function-to-simplify-pointer-error-checking-fix.patch drivers-scsi-sym53c8xx_2-sym_gluec-rename-skip_spaces-to-sym_skip_spaces.patch lib-introduce-strim-checkpatch-fixes.patch msm_sdccc-add-missing-include-fix-compilation-checkpatch-fixes.patch blackfin-sd-host-controller-driver-fix.patch blackfin-sd-host-controller-driver-fix-fix.patch blackfin-sd-host-controller-driver-fix-fix-fix.patch crc32-minor-optimizations-and-cleanup-checkpatch-fixes.patch hwmon-w83627ehf-updates-checkpatch-fixes.patch lis3-update-documentation-to-match-latest-changes-fix.patch spi-controller-driver-for-designware-spi-core-fix.patch spidev-use-declare_bitmap-instead-of-declaring-the-array-checkpatch-fixes.patch gpiolib-add-names-file-in-gpio-chip-sysfs.patch mb862xxfb-add-acceleration-support-for-coral-p-coral-pa-imageblt-copyarea-fillrect-fix.patch mb862xxfb-add-acceleration-support-for-coral-p-coral-pa-imageblt-copyarea-fillrect-fix2.patch mb862xxfb-add-acceleration-support-for-coral-p-coral-pa-imageblt-copyarea-fillrect-fix2-fix-3.patch ext2-avoid-warn-messages-when-failing-to-write-to-the-superblock-checkpatch-fixes.patch memcg-coalesce-charging-via-percpu-storage-fix.patch memcg-code-cleanrm-unused-variable-in-mem_cgroup_resize_limit-cleanup.patch ipc-remove-unreachable-code-in-semc-fix.patch
char-cyclades-fix-compiler-warning.patch ip2-remove-ifdef-module-from-ip2mainc-fix-2.patch drivers-edac-amd64_edacc-fix-use-uninitialised-bug.patch fs-cache-avoid-maybe-used-uninitialised-warning-on-variable.patch aio-dont-zero-out-the-pages-array-inside-struct-dio-fix.patch direct-io-cleanup-blockdev_direct_io-locking-checkpatch-fixes.patch drivers-media-video-cx23885-needs-kfifo-conversion.patch drivers-media-video-cx23885-needs-kfifo-updates.patch kfifo-move-struct-kfifo-in-place-fix.patch zlib-optimize-inffast-when-copying-direct-from-output-checkpatch-fixes.patch lib-add-support-for-lzo-compressed-kernels-checkpatch-fixes.patch lib-add-support-for-lzo-compressed-kernels-checkpatch-fixes-cleanup.patch net-netfilter-ipvs-ip_vs_wrrc-use-lib-gcdc-fix.patch reiser4-export-remove_from_page_cache-fix.patch
reiser4.patch
reiser4-remove-simple_prepare_write-usage-checkpatch-fixes.patch fs-reiser4-contextc-current_is_pdflush-got-removed.patch
reiser4-fix.patch
slab-leaks3-default-y.patch
put_bh-debug.patch
getblk-handle-2tb-devices.patch
getblk-handle-2tb-devices-fix.patch
undeprecate-pci_find_device.patch
notify_change-callers-must-hold-i_mutex.patch
William Allen Simpson
Acked-byQuoted 24 lines · [email protected] wrote:
The patch titled
net/ipv4/tcp.c: fix warning
has been added to the -mm tree. Its filename is
net-ipv4-tcpc-fix-warning.patchBefore you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's*** Remember to use
Documentation/SubmitChecklistwhen testing your code ***See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject:net/ipv4/tcp.c: fix warning
From: Andrew Morton <[email protected]>
x86_64allmodconfig:
Quoted 8 lines
net/ipv4/tcp.c: In function 'do_tcp_getsockopt':net/ipv4/tcp.c:2544: warning: comparison is always false due to limited range of data type
sizeof(tcpct_value)is 536, which can never be less than a value which is held in a u8.This fix is stupid - just delete the code?
I didn't have this warning, how in the world do you get it?
This is what David calls my "anal" coding style. I check everything, because someday somebody else might make a change, and it's important that such problems be detected. In this case, I assume the compiler will compile them out or it would have no effect, and commented that it should be impossible.
Your test should probably be TCP_MSS_DEFAULT < TCP_COOKIE_PAIR_SIZE
Quoted 2 lines
btw, what does "return as nonce" try to mean?
The internet-draft specifies returning a nonce.
Quoted 2 lines
Cc David S. Miller <[email protected]>Signed-off-by Andrew Morton <[email protected]>
Quoted 23 lines
---
net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+)diff -puN
net/ipv4/tcp.c~net-ipv4-tcpc-fix-warningnet/ipv4/tcp.cnet/ipv4/tcp.c renamed from net/ipv4/tcp.c~net-ipv4-tcpc-fix-warning +2
-0@@ -2540,11 +2540,13 @@ static int do_tcp_getsockopt(struct sock ctd.tcpct_cookie_desired = cvp->cookie_desired; ctd.tcpct_s_data_desired = cvp->s_data_desired; +#if TCP_MSS_DEFAULT <256 /* Cookie(s) saved, return as nonce */ if (sizeof (ctd.tcpct_value) < cvp->cookie_pair_size) {/* impossible? */ return -EINVAL ; } +#endif memcpy (&ctd.tcpct_value[0 ], &cvp->cookie_pair[0 ], cvp->cookie_pair_size); ctd.tcpct_used = cvp->cookie_pair_size;_
Quoted 9 lines · On Tue, 08 Dec 2009 20:45:53 -0500 William Allen Simpson…
Quoted 9 lines
------------------------------------------------------
Subject:net/ipv4/tcp.c: fix warning
From: Andrew Morton <[email protected]>
x86_64allmodconfig:
net/ipv4/tcp.c: In function 'do_tcp_getsockopt':net/ipv4/tcp.c:2544: warning: comparison is always false due to limited range of data type
Quoted 6 lines
Quoted 5 lines
sizeof(tcpct_value)is 536, which can never be less than a value which is held in a u8.This fix is stupid - just delete the code?
I didn't have this warning, how in the world do you get it?
Used gcc-4.0.2. They re-randomise the warnings with each release I think.
Quoted 7 lines
This is what David calls my "anal" coding style. I check everything, because someday somebody else might make a change, and it's important that such problems be detected. In this case, I assume the compiler will compile them out or it would have no effect, and commented that it should be impossible.
Your test should probably be
TCP_MSS_DEFAULT<TCP_COOKIE_PAIR_SIZE
I'd say just delete it ;)
David Miller
maintainerFrom: Andrew Morton <[email protected]>
Date: Tue, 8 Dec 2009 18:08:01 -0800
Quoted 1 line
I'd say just delete it ;)
That's how I'll handle this, thanks Andrew.
Quoted 6 lines · Andrew Morton
Quoted 1 line · On Tue, 08 Dec 2009 20:45:53 -0500 William Allen Simpson…
I didn't have this warning, how in the world do you get it?
Used gcc-4.0.2. They re-randomise the warnings with each release I think.
Using gcc-4.4.1 here, and the usual 'make -s -j4 vmlinux'.
Quoted 10 lines
Quoted 7 lines
This is what David calls my "anal" coding style. I check everything, because someday somebody else might make a change, and it's important that such problems be detected. In this case, I assume the compiler will compile them out or it would have no effect, and commented that it should be impossible.
Your test should probably be
TCP_MSS_DEFAULT<TCP_COOKIE_PAIR_SIZEI'd say just delete it ;)
Well, David said he would, but nothing seems to have happened, so I'll send a short patch in my next message.
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
Replace + net-ipv4-tcpc-fix-warning.patch added to -mm tree
Remove the offending code, and replace with comments. This is an unlikely problem, so depend on human finding any future error.
--- net/ipv4/tcp.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
net/ipv4/tcp.c +4 -5
@@ -2540,11 +2540,10 @@ static int do_tcp_getsockopt(struct sock *sk, int level, ctd.tcpct_cookie_desired = cvp->cookie_desired; ctd.tcpct_s_data_desired = cvp->s_data_desired; -/* Cookie(s) saved, return as nonce */ -if (sizeof (ctd.tcpct_value) < cvp->cookie_pair_size) { -/* impossible? */ -return -EINVAL ; - } +/* Cookie(s) saved, return as nonce. +* Assumes TCP_MSS_DEFAULT > TCP_COOKIE_PAIR_SIZE, +* sizeof(ctd.tcpct_value) > cvp->cookie_pair_size +*/ memcpy (&ctd.tcpct_value[0 ], &cvp->cookie_pair[0 ], cvp->cookie_pair_size); ctd.tcpct_used = cvp->cookie_pair_size;
Signature · 1 line
1.6.3.3
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
Quoted 16 lines · William Allen Simpson
Replace + net-ipv4-tcpc-fix-warning.patch added to -mm tree
Remove the offending code, and replace with comments. This is an unlikely problem, so depend on human finding any future error.
Signed-off-by [email protected]--- net/ipv4/tcp.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)plain text document attachment (net-ipv4-tcp.c-fix-warning-from-older-compilers.patch)
net/ipv4/tcp.c +0
-0
net/ipv4/tcp.c static int do_tcp_getsockopt(struct sock *sk, int level, · line 2544
Quoted 10 lines
net/ipv4/tcp.c +2
-5@@ -2540,11 +2540,10 @@ static int do_tcp_getsockopt(struct sock *sk, int level, ctd.tcpct_cookie_desired = cvp->cookie_desired; ctd.tcpct_s_data_desired = cvp->s_data_desired; -/* Cookie(s) saved, return as nonce */ -if (sizeof (ctd.tcpct_value) < cvp->cookie_pair_size) { -/* impossible? */ -return -EINVAL ; - } +/* Cookie(s) saved, return as nonce. +* Assumes TCP_MSS_DEFAULT > TCP_COOKIE_PAIR_SIZE,
[...]
You can use BUILD_BUG_ON() to ensure that remains true.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
Quoted 2 lines · Ben Hutchings
You can use
BUILD_BUG_ON()to ensure that remains true.
Another fine undocumented Linux Kernel feature. In the absence of standardized functions that check for buffer overruns, that's just the ticket!
Kinda the opposite conditional of static assert, but I'm pretty sure static assert wasn't working in gcc until a year or so ago. That's why I used the more old-fashioned test instead. I'd no idea those triggered a warning in some versions of gcc -- I never trusted 4.0.x, and had plenty of problems with 4.1.x, too.
Thanks, I'll resubmit.
PATCH v2 1/1 net-ipv4-tcp.c-fix-warning-for-older-compilers.patch
Replace + net-ipv4-tcpc-fix-warning.patch added to -mm tree
Remove the offending code, and replace with BUILD_BUG_ON().
--- net/ipv4/tcp.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
net/ipv4/tcp.c +1 -4
@@ -2541,10 +2541,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level, ctd.tcpct_s_data_desired = cvp->s_data_desired;/* Cookie(s) saved, return as nonce */ -if (sizeof (ctd.tcpct_value) < cvp->cookie_pair_size) { -/* impossible? */ -return -EINVAL ; - } +BUILD_BUG_ON (sizeof (ctd.tcpct_value) <TCP_COOKIE_PAIR_SIZE );memcpy (&ctd.tcpct_value[0 ], &cvp->cookie_pair[0 ], cvp->cookie_pair_size); ctd.tcpct_used = cvp->cookie_pair_size;
Signature · 1 line
1.6.3.3
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
In reply to William Allen SimpsonQuoted 9 lines · William Allen Simpson
Replace + net-ipv4-tcpc-fix-warning.patch added to -mm tree
Remove the offending code, and replace with comments. This is an unlikely problem, so depend on human finding any future error.
Signed-off-by [email protected]--- net/ipv4/tcp.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
This is not necessary, David already _did_ the thing, and _told_ so.
You probably missed fact we are in merge window, so fixes (and only fixes) are pushed into net-2.6 tree.
When Linus closes this merge window (issuing a linux-2.6.33-rc1 tag), then David re-opens net-next-2.6 tree for new stuff.
commit 3dc789320e1b310cb505dcd94512c279abcd5e1c
Author: David S. Miller <[email protected]> Date: Tue Dec 8 20:07:54 2009 -0800
tcp: Remove runtime check that can never be true.
GCC even warns about it, as reported by Andrew Morton:
net/ipv4/tcp.c: In function 'do_tcp_getsockopt':
net/ipv4/tcp.c:2544: warning: comparison is always false due to limited range of data type
David Miller
maintainerRe: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
From: Eric Dumazet <[email protected]>
Date: Thu, 10 Dec 2009 16:31:30 +0100
Quoted 6 lines
Le 10/12/2009 15:16, William Allen Simpson a $(D+1(Bcrit :
Quoted 5 lines
Replace + net-ipv4-tcpc-fix-warning.patch added to -mm tree
Remove the offending code, and replace with comments. This is an unlikely problem, so depend on human finding any future error.
Quoted 6 lines
Quoted 4 lines
Signed-off-by [email protected]--- net/ipv4/tcp.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)This is not necessary, David already _did_ the thing, and _told_ so.
Right.
Quoted 2 lines
You probably missed fact we are in merge window, so fixes (and only fixes) are pushed into net-2.6 tree.
I even announced this explicitly to the list:
http://marc.info/?l=linux-netdev&m=126031591420846&w=2
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Replace + net-ipv4-tcpc-fix-warning.patch added to -mm tree
Remove the offending code, and replace with comments. This is an unlikely problem, so depend on human finding any future error.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Signed-off-by [email protected]--- net/ipv4/tcp.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)This is not necessary, David already _did_ the thing, and _told_ so.
Right.
But David _did_ forget to _send_ the thing to the list. ;-)
Jarek P.
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
Quoted 4 lines · Jarek Poplawski
Quoted 1 line
Quoted 1 line
This is not necessary, David already _did_ the thing, and _told_ so.
But David _did_ forget to _send_ the thing to the list. ;-)
Aha, so it wasn't a local problem. Thanks!
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
Quoted 6 lines · William Allen Simpson
Quoted 4 lines · Jarek Poplawski
Quoted 1 line
Quoted 1 line
This is not necessary, David already _did_ the thing, and _told_ so.
But David _did_ forget to _send_ the thing to the list. ;-)
Aha, so it wasn't a local problem. Thanks!
It's (linux) universal:
1. Nobody (even davem) is perfect :-(
2. Except akpm ;-)
Jarek P.
David Miller
maintainerRe: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
In reply to William Allen SimpsonFrom: William Allen Simpson <[email protected]>
Date: Fri, 11 Dec 2009 10:51:21 -0500
Quoted 5 lines
Quoted 3 lines · Jarek Poplawski
Quoted 1 line
Quoted 1 line
This is not necessary, David already _did_ the thing, and _told_ so.
But David _did_ forget to _send_ the thing to the list. ;-)
Aha, so it wasn't a local problem. Thanks!
I didn't necessarily have to, I stated exactly in the thread with Andrew Morton what change I was going to make in my tree to resolve this.
If you're really interested in following development and generating correct current patches to the project, you should follow the appropriate GIT tree.
Re: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
In reply to Eric DumazetQuoted 2 lines · Eric Dumazet
This is not necessary, David already _did_ the thing, and _told_ so.
There doesn't seem to be a patch sent to the list, at least it didn't show up in my mail, nor is it in the archive. Such mistakes happen.
Quoted 3 lines
You probably missed fact we are in merge window, so fixes (and only fixes) are pushed into net-2.6 tree.
That's my understanding. I'd asked a question earlier which tree to patch against (which he didn't answer), but a later message was more helpful and detailed.
Quoted 3 lines
When Linus closes this merge window (issuing a linux-2.6.33-rc1 tag), then David re-opens net-next-2.6 tree for new stuff.
That's my understanding, thanks again. (This isn't new stuff.)
Quoted 2 lines
Well, I'll be darned! There must be some list that you're on that sends out such notifications....
Not a good patch, as it accidentally removed the section comment. And it fails to describe or test against buffer overruns.
So, he'll have no problems backing out his patch and adding mine.
David Miller
maintainerRe: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
From: William Allen Simpson <[email protected]>
Date: Fri, 11 Dec 2009 10:49:38 -0500
Quoted 1 line
So, he'll have no problems backing out his patch and adding mine.
Guess again.
David Miller
maintainerRe: [PATCH] net-ipv4-tcp.c-fix-warning-from-older-compilers.patch
In reply to William Allen SimpsonThis has already been taken care of in net-2.6 for more than a day.