From nobody Mon Sep 18 21:12:57 2023 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RqHZM0PHKz4tlqq for ; Mon, 18 Sep 2023 21:12:59 +0000 (UTC) (envelope-from rockyhotas@post.com) Received: from mout.gmx.com (mout.gmx.com [74.208.4.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.gmx.com", Issuer "GeoTrust TLS RSA CA G1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RqHZL37Mwz4Sg4 for ; Mon, 18 Sep 2023 21:12:58 +0000 (UTC) (envelope-from rockyhotas@post.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=post.com header.s=s1089575 header.b=cM42U1B2; spf=pass (mx1.freebsd.org: domain of rockyhotas@post.com designates 74.208.4.201 as permitted sender) smtp.mailfrom=rockyhotas@post.com; dmarc=pass (policy=none) header.from=post.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=post.com; s=s1089575; t=1695071577; x=1695676377; i=rockyhotas@post.com; bh=Jhg0U+RWt+M4yGIm4UQd+e959j7RQ5yXT5UCygYCD3U=; h=X-UI-Sender-Class:From:To:Subject:Date; b=cM42U1B2sB5/oIAENWdeve9dhqJE90hPYT46Wc0BJR7klJQpC6Bsm+FSBvqK6vFLFQJkev47JLy Q/dahKLvzbnwNQ58VvDkjdjCqIOPzZYoScAQeWLJ/zj4Kd30Eau4YKi8OM4lYHvrq652qbjOWLG1H qfxIyCtyYUV/yLpWYGrr3QB9HxPF3JIZ7cnqwp43hpgOzC3FV3nEuS77tAQIcd28aH5ZOT/neGC43 ziFeRucPC0tnG2jZ2rNOKPn0vNDsIbaD7BbL8KpMNP+HePJXa88QagVxWxtxxf4uty8oQzXRIIsHF cv7aKh4Gfxdzvo864S4C+qJQzI0VEpFIDG5A== X-UI-Sender-Class: f2cb72be-343f-493d-8ec3-b1efb8d6185a Received: from [91.81.140.147] ([91.81.140.147]) by web-mail.mail.com (3c-app-mailcom-lxa16.server.lan [10.76.45.17]) (via HTTP); Mon, 18 Sep 2023 23:12:57 +0200 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Message-ID: From: Rocky Hotas To: freebsd-hackers@FreeBSD.org Subject: Error while building a kernel module with mkdir(2) Content-Type: text/plain; charset=UTF-8 Date: Mon, 18 Sep 2023 23:12:57 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:h/E0rrLeuR3+5mXQDP4VCT9JnACJfO805Ms8bfla7mQPmdW691XOtgfYMx1fqUoxTXmj1 Ih9nwK0VIYYkI7kyiyzpAvrJLtc76GtkAylZsyTlqjaflHaXw/ebMKoQVE8fPhbcQBg8VHSKXp9b TlLeiJRj97x1AuXRx2IjLzrO8IQfD6iUokDXbHLaLekTGe5hUKjgJIsjOzg40iWj4DhUVI2HOlQR szreoEKKi/dWoG9QygxPk6gak6T3FZvuSTrKBxN/SH41KFCWiIbDD4xF+JJX/ZTeTaIMwfT41wQz kU= X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:1RcXozQnmcg=;D2gAldtroJHrxm2/1eUv8RrN24S njH38MPeeaPStZjwDXmGorCKiohhZamJ7aVY5NSXGPCt/YVflwk0nryFIiqTYe4c0AMQppM/Y YTcO6ozWNGG5Fd+1B1EE4C49JbtNkmXqkG3bs0GwWr5tbGwotwK4TOLeusGpEAkPek2JxPR3q TjdaTM2DopAJ+VyEbSyBlqu9VBPX3y5P1JbQXNutclFaC1C39If36NqKw0PxoQVXNn3CULyIR sp8ghlUQmefR+2JHB2f9uCaxM2XeTIs0rPbSTN/0UGF4qcTHBD5kp9NjPVE8mRyTl1piAES4a fVlybwS0oP4sdCveLCJuhnSmSQfElRrMEr6CXzlvnOqS/39rygciI5MG7jzQb3PSMNfm6BXxI JMVV17EyAKmc9YDZFPCD6n7dC+5iuWCO9U+fCSkvNUPORWHASU96KwO7cgujA8RGklceo8hdc v6O5EMDVIvlZ4YYJZhRXrWBWuLZ9F1LwEinN9C2A6tH6lalLkDEFbsEM2N6Lgg6rmwZ1WpR5k gOHRuFX0J0i5uVwY34P1HpiUTlZ1bfgKPWoJGV1pCRIBbdcsVHgOsUMKr9sA30Ao8bqDdKML+ uPKx7+Vh8Kx66vCxXI5iL9fnamoitx6r+mnlD2S6XOuVTWcxcCT/qoHEfkTrDlgJ0/tSo4xIK 3pzhAAlWqzbEVA6XxxhbCZlNmKerckma5irRMcYHoIL3qkz9DEHADLzfawgbFyciT1eqz0Qld IHoWUyvLsjbQu4eRwzd+QARYqbatgRtrXE6Gk2ywmRW1U+lsId24dI6dT46sQ0rw7XJ65RFXB Ed8rqCTG63i0Df27cNOrVx7w== X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.44 / 15.00]; NEURAL_HAM_MEDIUM(-0.99)[-0.994]; NEURAL_HAM_LONG(-0.98)[-0.978]; NEURAL_HAM_SHORT(-0.97)[-0.965]; MID_RHS_NOT_FQDN(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[post.com,none]; R_DKIM_ALLOW(-0.20)[post.com:s=s1089575]; R_SPF_ALLOW(-0.20)[+ip4:74.208.4.192/26]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[74.208.4.201:from]; ONCE_RECEIVED(0.10)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[post.com:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MLMMJ_DEST(0.00)[freebsd-hackers@FreeBSD.org]; BLOCKLISTDE_FAIL(0.00)[91.81.140.147:server fail,74.208.4.201:server fail]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; HAS_X_PRIO_THREE(0.00)[3]; ASN(0.00)[asn:8560, ipnet:74.208.0.0/16, country:DE]; FREEMAIL_ENVFROM(0.00)[post.com]; RCVD_TLS_LAST(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[74.208.4.201:from]; RCVD_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; FREEMAIL_FROM(0.00)[post.com] X-Rspamd-Queue-Id: 4RqHZL37Mwz4Sg4 Hello! I hope this is the right ML to discuss about this issue. I am trying to build the example kernel module presented in paragraph 2.1 of Designing BSD Rootkits: An Introduction to Kernel Hacking by Joseph Kong However, I get this error: mkdir_hook.c:42:9: error: implicit declaration of function 'mkdir' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return(mkdir(td, syscall_args)); ^ mkdir_hook.c:57:45: error: use of undeclared identifier 'mkdir' sysent[SYS_mkdir].sy_call = (sy_call_t *)mkdir; mkdir(2) requires `#include ' and I added it (while it was not in the code from the book), but nothing changes. What's still wrong? After this text, I paste the code and the Makefile (written following https://docs.freebsd.org/en/books/arch-handbook/driverbasics/). Bye! Rocky === code: mkdir_hook.c === #include #include /* defines used in kernel.h */ #include #include #include #include /* types used in module initialization */ #include /* uprintf */ #include #include #include /* mkdir(2) */ /* mkdir system call hook. */ static int mkdir_hook(struct thread *td, void *syscall_args) { struct mkdir_args /* { char *path; int mode; } */ *uap; uap = (struct mkdir_args *)syscall_args; char path[255]; size_t done; int error; error = copyinstr(uap->path, path, 255, &done); if (error != 0) return(error); /* Print a debug message. */ uprintf("The directory \"%s\" will be created with the following" " permissions: %o\n", path, uap->mode); return(mkdir(td, syscall_args)); } /* The function called at load/unload. */ static int load(struct module *module, int cmd, void *arg) { int error = 0; switch (cmd) { case MOD_LOAD: /* Replace mkdir with mkdir_hook. */ sysent[SYS_mkdir].sy_call = (sy_call_t *)mkdir_hook; break; case MOD_UNLOAD: /* Change everything back to normal. */ sysent[SYS_mkdir].sy_call = (sy_call_t *)mkdir; break; default: error = EOPNOTSUPP; break; } return(error); } static moduledata_t mkdir_hook_mod = { "mkdir_hook", /* module name */ load, /* event handler */ NULL /* extra data */ }; DECLARE_MODULE(mkdir_hook, mkdir_hook_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); === Makefile === KMOD=mkdir_hook SRCS=mkdir_hook.c .include