From nobody Mon Apr 6 10:37:48 2026 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 6A59E39E185 for ; Mon, 30 Mar 2026 07:09:17 +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=1774854558; cv=none; b=CXts3nhDWemtkZUT4T96vpxNIWD2F0gZrd21kNgGdy1b6VIzAV05Z31M29xOJjM28UvCE8PDJ3F3zA6yHNh15u/YZYe4cbaSeXIT3RE/sa2ZPUK/PtX1Oavg8khJ6Jm/lv2cV8SiwflODu791UyAa6sIMdsngO+TPK+J/X8LDkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774854558; c=relaxed/simple; bh=szRAvN0/rc8UxKL6zx8cg9WFhjQWEPmkqVa0nN95DE4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DSBba/uThb4Nh/zRsLNj1S5Uldb3Qethfu6fgXy0yoQv6YJmqdZlJXHusngugQX0ZuymHa9I2H9RVMt0gdhWA8Lul7VCuXzY5XaqPOe6PjjUtbVVqrVLR0HBfsKZhjb2Gt0FbflrWwFSalWxOsgmnPtdWzOOMINb49swvpBw/w0= 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=KSw3tzfO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aVyU+o56; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KSw3tzfO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aVyU+o56" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774854556; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PeFWDRPH243pvH53i4qrJq4j0Y8a3TWu5xuYPQ+5Eb4=; b=KSw3tzfOGXbD/Ux74iKD9Lr0VcHYaAC64Qq/9TQ0esHi5gFo4IiGBMwRzqARjTmuhz1+SN 5crSzjRnt8WlFA7dqADMXcVsPTehJqL5p2yYWPx0AqWVvrWwFpsBYmRNqfK7ORj9W0E7C3 /iKko9p/xaSLND/m1f44j1fQbTV5J/MJTEFu/ekUBc/qVxIG0IvGrC7aQwa3ObqyBOyP65 mFz/UY3BOBcB3cCT/oLMc/LdLRUYZIZCjERYUylkRz9671+yy/ByNiefIW0ppbALuEtF2D ZxK94TPQATPXuzjKWHzJv1nhpT2QFgMeW4PHsKyJEhujeWjW+JsFMZ0AMTYRMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774854556; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PeFWDRPH243pvH53i4qrJq4j0Y8a3TWu5xuYPQ+5Eb4=; b=aVyU+o56pDivT7otTy+Jqgs6FpjudgK1wep4eGDUPTxR1g3fgk1ag1Cl6AqflkHmNPFXQ3 hg3PN6NBNtDiFIBA== Date: Mon, 30 Mar 2026 09:07:55 +0200 Subject: [PATCH 1/4] timens: Add a __free() wrapper for put_time_ns() 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" Content-Transfer-Encoding: quoted-printable Message-Id: <20260330-timens-cleanup-v1-1-936e91c9dd30@linutronix.de> References: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> In-Reply-To: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1774854554; l=887; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=szRAvN0/rc8UxKL6zx8cg9WFhjQWEPmkqVa0nN95DE4=; b=9oYuB10tTnXf3UQJ1dxIoRoBHzPUMXOVtvD+L+CyYhZT0fGnU5y/eb5t8UciNUjbSUj3ZDa5x b7fxTNNn71YCvcGpc/q9wblnSWEHEH0gYZ2Xf07aY9PF0J58Wq8VuIc X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The wrapper will be used to simplify cleanups of 'struct time_namespace'. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/time_namespace.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index c1de21a27c34..58bd9728df58 100644 --- a/include/linux/time_namespace.h +++ b/include/linux/time_namespace.h @@ -8,6 +8,7 @@ #include #include #include +#include =20 struct user_namespace; extern struct user_namespace init_user_ns; @@ -171,4 +172,6 @@ static inline struct page *find_timens_vvar_page(struct= vm_area_struct *vma) } #endif /* CONFIG_TIME_NS_VDSO */ =20 +DEFINE_FREE(time_ns, struct time_namespace *, if (_T) put_time_ns(_T)) + #endif /* _LINUX_TIMENS_H */ --=20 2.53.0 From nobody Mon Apr 6 10:37:48 2026 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 04D8F1B4F0A for ; Mon, 30 Mar 2026 07:09:17 +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=1774854559; cv=none; b=Dh9UnI9HLvbEienCDJ461zSyls1ohedMAX+UKX/bPMsm11rBnPlPUw8leALtjliwdBYoiEaWRHsoDHCWMlUSm67jab9xcsdmqpcgIilq5sWBwgM/L0Yc4WDu7z5sb++suXp8PCGlJR2kE05EcjFNzfF5ZLAK5XbfAG1brITk7cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774854559; c=relaxed/simple; bh=RMi4toWB8rANPuRlGR/U3Ylpn46UH18qARWQgNaNc5w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hBQAQFXqzoa7HWnKx9GTgyR9EYVi5THTc32MMdPktcUSMIHvnsu3aMoI+OlCsuiWC8d3YD646txkDqx6ni5Y7mAlePnMRvn62mRFC01l7rsCx/gtGW+OLFN5yXTqkGpNZVR4imsGzi405sLNHM6+PLkCUatBBSltxP9R7ThcOd4= 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=fnoHweYl; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PhN3DIzv; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fnoHweYl"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PhN3DIzv" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774854556; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ppYCVW3xdyWu4fiIVU8bl2UHAp4HeSZWcfGNTKcTgZI=; b=fnoHweYlm6kBox4HUIJHQfc3j6yLPzIDCFxB9RdUnwMyfoZa+Ud/T9vXb3NFnq3a58lt50 EEdlOxS16ujlU51E0yMrsKoRB9STkS/KKgWtqlPvM6+rK6eQz1eg9+wnAnBjeaHDG5qq3b FqGj6sSQRW5ObV2t7yIitRkvkXhds8hiOgz7IxdLoA3mmOmZgrbp6M2RMLJpNFnhNPckAE kEcshiSlZLfCRu7okj7kkC18PWwLbGe3hPXJdauIabksw+VR5WP6HhCMxDISybmFc76lHr O2XDxk4XmKMg9ON7nwQfI3ZULYmc5xoI/8anLYkiCE9PE3W7vTXNRGwITswtWg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774854556; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ppYCVW3xdyWu4fiIVU8bl2UHAp4HeSZWcfGNTKcTgZI=; b=PhN3DIzv6ieMlAGSbLlpbrnnl3c/ErgnWBkLJq4sNRXhlhrIHXsQH05f7v3FcRht6oZYta S63LNEKef/s2+rDg== Date: Mon, 30 Mar 2026 09:07:56 +0200 Subject: [PATCH 2/4] timens: Simplify some calls to put_time_ns() 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" Content-Transfer-Encoding: quoted-printable Message-Id: <20260330-timens-cleanup-v1-2-936e91c9dd30@linutronix.de> References: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> In-Reply-To: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1774854554; l=2777; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=RMi4toWB8rANPuRlGR/U3Ylpn46UH18qARWQgNaNc5w=; b=5jHpcf13Q3Og8xKg3yVVvwuIdu64fzxE4Sai8SM99bjUBSS/k5mx2PILHWSRLJuZIkIKpKyxY pNVTXD73sWkCui9t5CJ1sevi7VQz88aQfRZTRe22aSEV45nLsC+4Z0r X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Use the new __free() based cleanup helpers to simplify some functions. Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/time/namespace.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index 42302cc3f3fb..ae9a3a5d53ab 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 #include "namespace_internal.h" =20 @@ -252,7 +253,7 @@ static void show_offset(struct seq_file *m, int clockid= , struct timespec64 *ts) void proc_timens_show_offsets(struct task_struct *p, struct seq_file *m) { struct ns_common *ns; - struct time_namespace *time_ns; + struct time_namespace *time_ns __free(time_ns) =3D NULL; =20 ns =3D timens_for_children_get(p); if (!ns) @@ -261,14 +262,13 @@ void proc_timens_show_offsets(struct task_struct *p, = struct seq_file *m) =20 show_offset(m, CLOCK_MONOTONIC, &time_ns->offsets.monotonic); show_offset(m, CLOCK_BOOTTIME, &time_ns->offsets.boottime); - put_time_ns(time_ns); } =20 int proc_timens_set_offset(struct file *file, struct task_struct *p, struct proc_timens_offset *offsets, int noffsets) { struct ns_common *ns; - struct time_namespace *time_ns; + struct time_namespace *time_ns __free(time_ns) =3D NULL; struct timespec64 tp; int i, err; =20 @@ -277,10 +277,8 @@ int proc_timens_set_offset(struct file *file, struct t= ask_struct *p, return -ESRCH; time_ns =3D to_time_ns(ns); =20 - if (!file_ns_capable(file, time_ns->user_ns, CAP_SYS_TIME)) { - put_time_ns(time_ns); + if (!file_ns_capable(file, time_ns->user_ns, CAP_SYS_TIME)) return -EPERM; - } =20 for (i =3D 0; i < noffsets; i++) { struct proc_timens_offset *off =3D &offsets[i]; @@ -293,15 +291,12 @@ int proc_timens_set_offset(struct file *file, struct = task_struct *p, ktime_get_boottime_ts64(&tp); break; default: - err =3D -EINVAL; - goto out; + return -EINVAL; } =20 - err =3D -ERANGE; - if (off->val.tv_sec > KTIME_SEC_MAX || off->val.tv_sec < -KTIME_SEC_MAX) - goto out; + return -ERANGE; =20 tp =3D timespec64_add(tp, off->val); /* @@ -309,7 +304,7 @@ int proc_timens_set_offset(struct file *file, struct ta= sk_struct *p, * still unreachable. */ if (tp.tv_sec < 0 || tp.tv_sec > KTIME_SEC_MAX / 2) - goto out; + return -ERANGE; } =20 mutex_lock(&timens_offset_lock); @@ -338,8 +333,6 @@ int proc_timens_set_offset(struct file *file, struct ta= sk_struct *p, =20 out_unlock: mutex_unlock(&timens_offset_lock); -out: - put_time_ns(time_ns); =20 return err; } --=20 2.53.0 From nobody Mon Apr 6 10:37:48 2026 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 7CE8539E182 for ; Mon, 30 Mar 2026 07:09:18 +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=1774854559; cv=none; b=R10ThfomYd9dpYWKhtvi/pZ0q+pJPGf7MDohuRuYrQ8YxwoyfSyCF2mxQ0wwsI9wUCaKbBwcGEaRW/qMYwMJxwMYPE49Qe3pGJ6/zHRbHy/Plcos00g/HYV4UZD6R5a6zyuFs6U6mZ18/xkLzvgsp7NhvlNbw4TIyRX0PHiAS+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774854559; c=relaxed/simple; bh=Bc+ptgJBdaBk/5Sx6PCdBEGIkalnt6khME7rGqNXpsI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UATSVgkq5bxpSkRBk39UmPvBCwRayzaJca14G1MbRiGMJX2KyVuXeipjFrIXGVBghXHNQDf3rhFvBvDNjEQTnpG4M5YvLv6spUkyRTcrslx/hKi4o5o9dJnJPgFXko9qbv/4pNiE5tuoTw584fPmBcd/RDY3muOOF7FhfyKJpw4= 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=SWyyHqOd; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Mf3R47AL; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SWyyHqOd"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Mf3R47AL" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774854557; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zAGYtFj+YwYE6/AdrTqvaZohgqeJBNZIvkdQXQ8WpbA=; b=SWyyHqOdqwVx0Dq8EuDvFHZUjPMMaI/Gi3bOIdoyhbwnaBXnHdvQBycDFyDWoLbxFrEZXX +s4GTl8hhO8LRvugsqjhnwdr5Mskg1s9uuImd4IsDZel3nFHwVo2NjyxrAOrjf6c/CIMjd c5p/La9RJrBS0EyvtHv6jpwLj0w3BOSPALl4ELJR5ipyBN9Pv1o3fB50MoMqJvu/gVSqbH so8rpy1Velov7vPN4ek1Syi8B2wcqNjEzovjVWf40utis7pLwps7LxJvAHecHaQTAmqjGm PniSYAkpLPm19SDPIqps4qVuISg08p1PWIhgMWI9mRdipGxHtGfIsDkEm4yGGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774854557; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zAGYtFj+YwYE6/AdrTqvaZohgqeJBNZIvkdQXQ8WpbA=; b=Mf3R47ALsxHqym9xAWPhYs2aTNUn1XmMX1Jku7GASNXnFujEIvdxm0q4jJRP9VSkzwQ8ic tCLFzi8hQ0FTp/DA== Date: Mon, 30 Mar 2026 09:07:57 +0200 Subject: [PATCH 3/4] timens: Use mutex guard in proc_timens_set_offset() 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" Content-Transfer-Encoding: quoted-printable Message-Id: <20260330-timens-cleanup-v1-3-936e91c9dd30@linutronix.de> References: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> In-Reply-To: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1774854554; l=1466; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Bc+ptgJBdaBk/5Sx6PCdBEGIkalnt6khME7rGqNXpsI=; b=SR3p88+d/ix+GYc1LgMloVXcCQjreBBJTaCJEUuEYpY4YwJoo8adqmYZhzIt15f2HIWEDRk3y ZRynXb82XLDAEOeYIuajqexjH7FRS/TMh/xlHO0EYDsr/geJpPdSCdA X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Simplify the logic in proc_timens_set_offset() by converting the mutex usage to a guard(). Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/time/namespace.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index ae9a3a5d53ab..fbf026e63104 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -270,7 +270,7 @@ int proc_timens_set_offset(struct file *file, struct ta= sk_struct *p, struct ns_common *ns; struct time_namespace *time_ns __free(time_ns) =3D NULL; struct timespec64 tp; - int i, err; + int i; =20 ns =3D timens_for_children_get(p); if (!ns) @@ -307,13 +307,10 @@ int proc_timens_set_offset(struct file *file, struct = task_struct *p, return -ERANGE; } =20 - mutex_lock(&timens_offset_lock); - if (time_ns->frozen_offsets) { - err =3D -EACCES; - goto out_unlock; - } + guard(mutex)(&timens_offset_lock); + if (time_ns->frozen_offsets) + return -EACCES; =20 - err =3D 0; /* Don't report errors after this line */ for (i =3D 0; i < noffsets; i++) { struct proc_timens_offset *off =3D &offsets[i]; @@ -331,10 +328,7 @@ int proc_timens_set_offset(struct file *file, struct t= ask_struct *p, *offset =3D off->val; } =20 -out_unlock: - mutex_unlock(&timens_offset_lock); - - return err; + return 0; } =20 const struct proc_ns_operations timens_operations =3D { --=20 2.53.0 From nobody Mon Apr 6 10:37:48 2026 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 EC07239E196 for ; Mon, 30 Mar 2026 07:09:18 +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=1774854560; cv=none; b=g43eBr7tcmFwUMCeDKgJB23rAsoM1agoCCG1lxOiy+E3I5CYf7X0bGPVfSc+8FZrzcbw+LtmypdZyKsmsSF7XKXipf521WcIv4Mp1phmO5H78rk4vHRa4DSIHwh6IxIi9Tn4CTcogBR8O9JfVk1OJiYzSf3G/lHvLO0SvlOyvVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774854560; c=relaxed/simple; bh=zaOZZgV/Oh9qZStVRJd7WDKI3LH+qej3/KimnlajPCk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AAOyAoByGrm4o3tihRjpLqZjOfvKwc/EeNK9MzNLX0Ay4y9KqvMfsBYYdMJ+O8AVC2S1DJ4L8OIin4hyi5pyj+jQvVc2Hip9aoiHVkd3Pgrw++sg/+spTtt9S7tBCFCCtAVFDskYiGVGPbYWVcpQkCOL/oSW4W49+ntjzNZjuqI= 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=ETBCNaiT; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BkC91JwI; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ETBCNaiT"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BkC91JwI" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774854557; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VVt4vmqZpClveKwXCPCJckhLv0/U++7IiRFJx443mMo=; b=ETBCNaiTRf8bWJHBmqODJ92dTSQvMF9/1fvfq8uhliPEw2Dr4SXZHk/ou/9fRWNf3VCWkB Gnf8jPWd5BziqG/V3/KPwlzs4USyPt1cRpsBqODLeej4rDn1j91ROBCjlKoxU6Fmf8rbnG 5b82g6VqtbE2kNeWuwjgx6PfEW4PrY7eynmBOLWCclq5ca7fUizgsPx1jiynCgXBzD81El r9+6nn1/2a3sHDQyevxwWU71J9zw15DGSX4NvqVGU/yo1BUZaYxvUEh6ZVykgqwPKLJYQp mu14Dq3StE31Pe4W/IbZljTYVXU6luIwI4i9RRcWFei6xH6DKGNwUrKUdPejuQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774854557; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VVt4vmqZpClveKwXCPCJckhLv0/U++7IiRFJx443mMo=; b=BkC91JwI8zixnPgpit8MnTAtslgdFWy8PeW5+qxaMUKTFApT+IUj+xgNaFidombP8M5NNW MUiv5GLR7/X76ACQ== Date: Mon, 30 Mar 2026 09:07:58 +0200 Subject: [PATCH 4/4] timens: Use task_lock guard in timens_get*() 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" Content-Transfer-Encoding: quoted-printable Message-Id: <20260330-timens-cleanup-v1-4-936e91c9dd30@linutronix.de> References: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> In-Reply-To: <20260330-timens-cleanup-v1-0-936e91c9dd30@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1774854554; l=1564; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=zaOZZgV/Oh9qZStVRJd7WDKI3LH+qej3/KimnlajPCk=; b=OdCM4qXeYU6oLuOlJFI2vSLHbUba9GpyOoA3cSA6Pj6AufA/43r9R08+HUHzE+bJ4GR9E2ooa 9Ythnu4evDpBpyHpsMS98ayyn7pkRwfpJAzQVYHm28COI9jD60ZtEML X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Simplify the logic in timens_get*() by converting the task_lock usage to a guard(). Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/time/namespace.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index fbf026e63104..9d2e4870a2c5 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -154,34 +154,32 @@ void free_time_ns(struct time_namespace *ns) =20 static struct ns_common *timens_get(struct task_struct *task) { - struct time_namespace *ns =3D NULL; + struct time_namespace *ns; struct nsproxy *nsproxy; =20 - task_lock(task); + guard(task_lock)(task); nsproxy =3D task->nsproxy; - if (nsproxy) { - ns =3D nsproxy->time_ns; - get_time_ns(ns); - } - task_unlock(task); + if (!nsproxy) + return NULL; =20 - return ns ? &ns->ns : NULL; + ns =3D nsproxy->time_ns; + get_time_ns(ns); + return &ns->ns; } =20 static struct ns_common *timens_for_children_get(struct task_struct *task) { - struct time_namespace *ns =3D NULL; + struct time_namespace *ns; struct nsproxy *nsproxy; =20 - task_lock(task); + guard(task_lock)(task); nsproxy =3D task->nsproxy; - if (nsproxy) { - ns =3D nsproxy->time_ns_for_children; - get_time_ns(ns); - } - task_unlock(task); + if (!nsproxy) + return NULL; =20 - return ns ? &ns->ns : NULL; + ns =3D nsproxy->time_ns_for_children; + get_time_ns(ns); + return &ns->ns; } =20 static void timens_put(struct ns_common *ns) --=20 2.53.0