From: Greg Kroah-Hartman Date: Sun, 5 Aug 2012 16:48:59 +0000 (-0700) Subject: 3.5-stable patches X-Git-Tag: v3.5.1~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb8586316e0cccae43fd116170f4d19f846ddbcb;p=thirdparty%2Fkernel%2Fstable-queue.git 3.5-stable patches added patches: posix_types.h-cleanup-stale-__nfdbits-and-related.patch --- diff --git a/queue-3.5/posix_types.h-cleanup-stale-__nfdbits-and-related.patch b/queue-3.5/posix_types.h-cleanup-stale-__nfdbits-and-related.patch new file mode 100644 index 00000000000..1f8e5c8c0a5 --- /dev/null +++ b/queue-3.5/posix_types.h-cleanup-stale-__nfdbits-and-related.patch @@ -0,0 +1,174 @@ +From 8ded2bbc1845e19c771eb55209aab166ef011243 Mon Sep 17 00:00:00 2001 +From: Josh Boyer +Date: Wed, 25 Jul 2012 10:40:34 -0400 +Subject: posix_types.h: Cleanup stale __NFDBITS and related + definitions + +From: Josh Boyer + +commit 8ded2bbc1845e19c771eb55209aab166ef011243 upstream. + +Recently, glibc made a change to suppress sign-conversion warnings in +FD_SET (glibc commit ceb9e56b3d1). This uncovered an issue with the +kernel's definition of __NFDBITS if applications #include + after including . A build failure would +be seen when passing the -Werror=sign-compare and -D_FORTIFY_SOURCE=2 +flags to gcc. + +It was suggested that the kernel should either match the glibc +definition of __NFDBITS or remove that entirely. The current in-kernel +uses of __NFDBITS can be replaced with BITS_PER_LONG, and there are no +uses of the related __FDELT and __FDMASK defines. Given that, we'll +continue the cleanup that was started with commit 8b3d1cda4f5f +("posix_types: Remove fd_set macros") and drop the remaining unused +macros. + +Additionally, linux/time.h has similar macros defined that expand to +nothing so we'll remove those at the same time. + +Reported-by: Jeff Law +Suggested-by: Linus Torvalds +Signed-off-by: Josh Boyer +[ .. and fix up whitespace as per akpm ] +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + arch/mips/kernel/kspd.c | 2 +- + fs/exec.c | 2 +- + fs/select.c | 10 +++++----- + include/linux/posix_types.h | 18 +++--------------- + include/linux/time.h | 8 -------- + kernel/exit.c | 2 +- + security/selinux/hooks.c | 2 +- + 7 files changed, 12 insertions(+), 32 deletions(-) + +--- a/arch/mips/kernel/kspd.c ++++ b/arch/mips/kernel/kspd.c +@@ -323,7 +323,7 @@ static void sp_cleanup(void) + fdt = files_fdtable(files); + for (;;) { + unsigned long set; +- i = j * __NFDBITS; ++ i = j * BITS_PER_LONG; + if (i >= fdt->max_fds) + break; + set = fdt->open_fds[j++]; +--- a/fs/exec.c ++++ b/fs/exec.c +@@ -1020,7 +1020,7 @@ static void flush_old_files(struct files + unsigned long set, i; + + j++; +- i = j * __NFDBITS; ++ i = j * BITS_PER_LONG; + fdt = files_fdtable(files); + if (i >= fdt->max_fds) + break; +--- a/fs/select.c ++++ b/fs/select.c +@@ -345,8 +345,8 @@ static int max_select_fd(unsigned long n + struct fdtable *fdt; + + /* handle last in-complete long-word first */ +- set = ~(~0UL << (n & (__NFDBITS-1))); +- n /= __NFDBITS; ++ set = ~(~0UL << (n & (BITS_PER_LONG-1))); ++ n /= BITS_PER_LONG; + fdt = files_fdtable(current->files); + open_fds = fdt->open_fds + n; + max = 0; +@@ -373,7 +373,7 @@ get_max: + max++; + set >>= 1; + } while (set); +- max += n * __NFDBITS; ++ max += n * BITS_PER_LONG; + } + + return max; +@@ -435,11 +435,11 @@ int do_select(int n, fd_set_bits *fds, s + in = *inp++; out = *outp++; ex = *exp++; + all_bits = in | out | ex; + if (all_bits == 0) { +- i += __NFDBITS; ++ i += BITS_PER_LONG; + continue; + } + +- for (j = 0; j < __NFDBITS; ++j, ++i, bit <<= 1) { ++ for (j = 0; j < BITS_PER_LONG; ++j, ++i, bit <<= 1) { + int fput_needed; + if (i >= n) + break; +--- a/include/linux/posix_types.h ++++ b/include/linux/posix_types.h +@@ -15,26 +15,14 @@ + */ + + /* +- * Those macros may have been defined in . But we always +- * use the ones here. ++ * This macro may have been defined in . But we always ++ * use the one here. + */ +-#undef __NFDBITS +-#define __NFDBITS (8 * sizeof(unsigned long)) +- + #undef __FD_SETSIZE + #define __FD_SETSIZE 1024 + +-#undef __FDSET_LONGS +-#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS) +- +-#undef __FDELT +-#define __FDELT(d) ((d) / __NFDBITS) +- +-#undef __FDMASK +-#define __FDMASK(d) (1UL << ((d) % __NFDBITS)) +- + typedef struct { +- unsigned long fds_bits [__FDSET_LONGS]; ++ unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))]; + } __kernel_fd_set; + + /* Type of a signal handler. */ +--- a/include/linux/time.h ++++ b/include/linux/time.h +@@ -257,14 +257,6 @@ static __always_inline void timespec_add + + #endif /* __KERNEL__ */ + +-#define NFDBITS __NFDBITS +- +-#define FD_SETSIZE __FD_SETSIZE +-#define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp) +-#define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp) +-#define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp) +-#define FD_ZERO(fdsetp) __FD_ZERO(fdsetp) +- + /* + * Names of the interval timers, and structure + * defining a timer setting: +--- a/kernel/exit.c ++++ b/kernel/exit.c +@@ -483,7 +483,7 @@ static void close_files(struct files_str + rcu_read_unlock(); + for (;;) { + unsigned long set; +- i = j * __NFDBITS; ++ i = j * BITS_PER_LONG; + if (i >= fdt->max_fds) + break; + set = fdt->open_fds[j++]; +--- a/security/selinux/hooks.c ++++ b/security/selinux/hooks.c +@@ -2129,7 +2129,7 @@ static inline void flush_unauthorized_fi + int fd; + + j++; +- i = j * __NFDBITS; ++ i = j * BITS_PER_LONG; + fdt = files_fdtable(files); + if (i >= fdt->max_fds) + break; diff --git a/queue-3.5/series b/queue-3.5/series index 22b58f65be8..31b9a4e9f82 100644 --- a/queue-3.5/series +++ b/queue-3.5/series @@ -82,3 +82,4 @@ drm-radeon-fix-hotplug-of-dp-to-dvi-hdmi-passive-adapters-v2.patch drm-radeon-on-hotplug-force-link-training-to-happen-v2.patch drm-radeon-fix-dpms-on-off-on-trinity-aruba-v2.patch drm-nouveau-init-vblank-requests-list.patch +posix_types.h-cleanup-stale-__nfdbits-and-related.patch