paxctld-1.2.1/0000755000000000000000000000000012744700466011662 5ustar rootrootpaxctld-1.2.1/paxctld.c0000644000000000000000000003132012744700466013464 0ustar rootroot/* * Copyright 2012-2016 Open Source Security, Inc. * * This file is part of paxctld. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define DEFAULT_PAXCTLD_CONF "/etc/paxctld.conf" #define DEFAULT_PAXCTLD_CONF_DIR "/etc/paxctld.d" #define MAX_CONFIG_ENTRIES 16384 #define INOTIFY_FLAGS (IN_DONT_FOLLOW | IN_ATTRIB | IN_CREATE | IN_DELETE_SELF | IN_MOVE_SELF | IN_MOVED_TO) #define DIR_INOTIFY_FLAGS (INOTIFY_FLAGS &~ IN_ATTRIB) #define PAX_PAGEEXEC_ON 0x00000001 #define PAX_SEGMEXEC_ON 0x00000002 #define PAX_MPROTECT_ON 0x00000004 #define PAX_ASLR_ON 0x00000008 #define PAX_EMUTRAMP_ON 0x00000010 #define PAX_DEFAULT_FLAGS \ (PAX_PAGEEXEC_ON|PAX_SEGMEXEC_ON|PAX_MPROTECT_ON|PAX_ASLR_ON) struct conf_entry { char *requested_path; char *existing_path; unsigned int pax_flags; int watch_id; int nonroot; }; struct paxctld_config { struct conf_entry *entries; unsigned int count; }; static struct paxctld_config config; static int ino = -1; static int do_daemonize; static char *pidfile; static int quiet; #define gr_syslog(level, ...) do { \ if (!quiet) { \ if (do_daemonize) \ syslog(level, ## __VA_ARGS__); \ else \ fprintf(stderr, ## __VA_ARGS__); \ } \ } while (0) static char *gr_strdup(const char *str) { char *ret = strdup(str); if (ret == NULL) { fprintf(stderr, "Unable to allocate memory.\n"); exit(EXIT_FAILURE); } return ret; } static void decode_pax_flags(unsigned int flags, char *buf) { buf[0] = '\0'; if (!(flags & PAX_EMUTRAMP_ON)) strcat(buf, "e"); if (!(flags & PAX_PAGEEXEC_ON)) strcat(buf, "p"); if (!(flags & PAX_SEGMEXEC_ON)) strcat(buf, "s"); if (!(flags & PAX_MPROTECT_ON)) strcat(buf, "m"); if (!(flags & PAX_ASLR_ON)) strcat(buf, "r"); } static unsigned int encode_pax_flags(const char *conf) { unsigned int ret = PAX_DEFAULT_FLAGS; const char *p = conf; while (*p) { switch (*p) { case 'E': ret |= PAX_EMUTRAMP_ON; break; case 'p': ret &= ~PAX_PAGEEXEC_ON; break; case 'm': ret &= ~PAX_MPROTECT_ON; break; case 'r': ret &= ~PAX_ASLR_ON; break; case 's': ret &= ~PAX_SEGMEXEC_ON; break; default: fprintf(stderr, "Unknown character: \"%c\" in PaX configuration string: \"%s\". Permitted characters are: \"pEmrs\".\n", *p, conf); exit(EXIT_FAILURE); } p++; }; return ret; } static char *get_parent_dir(char *path) { char *tmpp = strrchr(path, '/'); if (tmpp) { if (tmpp == path) tmpp[1] = '\0'; else tmpp[0] = '\0'; } return path; } static void init_watches(void); static int add_watch(int inotify, const char *pathname, unsigned int flags) { int ret = inotify_add_watch(inotify, pathname, flags); if (ret == -1 && errno == ENOSPC) { init_watches(); ret = inotify_add_watch(inotify, pathname, flags); } return ret; } static void add_watch_to_closest_path(struct conf_entry *entry) { char tmp[4096]; strncpy(tmp, entry->requested_path, sizeof(tmp)); int id = add_watch(ino, entry->requested_path, INOTIFY_FLAGS); while (id == -1 && errno == ENOENT && strcmp(tmp, "/")) { // keep stripping path components until we reach an existing directory get_parent_dir(tmp); id = add_watch(ino, tmp, DIR_INOTIFY_FLAGS); } entry->watch_id = id; if (entry->existing_path) free(entry->existing_path); entry->existing_path = gr_strdup(tmp); } /* do safe setting of user xattrs */ static int set_xattr(struct conf_entry *entry) { struct stat st; uid_t linkuid; char path[PATH_MAX+1]; int ret; char pax_flags_str[16]; if (lstat(entry->requested_path, &st)) { if (errno == ENOENT) return 0; goto error; } linkuid = st.st_uid; if (!entry->nonroot && linkuid) goto error2; if (!realpath(entry->requested_path, path)) return 0; if (lstat(path, &st)) { if (errno == ENOENT) return 0; goto error; } if (entry->nonroot && st.st_uid != linkuid && linkuid) goto error2; // prevent duplicate events inotify_rm_watch(ino, entry->watch_id); // create or replace as necessary decode_pax_flags(entry->pax_flags, pax_flags_str); ret = lsetxattr(path, "user.pax.flags", pax_flags_str, strlen(pax_flags_str), 0); add_watch_to_closest_path(entry); if (ret == -1) { if (errno == ENOENT) return 0; goto error; } return 1; error: gr_syslog(LOG_ERR, "Unable to set extended attribute on \"%s\". Error: %s\n", entry->requested_path, strerror(errno)); exit(EXIT_FAILURE); error2: gr_syslog(LOG_ERR, "Unable to set extended attribute on \"%s\". Error: owner of symlink did not match that of target.\n", entry->requested_path); exit(EXIT_FAILURE); } static char *append_path(char *path, char *last) { char *ret = calloc(1, strlen(path) + strlen(last) + 2); if (ret == NULL) { fprintf(stderr, "Unable to allocate memory.\n"); exit(EXIT_FAILURE); } if (strcmp(path, "/")) sprintf(ret, "%s/%s", path, last); else sprintf(ret, "/%s", last); return ret; } static void init_watches(void) { unsigned int i; if (ino >= 0) close(ino); ino = inotify_init(); if (ino < 0) { gr_syslog(LOG_ERR, "Fatal: Unable to initialize inotify system: %s\n", strerror(errno)); exit(EXIT_FAILURE); } for (i = 0; i < config.count; i++) { struct conf_entry *entry = &config.entries[i]; add_watch_to_closest_path(entry); /* mark the binary if possible */ set_xattr(entry); } } static char* quoted_scan_string_nonroot = "\"%4095[^\"]\" %15s nonroot"; static char* quoted_scan_string = "\"%4095[^\"]\" %15s"; static char* unquoted_scan_string_nonroot = "%4095s %15s nonroot"; static char* unquoted_scan_string = "%4095s %15s"; static void parse_config(const char *confpath, struct paxctld_config *config) { FILE *f = fopen(confpath, "r"); char buf[8192] = { 0 }; char *p; char path[4096] = { 0 }; char flags[16] = { 0 }; unsigned long lineno = 0; int nonroot; int ret; char *scan_string; char *scan_string_nonroot; if (f == NULL) { fprintf(stderr, "Unable to open configuration file: %s\nError: %s\n", confpath, strerror(errno)); exit(EXIT_FAILURE); } while(fgets(buf, sizeof(buf) - 1, f)) { lineno++; p = buf; while (*p == ' ' || *p == '\t') p++; // ignore comment and empty lines if (*p == '#' || *p == '\n') continue; // if the path is quoted (i.e. has spaces), accomodate that if (*p == '"') { scan_string = quoted_scan_string; scan_string_nonroot = quoted_scan_string_nonroot; } else { scan_string = unquoted_scan_string; scan_string_nonroot = unquoted_scan_string_nonroot; } ret = sscanf(p, scan_string_nonroot, path, flags); if (ret != 2) { nonroot = 0; ret = sscanf(p, scan_string, path, flags); } else { nonroot = 1; } if (ret != 2) { fprintf(stderr, "Invalid configuration on line %lu of %s.\nSyntax is: [nonroot]\n", lineno, confpath); exit(EXIT_FAILURE); } if (config->count >= MAX_CONFIG_ENTRIES) { fprintf(stderr, "Exceeded maximum number of config entries.\n"); exit(EXIT_FAILURE); } config->entries[config->count].nonroot = nonroot; config->entries[config->count].requested_path = gr_strdup(path); config->entries[config->count].pax_flags = encode_pax_flags(flags); config->count++; } fclose(f); } static void usage(const char *name) { fprintf(stderr, "Usage: %s [-c config_file] [-d] [-p pid_file] [-q]\n", name); exit(EXIT_FAILURE); } static void handle_event(struct inotify_event *event, struct conf_entry *confentry) { if ((event->mask & (IN_CREATE | IN_MOVED_TO)) && strcmp(confentry->existing_path, confentry->requested_path)) { char *p = append_path(confentry->existing_path, event->name); unsigned int plen = strlen(p); if (!strncmp(confentry->requested_path, p, plen) && (confentry->requested_path[plen] == '/' || confentry->requested_path[plen] == '\0')) { confentry->watch_id = add_watch(ino, p, INOTIFY_FLAGS); free(confentry->existing_path); confentry->existing_path = p; if (!strcmp(confentry->requested_path, p)) gr_syslog(LOG_INFO, "File %s created.\n", confentry->existing_path); } else free(p); } else if (event->mask & (IN_DELETE_SELF | IN_MOVE_SELF)) { if (!strcmp(confentry->requested_path, confentry->existing_path)) gr_syslog(LOG_INFO, "File %s deleted.\n", confentry->existing_path); get_parent_dir(confentry->existing_path); confentry->watch_id = add_watch(ino, confentry->existing_path, DIR_INOTIFY_FLAGS); } else if ((event->mask & IN_ATTRIB) && !strcmp(confentry->existing_path, confentry->requested_path)) { struct stat st; if ((lstat(confentry->existing_path, &st)) == -1 && errno == ENOENT) { // file was deleted gr_syslog(LOG_INFO, "File %s deleted.\n", confentry->existing_path); get_parent_dir(confentry->existing_path); confentry->watch_id = add_watch(ino, confentry->existing_path, DIR_INOTIFY_FLAGS); } else { gr_syslog(LOG_INFO, "File %s had its attributes changed.\n", confentry->existing_path); } } /* if after processing the existing file matches the requested file, then set extended attributes on the file */ if (!strcmp(confentry->existing_path, confentry->requested_path)) { // create or replace as necessary int ret = set_xattr(confentry); if (ret) gr_syslog(LOG_INFO, "Restored PaX flags on \"%s\" after update.\n", confentry->existing_path); } } static void daemonize(void) { pid_t pid; pid = fork(); if (pid == 0) { if (setsid() < 0) exit(EXIT_FAILURE); signal(SIGCHLD, SIG_IGN); signal(SIGHUP, SIG_IGN); pid = fork(); if (pid == 0) { FILE *f; int i; if (chdir("/")) exit(EXIT_FAILURE); for (i = 0; i <= sysconf(_SC_OPEN_MAX); i++) if (i != ino) close(i); if (pidfile) { f = fopen(pidfile, "w"); fprintf(f, "%u\n", getpid()); fclose(f); } openlog("paxctld", 0, LOG_DAEMON); return; } else exit(EXIT_SUCCESS); } else exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) { int opt; char *config_path = DEFAULT_PAXCTLD_CONF; unsigned int i; struct inotify_event *event; char flags[16] = { 0 }; DIR *dir; if (argc < 1) usage("paxctld"); while ((opt = getopt(argc, argv, "c:dp:q")) != -1) { switch (opt) { case 'c': config_path = gr_strdup(optarg); break; case 'd': do_daemonize = 1; break; case 'p': pidfile = gr_strdup(optarg); break; case 'q': quiet = 1; break; default: fprintf(stderr, "Unknown option: \"%c\".", opt); usage(argv[0]); } } if (getxattr("/proc/self/exe", "user.pax.flags", flags, sizeof(flags)-1) == -1 && errno == ENOTSUP) { fprintf(stderr, "Fatal: Filesystem extended attribute support is not enabled on the current running kernel.\n"); exit(EXIT_FAILURE); } config.count = 0; config.entries = calloc(MAX_CONFIG_ENTRIES, sizeof(struct conf_entry)); if (config.entries == NULL) { fprintf(stderr, "Unable to allocate memory.\n"); exit(EXIT_FAILURE); } parse_config(config_path, &config); dir = opendir(DEFAULT_PAXCTLD_CONF_DIR); if (dir) { struct dirent *conf_file; char tmppath[PATH_MAX]; while ((conf_file = readdir(dir))) { struct stat st; if (conf_file->d_name[0] == '.') continue; strcpy(tmppath, DEFAULT_PAXCTLD_CONF_DIR "/"); strncat(tmppath, conf_file->d_name, sizeof(tmppath)-1); if (stat(tmppath, &st)) continue; if (!S_ISREG(st.st_mode)) continue; parse_config(tmppath, &config); } closedir(dir); } event = calloc(1, sizeof(struct inotify_event) + 4096); if (event == NULL) { fprintf(stderr, "Fatal: Unable to allocate memory.\n"); exit(EXIT_FAILURE); } if (do_daemonize) daemonize(); gr_syslog(LOG_INFO, "paxctld initialized.\n"); init_watches(); while (read(ino, event, sizeof(struct inotify_event) + 4096) > 0) { // if it's a delete, we need to remove the watch on the file and add it to its parent directory for (i = 0; i < config.count; i++) { struct conf_entry *entry = &config.entries[i]; if (event->wd == -1) { init_watches(); break; } if (event->wd != entry->watch_id) continue; handle_event(event, entry); } } return 0; } paxctld-1.2.1/paxctld.conf0000644000000000000000000000515412744700466014175 0ustar rootroot# grub /usr/bin/grub-script-check E /usr/bin/grub-bios-setup E /usr/sbin/grub-mkdevicemap E /usr/sbin/grub-probe E # qemu /usr/bin/qemu-alpha m /usr/bin/qemu-arm m /usr/bin/qemu-armeb m /usr/bin/qemu-cris m /usr/bin/qemu-i386 m /usr/bin/qemu-m68k m /usr/bin/qemu-microblaze m /usr/bin/qemu-microblazeel m /usr/bin/qemu-mips m /usr/bin/qemu-mips64 m /usr/bin/qemu-mips64el m /usr/bin/qemu-mipsel m /usr/bin/qemu-mipsn32 m /usr/bin/qemu-mipsn32el m /usr/bin/qemu-or32 m /usr/bin/qemu-ppc m /usr/bin/qemu-ppc64 m /usr/bin/qemu-ppc64abi32 m /usr/bin/qemu-s390x m /usr/bin/qemu-sh4 m /usr/bin/qemu-sh4eb m /usr/bin/qemu-sparc m /usr/bin/qemu-sparc32plus m /usr/bin/qemu-sparc64 m /usr/bin/qemu-unicore32 m /usr/bin/qemu-x86_64 m /usr/bin/qemu-system-aarch64 m /usr/bin/qemu-system-alpha m /usr/bin/qemu-system-arm m /usr/bin/qemu-system-cris m /usr/bin/qemu-system-i386 m /usr/bin/qemu-system-lm32 m /usr/bin/qemu-system-m68k m /usr/bin/qemu-system-microblaze m /usr/bin/qemu-system-microblazeel m /usr/bin/qemu-system-mips m /usr/bin/qemu-system-mips64 m /usr/bin/qemu-system-mips64el m /usr/bin/qemu-system-mipsel m /usr/bin/qemu-system-moxie m /usr/bin/qemu-system-or32 m /usr/bin/qemu-system-ppc m /usr/bin/qemu-system-ppc64 m /usr/bin/qemu-system-ppcemb m /usr/bin/qemu-system-s390x m /usr/bin/qemu-system-sh4 m /usr/bin/qemu-system-sh4eb m /usr/bin/qemu-system-sparc m /usr/bin/qemu-system-sparc64 m /usr/bin/qemu-system-unicore32 m /usr/bin/qemu-system-x86_64 m /usr/bin/qemu-system-xtensa m /usr/bin/qemu-system-xtensaeb m # skype /usr/lib/skype/skype m /usr/lib32/skype/skype m # steam /usr/lib32/ld-linux.so.2 m # node /usr/bin/node m # chrome /opt/google/chrome/chrome-sandbox m /opt/google/chrome/nacl_helper m /opt/google/chrome/chrome m # chromium /usr/lib/chromium-browser/chromium-browser m # firefox /usr/lib/firefox/firefox m /usr/lib/firefox/plugin-container m # webapp-container /usr/bin/webapp-container m # oxide /usr/lib/x86_64-linux-gnu/oxide-qt/oxide-renderer m # valgrind /usr/bin/valgrind m # python /usr/bin/python2.7 E /usr/bin/python3.5 E # java /usr/lib/jvm/java-6-sun-1.6.0.10/jre/bin/java m /usr/lib/jvm/java-6-sun-1.6.0.10/jre/bin/javaws m /usr/lib/jvm/java-6-openjdk/jre/bin/java m /usr/lib/jvm/java-6-openjdk/jre/bin/java m /usr/lib/jvm/java-8-openjdk/jre/bin/java m # openrc /lib/rc/bin/lsb2rcconf E # libreoffice # Ubuntu doesn't seem to carry this patch: # https://bz.apache.org/ooo/show_bug.cgi?id=80816 # libreoffice will still run fine without the below line, # but it will report an RWX mprotect attempt # /usr/lib/libreoffice/program/soffice.bin m paxctld-1.2.1/paxctld.80000644000000000000000000000313212744700466013411 0ustar rootroot.TH PAXCTLD 8 .SH NAME paxctld \- Daemon to automatically apply appropriate PaX flags .SH SYNOPSIS .B paxctld [ .B \-c ] [ .B \-d ] [ .B \-p ] [ .B \-q ] .SH DESCRIPTION .I paxctld is a daemon that automatically applies PaX flags to binaries on the system. These flags are applied via user extended attributes and are refreshed on any update to the binaries specified in its configuration file. .I paxctld.conf is the configuration file located in /etc that defines which binaries to mark with specific PaX flags. The format of this configuration file is multiple lines of the form: .RS [nonroot] .RE Empty lines or lines beginning with '#' are ignored. Files that have spaces in the path leading to them must be surrounded in double quotes. The optional nonroot string is to be used if the file being marked is not owned by root. paxctld will not allow files not owned by root to be marked (or have their symlinks followed) without this string. If the pathname specifies a symlink not owned by root, the target of the symlink must have the same owner. .SH OPTIONS .TP .B \-c Specify a config file other than the default of \%/etc/paxctld.conf .TP .B \-d Make paxctld run as a daemon .TP .B \-p Specify the pid file to use when running in daemon mode .TP .B \-q Enable quiet mode to suppress all syslogs from paxctld .SH REPORTING BUGS Please include as much information as possible and send bug reports to .B spender@grsecurity.net .SH AUTHOR .B paxctld was created and is maintained by Brad Spengler \% paxctld-1.2.1/Makefile0000644000000000000000000000157212744700466013327 0ustar rootroot# Copyright 2014-2015 Open Source Security, Inc. # paxctld is licensed under the GNU GPL v2 only http://www.gnu.org # see COPYRIGHT and LICENSE files for more information CC=/usr/bin/gcc CFLAGS?=-Wall -O2 -pie -fPIC -D_FORTIFY_SOURCE=2 -fstack-protector-all LDFLAGS= STRIP=/usr/bin/strip MANDIR=/usr/share/man INSTALL=/usr/bin/install -c DESTDIR= all: paxctld paxctld: paxctld.c install: paxctld paxctld.8 paxctld.conf @echo "Installing paxctld.conf..." @mkdir -p $(DESTDIR)/etc @$(INSTALL) -m 0644 paxctld.conf $(DESTDIR)/etc @echo "Installing paxctld..." @mkdir -p $(DESTDIR)/sbin @$(INSTALL) -m 0755 paxctld $(DESTDIR)/sbin @$(STRIP) $(DESTDIR)/sbin/paxctld @echo "Installing paxctld manpage..." @mkdir -p $(DESTDIR)$(MANDIR)/man8 @$(INSTALL) -m 0644 paxctld.8 $(DESTDIR)$(MANDIR)/man8/paxctld.8 clean: rm -rf core *.o paxctld debian/paxctld debian/paxctld.debhelper.log paxctld-1.2.1/rpm/0000755000000000000000000000000012744700466012460 5ustar rootrootpaxctld-1.2.1/rpm/paxctld.service0000644000000000000000000000030712744700466015501 0ustar rootroot[Unit] Description=PaX flags maintenance daemon DefaultDependencies=no After=systemd-remount-fs.service Before=sysinit.target [Service] ExecStart=/sbin/paxctld [Install] WantedBy=multi-user.target paxctld-1.2.1/rpm/paxctld.spec0000644000000000000000000000757712744700466015013 0ustar rootrootName: paxctld Version: 1.2.1 Release: 1%{?dist} Summary: PaX flags maintenance daemon Group: admin License: GPLv2 Requires(post): chkconfig Requires(preun): chkconfig Requires(preun): initscripts Requires(postun): initscripts URL: https://grsecurity.net Source: https://grsecurity.net/paxctld-1.2.1.tgz %description paxctld is a daemon that automatically applies PaX flags to binaries on the system. These flags are applied via user extended attributes and are refreshed on any update to the binaries specified in its configuration file. %package systemd Summary: PaX flags maintenance daemon Group: admin Requires(post): systemd Requires(preun): systemd Requires(postun): systemd %description systemd paxctld is a daemon that automatically applies PaX flags to binaries on the system. These flags are applied via user extended attributes and are refreshed on any update to the binaries specified in its configuration file. This package supports those who have been forced to run only systemd by their distro. %prep %setup -q %build make %{?_smp_mflags} %install %make_install install -d $RPM_BUILD_ROOT/etc/rc.d/init.d install -d $RPM_BUILD_ROOT/etc/systemd/system install -m755 rpm/paxctld.init $RPM_BUILD_ROOT/etc/rc.d/init.d/paxctld install -m755 rpm/paxctld.service $RPM_BUILD_ROOT/etc/systemd/system %post # This adds the proper /etc/rc*.d links for the script /sbin/chkconfig --add paxctld /sbin/service paxctld start >/dev/null 2>&1 %post systemd /usr/bin/systemctl enable paxctld.service >/dev/null 2>&1 || : %preun if [ $1 -eq 0 ] ; then /sbin/service paxctld stop >/dev/null 2>&1 /sbin/chkconfig --del paxctld fi %preun systemd %systemd_preun paxctld.service %postun if ["$!" -ge "1" ] ; then /sbin/service paxctld condrestart >/dev/null 2>&1 || : fi %postun systemd %systemd_postun paxctld.service %files %defattr(-,root,root) %attr(0755,root,root) /sbin/paxctld %attr(0644,root,root) %{_mandir}/man8/paxctld.8.gz %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/paxctld.conf %attr(0755,root,root) %config %{_sysconfdir}/rc.d/init.d/paxctld %doc %files systemd %defattr(-,root,root) %attr(0755,root,root) /sbin/paxctld %attr(0644,root,root) %{_mandir}/man8/paxctld.8.gz %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/paxctld.conf %attr(0755,root,root) %config %{_sysconfdir}/systemd/system/paxctld.service %doc %changelog * Sun Jul 23 2016 Brad Spengler 1.2.1-1 - Updated default paxctld.conf to improve Ubuntu usability - Updated chrome/firefox settings now that the anti-defense "features" of firefox in particular have been fixed * Sun Jul 17 2016 Brad Spengler 1.2-1 - Added support for filesystems that don't provide d_type, from Damir Vandic: https://forums.grsecurity.net/viewtopic.php?f=1&t=4484 * Tue Feb 9 2016 Brad Spengler 1.1-1 - Added support for pathnames with spaces, from Austin Seipp * Wed Dec 23 2015 Brad Spengler 1.0-4 - Fixed a non-security-relevant crash on too-large paxctld.conf files, reported by Jurriaan Bremer - Fixed the xattrs set by paxctld -- due to the nonintuitivity of PaX xattr parsing which differed from some previous marking methods, it ended up being the case that if EMUTRAMP was enabled in the kernel, all binaries marked with xattrs via paxctld were running with EMUTRAMP enabled. Running the updated version of paxctld will fix the issue on binaries listed in paxctld.conf. This issue was found via an internal audit. * Thu Oct 29 2015 Brad Spengler 1.0-3 - Added support for reading extra config files from /etc/paxctld.d Files beginning with '.' are ignored, as are any non-regular files in the directory * Thu Mar 12 2015 Brad Spengler 1.0 - Added systemd-specific subpackage from 'tweek' on the forums, * Wed Dec 17 2014 Brad Spengler 1.0 - Initial release paxctld-1.2.1/rpm/paxctld.init0000644000000000000000000000400512744700466015003 0ustar rootroot#!/bin/sh # # paxctld PaX flags maintenance daemon # # chkconfig: 2345 01 99 # description PaX flags maintenance daemon # # processname: paxctld # config: /etc/paxctld.conf # pidfile: /var/run/paxctld.pid ### BEGIN INIT INFO # Provides: paxctld # Required-Start: $local_fs $network $remote_fs $syslog # Required-Stop: $local_fs $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO # Author: Brad Spengler # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="PaX flags maintenance daemon" NAME=paxctld DAEMON=/sbin/paxctld PIDFILE=/var/run/$NAME.pid DAEMON_ARGS="-d -p $PIDFILE" SCRIPTNAME=/etc/rc.d/init.d/$NAME CONFIG=/etc/paxctld.conf # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # source function library . /etc/rc.d/init.d/functions lockfile=/var/lock/subsys/$NAME start() { [ -x $exec ] || exit 5 [ -f $config ] || exit 6 echo -n $"Starting $NAME: " daemon $DAEMON $DAEMON_ARGS retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $NAME: " killproc $NAME retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop start } reload() { restart } force_reload() { restart } rh_status() { status $NAME } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac exit $? paxctld-1.2.1/debian/0000755000000000000000000000000012744700466013104 5ustar rootrootpaxctld-1.2.1/debian/copyright0000644000000000000000000000161512744700466015042 0ustar rootrootFormat: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: paxctld Source: Files: * Copyright: 2014 Brad Spengler License: GPL-2 This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation. . This package 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 . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". paxctld-1.2.1/debian/docs0000644000000000000000000000000012744700466013745 0ustar rootrootpaxctld-1.2.1/debian/changelog0000644000000000000000000000402212744700466014754 0ustar rootrootpaxctld (1.2.1-1) unstable; urgency=low * Updated default paxctld.conf to improve Ubuntu usability * Updated chrome/firefox settings now that the anti-defense "features" of firefox in particular have been fixed -- Brad Spengler Sat, 23 Jul 2016 10:11:00 -0500 paxctld (1.2-1) unstable; urgency=low * Added support for filesystems that don't provide d_type, from Damir Vandic: https://forums.grsecurity.net/viewtopic.php?f=1&t=4484 -- Brad Spengler Sun, 17 Jul 2016 20:10:00 -0500 paxctld (1.1-1) unstable; urgency=low * Added support for paths with spaces, from Austin Seipp -- Brad Spengler Tue, 9 Feb 2016 22:57:00 -0500 paxctld (1.0-4) unstable; urgency=low * Fixed a non-security-relevant crash on too-large paxctld.conf files, reported by Jurriaan Bremer * Fixed the xattrs set by paxctld -- due to the nonintuitivity of PaX xattr parsing which differed from some previous marking methods, it ended up being the case that if EMUTRAMP was enabled in the kernel, all binaries marked with xattrs via paxctld were running with EMUTRAMP enabled. Running the updated version of paxctld will fix the issue on binaries listed in paxctld.conf. This issue was found via an internal audit. -- Brad Spengler Wed, 23 Dec 2015 14:48:00 -0500 paxctld (1.0-3) unstable; urgency=low * Fixed starting at boot with systemd, from rufoa * Added support for reading extra config files from /etc/paxctld.d Files beginning with '.' are ignored, as are any non-regular files in the directory -- Brad Spengler Thu, 29 Oct 2015 20:29:00 -0500 paxctld (1.0-2) unstable; urgency=low * Fixed a missing quotation mark in upstart script, reported by Andrew Alexander -- Brad Spengler Thu, 1 Jan 2015 11:51:00 -0500 paxctld (1.0-1) unstable; urgency=low * Initial release -- Brad Spengler Tue, 16 Dec 2014 21:06:36 -0500 paxctld-1.2.1/debian/paxctld.substvars0000644000000000000000000000007312744700466016521 0ustar rootrootmisc:Depends=sysv-rc (>= 2.88dsf-24) | file-rc (>= 0.8.16) paxctld-1.2.1/debian/paxctld.service0000644000000000000000000000030712744700466016125 0ustar rootroot[Unit] Description=PaX flags maintenance daemon DefaultDependencies=no After=systemd-remount-fs.service Before=sysinit.target [Service] ExecStart=/sbin/paxctld [Install] WantedBy=multi-user.target paxctld-1.2.1/debian/paxctld.upstart0000644000000000000000000000031212744700466016163 0ustar rootrootdescription "PaX flags maintenance daemon" start on runlevel [2345] stop on runlevel [!2345] console none pre-start script test -x /sbin/paxctld || { stop; exit 0; } end script exec /sbin/paxctld paxctld-1.2.1/debian/compat0000644000000000000000000000000212744700466014302 0ustar rootroot9 paxctld-1.2.1/debian/rules0000755000000000000000000000016212744700466014163 0ustar rootroot#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ paxctld-1.2.1/debian/control0000644000000000000000000000103312744700466014504 0ustar rootrootSource: paxctld Section: admin Priority: important Maintainer: Brad Spengler Build-Depends: debhelper (>= 8.0.0) Standards-Version: 3.9.4 Homepage: https://grsecurity.net Package: paxctld Architecture: any Depends: ${misc:Depends} Description: Daemon to automatically set appropriate PaX flags paxctld automatically sets appropriate PaX flags on binaries on the system using user extended attributes. The flags are maintained across any updates made to the binaries listed in the paxctld configuration file. paxctld-1.2.1/debian/paxctld.postinst.debhelper0000644000000000000000000000062412744700466020303 0ustar rootroot# Automatically added by dh_installinit if [ -x "/etc/init.d/paxctld" ] || [ -e "/etc/init/paxctld.conf" ]; then if [ ! -e "/etc/init/paxctld.conf" ]; then update-rc.d paxctld defaults >/dev/null fi invoke-rc.d paxctld start || exit $? fi # End automatically added section # Automatically added by dh_installinit update-rc.d -f paxctld remove >/dev/null || exit $? # End automatically added section paxctld-1.2.1/debian/paxctld.prerm.debhelper0000644000000000000000000000027312744700466017545 0ustar rootroot# Automatically added by dh_installinit if [ -x "/etc/init.d/paxctld" ] || [ -e "/etc/init/paxctld.conf" ]; then invoke-rc.d paxctld stop || exit $? fi # End automatically added section paxctld-1.2.1/debian/files0000644000000000000000000000005012744700466014124 0ustar rootrootpaxctld_1.2-1_amd64.deb admin important paxctld-1.2.1/debian/paxctld.init0000644000000000000000000000534212744700466015434 0ustar rootroot#!/bin/sh ### BEGIN INIT INFO # Provides: paxctld # Required-Start: $local_fs $network $remote_fs $syslog # Required-Stop: $local_fs $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO # Author: Brad Spengler # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="PaX flags maintenance daemon" NAME=paxctld DAEMON=/sbin/paxctld PIDFILE=/var/run/$NAME.pid DAEMON_ARGS="-d -p $PIDFILE" SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present # and status_of_proc is working. . /lib/lsb/init-functions check_for_upstart() { if init_is_upstart; then exit $1 fi } # # Function that starts the daemon/service # do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" } case "$1" in start) check_for_upstart 1 log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; stop) check_for_upstart 0 log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; status) check_for_upstart 1 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; restart|force-reload) check_for_upstart 1 log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac : paxctld-1.2.1/debian/source/0000755000000000000000000000000012744700466014404 5ustar rootrootpaxctld-1.2.1/debian/source/format0000644000000000000000000000001412744700466015612 0ustar rootroot3.0 (quilt) paxctld-1.2.1/debian/paxctld.preinst.debhelper0000644000000000000000000000046212744700466020104 0ustar rootroot# Automatically added by dh_installinit if [ "$1" = install ] || [ "$1" = upgrade ]; then if [ -e "/etc/init.d/paxctld" ] && [ -L "/etc/init.d/paxctld" ] \ && [ $(readlink -f "/etc/init.d/paxctld") = /lib/init/upstart-job ] then rm -f "/etc/init.d/paxctld" fi fi # End automatically added section paxctld-1.2.1/COPYRIGHT0000644000000000000000000000141312744700466013154 0ustar rootrootpaxctld - PaX flags maintenance daemon Copyright (C) 2012-2015 Bradley Spengler, Open Source Security, Inc. http://www.grsecurity.net spender@grsecurity.net This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. paxctld-1.2.1/LICENSE0000644000000000000000000003556412744700466012704 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS