| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | |
|---|
| 2 | 3 | /* |
|---|
| 3 | 4 | * PARISC specific syscalls |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org> |
|---|
| 6 | 7 | * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org> |
|---|
| 7 | 8 | * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> |
|---|
| 8 | | - * Copyright (C) 1999-2014 Helge Deller <deller@gmx.de> |
|---|
| 9 | | - * |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 12 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 13 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 14 | | - * (at your option) any later version. |
|---|
| 15 | | - * |
|---|
| 16 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 17 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 19 | | - * GNU General Public License for more details. |
|---|
| 20 | | - * |
|---|
| 21 | | - * You should have received a copy of the GNU General Public License |
|---|
| 22 | | - * along with this program; if not, write to the Free Software |
|---|
| 23 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 9 | + * Copyright (C) 1999-2020 Helge Deller <deller@gmx.de> |
|---|
| 24 | 10 | */ |
|---|
| 25 | 11 | |
|---|
| 26 | 12 | #include <linux/uaccess.h> |
|---|
| .. | .. |
|---|
| 37 | 23 | #include <linux/utsname.h> |
|---|
| 38 | 24 | #include <linux/personality.h> |
|---|
| 39 | 25 | #include <linux/random.h> |
|---|
| 26 | +#include <linux/compat.h> |
|---|
| 40 | 27 | |
|---|
| 41 | 28 | /* we construct an artificial offset for the mapping based on the physical |
|---|
| 42 | 29 | * address of the kernel mapping variable */ |
|---|
| .. | .. |
|---|
| 86 | 73 | stack_base = STACK_SIZE_MAX; |
|---|
| 87 | 74 | |
|---|
| 88 | 75 | /* Add space for stack randomization. */ |
|---|
| 89 | | - stack_base += (STACK_RND_MASK << PAGE_SHIFT); |
|---|
| 76 | + if (current->flags & PF_RANDOMIZE) |
|---|
| 77 | + stack_base += (STACK_RND_MASK << PAGE_SHIFT); |
|---|
| 90 | 78 | |
|---|
| 91 | 79 | return PAGE_ALIGN(STACK_TOP - stack_base); |
|---|
| 92 | 80 | } |
|---|
| .. | .. |
|---|
| 386 | 374 | |
|---|
| 387 | 375 | return err; |
|---|
| 388 | 376 | } |
|---|
| 377 | + |
|---|
| 378 | +/* |
|---|
| 379 | + * Up to kernel v5.9 we defined O_NONBLOCK as 000200004, |
|---|
| 380 | + * since then O_NONBLOCK is defined as 000200000. |
|---|
| 381 | + * |
|---|
| 382 | + * The following wrapper functions mask out the old |
|---|
| 383 | + * O_NDELAY bit from calls which use O_NONBLOCK. |
|---|
| 384 | + * |
|---|
| 385 | + * XXX: Remove those in year 2022 (or later)? |
|---|
| 386 | + */ |
|---|
| 387 | + |
|---|
| 388 | +#define O_NONBLOCK_OLD 000200004 |
|---|
| 389 | +#define O_NONBLOCK_MASK_OUT (O_NONBLOCK_OLD & ~O_NONBLOCK) |
|---|
| 390 | + |
|---|
| 391 | +static int FIX_O_NONBLOCK(int flags) |
|---|
| 392 | +{ |
|---|
| 393 | + if (flags & O_NONBLOCK_MASK_OUT) { |
|---|
| 394 | + struct task_struct *tsk = current; |
|---|
| 395 | + pr_warn_once("%s(%d) uses a deprecated O_NONBLOCK value.\n", |
|---|
| 396 | + tsk->comm, tsk->pid); |
|---|
| 397 | + } |
|---|
| 398 | + return flags & ~O_NONBLOCK_MASK_OUT; |
|---|
| 399 | +} |
|---|
| 400 | + |
|---|
| 401 | +asmlinkage long parisc_timerfd_create(int clockid, int flags) |
|---|
| 402 | +{ |
|---|
| 403 | + flags = FIX_O_NONBLOCK(flags); |
|---|
| 404 | + return sys_timerfd_create(clockid, flags); |
|---|
| 405 | +} |
|---|
| 406 | + |
|---|
| 407 | +asmlinkage long parisc_signalfd4(int ufd, sigset_t __user *user_mask, |
|---|
| 408 | + size_t sizemask, int flags) |
|---|
| 409 | +{ |
|---|
| 410 | + flags = FIX_O_NONBLOCK(flags); |
|---|
| 411 | + return sys_signalfd4(ufd, user_mask, sizemask, flags); |
|---|
| 412 | +} |
|---|
| 413 | + |
|---|
| 414 | +#ifdef CONFIG_COMPAT |
|---|
| 415 | +asmlinkage long parisc_compat_signalfd4(int ufd, |
|---|
| 416 | + compat_sigset_t __user *user_mask, |
|---|
| 417 | + compat_size_t sizemask, int flags) |
|---|
| 418 | +{ |
|---|
| 419 | + flags = FIX_O_NONBLOCK(flags); |
|---|
| 420 | + return compat_sys_signalfd4(ufd, user_mask, sizemask, flags); |
|---|
| 421 | +} |
|---|
| 422 | +#endif |
|---|
| 423 | + |
|---|
| 424 | +asmlinkage long parisc_eventfd2(unsigned int count, int flags) |
|---|
| 425 | +{ |
|---|
| 426 | + flags = FIX_O_NONBLOCK(flags); |
|---|
| 427 | + return sys_eventfd2(count, flags); |
|---|
| 428 | +} |
|---|
| 429 | + |
|---|
| 430 | +asmlinkage long parisc_userfaultfd(int flags) |
|---|
| 431 | +{ |
|---|
| 432 | + flags = FIX_O_NONBLOCK(flags); |
|---|
| 433 | + return sys_userfaultfd(flags); |
|---|
| 434 | +} |
|---|
| 435 | + |
|---|
| 436 | +asmlinkage long parisc_pipe2(int __user *fildes, int flags) |
|---|
| 437 | +{ |
|---|
| 438 | + flags = FIX_O_NONBLOCK(flags); |
|---|
| 439 | + return sys_pipe2(fildes, flags); |
|---|
| 440 | +} |
|---|
| 441 | + |
|---|
| 442 | +asmlinkage long parisc_inotify_init1(int flags) |
|---|
| 443 | +{ |
|---|
| 444 | + flags = FIX_O_NONBLOCK(flags); |
|---|
| 445 | + return sys_inotify_init1(flags); |
|---|
| 446 | +} |
|---|