1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 1991, 1992 Linus Torvalds
8 #include <linux/syscalls.h>
9 #include <linux/init.h>
11 #include <linux/sched/task.h>
13 #include <linux/file.h>
14 #include <linux/fdtable.h>
15 #include <linux/capability.h>
16 #include <linux/dnotify.h>
17 #include <linux/slab.h>
18 #include <linux/module.h>
19 #include <linux/pipe_fs_i.h>
20 #include <linux/security.h>
21 #include <linux/ptrace.h>
22 #include <linux/signal.h>
23 #include <linux/rcupdate.h>
24 #include <linux/pid_namespace.h>
25 #include <linux/user_namespace.h>
26 #include <linux/shmem_fs.h>
27 #include <linux/compat.h>
30 #include <asm/siginfo.h>
31 #include <linux/uaccess.h>
33 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIME)
35 int setfl(int fd
, struct file
* filp
, unsigned long arg
)
37 struct inode
* inode
= file_inode(filp
);
41 * O_APPEND cannot be cleared if the file is marked as append-only
42 * and the file is open for write.
44 if (((arg
^ filp
->f_flags
) & O_APPEND
) && IS_APPEND(inode
))
47 /* O_NOATIME can only be set by the owner or superuser */
48 if ((arg
& O_NOATIME
) && !(filp
->f_flags
& O_NOATIME
))
49 if (!inode_owner_or_capable(inode
))
52 /* required for strict SunOS emulation */
53 if (O_NONBLOCK
!= O_NDELAY
)
57 /* Pipe packetized mode is controlled by O_DIRECT flag */
58 if (!S_ISFIFO(inode
->i_mode
) && (arg
& O_DIRECT
)) {
59 if (!filp
->f_mapping
|| !filp
->f_mapping
->a_ops
||
60 !filp
->f_mapping
->a_ops
->direct_IO
)
64 if (filp
->f_op
->check_flags
)
65 error
= filp
->f_op
->check_flags(arg
);
66 if (!error
&& filp
->f_op
->setfl
)
67 error
= filp
->f_op
->setfl(filp
, arg
);
72 * ->fasync() is responsible for setting the FASYNC bit.
74 if (((arg
^ filp
->f_flags
) & FASYNC
) && filp
->f_op
->fasync
) {
75 error
= filp
->f_op
->fasync(fd
, filp
, (arg
& FASYNC
) != 0);
81 spin_lock(&filp
->f_lock
);
82 filp
->f_flags
= (arg
& SETFL_MASK
) | (filp
->f_flags
& ~SETFL_MASK
);
83 spin_unlock(&filp
->f_lock
);
88 EXPORT_SYMBOL_GPL(setfl
);
90 static void f_modown(struct file
*filp
, struct pid
*pid
, enum pid_type type
,
93 write_lock_irq(&filp
->f_owner
.lock
);
94 if (force
|| !filp
->f_owner
.pid
) {
95 put_pid(filp
->f_owner
.pid
);
96 filp
->f_owner
.pid
= get_pid(pid
);
97 filp
->f_owner
.pid_type
= type
;
100 const struct cred
*cred
= current_cred();
101 filp
->f_owner
.uid
= cred
->uid
;
102 filp
->f_owner
.euid
= cred
->euid
;
105 write_unlock_irq(&filp
->f_owner
.lock
);
108 void __f_setown(struct file
*filp
, struct pid
*pid
, enum pid_type type
,
111 security_file_set_fowner(filp
);
112 f_modown(filp
, pid
, type
, force
);
114 EXPORT_SYMBOL(__f_setown
);
116 int f_setown(struct file
*filp
, unsigned long arg
, int force
)
119 struct pid
*pid
= NULL
;
120 int who
= arg
, ret
= 0;
124 /* avoid overflow below */
134 pid
= find_vpid(who
);
140 __f_setown(filp
, pid
, type
, force
);
145 EXPORT_SYMBOL(f_setown
);
147 void f_delown(struct file
*filp
)
149 f_modown(filp
, NULL
, PIDTYPE_PID
, 1);
152 pid_t
f_getown(struct file
*filp
)
155 read_lock(&filp
->f_owner
.lock
);
156 pid
= pid_vnr(filp
->f_owner
.pid
);
157 if (filp
->f_owner
.pid_type
== PIDTYPE_PGID
)
159 read_unlock(&filp
->f_owner
.lock
);
163 static int f_setown_ex(struct file
*filp
, unsigned long arg
)
165 struct f_owner_ex __user
*owner_p
= (void __user
*)arg
;
166 struct f_owner_ex owner
;
171 ret
= copy_from_user(&owner
, owner_p
, sizeof(owner
));
175 switch (owner
.type
) {
193 pid
= find_vpid(owner
.pid
);
194 if (owner
.pid
&& !pid
)
197 __f_setown(filp
, pid
, type
, 1);
203 static int f_getown_ex(struct file
*filp
, unsigned long arg
)
205 struct f_owner_ex __user
*owner_p
= (void __user
*)arg
;
206 struct f_owner_ex owner
;
209 read_lock(&filp
->f_owner
.lock
);
210 owner
.pid
= pid_vnr(filp
->f_owner
.pid
);
211 switch (filp
->f_owner
.pid_type
) {
213 owner
.type
= F_OWNER_TID
;
217 owner
.type
= F_OWNER_PID
;
221 owner
.type
= F_OWNER_PGRP
;
229 read_unlock(&filp
->f_owner
.lock
);
232 ret
= copy_to_user(owner_p
, &owner
, sizeof(owner
));
239 #ifdef CONFIG_CHECKPOINT_RESTORE
240 static int f_getowner_uids(struct file
*filp
, unsigned long arg
)
242 struct user_namespace
*user_ns
= current_user_ns();
243 uid_t __user
*dst
= (void __user
*)arg
;
247 read_lock(&filp
->f_owner
.lock
);
248 src
[0] = from_kuid(user_ns
, filp
->f_owner
.uid
);
249 src
[1] = from_kuid(user_ns
, filp
->f_owner
.euid
);
250 read_unlock(&filp
->f_owner
.lock
);
252 err
= put_user(src
[0], &dst
[0]);
253 err
|= put_user(src
[1], &dst
[1]);
258 static int f_getowner_uids(struct file
*filp
, unsigned long arg
)
264 static bool rw_hint_valid(enum rw_hint hint
)
267 case RWF_WRITE_LIFE_NOT_SET
:
268 case RWH_WRITE_LIFE_NONE
:
269 case RWH_WRITE_LIFE_SHORT
:
270 case RWH_WRITE_LIFE_MEDIUM
:
271 case RWH_WRITE_LIFE_LONG
:
272 case RWH_WRITE_LIFE_EXTREME
:
279 static long fcntl_rw_hint(struct file
*file
, unsigned int cmd
,
282 struct inode
*inode
= file_inode(file
);
283 u64
*argp
= (u64 __user
*)arg
;
288 case F_GET_FILE_RW_HINT
:
289 h
= file_write_hint(file
);
290 if (copy_to_user(argp
, &h
, sizeof(*argp
)))
293 case F_SET_FILE_RW_HINT
:
294 if (copy_from_user(&h
, argp
, sizeof(h
)))
296 hint
= (enum rw_hint
) h
;
297 if (!rw_hint_valid(hint
))
300 spin_lock(&file
->f_lock
);
301 file
->f_write_hint
= hint
;
302 spin_unlock(&file
->f_lock
);
305 h
= inode
->i_write_hint
;
306 if (copy_to_user(argp
, &h
, sizeof(*argp
)))
310 if (copy_from_user(&h
, argp
, sizeof(h
)))
312 hint
= (enum rw_hint
) h
;
313 if (!rw_hint_valid(hint
))
317 inode
->i_write_hint
= hint
;
325 static long do_fcntl(int fd
, unsigned int cmd
, unsigned long arg
,
328 void __user
*argp
= (void __user
*)arg
;
334 err
= f_dupfd(arg
, filp
, 0);
336 case F_DUPFD_CLOEXEC
:
337 err
= f_dupfd(arg
, filp
, O_CLOEXEC
);
340 err
= get_close_on_exec(fd
) ? FD_CLOEXEC
: 0;
344 set_close_on_exec(fd
, arg
& FD_CLOEXEC
);
350 err
= setfl(fd
, filp
, arg
);
352 #if BITS_PER_LONG != 32
353 /* 32-bit arches must use fcntl64() */
357 if (copy_from_user(&flock
, argp
, sizeof(flock
)))
359 err
= fcntl_getlk(filp
, cmd
, &flock
);
360 if (!err
&& copy_to_user(argp
, &flock
, sizeof(flock
)))
363 #if BITS_PER_LONG != 32
364 /* 32-bit arches must use fcntl64() */
371 if (copy_from_user(&flock
, argp
, sizeof(flock
)))
373 err
= fcntl_setlk(fd
, filp
, cmd
, &flock
);
377 * XXX If f_owner is a process group, the
378 * negative return value will get converted
379 * into an error. Oops. If we keep the
380 * current syscall conventions, the only way
381 * to fix this will be in libc.
383 err
= f_getown(filp
);
384 force_successful_syscall_return();
387 err
= f_setown(filp
, arg
, 1);
390 err
= f_getown_ex(filp
, arg
);
393 err
= f_setown_ex(filp
, arg
);
395 case F_GETOWNER_UIDS
:
396 err
= f_getowner_uids(filp
, arg
);
399 err
= filp
->f_owner
.signum
;
402 /* arg == 0 restores default behaviour. */
403 if (!valid_signal(arg
)) {
407 filp
->f_owner
.signum
= arg
;
410 err
= fcntl_getlease(filp
);
413 err
= fcntl_setlease(fd
, filp
, arg
);
416 err
= fcntl_dirnotify(fd
, filp
, arg
);
420 err
= pipe_fcntl(filp
, cmd
, arg
);
424 err
= shmem_fcntl(filp
, cmd
, arg
);
428 case F_GET_FILE_RW_HINT
:
429 case F_SET_FILE_RW_HINT
:
430 err
= fcntl_rw_hint(filp
, cmd
, arg
);
438 static int check_fcntl_cmd(unsigned cmd
)
442 case F_DUPFD_CLOEXEC
:
451 SYSCALL_DEFINE3(fcntl
, unsigned int, fd
, unsigned int, cmd
, unsigned long, arg
)
453 struct fd f
= fdget_raw(fd
);
459 if (unlikely(f
.file
->f_mode
& FMODE_PATH
)) {
460 if (!check_fcntl_cmd(cmd
))
464 err
= security_file_fcntl(f
.file
, cmd
, arg
);
466 err
= do_fcntl(fd
, cmd
, arg
, f
.file
);
474 #if BITS_PER_LONG == 32
475 SYSCALL_DEFINE3(fcntl64
, unsigned int, fd
, unsigned int, cmd
,
478 void __user
*argp
= (void __user
*)arg
;
479 struct fd f
= fdget_raw(fd
);
480 struct flock64 flock
;
486 if (unlikely(f
.file
->f_mode
& FMODE_PATH
)) {
487 if (!check_fcntl_cmd(cmd
))
491 err
= security_file_fcntl(f
.file
, cmd
, arg
);
499 if (copy_from_user(&flock
, argp
, sizeof(flock
)))
501 err
= fcntl_getlk64(f
.file
, cmd
, &flock
);
502 if (!err
&& copy_to_user(argp
, &flock
, sizeof(flock
)))
510 if (copy_from_user(&flock
, argp
, sizeof(flock
)))
512 err
= fcntl_setlk64(fd
, f
.file
, cmd
, &flock
);
515 err
= do_fcntl(fd
, cmd
, arg
, f
.file
);
526 /* careful - don't use anywhere else */
527 #define copy_flock_fields(dst, src) \
528 (dst)->l_type = (src)->l_type; \
529 (dst)->l_whence = (src)->l_whence; \
530 (dst)->l_start = (src)->l_start; \
531 (dst)->l_len = (src)->l_len; \
532 (dst)->l_pid = (src)->l_pid;
534 static int get_compat_flock(struct flock
*kfl
, const struct compat_flock __user
*ufl
)
536 struct compat_flock fl
;
538 if (copy_from_user(&fl
, ufl
, sizeof(struct compat_flock
)))
540 copy_flock_fields(kfl
, &fl
);
544 static int get_compat_flock64(struct flock
*kfl
, const struct compat_flock64 __user
*ufl
)
546 struct compat_flock64 fl
;
548 if (copy_from_user(&fl
, ufl
, sizeof(struct compat_flock64
)))
550 copy_flock_fields(kfl
, &fl
);
554 static int put_compat_flock(const struct flock
*kfl
, struct compat_flock __user
*ufl
)
556 struct compat_flock fl
;
558 memset(&fl
, 0, sizeof(struct compat_flock
));
559 copy_flock_fields(&fl
, kfl
);
560 if (copy_to_user(ufl
, &fl
, sizeof(struct compat_flock
)))
565 static int put_compat_flock64(const struct flock
*kfl
, struct compat_flock64 __user
*ufl
)
567 struct compat_flock64 fl
;
569 BUILD_BUG_ON(sizeof(kfl
->l_start
) > sizeof(ufl
->l_start
));
570 BUILD_BUG_ON(sizeof(kfl
->l_len
) > sizeof(ufl
->l_len
));
572 memset(&fl
, 0, sizeof(struct compat_flock64
));
573 copy_flock_fields(&fl
, kfl
);
574 if (copy_to_user(ufl
, &fl
, sizeof(struct compat_flock64
)))
578 #undef copy_flock_fields
581 convert_fcntl_cmd(unsigned int cmd
)
596 * GETLK was successful and we need to return the data, but it needs to fit in
597 * the compat structure.
598 * l_start shouldn't be too big, unless the original start + end is greater than
599 * COMPAT_OFF_T_MAX, in which case the app was asking for trouble, so we return
600 * -EOVERFLOW in that case. l_len could be too big, in which case we just
601 * truncate it, and only allow the app to see that part of the conflicting lock
602 * that might make sense to it anyway
604 static int fixup_compat_flock(struct flock
*flock
)
606 if (flock
->l_start
> COMPAT_OFF_T_MAX
)
608 if (flock
->l_len
> COMPAT_OFF_T_MAX
)
609 flock
->l_len
= COMPAT_OFF_T_MAX
;
613 COMPAT_SYSCALL_DEFINE3(fcntl64
, unsigned int, fd
, unsigned int, cmd
,
616 struct fd f
= fdget_raw(fd
);
623 if (unlikely(f
.file
->f_mode
& FMODE_PATH
)) {
624 if (!check_fcntl_cmd(cmd
))
628 err
= security_file_fcntl(f
.file
, cmd
, arg
);
634 err
= get_compat_flock(&flock
, compat_ptr(arg
));
637 err
= fcntl_getlk(f
.file
, convert_fcntl_cmd(cmd
), &flock
);
640 err
= fixup_compat_flock(&flock
);
642 err
= put_compat_flock(&flock
, compat_ptr(arg
));
646 err
= get_compat_flock64(&flock
, compat_ptr(arg
));
649 err
= fcntl_getlk(f
.file
, convert_fcntl_cmd(cmd
), &flock
);
651 err
= put_compat_flock64(&flock
, compat_ptr(arg
));
655 err
= get_compat_flock(&flock
, compat_ptr(arg
));
658 err
= fcntl_setlk(fd
, f
.file
, convert_fcntl_cmd(cmd
), &flock
);
664 err
= get_compat_flock64(&flock
, compat_ptr(arg
));
667 err
= fcntl_setlk(fd
, f
.file
, convert_fcntl_cmd(cmd
), &flock
);
670 err
= do_fcntl(fd
, cmd
, arg
, f
.file
);
678 COMPAT_SYSCALL_DEFINE3(fcntl
, unsigned int, fd
, unsigned int, cmd
,
690 return compat_sys_fcntl64(fd
, cmd
, arg
);
694 /* Table to convert sigio signal codes into poll band bitmaps */
696 static const long band_table
[NSIGPOLL
] = {
697 POLLIN
| POLLRDNORM
, /* POLL_IN */
698 POLLOUT
| POLLWRNORM
| POLLWRBAND
, /* POLL_OUT */
699 POLLIN
| POLLRDNORM
| POLLMSG
, /* POLL_MSG */
700 POLLERR
, /* POLL_ERR */
701 POLLPRI
| POLLRDBAND
, /* POLL_PRI */
702 POLLHUP
| POLLERR
/* POLL_HUP */
705 static inline int sigio_perm(struct task_struct
*p
,
706 struct fown_struct
*fown
, int sig
)
708 const struct cred
*cred
;
712 cred
= __task_cred(p
);
713 ret
= ((uid_eq(fown
->euid
, GLOBAL_ROOT_UID
) ||
714 uid_eq(fown
->euid
, cred
->suid
) || uid_eq(fown
->euid
, cred
->uid
) ||
715 uid_eq(fown
->uid
, cred
->suid
) || uid_eq(fown
->uid
, cred
->uid
)) &&
716 !security_file_send_sigiotask(p
, fown
, sig
));
721 static void send_sigio_to_task(struct task_struct
*p
,
722 struct fown_struct
*fown
,
723 int fd
, int reason
, int group
)
726 * F_SETSIG can change ->signum lockless in parallel, make
727 * sure we read it once and use the same value throughout.
729 int signum
= READ_ONCE(fown
->signum
);
731 if (!sigio_perm(p
, fown
, signum
))
737 /* Queue a rt signal with the appropriate fd as its
738 value. We use SI_SIGIO as the source, not
739 SI_KERNEL, since kernel signals always get
740 delivered even if we can't queue. Failure to
741 queue in this case _should_ be reported; we fall
742 back to SIGIO in that case. --sct */
743 si
.si_signo
= signum
;
747 * Posix definies POLL_IN and friends to be signal
748 * specific si_codes for SIG_POLL. Linux extended
749 * these si_codes to other signals in a way that is
750 * ambiguous if other signals also have signal
751 * specific si_codes. In that case use SI_SIGIO instead
752 * to remove the ambiguity.
754 if ((signum
!= SIGPOLL
) && sig_specific_sicodes(signum
))
755 si
.si_code
= SI_SIGIO
;
757 /* Make sure we are called with one of the POLL_*
758 reasons, otherwise we could leak kernel stack into
760 BUG_ON((reason
< POLL_IN
) || ((reason
- POLL_IN
) >= NSIGPOLL
));
761 if (reason
- POLL_IN
>= NSIGPOLL
)
764 si
.si_band
= band_table
[reason
- POLL_IN
];
766 if (!do_send_sig_info(signum
, &si
, p
, group
))
768 /* fall-through: fall back on the old plain SIGIO signal */
770 do_send_sig_info(SIGIO
, SEND_SIG_PRIV
, p
, group
);
774 void send_sigio(struct fown_struct
*fown
, int fd
, int band
)
776 struct task_struct
*p
;
781 read_lock(&fown
->lock
);
783 type
= fown
->pid_type
;
784 if (type
== PIDTYPE_MAX
) {
791 goto out_unlock_fown
;
793 read_lock(&tasklist_lock
);
794 do_each_pid_task(pid
, type
, p
) {
795 send_sigio_to_task(p
, fown
, fd
, band
, group
);
796 } while_each_pid_task(pid
, type
, p
);
797 read_unlock(&tasklist_lock
);
799 read_unlock(&fown
->lock
);
802 static void send_sigurg_to_task(struct task_struct
*p
,
803 struct fown_struct
*fown
, int group
)
805 if (sigio_perm(p
, fown
, SIGURG
))
806 do_send_sig_info(SIGURG
, SEND_SIG_PRIV
, p
, group
);
809 int send_sigurg(struct fown_struct
*fown
)
811 struct task_struct
*p
;
817 read_lock(&fown
->lock
);
819 type
= fown
->pid_type
;
820 if (type
== PIDTYPE_MAX
) {
827 goto out_unlock_fown
;
831 read_lock(&tasklist_lock
);
832 do_each_pid_task(pid
, type
, p
) {
833 send_sigurg_to_task(p
, fown
, group
);
834 } while_each_pid_task(pid
, type
, p
);
835 read_unlock(&tasklist_lock
);
837 read_unlock(&fown
->lock
);
841 static DEFINE_SPINLOCK(fasync_lock
);
842 static struct kmem_cache
*fasync_cache __read_mostly
;
844 static void fasync_free_rcu(struct rcu_head
*head
)
846 kmem_cache_free(fasync_cache
,
847 container_of(head
, struct fasync_struct
, fa_rcu
));
851 * Remove a fasync entry. If successfully removed, return
852 * positive and clear the FASYNC flag. If no entry exists,
853 * do nothing and return 0.
855 * NOTE! It is very important that the FASYNC flag always
856 * match the state "is the filp on a fasync list".
859 int fasync_remove_entry(struct file
*filp
, struct fasync_struct
**fapp
)
861 struct fasync_struct
*fa
, **fp
;
864 spin_lock(&filp
->f_lock
);
865 spin_lock(&fasync_lock
);
866 for (fp
= fapp
; (fa
= *fp
) != NULL
; fp
= &fa
->fa_next
) {
867 if (fa
->fa_file
!= filp
)
870 spin_lock_irq(&fa
->fa_lock
);
872 spin_unlock_irq(&fa
->fa_lock
);
875 call_rcu(&fa
->fa_rcu
, fasync_free_rcu
);
876 filp
->f_flags
&= ~FASYNC
;
880 spin_unlock(&fasync_lock
);
881 spin_unlock(&filp
->f_lock
);
885 struct fasync_struct
*fasync_alloc(void)
887 return kmem_cache_alloc(fasync_cache
, GFP_KERNEL
);
891 * NOTE! This can be used only for unused fasync entries:
892 * entries that actually got inserted on the fasync list
893 * need to be released by rcu - see fasync_remove_entry.
895 void fasync_free(struct fasync_struct
*new)
897 kmem_cache_free(fasync_cache
, new);
901 * Insert a new entry into the fasync list. Return the pointer to the
902 * old one if we didn't use the new one.
904 * NOTE! It is very important that the FASYNC flag always
905 * match the state "is the filp on a fasync list".
907 struct fasync_struct
*fasync_insert_entry(int fd
, struct file
*filp
, struct fasync_struct
**fapp
, struct fasync_struct
*new)
909 struct fasync_struct
*fa
, **fp
;
911 spin_lock(&filp
->f_lock
);
912 spin_lock(&fasync_lock
);
913 for (fp
= fapp
; (fa
= *fp
) != NULL
; fp
= &fa
->fa_next
) {
914 if (fa
->fa_file
!= filp
)
917 spin_lock_irq(&fa
->fa_lock
);
919 spin_unlock_irq(&fa
->fa_lock
);
923 spin_lock_init(&new->fa_lock
);
924 new->magic
= FASYNC_MAGIC
;
927 new->fa_next
= *fapp
;
928 rcu_assign_pointer(*fapp
, new);
929 filp
->f_flags
|= FASYNC
;
932 spin_unlock(&fasync_lock
);
933 spin_unlock(&filp
->f_lock
);
938 * Add a fasync entry. Return negative on error, positive if
939 * added, and zero if did nothing but change an existing one.
941 static int fasync_add_entry(int fd
, struct file
*filp
, struct fasync_struct
**fapp
)
943 struct fasync_struct
*new;
945 new = fasync_alloc();
950 * fasync_insert_entry() returns the old (update) entry if
953 * So free the (unused) new entry and return 0 to let the
954 * caller know that we didn't add any new fasync entries.
956 if (fasync_insert_entry(fd
, filp
, fapp
, new)) {
965 * fasync_helper() is used by almost all character device drivers
966 * to set up the fasync queue, and for regular files by the file
967 * lease code. It returns negative on error, 0 if it did no changes
968 * and positive if it added/deleted the entry.
970 int fasync_helper(int fd
, struct file
* filp
, int on
, struct fasync_struct
**fapp
)
973 return fasync_remove_entry(filp
, fapp
);
974 return fasync_add_entry(fd
, filp
, fapp
);
977 EXPORT_SYMBOL(fasync_helper
);
980 * rcu_read_lock() is held
982 static void kill_fasync_rcu(struct fasync_struct
*fa
, int sig
, int band
)
985 struct fown_struct
*fown
;
988 if (fa
->magic
!= FASYNC_MAGIC
) {
989 printk(KERN_ERR
"kill_fasync: bad magic number in "
993 spin_lock_irqsave(&fa
->fa_lock
, flags
);
995 fown
= &fa
->fa_file
->f_owner
;
996 /* Don't send SIGURG to processes which have not set a
997 queued signum: SIGURG has its own default signalling
999 if (!(sig
== SIGURG
&& fown
->signum
== 0))
1000 send_sigio(fown
, fa
->fa_fd
, band
);
1002 spin_unlock_irqrestore(&fa
->fa_lock
, flags
);
1003 fa
= rcu_dereference(fa
->fa_next
);
1007 void kill_fasync(struct fasync_struct
**fp
, int sig
, int band
)
1009 /* First a quick test without locking: usually
1010 * the list is empty.
1014 kill_fasync_rcu(rcu_dereference(*fp
), sig
, band
);
1018 EXPORT_SYMBOL(kill_fasync
);
1020 static int __init
fcntl_init(void)
1023 * Please add new bits here to ensure allocation uniqueness.
1024 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
1025 * is defined as O_NONBLOCK on some platforms and not on others.
1027 BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ !=
1029 (VALID_OPEN_FLAGS
& ~(O_NONBLOCK
| O_NDELAY
)) |
1030 __FMODE_EXEC
| __FMODE_NONOTIFY
));
1032 fasync_cache
= kmem_cache_create("fasync_cache",
1033 sizeof(struct fasync_struct
), 0, SLAB_PANIC
, NULL
);
1037 module_init(fcntl_init
)