mbox series

[v2,0/1,F] ptp: fix potential general protection fault in ptp_clock_unregister()

Message ID 20200327100706.1356731-1-andrea.righi@canonical.com
Headers show
Series ptp: fix potential general protection fault in ptp_clock_unregister() | expand

Message

Andrea Righi March 27, 2020, 10:07 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1864754

v2: move pps_unregister_source() to ptp_clock_release(), instead of
    posix_clock_unregister(), that would just introduce a resource leak

[Impact]

Disconnecting a thunderbolt docking station on a Dell Inc. XPS 13
9360/0D4J15 can cause a general protection fault (with kernel 5.3.0-40
and above).

The bug has been introduced by this upstream commit:

  ffe3bcaf02c4 ptp: fix the race between the release of ptp_clock and cdev

Reverting the commit is not a viable option, because we would
re-introduce another bug.

The proper fix is to do something similar to this:

  75718584cb3c64e6269109d4d54f888ac5a5fd15 "ptp: free ptp device pin descriptors properly"

and call pps_unregister_source() in ptp_clock_release(). NOTE: this bug
is also present upstream.

[Test case]

Bug reported provided the test case by physically disconnecting the
docking station. The problems can be easily reproduced and it doesn't
seem to happen anymore with the fix applied.

[Fix]

Call call pps_unregister_source() from ptp_clock_release() instead of
ptp_clock_unregister().

[Regression potential]

Minimal regression potential, the change is limited to the ptp clock
unregistering code path.

----------------------------------------------------------------
The following changes since commit 18e4e93f3f5cfbc918bce59299b81742b09ed7b5:

  UBUNTU: SAUCE: selftests/seccomp -- Disable timeout for seccomp tests (2020-03-26 16:13:17 +0100)

are available in the Git repository at:

  . cranky/master-next

for you to fetch changes up to 9036326e9f2770ba48ba02846ef5ec59ebaf5aae:

  UBUNTU: SAUCE: ptp: free ptp clock properly (2020-03-27 10:51:36 +0100)

----------------------------------------------------------------
Andrea Righi (1):
      UBUNTU: SAUCE: ptp: free ptp clock properly

 drivers/ptp/ptp_clock.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Seth Forshee April 2, 2020, 6:31 p.m. UTC | #1
On Fri, Mar 27, 2020 at 11:07:05AM +0100, Andrea Righi wrote:
> BugLink: https://bugs.launchpad.net/bugs/1864754
> 
> v2: move pps_unregister_source() to ptp_clock_release(), instead of
>     posix_clock_unregister(), that would just introduce a resource leak
> 
> [Impact]
> 
> Disconnecting a thunderbolt docking station on a Dell Inc. XPS 13
> 9360/0D4J15 can cause a general protection fault (with kernel 5.3.0-40
> and above).
> 
> The bug has been introduced by this upstream commit:
> 
>   ffe3bcaf02c4 ptp: fix the race between the release of ptp_clock and cdev
> 
> Reverting the commit is not a viable option, because we would
> re-introduce another bug.
> 
> The proper fix is to do something similar to this:
> 
>   75718584cb3c64e6269109d4d54f888ac5a5fd15 "ptp: free ptp device pin descriptors properly"
> 
> and call pps_unregister_source() in ptp_clock_release(). NOTE: this bug
> is also present upstream.
> 
> [Test case]
> 
> Bug reported provided the test case by physically disconnecting the
> docking station. The problems can be easily reproduced and it doesn't
> seem to happen anymore with the fix applied.
> 
> [Fix]
> 
> Call call pps_unregister_source() from ptp_clock_release() instead of
> ptp_clock_unregister().
> 
> [Regression potential]
> 
> Minimal regression potential, the change is limited to the ptp clock
> unregistering code path.

This was applied previously, noting it here for the record.