Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp851266rdb; Fri, 23 Feb 2024 01:51:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9shZV0TkXaKyLuK+Y7MocCiT8KxEvDdCyTLD2Fm9zGuoh0R93LAzkHjoWhGqAs7/f5NAXtmxe08PS103YGzH7VoeRQig89MSdV019SA== X-Google-Smtp-Source: AGHT+IGBilH8BWIu/vAjn690WeWdIxB0m0WJOzYtGid81ItGpO5JANyYs9TqYV6+/2b6u3est4b1 X-Received: by 2002:a05:6830:1e87:b0:6e2:f031:6956 with SMTP id n7-20020a0568301e8700b006e2f0316956mr1688706otr.30.1708681866234; Fri, 23 Feb 2024 01:51:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681866; cv=pass; d=google.com; s=arc-20160816; b=oWQfcHD+5f9zyE5SAfX+7acMqbzAxjS6IVkl/+Cv5sAkHaN4Me/AeqJqAovTJhTaTM lmOMiJedjrcrrzEVrzBOXOZ2pERAU4pr17SPPIdJ4GcC2JLxNIC7ReHC11WKO4jERgRw gQi8uYpq2MBAlDXT3GXYjbV7KSQd10acDMgbT+hfn7sjRO2ipErGfJDIoTlHgWSqVia0 KicgpmiEjlhZRaCAZshVIeLFwe1kaSYdN6jN/vAC8zv0ruBZtkMgVLv1VLnGnKDFkZQ0 eUHmTaGUSoEwD6TceE8NGQr2DbHijWSN91AR29kDWIpWTEdPDuOfHeRCm+B0+ekBgGSz Sarw== 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:references :message-id:subject:cc:to:from:date:dkim-signature; bh=mZ+T6hgohzDKZmregENWnrw75IZiMmG3BeEJe4k3v1A=; fh=oHIMBvuofc6yJICISVKj4ram2A2RzFDp3fDKs3bYbq4=; b=Wq0Tj6zYxmmdfGOB2HZ1uQ8nmHqbnCosCuphwiGyNQJvUsZpIGXs64z3+PzvUqoiui rTMQXSA7ZPpFeH+huosDfzd1uaoesvmSFdwoEvKqWtvb0N/Q+mc95RmteY1HC2yD+y13 6Tg2/7WYv6aQvgWTJlEozs6ow6KFvDwalInXO3R3FQTpIJIM/v4jZLsfbWnHNmmTyXni Lx3tp0kIKQBwWkEtegAx8mXgAAV/ClRZRfM9Xq4TLeLeCGUaT17r/XtKaQ85Xl5mBH5i YXKNPiGaVM7Zr97toJD7gzS0jGQiecg56vymohYJwccmHdnySrOrK75oHVaryUS/Yf37 NbrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VhY3Pvtk; 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-78073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q6-20020a634306000000b005d8b547307bsi11680775pga.575.2024.02.23.01.51.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:51:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78073-linux.lists.archive=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=VhY3Pvtk; 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-78073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78073-linux.lists.archive=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 DFFE1283725 for ; Fri, 23 Feb 2024 09:51:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BE8D5D463; Fri, 23 Feb 2024 09:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VhY3Pvtk" 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 DC89B5C912 for ; Fri, 23 Feb 2024 09:47:47 +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=1708681669; cv=none; b=o2n8IezWORaqc/t0kGybih8+4aPDL44qbFen4YzDxQKyRTFNkBKb3qvGNqaph7juu73uGuj2Pc4Gk9UC8K8vMCj6zdAnhUCwFwG1KnYpzf6/o+GEAhSobXzbTa9liErigqnqkixcB12WbIh6ANYUolAazOkYyC4aSPuv5jydehk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681669; c=relaxed/simple; bh=Lp1mhiHVT598EFwhxi9naZDlUAJ7pCCeTz8RW/4n82o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eNutJzOXc4mDS/nop/66of45EQ4xZAFf2w1945nSCI63yxGKf0K7jHqGOkkWggS3JVLkHdAKMa+jvJOtPNgsmyInnHswwgQdLeiOQZiDyKRKI1DW9NineA5ZNAsOEDpTZMDukguAtQOysWJm1NivpNIK5i9p3WSot9RHqwbZBMk= 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=VhY3Pvtk; 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=1708681666; 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=mZ+T6hgohzDKZmregENWnrw75IZiMmG3BeEJe4k3v1A=; b=VhY3PvtkPIwCYeIqXhxqJ2w8ixLastfVM/sRGV3JSpaaD7M1WtHpFJIbXsDoT4RxjP8F0C 2QM8v4ZAqZQNB96BHvZOFwiQhVGghf/rLNez6WhoCx0ObmfjHdQGRAfKkAXDPDYP/38wbm XTb9JX/7IJYDWes/lgD/56X3ed5TOW8= 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-516-pmmFTt19MPWTk7Lcd7TNVg-1; Fri, 23 Feb 2024 04:47:43 -0500 X-MC-Unique: pmmFTt19MPWTk7Lcd7TNVg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 CC19B29AA39C; Fri, 23 Feb 2024 09:47:42 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.151]) by smtp.corp.redhat.com (Postfix) with SMTP id 424D724E4; Fri, 23 Feb 2024 09:47:39 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 23 Feb 2024 10:46:24 +0100 (CET) Date: Fri, 23 Feb 2024 10:46:20 +0100 From: Oleg Nesterov To: Wen Yang Cc: Christian Brauner , Andrew Morton , Thomas Gleixner , Sebastian Andrzej Siewior , Luis Chamberlain , Mike Christie , Dmitry Vyukov , Vincent Whitchurch , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] kernel/signal.c: explicitly initialize si_code and use ksig->info uniformly Message-ID: <20240223094620.GA8267@redhat.com> References: <20240222190546.GA5993@redhat.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: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 On 02/23, Wen Yang wrote: > > On 2024/2/23 03:05, Oleg Nesterov wrote: > >On 02/23, wenyang.linux@foxmail.com wrote: > >> > >>From: Wen Yang > >> > >>By explicitly initializing ksig->info.si_code and uniformly using ksig->info, > >>get_signal() function could be slightly optimized, as folowes: > > > >I don't understand. Why do you think it will be optimized? in what sense? > > > >> clear_siginfo(&ksig->info); > >> ksig->info.si_signo = signr = SIGKILL; --> missed si_code > > > >because we do not need to set .si_code in this case? > > > >> sigdelset(¤t->pending.signal, SIGKILL); > >> trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, --> unnecessary SEND_SIG_NOINFO > > > >Why do you think the usage of SEND_SIG_NOINFO is "unnecessary" or bad? > >To me this looks good. > > > > Since it is called "SEND_SIG_NOINFO", but here it is neither SEND_SIG > nor NOINFO. I don't really understand what does this mean. But I can say that SEND_SIG_NOINFO is exactly what we should use, this signal has no info. In fact, SIGKILL can never have the info, see the sig == SIGKILL check in __send_signal_locked() but this is offtopic. > It is get_signal() here, and ksig->info has also been partially > initialized before calling trace_signal_deliver(). Below "goto fatal", > do_coredump() also use the initialized ksig->info. IIRC, do_coredump() paths use only siginfo->si_signo, but this doesn't matter. do_coredump() can't be called, sig_kernel_coredump(SIGKILL) is false. > >and it seems that we can simply kill clear_siginfo(), but this is > >another story. > > This is not right. > > ksig->info will be passed to user space through do_coredump(), and the > clear_siginfo() cannot be killed. See above. Oleg.