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.133.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 7D3CA289367 for ; Sun, 28 Jun 2026 17:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782669131; cv=none; b=qD/9NsaHt5F1nhtr+1sA08tuiHy5KNWimyflDKugKqCWgesiHY+nS95wMDadqeJyJ9Mcx2WIONO46eO11oozMiB/y6qg9W+7Nykdx/Wqh5fsHhazGAwIeDqv0QI4FzvJLgqGgj2O6lWC3mp+c/CIvoauTb5tVP6P1VlesjQFZCI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782669131; c=relaxed/simple; bh=xKY3iZZVHAHAsPzQrKIy/GdBNipb/JTblcnVjOYBqmY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dlwyp9KJ1SH9p+ZGx0riXe/AoCo0iX6k4yblzJIWUrYiZFZldmvdrb/GPZb4VzY16FBr00/+PmrRjcV+Ha9g68WvymhrPqi+WV4jScnx3SQhhtzean3EwUuv8TkHsfExulWE3qaBPowDMchOxlYqcRCa4geQxHSnuZv70GXjNz0= 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=RDXTpk+Y; arc=none smtp.client-ip=170.10.133.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="RDXTpk+Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782669128; 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=LawV63VLdDYYH2sjurgoXx+NaUSo/fOiiMBdvafIKpQ=; b=RDXTpk+YORpUnn82KGFd8LYpCpBm6uLmcbOoByv89YgjogJxzc0tq3eDJyTIC16g+wFIaK 2IIxT0wc/dS2wfhJ4wNfW8fcIFcnSe9263b5A5u3PnF0bP05W/1aBZA6E/xyGtzPhDb5PP JI1loBBaLwaD08A7RZUDZCNXpfKBlf0= Received: from mx-prod-mc-05.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-232-yX3B0ULONFGHNfobNxcJyQ-1; Sun, 28 Jun 2026 13:52:04 -0400 X-MC-Unique: yX3B0ULONFGHNfobNxcJyQ-1 X-Mimecast-MFC-AGG-ID: yX3B0ULONFGHNfobNxcJyQ_1782669123 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E1C8F19560BC; Sun, 28 Jun 2026 17:52:02 +0000 (UTC) Received: from fedora (unknown [10.44.32.34]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 89CFE1766; Sun, 28 Jun 2026 17:52:00 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 28 Jun 2026 19:52:02 +0200 (CEST) Date: Sun, 28 Jun 2026 19:51:58 +0200 From: Oleg Nesterov To: Andrew Morton Cc: Bradley Morgan , "Eric W. Biederman" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] signal: change sys_kill() to use SEND_SIG_NOINFO Message-ID: References: <20260626093603.7eb06a58684e0d02f3b9d0f8@linux-foundation.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: <20260626093603.7eb06a58684e0d02f3b9d0f8@linux-foundation.org> X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 On 06/26, Andrew Morton wrote: > > On Fri, 26 Jun 2026 17:33:08 +0200 Oleg Nesterov wrote: > > > prepare_kill_siginfo(PIDTYPE_TGID) fills si_code = SI_USER and sets > > si_pid/si_uid in the sender's namespace. Then send_signal_locked() > > translates si_pid/si_uid to the target's namespace. > > > > SEND_SIG_NOINFO produces the same result: si_code = SI_USER, and > > __send_signal_locked() computes si_pid/si_uid directly in the target's > > namespace. The force computation is also the same: both check if the > > sender is visible in the target's pid namespace. > > The above paragraphs contain no description of any flaw. What's wrong > here? Ah, sorry. nothing wrong if we forget about the fix from Bradley, but we need this fix with or without this cleanup... > > Note: this also fixes the kill(-1, sig) case where send_signal_locked() > > rewrites si_pid/si_uid in the shared siginfo, corrupting it for subsequent > > recipients. But for other group senders like __kill_pgrp_info() we still > > need the fix from Bradley Morgan [1] who found this problem. > > "also fixes". Again, what was the first fix? Agreed. This is confusing. > Thanks, I'll queue this for testing. Thanks, > Please send along some changelog > edits sometime? Please see the new changelog below. Does it look more clear? Bradley, do you agree? Oleg. --- signal: change sys_kill() to use SEND_SIG_NOINFO prepare_kill_siginfo(PIDTYPE_TGID) fills si_code = SI_USER and sets si_pid/si_uid in the sender's namespace. Then send_signal_locked() translates si_pid/si_uid to the target's namespace. SEND_SIG_NOINFO exists precisely for the case when si_code == SI_USER and si_pid/si_uid are the sender's ids; this is exactly what sys_kill() does via prepare_kill_siginfo(PIDTYPE_TGID). Change sys_kill() to use it directly. SEND_SIG_NOINFO produces the same result: si_code = SI_USER, and __send_signal_locked() computes si_pid/si_uid directly in the target's namespace. The force computation is also the same: both check if the sender is visible in the target's pid namespace. This is just a cleanup and microoptimization (especially with [1]), this skips the has_si_pid_and_uid() block in send_signal_locked() and offloads the namespace translation logic to __send_signal_locked(SEND_SIG_NOINFO) which uses the simpler computations. NOTE: As a "side effect" this also fixes the kill(pid < 0, sig) case where send_signal_locked() rewrites si_pid/si_uid in the shared siginfo, corrupting it for subsequent recipients. But for other group senders like __kill_pgrp_info() we still need the fix from Bradley Morgan [1] who found this problem. TODO: kill prepare_kill_siginfo() and change other users to use SEND_SIG_NOINFO too. This needs trivial changes in __send_signal_locked() and TP_STORE_SIGINFO(). Link: https://lore.kernel.org/all/20260622164029.11474-1-include@grrlz.net/ [1] Signed-off-by: Oleg Nesterov