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 4C2F331690A for ; Thu, 2 Apr 2026 13:13:32 +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=1775135613; cv=none; b=KB5GvNum/pUPourbPgLHNTyZ+yhRDCTZ7asoqq+JOib9zcwy17XKbrTy4rVt6i32CrbxIdAtZz4RP63wUU5A6DaPnKcNSKW6Strk/v/AzFvpDZMNnn7gvqSZrQzyF7F2Iw63bEMNalnbiDqlkb7AIjTYHCzu961S0MFDDEBeXOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775135613; c=relaxed/simple; bh=/YRNIQrSkQf4zLA1baxaQXSwOyrPQlDuT6XsLrPAOZ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J1MoRQnXYewqiMdAqW3JjriPJams3KFShJ2HP6NgUFQYgg0yst2e6ov86WLIW1qy7zfOBEdzVD/ULg623V0+Ed1EmnetlEuAJMq8o/DMWY4dpYBJBPnezRL/CLWwoxf9HVGCnNV2o9EomB//HpLALxKtj0bNmX/J36+bsJE7W24= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=DrZSCQ2J; arc=none smtp.client-ip=170.10.129.124 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.b="DrZSCQ2J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775135611; 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=8dqJbydy8kPoZ8vkvOHpYwvti02M9iy/iDgel0f8R/U=; b=DrZSCQ2J4bbTETc4NSJ8k1m/MdzeMP2OAmIUT/S028+Bs9ncMi6wbkBoOn6an/a0PlOhwL RUH+PO3GIeHtxldq94R21biAZ4fjEWLHTUGQYgqet38LYcXOCIiLq/ntaA5Ni/KiASZDb6 9T+GfIhK2ejc1NRuJJnkKCa756Xn1Is= 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-617-6yz4-_QfOT6mBShUEPdWVQ-1; Thu, 02 Apr 2026 09:13:27 -0400 X-MC-Unique: 6yz4-_QfOT6mBShUEPdWVQ-1 X-Mimecast-MFC-AGG-ID: 6yz4-_QfOT6mBShUEPdWVQ_1775135601 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 D22D51800654; Thu, 2 Apr 2026 13:13:19 +0000 (UTC) Received: from fedora (unknown [10.44.36.60]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 0F60730002D2; Thu, 2 Apr 2026 13:13:16 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 2 Apr 2026 15:13:19 +0200 (CEST) Date: Thu, 2 Apr 2026 15:13:15 +0200 From: Oleg Nesterov To: Qi Tang Cc: Andrew Morton , Cyrill Gorcunov , David Hildenbrand , Lorenzo Stoakes , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] prctl: require checkpoint_restore_ns_capable for PR_SET_MM_MAP Message-ID: References: <20260402111332.55957-1-tpluszz77@gmail.com> 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: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Note also the comment above validate_prctl_map_addr() called by prctl_set_mm_map(), "we don't require any capability here ...". Oleg. On 04/02, Oleg Nesterov wrote: > > On 04/02, Qi Tang wrote: > > > > The original commit f606b77f1a9e ("prctl: PR_SET_MM -- introduce > > PR_SET_MM_MAP operation") states "we require the caller to be at least > > user-namespace root user", but this was never enforced in the code. > > > > Add a checkpoint_restore_ns_capable() check at the top of > > prctl_set_mm_map(), after the PR_SET_MM_MAP_SIZE early return. This > > requires CAP_CHECKPOINT_RESTORE or CAP_SYS_ADMIN in the caller's > > user namespace, matching the stated design intent and the existing > > check for exe_fd changes. > > Can't really comment... but if you add this check at the start, then you > should also remove the same checkpoint_restore_ns_capable() check below? > In the "if (prctl_map.exe_fd != (u32)-1)" block. > > Oleg. > > > > Fixes: f606b77f1a9e ("prctl: PR_SET_MM -- introduce PR_SET_MM_MAP operation") > > Cc: stable@vger.kernel.org > > Cc: Cyrill Gorcunov > > Signed-off-by: Qi Tang > > --- > > kernel/sys.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/kernel/sys.c b/kernel/sys.c > > index c86eba9aa7e9..2b8c57f23a35 100644 > > --- a/kernel/sys.c > > +++ b/kernel/sys.c > > @@ -2071,6 +2071,9 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data > > return put_user((unsigned int)sizeof(prctl_map), > > (unsigned int __user *)addr); > > > > + if (!checkpoint_restore_ns_capable(current_user_ns())) > > + return -EPERM; > > + > > if (data_size != sizeof(prctl_map)) > > return -EINVAL; > > > > -- > > 2.43.0 > >