Skip to content

Commit c48a7f1

Browse files
CKI Backport BotHangbin Liu
authored andcommitted
ptp: Ensure info->enable callback is always set
JIRA: https://issues.redhat.com/browse/RHEL-84646 CVE: CVE-2025-21814 commit fd53aa4 Author: Thomas Weißschuh <linux@weissschuh.net> Date: Thu Jan 23 08:22:40 2025 +0100 ptp: Ensure info->enable callback is always set The ioctl and sysfs handlers unconditionally call the ->enable callback. Not all drivers implement that callback, leading to NULL dereferences. Example of affected drivers: ptp_s390.c, ptp_vclock.c and ptp_mock.c. Instead use a dummy callback if no better was specified by the driver. Fixes: d94ba80 ("ptp: Added a brand new class driver for ptp clocks.") Cc: stable@vger.kernel.org Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Richard Cochran <richardcochran@gmail.com> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Link: https://patch.msgid.link/20250123-ptp-enable-v1-1-b015834d3a47@weissschuh.net Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> Signed-off-by: Hangbin Liu <haliu@redhat.com>
1 parent 7110535 commit c48a7f1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/ptp/ptp_clock.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ static int ptp_getcycles64(struct ptp_clock_info *info, struct timespec64 *ts)
217217
return info->gettime64(info, ts);
218218
}
219219

220+
static int ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *request, int on)
221+
{
222+
return -EOPNOTSUPP;
223+
}
224+
220225
static void ptp_aux_kworker(struct kthread_work *work)
221226
{
222227
struct ptp_clock *ptp = container_of(work, struct ptp_clock,
@@ -294,6 +299,9 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
294299
ptp->info->getcrosscycles = ptp->info->getcrosststamp;
295300
}
296301

302+
if (!ptp->info->enable)
303+
ptp->info->enable = ptp_enable;
304+
297305
if (ptp->info->do_aux_work) {
298306
kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker);
299307
ptp->kworker = kthread_create_worker(0, "ptp%d", ptp->index);

0 commit comments

Comments
 (0)