Commit Graph

30 Commits

Author SHA1 Message Date
2b6e074846 Update copyright headers
Headers updated automatically using maint/update_copyright_years.sh
script.
2018-06-14 11:00:00 +00:00
Eugene Syromyatnikov
22aa768c1d keyctl: print KEYCTL_SET_REQKEY_KEYRING argument as an integer
* xlat/key_reqkeys.in: Add #val_type int.
* keyctl.c (SYS_FUNC(keyctl)) <case KEYCTL_SET_REQKEY_KEYRING>: Print
arg2 as an integer.
* tests/keyctl.c: Update expected output.
2018-05-25 09:15:03 +00:00
Eugene Syromyatnikov
4105c9fb5d keyctl: respect xlat style when printing errno
* keyctl.c (keyctl_reject_key): Use print_xlat_ex for printing error
argument.
2018-05-25 09:15:03 +00:00
Eugene Syromyatnikov
942033a35e keyctl: use printxval_d for printing keyring serial number
* keyctl.c (print_keyring_serial_number): Use printxval_d instead of
looking up and printing xlat value manually.
* xlat/key_spec.in: Add "#val_type int" so the xlat values have sign
bit propagated.
2018-04-27 00:56:25 +00:00
Eugene Syromyatnikov
46a4dcf4c3 keyctl: add support for KDF parameters decoding in KEYCTL_DH_COMPUTE
* fetch_struct_keyctl_kdf_params.c: New file.
* keyctl_kdf_params.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* configure.ac: Add check for struct keyctl_kdf_params presence in
<linux/keyctl.h>.
* defs.h (struct strace_keyctl_kdf_params): Add forward declaration.
* keyctl.c (keyctl_dh_compute): Add new parameter kdf_addr, print it
on exiting.
(SYS_FUNC(keyctl)) <case KEYCTL_DH_COMPUTE>: Pass arg5 to
keyctl_dh_compute.
* tests/keyctl.c: Include assert.h.
(struct keyctl_kdf_params) [!HAVE_STRUCT_KEYCTL_KDF_PARAMS]: New
definition.
(STR32): New definition, copied from ioctl_dm.c.
(append_str, kckdfp_to_str): New functions.
(main): Update expected output, add checks for struct keyctl_kdf_params
decoding.
2017-09-02 21:48:14 +00:00
6f51a6d00d keyctl: add support for KEYCTL_RESTRICT_KEYRING operation
* keyctl.c (keyctl_restrict_keyring): New function.
(SYS_FUNC(keyctl)): Use it to implement KEYCTL_RESTRICT_KEYRING support.
* NEWS: Mention this.
* tests/keyctl.c (main): Check KEYCTL_RESTRICT_KEYRING decoding.
2017-07-21 11:07:55 +00:00
Eugene Syromyatnikov
9d095c7860 Add copyright headers 2017-05-22 17:33:51 +00:00
50b50e78f6 Remove getarg_klu
After transition from long to kernel_ulong_t we no longer need
tcp->ext_arg, and therefore a function to access it is also no longer
needed.

* defs.h (getarg_klu): Remove prototype.
* util.c (getarg_klu): Remove.
(printargs): Access tcp->u_arg directly
* bjm.c (SYS_FUNC(init_module)): Likewise.
* clone.c (SYS_FUNC(unshare)): Likewise.
* fadvise.c (SYS_FUNC(fadvise64)): Likewise.
* kcmp.c (SYS_FUNC(kcmp)): Likewise.
* kexec.c (SYS_FUNC(kexec_file_load)): Likewise.
* keyctl.c (SYS_FUNC(keyctl)): Likewise.
* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Likewise.
* mem.c (do_mprotect): Likewise.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Likewise.
* pkeys.c (SYS_FUNC(pkey_alloc)): Likewise.
* prctl.c (print_prctl_args, SYS_FUNC(prctl), SYS_FUNC(arch_prctl)):
Likewise.
2016-12-26 10:43:35 +00:00
89636759d7 Automatically replace PRI_kr[dux] with PRI_kl[dux]
Remove temporary macros created for transition from long
to kernel_ulong_t.

Automatically replace PRI_kr[dux] with PRI_kl[dux] using
$ git grep -l 'PRI_kr[dux]' | xargs sed -ri 's/PRI_kr([dux])/PRI_kl\1/g'

* defs.h (PRI_krd, PRI_kru, PRI_krx): Remove.  All users updated.
2016-12-26 10:43:34 +00:00
1d5bb61c49 Print kernel_ureg_t and kernel_scno_t using dedicated format strings
Prepare for the change of kernel_ureg_t and kernel_scno_t from
unsigned long to kernel_ulong_t.

* defs.h (PRI_krd, PRI_kru, PRI_krx): New temporary macros.
All users updated.
2016-12-26 10:43:04 +00:00
a940d1a60f printstr: rename to printstrn, add printstr as a thin wrapper
As about half of all printstr uses cases are invocations with the last
argument set to -1, create a dedicated function for this use case.

* defs.h (printstr): Rename to printstrn.  All callers updated.
(printstr): New static inline function.  All callers updated.
2016-12-25 11:32:45 +00:00
a2485b86e7 Use kernel_ulong_t instead of unsigned long long where appropriate
* defs.h (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t.  All callers updated.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t.  All callers updated.
(PRI_kl, PRI_kld, PRI_klu, PRI_klx): New macros.
* bjm.c (SYS_FUNC(init_module)): Print kernel_ulong_t type using
PRI_klu format.
* desc.c (SYS_FUNC(pselect6)): Likewise.
* fadvise.c (SYS_FUNC(fadvise64)): Likewise.
* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Likewise.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Likewise.
* kcmp.c (SYS_FUNC(kcmp)): Print kernel_ulong_t type using
PRI_klx format.
* keyctl.c (SYS_FUNC(keyctl)): Likewise.
* pkeys.c (SYS_FUNC(pkey_alloc)): Likewise.
* prctl.c (print_prctl_args, SYS_FUNC(prctl), SYS_FUNC(arch_prctl)):
Print kernel_ulong_t type using PRI_kld, PRI_klu, or PRI_klx format.
* util.c (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.
2016-12-19 19:58:16 +00:00
f55ef46feb Include "kernel_types.h" in defs.h and tests/tests.h
As kernel_ulong_t type is going to be used in the definition
of struct tcb and in many function prototypes, make it readily
available for every source file by including "kernel_types.h"
in defs.h and tests/tests.h files.

* defs.h: Include "kernel_types.h".
* tests/tests.h: Likewise.
* desc.c: Do not include "kernel_types.h".
* dirent.c: Likewise.
* keyctl.c: Likewise.
* syscall.c: Likewise.
* linux/asm_stat.h: Likewise.
* tests/answer.c: Likewise.
* tests/epoll_pwait.c: Likewise.
* tests/fanotify_init.c: Likewise.
* tests/fanotify_mark.c: Likewise.
* tests/file_handle.c: Likewise.
* tests/ftruncate.c: Likewise.
* tests/getdents.c: Likewise.
* tests/init_delete_module.h: Likewise.
* tests/inotify.c: Likewise.
* tests/inotify_init1.c: Likewise.
* tests/ioprio.c: Likewise.
* tests/ipc_msgbuf.c: Likewise.
* tests/kcmp.c: Likewise.
* tests/kexec_file_load.c: Likewise.
* tests/kexec_load.c: Likewise.
* tests/keyctl.c: Likewise.
* tests/lookup_dcookie.c: Likewise.
* tests/lseek.c: Likewise.
* tests/mq_sendrecv.c: Likewise.
* tests/nsyscalls.c: Likewise.
* tests/pkey_alloc.c: Likewise.
* tests/pkey_free.c: Likewise.
* tests/pkey_mprotect.c: Likewise.
* tests/prctl-pdeathsig.c: Likewise.
* tests/prctl-tsc.c: Likewise.
* tests/preadv2-pwritev2.c: Likewise.
* tests/process_vm_readv_writev.c: Likewise.
* tests/read-write.c: Likewise.
* tests/setfsugid.c: Likewise.
* tests/setns.c: Likewise.
* tests/truncate.c: Likewise.
* tests/unshare.c: Likewise.
* tests/xgetrlimit.c: Likewise.
2016-12-16 12:01:44 +00:00
Eugene Syromyatnikov
27aaa29d73 keyctl: use kernel_ulong_t and getarg_ull instead of long
This potentially fixes keyctl decoder for x32 personality.

* keyctl.c (keyctl_update_key, keyctl_read_key, keyctl_instantiate_key,
keyctl_instantiate_key_iov, keyctl_dh_compute): Change addr and len
arguments to kernel_ulong_t.  Print len using %llu format.
(keyctl_keyring_search): Change addr1 and addr2 arguments
to kernel_ulong_t.
(print_dh_params): Change addr argument to kernel_ulong_t.
(SYS_FUNC(keyctl)): Retrieve arguments via getarg_ull, pass them
to the appropriate handlers.
2016-10-03 23:48:48 +00:00
Eugene Syromyatnikov
66db159f7e keyctl: fix parameter signedness
* keyctl.c (keyctl_update_key): Change addr and len arguments
to unsigned.
(keyctl_read_key): Likewise.
(keyctl_instantiate_key): Likewise.
(keyctl_instantiate_key_iov): Likewise.
(keyctl_dh_compute): Likewise.
(keyctl_keyring_search): Change addr1 and addr2 arguments to unsigned.
(keyctl_chown_key): Change user and group arguments to unsigned.
(keyctl_get_persistent): Change uid argument to unsigned.
2016-10-03 21:50:45 +00:00
Eugene Syromyatnikov
9f294b39f5 keyctl: use printstr_ex for printing out buffer
keyctl_read_key had subtle bug by treating out buffer in KEYCTL_READ
as NUL-terminated, which is not true.  We fix it by adding parameter to
keyctl_read_key signalising whether buffer is NUL-terminated and using
printstr_ex for printing (expectedly) NUL-terminated strings.

* keyctl.c (keyctl_read_key): Add has_nul parameter.  Do not use -1 as
string len.  Use printstr_ex for buffer output with user style depending
on has_nul value.
(SYS_FUNC(keyctl)): Specify has_nul parameter to keyctl_read_key
by comparing cmd value with KEYCTL_READ.
2016-10-03 21:50:45 +00:00
Eugene Syromyatnikov
04ec08ab62 keyctl: add support for KEYCTL_DH_COMPUTE
* keyctl.c (struct keyctl_dh_params): New structure.
(print_dh_params, keyctl_dh_compute): New functions.
(SYS_FUNC(keyctl)): Add support for KEYCTL_DH_COMPUTE cmd value.
2016-10-03 19:27:38 +00:00
Eugene Syromyatnikov
7211bdb982 keyctl: print errno name in KEYCTL_REJECT in case it is available
* keyctl.c (keyctl_reject_key): Get errno string via err_name
and print it if it is not NULL.
2016-10-03 12:03:03 +00:00
Eugene Syromyatnikov
7fa26e1712 keyctl: do not print comma for KEYCTL_SESSION_TO_PARENT command
Since this command doesn't have any additional arguments, the comma does
not needed.  Since this is the only command which lacks additional
arguments, it's better to add special case for it rather than add
printing of comma to all other commands.

* keyctl.c (SYS_FUNC(keyctl)): Add check for command not being
KEYCTL_SESSION_TO_PARENT when printing comma dividing cmd argument
from the rest.
2016-10-02 19:19:15 +00:00
Eugene Syromyatnikov
f5278a7d94 keyctl: use getarg_ull for printing generic arguments
Otherwise it is erroneous on x32, for example.

* keyctl.c (SYS_FUNC(keyctl)): Use "%#llx" conversion specifier
and getarg_ull for fallback argument printing.
2016-10-02 19:19:15 +00:00
Eugene Syromyatnikov
db098f9a3d keyctl: use printuid for printing UID/GID
UID/GID are unsigned except special -1 value (which is also special in
context of specific keyctl commands), so special printing function
should be used.

* keyctl.c (keyctl_chown_key, keyctl_get_persistent): Use printuid
instead of printf with "%d" conversion for printing UID/GID.
2016-10-02 19:19:15 +00:00
Fabien Siron
2a54d8b257 Add a enum for decoding to tprint_iov() and tprint_iov_upto()
Introduce a new type iov_decode which will be used instead of the integer
"decode" as a parameter.

* defs.h (iov_decode): New enum.
(tprint_iov, tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
* aio.c (print_iocb): Change type of "decode_iov" to enum iov_decode in
tprint_iov() call.
* keyctl.c (keyctl_instantiate_key_iov): Likewise.
* process.c (ptrace): Likewise.
* process_vm.c (process_vm_readv, process_vm_writev): Likewise.
* io.c (writev, do_pwritev, vmsplice): Likewise.
(print_iovec): Replace the condition with a switch.
(tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
(readv, do_preadv): Change type of "decode_iov" to enum iov_decode in
tprint_iov_upto() call.
* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res): Likewise.
* net.c (do_msghdr): Adapt call of tprint_iov_upto().
2016-06-22 14:40:57 +00:00
9134aab407 Prepare for transition from xlookup64 to xlookup
* fcntl.c (print_fcntl, SYS_FUNC(fcntl), SYS_FUNC(fcntl64)):
Cast 2nd argument of xlookup to unsigned long.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* sched.c (SYS_FUNC(sched_getscheduler)): Likewise.
* time.c (do_adjtimex): Likewise.
* ioprio.c (sprint_ioprio): Change type of the argument
and local variables from int to unsigned int.
* keyctl.c (print_keyring_serial_number): Cast 2nd argument
of xlookup to unsigned int.
* net.c (tprint_sock_type): Change type of the argument to unsigned int.
* printmode.c (sprintmode): Likewise.
* printsiginfo.c (printsigval):  Change type of si_code argument
to unsigned int.
2016-05-14 22:05:06 +00:00
38a34c9349 Add copyright headers to some files which lack them
Before this change, all files that exist since 20th century had
copyright headers, while most files that appeared later didn't.  This
change fixes the inconsistency by adding missing copyright headers.

It doesn't mean that copyright headers became maintained.  In my view,
git history provides much better information on this subject and is much
more accurate than copyright headers.
2015-12-17 17:56:48 +00:00
4eef291671 keyctl.c: make use of RVAL_DECODED
* keyctl.c (sys_add_key, sys_request_key): Update for RVAL_DECODED.
(keyctl_join_session_keyring, keyctl_handle_key,
keyctl_set_reqkey_keyring): Remove.
(keyctl_get_keyring_id, keyctl_update_key, keyctl_handle_key_key,
keyctl_read_key, keyctl_keyring_search, keyctl_chown_key,
keyctl_instantiate_key, keyctl_instantiate_key_iov, keyctl_negate_key,
keyctl_reject_key, keyctl_set_timeout, keyctl_get_persistent,
keyctl_setperm_key): Change to return void.
Update for RVAL_DECODED.
(sys_keyctl): Update callers.  Update for RVAL_DECODED.
2015-07-20 01:42:01 +00:00
5f6ca3d475 keyctl.c: use printaddr
* keyctl.c (keyctl_read_key): Use printaddr.
2015-07-20 01:42:01 +00:00
a0bd3749fc Declare syscall parsers using SYS_FUNC macro
Introduce SYS_FUNC macro to declare and define all syscall parsers.

* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sys_func.h.
(sys_func.h): New rule.
* defs.h (SYS_FUNC_NAME, SYS_FUNC): New macros.
* linux/syscall.h: Include "sys_func.h".
[NEED_UID16_PARSERS]: Use SYS_FUNC to declare uid16 syscall parsers.
Remove other declarations.
* linux/alpha/syscallent.h (160, 161): Add sys_ prefix to osf_statfs
and osf_fstatfs syscall parsers.
* *.c: Use SYS_FUNC to define syscall parsers.
2015-04-07 11:22:49 +00:00
2094573930 Remove linux/keyctl.h
* linux/keyctl.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* keyctl.c: Do not include <linux/keyctl.h>.
* xlat/key_perms.in: Add default values.
* xlat/key_reqkeys.in: Likewise.
* xlat/key_spec.in: Likewise.
* xlat/keyctl_commands.in: Likewise.
2015-02-19 21:42:31 +00:00
0ed617bd66 Generate xlat/*.in files
Automatically convert xlat structures from *.c files to xlat/*.in files
using "./generate_xlat_in.sh *.c" command.
2014-05-30 21:40:03 +00:00
3acf4035ea Implement add_key, keyctl, and request_key decoding
* keyctl.c: New file.
* linux/keyctl.h: Likewise.
* Makefile.am (strace_SOURCES): Add keyctl.c.
(EXTRA_DIST): Add linux/keyctl.h.
* linux/dummy.h (sys_add_key, sys_keyctl, sys_request_key): Remove.
* linux/syscall.h (sys_add_key, sys_keyctl, sys_request_key): New
prototypes.
2014-02-05 23:41:50 +00:00