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 00ADE3D7D6A for ; Wed, 5 Aug 2026 20:08:43 +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=1785960525; cv=none; b=DNyZ8Tdgz16pDxoxuOgsLs30Zxe/R/JuJ6I6pjKfKXVEHVUIHj0NLtt45eWTy6IWbyHL/RwxEfFBln6f1o64h1F7E7U9mDZrBF2vgwWGwqN526nIJ6MRUhW/7oET75DnZXmEjWC5fTeS7T3XYPRiibsTwAU9qWUjk3fMvhrAdAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785960525; c=relaxed/simple; bh=rQ4pZtnCCWdoa/iitpciMXyLEb2IFj5/AuQ5ewqI9Oo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uXrGbIW7jpgJvNMnCBxbb5kOqrFkGxaZvXKV384GLMskpoKTqAwvyglYQgewotSMfp9Hj7vCuI5s94Kyq2sOVzJt2wt1ujYzwjhsqqCh7KCvPPBjF2kPB2MFtvzRD1+sI5AAZIsHCKormroM+zTetF5njiE0tLqkfOhdtnDmzoM= 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=aA0PH9WU; 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="aA0PH9WU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785960522; 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=sTiyqmkl0v9aFMWMw5iqCr2lmn/LbjWqi//G2gw6tLQ=; b=aA0PH9WUg68gTrn8egO2aODbA4XFfcrPitP9YBKyAbKXE+0vOghgnZR7KhK61x4wEb0c4m zjoKZiLXkiQ88DiQwL++IwjKKDb8nRPInodfFrn5l8zBf6sGdaaXnHOA1yStShfnvevQDb YHP3YMQIOG6B8prq1hdPuiACnc20eqk= 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-9-aX8VdfKxMQ2kJXmGZFSBiA-1; Wed, 05 Aug 2026 16:08:38 -0400 X-MC-Unique: aX8VdfKxMQ2kJXmGZFSBiA-1 X-Mimecast-MFC-AGG-ID: aX8VdfKxMQ2kJXmGZFSBiA_1785960517 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 647121955F16; Wed, 5 Aug 2026 20:08:36 +0000 (UTC) Received: from fedora (unknown [10.44.32.54]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id A5295426; Wed, 5 Aug 2026 20:08:33 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 5 Aug 2026 22:08:35 +0200 (CEST) Date: Wed, 5 Aug 2026 22:08:31 +0200 From: Oleg Nesterov To: Bradley Morgan Cc: brauner@kernel.org, akpm@linux-foundation.org, tglx@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] signal: add a helper for the si_code kernel impersonation check Message-ID: References: <20260706124003.8000-1-include@grrlz.net> <28A302F8-20DB-46D6-AEA5-5F46824E57D4@grrlz.net> 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: <28A302F8-20DB-46D6-AEA5-5F46824E57D4@grrlz.net> X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 On 08/05, Bradley Morgan wrote: > > On 5 August 2026 20:26:47 BST, Oleg Nesterov wrote: > >On 07/06, Bradley Morgan wrote: > >> > >> +/* > >> + * si_code values >= 0 and SI_TKILL are reserved to the kernel. Not > >even > >> + * root can use them to pretend a signal was sent by the kernel or by > >> + * kill()/tgkill(), except when signaling itself. > >> + */ > >> +static bool si_code_reserved_to_kernel(int si_code) > >> +{ > >> + return si_code >= 0 || si_code == SI_TKILL; > >> +} > > > >... > > > >> static int do_rt_sigqueueinfo(pid_t pid, int sig, kernel_siginfo_t > >*info) > >> { > >> - /* Not even root can pretend to send signals from the kernel. > >> - * Nor can they impersonate a kill()/tgkill(), which adds source info. > >> - */ > >> - if ((info->si_code >= 0 || info->si_code == SI_TKILL) && > >> - (task_pid_vnr(current) != pid)) > >> + if (si_code_reserved_to_kernel(info->si_code) && > >> + task_pid_vnr(current) != pid) > > > >Well, technically this (cosmetic) change is obviouly correct. And I do > >agree > >it makes sense to factor out these checks and (more importantly) the > >comments. > > > >But. IMO, the new comment looks a bit worse. > > > >The old comment has "impersonate a kill()/tgkill(), which adds source > >info" > >and this in fact explains that si_code == 0 or si_code == SI_TKILL come > >with > >the real/valid .si_pid and .si_uid and the reciever can trust them. > > > > Hmm, what do you suggest? Hmm. it seems I wasn't clear... If nothing else you can keep the old comment: * Not even root can pretend to send signals from the kernel. * Nor can they impersonate a kill()/tgkill(), which adds source info. IMO, no need to add "si_code values >= 0 and SI_TKILL ..." at the start, this just mirrors what the new (and trivial!) helper does. May be you can improve it a bit, something like * Not even root can pretend to send SI_FROMKERNEL() signals. * Nor can they impersonate kill()/tgkill(), which have si_pid/uid but this is subjective and minor. I am fine either way. Just IMO the old comment(s) was more useful. Oleg.