Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[tore@xxxxxxxxxx: Bug#295511: Fork bomb in default make completion]



I can reproduce this.
http://bugs.debian.org/cgi-bin/bugreport.cgi/Makefile?bug=295511&msg=3&att=1

I'm attaching the trace (up 'til I killed it) gzipped.

----- Forwarded message from Tore Anderson <tore@xxxxxxxxxx> -----

  When trying to tab complete anything after make in a directory with
 the Makefile from Cisco's software iSCSI initiator, the shell initiates
 a fork bomb, grinding the system to a halt.

  This is for me 100% reproducable with zsh 4.2.4-2 on i386 with the
 following steps:

  1) Save the attached Makefile to some directory.
  2) Save all your work and sync your file systems.
  3) Push the aforementioned directory onto the shell's directory stack
  4) Type "make " and then hit the TAB key.
  5) Enjoy the frantic sound of your hard drive as kswapd starts
     trashing - if you're quick you may also be able to get a "ps"
     listing of the hundreds of child processes before the system ends
     up in a totally unusable state.

  Oh and by the way, I initiate the completion stuff like this in
 my .zshrc:

    autoload -U compinit; compinit

-- 
Tore Anderson

# Makefile for the Linux iSCSI driver
# Copyright (C) 2001 Cisco Systems, Inc.
# maintained by linux-iscsi-devel@xxxxxxxxxxxxxxxxxxxxx
#
# 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 2 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.
#
# See the file COPYING included with this distribution for more details.

#
#
#
## THE USER MAKEFILE BEGINS !!!

# for compiling the daemon and utils
OS:=$(shell uname)
ARCH:=$(shell uname -m)

DRIVER_DIR:=driver
DAEMON_DIR:=daemon
COMMON_DIR:=common
MISC_DIR:=misc
MAN_DIR:=man
UTILS_DIR:=utils
INCLUDE_DIR:=include
DISCOVERY_DIR:=$(DAEMON_DIR)/discovery
LOGIN_DIR:=$(COMMON_DIR)/login
AUTH_DIR:=$(COMMON_DIR)/auth
SCRIPT_DIR:=$(MISC_DIR)/scripts
ISCSI_BOOT_DIR:=$(UTILS_DIR)/iscsi-boot

# Where to install files that must be relative to the root dir.
# This is a prefix prepended before the pathname, and is
# normally unset.  It would be set for such things as diskless
# clients, where the driver is being installed on the server
# for a client.
ROOT:=
export ROOT

# Where to install the relocatable files (daemon, utilities, and man pages)
BASEDIR:=/
export BASEDIR

# We need to have the kernel headers installed in order to compile.
# You can specify a TOPDIR for your Linux kernel here, or if you don't
# we'll look for it in a few likely places later.
TOPDIR:=

# We also need the pathname of the kernel .config file to use.
# You can specify a .config for your Linux kernel here, or if you don't
# we'll look for it in a few likely places later.
KERNEL_CONFIG:=

# The rest of this Makefile shouldn't need to be modified

# record the version of the running kernel
KERNEL_VPSE:=$(shell uname -r)

# Try to find the top of the Linux kernel source tree for the running kernel
ifeq ($(TOPDIR),)
  ifeq ($(wildcard /lib/modules/$(KERNEL_VPSE)/build/.),/lib/modules/$(KERNEL_VPSE)/build/.)
    TOPDIR:=/lib/modules/$(KERNEL_VPSE)/build
  endif
  ifeq ($(TOPDIR),)
    $(warning Linux kernel source must be installed to compile this code.)
    $(error Could not find the top of the linux kernel source tree.)
  endif
endif

# record the kernel source version
KERNEL_VERSION:=$(shell awk -F"[ \t]*=[ \t]*" '$$1 == "VERSION" { print $$2 }' $(TOPDIR)/Makefile | sed -e 's/[ \t\n]*//g')
KERNEL_PATCHLEVEL:=$(shell awk -F"[ \t]*=[ \t]*" '$$1 == "PATCHLEVEL" {print $$2}' $(TOPDIR)/Makefile | sed -e 's/[ \t\n]*//g')
KERNEL_SUBLEVEL:=$(shell awk -F"[ \t]*=[ \t]*" '$$1 == "SUBLEVEL" {print $$2 }' $(TOPDIR)/Makefile | sed -e 's/[ \t\n]*//g')
KERNEL_EXTRAVERSION:=$(shell awk -F"[ \t]*=[ \t]*" '$$1 == "EXTRAVERSION" {print $$2 }' $(TOPDIR)/Makefile | sed -e 's/[ \t\n]*//g')
KERNEL_SRC_VPSE:=$(KERNEL_VERSION).$(KERNEL_PATCHLEVEL).$(KERNEL_SUBLEVEL)$(KERNEL_EXTRAVERSION)


# Try to find the kernel's config if the user didn't tell us where to find it.
# People who compile their own kernels will have a .config, as will some
# distributions that only ship one kernel binary, or that use separate
# kernel source for each kernel binary.  Redhat uses the same kernel source
# for multiple kernel binaries.

# the standard config file location is $(TOPDIR)/.config
ifeq ($(wildcard $(TOPDIR)/.config),$(TOPDIR)/.config)
  KERNEL_CONFIG:=$(TOPDIR)/.config
endif


# for compiling the daemon and utils 
CC:=gcc
INCLUDE:= -I$(PWD)/include  -I$(PWD)/$(LOGIN_DIR) -I$(PWD)/$(AUTH_DIR) -I$(PWD)/$(DISCOVERY_DIR) -I$(PWD)/$(DAEMON_DIR)/include -I$(PWD)/$(MISC_DIR)/include
OPTFLAGS = -O2
CFLAGS:= -Wall -Wstrict-prototypes $(OPTFLAGS) $(INCLUDE)
LDFLAGS:= 

# assume object dirs should go under the current directory, unless told
# otherwise
OBJ:=$(CURDIR)

ifdef DEBUG
OBJDIR:=$(OBJ)/$(OS)-$(ARCH)/dbg-obj
KOBJDIR:=$(PWD)
CFLAGS += -g -DDEBUG
LDFLAGS += -g
else
KOBJDIR:=$(PWD)
OBJDIR:=$(OBJ)/$(OS)-$(ARCH)/obj
CFLAGS += -fomit-frame-pointer
endif

.PHONY: all module daemon utils kernel user permissions clean tar dist release \
         checklocal version newversion install remove uninstall dirs

# default target
all:: dirs module daemon utils permissions checkkernel checkscsi checkcrypto
module: dirs checkkernel 
daemon:  dirs $(OBJDIR)/iscsid
utils: dirs $(OBJDIR)/$(UTILS_DIR)/iscsi-device $(OBJDIR)/$(UTILS_DIR)/iscsi-iname $(OBJDIR)/$(UTILS_DIR)/iscsi-boot/init

# distributors usually want these targets when building packages
user: dirs daemon utils permissions
kernel: dirs checkkernel checkscsi checkcrypto module

export OBJDIR
export KOBJDIR

.SUFFIXES:

DRIVER_FILES:=	$(DRIVER_DIR)/iscsi-initiator.c
DRIVER_FILES+=	$(DRIVER_DIR)/iscsi-attr.c \
	      	$(DRIVER_DIR)/iscsi-ioctl.c \
	      	$(DRIVER_DIR)/iscsi-network.c \
	      	$(DRIVER_DIR)/iscsi-portal.c \
	      	$(DRIVER_DIR)/iscsi-recv-pdu.c \
	      	$(DRIVER_DIR)/iscsi-xmit-pdu.c \
	      	$(DRIVER_DIR)/iscsi-session.c \
	      	$(DRIVER_DIR)/iscsi-task.c \
	      	$(DRIVER_DIR)/iscsi-auth.c \
	      	$(DRIVER_DIR)/Makefile \
	      	$(DRIVER_DIR)/include/iscsi-sfnet.h \
	      	$(DRIVER_DIR)/include/iscsi-session.h \
	      	$(DRIVER_DIR)/include/iscsi-task.h \
		$(DRIVER_DIR)/scsi_transport_iscsi.c \
		$(DRIVER_DIR)/include/scsi_transport_iscsi.h \

DAEMON_FILES:=	$(DAEMON_DIR)/iscsi-config.c
DAEMON_FILES+=	$(DAEMON_DIR)/iscsid.c \
	      	$(DISCOVERY_DIR)/iscsi-discovery.c \
	      	$(DAEMON_DIR)/iscsi-io.c \
	      	$(DAEMON_DIR)/iscsi-linux.c \
	      	$(DAEMON_DIR)/iscsi-auth.c \

MAN_FILES:=	$(MAN_DIR)/iscsi.conf.5
MAN_FILES+=	$(MAN_DIR)/iscsid.8 \
		$(MAN_DIR)/iscsi-ls.1

SCRIPT_FILES:=	$(SCRIPT_DIR)/install.sh
SCRIPT_FILES+=	$(SCRIPT_DIR)/iscsi-mountall \
		$(SCRIPT_DIR)/iscsi-umountall \
		$(SCRIPT_DIR)/iscsi-rename \
		$(SCRIPT_DIR)/remove.sh \
		$(UTILS_DIR)/iscsi-boot/mkinitrd.iscsi \
		$(SCRIPT_DIR)/rc.iscsi \
		$(SCRIPT_DIR)/iscsi-ls

UTILS_FILES:=	$(ISCSI_BOOT_DIR)/init.c
UTILS_FILES+=	$(UTILS_DIR)/iscsi-device.c \
		$(UTILS_DIR)/iscsi-iname.c \
		$(ISCSI_BOOT_DIR)/iscsi-network-boot.c \
		$(ISCSI_BOOT_DIR)/iscsi-network-boot.h

MODULE_SRCS:=	$(DRIVER_FILES) $(LOGIN_DIR)/iscsi-login.c $(AUTH_DIR)/iscsi-auth-client.c
DAEMON_SRCS:=	$(LOGIN_DIR)/iscsi-login.c $(DAEMON_FILES) \
		$(MISC_DIR)/string-buffer.c \
		$(MISC_DIR)/md5.c \
		$(AUTH_DIR)/iscsi-auth-client.c

DAEMON_FILES+= $(DISCOVERY_DIR)/iscsi-slp-discovery.c

#Install openslp release 1.1.4 and onwards on the system and uncomment the follo
#wing line to enable SLP discovery for iSCSI.
#ENABLE_SLP:= 1
ifeq ($(ENABLE_SLP),1)
CFLAGS+=-DSLP_ENABLE=1
LDFLAGS+=-lslp
DAEMON_SRCS += $(DISCOVERY_DIR)/iscsi-slp-discovery.c
endif

UTIL_SRCS:=$(MISC_DIR)/md5.c $(UTILS_FILES)
UTIL_OBJS:=$(UTIL_SRCS:%.c=$(OBJDIR)/$(UTILS_DIR)/%.o)
DAEMON_OBJS:=$(DAEMON_SRCS:%.c=$(OBJDIR)/%.o) 
KDIR:= /lib/modules/$(shell uname -r)/build

# Make all objects depend on the Makefile
$(DAEMON_OBJS): Makefile 
$(UTIL_OBJS): Makefile

install: module daemon utils
	@./$(SCRIPT_DIR)/install.sh

remove uninstall:
	@./$(SCRIPT_DIR)/remove.sh

echomodsrcs:
	@echo $(MODULE_SRCS)

# warn the user if the running kernel version
# doesn't match the $TOPDIR/Makefile version
checkkernel:
	@printf "\nNote: using kernel source from $(TOPDIR)\ncontaining kernel version $(KERNEL_SRC_VPSE)\n\n" | fmt -
	@if [ "$(KERNEL_CONFIG)" ] ; then \
                printf "Note: using kernel config from $(KERNEL_CONFIG)\n\n" | fmt - ; \
        else \
	   ( printf "Warning: failed to find a kernel config file for $(KERNEL_SRC_VPSE).\n" ; \
             printf "The iSCSI kernel module may fail to load or run properly.\n\n"; ) | fmt - ; \
        fi
        @if [ "$(KERNEL_VERSION).$(KERNEL_PATCHLEVEL)" = "2.4" ] ; then \
            ( printf "\nError: this iSCSI driver does not support 2.4 kernels.\n" ; \
              printf "You must upgrade your kernel to 2.6 or later\n" ; \
              printf "in order to use this driver.\n\n" ; ) | fmt - ; \
            exit 1; \
        fi
	@if [ "$(KERNEL_SRC_VPSE)" != "$(KERNEL_VPSE)" ] ; then\
            (   echo "Warning: $(TOPDIR) contains kernel version " ; \
                echo "$(KERNEL_SRC_VPSE), but kernel version $(KERNEL_VPSE) ";\
                echo "is currently running. This mismatch may prevent the " ; \
                echo "iSCSI module from loading on the running kernel due " ; \
                echo "to unresolved symbols, or may cause problems during " ; \
		echo "the operation of the iSCSI driver. The iSCSI driver " ; \
                echo "will be built for kernel version $(KERNEL_SRC_VPSE). "; \
                echo "If you wish to build the iSCSI driver for the kernel "; \
                echo "that is currently running, you must install the "; \
                echo "appropriate kernel source and rebuild the iSCSI " ; \
                echo "driver."; ) | fmt - ; \
        fi;

# Error out if there is no scsi support in the kernel
checkscsi:
	@if [ -n "$(KERNEL_CONFIG)" ] ; then \
	SCSI=`grep 'CONFIG_SCSI=' $(KERNEL_CONFIG)|awk -F'=' '{print $$2}'`; \
	if [ "$$SCSI" != "y" -a "$$SCSI" != "m" -a "$$SCSI" != "unknown" ] ; then \
		echo ; \
		echo "Error: your kernel does not appear to support SCSI." ; \
		echo "For iSCSI to function, you must rebuild your kernel " ; \
		echo "with either SCSI support compiled into the kernel, " ; \
		echo "or with SCSI support as a module." ; \
		echo ; \
		exit 1;\
	fi \
	fi

checkcrypto:
	@if [ -n "$(KERNEL_CONFIG)" ] ; then \
	CRYPTO=`grep 'CONFIG_CRYPTO=' $(KERNEL_CONFIG)|awk -F'=' '{print $$2}'`; \
	MD5=`grep 'CONFIG_CRYPTO_MD5=' $(KERNEL_CONFIG)|awk -F'=' '{print $$2}'` ; \
	CRC32C=`grep 'CONFIG_CRYPTO_CRC32C=' $(KERNEL_CONFIG)|awk -F'=' '{print $$2}'` ; \
	if [ "$$CRYPTO" != "y" -a "$$CRYPTO" != "unknown" ]; then \
		echo ; \
		echo "Error: your kernel does not appear to support CRYPTO" ; \
		echo "API. For iSCSI to function, you must rebuild your " ; \
		echo "kernel with CRYPTO API support compiled into the " ; \
		echo "kernel." ; \
		exit 1;\
	elif [ "$$MD5" != "y" -a "$$MD5" != "m" -a "$$MD5" != "unknown" ]; then \
		echo; \
		echo "Error: your kernel does not appear to support MD5." ; \
		echo "For iSCSI to function, you must rebuild your kernel " ; \
		echo "with MD5 support compiled into the kernel." ; \
		echo ; \
		exit 1;\
	elif [ "$$CRC32C" != "y" -a "$$CRC32C" != "m" -a "$$CRC32C" != "unknown" ];then \
		echo; \
		echo "Warning:your kernel does not appear to support CRC." ;\
		echo "You will not be able to enable Header and Data Digest" ;\
		echo "features of iSCSI driver";\
		echo ;\
	fi \
	fi

# compile daemon/utility code and auto-generate dependencies (and make missing prereqs cause a rebuild,
# not an error)
$(OBJDIR)/%.o : %.c
	$(CC) $(CFLAGS) -MMD -c -o $(OBJDIR)/$*.o $*.c
	@if [ ! -f $(OBJDIR)/$*.d -a -f $*.d ] ; then \
		printf "$(OBJDIR)/" > $(OBJDIR)/$*.d ; \
		cat $*.d >> $(OBJDIR)/$*.d && rm -f $*.d ; \
	fi
	@cp -f $(OBJDIR)/$*.d $(OBJDIR)/$*.dep
	@sed -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' < $(OBJDIR)/$*.d >> $(OBJDIR)/$*.dep


$(OBJDIR)/iscsid: $(DAEMON_OBJS)
	$(CC) $(LDFLAGS)  $(DAEMONFLAGS) -o $@ $^

#statically linked version
$(OBJDIR)/iscsid-static: $(DAEMON_OBJS)
	$(CC) -static $(LDFLAGS)  $(DAEMONFLAGS) -o $@ $^

# includes TOPDIR/include/scsi/scsi_ioctl.h
$(OBJDIR)/$(UTILS_DIR)/iscsi-device: $(UTILS_DIR)/iscsi-device.c Makefile
	$(CC) $(CFLAGS) -I$(TOPDIR)/include -o $@ $<

# Link the iscsi-iname utility
$(OBJDIR)/$(UTILS_DIR)/iscsi-iname: $(OBJDIR)/$(UTILS_DIR)/iscsi-iname.o $(OBJDIR)/$(MISC_DIR)/md5.o
	$(CC) $(CFLAGS) -o $@ $^

# Make the init utility. This needs to be statically compiled for initrd.
$(OBJDIR)/$(UTILS_DIR)/iscsi-boot/init: $(OBJDIR)/$(UTILS_DIR)/iscsi-boot/init.o $(OBJDIR)/$(UTILS_DIR)/iscsi-boot/iscsi-network-boot.o
	$(CC) $(CFLAGS) -static -o $@ $^

dirs:
	@mkdir -p $(OBJDIR)
	@mkdir -p $(OBJDIR)/$(DAEMON_DIR)
	@mkdir -p $(OBJDIR)/$(DISCOVERY_DIR)
	@mkdir -p $(OBJDIR)/$(UTILS_DIR)
	@mkdir -p $(OBJDIR)/$(UTILS_DIR)/iscsi-boot
	@mkdir -p $(OBJDIR)/$(COMMON_DIR)
	@mkdir -p $(OBJDIR)/$(AUTH_DIR)
	@mkdir -p $(OBJDIR)/$(LOGIN_DIR)
	@mkdir -p $(OBJDIR)/$(MISC_DIR)

permissions:
	@chmod 744 $(SCRIPT_DIR)/rc.iscsi
	@chmod 744 $(UTILS_DIR)/iscsi-boot/mkinitrd.iscsi
	@chmod 744 $(SCRIPT_DIR)/install.sh
	@chmod 744 $(SCRIPT_DIR)/remove.sh
	@chmod 744 $(SCRIPT_DIR)/iscsi-mountall
	@chmod 744 $(SCRIPT_DIR)/iscsi-umountall
	@chmod 744 $(SCRIPT_DIR)/iscsi-ls
clean:
	rm -rf $(OBJDIR) *.o $(DRIVER_DIR)/*.ko $(DRIVER_DIR)/.*.cmd $(DRIVER_DIR)/*.mod.c $(DRIVER_DIR)/*.o $(DRIVER_DIR)/.tmp_versions $(COMMON_DIR)/*.o $(AUTH_DIR)/*.o $(AUTH_DIR)/.*.cmd $(LOGIN_DIR)/*.o $(LOGIN_DIR)/.*.cmd $(AUTH_DIR)/*.mod.c $(COMMON_DIR)/*.mod.c

module: 
	@sed -e 's|COMMON_DIR:=common|COMMON_DIR:=..\/common|' <driver/Makefile > kernel.Makefile ;\
	sed -e 's|(DRIVER_DIR)\/|(DRIVER_DIR)|' < kernel.Makefile > driver/Makefile; \
	rm -f kernel.Makefile ;\
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD)/driver modules;
	@sed -e 's|COMMON_DIR:=..\/common|COMMON_DIR:=common|' <driver/Makefile > kernel.Makefile ;\
	sed -e 's|(DRIVER_DIR)|(DRIVER_DIR)\/|' < kernel.Makefile > driver/Makefile; \
	rm -f kernel.Makefile ;\



----- End forwarded message -----



Messages sorted by: Reverse Date, Date, Thread, Author