From patchwork Thu Feb 22 16:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 204853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp51620dyb; Thu, 22 Feb 2024 08:24:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVZGn1+MQEzjFbTwctc/wwdrtpvb+GhtN8BqctVfPSDgtrsdxt8kIsy9yxKP4aEJTtEwg+YSqzHBvesxCR6vBCsW5Dnxw== X-Google-Smtp-Source: AGHT+IFqdEBcbQhY7N+f22mxb8oVD8BYvrQvhWva5YhN+zF4hO6YbM5rUQKpveHEsSKeo6XUH44D X-Received: by 2002:a05:6a20:c6c8:b0:1a0:c3e6:313e with SMTP id gw8-20020a056a20c6c800b001a0c3e6313emr5388772pzb.28.1708619084400; Thu, 22 Feb 2024 08:24:44 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t23-20020a62d157000000b006e0dd1fc7aasi10423318pfl.187.2024.02.22.08.24.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 08:24:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76850-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=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=C2pw+fnC; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-76850-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76850-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.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 56334B29EDA for ; Thu, 22 Feb 2024 16:06:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BD3A1509A1; Thu, 22 Feb 2024 16:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b="C2pw+fnC" Received: from out162-62-63-194.mail.qq.com (out162-62-63-194.mail.qq.com [162.62.63.194]) (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 1F5D115098A for ; Thu, 22 Feb 2024 16:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.62.63.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708617917; cv=none; b=KOE6taDZWH9Bs5A+LylBPvONBbWj+51frCwD3Z4pQ5uAXCrT7qlmTEM+cM/uhH7y19qZT4Nklpd+2wz1pmNnpUDbc81tC5cRmSa3N+BxfML7WrJfl/5910FkZ9AvFx/1Qk4kQQ0+tDpNlxTZwAqpLskAmuLJOYLwf7ut07EuLtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708617917; c=relaxed/simple; bh=ae7acFbeFbOsSBOJq7Wm0wlb7xN42xulyX2kNqEdUOo=; h=Message-ID:From:To:Cc:Subject:Date:MIME-Version; b=lBS0DJk/SXnOQdnxV8LMt90hy/l5/sgfkYa8WsN/jKsyDg5JakymrmeknuHdw5ib1CS3u4tHoVGKw8KHUtuq8MvT+vuvYpTtHjTnZS+yncTGmErQY3B+Ft2eY8sQDsEBOqbIqyVbT2SRcxx1v1t/LimfkR3OLiap5JQ4ruXAeDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com; spf=pass smtp.mailfrom=foxmail.com; dkim=pass (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b=C2pw+fnC; arc=none smtp.client-ip=162.62.63.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foxmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1708617904; bh=zZh0WkZk+9GyZffXATDDdHfCvt2/6IAILrMFkC15vkQ=; h=From:To:Cc:Subject:Date; b=C2pw+fnCMVx8xK7NaPwqIQvCS5H+DCeMsCVWLdIfq1pUbLfSwHgqhN9aCTE1BwmUF KjW7TwYEwmy4zckquuYDk8Gb3MOwsNzYb6yrHo0ZIIzyBZMb7R+pMUp4T/8SFy1uer 1DfMbu3vC8ujcyPKSrY++iTomni9wYJvUJm6oCX4= Received: from localhost.localdomain ([2409:8a60:2a61:ef40:7404:388f:486a:7747]) by newxmesmtplogicsvrszb9-1.qq.com (NewEsmtp) with SMTP id 1408404F; Fri, 23 Feb 2024 00:05:00 +0800 X-QQ-mid: xmsmtpt1708617900tg2p8wddx Message-ID: X-QQ-XMAILINFO: OKkKo7I1HxIeh1aHFKTXeWUiHFboQXSuYm5LrX/xH4fLMw9Q+j0Ri7J8xBBS81 cdb2yPrpXqYl8cgzWpPku3vaZxed8meca1uKKX8GclfTeXPJFW3nyaCO0lkSmNmV2r7VUB2H7aMa 8yaZW1rrGfAgPzgFhN2B+VI847J6ffgNaMtIPiDhUIYNWDBk83ENZkGm7jMWDiedWQNAz/n074Af 5TC69wlb1vjsBb6yQeHFmOT6JStU8f7GaM62JlMX/vQnXJwLkqInfHYXXPwZhq3SdhfuqBYKz0j9 lGcs3R5qGsRB/+SgmMqy9T6++d/ZTfx9NSiKEGFwMa1uBkVnbCKzHo5y8SJItwHgJWbjwQ5XD1lM H/WD7qFtP4tm3l5kM1qKIxLKYJl9wUtqi90Ql6v76XZ1k3e4ndHI9LGTi/3IHgWmp1+GWAvBVAqD iEmLmbds/ScTO6QqtOvu6yrCswhBzxuOZaRRTL27Y2MA58lS34CDAW8uEl/UI5Tatq2BByOcFXXE Q4kHLIARxKJaMea1I65iLVzC39kNzGJ8p7dZrgXKcpn+/yKPgopSb+tiukSKyx/KnFx9tCnxJjt3 QMjlOOjSMlaTEQ8r5ryc9DkyiYFw7DGOVliMm21pAkfIk99VnfgqGvibTYLvZ7WO5iITi04127lY ywL/M7qMS2SWASILuM87q2liLUNh29qi+YokL4w4PxiRx/M9tKn+IXnLx86D/Z3iLslyGqFyzeLC s5OR7Wbjk71WGttqOSUYlFf13x5H2kXug8+ExfDFUyy/ODUGPAbs++43vSRrbItdC+SUnpHNbJqC TkimoG32NdmYQ/uhns87Te2MCn5JieOjyC/y2+RjTRBwBcLrf68PqAnAe0PhGcXx9+bDAcagNfFc onKhXrlNiRQOKrEfgLYTdZS2z7MJ4Lu2ZhaBSQD5/bo1SyZl4+NjXGUdkxN9kHX9ejSuaeGXABrf NJh87dILEQvfUXEMjYJsbmGVwXSm8nNms7kqt1QJ4ukiVndKvaatqqZfbVEn29bF0Fxk6tYToORU qGRjLhS8IKVu9tB2lRqgp0tcz6rOXCieF9v97M09bBg/TzssZERY1gQ4FHg0bNFOWD9y3sgQ== X-QQ-XMRINFO: MPJ6Tf5t3I/ycC2BItcBVIA= From: wenyang.linux@foxmail.com To: Christian Brauner , Andrew Morton , Oleg Nesterov Cc: Wen Yang , Thomas Gleixner , Sebastian Andrzej Siewior , Luis Chamberlain , Mike Christie , Dmitry Vyukov , Vincent Whitchurch , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] kernel/signal.c: explicitly initialize si_code and use ksig->info uniformly Date: Fri, 23 Feb 2024 00:04:57 +0800 X-OQ-MSGID: <20240222160457.350657-1-wenyang.linux@foxmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791616965078654800 X-GMAIL-MSGID: 1791616965078654800 From: Wen Yang By explicitly initializing ksig->info.si_code and uniformly using ksig->info, get_signal() function could be slightly optimized, as folowes: clear_siginfo(&ksig->info); ksig->info.si_signo = signr = SIGKILL; --> missed si_code sigdelset(¤t->pending.signal, SIGKILL); trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, --> unnecessary SEND_SIG_NOINFO &sighand->action[SIGKILL - 1]); recalc_sigpending(); goto fatal; .. fatal: .. if (sig_kernel_coredump(signr)) { .. do_coredump(&ksig->info); --> contains si_code } No functional change intended. Signed-off-by: Wen Yang Cc: Oleg Nesterov Cc: Andrew Morton Cc: Christian Brauner Cc: Thomas Gleixner Cc: Sebastian Andrzej Siewior Cc: Luis Chamberlain Cc: Mike Christie Cc: Dmitry Vyukov Cc: Vincent Whitchurch Cc: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org --- kernel/signal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/signal.c b/kernel/signal.c index 9b40109f0c56..8cab55bbec2f 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2732,8 +2732,9 @@ bool get_signal(struct ksignal *ksig) signal->group_exec_task) { clear_siginfo(&ksig->info); ksig->info.si_signo = signr = SIGKILL; + ksig->info.si_code = SI_USER; sigdelset(¤t->pending.signal, SIGKILL); - trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, + trace_signal_deliver(SIGKILL, &ksig->info, &sighand->action[SIGKILL - 1]); recalc_sigpending(); goto fatal;