forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parisc: Add wrapper syscalls to fix O_NONBLOCK flag usage
The commit 75ae042 ("parisc: Define O_NONBLOCK to become 000200000") changed the O_NONBLOCK constant to have only one bit set (like all other architectures). This change broke some existing userspace code (e.g. udevadm, systemd-udevd, elogind) which called specific syscalls which do strict value checking on their flag parameter. This patch adds wrapper functions for the relevant syscalls. The wrappers masks out any old invalid O_NONBLOCK flags, reports in the syslog if the old O_NONBLOCK value was used and then calls the target syscall with the new O_NONBLOCK value. Fixes: 75ae042 ("parisc: Define O_NONBLOCK to become 000200000") Signed-off-by: Helge Deller <[email protected]> Tested-by: Meelis Roos <[email protected]> Tested-by: Jeroen Roovers <[email protected]>
- Loading branch information
Showing
2 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org> | ||
* Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org> | ||
* Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> | ||
* Copyright (C) 1999-2014 Helge Deller <[email protected]> | ||
* Copyright (C) 1999-2020 Helge Deller <[email protected]> | ||
*/ | ||
|
||
#include <linux/uaccess.h> | ||
|
@@ -23,6 +23,7 @@ | |
#include <linux/utsname.h> | ||
#include <linux/personality.h> | ||
#include <linux/random.h> | ||
#include <linux/compat.h> | ||
|
||
/* we construct an artificial offset for the mapping based on the physical | ||
* address of the kernel mapping variable */ | ||
|
@@ -373,3 +374,73 @@ long parisc_personality(unsigned long personality) | |
|
||
return err; | ||
} | ||
|
||
/* | ||
* Up to kernel v5.9 we defined O_NONBLOCK as 000200004, | ||
* since then O_NONBLOCK is defined as 000200000. | ||
* | ||
* The following wrapper functions mask out the old | ||
* O_NDELAY bit from calls which use O_NONBLOCK. | ||
* | ||
* XXX: Remove those in year 2022 (or later)? | ||
*/ | ||
|
||
#define O_NONBLOCK_OLD 000200004 | ||
#define O_NONBLOCK_MASK_OUT (O_NONBLOCK_OLD & ~O_NONBLOCK) | ||
|
||
static int FIX_O_NONBLOCK(int flags) | ||
{ | ||
if (flags & O_NONBLOCK_MASK_OUT) { | ||
struct task_struct *tsk = current; | ||
pr_warn_once("%s(%d) uses a deprecated O_NONBLOCK value.\n", | ||
tsk->comm, tsk->pid); | ||
} | ||
return flags & ~O_NONBLOCK_MASK_OUT; | ||
} | ||
|
||
asmlinkage long parisc_timerfd_create(int clockid, int flags) | ||
{ | ||
flags = FIX_O_NONBLOCK(flags); | ||
return sys_timerfd_create(clockid, flags); | ||
} | ||
|
||
asmlinkage long parisc_signalfd4(int ufd, sigset_t __user *user_mask, | ||
size_t sizemask, int flags) | ||
{ | ||
flags = FIX_O_NONBLOCK(flags); | ||
return sys_signalfd4(ufd, user_mask, sizemask, flags); | ||
} | ||
|
||
#ifdef CONFIG_COMPAT | ||
asmlinkage long parisc_compat_signalfd4(int ufd, | ||
compat_sigset_t __user *user_mask, | ||
compat_size_t sizemask, int flags) | ||
{ | ||
flags = FIX_O_NONBLOCK(flags); | ||
return compat_sys_signalfd4(ufd, user_mask, sizemask, flags); | ||
} | ||
#endif | ||
|
||
asmlinkage long parisc_eventfd2(unsigned int count, int flags) | ||
{ | ||
flags = FIX_O_NONBLOCK(flags); | ||
return sys_eventfd2(count, flags); | ||
} | ||
|
||
asmlinkage long parisc_userfaultfd(int flags) | ||
{ | ||
flags = FIX_O_NONBLOCK(flags); | ||
return sys_userfaultfd(flags); | ||
} | ||
|
||
asmlinkage long parisc_pipe2(int __user *fildes, int flags) | ||
{ | ||
flags = FIX_O_NONBLOCK(flags); | ||
return sys_pipe2(fildes, flags); | ||
} | ||
|
||
asmlinkage long parisc_inotify_init1(int flags) | ||
{ | ||
flags = FIX_O_NONBLOCK(flags); | ||
return sys_inotify_init1(flags); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters