Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2032169pxb; Fri, 25 Mar 2022 09:55:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYbsJLU6aempsOSgJPg8HkYX9l2LUlxjfN6kEka8aI+CmIlG5l9Fp7oRYG/RRFPy3Usiju X-Received: by 2002:a17:906:9c8e:b0:6df:f6bf:7902 with SMTP id fj14-20020a1709069c8e00b006dff6bf7902mr12530708ejc.191.1648227314078; Fri, 25 Mar 2022 09:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648227314; cv=none; d=google.com; s=arc-20160816; b=IIOWkA/mTpIyYyX225fKU9bAi0j5a6DrhB69SfHEsqteIUf4BJqYp3LDIiUYDlVakX ctmeHIp7o1OE3eIpiKJ3FqRBrhgv1VJV6onvkBYj7pbUnzp5fza/ch6/pua5mVUIzSIm XMcVI+bTg1Vzx4UDW9AQRNG3t6uUq4mGthex1ySe4pv7qmqknWoO1X+v5HJ/Eb+6R4PB d53ZO0gMSZennC5SHHD7+Sgm3r1iS86zXm40IBUZEkjgJQutNOs4a4vyxQxmCz6v1U9l pl7Z8x161ZG2cM0kigfZ/79wkbW2jM0ohgRpRVFBwpKjJr4LjChYm/Ck12wYSa7PDdkZ Kg8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/LSEoPoVBVnfztCSkUFcbwBfE5ukisNTx0Z0bM1jWgk=; b=Lue2qv5ZGnQ+ZwZjhbBcIF69AcCqH2AoxAM8rUyzQ3KHQP8tNTSh/ynOV/YOE8N+Bi fQt+BeM7D0IB6xzGRj+by4C+KL0o+XeWgj73y9YvRe4sa8Uhy4egWkGFw59+0VXLRY77 PA5ONgi9xFciak++Hr1sFgHe0k6Ml3RoEMCNM+1iD++ptr1KEa/uT13B68uHTAV7SOR+ uhEngLtNaQOYRXx9EAuWaP9NhBMrb+9ALfNgWTqDkt6bLVsxJv3YZuabew8SetTxX9u6 lGAaWQTjrcHDs4DopFDuITa5cEsiXI4EL4neRygzH0OLLoPPYeHiLbTOsXkJddS3/ICa 9z/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=fBZauSq0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a056402275300b00419a573741dsi3082836edd.255.2022.03.25.09.54.47; Fri, 25 Mar 2022 09:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=fBZauSq0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352540AbiCXSOS (ORCPT + 99 others); Thu, 24 Mar 2022 14:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352542AbiCXSOQ (ORCPT ); Thu, 24 Mar 2022 14:14:16 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EB52B7168 for ; Thu, 24 Mar 2022 11:12:44 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id k21so9463614lfe.4 for ; Thu, 24 Mar 2022 11:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/LSEoPoVBVnfztCSkUFcbwBfE5ukisNTx0Z0bM1jWgk=; b=fBZauSq0ACQcCD0aXGuuoIgacGzWbZWvHI/yboiImq3d2gbCBsK4u0P2R6I9rA5s+1 llLlGyVUkbHFxwANgyrhG7OcuWCL4PearUKXNl+3bWauMSB43nTGA6zaQsGMBIOxTMat Y9LYQyxU0oUnKd77In8/8H15bD1XyIFNQEVc4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/LSEoPoVBVnfztCSkUFcbwBfE5ukisNTx0Z0bM1jWgk=; b=WDHBadPDRFzXW85OeY1DDEatY/o256RjHJwyYNtZ8yULIZLI5x2X0edB6yscm0pi8V 8z1NMaho1a1qIyIlRSuMcYwjHTuNFqXCJHzMppNJAmh+IHBhCS/8C3d2MoYzMV+qnKTs b1iFkwyPkjPVzpU0INDww++J5el8Nt9Hwj389M89hc0gdi/mjaIQ8+/GyfEeaBeARQGt jUfGPn3as8UxusDAM3cmyDTShVbQceDrq0o/SrVHxeGk+QPspiheM77AePeZM1h/R2S1 U47QMrgAXLElCpvqgDrQC5n2zd8SeJVV4j43BRzoe+OkN+Odh3j9VXxMgG2lpKCGgy9u divQ== X-Gm-Message-State: AOAM532DGhkYOCo3zloG91CiZFzsKmG1ZqRTY+N7w0hKdMCqqnJUSu5A etoehN7jl5VLXT3cO2df+OEtu/2L/lwa773d2pE= X-Received: by 2002:a05:6512:2395:b0:44a:33d2:b9b5 with SMTP id c21-20020a056512239500b0044a33d2b9b5mr4743483lfv.514.1648145562200; Thu, 24 Mar 2022 11:12:42 -0700 (PDT) Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com. [209.85.208.173]) by smtp.gmail.com with ESMTPSA id k9-20020a192d09000000b004487dfc9d9csm415417lfj.260.2022.03.24.11.12.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Mar 2022 11:12:38 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id 17so7270447ljw.8 for ; Thu, 24 Mar 2022 11:12:38 -0700 (PDT) X-Received: by 2002:a2e:a5c4:0:b0:249:9ec3:f2b with SMTP id n4-20020a2ea5c4000000b002499ec30f2bmr4898966ljp.358.1648145558024; Thu, 24 Mar 2022 11:12:38 -0700 (PDT) MIME-Version: 1.0 References: <877d8kfmdp.fsf@email.froward.int.ebiederm.org> In-Reply-To: <877d8kfmdp.fsf@email.froward.int.ebiederm.org> From: Linus Torvalds Date: Thu, 24 Mar 2022 11:12:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] ipc: Bind to the ipc namespace at open time. To: "Eric W. Biederman" , Alexey Gladkov Cc: LKML , Linux Containers , Alexander Mikhalitsyn , Andrew Morton , Christian Brauner , Daniel Walsh , Davidlohr Bueso , Kirill Tkhai , Manfred Spraul , Serge Hallyn , Varad Gautam , Vasily Averin Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 23, 2022 at 1:24 PM Eric W. Biederman wrote: > > Please pull the per-namespace-ipc-sysctls-for-v5.18 tag from the git tree: Ugh. I pulled this. Then I stared at it for a long time. And then I decided that this is too ugly to live. I'm sorry. I think Alexey has probably spent a fair amount of time on it, but I really think the sysctl code needs to be cleaned up way more than this. The old code was horribly hacky too, but that setup_ipc_sysctls() (and setup_mq_sysctls()) thing that copies the whole sysctls table, and then walks it entry by entry to modify it, is just too ugly for words. And then it hides things in .extra1, and because it does that it can't use the normal "extra1 and extra2 contains the limits" so then at write() time it copies it into a local one AGAIN only to set the limits back so that it can call the normal routines again. Not ok. Yes, yes, the old code did some similar things - to set the 'data' pointer. That was disgusting too. Don't get me wrong - the existing code was nasty too. But this took nasty code, and doubled down on it. I really think this is a fundamental problem, and needs a more fundamental fix than adding more and more of these kinds of nasty hacks. And yes, that fundamental fix is almost certainly to pass in 'struct cred *' to all those sysctl helper functions. Then, when you do the actual 'sysctl()' system calls, you pass in 'current_cred()". And the /proc users would pass in file->f_cred. And yes, that patch might be quite messy, because we have quite a lot of those random .proc_handler users. But *most* of them by far (at least in random code) use the standard proc_dointvec_minmax() and friends, and won't even notice. And then the ones that are about namespace issues will have to continue to do the nasty "make a copy and update the data pointer", but *MAYBE* we could also introduce the notion of an "offset" to those proc_dointvec_minmax() things to help them out (and at least avoid the "make a copy" thing). Anyway, I really think we must not make that sysctl code even uglier than it is today, and I think we need to move towards a model that actually makes sense. And that "pass in the right cred" is the only sensible model I can see. I haven't tried to create such a patch, and maybe Alexey already tried to do something like that and it turned out to be too ugly for words and that's why these nasty patches happened. But at least for now, I can't with a good conscience pull this. Sorry, Linus