summaryrefslogtreecommitdiff
path: root/drivers/ptp/ptp_private.h
diff options
context:
space:
mode:
authorEdward Adam Davis <eadavis@qq.com>2023-11-07 16:00:41 +0800
committerJakub Kicinski <kuba@kernel.org>2023-11-08 18:47:07 -0800
commit1bea2c3e6df8caf45d18384abfb707f47e9ff993 (patch)
tree247a0999ede72aabbdd2c4acf9ada9a843947ebd /drivers/ptp/ptp_private.h
parentb714ca2ccf6a90733f6ceb14abb6ce914f8832c3 (diff)
ptp: fix corrupted list in ptp_open
There is no lock protection when writing ptp->tsevqs in ptp_open() and ptp_release(), which can cause data corruption, use spin lock to avoid this issue. Moreover, ptp_release() should not be used to release the queue in ptp_read(), and it should be deleted altogether. Acked-by: Richard Cochran <richardcochran@gmail.com> Reported-and-tested-by: syzbot+df3f3ef31f60781fa911@syzkaller.appspotmail.com Fixes: 8f5de6fb2453 ("ptp: support multiple timestamp event readers") Signed-off-by: Edward Adam Davis <eadavis@qq.com> Link: https://lore.kernel.org/r/tencent_CD19564FFE8DA8A5918DFE92325D92DD8107@qq.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/ptp/ptp_private.h')
-rw-r--r--drivers/ptp/ptp_private.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h
index 52f87e394aa6..35fde0a05746 100644
--- a/drivers/ptp/ptp_private.h
+++ b/drivers/ptp/ptp_private.h
@@ -44,6 +44,7 @@ struct ptp_clock {
struct pps_device *pps_source;
long dialed_frequency; /* remembers the frequency adjustment */
struct list_head tsevqs; /* timestamp fifo list */
+ spinlock_t tsevqs_lock; /* protects tsevqs from concurrent access */
struct mutex pincfg_mux; /* protect concurrent info->pin_config access */
wait_queue_head_t tsev_wq;
int defunct; /* tells readers to go away when clock is being removed */