From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796142417; b=O2rcKo33JYUZbdxMI4IhM44xXMNN2KHYeFmAQMEG8P7jpHDh0eivsp89FIUWqWt8gzHv y2isg2HDV+ulmYLRI4BVaSlK12rK1tecA3WO4y0s3kg5go/TZlIZR/vtdOwsE7awjYIeC zqIK8QKUxS1uYdPRegHWCtvkarVFUpa3ETRUdr5mQZ2VU7S+XkWHIUezOjSprsfN2lMpF SE+1DPVq9pf0+W7J0XrfFlXcMAINuzbd3qTo/0PHsOG85iZeGJbyPZbyh3m5vWPd6mw7v 5fgElcTOs73lxiWlTRwtB8pB8+e6/352FnVAvPOl9b0fxS7oK2OtbweHwWz1cGx5xRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142417; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-Scanned-By; bh=wizu3QMBFDGPULlL5fglWg3tqsGyeCiGnyiO999Xu3Y=; b=10FHcHXdpL9T8aUY5Mijky5/xV7fSEQu9RHot5jNY9DX3Qj5Lds9N102GWZ7rpaRYfqK POohbixnCWdPCcWzs5tyJZe4LvV/6QLyAukbZN+fM/0NKeVcuqZr5+prxFst8MRixz/GW aCScrlgvMN+qE9tLAsFh5it2smHaJkKru4c44Xu1K0iAj+ozRWtItdat2pD2V+OrcB7O7 H+AsCwAnoW+niXKnuosctcK5Oimkz4EyfciQUNnALHRyt1cn8cb9NKnj79kQ5am5Uxa+i J8arcix03sKGccR9Mg7/b9e2N9+wyTrn2JvERL90XHVp/GZ1uOFB0x5rmKlr6yYSXOQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=A6iCfDxt; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9392E606A68D for ; Tue, 1 Dec 2026 16:26:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9392E606A68D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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.a=rsa-sha256 header.s=mimecast20190719 header.b=A6iCfDxt DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796142415; 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=wizu3QMBFDGPULlL5fglWg3tqsGyeCiGnyiO999Xu3Y=; b=A6iCfDxtnYAqiekx0O34gmWIMyvkeX1yHT4pBvdp1Kn2LDqSfkc1tH6X4b9iY1BPvSFH1H UE6RvH35IaCVgwpV1ABH7sHEf4sHfUtnLPmu5ThgWeDgKQad53cW0aI3awG+eEp5uZrP3x +O7mrBzgQkaWQwD+aGsKCkFdtVauU9Y= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-34-7bGJilM1M8m_j09HkRDqSw-1; Tue, 1 Dec 2026 16:26:49 +0000 X-MC-Unique: 7bGJilM1M8m_j09HkRDqSw-1 X-Mimecast-MFC-AGG-ID: 7bGJilM1M8m_j09HkRDqSw_1796142407 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 31CA8180AE8F; Tue, 1 Dec 2026 16:26:08 +0000 (UTC) Received: from onestero-thinkpadp1gen7.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 82C1630002FA; Tue, 1 Dec 2026 16:26:05 +0000 (UTC) Received: by onestero-thinkpadp1gen7.tpbc.csb (nbSMTP-1.00) for uid 13628 oleg@redhat.com; Tue, 1 Dec 2026 17:26:07 +0100 (CET) Date: Tue, 1 Dec 2026 17:26:04 +0100 From: Oleg Nesterov To: Chen Linxuan Cc: Hungyu Lin , akpm@linux-foundation.org, brauner@kernel.org, adobriyan@gmail.com, jannh@google.com, jack@suse.cz, sforshee@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] proc: also check the opener's capability for oom_score_adj and oom_adj Message-ID: References: <20261126045222.20770-1-dennylin0707@gmail.com> X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Damn ;) let me apologise first, I'am afraid my comments just added the unnecessary noise to this thread. But don't worry, I am going to add even more noise, please see below. On 12/01, Chen Linxuan wrote: > > LGTM. A few additional comments below. Same here, please see below. > On Thu, Nov 26, 2026 at 11:50:54AM +0100, Oleg Nesterov wrote: > > do we really need to keep the old capable(CAP_SYS_RESOURCE) check? > > > > If a privileged opener of /proc//oom_score_adj passes fd to > > to unprivileged writer, we probably don't care? > > I agree with keeping the writer-side check: a permission check should not be > relaxed without a detailed justification. OK, agreed. In case it wasn't clear let me repeat: I didn't really try to argue, I just tried to understand this patch. Oh. Now let me also repeat that I don't really understand this code, so you can safely ignore me. ------------------------------------------------------------------------------- That said... So. To simplify, lets forget about "legacy", ->vfork_done, and CAP_OPT_NOAUDIT. And about this patch for the moment. In essence we have if (oom_adj < oom_score_adj_min && !CAP_SYS_RESOURCE) // CHECK 1 return -EACCES; oom_score_adj = oom_adj; // unconditional if CHECK 1 passes if (CAP_SYS_RESOURCE) // CHECK 2 oom_score_adj_min = oom_adj; This already looks messy to me, but perhaps this is because I don't really understand this logic. Now lets recall that this patch adds file_ns_capable() into CHECK 1, but not into CHECK 2. Now. Lets suppose a task T has oom_score_adj = oom_score_adj_min = 0. This task does "setuid-app-which-writes-500-to-stdout > /proc//oom_score_adj". CHECK 1 is skipped. CHECK 2 passes (app is setuid), oom_score_adj_min is raised to 500. Now, T can't lower oom_score_adj back to 0. Compare that with the case when T writes "500" directly: oom_score_adj becomes 500, but oom_score_adj_min is still 0. And in this case T still can lower its oom_score_adj to 0. That is why I tried to suggest to unify / factor out CAP_SYS_RESOURCE checks (again, let's ignore the possible noise from audit). I mean, suppose we add bool xxx = CAP_SYS_RESOURCE && file_ns_capable(CAP_SYS_RESOURCE); at the start and change __set_oom_adj() to use it consistently. In this case CHECK 1 and 2 will agree at least in the scenario above: oom_score_adj_min will be 0. Oleg.