profile/ivi/kernel-x86-ivi.git
9 years agoNFS: pn533 : delete timer when polling is complete 58/33458/1 accepted/tizen_3.0_ivi accepted/tizen_ivi accepted/tizen_unified tizen_3.0 tizen_3.0.m2 accepted/tizen/3.0/ivi/20150120.102759 accepted/tizen/3.0/ivi/20161011.044304 accepted/tizen/ivi/20150120.050638 accepted/tizen/ivi/20160606.040828 accepted/tizen/unified/20170309.074707 accepted/tizen/unified/20170310.110236 submit/tizen/20150120.011017 submit/tizen/20160603.052607 submit/tizen_3.0_ivi/20150120.063505 submit/tizen_3.0_ivi/20161010.000003 submit/tizen_unified/20170308.100418 submit/tizen_unified/20170309.100417 submit/tizen_unified/20170310.104248 tizen_3.0_ivi_release
Ricardo Neri [Sat, 10 Jan 2015 03:30:25 +0000 (19:30 -0800)]
NFS: pn533 : delete timer when polling is complete

When polling is complete, the listen timer is not longer required.
Thus, we delete it. Otherwise, it might be possible that the
expiring timer runs its callback with the mod list already reset.
This would cause a division by zero in pn533_poll_next_mod. A
warning is issued to make sure that we are informed of the condition.

Also, cancel the timer in dep_link_down as it resets the poll mod
count.

Change-Id: Ia3590ec536deeaed3abf36d2c9abf065174d7e33
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
9 years agoMerge "packaging: make initrd creation a build option" into tizen tizen_3.0_ivi accepted/tizen/ivi/20141219.050210 submit/tizen/20141218.025211
Ricardo Neri [Thu, 18 Dec 2014 02:48:53 +0000 (18:48 -0800)]
Merge "packaging: make initrd creation a build option" into tizen

9 years agopackaging: make initrd creation a build option 01/32201/2
Mikko Ylinen [Tue, 16 Dec 2014 13:56:22 +0000 (15:56 +0200)]
packaging: make initrd creation a build option

initrd image is being generated but not used. Further, initrd
creation adds a dependency to dracut RPM in the image.

Use %bcond_with RPM macro to make initrd creation a build option
and turn it off by default.

Change-Id: I94de75108caab640b45caae5281f98d9ea0d400b
Bug-Tizen: TC-2178
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
9 years agoMerge "Add CONFIG_V2G_BRIDGE for X86 platform." into tizen accepted/tizen/ivi/20141217.060359 submit/tizen/20141217.035000
Ricardo Neri [Wed, 17 Dec 2014 03:34:45 +0000 (19:34 -0800)]
Merge "Add CONFIG_V2G_BRIDGE for X86 platform." into tizen

9 years agoAdd CONFIG_V2G_BRIDGE for X86 platform. 47/32147/1
Fang, Neo [Tue, 16 Dec 2014 17:22:32 +0000 (17:22 +0000)]
Add CONFIG_V2G_BRIDGE for X86 platform.

For early camera only supports intel graphics, and it will cause
compiling errors when building as arm platform. Add CONFIG_V2G_BRIDGE
and modify the related Kconfig and Makefile, and enable early camera
feature only in X86 platforms.

Change-Id: I09cb697fad19ec04975c600b449160fed31dc323
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoFix "unable to open rtc device (rtc0)" in Tizen IVI 12/32012/1
caoxinintel [Mon, 15 Dec 2014 06:42:52 +0000 (14:42 +0800)]
Fix "unable to open rtc device (rtc0)" in Tizen IVI

Compiling rtc-cmos.c as Module will make hctosys module be loaded
earlier than rtc-cmos. And at that time, rtc0 device is not ready.

Making rtc-cmos.c a kernel built-in module will solve this problem.

Change-Id: I90843576101c7c40a1c7a075d7c4b7e541453c71
Signed-off-by: caoxinintel <xinx.cao@intel.com>
9 years agoMerge "move i915 driver init to late_initcall" into tizen submit/tizen/20141216.003836
Ricardo Neri [Sun, 14 Dec 2014 00:14:59 +0000 (16:14 -0800)]
Merge "move i915 driver init to late_initcall" into tizen

9 years agomove i915 driver init to late_initcall 48/29848/2
Xing Wei [Tue, 4 Nov 2014 08:27:29 +0000 (16:27 +0800)]
move i915 driver init to late_initcall

we can make i915 and sata init run in parallel
to reduce kernel boot time about 260ms

Change-Id: Iba9cf56a1f5371f734f826f3271383bfb591e6a0
Signed-off-by: Xing Wei <xing.wei@intel.com>
9 years agoPromote the booting priority of scsi and ata. 52/31852/1
Fang, Neo [Thu, 11 Dec 2014 14:41:44 +0000 (14:41 +0000)]
Promote the booting priority of scsi and ata.

Promote the booting priority of scsi and ata. SATA disk loading will
waste many msecs, it will delay the whole Tizen system boot-up
procedure. Hence, promote the priority of sata/ata modules before tty
devices will improve kernel booting performance. From testing with
vtc1010, kernel-3.14.19, and kingston 120GB ssd, the original kernel
booting time is 1.314s; after tuning scsi/ata, the kernel booting time
is 948ms.

Change-Id: I8023ace1b1a30f09b5b76cac3be732b1c939f873
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoImplements v2g bridge module for early camera. 80/30780/2
Fang, Neo [Fri, 21 Nov 2014 16:34:39 +0000 (16:34 +0000)]
Implements v2g bridge module for early camera.

V2G bridge module detects and opens camera devices through V4L2
APIs, and mmaps the camera video on spriteC plane of Intel i915
driver. Currently, this module supports UVC cameras.
For the details, please check wiki page:
https://wiki.tizen.org/wiki/Early_Camera

Change-Id: I9e3a8a7f67f07182076c225ddfe4509130041319
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoCreate new DRM APIs for early camera. 47/30747/3
Fang, Neo [Fri, 21 Nov 2014 16:33:49 +0000 (16:33 +0000)]
Create new DRM APIs for early camera.

New drm APIs(drm_open_kernel, drm_release_kernel,
drm_open_helper_kernel, drm_mode_getresources_kernel)
are created for early camera.
For the original drm APIs drm_open, drm_release,
drm_open_helper and drm_mode_getresources are used by X. And early
camera should not open/release the drm resources exclusively. To
avoid the conflict issues with X and bypass drm_master, it is
necessary to create new APIs. For more details about early camera
feature, please visit the wiki page:
https://wiki.tizen.org/wiki/Early_Camera

Change-Id: I0ec645054e425c303dfb710f72ca9f873b54e051
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoExport drm APIs to support early camera. 10/30610/2
Fang, Neo [Fri, 21 Nov 2014 16:33:13 +0000 (16:33 +0000)]
Export drm APIs to support early camera.

To mmap camera videos to the spriteC plane(Intel i915), early camera
will bypass DRM_IOCTL to avoid drm_master conflicting issues, and
call drm APIs directly. Because drm APIs are for user space
framworks and applications, it is necessary to export them for
early camera module.
For the details of early camera, please check the wiki page:
https://wiki.tizen.org/wiki/Early_Camera

Change-Id: I26773dd5aa50f68011c92350f8af3ba88aade426
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoShare drm resources between X and early camera 09/30609/2
Fang, Neo [Fri, 21 Nov 2014 16:32:20 +0000 (16:32 +0000)]
Share drm resources between X and early camera

Early camera module will open drm before X, so when X starts up,
it should share the mapping address with early camera rather than
reopen it again. Normally, X will call drm_release when system
shutdown. At that time, early camera has already quitted and
released the drm resources. So it does not need to do resource
check in drm_release.

Change-Id: I692e111d76bf76c0a3faaac15f89e9ef8b261114
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoAdd a new v4l2 API to enumerate camera devs. 08/30608/2
Fang, Neo [Fri, 21 Nov 2014 16:31:28 +0000 (16:31 +0000)]
Add a new v4l2 API to enumerate camera devs.

To inform early camera module when camera devs are detected,
v4l2_enumerate_camera is implemented. For details, please
check the wiki page:
https://wiki.tizen.org/wiki/Early_Camera

Change-Id: I3cdf6a54ae179c366e22c7e7a6b51f03c0c10efd
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoExport V4L2 APIs to support early camera. 07/30607/2
Fang, Neo [Fri, 21 Nov 2014 16:30:34 +0000 (16:30 +0000)]
Export V4L2 APIs to support early camera.

To mmap camera videos to the spriteC plane(Intel i915), early camera
will bypass DRM_IOCTL to avoid drm_master conflicting issues, and
call drm APIs directly. Because drm APIs are for user space
framworks and applications, it is necessary to export them for early
camera module.
For the details of early camera feature, please check the wiki page:
https://wiki.tizen.org/wiki/Early_Camera

Change-Id: I955ca2c73e9c33c5987ac8f36c7c730545ce1333
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoBuild in V4L2 modules for x86_64 platforms. 79/30779/1
Fang, Neo [Tue, 25 Nov 2014 16:12:46 +0000 (16:12 +0000)]
Build in V4L2 modules for x86_64 platforms.

Early camera feature is a fundamental requirement in IVI system. This
feature requires the rear video showing on screen in less 2 seconds.
Therefore, to save the initializing time of camera devices, it's very
necessary to build in V4L2 modules into kernel. Modify
ivi_x86_64_defconfig for x86_64 platform support.

Change-Id: Ie6d99ed9bfa6eca31f584c29fd0aedc3033526c5
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agoBuild in V4L2 modules to support early camera. 06/30606/1
Fang, Neo [Fri, 21 Nov 2014 16:30:02 +0000 (16:30 +0000)]
Build in V4L2 modules to support early camera.

Early camera feature is a fundamental requirement in IVI system. This
feature requires the rear video showing on screen in less 2 seconds.
Therefore, to save the initializing time of camera devices, it's very
necessary to build in V4L2 modules into kernel.

Change-Id: I3ac61173ce7c7a362f37c86366c1507b3117c389
Signed-off-by: Fang, Neo <neo.fang@intel.com>
9 years agopackaging: update spec for ivi accepted/tizen_3.0.m14.3_ivi tizen_3.0.m14.3_ivi accepted/tizen/ivi/20140930.164320 submit/tizen_ivi/20140930.060855 submit/tizen_ivi/20140930.112233 submit/tizen_ivi/20140930.989898 submit/tizen_ivi/20140930.998877 tizen_3.0.m14.3_ivi_release
Ricardo Neri [Sun, 28 Sep 2014 00:29:47 +0000 (17:29 -0700)]
packaging: update spec for ivi

We now are basing our spec file on kernel-common (renamed as
kernel-x86-ivi.spec). Thus, update the profile and name
parameters.

Change-Id: I7e6689cfe650790523be1822f2c9614e50a91080
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
9 years agopackaging: base ivi spec on common
Ricardo Neri [Sun, 28 Sep 2014 00:25:02 +0000 (17:25 -0700)]
packaging: base ivi spec on common

kernel-common provides infrastructure to be adopted for kernels
downstream. Thus, base kernel-common.spec for ivi (i.e.,
rename as kernel-x86-ivi.spec.

Change-Id: Ie24b077912127a6cf593e8eb2738396e91cf8d24
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
9 years agoconfig: add configuration for x86_64
Stephane Desneux [Sat, 27 Sep 2014 00:18:05 +0000 (17:18 -0700)]
config: add configuration for x86_64

Change-Id: I1b5338c36bfb7a3a11dba22d05596d9078ebc148
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
9 years agoconfigure: ivi_x86_defconfig: remove double assign of CONFIG_CAN_CALC_BITTIMING
Ricardo Neri [Sat, 27 Sep 2014 00:23:25 +0000 (17:23 -0700)]
configure: ivi_x86_defconfig: remove double assign of CONFIG_CAN_CALC_BITTIMING

Even though CONFIG_CAN_CALC_BITTIMING is selected as 'y' the commented-out
line causes kbuild to generate a warning about double assignation.
Remove the warning.

Change-Id: Ibb3679e721e188754a2bbdf58d9f8534879740e7
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
9 years agoconfig: rename ivi_defconfig
Ricardo Neri [Sat, 27 Sep 2014 00:15:16 +0000 (17:15 -0700)]
config: rename ivi_defconfig

This change is needed for this config to work with the updated
packaging infrstructure.

Change-Id: I05c24466e7ae39e8bc1ea0e22c0e94be6e111ce9
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
9 years agoMerge remote-tracking branch 'remotes/common/tizen' into tizen
Ricardo Neri [Mon, 29 Sep 2014 18:23:18 +0000 (11:23 -0700)]
Merge remote-tracking branch 'remotes/common/tizen' into tizen

This update makes ivi be based on kernel-common tizen. The objective
is to leverage on the changes from kernel-common (e.g., unified
packaging) while preserving ivi-specific changes:

 * drm/i915 driver updates
 * kernel setting CAN bus bit-timing

9 years agobump to 3.14.19 sandbox/sdx/upstream upstream submit/tizen_common/20140918.111125 v3.14.19
Stephane Desneux [Thu, 18 Sep 2014 11:07:18 +0000 (13:07 +0200)]
bump to 3.14.19

Change-Id: I4c40d3e4de93993ca8fb1f9626d641d864329322
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agoSMACK: Fix wrong copy size
José Bollo [Mon, 15 Sep 2014 09:42:04 +0000 (11:42 +0200)]
SMACK: Fix wrong copy size

The function strncpy was copying an extra character 9
when i == len (what is possible via revoke interface).

Change-Id: Ic7452da05773e620a1d7bbc55e859c25a86c65f6
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
9 years agoperf tools: define _DEFAULT_SOURCE for glibc_2.20
Chanho Park [Fri, 12 Sep 2014 02:03:01 +0000 (11:03 +0900)]
perf tools: define _DEFAULT_SOURCE for glibc_2.20

_BSD_SOURCE was deprecated in favour of _DEFAULT_SOURCE since glibc
2.20[1]. To avoid build warning on glibc2.20, _DEFAULT_SOURCE should
also be defined.

[1]: https://sourceware.org/glibc/wiki/Release/2.20

Change-Id: I01a2849bb8642cbf5c875caf227ab05e6fa0fa41
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agoSmack: Fix setting label on successful file open
Marcin Niesluchowski [Tue, 19 Aug 2014 12:26:32 +0000 (14:26 +0200)]
Smack: Fix setting label on successful file open

While opening with CAP_MAC_OVERRIDE file label is not set.
Other calls may access it after CAP_MAC_OVERRIDE is dropped from process.

Change-Id: I937d070e1c0cb251f4a0dd3291efbc94be3ca548
Signed-off-by: Marcin Niesluchowski <m.niesluchow@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Origin: git://git.gitorious.org/smack-next/kernel.git# smack-for-3.18

9 years agoSmack: remove unneeded NULL-termination from securtity label
Konstantin Khlebnikov [Thu, 7 Aug 2014 16:52:49 +0000 (20:52 +0400)]
Smack: remove unneeded NULL-termination from securtity label

Values of extended attributes are stored as binary blobs. NULL-termination
of them isn't required. It just wastes disk space and confuses command-line
tools like getfattr because they have to print that zero byte at the end.

This patch removes terminating zero byte from initial security label in
smack_inode_init_security and cuts it out in function smack_inode_getsecurity
which is used by syscall getxattr. This change seems completely safe, because
function smk_parse_smack ignores everything after first zero byte.

Change-Id: I131879e36fc9e71b65857b46714ccd0e512fc83c
Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: handle zero-length security labels without panic
Konstantin Khlebnikov [Thu, 7 Aug 2014 16:52:43 +0000 (20:52 +0400)]
Smack: handle zero-length security labels without panic

Zero-length security labels are invalid but kernel should handle them.

This patch fixes kernel panic after setting zero-length security labels:

And after writing zero-length string into smackfs files syslog and onlycp:

The problem is caused by brain-damaged logic in function smk_parse_smack()
which takes pointer to buffer and its length but if length below or equal zero
it thinks that the buffer is zero-terminated. Unfortunately callers of this
function are widely used and proper fix requires serious refactoring.

Change-Id: I931735ccfaea4d8d2f0a98eacf8467f0a8359bc6
Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: fix behavior of smack_inode_listsecurity
Konstantin Khlebnikov [Thu, 7 Aug 2014 16:52:33 +0000 (20:52 +0400)]
Smack: fix behavior of smack_inode_listsecurity

Security operation ->inode_listsecurity is used for generating list of
available extended attributes for syscall listxattr. Currently it's used
only in nfs4 or if filesystem doesn't provide i_op->listxattr.

The list is the set of NULL-terminated names, one after the other.
This method must include zero byte at the and into result.

Also this function must return length even if string does not fit into
output buffer or it is NULL, see similar method in selinux and man listxattr.

Change-Id: I3ba4524fead6ef6ab0c93238fa8d422e6b155efb
Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoWarning in scanf string typing
Toralf Förster [Sun, 27 Apr 2014 17:33:34 +0000 (19:33 +0200)]
Warning in scanf string typing

This fixes a warning about the mismatch of types between
the declared unsigned and integer.

Change-Id: Ie7170fa22c1f641b2990721b44059d399c92ffe6
Signed-off-by: Toralf Förster <toralf.foerster@gmx.de>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: Verify read access on file open - v3
Casey Schaufler [Mon, 21 Apr 2014 18:10:26 +0000 (11:10 -0700)]
Smack: Verify read access on file open - v3

Smack believes that many of the operatons that can
be performed on an open file descriptor are read operations.
The fstat and lseek system calls are examples.
An implication of this is that files shouldn't be open
if the task doesn't have read access even if it has
write access and the file is being opened write only.

Targeted for git://git.gitorious.org/smack-next/kernel.git

Change-Id: Iefff38549f9f2e242fd21fce42db067c4c4d8a12
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: bidirectional UDS connect check
Casey Schaufler [Thu, 10 Apr 2014 23:37:08 +0000 (16:37 -0700)]
Smack: bidirectional UDS connect check

Smack IPC policy requires that the sender have write access
to the receiver. UDS streams don't do per-packet checks. The
only check is done at connect time. The existing code checks
if the connecting process can write to the other, but not the
other way around. This change adds a check that the other end
can write to the connecting process.

Targeted for git://git.gitorious.org/smack-next/kernel.git

Change-Id: I0dd9124261cb66a364322ed88e9dcb3213157cb6
Signed-off-by: Casey Schuafler <casey@schaufler-ca.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: Correctly remove SMACK64TRANSMUTE attribute
Casey Schaufler [Thu, 10 Apr 2014 23:35:36 +0000 (16:35 -0700)]
Smack: Correctly remove SMACK64TRANSMUTE attribute

Sam Henderson points out that removing the SMACK64TRANSMUTE
attribute from a directory does not result in the directory
transmuting. This is because the inode flag indicating that
the directory is transmuting isn't cleared. The fix is a tad
less than trivial because smk_task and smk_mmap should have
been broken out, too.

Targeted for git://git.gitorious.org/smack-next/kernel.git

Change-Id: Iae25080bfd0ec247391c997a59f3e2327423e33d
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agobugfix patch for SMACK
Pankaj Kumar [Fri, 13 Dec 2013 09:42:22 +0000 (15:12 +0530)]
bugfix patch for SMACK

1. In order to remove any SMACK extended attribute from a file, a user
should have CAP_MAC_ADMIN capability. But user without having this
capability is able to remove SMACK64MMAP security attribute.

2. While validating size and value of smack extended attribute in
smack_inode_setsecurity hook, wrong error code is returned.

Change-Id: Ib4b290150f4a003733f76cbb7ccc25d228310ecb
Signed-off-by: Pankaj Kumar <pamkaj.k2@samsung.com>
Signed-off-by: Himanshu Shukla <himanshu.sh@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: adds smackfs/ptrace interface
Lukasz Pawelczyk [Tue, 11 Mar 2014 16:07:06 +0000 (17:07 +0100)]
Smack: adds smackfs/ptrace interface

This allows to limit ptrace beyond the regular smack access rules.
It adds a smackfs/ptrace interface that allows smack to be configured
to require equal smack labels for PTRACE_MODE_ATTACH access.
See the changes in Documentation/security/Smack.txt below for details.

Change-Id: If5d887a86b8d05ac46c82e1e7e123b86a5d62ddb
Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: unify all ptrace accesses in the smack
Lukasz Pawelczyk [Tue, 11 Mar 2014 16:07:05 +0000 (17:07 +0100)]
Smack: unify all ptrace accesses in the smack

The decision whether we can trace a process is made in the following
functions:
smack_ptrace_traceme()
smack_ptrace_access_check()
smack_bprm_set_creds() (in case the proces is traced)

This patch unifies all those decisions by introducing one function that
checks whether ptrace is allowed: smk_ptrace_rule_check().

This makes possible to actually trace with TRACEME where first the
TRACEME itself must be allowed and then exec() on a traced process.

Additional bugs fixed:
- The decision is made according to the mode parameter that is now correctly
  translated from PTRACE_MODE_* to MAY_* instead of being treated 1:1.
  PTRACE_MODE_READ requires MAY_READ.
  PTRACE_MODE_ATTACH requires MAY_READWRITE.
- Add a smack audit log in case of exec() refused by bprm_set_creds().
- Honor the PTRACE_MODE_NOAUDIT flag and don't put smack audit info
  in case this flag is set.

Change-Id: I14d6de0c11ce190e53788a0b4fc096471506c736
Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoSmack: fix the subject/object order in smack_ptrace_traceme()
Lukasz Pawelczyk [Tue, 11 Mar 2014 16:07:04 +0000 (17:07 +0100)]
Smack: fix the subject/object order in smack_ptrace_traceme()

The order of subject/object is currently reversed in
smack_ptrace_traceme(). It is currently checked if the tracee has a
capability to trace tracer and according to this rule a decision is made
whether the tracer will be allowed to trace tracee.

Change-Id: I70afd604b29e5d6515d042ab648b0513c1f77d7a
Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoMinor improvement of 'smack_sb_kern_mount'
José Bollo [Wed, 8 Jan 2014 14:53:05 +0000 (15:53 +0100)]
Minor improvement of 'smack_sb_kern_mount'

Fix a possible memory access fault when transmute is true and isp is NULL.

Change-Id: I29708ce54b96b34b440cf349e2b1891ea8d9d34f
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agosmack: fix key permission verification
Dmitry Kasatkin [Fri, 14 Mar 2014 17:44:49 +0000 (17:44 +0000)]
smack: fix key permission verification

For any keyring access type SMACK always used MAY_READWRITE access check.
It prevents reading the key with label "_", which should be allowed for anyone.

This patch changes default access check to MAY_READ and use MAY_READWRITE in only
appropriate cases.

Change-Id: Ie357956730df93058198e2df13ef307ce4e8f675
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
9 years agoKEYS: Move the flags representing required permission to linux/key.h
David Howells [Fri, 14 Mar 2014 17:44:49 +0000 (17:44 +0000)]
KEYS: Move the flags representing required permission to linux/key.h

Move the flags representing required permission to linux/key.h as the perm
parameter of security_key_permission() is in terms of them - and not the
permissions mask flags used in key->perm.

Whilst we're at it:

 (1) Rename them to be KEY_NEED_xxx rather than KEY_xxx to avoid collisions
     with symbols in uapi/linux/input.h.

 (2) Don't use key_perm_t for a mask of required permissions, but rather limit
     it to the permissions mask attached to the key and arguments related
     directly to that.

Change-Id: Id9de84f93e5dd668a3b8ba00fc2440c6d6c6f988
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Origin: upstream

9 years agopackaging: fix the "devel" package requirements
Manuel Bachmann [Wed, 10 Sep 2014 17:01:11 +0000 (19:01 +0200)]
packaging: fix the "devel" package requirements

"kernel-common-$arch-default-devel" was checking for
"kernel-common" instead of "kernel-common-$arch-default",
which means it was never installable without forcing.
Fixing this.

Change-Id: I4435b19634289840c3b8ca74ea7ab36c867ab357
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
9 years agoRevert "x86/efi: Correct EFI boot stub use of code32_start"
Philippe Coval [Fri, 22 Aug 2014 08:09:19 +0000 (10:09 +0200)]
Revert "x86/efi: Correct EFI boot stub use of code32_start"

This reverts commit 45ada9fae6d836aa8e3be5302d7aeb50c44e0629.

With this change in , nexcom's vtc1010 does not boot anynore
even rebased on latest version v3.14.17
and with latest firmware :
ftp://ftp.nexcom.com/pub/BIOS/VTC1010/x86_32bit/MV11A109.rom
( md5=f5ccb5284ca5bd8668fa1031067dad27 )

The bug is now tracked upstream.

Bug: https://bugzilla.kernel.org/show_bug.cgi?id=82891
Change-Id: I82bb1227dcbcbfe1371d685d241e985a6e58ddf3
Bug-Tizen: TC-1513/part

9 years agoignore: defconfig
Philippe Coval [Thu, 21 Aug 2014 15:10:47 +0000 (17:10 +0200)]
ignore: defconfig

Change-Id: I6d41a551a09dc80663dd48579e43dadacf2d6f80
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agotizen: support fat32 as builtin feature
Philippe Coval [Thu, 21 Aug 2014 13:47:19 +0000 (15:47 +0200)]
tizen: support fat32 as builtin feature

Needed to mount /boot partition used for ARM or EFI

Change-Id: I7f9871931f9dbeab1682d3454ebd484634f8e374
Bug-Tizen: TC-1513
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agopackaging: cleanup release set to 0
Philippe Coval [Wed, 13 Aug 2014 13:26:05 +0000 (15:26 +0200)]
packaging: cleanup release set to 0

Change-Id: I0e9ace01f9e6824dfa2e1860b041679f2a4fbc7f
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agopackaging: support efi using setup-scripts
Philippe Coval [Tue, 12 Aug 2014 08:06:00 +0000 (10:06 +0200)]
packaging: support efi using setup-scripts

This change was adapted from tizen's kernel-x86-ivi
It was tested fine on same version (v3.14.2)

Change-Id: I39733bf4ffc54efb9389b15345e604a99f69ccd0
Bug-Tizen: TC-1513
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agopackaging: tizen: dont ship debug files
Philippe Coval [Tue, 12 Aug 2014 08:03:53 +0000 (10:03 +0200)]
packaging: tizen: dont ship debug files

Will save you time on rpm build

Change-Id: I2b73827cc0a9446b41bb29d6a229ede37aa144f3
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agopackaging: tizen: arm: install device trees
Philippe Coval [Wed, 6 Aug 2014 08:36:53 +0000 (10:36 +0200)]
packaging: tizen: arm: install device trees

Change-Id: Ie18356c51da5681ae760d33dbbc7b4f4342f38d8
Bug-Tizen: TC-1464
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agopackaging: more genericity for downstream platform maintenance
Philippe Coval [Fri, 1 Aug 2014 13:13:03 +0000 (15:13 +0200)]
packaging: more genericity for downstream platform maintenance

Change-Id: I61629c361a163b0abb34b74d1a0a5093cbe060ab
Bug-Tizen: TC-1464
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agoredefine default platform
Stephane Desneux [Thu, 31 Jul 2014 15:04:25 +0000 (17:04 +0200)]
redefine default platform

Change-Id: I7c159baeb091440acf7ab8232cdb9569072b38ef
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agochange name of binary rpms for kernel
Stephane Desneux [Wed, 30 Jul 2014 15:21:00 +0000 (17:21 +0200)]
change name of binary rpms for kernel

Support multiple profiles, platforms etc. for naming the output rpms

Change-Id: If3ecd19473fb1c115d892cfc52016602cf271a9d
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agoBump kernel to 3.14.14 (LTS)
Stephane Desneux [Wed, 30 Jul 2014 08:31:17 +0000 (10:31 +0200)]
Bump kernel to 3.14.14 (LTS)

Change-Id: I3b504688ddc913995382751a46c5800386d2567b
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agotizen: arm: set hostname to common-box
Philippe Coval [Tue, 29 Jul 2014 09:02:02 +0000 (11:02 +0200)]
tizen: arm: set hostname to common-box

Bug-Tizen: TC-1234
Change-Id: I2d9f7e2644869a9c876b6765c025f1d604d787ee
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agotizen: arm: enable SMACK (security)
Philippe Coval [Tue, 29 Jul 2014 08:51:17 +0000 (10:51 +0200)]
tizen: arm: enable SMACK (security)

Bug-Tizen: TC-1234
Change-Id: Ibd7a7e43f5ea2bc8dfa6ea24d39f84526ccd7555
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agoadd support for ebtables
Dariusz Michaluk [Mon, 26 May 2014 12:30:29 +0000 (14:30 +0200)]
add support for ebtables

The ebtables program is a filtering tool for a Linux-based bridging firewall.

Change-Id: I0892d969a3a2cddb74e33c88b5b545b8362017df
Signed-off-by: Dariusz Michaluk <d.michaluk@samsung.com>
9 years agoadd support for libvirt
Dariusz Michaluk [Fri, 23 May 2014 09:31:52 +0000 (11:31 +0200)]
add support for libvirt

Libvirt is a toolkit to interact with LXC(Linux kernel containers).
Current libvirt-lxc driver need some additional kernel features:
1. CFS Scheduler
        CONFIG_CFS_BANDWIDTH
2. VLAN interface
        CONFIG_VETH

Change-Id: I83a70e985924055639c8a2086ec3ea447958171b
Signed-off-by: Dariusz Michaluk <d.michaluk@samsung.com>
9 years agopackaging: support armv7l building for Tizen:Common
Philippe Coval [Thu, 10 Jul 2014 18:07:28 +0000 (20:07 +0200)]
packaging: support armv7l building for Tizen:Common

Bug-Tizen: TC-1234
Change-Id: Iba7791682442baa4b41a7daf10949de4baf0a4fa
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agotizen: arm: add default arm configuration
Philippe Coval [Thu, 10 Jul 2014 18:23:56 +0000 (20:23 +0200)]
tizen: arm: add default arm configuration

Copied vexpress_defconfig from version 3.14.4

Change-Id: I0e2f0f061fe7f81a2b1aed6157d683c053d6d814
Bug-Tizen: TC-1234
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
9 years agocommon_{x86_64|x86}_defconfig: change default hostname to 'common_box'
gvancuts [Mon, 30 Jun 2014 15:43:04 +0000 (17:43 +0200)]
common_{x86_64|x86}_defconfig: change default hostname to 'common_box'

Tizen Bug: TC-1346

Change-Id: Id4dd1ae75a5f1d2c41d1b424f950d4a24e2dfd16
Signed-off-by: gvancuts <geoffroy.vancutsem@intel.com>
9 years agoenable Fusion SPI in kernel (not as a module) for VMWare
Stephane Desneux [Fri, 16 May 2014 13:57:13 +0000 (15:57 +0200)]
enable Fusion SPI in kernel (not as a module) for VMWare

Change-Id: I1987a5e1531d55c2d262b53133818f76a902f024
Bug-Tizen: TC-2
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agocommon_x86_64_defconfig: add VMWGFX as built-in
gvancuts [Fri, 16 May 2014 22:44:26 +0000 (00:44 +0200)]
common_x86_64_defconfig: add VMWGFX as built-in
common_x86_defconfig: add VMWGFX as built-in

Fix Tizen JIRA: TC-3

Change-Id: I6a6c33ae4b16fc6046a4fed42fad391f77d25d2f
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
9 years agobump to 3.14.4, update configuration with new options
Stephane Desneux [Wed, 14 May 2014 16:55:04 +0000 (18:55 +0200)]
bump to 3.14.4, update configuration with new options

Change-Id: I86cee79518a33c864bd8c9ba2b891c281f614be1
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agomigrate to Tizen:Common; bump to 3.14.1
Stephane Desneux [Sun, 20 Apr 2014 22:38:32 +0000 (00:38 +0200)]
migrate to Tizen:Common; bump to 3.14.1

Change-Id: I3fcde3a0b969d1a01b999e1358c6d0e312c6947d
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agopackaging: fix kernel version
Stephane Desneux [Fri, 11 Apr 2014 07:22:43 +0000 (09:22 +0200)]
packaging: fix kernel version

A tag v3.14.0 has been added to make the package version match with
internal kernel version. Otherwise, the kernel is unable to find its
modules in /lib/modules/<version>

Change-Id: I2cf04cc47a97dd2632743d1972cac665e6e1319b
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agopackaging for linux 3.14
Stephane Desneux [Thu, 10 Apr 2014 16:10:24 +0000 (18:10 +0200)]
packaging for linux 3.14

Change-Id: I946911e78c8f2a2f12b67938ec54d4e621a5c8a0
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agoSMACK: Fix handling value==NULL in post setxattr
José Bollo [Thu, 3 Apr 2014 07:51:07 +0000 (09:51 +0200)]
SMACK: Fix handling value==NULL in post setxattr

The function `smack_inode_post_setxattr` is called each
time that a setxattr is done, for any value of name.
The kernel allow to put value==NULL when size==0
to set an empty attribute value. The systematic
call to smk_import_entry was causing the dereference
of a NULL pointer hence a KERNEL PANIC!

The problem can be produced easily by issuing the
command `setfattr -n user.data file` under bash prompt
when SMACK is active.

Moving the call to smk_import_entry as proposed by this
patch is correcting the behaviour because the function
smack_inode_post_setxattr is called for the SMACK's
attributes only if the function smack_inode_setxattr validated
the value and its size (what will not be the case when size==0).

It also has a benefical effect to not fill the smack hash
with garbage values coming from any extended attribute
write.

Change-Id: Iaf0039c2be9bccb6cee11c24a3b44d209101fe47
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agoSmack: Cgroup filesystem access
Casey Schaufler [Thu, 21 Nov 2013 08:55:10 +0000 (10:55 +0200)]
Smack: Cgroup filesystem access

The cgroup filesystems are not mounted using conventional
mechanisms. This prevents the use of mount options to
set Smack attributes. This patch makes the behavior
of cgroup filesystems compatable with the way systemd
uses them.

Change-Id: I1e0429f133db9e14117dc754d682dec08221354c
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Stephane Desneux <stephane.desneux@open.eurogiciel.org>
9 years agoLinux 3.14.19 sandbox/ricardon/upstream
Greg Kroah-Hartman [Wed, 17 Sep 2014 16:21:23 +0000 (09:21 -0700)]
Linux 3.14.19

9 years agoKEYS: Fix termination condition in assoc array garbage collection
David Howells [Wed, 10 Sep 2014 21:22:00 +0000 (22:22 +0100)]
KEYS: Fix termination condition in assoc array garbage collection

commit 95389b08d93d5c06ec63ab49bd732b0069b7c35e upstream.

This fixes CVE-2014-3631.

It is possible for an associative array to end up with a shortcut node at the
root of the tree if there are more than fan-out leaves in the tree, but they
all crowd into the same slot in the lowest level (ie. they all have the same
first nibble of their index keys).

When assoc_array_gc() returns back up the tree after scanning some leaves, it
can fall off of the root and crash because it assumes that the back pointer
from a shortcut (after label ascend_old_tree) must point to a normal node -
which isn't true of a shortcut node at the root.

Should we find we're ascending rootwards over a shortcut, we should check to
see if the backpointer is zero - and if it is, we have completed the scan.

This particular bug cannot occur if the root node is not a shortcut - ie. if
you have fewer than 17 keys in a keyring or if you have at least two keys that
sit into separate slots (eg. a keyring and a non keyring).

This can be reproduced by:

ring=`keyctl newring bar @s`
for ((i=1; i<=18; i++)); do last_key=`keyctl newring foo$i $ring`; done
keyctl timeout $last_key 2

Doing this:

echo 3 >/proc/sys/kernel/keys/gc_delay

first will speed things up.

If we do fall off of the top of the tree, we get the following oops:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
IP: [<ffffffff8136cea7>] assoc_array_gc+0x2f7/0x540
PGD dae15067 PUD cfc24067 PMD 0
Oops: 0000 [#1] SMP
Modules linked in: xt_nat xt_mark nf_conntrack_netbios_ns nf_conntrack_broadcast ip6t_rpfilter ip6t_REJECT xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_ni
CPU: 0 PID: 26011 Comm: kworker/0:1 Not tainted 3.14.9-200.fc20.x86_64 #1
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Workqueue: events key_garbage_collector
task: ffff8800918bd580 ti: ffff8800aac14000 task.ti: ffff8800aac14000
RIP: 0010:[<ffffffff8136cea7>] [<ffffffff8136cea7>] assoc_array_gc+0x2f7/0x540
RSP: 0018:ffff8800aac15d40  EFLAGS: 00010206
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff8800aaecacc0
RDX: ffff8800daecf440 RSI: 0000000000000001 RDI: ffff8800aadc2bc0
RBP: ffff8800aac15da8 R08: 0000000000000001 R09: 0000000000000003
R10: ffffffff8136ccc7 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000070 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff88011fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000018 CR3: 00000000db10d000 CR4: 00000000000006f0
Stack:
 ffff8800aac15d50 0000000000000011 ffff8800aac15db8 ffffffff812e2a70
 ffff880091a00600 0000000000000000 ffff8800aadc2bc3 00000000cd42c987
 ffff88003702df20 ffff88003702dfa0 0000000053b65c09 ffff8800aac15fd8
Call Trace:
 [<ffffffff812e2a70>] ? keyring_detect_cycle_iterator+0x30/0x30
 [<ffffffff812e3e75>] keyring_gc+0x75/0x80
 [<ffffffff812e1424>] key_garbage_collector+0x154/0x3c0
 [<ffffffff810a67b6>] process_one_work+0x176/0x430
 [<ffffffff810a744b>] worker_thread+0x11b/0x3a0
 [<ffffffff810a7330>] ? rescuer_thread+0x3b0/0x3b0
 [<ffffffff810ae1a8>] kthread+0xd8/0xf0
 [<ffffffff810ae0d0>] ? insert_kthread_work+0x40/0x40
 [<ffffffff816ffb7c>] ret_from_fork+0x7c/0xb0
 [<ffffffff810ae0d0>] ? insert_kthread_work+0x40/0x40
Code: 08 4c 8b 22 0f 84 bf 00 00 00 41 83 c7 01 49 83 e4 fc 41 83 ff 0f 4c 89 65 c0 0f 8f 5a fe ff ff 48 8b 45 c0 4d 63 cf 49 83 c1 02 <4e> 8b 34 c8 4d 85 f6 0f 84 be 00 00 00 41 f6 c6 01 0f 84 92
RIP  [<ffffffff8136cea7>] assoc_array_gc+0x2f7/0x540
 RSP <ffff8800aac15d40>
CR2: 0000000000000018
---[ end trace 1129028a088c0cbd ]---

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoKEYS: Fix use-after-free in assoc_array_gc()
David Howells [Tue, 2 Sep 2014 12:52:20 +0000 (13:52 +0100)]
KEYS: Fix use-after-free in assoc_array_gc()

commit 27419604f51a97d497853f14142c1059d46eb597 upstream.

An edit script should be considered inaccessible by a function once it has
called assoc_array_apply_edit() or assoc_array_cancel_edit().

However, assoc_array_gc() is accessing the edit script just after the
gc_complete: label.

Reported-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
cc: shemming@brocade.com
cc: paulmck@linux.vnet.ibm.com
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agolibceph: gracefully handle large reply messages from the mon
Sage Weil [Mon, 4 Aug 2014 14:01:54 +0000 (07:01 -0700)]
libceph: gracefully handle large reply messages from the mon

commit 73c3d4812b4c755efeca0140f606f83772a39ce4 upstream.

We preallocate a few of the message types we get back from the mon.  If we
get a larger message than we are expecting, fall back to trying to allocate
a new one instead of blindly using the one we have.

Signed-off-by: Sage Weil <sage@redhat.com>
Reviewed-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agovfs: fix bad hashing of dentries
Linus Torvalds [Sat, 13 Sep 2014 18:30:10 +0000 (11:30 -0700)]
vfs: fix bad hashing of dentries

commit 99d263d4c5b2f541dfacb5391e22e8c91ea982a6 upstream.

Josef Bacik found a performance regression between 3.2 and 3.10 and
narrowed it down to commit bfcfaa77bdf0 ("vfs: use 'unsigned long'
accesses for dcache name comparison and hashing"). He reports:

 "The test case is essentially

      for (i = 0; i < 1000000; i++)
              mkdir("a$i");

  On xfs on a fio card this goes at about 20k dir/sec with 3.2, and 12k
  dir/sec with 3.10.  This is because we spend waaaaay more time in
  __d_lookup on 3.10 than in 3.2.

  The new hashing function for strings is suboptimal for <
  sizeof(unsigned long) string names (and hell even > sizeof(unsigned
  long) string names that I've tested).  I broke out the old hashing
  function and the new one into a userspace helper to get real numbers
  and this is what I'm getting:

      Old hash table had 1000000 entries, 0 dupes, 0 max dupes
      New hash table had 12628 entries, 987372 dupes, 900 max dupes
      We had 11400 buckets with a p50 of 30 dupes, p90 of 240 dupes, p99 of 567 dupes for the new hash

  My test does the hash, and then does the d_hash into a integer pointer
  array the same size as the dentry hash table on my system, and then
  just increments the value at the address we got to see how many
  entries we overlap with.

  As you can see the old hash function ended up with all 1 million
  entries in their own bucket, whereas the new one they are only
  distributed among ~12.5k buckets, which is why we're using so much
  more CPU in __d_lookup".

The reason for this hash regression is two-fold:

 - On 64-bit architectures the down-mixing of the original 64-bit
   word-at-a-time hash into the final 32-bit hash value is very
   simplistic and suboptimal, and just adds the two 32-bit parts
   together.

   In particular, because there is no bit shuffling and the mixing
   boundary is also a byte boundary, similar character patterns in the
   low and high word easily end up just canceling each other out.

 - the old byte-at-a-time hash mixed each byte into the final hash as it
   hashed the path component name, resulting in the low bits of the hash
   generally being a good source of hash data.  That is not true for the
   word-at-a-time case, and the hash data is distributed among all the
   bits.

The fix is the same in both cases: do a better job of mixing the bits up
and using as much of the hash data as possible.  We already have the
"hash_32|64()" functions to do that.

Reported-by: Josef Bacik <jbacik@fb.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chris Mason <clm@fb.com>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agodrm/nouveau: Bump version from 1.1.1 to 1.1.2
Mario Kleiner [Wed, 6 Aug 2014 04:09:44 +0000 (06:09 +0200)]
drm/nouveau: Bump version from 1.1.1 to 1.1.2

commit 7820e5eef0faa4a5e10834296680827f7ce78a89 upstream.

Linux 3.16 fixed multiple bugs in kms pageflip completion events
and timestamping, which were originally introduced in Linux 3.13.

These fixes have been backported to all stable kernels since 3.13.

However, the userspace nouveau-ddx needs to be aware if it is
running on a kernel on which these bugs are fixed, or not.

Bump the patchlevel of the drm driver version to signal this,
so backporting this patch to stable 3.13+ kernels will give the
ddx the required info.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoIB/srp: Fix deadlock between host removal and multipathd
Bart Van Assche [Wed, 9 Jul 2014 13:57:26 +0000 (15:57 +0200)]
IB/srp: Fix deadlock between host removal and multipathd

commit bcc05910359183b431da92713e98eed478edf83a upstream.

If scsi_remove_host() is invoked after a SCSI device has been blocked,
if the fast_io_fail_tmo or dev_loss_tmo work gets scheduled on the
workqueue executing srp_remove_work() and if an I/O request is
scheduled after the SCSI device had been blocked by e.g. multipathd
then the following deadlock can occur:

    kworker/6:1     D ffff880831f3c460     0   195      2 0x00000000
    Call Trace:
     [<ffffffff814aafd9>] schedule+0x29/0x70
     [<ffffffff814aa0ef>] schedule_timeout+0x10f/0x2a0
     [<ffffffff8105af6f>] msleep+0x2f/0x40
     [<ffffffff8123b0ae>] __blk_drain_queue+0x4e/0x180
     [<ffffffff8123d2d5>] blk_cleanup_queue+0x225/0x230
     [<ffffffffa0010732>] __scsi_remove_device+0x62/0xe0 [scsi_mod]
     [<ffffffffa000ed2f>] scsi_forget_host+0x6f/0x80 [scsi_mod]
     [<ffffffffa0002eba>] scsi_remove_host+0x7a/0x130 [scsi_mod]
     [<ffffffffa07cf5c5>] srp_remove_work+0x95/0x180 [ib_srp]
     [<ffffffff8106d7aa>] process_one_work+0x1ea/0x6c0
     [<ffffffff8106dd9b>] worker_thread+0x11b/0x3a0
     [<ffffffff810758bd>] kthread+0xed/0x110
     [<ffffffff814b972c>] ret_from_fork+0x7c/0xb0
    multipathd      D ffff880096acc460     0  5340      1 0x00000000
    Call Trace:
     [<ffffffff814aafd9>] schedule+0x29/0x70
     [<ffffffff814aa0ef>] schedule_timeout+0x10f/0x2a0
     [<ffffffff814ab79b>] io_schedule_timeout+0x9b/0xf0
     [<ffffffff814abe1c>] wait_for_completion_io_timeout+0xdc/0x110
     [<ffffffff81244b9b>] blk_execute_rq+0x9b/0x100
     [<ffffffff8124f665>] sg_io+0x1a5/0x450
     [<ffffffff8124fd21>] scsi_cmd_ioctl+0x2a1/0x430
     [<ffffffff8124fef2>] scsi_cmd_blk_ioctl+0x42/0x50
     [<ffffffffa00ec97e>] sd_ioctl+0xbe/0x140 [sd_mod]
     [<ffffffff8124bd04>] blkdev_ioctl+0x234/0x840
     [<ffffffff811cb491>] block_ioctl+0x41/0x50
     [<ffffffff811a0df0>] do_vfs_ioctl+0x300/0x520
     [<ffffffff811a1051>] SyS_ioctl+0x41/0x80
     [<ffffffff814b9962>] tracesys+0xd0/0xd5

Fix this by scheduling removal work on another workqueue than the
transport layer timers.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Reviewed-by: David Dillow <dave@thedillows.org>
Cc: Sebastian Parschauer <sebastian.riemer@profitbricks.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agomtd: nand: omap: Fix 1-bit Hamming code scheme, omap_calculate_ecc()
Roger Quadros [Mon, 25 Aug 2014 23:15:33 +0000 (16:15 -0700)]
mtd: nand: omap: Fix 1-bit Hamming code scheme, omap_calculate_ecc()

commit 40ddbf5069bd4e11447c0088fc75318e0aac53f0 upstream.

commit 65b97cf6b8de introduced in v3.7 caused a regression
by using a reversed CS_MASK thus causing omap_calculate_ecc to
always fail. As the NAND base driver never checks for .calculate()'s
return value, the zeroed ECC values are used as is without showing
any error to the user. However, this won't work and the NAND device
won't be guarded by any error code.

Fix the issue by using the correct mask.

Code was tested on omap3beagle using the following procedure
- flash the primary bootloader (MLO) from the kernel to the first
NAND partition using nandwrite.
- boot the board from NAND. This utilizes OMAP ROM loader that
relies on 1-bit Hamming code ECC.

Fixes: 65b97cf6b8de (mtd: nand: omap2: handle nand on gpmc)

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agomtd/ftl: fix the double free of the buffers allocated in build_maps()
Kevin Hao [Thu, 3 Jul 2014 02:35:26 +0000 (10:35 +0800)]
mtd/ftl: fix the double free of the buffers allocated in build_maps()

commit a152056c912db82860a8b4c23d0bd3a5aa89e363 upstream.

I got the following panic on my fsl p5020ds board.

  Unable to handle kernel paging request for data at address 0x7375627379737465
  Faulting instruction address: 0xc000000000100778
  Oops: Kernel access of bad area, sig: 11 [#1]
  SMP NR_CPUS=24 CoreNet Generic
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.15.0-next-20140613 #145
  task: c0000000fe080000 ti: c0000000fe088000 task.ti: c0000000fe088000
  NIP: c000000000100778 LR: c00000000010073c CTR: 0000000000000000
  REGS: c0000000fe08aa00 TRAP: 0300   Not tainted  (3.15.0-next-20140613)
  MSR: 0000000080029000 <CE,EE,ME>  CR: 24ad2e24  XER: 00000000
  DEAR: 7375627379737465 ESR: 0000000000000000 SOFTE: 1
  GPR00: c0000000000c99b0 c0000000fe08ac80 c0000000009598e0 c0000000fe001d80
  GPR04: 00000000000000d0 0000000000000913 c000000007902b20 0000000000000000
  GPR08: c0000000feaae888 0000000000000000 0000000007091000 0000000000200200
  GPR12: 0000000028ad2e28 c00000000fff4000 c0000000007abe08 0000000000000000
  GPR16: c0000000007ab160 c0000000007aaf98 c00000000060ba68 c0000000007abda8
  GPR20: c0000000007abde8 c0000000feaea6f8 c0000000feaea708 c0000000007abd10
  GPR24: c000000000989370 c0000000008c6228 00000000000041ed c0000000fe00a400
  GPR28: c00000000017c1cc 00000000000000d0 7375627379737465 c0000000fe001d80
  NIP [c000000000100778] .__kmalloc_track_caller+0x70/0x168
  LR [c00000000010073c] .__kmalloc_track_caller+0x34/0x168
  Call Trace:
  [c0000000fe08ac80] [c00000000087e6b8] uevent_sock_list+0x0/0x10 (unreliable)
  [c0000000fe08ad20] [c0000000000c99b0] .kstrdup+0x44/0x90
  [c0000000fe08adc0] [c00000000017c1cc] .__kernfs_new_node+0x4c/0x130
  [c0000000fe08ae70] [c00000000017d7e4] .kernfs_new_node+0x2c/0x64
  [c0000000fe08aef0] [c00000000017db00] .kernfs_create_dir_ns+0x34/0xc8
  [c0000000fe08af80] [c00000000018067c] .sysfs_create_dir_ns+0x58/0xcc
  [c0000000fe08b010] [c0000000002c711c] .kobject_add_internal+0xc8/0x384
  [c0000000fe08b0b0] [c0000000002c7644] .kobject_add+0x64/0xc8
  [c0000000fe08b140] [c000000000355ebc] .device_add+0x11c/0x654
  [c0000000fe08b200] [c0000000002b5988] .add_disk+0x20c/0x4b4
  [c0000000fe08b2c0] [c0000000003a21d4] .add_mtd_blktrans_dev+0x340/0x514
  [c0000000fe08b350] [c0000000003a3410] .mtdblock_add_mtd+0x74/0xb4
  [c0000000fe08b3e0] [c0000000003a32cc] .blktrans_notify_add+0x64/0x94
  [c0000000fe08b470] [c00000000039b5b4] .add_mtd_device+0x1d4/0x368
  [c0000000fe08b520] [c00000000039b830] .mtd_device_parse_register+0xe8/0x104
  [c0000000fe08b5c0] [c0000000003b8408] .of_flash_probe+0x72c/0x734
  [c0000000fe08b750] [c00000000035ba40] .platform_drv_probe+0x38/0x84
  [c0000000fe08b7d0] [c0000000003599a4] .really_probe+0xa4/0x29c
  [c0000000fe08b870] [c000000000359d3c] .__driver_attach+0x100/0x104
  [c0000000fe08b900] [c00000000035746c] .bus_for_each_dev+0x84/0xe4
  [c0000000fe08b9a0] [c0000000003593c0] .driver_attach+0x24/0x38
  [c0000000fe08ba10] [c000000000358f24] .bus_add_driver+0x1c8/0x2ac
  [c0000000fe08bab0] [c00000000035a3a4] .driver_register+0x8c/0x158
  [c0000000fe08bb30] [c00000000035b9f4] .__platform_driver_register+0x6c/0x80
  [c0000000fe08bba0] [c00000000084e080] .of_flash_driver_init+0x1c/0x30
  [c0000000fe08bc10] [c000000000001864] .do_one_initcall+0xbc/0x238
  [c0000000fe08bd00] [c00000000082cdc0] .kernel_init_freeable+0x188/0x268
  [c0000000fe08bdb0] [c0000000000020a0] .kernel_init+0x1c/0xf7c
  [c0000000fe08be30] [c000000000000884] .ret_from_kernel_thread+0x58/0xd4
  Instruction dump:
  41bd0010 480000c8 4bf04eb5 60000000 e94d0028 e93f0000 7cc95214 e8a60008
  7fc9502a 2fbe0000 419e00c8 e93f0022 <7f7e482a39200000 88ed06b2 992d06b2
  ---[ end trace b4c9a94804a42d40 ]---

It seems that the corrupted partition header on my mtd device triggers
a bug in the ftl. In function build_maps() it will allocate the buffers
needed by the mtd partition, but if something goes wrong such as kmalloc
failure, mtd read error or invalid partition header parameter, it will
free all allocated buffers and then return non-zero. In my case, it
seems that partition header parameter 'NumTransferUnits' is invalid.

And the ftl_freepart() is a function which free all the partition
buffers allocated by build_maps(). Given the build_maps() is a self
cleaning function, so there is no need to invoke this function even
if build_maps() return with error. Otherwise it will causes the
buffers to be freed twice and then weird things would happen.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoCIFS: Fix wrong restart readdir for SMB1
Pavel Shilovsky [Tue, 26 Aug 2014 15:04:44 +0000 (19:04 +0400)]
CIFS: Fix wrong restart readdir for SMB1

commit f736906a7669a77cf8cabdcbcf1dc8cb694e12ef upstream.

The existing code calls server->ops->close() that is not
right. This causes XFS test generic/310 to fail. Fix this
by using server->ops->closedir() function.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoCIFS: Fix wrong filename length for SMB2
Pavel Shilovsky [Fri, 22 Aug 2014 09:32:11 +0000 (13:32 +0400)]
CIFS: Fix wrong filename length for SMB2

commit 1bbe4997b13de903c421c1cc78440e544b5f9064 upstream.

The existing code uses the old MAX_NAME constant. This causes
XFS test generic/013 to fail. Fix it by replacing MAX_NAME with
PATH_MAX that SMB1 uses. Also remove an unused MAX_NAME constant
definition.

Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoCIFS: Fix directory rename error
Pavel Shilovsky [Fri, 22 Aug 2014 09:32:09 +0000 (13:32 +0400)]
CIFS: Fix directory rename error

commit a07d322059db66b84c9eb4f98959df468e88b34b upstream.

CIFS servers process nlink counts differently for files and directories.
In cifs_rename() if we the request fails on the existing target, we
try to remove it through cifs_unlink() but this is not what we want
to do for directories. As the result the following sequence of commands

mkdir {1,2}; mv -T 1 2; rmdir {1,2}; mkdir {1,2}; echo foo > 2/bar

and XFS test generic/023 fail with -ENOENT error. That's why the second
mkdir reuses the existing inode (target inode of the mv -T command) with
S_DEAD flag.

Fix this by checking whether the target is directory or not and
calling cifs_rmdir() rather than cifs_unlink() for directories.

Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agovfs: add d_is_dir()
Miklos Szeredi [Tue, 1 Apr 2014 15:08:41 +0000 (17:08 +0200)]
vfs: add d_is_dir()

commit 44b1d53043c482225196e8a9cd9f35163a1b3336 upstream.

Add d_is_dir(dentry) helper which is analogous to S_ISDIR().

To avoid confusion, rename d_is_directory() to d_can_lookup().

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Reviewed-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoCIFS: Fix wrong directory attributes after rename
Pavel Shilovsky [Mon, 18 Aug 2014 16:49:58 +0000 (20:49 +0400)]
CIFS: Fix wrong directory attributes after rename

commit b46799a8f28c43c5264ac8d8ffa28b311b557e03 upstream.

When we requests rename we also need to update attributes
of both source and target parent directories. Not doing it
causes generic/309 xfstest to fail on SMB2 mounts. Fix this
by marking these directories for force revalidating.

Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoCIFS: Possible null ptr deref in SMB2_tcon
Steve French [Sun, 17 Aug 2014 05:22:24 +0000 (00:22 -0500)]
CIFS: Possible null ptr deref in SMB2_tcon

commit 18f39e7be0121317550d03e267e3ebd4dbfbb3ce upstream.

As Raphael Geissert pointed out, tcon_error_exit can dereference tcon
and there is one path in which tcon can be null.

Signed-off-by: Steve French <smfrench@gmail.com>
Reported-by: Raphael Geissert <geissert@debian.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoCIFS: Fix async reading on reconnects
Pavel Shilovsky [Fri, 27 Jun 2014 06:33:11 +0000 (10:33 +0400)]
CIFS: Fix async reading on reconnects

commit 038bc961c31b070269ecd07349a7ee2e839d4fec upstream.

If we get into read_into_pages() from cifs_readv_receive() and then
loose a network, we issue cifs_reconnect that moves all mids to
a private list and issue their callbacks. The callback of the async
read request sets a mid to retry, frees it and wakes up a process
that waits on the rdata completion.

After the connection is established we return from read_into_pages()
with a short read, use the mid that was freed before and try to read
the remaining data from the a newly created socket. Both actions are
not what we want to do. In reconnect cases (-EAGAIN) we should not
mask off the error with a short read but should return the error
code instead.

Acked-by: Jeff Layton <jlayton@samba.org>
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoCIFS: Fix STATUS_CANNOT_DELETE error mapping for SMB2
Pavel Shilovsky [Fri, 18 Jul 2014 14:25:52 +0000 (18:25 +0400)]
CIFS: Fix STATUS_CANNOT_DELETE error mapping for SMB2

commit 21496687a79424572f46a84c690d331055f4866f upstream.

The existing mapping causes unlink() call to return error after delete
operation. Changing the mapping to -EACCES makes the client process
the call like CIFS protocol does - reset dos attributes with ATTR_READONLY
flag masked off and retry the operation.

Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agolibceph: do not hard code max auth ticket len
Ilya Dryomov [Tue, 9 Sep 2014 15:39:15 +0000 (19:39 +0400)]
libceph: do not hard code max auth ticket len

commit c27a3e4d667fdcad3db7b104f75659478e0c68d8 upstream.

We hard code cephx auth ticket buffer size to 256 bytes.  This isn't
enough for any moderate setups and, in case tickets themselves are not
encrypted, leads to buffer overflows (ceph_x_decrypt() errors out, but
ceph_decode_copy() doesn't - it's just a memcpy() wrapper).  Since the
buffer is allocated dynamically anyway, allocated it a bit later, at
the point where we know how much is going to be needed.

Fixes: http://tracker.ceph.com/issues/8979

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Sage Weil <sage@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agolibceph: add process_one_ticket() helper
Ilya Dryomov [Mon, 8 Sep 2014 13:25:34 +0000 (17:25 +0400)]
libceph: add process_one_ticket() helper

commit 597cda357716a3cf8d994cb11927af917c8d71fa upstream.

Add a helper for processing individual cephx auth tickets.  Needed for
the next commit, which deals with allocating ticket buffers.  (Most of
the diff here is whitespace - view with git diff -b).

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Sage Weil <sage@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agolibceph: set last_piece in ceph_msg_data_pages_cursor_init() correctly
Ilya Dryomov [Fri, 8 Aug 2014 08:43:39 +0000 (12:43 +0400)]
libceph: set last_piece in ceph_msg_data_pages_cursor_init() correctly

commit 5f740d7e1531099b888410e6bab13f68da9b1a4d upstream.

Determining ->last_piece based on the value of ->page_offset + length
is incorrect because length here is the length of the entire message.
->last_piece set to false even if page array data item length is <=
PAGE_SIZE, which results in invalid length passed to
ceph_tcp_{send,recv}page() and causes various asserts to fire.

    # cat pages-cursor-init.sh
    #!/bin/bash
    rbd create --size 10 --image-format 2 foo
    FOO_DEV=$(rbd map foo)
    dd if=/dev/urandom of=$FOO_DEV bs=1M &>/dev/null
    rbd snap create foo@snap
    rbd snap protect foo@snap
    rbd clone foo@snap bar
    # rbd_resize calls librbd rbd_resize(), size is in bytes
    ./rbd_resize bar $(((4 << 20) + 512))
    rbd resize --size 10 bar
    BAR_DEV=$(rbd map bar)
    # trigger a 512-byte copyup -- 512-byte page array data item
    dd if=/dev/urandom of=$BAR_DEV bs=1M count=1 seek=5

The problem exists only in ceph_msg_data_pages_cursor_init(),
ceph_msg_data_pages_advance() does the right thing.  The size_t cast is
unnecessary.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoxfs: don't zero partial page cache pages during O_DIRECT writes
Chris Mason [Tue, 2 Sep 2014 02:12:52 +0000 (12:12 +1000)]
xfs: don't zero partial page cache pages during O_DIRECT writes

commit 85e584da3212140ee80fd047f9058bbee0bc00d5 upstream.

xfs is using truncate_pagecache_range to invalidate the page cache
during DIO reads.  This is different from the other filesystems who
only invalidate pages during DIO writes.

truncate_pagecache_range is meant to be used when we are freeing the
underlying data structs from disk, so it will zero any partial
ranges in the page.  This means a DIO read can zero out part of the
page cache page, and it is possible the page will stay in cache.

buffered reads will find an up to date page with zeros instead of
the data actually on disk.

This patch fixes things by using invalidate_inode_pages2_range
instead.  It preserves the page cache invalidation, but won't zero
any pages.

[dchinner: catch error and warn if it fails. Comment.]

Signed-off-by: Chris Mason <clm@fb.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoxfs: don't zero partial page cache pages during O_DIRECT writes
Dave Chinner [Tue, 2 Sep 2014 02:12:52 +0000 (12:12 +1000)]
xfs: don't zero partial page cache pages during O_DIRECT writes

commit 834ffca6f7e345a79f6f2e2d131b0dfba8a4b67a upstream.

Similar to direct IO reads, direct IO writes are using
truncate_pagecache_range to invalidate the page cache. This is
incorrect due to the sub-block zeroing in the page cache that
truncate_pagecache_range() triggers.

This patch fixes things by using invalidate_inode_pages2_range
instead.  It preserves the page cache invalidation, but won't zero
any pages.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoxfs: don't dirty buffers beyond EOF
Dave Chinner [Tue, 2 Sep 2014 02:12:51 +0000 (12:12 +1000)]
xfs: don't dirty buffers beyond EOF

commit 22e757a49cf010703fcb9c9b4ef793248c39b0c2 upstream.

generic/263 is failing fsx at this point with a page spanning
EOF that cannot be invalidated. The operations are:

1190 mapwrite   0x52c00 thru    0x5e569 (0xb96a bytes)
1191 mapread    0x5c000 thru    0x5d636 (0x1637 bytes)
1192 write      0x5b600 thru    0x771ff (0x1bc00 bytes)

where 1190 extents EOF from 0x54000 to 0x5e569. When the direct IO
write attempts to invalidate the cached page over this range, it
fails with -EBUSY and so any attempt to do page invalidation fails.

The real question is this: Why can't that page be invalidated after
it has been written to disk and cleaned?

Well, there's data on the first two buffers in the page (1k block
size, 4k page), but the third buffer on the page (i.e. beyond EOF)
is failing drop_buffers because it's bh->b_state == 0x3, which is
BH_Uptodate | BH_Dirty.  IOWs, there's dirty buffers beyond EOF. Say
what?

OK, set_buffer_dirty() is called on all buffers from
__set_page_buffers_dirty(), regardless of whether the buffer is
beyond EOF or not, which means that when we get to ->writepage,
we have buffers marked dirty beyond EOF that we need to clean.
So, we need to implement our own .set_page_dirty method that
doesn't dirty buffers beyond EOF.

This is messy because the buffer code is not meant to be shared
and it has interesting locking issues on the buffer dirty bits.
So just copy and paste it and then modify it to suit what we need.

Note: the solutions the other filesystems and generic block code use
of marking the buffers clean in ->writepage does not work for XFS.
It still leaves dirty buffers beyond EOF and invalidations still
fail. Hence rather than play whack-a-mole, this patch simply
prevents those buffers from being dirtied in the first place.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoxfs: quotacheck leaves dquot buffers without verifiers
Dave Chinner [Mon, 4 Aug 2014 02:43:26 +0000 (12:43 +1000)]
xfs: quotacheck leaves dquot buffers without verifiers

commit 5fd364fee81a7888af806e42ed8a91c845894f2d upstream.

When running xfs/305, I noticed that quotacheck was flushing dquot
buffers that did not have the xfs_dquot_buf_ops verifiers attached:

XFS (vdb): _xfs_buf_ioapply: no ops on block 0x1dc8/0x1dc8
ffff880052489000: 44 51 01 04 00 00 65 b8 00 00 00 00 00 00 00 00  DQ....e.........
ffff880052489010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
ffff880052489020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
ffff880052489030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
CPU: 1 PID: 2376 Comm: mount Not tainted 3.16.0-rc2-dgc+ #306
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 ffff88006fe38000 ffff88004a0ffae8 ffffffff81cf1cca 0000000000000001
 ffff88004a0ffb88 ffffffff814d50ca 000010004a0ffc70 0000000000000000
 ffff88006be56dc4 0000000000000021 0000000000001dc8 ffff88007c773d80
Call Trace:
 [<ffffffff81cf1cca>] dump_stack+0x45/0x56
 [<ffffffff814d50ca>] _xfs_buf_ioapply+0x3ca/0x3d0
 [<ffffffff810db520>] ? wake_up_state+0x20/0x20
 [<ffffffff814d51f5>] ? xfs_bdstrat_cb+0x55/0xb0
 [<ffffffff814d513b>] xfs_buf_iorequest+0x6b/0xd0
 [<ffffffff814d51f5>] xfs_bdstrat_cb+0x55/0xb0
 [<ffffffff814d53ab>] __xfs_buf_delwri_submit+0x15b/0x220
 [<ffffffff814d6040>] ? xfs_buf_delwri_submit+0x30/0x90
 [<ffffffff814d6040>] xfs_buf_delwri_submit+0x30/0x90
 [<ffffffff8150f89d>] xfs_qm_quotacheck+0x17d/0x3c0
 [<ffffffff81510591>] xfs_qm_mount_quotas+0x151/0x1e0
 [<ffffffff814ed01c>] xfs_mountfs+0x56c/0x7d0
 [<ffffffff814f0f12>] xfs_fs_fill_super+0x2c2/0x340
 [<ffffffff811c9fe4>] mount_bdev+0x194/0x1d0
 [<ffffffff814f0c50>] ? xfs_finish_flags+0x170/0x170
 [<ffffffff814ef0f5>] xfs_fs_mount+0x15/0x20
 [<ffffffff811ca8c9>] mount_fs+0x39/0x1b0
 [<ffffffff811e4d67>] vfs_kern_mount+0x67/0x120
 [<ffffffff811e757e>] do_mount+0x23e/0xad0
 [<ffffffff8117abde>] ? __get_free_pages+0xe/0x50
 [<ffffffff811e71e6>] ? copy_mount_options+0x36/0x150
 [<ffffffff811e8103>] SyS_mount+0x83/0xc0
 [<ffffffff81cfd40b>] tracesys+0xdd/0xe2

This was caused by dquot buffer readahead not attaching a verifier
structure to the buffer when readahead was issued, resulting in the
followup read of the buffer finding a valid buffer and so not
attaching new verifiers to the buffer as part of the read.

Also, when a verifier failure occurs, we then read the buffer
without verifiers. Attach the verifiers manually after this read so
that if the buffer is then written it will be verified that the
corruption has been repaired.

Further, when flushing a dquot we don't ask for a verifier when
reading in the dquot buffer the dquot belongs to. Most of the time
this isn't an issue because the buffer is still cached, but when it
is not cached it will result in writing the dquot buffer without
having the verfier attached.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoxfs: ensure verifiers are attached to recovered buffers
Dave Chinner [Mon, 4 Aug 2014 02:43:06 +0000 (12:43 +1000)]
xfs: ensure verifiers are attached to recovered buffers

commit 67dc288c21064b31a98a53dc64f6b9714b819fd6 upstream.

Crash testing of CRC enabled filesystems has resulted in a number of
reports of bad CRCs being detected after the filesystem was mounted.
Errors such as the following were being seen:

XFS (sdb3): Mounting V5 Filesystem
XFS (sdb3): Starting recovery (logdev: internal)
XFS (sdb3): Metadata CRC error detected at xfs_agf_read_verify+0x5a/0x100 [xfs], block 0x1
XFS (sdb3): Unmount and run xfs_repair
XFS (sdb3): First 64 bytes of corrupted metadata buffer:
ffff880136ffd600: 58 41 47 46 00 00 00 01 00 00 00 00 00 0f aa 40  XAGF...........@
ffff880136ffd610: 00 02 6d 53 00 02 77 f8 00 00 00 00 00 00 00 01  ..mS..w.........
ffff880136ffd620: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 03  ................
ffff880136ffd630: 00 00 00 04 00 08 81 d0 00 08 81 a7 00 00 00 00  ................
XFS (sdb3): metadata I/O error: block 0x1 ("xfs_trans_read_buf_map") error 74 numblks 1

The errors were typically being seen in AGF, AGI and their related
btree block buffers some time after log recovery had run. Often it
wasn't until later subsequent mounts that the problem was
discovered. The common symptom was a buffer with the correct
contents, but a CRC and an LSN that matched an older version of the
contents.

Some debug added to _xfs_buf_ioapply() indicated that buffers were
being written without verifiers attached to them from log recovery,
and Jan Kara isolated the cause to log recovery readahead an dit's
interactions with buffers that had a more recent LSN on disk than
the transaction being recovered. In this case, the buffer did not
get a verifier attached, and os when the second phase of log
recovery ran and recovered EFIs and unlinked inodes, the buffers
were modified and written without the verifier running. Hence they
had up to date contents, but stale LSNs and CRCs.

Fix it by attaching verifiers to buffers we skip due to future LSN
values so they don't escape into the buffer cache without the
correct verifier attached.

This patch is based on analysis and a patch from Jan Kara.

Reported-by: Jan Kara <jack@suse.cz>
Reported-by: Fanael Linithien <fanael4@gmail.com>
Reported-by: Grozdan <neutrino8@gmail.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoRDMA/uapi: Include socket.h in rdma_user_cm.h
Doug Ledford [Tue, 12 Aug 2014 23:20:11 +0000 (19:20 -0400)]
RDMA/uapi: Include socket.h in rdma_user_cm.h

commit db1044d458a287c18c4d413adc4ad12e92e253b5 upstream.

added struct sockaddr_storage to rdma_user_cm.h without also adding an
include for linux/socket.h to make sure it is defined.  Systemtap
needs the header files to build standalone and cannot rely on other
files to pre-include other headers, so add linux/socket.h to the list
of includes in this file.

Fixes: ee7aed4528f ("RDMA/ucma: Support querying for AF_IB addresses")
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoRDMA/iwcm: Use a default listen backlog if needed
Steve Wise [Fri, 25 Jul 2014 14:11:33 +0000 (09:11 -0500)]
RDMA/iwcm: Use a default listen backlog if needed

commit 2f0304d21867476394cd51a54e97f7273d112261 upstream.

If the user creates a listening cm_id with backlog of 0 the IWCM ends
up not allowing any connection requests at all.  The correct behavior
is for the IWCM to pick a default value if the user backlog parameter
is zero.

Lustre from version 1.8.8 onward uses a backlog of 0, which breaks
iwarp support without this fix.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agomd/raid10: Fix memory leak when raid10 reshape completes.
NeilBrown [Mon, 18 Aug 2014 03:59:50 +0000 (13:59 +1000)]
md/raid10: Fix memory leak when raid10 reshape completes.

commit b39685526f46976bcd13aa08c82480092befa46c upstream.

When a raid10 commences a resync/recovery/reshape it allocates
some buffer space.
When a resync/recovery completes the buffer space is freed.  But not
when the reshape completes.
This can result in a small memory leak.

There is a subtle side-effect of this bug.  When a RAID10 is reshaped
to a larger array (more devices), the reshape is immediately followed
by a "resync" of the new space.  This "resync" will use the buffer
space which was allocated for "reshape".  This can cause problems
including a "BUG" in the SCSI layer.  So this is suitable for -stable.

Fixes: 3ea7daa5d7fde47cd41f4d56c2deb949114da9d6
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agomd/raid10: fix memory leak when reshaping a RAID10.
NeilBrown [Mon, 18 Aug 2014 03:56:38 +0000 (13:56 +1000)]
md/raid10: fix memory leak when reshaping a RAID10.

commit ce0b0a46955d1bb389684a2605dbcaa990ba0154 upstream.

raid10 reshape clears unwanted bits from a bio->bi_flags using
a method which, while clumsy, worked until 3.10 when BIO_OWNS_VEC
was added.
Since then it clears that bit but shouldn't.  This results in a
memory leak.

So change to used the approved method of clearing unwanted bits.

As this causes a memory leak which can consume all of memory
the fix is suitable for -stable.

Fixes: a38352e0ac02dbbd4fa464dc22d1352b5fbd06fd
Reported-by: mdraid.pkoch@dfgh.net (Peter Koch)
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agomd/raid6: avoid data corruption during recovery of double-degraded RAID6
NeilBrown [Tue, 12 Aug 2014 23:57:07 +0000 (09:57 +1000)]
md/raid6: avoid data corruption during recovery of double-degraded RAID6

commit 9c4bdf697c39805078392d5ddbbba5ae5680e0dd upstream.

During recovery of a double-degraded RAID6 it is possible for
some blocks not to be recovered properly, leading to corruption.

If a write happens to one block in a stripe that would be written to a
missing device, and at the same time that stripe is recovering data
to the other missing device, then that recovered data may not be written.

This patch skips, in the double-degraded case, an optimisation that is
only safe for single-degraded arrays.

Bug was introduced in 2.6.32 and fix is suitable for any kernel since
then.  In an older kernel with separate handle_stripe5() and
handle_stripe6() functions the patch must change handle_stripe6().

Fixes: 6c0069c0ae9659e3a91b68eaed06a5c6c37f45c8
Cc: Yuri Tikhonov <yur@emcraft.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Reported-by: "Manibalan P" <pmanibalan@amiindia.co.in>
Tested-by: "Manibalan P" <pmanibalan@amiindia.co.in>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1090423
Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agomd/raid1,raid10: always abort recover on write error.
NeilBrown [Thu, 31 Jul 2014 00:16:29 +0000 (10:16 +1000)]
md/raid1,raid10: always abort recover on write error.

commit 2446dba03f9dabe0b477a126cbeb377854785b47 upstream.

Currently we don't abort recovery on a write error if the write error
to the recovering device was triggerd by normal IO (as opposed to
recovery IO).

This means that for one bitmap region, the recovery might write to the
recovering device for a few sectors, then not bother for subsequent
sectors (as it never writes to failed devices).  In this case
the bitmap bit will be cleared, but it really shouldn't.

The result is that if the recovering device fails and is then re-added
(after fixing whatever hardware problem triggerred the failure),
the second recovery won't redo the region it was in the middle of,
so some of the device will not be recovered properly.

If we abort the recovery, the region being processes will be cancelled
(bit not cleared) and the whole region will be retried.

As the bug can result in data corruption the patch is suitable for
-stable.  For kernels prior to 3.11 there is a conflict in raid10.c
which will require care.

Original-from: jiao hui <jiaohui@bwstor.com.cn>
Reported-and-tested-by: jiao hui <jiaohui@bwstor.com.cn>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agofix copy_tree() regression
Al Viro [Sun, 10 Aug 2014 07:44:55 +0000 (03:44 -0400)]
fix copy_tree() regression

commit 12a5b5294cb1896e9a3c9fca8ff5a7e3def4e8c6 upstream.

Since 3.14 we had copy_tree() get the shadowing wrong - if we had one
vfsmount shadowing another (i.e. if A is a slave of B, C is mounted
on A/foo, then D got mounted on B/foo creating D' on A/foo shadowed
by C), copy_tree() of A would make a copy of D' shadow the the copy of
C, not the other way around.

It's easy to fix, fortunately - just make sure that mount follows
the one that shadows it in mnt_child as well as in mnt_hash, and when
copy_tree() decides to attach a new mount, check if the last child
it has added to the same parent should be shadowing the new one.
And if it should, just use the same logics commit_tree() has - put the
new mount into the hash and children lists right after the one that
should shadow it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>