Warnings when building out-of-tree module with -Wsign-compare

Bug #1321791 reported by Mauricio Faria de Oliveira
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Undecided
Unassigned
Trusty
Fix Released
Undecided
Mauricio Faria de Oliveira
Utopic
Fix Released
Undecided
Unassigned

Bug Description

Bug originally reported and fixes provided by Brian Hart, IBM.

Various warnings will be seen when building an out-of-tree module with -Wsign-compare if any of the following are included:

include/linux/bitops.h
include/linux/cpumask.h
include/linux/fb.h

Seen on post-release 14.04, with current kernel headers.

Example...

Makefile:
----------------------------------------
obj-m := sample.o

EXTRA_CFLAGS = -Wsign-compare
----------------------------------------

sample.c:
----------------------------------------
#include <linux/init.h>
#include <linux/module.h>
#include <linux/bitops.h>
#include <linux/cpumask.h>
#include <linux/fb.h>

MODULE_LICENSE("GPL");

static int sample_init(void)
{
    printk(KERN_ALERT "sample init\n");
    return 0;
}

static void sample_term(void)
{
    printk(KERN_ALERT "sample term\n");
    return;
}

module_init(sample_init)
module_exit(sample_term)
----------------------------------------

$ ARCH=powerpc make -C /usr/src/linux-headers-`uname -r` M=`pwd` modules
...
include/asm-generic/bitops/const_hweight.h:27:70: warning: signed and unsigned type in conditional expression [-Wsign-...
..
include/linux/cpumask.h:603:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
...
include/linux/fb.h:650:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
...

Fix:
-----

upstream commits:
- bitops.h: linux c32fa99f0b4252633aa464e28d1cb925bd2a79df
- cpumask.h: linux-next cea092c9488cbb22c8b70336ab1413e0daf350f0
- fb.h: linux-next ee3468739ed83d862dbbd90397aff5258f8f2c8e

Patches will be sent to the kernel-team mailing list.

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Patches submitted to the mailing list. [1]

Marking this as confirmed since I confirmed Brian's report.

[1] https://lists.ubuntu.com/archives/kernel-team/2014-May/043098.html

Changed in linux (Ubuntu):
status: New → Confirmed
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

The e-mail thread mentions 'Trusty SRU' on subject, but not sure where to reflect it on this bug's fields.

Tim Gardner (timg-tpi)
Changed in linux (Ubuntu Trusty):
status: New → In Progress
Changed in linux (Ubuntu Utopic):
status: Confirmed → Fix Released
Changed in linux (Ubuntu Trusty):
assignee: nobody → Mauricio Faria de Oliveira (mauricfo)
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Tim asked for waiting the 2 commits in linux-next to make into linux.

I'll ping him when that happens.

Revision history for this message
Brian W Hart (hartb) wrote :

All these changes are now present in Linus' tree:

- bitops.h: linux c32fa99f0b4252633aa464e28d1cb925bd2a79df
- cpumask.h: cea092c9488cbb22c8b70336ab1413e0daf350f0
- fb.h: ee3468739ed83d862dbbd90397aff5258f8f2c8e

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Thanks, Brian.

I just passed along in the kernel-team mailing list, as Tim requested last time.
I'll ping you once there are news.

Tim Gardner (timg-tpi)
Changed in linux (Ubuntu Trusty):
status: In Progress → Fix Committed
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

... guy is blazing fast; commits in master-next.

Revision history for this message
Luis Henriques (henrix) wrote :

This bug is awaiting verification that the kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-trusty' to 'verification-done-trusty'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: verification-needed-trusty
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

The packages in proposed fix it.
Thanks.

$ ARCH=powerpc make -C /usr/src/linux-headers-`uname -r` M=`pwd` clean modules 2>&1 | fgrep Wsign-compare
include/linux/bitops.h:77:3641: warning: signed and unsigned type in conditional expression [-Wsign-compare]
include/linux/cpumask.h:603:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
include/linux/fb.h:650:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
include/linux/bitops.h:77:3641: warning: signed and unsigned type in conditional expression [-Wsign-compare]
include/linux/cpumask.h:603:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
$

$ sudo apt-get install linux-image-virtual
[...]

$ ARCH=powerpc make -C /usr/src/linux-headers-`uname -r` M=`pwd` clean modules 2>&1 | fgrep Wsign-compare
$

tags: added: verification-done-trusty
removed: verification-needed-trusty
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

For the record:

$ uname -r
3.13.0-32-generic

Revision history for this message
Brian W Hart (hartb) wrote :

Same result here. Our out-of-tree modules builds without warning on 3.13.0-32-generic from proposed.

Thank you!

Just one note that the repo information in that wiki page doesn't really work for ports. Wiki suggests:

deb http://archive.ubuntu.com/ubuntu/ <release>-proposed restricted main multiverse universe

But what's needed for non-x86/AMD64 is:

deb http://ports.ubuntu.com/ubuntu-ports/ <release>-proposed restricted main multiverse universe

The software-center method isn't a good fit for us because these are display-less servers; we're not really running a desktop environment.

Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (35.8 KiB)

This bug was fixed in the package linux - 3.13.0-32.57

---------------
linux (3.13.0-32.57) trusty; urgency=low

  [ Upstream Kernel Changes ]

  * l2tp: Privilege escalation in ppp over l2tp sockets
    - LP: #1341472
    - CVE-2014-4943

linux (3.13.0-32.56) trusty; urgency=low

  [ Luis Henriques ]

  * Merged back Ubuntu-3.13.0-30.55 security release
  * Revert "x86_64,ptrace: Enforce RIP <= TASK_SIZE_MAX (CVE-2014-4699)"
    - LP: #1337339
  * Release Tracking Bug
    - LP: #1338524

  [ Upstream Kernel Changes ]

  * ptrace,x86: force IRET path after a ptrace_stop()
    - LP: #1337339
    - CVE-2014-4699
  * hpsa: add new Smart Array PCI IDs (May 2014)
    - LP: #1337516

linux (3.13.0-31.55) trusty; urgency=low

  [ Luis Henriques ]

  * Release Tracking Bug
    - LP: #1336278

  [ Andy Whitcroft ]

  * [Config] switch hyper-keyboard to virtual
    - LP: #1325306
  * [Packaging] linux-udeb-flavour -- standardise on linux prefix

  [ dann frazier ]

  * [Config] CONFIG_GPIO_DWAPB=m
    - LP: #1334823

  [ Feng Kan ]

  * SAUCE: (no-up) arm64: dts: Add Designware GPIO dts binding to APM
    X-Gene platform
    - LP: #1334823

  [ John Johansen ]

  * SAUCE: (no-up) apparmor: fix apparmor spams log with warning message
    - LP: #1308761

  [ Kamal Mostafa ]

  * [Config] updateconfigs ACPI_PROCFS_POWER=y after v3.13.11.4 rebase

  [ Loc Ho ]

  * SAUCE: (no-up) phy-xgene: Use correct tuning for Mustang
    - LP: #1335636

  [ Michael Ellerman ]

  * SAUCE: (no-up) powerpc/perf: Ensure all EBB register state is cleared
    on fork()
    - LP: #1328914

  [ Ming Lei ]

  * Revert "SAUCE: (no-up) rtc: Add X-Gene SoC Real Time Clock Driver"
    - LP: #1274305

  [ Suman Tripathi ]

  * SAUCE: (no-up) libahci: Implement the function ahci_restart_engine to
    restart the port dma engine.
    - LP: #1335645
  * SAUCE: (no-up) ata: Fix the dma state machine lockup for the IDENTIFY
    DEVICE PIO mode command.
    - LP: #1335645

  [ Tim Gardner ]

  * [Config] CONFIG_POWERNV_CPUFREQ=y for powerpc, ppc64el
    - LP: #1324571
  * [Debian] Add UTS_UBUNTU_RELEASE_ABI to utsrelease.h
    - LP: #1327619
  * [Config] CONFIG_HAVE_MEMORYLESS_NODES=y
    - LP: #1332063
  * [Config] CONFIG_HID_RMI=m
    - LP: #1305522

  [ Upstream Kernel Changes ]

  * Revert "offb: Add palette hack for little endian"
    - LP: #1333430
  * Revert "net: mvneta: fix usage as a module on RGMII configurations"
    - LP: #1333837
  * Revert "USB: serial: add usbid for dell wwan card to sierra.c"
    - LP: #1333837
  * Revert "macvlan : fix checksums error when we are in bridge mode"
    - LP: #1333838
  * serial: uart: add hw flow control support configuration
    - LP: #1328295
  * mm/numa: Remove BUG_ON() in __handle_mm_fault()
    - LP: #1323165
  * Tools: hv: Handle the case when the target file exists correctly
    - LP: #1306215
  * Documentation/devicetree/bindings: add documentation for the APM X-Gene
    SoC RTC DTS binding
    - LP: #1274305
  * drivers/rtc: add APM X-Gene SoC RTC driver
    - LP: #1274305
  * arm64: add APM X-Gene SoC RTC DTS entry
    - LP: #1274305
  * powerpc/perf: Add Power8 cache & TLB events
    - LP: #1328914
  * powerpc/perf: Configure BH...

Changed in linux (Ubuntu Trusty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.