From nobody Mon Apr 6 12:00:19 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