Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946095Ab2JYPCW (ORCPT ); Thu, 25 Oct 2012 11:02:22 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:42130 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933975Ab2JYPCU (ORCPT ); Thu, 25 Oct 2012 11:02:20 -0400 MIME-Version: 1.0 In-Reply-To: <20121024124607.43f599e8.akpm@linux-foundation.org> References: <1350045042-1369134-1-git-send-email-avagin@openvz.org> <20121023165651.88af399d.akpm@linux-foundation.org> <20121024124607.43f599e8.akpm@linux-foundation.org> Date: Thu, 25 Oct 2012 19:02:18 +0400 Message-ID: Subject: Re: [PATCH] pidns: limit the nesting depth of pid namespaces From: Andrey Wagin To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Oleg Nesterov , Cyrill Gorcunov , "Eric W. Biederman" , Pavel Emelyanov Content-Type: multipart/mixed; boundary=047d7b621bdc5181f104cce37d0d Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5478 Lines: 103 --047d7b621bdc5181f104cce37d0d Content-Type: text/plain; charset=ISO-8859-1 2012/10/24 Andrew Morton : > On Wed, 24 Oct 2012 09:38:57 +0400 > Andrey Wagin wrote: > >> > >> > I think that returning -ENOMEM in response to an excessive nesting >> > attempt is misleading - the system *didn't* run out of memory. EINVAL >> > is better? >> >> I chose ENOMEM by analogy with max_pid. When a new PID can not be >> allocated, ENOMEM is returned too. > > I don't know what this means - please be carefully specific when > identifying kernel code. Sorry. > > If you're referring to kernel/pid.c:alloc_pid() then -ENOMEM is > appropriate there, because a failure *is* caused by memory allocation > failure. I'm referring to alloc_pidmap(). For example I set pid_max to 500 and try to create more than 500 processes. [pid 345] clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f8721716a10) = -1 ENOMEM (Cannot allocate memory) Actually I'm agree with EINVAL and a patch is attached to this message. Thanks. > > But ENOMEM isn't appropriate for nesting-depth-exceeded - we shouldn't > tell the user "you ran out of memory" when he didn't! -EINVAL isn't > really appropriate either ("Invalid argument") but it has become a > general you-screwed-up catchall and seems to me to be the most > appropriate errno we have available. > --047d7b621bdc5181f104cce37d0d Content-Type: application/octet-stream; name="0001-pidns-limit-the-nesting-depth-of-pid-namespaces-v2.patch" Content-Disposition: attachment; filename="0001-pidns-limit-the-nesting-depth-of-pid-namespaces-v2.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_h8q01vib0 RnJvbSA1MzI4NmJhMGNmNTY1ODUwNDhiNTM2Mzg0NGRlYzkyNDA4MWZlMDZkIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbmRyZXcgVmFnaW4gPGF2YWdpbkBvcGVudnoub3JnPgpEYXRl OiBXZWQsIDEwIE9jdCAyMDEyIDEyOjIyOjE2ICswNDAwClN1YmplY3Q6IFtQQVRDSF0gcGlkbnM6 IGxpbWl0IHRoZSBuZXN0aW5nIGRlcHRoIG9mIHBpZCBuYW1lc3BhY2VzICh2MikKCidzdHJ1Y3Qg cGlkJyBpcyBhICJ2YXJpYWJsZSBzaXplZCBzdHJ1Y3QiIC0gYSBoZWFkZXIgd2l0aCBhbiBhcnJh eQpvZiB1cGlkcyBhdCB0aGUgZW5kLgoKQSBzaXplIG9mIHRoZSBhcnJheSBkZXBlbmRzIG9uIGEg bGV2ZWwgKGRlcHRoKSBvZiBwaWQgbmFtZXNwYWNlcy4gTm93CmEgbGV2ZWwgb2YgcGlkbnMgaXMg bm90IGxpbWl0ZWQsIHNvICdzdHJ1Y3QgcGlkJyBjYW4gYmUgbW9yZSB0aGFuIG9uZQpwYWdlLgoK TG9va3MgcmVhc29uYWJsZSwgdGhhdCBpdCBzaG91bGQgYmUgbGVzcyB0aGFuIGEgcGFnZS4gTUFY X1BJU19OU19MRVZFTAppcyBub3QgY2FsY3VsYXRl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EX05TX0xFVkVMIGlzIG5lZWRlZCBmb3IgbGltaXRpbmcgc2l6ZSBv ZiAnc3RydWN0IHBpZCcgKi8KKyNkZWZpbmUgTUFYX1BJRF9OU19MRVZFTCAzMgorCiBzdGF0aWMg c3RydWN0IHBpZF9uYW1lc3BhY2UgKmNyZWF0ZV9waWRfbmFtZXNwYWNlKHN0cnVjdCBwaWRfbmFt ZXNwYWNlICpwYXJlbnRfcGlkX25zKQogewogCXN0cnVjdCBwaWRfbmFtZXNwYWNlICpuczsKIAl1 bnNpZ25lZCBpbnQgbGV2ZWwgPSBwYXJlbnRfcGlkX25zLT5sZXZlbCArIDE7CiAJaW50IGksIGVy ciA9IC1FTk9NRU07CiAKKwlpZiAobGV2ZWwgPiBNQVhfUElEX05TX0xFVkVMKQorCQlyZXR1cm4g RVJSX1BUUigtRUlOVkFMKTsKKwogCW5zID0ga21lbV9jYWNoZV96YWxsb2MocGlkX25zX2NhY2hl cCwgR0ZQX0tFUk5FTCk7CiAJaWYgKG5zID09IE5VTEwpCiAJCWdvdG8gb3V0OwotLSAKMS43LjEK Cg== --047d7b621bdc5181f104cce37d0d-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/