<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/ptp, branch v5.4.213</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.213</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.213'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2022-04-15T12:18:32Z</updated>
<entry>
<title>ptp: replace snprintf with sysfs_emit</title>
<updated>2022-04-15T12:18:32Z</updated>
<author>
<name>Yang Guang</name>
<email>yang.guang5@zte.com.cn</email>
</author>
<published>2022-01-27T00:02:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9388d876099710da96a0e64b512b08c019d7fc19'/>
<id>urn:sha1:9388d876099710da96a0e64b512b08c019d7fc19</id>
<content type='text'>
[ Upstream commit e2cf07654efb0fd7bbcb475c6f74be7b5755a8fd ]

coccinelle report:
./drivers/ptp/ptp_sysfs.c:17:8-16:
WARNING: use scnprintf or sprintf
./drivers/ptp/ptp_sysfs.c:390:8-16:
WARNING: use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot &lt;zealci@zte.com.cn&gt;
Signed-off-by: Yang Guang &lt;yang.guang5@zte.com.cn&gt;
Signed-off-by: David Yang &lt;davidcomponentone@gmail.com&gt;
Acked-by: Richard Cochran &lt;richardcochran@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>ptp_pch: Load module automatically if ID matches</title>
<updated>2021-10-13T08:08:19Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2021-10-01T16:20:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=27e53e23a3cef73a6aac9a776685af1bebca0565'/>
<id>urn:sha1:27e53e23a3cef73a6aac9a776685af1bebca0565</id>
<content type='text'>
[ Upstream commit 7cd8b1542a7ba0720c5a0a85ed414a122015228b ]

The driver can't be loaded automatically because it misses
module alias to be provided. Add corresponding MODULE_DEVICE_TABLE()
call to the driver.

Fixes: 863d08ece9bf ("supports eg20t ptp clock")
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>ptp_pch: Restore dependency on PCI</title>
<updated>2021-08-26T12:36:17Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2021-08-13T17:33:27Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c9566df334d0c3356c80b9ba79161ebb433c16c6'/>
<id>urn:sha1:c9566df334d0c3356c80b9ba79161ebb433c16c6</id>
<content type='text'>
[ Upstream commit 55c8fca1dae1fb0d11deaa21b65a647dedb1bc50 ]

During the swap dependency on PCH_GBE to selection PTP_1588_CLOCK_PCH
incidentally dropped the implicit dependency on the PCI. Restore it.

Fixes: 18d359ceb044 ("pch_gbe, ptp_pch: Fix the dependency direction between these drivers")
Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>ptp: improve max_adj check against unreasonable values</title>
<updated>2021-06-23T12:41:26Z</updated>
<author>
<name>Jakub Kicinski</name>
<email>kuba@kernel.org</email>
</author>
<published>2021-06-14T22:24:05Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3daa97817aa818ea783e6edcf4e9d9c47b6c330f'/>
<id>urn:sha1:3daa97817aa818ea783e6edcf4e9d9c47b6c330f</id>
<content type='text'>
[ Upstream commit 475b92f932168a78da8109acd10bfb7578b8f2bb ]

Scaled PPM conversion to PPB may (on 64bit systems) result
in a value larger than s32 can hold (freq/scaled_ppm is a long).
This means the kernel will not correctly reject unreasonably
high -&gt;freq values (e.g. &gt; 4294967295ppb, 281474976645 scaled PPM).

The conversion is equivalent to a division by ~66 (65.536),
so the value of ppb is always smaller than ppm, but not small
enough to assume narrowing the type from long -&gt; s32 is okay.

Note that reasonable user space (e.g. ptp4l) will not use such
high values, anyway, 4289046510ppb ~= 4.3x, so the fix is
somewhat pedantic.

Fixes: d39a743511cd ("ptp: validate the requested frequency adjustment.")
Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Acked-by: Richard Cochran &lt;richardcochran@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>ptp: free ptp device pin descriptors properly</title>
<updated>2020-01-23T07:22:51Z</updated>
<author>
<name>Vladis Dronov</name>
<email>vdronov@redhat.com</email>
</author>
<published>2020-01-13T13:00:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4fd16cfcc3ae28cf42c67941fd529600f21bec39'/>
<id>urn:sha1:4fd16cfcc3ae28cf42c67941fd529600f21bec39</id>
<content type='text'>
[ Upstream commit 75718584cb3c64e6269109d4d54f888ac5a5fd15 ]

There is a bug in ptp_clock_unregister(), where ptp_cleanup_pin_groups()
first frees ptp-&gt;pin_{,dev_}attr, but then posix_clock_unregister() needs
them to destroy a related sysfs device.

These functions can not be just swapped, as posix_clock_unregister() frees
ptp which is needed in the ptp_cleanup_pin_groups(). Fix this by calling
ptp_cleanup_pin_groups() in ptp_clock_release(), right before ptp is freed.

This makes this patch fix an UAF bug in a patch which fixes an UAF bug.

Reported-by: Antti Laakso &lt;antti.laakso@intel.com&gt;
Fixes: a33121e5487b ("ptp: fix the race between the release of ptp_clock and cdev")
Link: https://lore.kernel.org/netdev/3d2bd09735dbdaf003585ca376b7c1e5b69a19bd.camel@intel.com/
Signed-off-by: Vladis Dronov &lt;vdronov@redhat.com&gt;
Acked-by: Richard Cochran &lt;richardcochran@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ptp: fix the race between the release of ptp_clock and cdev</title>
<updated>2020-01-04T18:18:48Z</updated>
<author>
<name>Vladis Dronov</name>
<email>vdronov@redhat.com</email>
</author>
<published>2019-12-27T02:26:27Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bfa2e0cd3dfda64fde43c3dca3aeba298d2fe7ad'/>
<id>urn:sha1:bfa2e0cd3dfda64fde43c3dca3aeba298d2fe7ad</id>
<content type='text'>
[ Upstream commit a33121e5487b424339636b25c35d3a180eaa5f5e ]

In a case when a ptp chardev (like /dev/ptp0) is open but an underlying
device is removed, closing this file leads to a race. This reproduces
easily in a kvm virtual machine:

ts# cat openptp0.c
int main() { ... fp = fopen("/dev/ptp0", "r"); ... sleep(10); }
ts# uname -r
5.5.0-rc3-46cf053e
ts# cat /proc/cmdline
... slub_debug=FZP
ts# modprobe ptp_kvm
ts# ./openptp0 &amp;
[1] 670
opened /dev/ptp0, sleeping 10s...
ts# rmmod ptp_kvm
ts# ls /dev/ptp*
ls: cannot access '/dev/ptp*': No such file or directory
ts# ...woken up
[   48.010809] general protection fault: 0000 [#1] SMP
[   48.012502] CPU: 6 PID: 658 Comm: openptp0 Not tainted 5.5.0-rc3-46cf053e #25
[   48.014624] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), ...
[   48.016270] RIP: 0010:module_put.part.0+0x7/0x80
[   48.017939] RSP: 0018:ffffb3850073be00 EFLAGS: 00010202
[   48.018339] RAX: 000000006b6b6b6b RBX: 6b6b6b6b6b6b6b6b RCX: ffff89a476c00ad0
[   48.018936] RDX: fffff65a08d3ea08 RSI: 0000000000000247 RDI: 6b6b6b6b6b6b6b6b
[   48.019470] ...                                              ^^^ a slub poison
[   48.023854] Call Trace:
[   48.024050]  __fput+0x21f/0x240
[   48.024288]  task_work_run+0x79/0x90
[   48.024555]  do_exit+0x2af/0xab0
[   48.024799]  ? vfs_write+0x16a/0x190
[   48.025082]  do_group_exit+0x35/0x90
[   48.025387]  __x64_sys_exit_group+0xf/0x10
[   48.025737]  do_syscall_64+0x3d/0x130
[   48.026056]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   48.026479] RIP: 0033:0x7f53b12082f6
[   48.026792] ...
[   48.030945] Modules linked in: ptp i6300esb watchdog [last unloaded: ptp_kvm]
[   48.045001] Fixing recursive fault but reboot is needed!

This happens in:

static void __fput(struct file *file)
{   ...
    if (file-&gt;f_op-&gt;release)
        file-&gt;f_op-&gt;release(inode, file); &lt;&lt;&lt; cdev is kfree'd here
    if (unlikely(S_ISCHR(inode-&gt;i_mode) &amp;&amp; inode-&gt;i_cdev != NULL &amp;&amp;
             !(mode &amp; FMODE_PATH))) {
        cdev_put(inode-&gt;i_cdev); &lt;&lt;&lt; cdev fields are accessed here

Namely:

__fput()
  posix_clock_release()
    kref_put(&amp;clk-&gt;kref, delete_clock) &lt;&lt;&lt; the last reference
      delete_clock()
        delete_ptp_clock()
          kfree(ptp) &lt;&lt;&lt; cdev is embedded in ptp
  cdev_put
    module_put(p-&gt;owner) &lt;&lt;&lt; *p is kfree'd, bang!

Here cdev is embedded in posix_clock which is embedded in ptp_clock.
The race happens because ptp_clock's lifetime is controlled by two
refcounts: kref and cdev.kobj in posix_clock. This is wrong.

Make ptp_clock's sysfs device a parent of cdev with cdev_device_add()
created especially for such cases. This way the parent device with its
ptp_clock is not released until all references to the cdev are released.
This adds a requirement that an initialized but not exposed struct
device should be provided to posix_clock_register() by a caller instead
of a simple dev_t.

This approach was adopted from the commit 72139dfa2464 ("watchdog: Fix
the race between the release of watchdog_core_data and cdev"). See
details of the implementation in the commit 233ed09d7fda ("chardev: add
helper function to register char devs with a struct device").

Link: https://lore.kernel.org/linux-fsdevel/20191125125342.6189-1-vdronov@redhat.com/T/#u
Analyzed-by: Stephen Johnston &lt;sjohnsto@redhat.com&gt;
Analyzed-by: Vern Lovejoy &lt;vlovejoy@redhat.com&gt;
Signed-off-by: Vladis Dronov &lt;vdronov@redhat.com&gt;
Acked-by: Richard Cochran &lt;richardcochran@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ptp: Introduce strict checking of external time stamp options.</title>
<updated>2019-11-15T20:48:32Z</updated>
<author>
<name>Richard Cochran</name>
<email>richardcochran@gmail.com</email>
</author>
<published>2019-11-14T18:45:02Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6138e687c7b679da08c0feb55a88f448f7890c07'/>
<id>urn:sha1:6138e687c7b679da08c0feb55a88f448f7890c07</id>
<content type='text'>
User space may request time stamps on rising edges, falling edges, or
both.  However, the particular mode may or may not be supported in the
hardware or in the driver.  This patch adds a "strict" flag that tells
drivers to ensure that the requested mode will be honored.

Signed-off-by: Richard Cochran &lt;richardcochran@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>ptp: Validate requests to enable time stamping of external signals.</title>
<updated>2019-11-15T20:48:32Z</updated>
<author>
<name>Richard Cochran</name>
<email>richardcochran@gmail.com</email>
</author>
<published>2019-11-14T18:44:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cd734d54e67990eebfc3106dc39047c1141d4197'/>
<id>urn:sha1:cd734d54e67990eebfc3106dc39047c1141d4197</id>
<content type='text'>
Commit 415606588c61 ("PTP: introduce new versions of IOCTLs")
introduced a new external time stamp ioctl that validates the flags.
This patch extends the validation to ensure that at least one rising
or falling edge flag is set when enabling external time stamps.

Signed-off-by: Richard Cochran &lt;richardcochran@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>ptp: fix typo of "mechanism" in Kconfig help text</title>
<updated>2019-10-07T18:55:46Z</updated>
<author>
<name>Antonio Borneo</name>
<email>antonio.borneo@st.com</email>
</author>
<published>2019-10-07T15:43:02Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=503c9addef613c872679e24fc8a78f3febeb5a08'/>
<id>urn:sha1:503c9addef613c872679e24fc8a78f3febeb5a08</id>
<content type='text'>
Fix typo s/mechansim/mechanism/

Signed-off-by: Antonio Borneo &lt;antonio.borneo@st.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>ptp_qoriq: Initialize the registers' spinlock before calling ptp_qoriq_settime</title>
<updated>2019-10-02T16:20:38Z</updated>
<author>
<name>Vladimir Oltean</name>
<email>olteanv@gmail.com</email>
</author>
<published>2019-10-01T19:07:01Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=db34a4714c013b644eec2de0ec81b1f0373b8b93'/>
<id>urn:sha1:db34a4714c013b644eec2de0ec81b1f0373b8b93</id>
<content type='text'>
Because ptp_qoriq_settime is being called prior to spin_lock_init, the
following stack trace can be seen at driver probe time:

[    2.269117] the code is fine but needs lockdep annotation.
[    2.274569] turning off the locking correctness validator.
[    2.280027] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc7-01478-g01eaa67a4797 #263
[    2.288073] Hardware name: Freescale LS1021A
[    2.292337] [&lt;c0313cb4&gt;] (unwind_backtrace) from [&lt;c030e11c&gt;] (show_stack+0x10/0x14)
[    2.300045] [&lt;c030e11c&gt;] (show_stack) from [&lt;c1219440&gt;] (dump_stack+0xcc/0xf8)
[    2.307235] [&lt;c1219440&gt;] (dump_stack) from [&lt;c03b9b44&gt;] (register_lock_class+0x730/0x73c)
[    2.315372] [&lt;c03b9b44&gt;] (register_lock_class) from [&lt;c03b6190&gt;] (__lock_acquire+0x78/0x270c)
[    2.323856] [&lt;c03b6190&gt;] (__lock_acquire) from [&lt;c03b90cc&gt;] (lock_acquire+0xe0/0x22c)
[    2.331649] [&lt;c03b90cc&gt;] (lock_acquire) from [&lt;c123c310&gt;] (_raw_spin_lock_irqsave+0x54/0x68)
[    2.340048] [&lt;c123c310&gt;] (_raw_spin_lock_irqsave) from [&lt;c0e73fe4&gt;] (ptp_qoriq_settime+0x38/0x80)
[    2.348878] [&lt;c0e73fe4&gt;] (ptp_qoriq_settime) from [&lt;c0e746d4&gt;] (ptp_qoriq_init+0x1f8/0x484)
[    2.357189] [&lt;c0e746d4&gt;] (ptp_qoriq_init) from [&lt;c0e74aac&gt;] (ptp_qoriq_probe+0xd0/0x184)
[    2.365243] [&lt;c0e74aac&gt;] (ptp_qoriq_probe) from [&lt;c0b0a07c&gt;] (platform_drv_probe+0x48/0x9c)
[    2.373555] [&lt;c0b0a07c&gt;] (platform_drv_probe) from [&lt;c0b07a14&gt;] (really_probe+0x1c4/0x400)
[    2.381779] [&lt;c0b07a14&gt;] (really_probe) from [&lt;c0b07e28&gt;] (driver_probe_device+0x78/0x1b8)
[    2.390003] [&lt;c0b07e28&gt;] (driver_probe_device) from [&lt;c0b081d0&gt;] (device_driver_attach+0x58/0x60)
[    2.398832] [&lt;c0b081d0&gt;] (device_driver_attach) from [&lt;c0b082d4&gt;] (__driver_attach+0xfc/0x160)
[    2.407402] [&lt;c0b082d4&gt;] (__driver_attach) from [&lt;c0b05a84&gt;] (bus_for_each_dev+0x68/0xb4)
[    2.415539] [&lt;c0b05a84&gt;] (bus_for_each_dev) from [&lt;c0b06b68&gt;] (bus_add_driver+0x104/0x20c)
[    2.423763] [&lt;c0b06b68&gt;] (bus_add_driver) from [&lt;c0b0909c&gt;] (driver_register+0x78/0x10c)
[    2.431815] [&lt;c0b0909c&gt;] (driver_register) from [&lt;c030313c&gt;] (do_one_initcall+0x8c/0x3ac)
[    2.439954] [&lt;c030313c&gt;] (do_one_initcall) from [&lt;c1f013f4&gt;] (kernel_init_freeable+0x468/0x548)
[    2.448610] [&lt;c1f013f4&gt;] (kernel_init_freeable) from [&lt;c12344d8&gt;] (kernel_init+0x8/0x10c)
[    2.456745] [&lt;c12344d8&gt;] (kernel_init) from [&lt;c03010b4&gt;] (ret_from_fork+0x14/0x20)
[    2.464273] Exception stack(0xea89ffb0 to 0xea89fff8)
[    2.469297] ffa0:                                     00000000 00000000 00000000 00000000
[    2.477432] ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.485566] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000

Fixes: ff54571a747b ("ptp_qoriq: convert to use ptp_qoriq_init/free")
Signed-off-by: Vladimir Oltean &lt;olteanv@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
