35752 Commits

Author SHA1 Message Date
ggow fddef9b0e1 Add required changes for austin and ford 2019-04-21 09:20:06 +01:00
Tom Marshall 672c40a112 kernel: Only expose su when daemon is running
It has been claimed that the PG implementation of 'su' has security
vulnerabilities even when disabled.  Unfortunately, the people that
find these vulnerabilities often like to keep them private so they
can profit from exploits while leaving users exposed to malicious
hackers.

In order to reduce the attack surface for vulnerabilites, it is
therefore necessary to make 'su' completely inaccessible when it
is not in use (except by the root and system users).

Change-Id: I79716c72f74d0b7af34ec3a8054896c6559a181d
2018-05-03 18:44:36 +02:00
Al Viro 0f63c0e88f introduce ->iterate(), ctx->pos, dir_emit()
New method - ->iterate(file, ctx).  That's the replacement for ->readdir();
it takes callback from ctx->actor, uses ctx->pos instead of file->f_pos and
calls dir_emit(ctx, ...) instead of filldir(data, ...).  It does *not*
update file->f_pos (or look at it, for that matter); iterate_dir() does the
update.

Note that dir_emit() takes the offset from ctx->pos (and eventually
filldir_t will lose that argument).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-03 18:37:22 +02:00
Al Viro 0f8376923b introduce iterate_dir() and dir_context
iterate_dir(): new helper, replacing vfs_readdir().

struct dir_context: contains the readdir callback (and will get more stuff
in it), embedded into whatever data that callback wants to deal with;
eventually, we'll be passing it to ->readdir() replacement instead of
(data,filldir) pair.

Change-Id: Idb3843e77b97d52490b297b1f9e7d7efab18eaef
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-03 18:33:29 +02:00
Jeff Vander Stoep a4a18acb07 security: add ioctl specific auditing to lsm_audit
(cherry pick from commit 671a2781ff01abf4fdc8904881fc3abd3a8279af)

Add information about ioctl calls to the LSM audit data. Log the
file path and command number.

Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
Acked-by: Nick Kralevich <nnk@google.com>
[PM: subject line tweak]
Signed-off-by: Paul Moore <pmoore@redhat.com>
Bug: 22846070
Change-Id: I88a6ecdd59297a315a6fb9c82c0a798bdb6bafaa
2018-04-20 19:26:01 +02:00
Stricted bdecc6d184 Merge tag 'v3.10.108' into update
This is the 3.10.108 stable release
2018-03-21 23:07:40 +01:00
Stricted 073b9047a0 Merge tag 'v3.10.107' into update
This is the 3.10.107 stable release
2018-03-21 23:07:35 +01:00
Stricted 47e5ca72da Merge tag 'v3.10.106' into update
This is the 3.10.106 stable release
2018-03-21 23:06:23 +01:00
Stricted ad957d335c Merge tag 'v3.10.105' into update
This is the 3.10.105 stable release
2018-03-21 23:00:38 +01:00
Stricted c8df40eb3e Merge tag 'v3.10.104' into update
This is the 3.10.104 stable release
2018-03-21 22:58:25 +01:00
Stricted b9e7bc93d6 Merge tag 'v3.10.103' into update
This is the 3.10.103 stable release
2018-03-21 22:58:21 +01:00
Stricted a8732f92e3 Merge tag 'v3.10.102' into update
This is the 3.10.102 stable release
2018-03-21 22:54:09 +01:00
Stricted 9aae3dad3d Merge tag 'v3.10.101' into update
This is the 3.10.101 stable release
2018-03-21 22:52:41 +01:00
Stricted 93481ad93e Merge tag 'v3.10.100' into update
This is the 3.10.100 stable release
2018-03-21 22:52:38 +01:00
Stricted d09f889ac9 Merge tag 'v3.10.99' into update
This is the 3.10.99 stable release
2018-03-21 22:51:42 +01:00
Stricted 647f2da1e2 Merge tag 'v3.10.98' into update
This is the 3.10.98 stable release
2018-03-21 22:51:37 +01:00
Stricted dd388bd4cd Merge tag 'v3.10.97' into update
This is the 3.10.97 stable release
2018-03-21 22:51:04 +01:00
Stricted ca0dd0f30e Merge tag 'v3.10.96' into update
This is the 3.10.96 stable release
2018-03-21 22:51:00 +01:00
Stricted f3d34b554f Merge tag 'v3.10.95' into update
This is the 3.10.95 stable release
2018-03-21 22:50:56 +01:00
Stricted 4511a4e21f Merge tag 'v3.10.92' into update
This is the 3.10.92 stable release
2018-03-21 22:49:35 +01:00
Stricted d50b84c473 Merge tag 'v3.10.91' into update
This is the 3.10.91 stable release
2018-03-21 22:48:36 +01:00
Stricted 15bd15baa8 Merge tag 'v3.10.89' into update
This is the 3.10.89 stable release
2018-03-21 22:47:28 +01:00
Stricted 38b8911896 Merge tag 'v3.10.85' into update
This is the 3.10.85 stable release
2018-03-21 22:46:39 +01:00
Stricted 81575b8770 Merge tag 'v3.10.83' into update
This is the 3.10.83 stable release
2018-03-21 22:46:32 +01:00
Stricted 5eab702925 Merge tag 'v3.10.80' into update
This is the 3.10.80 stable release
2018-03-21 22:45:22 +01:00
Stricted 705e3c2e81 Merge tag 'v3.10.79' into update
This is the 3.10.79 stable release
2018-03-21 22:44:42 +01:00
Stricted 9b13083065 Merge tag 'v3.10.77' into update
This is the 3.10.77 stable release
2018-03-21 22:44:34 +01:00
Stricted 85511b9d61 Merge tag 'v3.10.76' into update
This is the 3.10.76 stable release
2018-03-21 22:42:30 +01:00
Stricted 446a42c9b2 Merge tag 'v3.10.75' into update
This is the 3.10.75 stable release
2018-03-21 22:41:10 +01:00
Stricted eff333fa3b Merge tag 'v3.10.73' into update
This is the 3.10.73 stable release
2018-03-21 22:41:03 +01:00
Stricted 5d8d08710c Merge tag 'v3.10.71' into update
This is the 3.10.71 stable release
2018-03-21 22:40:50 +01:00
Stricted b2d402e5a4 Merge tag 'v3.10.67' into update
This is the 3.10.67 stable release
2018-03-21 22:36:30 +01:00
Stricted 90cb50b720 Merge tag 'v3.10.65' into update
This is the 3.10.65 stable release
2018-03-21 22:36:23 +01:00
Stricted d242a5721c Merge tag 'v3.10.64' into update
This is the 3.10.64 stable release
2018-03-21 22:33:51 +01:00
Stricted 620f7405fd Merge tag 'v3.10.62' into update
This is the 3.10.62 stable release
2018-03-21 22:31:45 +01:00
Stricted 7887027a47 Merge tag 'v3.10.61' into update
This is the 3.10.61 stable release
2018-03-21 22:31:40 +01:00
Stricted 6f56b75961 Merge tag 'v3.10.60' into update
This is the 3.10.60 stable release
2018-03-21 22:31:34 +01:00
Stricted 583be8778f Merge tag 'v3.10.59' into update
This is the 3.10.59 stable release
2018-03-21 22:31:29 +01:00
Stricted 3af310ffc1 Merge tag 'v3.10.58' into update
This is the 3.10.58 stable release
2018-03-21 22:31:25 +01:00
Stricted f5aa73ff5c Merge tag 'v3.10.57' into update
This is the 3.10.57 stable release
2018-03-21 22:28:46 +01:00
Stricted f29ec40f35 Merge tag 'v3.10.56' into update
This is the 3.10.56 stable release
2018-03-21 22:24:54 +01:00
Stricted b435043299 Merge tag 'v3.10.55' into update
This is the 3.10.55 stable release
2018-03-21 22:13:57 +01:00
Stricted 4b9e97964e import PULS_20180308 2018-03-13 20:30:12 +01:00
Stricted 6fa3eb70c0 import PULS_20160108 2018-03-13 20:29:02 +01:00
Tejun Heo 162f50e691 workqueue: implicit ordered attribute should be overridable
commit 0a94efb5acbb6980d7c9ab604372d93cd507e4d8 upstream.

5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be
ordered") automatically enabled ordered attribute for unbound
workqueues w/ max_active == 1.  Because ordered workqueues reject
max_active and some attribute changes, this implicit ordered mode
broke cases where the user creates an unbound workqueue w/ max_active
== 1 and later explicitly changes the related attributes.

This patch distinguishes explicit and implicit ordered setting and
overrides from attribute changes if implict.

Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered")
Cc: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Willy Tarreau <w@1wt.eu>
2017-11-02 10:45:58 +01:00
Eric Biggers e8705c4233 KEYS: prevent creating a different user's keyrings
commit 237bbd29f7a049d310d907f4b2716a7feef9abf3 upstream.

It was possible for an unprivileged user to create the user and user
session keyrings for another user.  For example:

    sudo -u '#3000' sh -c 'keyctl add keyring _uid.4000 "" @u
                           keyctl add keyring _uid_ses.4000 "" @u
                           sleep 15' &
    sleep 1
    sudo -u '#4000' keyctl describe @u
    sudo -u '#4000' keyctl describe @us

This is problematic because these "fake" keyrings won't have the right
permissions.  In particular, the user who created them first will own
them and will have full access to them via the possessor permissions,
which can be used to compromise the security of a user's keys:

    -4: alswrv-----v------------  3000     0 keyring: _uid.4000
    -5: alswrv-----v------------  3000     0 keyring: _uid_ses.4000

Fix it by marking user and user session keyrings with a flag
KEY_FLAG_UID_KEYRING.  Then, when searching for a user or user session
keyring by name, skip all keyrings that don't have the flag set.

Fixes: 69664cf16a ("keys: don't generate user and user session keyrings unless they're accessed")
Cc: <stable@vger.kernel.org>	[v2.6.26+]
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
[wt: adjust context]

Signed-off-by: Willy Tarreau <w@1wt.eu>
2017-11-02 07:16:18 +01:00
Hugh Dickins 1ad9a25dd0 mm: larger stack guard gap, between vmas
commit 1be7107fbe18eed3e319a6c3e83c78254b693acb upstream.

Stack guard page is a useful feature to reduce a risk of stack smashing
into a different mapping. We have been using a single page gap which
is sufficient to prevent having stack adjacent to a different mapping.
But this seems to be insufficient in the light of the stack usage in
userspace. E.g. glibc uses as large as 64kB alloca() in many commonly
used functions. Others use constructs liks gid_t buffer[NGROUPS_MAX]
which is 256kB or stack strings with MAX_ARG_STRLEN.

This will become especially dangerous for suid binaries and the default
no limit for the stack size limit because those applications can be
tricked to consume a large portion of the stack and a single glibc call
could jump over the guard page. These attacks are not theoretical,
unfortunatelly.

Make those attacks less probable by increasing the stack guard gap
to 1MB (on systems with 4k pages; but make it depend on the page size
because systems with larger base pages might cap stack allocations in
the PAGE_SIZE units) which should cover larger alloca() and VLA stack
allocations. It is obviously not a full fix because the problem is
somehow inherent, but it should reduce attack space a lot.

One could argue that the gap size should be configurable from userspace,
but that can be done later when somebody finds that the new 1MB is wrong
for some special case applications.  For now, add a kernel command line
option (stack_guard_gap) to specify the stack gap size (in page units).

Implementation wise, first delete all the old code for stack guard page:
because although we could get away with accounting one extra page in a
stack vma, accounting a larger gap can break userspace - case in point,
a program run with "ulimit -S -v 20000" failed when the 1MB gap was
counted for RLIMIT_AS; similar problems could come with RLIMIT_MLOCK
and strict non-overcommit mode.

Instead of keeping gap inside the stack vma, maintain the stack guard
gap as a gap between vmas: using vm_start_gap() in place of vm_start
(or vm_end_gap() in place of vm_end if VM_GROWSUP) in just those few
places which need to respect the gap - mainly arch_get_unmapped_area(),
and and the vma tree's subtree_gap support for that.

Original-patch-by: Oleg Nesterov <oleg@redhat.com>
Original-patch-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
[wt: backport to 4.11: adjust context]
[wt: backport to 4.9: adjust context ; kernel doc was not in admin-guide]
[wt: backport to 4.4: adjust context ; drop ppc hugetlb_radix changes]
[wt: backport to 3.18: adjust context ; no FOLL_POPULATE ;
     s390 uses generic arch_get_unmapped_area()]
[wt: backport to 3.16: adjust context]
[wt: backport to 3.10: adjust context ; code logic in PARISC's
     arch_get_unmapped_area() wasn't found ; code inserted into
     expand_upwards() and expand_downwards() runs under anon_vma lock;
     changes for gup.c:faultin_page go to memory.c:__get_user_pages();
     included Hugh Dickins' fixes]
Signed-off-by: Willy Tarreau <w@1wt.eu>
2017-06-21 15:42:43 +02:00
Linus Torvalds 46d284b7ac give up on gcc ilog2() constant optimizations
commit 474c90156c8dcc2fa815e6716cc9394d7930cb9c upstream.

gcc-7 has an "optimization" pass that completely screws up, and
generates the code expansion for the (impossible) case of calling
ilog2() with a zero constant, even when the code gcc compiles does not
actually have a zero constant.

And we try to generate a compile-time error for anybody doing ilog2() on
a constant where that doesn't make sense (be it zero or negative).  So
now gcc7 will fail the build due to our sanity checking, because it
created that constant-zero case that didn't actually exist in the source
code.

There's a whole long discussion on the kernel mailing about how to work
around this gcc bug.  The gcc people themselevs have discussed their
"feature" in

   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785

but it's all water under the bridge, because while it looked at one
point like it would be solved by the time gcc7 was released, that was
not to be.

So now we have to deal with this compiler braindamage.

And the only simple approach seems to be to just delete the code that
tries to warn about bad uses of ilog2().

So now "ilog2()" will just return 0 not just for the value 1, but for
any non-positive value too.

It's not like I can recall anybody having ever actually tried to use
this function on any invalid value, but maybe the sanity check just
meant that such code never made it out in public.

[js] no tools/include/linux/log2.h copy of that yet

Reported-by: Laura Abbott <labbott@redhat.com>
Cc: John Stultz <john.stultz@linaro.org>,
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2017-06-20 14:04:32 +02:00
Chuck Lever 379fa3e80f nfs: Don't increment lock sequence ID after NFS4ERR_MOVED
commit 059aa734824165507c65fd30a55ff000afd14983 upstream.

Xuan Qi reports that the Linux NFSv4 client failed to lock a file
that was migrated. The steps he observed on the wire:

1. The client sent a LOCK request to the source server
2. The source server replied NFS4ERR_MOVED
3. The client switched to the destination server
4. The client sent the same LOCK request to the destination
   server with a bumped lock sequence ID
5. The destination server rejected the LOCK request with
   NFS4ERR_BAD_SEQID

RFC 3530 section 8.1.5 provides a list of NFS errors which do not
bump a lock sequence ID.

However, RFC 3530 is now obsoleted by RFC 7530. In RFC 7530 section
9.1.7, this list has been updated by the addition of NFS4ERR_MOVED.

Reported-by: Xuan Qi <xuan.qi@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2017-06-20 14:04:16 +02:00
Arnd Bergmann de2e2803e6 cred/userns: define current_user_ns() as a function
commit 0335695dfa4df01edff5bb102b9a82a0668ee51e upstream.

The current_user_ns() macro currently returns &init_user_ns when user
namespaces are disabled, and that causes several warnings when building
with gcc-6.0 in code that compares the result of the macro to
&init_user_ns itself:

  fs/xfs/xfs_ioctl.c: In function 'xfs_ioctl_setattr_check_projid':
  fs/xfs/xfs_ioctl.c:1249:22: error: self-comparison always evaluates to true [-Werror=tautological-compare]
    if (current_user_ns() == &init_user_ns)

This is a legitimate warning in principle, but here it isn't really
helpful, so I'm reprasing the definition in a way that shuts up the
warning.  Apparently gcc only warns when comparing identical literals,
but it can figure out that the result of an inline function can be
identical to a constant expression in order to optimize a condition yet
not warn about the fact that the condition is known at compile time.
This is exactly what we want here, and it looks reasonable because we
generally prefer inline functions over macros anyway.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2017-06-20 14:03:25 +02:00