Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp72056lqg; Wed, 10 Apr 2024 16:06:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZKE5G86KF8eZc97IntqFGS6Tnz+6S21BNyOyBWb5+4Rn1g0ets5S7lCAahW4rW88Nz3Few927x/V1I4W4lgOVjAgsPBqPLrlC6ksC3g== X-Google-Smtp-Source: AGHT+IHJRK4fHPeK0lPoyafVknTEhtr4KtaU4hN9mhyTwIj4E4+Q6NdKkg1fN+pwQRZy3D9+pmvs X-Received: by 2002:a05:6a00:2355:b0:6e7:8322:ff8e with SMTP id j21-20020a056a00235500b006e78322ff8emr4410794pfj.30.1712790375479; Wed, 10 Apr 2024 16:06:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712790375; cv=pass; d=google.com; s=arc-20160816; b=h636Qeb38FkmwPzi57iVlHzNuY67h3HwGJgBjBYb+UuQ0LGSAWDhJQpaF7Fz1SM6r+ D1PWA4UCvjcjaB9QA28JCDrg3i+qU9Co1Gbq4Dsw9MpHEaOZh0Ica6f6aib1g9vkULHo 1PCBzPcP27M2L30C6I9sbBntN2CFftov/KwfxT/IgZx5vAZ1FJMB9cs7y7XDw81HPrQ6 ienIaGMFwbXmOIQmVdcWmfmjcy6SoFSkNuss5NnzPrBkDcA9bFVbSPJV0ceSUhKkZ3iK H9bP5+x1v5ZpiC18m46NA/NPy1iuNf/lBv3Zk+6lCT6EDK1W/FFxzIufVlSMPyD6Hnm4 s9sg== 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=T1fHMRbg1qN+b8vTg1bKFYEaUyKE9TjlCjmmTziHcwsNoEvSKyVYro7v4wNwAbkike tHaqyVZEcHV9eNo5Jlsx6IBzTA/OO9xTylBSaIAKQEXc+fCRF47rolkzLe1PEuaS518Q mMqZzZTJVkLciLkhEW1+A1dHUuA/nhASNdTKgr4uyqLK3Y4WuLkH1kzdsaxxRdZSkIkd RReraNbnrwrIkx2ytOf/4XQ9XjupvReVL2BT+0zp8N2WjLtXFXqz+GZVwdW+hnc6Fq5E kgQFUBSppAOxQ49bhnLV3fBFhISxlpkfLZDlCeM2qSLJcMbiaebp7CmjJ3lJGZvor2mf vkRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RCBCziDD; dkim=neutral (no key) header.i=@linutronix.de; 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-139490-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139490-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c17-20020a056a000ad100b006e8985a0f24si257630pfl.202.2024.04.10.16.06.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 16:06:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139490-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=@linutronix.de header.s=2020 header.b=RCBCziDD; dkim=neutral (no key) header.i=@linutronix.de; 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-139490-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139490-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C266B289D45 for ; Wed, 10 Apr 2024 22:54:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD9EE130A4A; Wed, 10 Apr 2024 22:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RCBCziDD"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uHNfD1Ve" 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 A775712F598 for ; Wed, 10 Apr 2024 22:47:19 +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=1712789241; cv=none; b=qMx/EMi6c0UNl5CaBGPSHR5JR1AhsyGq1BlVlC8E3/QSqobQn2NUaoh5VRmhFYBxkTSbW2xBYY8PRWyLHVIAOlybGRAXGBAlIFekh4JTraiiMw9VIobxHwGGGCKfuzVbKTp9VcfTMfGlFK6IKJW67kqGNJIiURbqbfNXa3h5rlg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712789241; c=relaxed/simple; bh=JBVsg51a1C6emguYqjQ6r5sm9uw8SoWsLBDNYeJITWk=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=EGjzKCOi0iMAWGkl5sNiguju6ZMxOy5M9Ui4Ayl3y+nksYc4bAkxMJFyfg5pfSwB06XYIgbzesVJel/qxiMHgdUYNXrYZ35GUVUWPEWvX+zbSIqwLIy8w4delArE4CWCICgvsxJVmleZpnoFZ/fNU5o14helTCNoWJNI1Lwg1LA= 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=RCBCziDD; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uHNfD1Ve; 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: <20240410165553.263875002@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712789237; 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=RCBCziDDYk8F0k08nosKA+Ykwj99TGVPTAO8C1s4EAvyRezArbTUnTxcqm9pLdoFCzNCl/ DjV5+/1UTy6p3rp7we9OH1j38D90ObzcZ/xhq9MakdCmGDGkNxXo0jIp1AJNnKWNNWfRI8 q+UcU/i0XjzRWTYOw4UDeKf1cu3E1vSqUo0NwJrMQ4dX+LeZwt1RuUeM+/nUCIVlaFIWDL LSgVfj8L5I4SCtMqqB2ioLs/nttUZg77sErDBvEVQZ8V18FRHBeLtZTNcqsXjT81lq9QPD xpp4I4jbkS2YkLg0e7+jjkwAtKWYyWRFaGVNbElTe+tcqEs0GXliPCh4f7CIlg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712789237; 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=uHNfD1VesuL0ML1QFJEDCYSbAmdJvPtbk96Erb0B7GRhFHI3b9yz2W0CXTpNpfu7WBdSmZ mi5dEovzu4lAA4Aw== 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 V2 37/50] signal: Provide posixtimer_sigqueue_init() References: <20240410164558.316665885@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: Thu, 11 Apr 2024 00:47:17 +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);