Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp486824lqp; Mon, 10 Jun 2024 09:50:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXqr/asNFLj5xM9eF9Akexaw2jy1VfK36Qudeyfa9HREJEgnVW0VPC5wi8DJGyYmDcc089dewPOZyB45GV8+9UIiwlriyhLojwEBPs8BQ== X-Google-Smtp-Source: AGHT+IGf/2FxqgovrbyRzsnHwpzSIpiTNL+OdRBUCUyo6DoVvlv8NTQGGALeblH4zUNsi9fs77rS X-Received: by 2002:a17:906:3e09:b0:a6d:ff12:5bd1 with SMTP id a640c23a62f3a-a6dff125c77mr524860166b.41.1718038247490; Mon, 10 Jun 2024 09:50:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718038247; cv=pass; d=google.com; s=arc-20160816; b=k0FX//jveDXXZ80AwiuQNDCO/aHghRXUwXM9xKQasPuiCnZyLT2wW3gRDjbHQmq+3D uA32rRR7/mcSqDg8ExSBEND/5rruJB6mqz9yqs2YNoMZRw5JkHozhFNC/DWcqc3ljFeH 4/h+A5j4eHTe+vntCxNm56GgE3OLN7Yl09+KJQw2Jyfjm5Fd4vAOxx+GzYemrjN7cob9 J0NIsHlo5akELkhXks0bkHLM2z0DV064JIcj/bScWKhj07WTNgUrfSiVJ+qf+QjSZB0h 0bEZRBlxj439s/DbXoi7IpmrNENK+zqEAk3F1NkUJX+IKTc91ilzUIfuGE5RxFCbKMyv i4GQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=Uih5CqJpJPUslYvMN+crWXfC4uyqUetkrCUQg27T5sU=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=NnQFTU53DPZ3nWZnP8wMgYl41WIpTA4RASOj/jg5xrHe8fSXt6YnnOaCxbqF0EzDoi bhQRzGv6LFCcLu2RUsLYtBpOQYQ0EQDYvb4GQkG+XYDOx5eVlu8q24orgUNBV7OFxsvG K6c4oHzzXBwnnCqGUhxt5c1nCgQYXHcdcO7lZO1/rhxnVRIww1c7taVYzrEG68non7Ym i/YdtA86Y33VQzAcH3OkvbsZcvBcoRllJ0ZR3L+0xFJV9/Wz7yRkPHmzPGX0dqc/FPrn KcSWdXKzTetTxttDDM6q0OzdT+owJn52cHsfemzwDYUGV+rplpgrTI/7rHuoHQ/tylM/ 9B+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=werZbN9V; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6e7e714ed0si330018466b.221.2024.06.10.09.50.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:50:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208602-linux.lists.archive=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=@linutronix.de header.s=2020 header.b=werZbN9V; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208602-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 379861F21DB6 for ; Mon, 10 Jun 2024 16:50:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E5481586D2; Mon, 10 Jun 2024 16:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="werZbN9V"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0sl6nfPu" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 471941581FF for ; Mon, 10 Jun 2024 16:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037776; cv=none; b=qkVce5BiDUW4EYarK+ZJWfmirdEIYOnLtNWmT3ChCItOgA9YRf7Us5MCr1pY89WE7vCGIJEoVtVwE7TSycfViNsBQVUmMH/GqVjXTQsVvhj+6Wt16fuW/zzlI3CH4n9JTGDXT6tviqmR27FepjQwzsgUOj5HlPOMIySel0B6BUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037776; c=relaxed/simple; bh=JBVsg51a1C6emguYqjQ6r5sm9uw8SoWsLBDNYeJITWk=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=AbR/AKNPdCAa8DIJSDJB+wo9/msmrj6Oy4Xx8hhT9AZD9IVT/nLJL/jRREbImwl5XRv5+xnJm+A1mJ9TKLoGXrrdI+qaTBLDBXrdwTepwXocLoKVmUke0nMOzrskVlfzFYv1FW2sRXvz05+Kd4yKOAYrKUt0I+OF53oXvgPjCI4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=werZbN9V; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0sl6nfPu; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240610164027.853215767@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037772; 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: references:references; bh=Uih5CqJpJPUslYvMN+crWXfC4uyqUetkrCUQg27T5sU=; b=werZbN9VkgOYnVeqcxaduNhFRxFdOPoUGuHTFfHDI/rslVinBnjNdBlL/Kc8n/kgvur2Os KorSDhs4p48tIRX4gOIvbE5oiMfJZbEC+YenHL5ojlZR5L1mbPCGN60XFcm1LJVCzHp6BK bjslNiEoNlibXyyAvI+Kx5EjI/mmdEPuSAJ6/LP0qEpxUhZfXkhq4xMvtPAGAmPlyZhDvH E5XqImHZbFkG/PiLeTYZipIOVmZvtfho1qkgxtcNWt1f2IVrDsXJz61YyB4zbxB3xV0rI9 RP59CqQKLrWYmlf7TDFi4grFv35bdvWu+JQRFG9REpX1W79b3CrB4qKSPLebQQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037772; 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: references:references; bh=Uih5CqJpJPUslYvMN+crWXfC4uyqUetkrCUQg27T5sU=; b=0sl6nfPu7GVfb4os1/xUF/w4qbivnJAl8p6g722HD2ToxD1k79mClQNojzJ4Mu6kzqICcY ur2jV7+lTd5uUhBA== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V3 38/51] signal: Provide posixtimer_sigqueue_init() References: <20240610163452.591699700@linutronix.de> 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=UTF-8 Date: Mon, 10 Jun 2024 18:42:52 +0200 (CEST) To cure the SIG_IGN handling for posix interval timers, the preallocated sigqueue needs to be embedded into struct k_itimer to prevent life time races of all sorts. Provide a new function to initialize the embedded sigqueue to prepare for that. Signed-off-by: Thomas Gleixner --- include/linux/posix-timers.h | 2 ++ kernel/signal.c | 11 +++++++++++ 2 files changed, 13 insertions(+) --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -12,6 +12,7 @@ struct kernel_siginfo; struct task_struct; +struct sigqueue; struct k_itimer; static inline clockid_t make_process_cpuclock(const unsigned int pid, @@ -106,6 +107,7 @@ static inline void posix_cputimers_rt_wa } void posixtimer_rearm_itimer(struct task_struct *p); +bool posixtimer_init_sigqueue(struct sigqueue *q); bool posixtimer_deliver_signal(struct kernel_siginfo *info); void posixtimer_free_timer(struct k_itimer *timer); --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1909,6 +1909,17 @@ void flush_itimer_signals(void) spin_unlock_irqrestore(&tsk->sighand->siglock, flags); } +bool posixtimer_init_sigqueue(struct sigqueue *q) +{ + struct ucounts *ucounts = sig_get_ucounts(current, -1, 0); + + if (!ucounts) + return false; + clear_siginfo(&q->info); + __sigqueue_init(q, ucounts, SIGQUEUE_PREALLOC); + return true; +} + struct sigqueue *sigqueue_alloc(void) { return __sigqueue_alloc(-1, current, GFP_KERNEL, 0, SIGQUEUE_PREALLOC);