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 912B91A6812 for ; Thu, 2 Apr 2026 12:57:59 +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=1775134686; cv=none; b=WI4Hw1ODKZ1OJOXwLgN6Es2srILuHwppvuRscEKUsH2ZzM+2jseARWyQJyXGlBZZQAHFIOpskb1kNB4LTw+SgSszmoqUne3X8OvMnAuGAe4LDu4jiOAS/7ZlMCIrKwfG7B7ilwHUNrbAiQWT/ShxgNPWmUnaaADX3trXoVLBWaw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775134686; c=relaxed/simple; bh=6FnZYlwyMDNLBNq27zxxOGZMwlAGDhGk7FWZ0NbrvLQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TepALO26Y14skx50qtawisaI6gxFV+eHSRcciZ8VIMlNl+s0vFPOnm9WWDRAtH4JHBJjOY9obt29Ax52s3mT2I1bvgPYVP/w5KERG9BGffeq+juRWKAGV1gQ+4p3opSHH68zWFGpAtMzkPcVXhWvQ+QKFzCZbp3Cw8Yx7NHy9qI= 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=Uclq5Spj; 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="Uclq5Spj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775134678; 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=eoOVeXGUHJIPyXgQfDU061gQQk/lbF5NXSd6xI6h5OM=; b=Uclq5SpjeyGSWvEl9Vm0c5lL8wLz4t/P4/rQqxvjyO0W/KLKO45YbbghQwyER0kQLX0kYl c8hJ9rXjKStwi4GwrMGN7j4tJsnw4UhDvFHcri5BUcvaV05N322PwkGl+rdvOFeHl2cNYb sCGRqlaSt48PdQWxE5UQQPwA0vkow/4= 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-591-HW5H98b1M_uiPAQjctu9Jg-1; Thu, 02 Apr 2026 08:57:56 -0400 X-MC-Unique: HW5H98b1M_uiPAQjctu9Jg-1 X-Mimecast-MFC-AGG-ID: HW5H98b1M_uiPAQjctu9Jg_1775134675 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 5D5F21800283; Thu, 2 Apr 2026 12:57:55 +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 9086030002D2; Thu, 2 Apr 2026 12:57:52 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 2 Apr 2026 14:57:54 +0200 (CEST) Date: Thu, 2 Apr 2026 14:57:51 +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: <20260402111332.55957-1-tpluszz77@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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 >