From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB34817DE15 for ; Sun, 3 Nov 2024 16:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730652678; cv=none; b=R3/8hlOv3pwVubNxsrfc6s7RKWfwbTuhlU6w1BgfEhqC9uHrGj16yjmWQ1PxU7KBO4Wy0Ns3BKGVL/HM9HvNO4yRgjA2TltWuPa92wOSI8aLYpvI1SvY3fifihaPtiitWBxSiOXMh3msg9mdEC2/B1xT3+7V6sKrkP/e1+NyBc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730652678; c=relaxed/simple; bh=ZsSNw+9icvvVr1pjTy3qhV4A/3FHQpPNRzqxjXLdzes=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YY6SoU6GcpWsLevgzsf70HEXFuG8AIGndewbgeab/4+Osd6d0JHPvh7P0qc/bM4sJaqdi6/TqVvB7CaXo4+yezqhMUm1NjcCELKaRQmv/FTAF3KQnY/Iju48AFAr30kiiRln/s4Wc2WV04nlCA/Qe76CUxaMzgzoKa4lTi84RwI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PjQtmZjI; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PjQtmZjI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730652675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ypFPoKgiYqq9zLFDMM1v1jWtbkTfe/etxTifSjr94PA=; b=PjQtmZjIvO1hNPvL5gJ/wTPSQ1NoZbFYjpUCTzbarYDvmG/86AxJ7PTGhfhZakBcaXNf1q q6+qg2jk3R/DUggdhexDSzKGHgYs7LBg01L2IcL+ropxjL2F7q0Lf7dOLCyOWGkaUKkzWe Qdj8Def17XPQufJgBvXV9sHB9MXpmj8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-XVBUbNQ2PpClkvWU62iKzQ-1; Sun, 03 Nov 2024 11:51:12 -0500 X-MC-Unique: XVBUbNQ2PpClkvWU62iKzQ-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A513A19560B1; Sun, 3 Nov 2024 16:51:10 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.49]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id A6B4C19560A2; Sun, 3 Nov 2024 16:51:07 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 3 Nov 2024 17:50:53 +0100 (CET) Date: Sun, 3 Nov 2024 17:50:49 +0100 From: Oleg Nesterov To: Alexey Gladkov Cc: Andrei Vagin , "Eric W. Biederman" , Roman Gushchin , linux-kernel@vger.kernel.org, Kees Cook , stable@vger.kernel.org Subject: Re: [PATCH] signal: restore the override_rlimit logic Message-ID: <20241103165048.GA11668@redhat.com> References: <20241031200438.2951287-1-roman.gushchin@linux.dev> <87zfmi3f8b.fsf@email.froward.int.ebiederm.org> <87o72y3c4g.fsf@email.froward.int.ebiederm.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On 11/02, Alexey Gladkov wrote: > > +Cc Oleg Nesterov. Well, I tend to agree with Roman and his patch looks good to me. But it seems that the change in inc_rlimit_get_ucounts() can be a bit simpler and more readable, see below. Oleg. --- --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -307,7 +307,8 @@ void dec_rlimit_put_ucounts(struct ucounts *ucounts, enum rlimit_type type) do_dec_rlimit_put_ucounts(ucounts, NULL, type); } -long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_type type) +long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_type type, + bool override_rlimit) { /* Caller must hold a reference to ucounts */ struct ucounts *iter; @@ -320,7 +321,8 @@ long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_type type) goto unwind; if (iter == ucounts) ret = new; - max = get_userns_rlimit_max(iter->ns, type); + if (!override_rlimit) + max = get_userns_rlimit_max(iter->ns, type); /* * Grab an extra ucount reference for the caller when * the rlimit count was previously 0.