ptp: prevent info leak to userspace
Subsystems (3)
PATCH 1/1 ptp: prevent info leak to userspace
Somehow the memset is lost after refactor, which leaks a lot of kernel stack data to userspace directly. This patch clears the reserved data region to prevent the info leak.
--- drivers/ptp/ptp_chardev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ptp/ptp_chardev.c +2 -0
@@ -195,6 +195,8 @@ static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg)if (caps.adjust_phase) caps.max_phase_adj = ptp->info->getmaxphase (ptp->info); +memset (caps.rsv,0 ,sizeof (caps.rsv)); +return copy_to_user (arg, &caps,sizeof (caps)) ? -EFAULT :0 ; }
Signature · 1 line
2.43.0
Quoted 14 lines · Kyle Zeng
Somehow the
memsetis lost after refactor, which leaks a lot of kernel stack data to userspace directly. This patch clears the reserved data region to prevent the info leak.Signed-off-by Kyle Zeng <[email protected]>--- drivers/ptp/ptp_chardev.c | 2 ++ 1 file changed, 2 insertions(+)drivers/ptp/ptp_chardev.c +0
-0
drivers/ptp/ptp_chardev.c static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg) · line 202
Quoted 8 lines
drivers/ptp/ptp_chardev.c +2
-0@@ -195,6 +195,8 @@ static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg)if (caps.adjust_phase) caps.max_phase_adj = ptp->info->getmaxphase (ptp->info); +memset (caps.rsv,0 ,sizeof (caps.rsv)); +return copy_to_user (arg, &caps,sizeof (caps)) ? -EFAULT :0 ; }
This is not how C works, the designated initializer clears the field implicitly.
I apologize for the rookie mistake. Should've known better than this. And thanks for the correction.
Quoted 27 lines · Gal Pressman
Quoted 14 lines · Kyle Zeng
Somehow the
memsetis lost after refactor, which leaks a lot of kernel stack data to userspace directly. This patch clears the reserved data region to prevent the info leak.Signed-off-by Kyle Zeng <[email protected]>--- drivers/ptp/ptp_chardev.c | 2 ++ 1 file changed, 2 insertions(+)drivers/ptp/ptp_chardev.c +0
-0drivers/ptp/ptp_chardev.c static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg) · line 202
Quoted 8 lines
drivers/ptp/ptp_chardev.c +2
-0@@ -195,6 +195,8 @@ static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg)if (caps.adjust_phase) caps.max_phase_adj = ptp->info->getmaxphase (ptp->info); +memset (caps.rsv,0 ,sizeof (caps.rsv)); +return copy_to_user (arg, &caps,sizeof (caps)) ? -EFAULT :0 ; }This is not how C works, the designated initializer clears the field implicitly.