From patchwork Mon Feb 26 16:56:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 206805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2212946dyb; Mon, 26 Feb 2024 09:11:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXEx3GaMCZQjSzNEzYZB+rQkQnAbdryDZaDjYwX268hwlzhwk1ukToP0yWiuYA987KoEjsbVv6ktSp1mO+46niWO5oAVw== X-Google-Smtp-Source: AGHT+IGSG2ogeLqy6fBd2MS9GnM+lOgLwkDkvq609hmRQ945DXlKCVPjdGXOYlog0P+WnR6B7GcE X-Received: by 2002:a05:6512:40e:b0:512:cebe:d035 with SMTP id u14-20020a056512040e00b00512cebed035mr4551125lfk.52.1708967462176; Mon, 26 Feb 2024 09:11:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967462; cv=pass; d=google.com; s=arc-20160816; b=h0YnZgYHDgUm/HJ9mOuYsDDIUT60jRRi49VZfksD0AhxIVANTo28n8FlI5hKwAiUCk AnYeimKX6ry9Yi+wjKTy9kaz5AZA+TjGoIsOu0br7sEqI5uekhnG3c/kyMod3E6W/vvn 9iXk+DuHhvscMMbDQ8Ck5h+PQatIaRDnDKi6QSLnkswLfKb0Rra6Q/wbS6ew5HTVpzqh uiTn6A573uZj9N639xaxrIFzWXYrDmt/FQ2fE/nZoSYWZXuUt9Hek9/w3YtDs77k25QC LpjAU5WLaEeS47AW5dBsyqNatJVm2I6Q66JhL5p7PDdLjPRNQ7WrfA2WfPSR/LEpzoZX LeJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id :subject:cc:to:from:date:dkim-signature; bh=sSoBVhFfYf93x8huXQpUdUaaiwpj6qVsl4+myZwSTiY=; fh=XYYaR4W4e5P6Am9UNO2Ld8ZOhmhTidS777C2awg0gPA=; b=utIpedpOKwfVOwg9yL3e1d3O3lX6vQ7wQPWWMN7FuCVgALwYAegmQc+3ZEArtwPP0/ jpMqtAJTUpbcuzzeyy22pwyORXLH99x7+uk5TPoffiHXxYG24wLG2duGFigI3tORrlez h2cbrjYOChB1cEdARFxyIzIUY3H0YzHHQhscBUPR0O6WbJIPHzSAiqDzaQU4bRPOTTju PTfZINg/PveH2DdJV8AcPoeleHjNCgv8/0e3dL8VaVhIcNueb6BeBpex8p4rJUYXeLRo 0TU1guPDy2B/WXd7r16y0yAKlNEXFVXFBRKrqR0yOuvsJLkPMI83iHEwOHSjzMOS4Twy JV3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PVsVMq1Y; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82003-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82003-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t12-20020a508d4c000000b00565f579c7a0si993736edt.155.2024.02.26.09.11.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:11:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82003-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PVsVMq1Y; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82003-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82003-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C0DB31F2B49E for ; Mon, 26 Feb 2024 17:11:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1529A13B28D; Mon, 26 Feb 2024 16:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PVsVMq1Y" 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 E83F012C522 for ; Mon, 26 Feb 2024 16:58:14 +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=1708966696; cv=none; b=JCCYjPjg8TVTsnanLbN/mTbju9CBCUg8m/I+8ikqCNEM2k+aZyak8LC3VODmvhfiG0/ea2N0D07ilQoDLBxMOKZEnNNLivIaW21tDkUxdYjl47phENRR1wKM4bi1AwwYFqiIZaB+USftyQvf0spFm8jYidQIAGH0mtyP4LqvJZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966696; c=relaxed/simple; bh=rjMSd3WxYvgOWTwaE5VTCXZ7wiN0ODta7cZDebmA1QU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=a+DzGcrw3UHMRKc0wk1+y7Vj5rw4Ig7kXBzBp8gbvFcfMWxZgkAyMxPKXYMxuuaTG2j6TcL7ZcCgjvOL/x8D9u2rAvyQeNxSEIM9UvuL+4KUufFR0QKahr1MGinFwWlLdUK6THv4TViZ7BmEFaUHR7ChxlqTVU8nZ7Gt+YRF9GA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=PVsVMq1Y; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708966693; 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; bh=sSoBVhFfYf93x8huXQpUdUaaiwpj6qVsl4+myZwSTiY=; b=PVsVMq1Yi+IkP/b0qAKUs8D+J687Rmk2uzfmVwmBs1VqgY9g5kiFQWw18eBNr9r0Iw77bJ CIKERANdX5To2ww7MbMtClHGTaxFm2AwXW519E40qeFXFlr/QEuyk/NUmSYRNrk2TZy3nj 7wdSiLj+qPko11cgNdVLg8i4KfD5uuI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-oTxWOuPWMYaohzELKozaAg-1; Mon, 26 Feb 2024 11:58:09 -0500 X-MC-Unique: oTxWOuPWMYaohzELKozaAg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 679BE1C04B54; Mon, 26 Feb 2024 16:58:09 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.85]) by smtp.corp.redhat.com (Postfix) with SMTP id BB74EC01644; Mon, 26 Feb 2024 16:58:07 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 26 Feb 2024 17:56:50 +0100 (CET) Date: Mon, 26 Feb 2024 17:56:47 +0100 From: Oleg Nesterov To: Andrew Morton Cc: "Eric W. Biederman" , Christian Brauner , Peter Collingbourne , Wen Yang , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] get_signal: don't abuse ksig->info.si_signo and ksig->sig Message-ID: <20240226165647.GA20826@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240226165612.GA20787@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791982265473456825 X-GMAIL-MSGID: 1791982265473456825 Cleanup and preparation for the next changes. get_signal() uses signr or ksig->info.si_signo or ksig->sig in a chaotic way, this looks confusing. Change it to always use signr. Signed-off-by: Oleg Nesterov --- kernel/signal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index c9c57d053ce4..09a6dd07cf6b 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2842,7 +2842,7 @@ bool get_signal(struct ksignal *ksig) spin_lock_irq(&sighand->siglock); } - if (likely(do_signal_stop(ksig->info.si_signo))) { + if (likely(do_signal_stop(signr))) { /* It released the siglock. */ goto relock; } @@ -2866,7 +2866,7 @@ bool get_signal(struct ksignal *ksig) if (sig_kernel_coredump(signr)) { if (print_fatal_signals) - print_fatal_signal(ksig->info.si_signo); + print_fatal_signal(signr); proc_coredump_connector(current); /* * If it was able to dump core, this kills all @@ -2890,7 +2890,7 @@ bool get_signal(struct ksignal *ksig) /* * Death signals, no core dump. */ - do_group_exit(ksig->info.si_signo); + do_group_exit(signr); /* NOTREACHED */ } spin_unlock_irq(&sighand->siglock); @@ -2900,7 +2900,7 @@ bool get_signal(struct ksignal *ksig) if (!(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS)) hide_si_addr_tag_bits(ksig); - return ksig->sig > 0; + return signr > 0; } /** From patchwork Mon Feb 26 16:56:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 206807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2214800dyb; Mon, 26 Feb 2024 09:13:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoANk28L2eaObXQ+qmA5KEyLtORrsjv9tM7mP1tfAruc/RT2zyJL/n8aJlNLgQc35uJ7bx+5KengBpZSF+36mfy6WUCA== X-Google-Smtp-Source: AGHT+IHKIZAKNcsMpJcamtRG6hW8cAL2Nj/i9iWR6KWLOL+SZANdKZYOIN7sL2y86Qic4vKh1Sai X-Received: by 2002:a05:6a00:4406:b0:6e5:bb8:dc19 with SMTP id br6-20020a056a00440600b006e50bb8dc19mr5992461pfb.15.1708967639582; Mon, 26 Feb 2024 09:13:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967639; cv=pass; d=google.com; s=arc-20160816; b=SHYobTcCyjbcrrUuEVmmCSW5H8V+2OwF/iAOQIkwi/HKymRQYTZZU9RSkJS880YUHr tw94EXapYFt5Z1ZuCUwmpceto11389fitsdVR0o8qPsRWEVRJZNWnngbt1OIYrGGPPEW pfnCCW/Zq7jj/F3y6/VmgQ2fiOtx3PEUrwkQTYiaCGnYyjj/rnTkliOWLz8PYz+hyO4Q vzGyP4cJqtH1dN4dlcw2CDtld3UoVnw1xpIkLh3Ngzp5Kd+0zrNjXJ0wMI2Iz9lbjyW8 irBpY8eGIAWn1lQ9dtmSDqjoxhcDfdgdwaAXHG+9YBkF+3lkUezNfdS5HzsUDVpfk6hn iTmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id :subject:cc:to:from:date:dkim-signature; bh=PgAcgLR0G7aO1N7QedETGwVIPeEZLgrQUsFrIQ40RNU=; fh=XYYaR4W4e5P6Am9UNO2Ld8ZOhmhTidS777C2awg0gPA=; b=sObDoo8oc0hIJsKzb7v5LdJbn3PBnBgSdK5jg9NeBMgEdrpEhocDJiee3dfpYk/VT4 umFYoiz4tklpN6A+geQnuz0pqTzoLpJMjD/LBrUvrx3VMGJR1kyT4B8BkTVswCEuy82Y HrzGqQ4GPBy5LwMSNu0ypsMh+OtUcv6MClpoWbdbllidnfkXg6FsdniXS4UTxQNumdsv OmqWPkJb0XIERzDjvqof2mrCupspvvHjGo0+Hp/HPaZuVw1Cf0COS8RYZwqXLeWTpnKG LBgWNkcA5OXLOK4bR7txv6aZsdTyTo+9hZnUIJKky7KIegir9pNOxY2oGmulBQqKPghe TIJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QZGBjvNL; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82004-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82004-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 18-20020a631652000000b005dc8bf6237bsi3961920pgw.689.2024.02.26.09.13.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:13:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82004-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QZGBjvNL; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82004-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82004-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D7A17280EB0 for ; Mon, 26 Feb 2024 17:11:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 455CE13B2A0; Mon, 26 Feb 2024 16:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QZGBjvNL" 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 17CFE13248D for ; Mon, 26 Feb 2024 16:58:16 +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=1708966698; cv=none; b=eyTEae28ndNGLzsKvEG9KxCXxBWbyrzzKwgoUZi1bnO/x13sQ9PU/q8dTTAi5FViQa7C2xb1ZKDhIPam8YdiTvnNCYMNsT+XCyr4OUirfncOHaPaciw2brrq6lTMEYEKyFnRV05l87X33ucqRObl7hTgIJUUI6oGNHvpzAhrNC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966698; c=relaxed/simple; bh=2vDMhs+lIZRQu6b8sDiWxOkdaX4P1Hf96dBkO5y7DyQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=jC3l+XUtrDL6ckHWs8tP5N8tovR41NzEDTVwY5DzSi7M1emjTNCMfowFIwyYrPCKmVKElJNCueIZ1tPPKjglTxrva3xSv7vU3H5ygt2u6JjZVZWYpOIovppKzehEdYq8xmamqX9pX5ShrJj9NnoJuKA9qnv6vu6H9ID0i7eRdFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=QZGBjvNL; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708966696; 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; bh=PgAcgLR0G7aO1N7QedETGwVIPeEZLgrQUsFrIQ40RNU=; b=QZGBjvNLyZ2btKqyWOuMpyFdtwfxHF0w4ljOgzygHxlu8sRuzBIw3anC5Gxl7FMKZfJghg /LaXn+86BESOdVkSyikem8eJWuw1kQ5ChRd57yXyZ/nrNw0MXnSpLqF7y78b7nSa867bmW dvYrhtjJlpQBQUvhS1nf+exkP2VSOu8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-329-AZ3hfYUIM5mHV2UatOoXvQ-1; Mon, 26 Feb 2024 11:58:12 -0500 X-MC-Unique: AZ3hfYUIM5mHV2UatOoXvQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14E5883B876; Mon, 26 Feb 2024 16:58:12 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.85]) by smtp.corp.redhat.com (Postfix) with SMTP id 826BB2026D0A; Mon, 26 Feb 2024 16:58:10 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 26 Feb 2024 17:56:52 +0100 (CET) Date: Mon, 26 Feb 2024 17:56:50 +0100 From: Oleg Nesterov To: Andrew Morton Cc: "Eric W. Biederman" , Christian Brauner , Peter Collingbourne , Wen Yang , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] get_signal: hide_si_addr_tag_bits: fix the usage of uninitialized ksig Message-ID: <20240226165650.GA20829@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240226165612.GA20787@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791982452119503346 X-GMAIL-MSGID: 1791982452119503346 ksig->ka and ksig->info are not initialized if get_signal() returns 0 or if the caller is PF_USER_WORKER. Check signr != 0 before SA_EXPOSE_TAGBITS and move the "out" label down. The latter means that ksig->sig won't be initialized if a PF_USER_WORKER thread gets a fatal signal but this is fine, PF_USER_WORKER's don't use ksig. And there is nothing new, in this case ksig->ka and ksig-info are not initialized anyway. Add a comment. Signed-off-by: Oleg Nesterov --- kernel/signal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 09a6dd07cf6b..a69d3069067a 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2881,8 +2881,9 @@ bool get_signal(struct ksignal *ksig) /* * PF_USER_WORKER threads will catch and exit on fatal signals - * themselves. They have cleanup that must be performed, so - * we cannot call do_exit() on their behalf. + * themselves. They have cleanup that must be performed, so we + * cannot call do_exit() on their behalf. Note that ksig won't + * be properly initialized, PF_USER_WORKER's shouldn't use it. */ if (current->flags & PF_USER_WORKER) goto out; @@ -2894,12 +2895,12 @@ bool get_signal(struct ksignal *ksig) /* NOTREACHED */ } spin_unlock_irq(&sighand->siglock); -out: + ksig->sig = signr; - if (!(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS)) + if (signr && !(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS)) hide_si_addr_tag_bits(ksig); - +out: return signr > 0; } From patchwork Mon Feb 26 16:56:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 206829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2228993dyb; Mon, 26 Feb 2024 09:38:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdHVbAvaB5HPEKfLJvxvYcTpyo5i8eOBa4tRn2Rh6ZkH8n8RdCN4ntKoNAA8vnwGTK/OtOqJ+RwRN99UL/6uruZNgaAg== X-Google-Smtp-Source: AGHT+IFX5oZqfha22DOiqonQUibi5zfofol5YnnWI01ZCnUxoQ2R6k0TRLYBJc66ksRCSJGfcTfk X-Received: by 2002:a62:6306:0:b0:6e5:30c4:19b with SMTP id x6-20020a626306000000b006e530c4019bmr2641305pfb.3.1708969123640; Mon, 26 Feb 2024 09:38:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708969123; cv=pass; d=google.com; s=arc-20160816; b=PQyjwWVC920CDJSM/I6e0Gw1Qao2HjZXzk0avnmYe9bb8hfAyQf0572JYEXmlOjPBA JRIMaygVIF+CCG/urlDmDmuOUtGzEKFKTxHBrZfVnAIHMozZpffXSvdB+n1Ph5RKZDZM JcKMnWMrr3dDFlApKlrkJ+eFH1BOm5qZnAvWjdIFT0LmLl8scXaiyQoyUBrhrj03KXSC 2RMXI9t8NXG2HK1z58zzKkOQ/zLWx2IjpR/LQ7vPiB39Say9J1wP52hKVYV8RNqTdubL sU2oHr6LVph0PIB8zVOyhHmsvloBbSzL/9/3YtaNQAwzipqYvAJlaeb1XUG9SYNI8HFB S4lQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id :subject:cc:to:from:date:dkim-signature; bh=92kRab4HqwTQmO/VgKs5fSqh+D6/YdS7SG+n+Wli5ZI=; fh=XYYaR4W4e5P6Am9UNO2Ld8ZOhmhTidS777C2awg0gPA=; b=Xdc/Wdd3R6TALunmwKBxYs3I4oqk7RJc7CG6Sck/uDTVlbxfYQSBzozx1XMe0nYggq nb89uWpp/2QBsen/p5wvJ6GtD33c9/RePKn21erOqni7AtMLge+MEVCnZAhok7B8GWuT vgN4M5IrbbCtGBt34mc7jnNJM7ritbBxisk6G4UAWICRqw6bA0fpRelQgHgTjcXd5se9 9G9mFWsUlStAh8YjS9ZdbV+NEJsFBVlolV/A6a439OrCJ4wrG39Ff7EdhzmiWCUsZ3Ro bWleq1HUwO8FiloUvCF6668wblOI9uDNQ4hn82drnHRRO7R36hUNA6bkW9a1IF58FZjL 6rBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HH6RcE0c; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82005-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82005-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h20-20020aa786d4000000b006e215fc036asi4002544pfo.218.2024.02.26.09.38.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:38:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82005-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HH6RcE0c; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82005-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82005-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 67D42B33DFF for ; Mon, 26 Feb 2024 17:11:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 891CE13B2B6; Mon, 26 Feb 2024 16:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HH6RcE0c" 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 5DE76132C01 for ; Mon, 26 Feb 2024 16:58:20 +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=1708966702; cv=none; b=Cb21wu5Jf/fD3mn1l6UlI8mx3QzzaOsj9o4GjHaPLfG56t9fJbsog1G2tuZb02ShHJC5RsrMMXIh3cumOsoTwJuDop4QGypdetFMxGlHAjeMfC+ry4IEfnjYX8Ejk059/L0JFTW/M/JZNOUri5FLyICW6Tgw00TxPOYn+6bTE78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966702; c=relaxed/simple; bh=LqGMQtPIGznoCP9QmWV2gD3wXujgVsqlU0n95FID8CY=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=rsZWd3DyYF8fGyvhurvZ+TsUQz4ux/xJ8cudQlKQipKRGO8TBrDYmAsZ/LwVGEWWNXY9ZozFaHkrZt55q6Cc8R1IKwuIqxUti86NdPBaUg5B6Hg+BE4KVDRBuwwDZh1NAX/QIcRqlY1gpalhDsbrr64r5pIPzx6OtAIoTAlefzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=HH6RcE0c; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708966699; 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; bh=92kRab4HqwTQmO/VgKs5fSqh+D6/YdS7SG+n+Wli5ZI=; b=HH6RcE0cjCp3ZP3EDiaqG4BLdVqo72hpOjB5gaFlQWTMn6S29saQs2Jk0B1WO1PP8kswdj YnOQfi6gbzuS0VboTxDSdwx8fq10PjKiksqziN3Y/BOD2voMEN3z8esCdbuAGiap7xWPuM 5E7XzOpbtYxHLfCLdMJEMXkOCEs3qr8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-79WX0-_8NRyaSb_F6N9a1Q-1; Mon, 26 Feb 2024 11:58:15 -0500 X-MC-Unique: 79WX0-_8NRyaSb_F6N9a1Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5C8C83B86C; Mon, 26 Feb 2024 16:58:14 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.85]) by smtp.corp.redhat.com (Postfix) with SMTP id 49036400D783; Mon, 26 Feb 2024 16:58:13 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 26 Feb 2024 17:56:55 +0100 (CET) Date: Mon, 26 Feb 2024 17:56:53 +0100 From: Oleg Nesterov To: Andrew Morton Cc: "Eric W. Biederman" , Christian Brauner , Peter Collingbourne , Wen Yang , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] get_signal: don't initialize ksig->info if SIGNAL_GROUP_EXIT/group_exec_task Message-ID: <20240226165653.GA20834@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240226165612.GA20787@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791984007678715062 X-GMAIL-MSGID: 1791984007678715062 This initialization is incomplete and unnecessary, neither do_group_exit() nor PF_USER_WORKER need ksig->info. Signed-off-by: Oleg Nesterov --- kernel/signal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index a69d3069067a..9c6a5ccac328 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2727,12 +2727,15 @@ bool get_signal(struct ksignal *ksig) /* Has this task already been marked for death? */ if ((signal->flags & SIGNAL_GROUP_EXIT) || signal->group_exec_task) { - clear_siginfo(&ksig->info); - ksig->info.si_signo = signr = SIGKILL; + signr = SIGKILL; sigdelset(¤t->pending.signal, SIGKILL); trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, - &sighand->action[SIGKILL - 1]); + &sighand->action[SIGKILL-1]); recalc_sigpending(); + /* + * implies do_group_exit() or return to PF_USER_WORKER, + * no need to initialize ksig->info/etc. + */ goto fatal; }