Server IP : 103.169.32.36 / Your IP : 216.73.217.13 Web Server : Apache System : Linux web.dpmptsp 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : apache ( 48) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/opt/eset/efs/eventd/eset_rtp/ |
Upload File : |
| Current File : /var/opt/eset/efs/eventd/eset_rtp/ertp_handlers_close.c |
/*
* eset_rtp (ESET Real-time file system protection module)
* Copyright (C) 1992-2023 ESET, spol. s r.o.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* In case of any questions, you can contact us at ESET, spol. s r.o., Einsteinova 24, 851 01 Bratislava, Slovakia.
*/
#include <linux/file.h>
#include <linux/namei.h>
#include "ertp_event_check.h"
#include "ertp_ftrace_utils.h"
#include "ertp_handlers_close.h"
#include "ertp_logs.h"
#include "ertp_path.h"
#ifdef ERTP_KERNEL_USES_SYSCALL_WRAPPER
sys_regs_t ertp_original_native_64_close;
sys_regs_t ertp_original_native_32_close;
sys_regs_t ertp_original_native_64_dup2;
sys_regs_t ertp_original_native_32_dup2;
sys_regs_t ertp_original_native_64_dup3;
sys_regs_t ertp_original_native_32_dup3;
#else
sys_close_t ertp_original_native_64_close;
sys_dup2_t ertp_original_native_64_dup2;
sys_dup3_t ertp_original_native_64_dup3;
#endif
static void check_close(unsigned int fd) {
struct file *file = fget(fd);
if (file) {
ertp_check_close(file);
fput(file);
} else {
ertp_pr_log(ERTP_LOG_CLOSE, "cannot get file object for file descriptor %d",
fd);
}
}
#ifdef ERTP_KERNEL_USES_SYSCALL_WRAPPER
asmlinkage long notrace ertp_handler_native_64_close(struct pt_regs *regs) {
unsigned int fd = ERTP_SYSCALL64_ARG0(unsigned int, regs);
long ret = 0;
check_close(fd);
ret = ertp_original_native_64_close(regs);
ertp_handler_end();
return ret;
}
asmlinkage long notrace ertp_handler_native_32_close(struct pt_regs *regs) {
unsigned int fd = ERTP_SYSCALL32_ARG0(unsigned int, regs);
long ret = 0;
check_close(fd);
ret = ertp_original_native_32_close(regs);
ertp_handler_end();
return ret;
}
#else
asmlinkage long notrace ertp_handler_native_64_close(unsigned int fd) {
long ret;
check_close(fd);
ret = ertp_original_native_64_close(fd);
ertp_handler_end();
return ret;
}
#endif
#ifdef ERTP_KERNEL_USES_SYSCALL_WRAPPER
asmlinkage long notrace ertp_handler_native_64_dup2(struct pt_regs *regs) {
unsigned int newfd = ERTP_SYSCALL64_ARG1(unsigned int, regs);
long ret = 0;
check_close(newfd);
ret = ertp_original_native_64_dup2(regs);
ertp_handler_end();
return ret;
}
asmlinkage long notrace ertp_handler_native_32_dup2(struct pt_regs *regs) {
unsigned int newfd = ERTP_SYSCALL32_ARG1(unsigned int, regs);
long ret = 0;
check_close(newfd);
ret = ertp_original_native_32_dup2(regs);
ertp_handler_end();
return ret;
}
#else
asmlinkage long notrace ertp_handler_native_64_dup2(unsigned int oldfd,
unsigned int newfd) {
long ret;
check_close(newfd);
ret = ertp_original_native_64_dup2(oldfd, newfd);
ertp_handler_end();
return ret;
}
#endif
#ifdef ERTP_KERNEL_USES_SYSCALL_WRAPPER
asmlinkage long notrace ertp_handler_native_64_dup3(struct pt_regs *regs) {
unsigned int newfd = ERTP_SYSCALL64_ARG1(unsigned int, regs);
long ret = 0;
check_close(newfd);
ret = ertp_original_native_64_dup3(regs);
ertp_handler_end();
return ret;
}
asmlinkage long notrace ertp_handler_native_32_dup3(struct pt_regs *regs) {
unsigned int newfd = ERTP_SYSCALL32_ARG1(unsigned int, regs);
long ret = 0;
check_close(newfd);
ret = ertp_original_native_32_dup3(regs);
ertp_handler_end();
return ret;
}
#else
asmlinkage long notrace ertp_handler_native_64_dup3(unsigned int oldfd,
unsigned int newfd,
int flags) {
long ret;
check_close(newfd);
ret = ertp_original_native_64_dup3(oldfd, newfd, flags);
ertp_handler_end();
return ret;
}
#endif