linux_misc.c (fd745e1db6b561900b8e5e9caa4ed05cf15398b3) | linux_misc.c (8340b03425cfa61ec17ad6a9b576590df3afd509) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2002 Doug Rabson 5 * Copyright (c) 1994-1995 Søren Schmidt 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 2541 unchanged lines hidden (view full) --- 2550 /* 2551 * Ignore unknown operations, just like Linux kernel built 2552 * without CONFIG_SECCOMP. 2553 */ 2554 return (EINVAL); 2555 } 2556} 2557 | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2002 Doug Rabson 5 * Copyright (c) 1994-1995 Søren Schmidt 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 2541 unchanged lines hidden (view full) --- 2550 /* 2551 * Ignore unknown operations, just like Linux kernel built 2552 * without CONFIG_SECCOMP. 2553 */ 2554 return (EINVAL); 2555 } 2556} 2557 |
2558#ifndef COMPAT_LINUX32 | 2558/* 2559 * Custom version of exec_copyin_args(), to copy out argument and environment 2560 * strings from the old process address space into the temporary string buffer. 2561 * Based on freebsd32_exec_copyin_args. 2562 */ 2563static int 2564linux_exec_copyin_args(struct image_args *args, const char *fname, 2565 enum uio_seg segflg, l_uintptr_t *argv, l_uintptr_t *envv) 2566{ 2567 char *argp, *envp; 2568 l_uintptr_t *ptr, arg; 2569 int error; 2570 2571 bzero(args, sizeof(*args)); 2572 if (argv == NULL) 2573 return (EFAULT); 2574 2575 /* 2576 * Allocate demand-paged memory for the file name, argument, and 2577 * environment strings. 2578 */ 2579 error = exec_alloc_args(args); 2580 if (error != 0) 2581 return (error); 2582 2583 /* 2584 * Copy the file name. 2585 */ 2586 error = exec_args_add_fname(args, fname, segflg); 2587 if (error != 0) 2588 goto err_exit; 2589 2590 /* 2591 * extract arguments first 2592 */ 2593 ptr = argv; 2594 for (;;) { 2595 error = copyin(ptr++, &arg, sizeof(arg)); 2596 if (error) 2597 goto err_exit; 2598 if (arg == 0) 2599 break; 2600 argp = PTRIN(arg); 2601 error = exec_args_add_arg(args, argp, UIO_USERSPACE); 2602 if (error != 0) 2603 goto err_exit; 2604 } 2605 2606 /* 2607 * This comment is from Linux do_execveat_common: 2608 * When argv is empty, add an empty string ("") as argv[0] to 2609 * ensure confused userspace programs that start processing 2610 * from argv[1] won't end up walking envp. 2611 */ 2612 if (args->argc == 0 && 2613 (error = exec_args_add_arg(args, "", UIO_SYSSPACE) != 0)) 2614 goto err_exit; 2615 2616 /* 2617 * extract environment strings 2618 */ 2619 if (envv) { 2620 ptr = envv; 2621 for (;;) { 2622 error = copyin(ptr++, &arg, sizeof(arg)); 2623 if (error) 2624 goto err_exit; 2625 if (arg == 0) 2626 break; 2627 envp = PTRIN(arg); 2628 error = exec_args_add_env(args, envp, UIO_USERSPACE); 2629 if (error != 0) 2630 goto err_exit; 2631 } 2632 } 2633 2634 return (0); 2635 2636err_exit: 2637 exec_free_args(args); 2638 return (error); 2639} 2640 |
2559int 2560linux_execve(struct thread *td, struct linux_execve_args *args) 2561{ 2562 struct image_args eargs; 2563 int error; 2564 2565 LINUX_CTR(execve); 2566 | 2641int 2642linux_execve(struct thread *td, struct linux_execve_args *args) 2643{ 2644 struct image_args eargs; 2645 int error; 2646 2647 LINUX_CTR(execve); 2648 |
2567 error = exec_copyin_args(&eargs, args->path, UIO_USERSPACE, | 2649 error = linux_exec_copyin_args(&eargs, args->path, UIO_USERSPACE, |
2568 args->argp, args->envp); 2569 if (error == 0) 2570 error = linux_common_execve(td, &eargs); 2571 AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); 2572 return (error); 2573} | 2650 args->argp, args->envp); 2651 if (error == 0) 2652 error = linux_common_execve(td, &eargs); 2653 AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); 2654 return (error); 2655} |
2574#endif | |