Skip to content
Snippets Groups Projects
  1. Jan 06, 2022
    • Miroslav Lichvar's avatar
      net: fix SOF_TIMESTAMPING_BIND_PHC to work with multiple sockets · 007747a9
      Miroslav Lichvar authored
      
      When multiple sockets using the SOF_TIMESTAMPING_BIND_PHC flag received
      a packet with a hardware timestamp (e.g. multiple PTP instances in
      different PTP domains using the UDPv4/v6 multicast or L2 transport),
      the timestamps received on some sockets were corrupted due to repeated
      conversion of the same timestamp (by the same or different vclocks).
      
      Fix ptp_convert_timestamp() to not modify the shared skb timestamp
      and return the converted timestamp as a ktime_t instead. If the
      conversion fails, return 0 to not confuse the application with
      timestamps corresponding to an unexpected PHC.
      
      Fixes: d7c08826 ("net: socket: support hardware timestamp conversion to PHC bound")
      Signed-off-by: default avatarMiroslav Lichvar <mlichvar@redhat.com>
      Cc: Yangbo Lu <yangbo.lu@nxp.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      007747a9
  2. Jan 02, 2022
  3. Dec 27, 2021
  4. Dec 16, 2021
  5. Aug 27, 2021
    • Peter Collingbourne's avatar
      net: don't unconditionally copy_from_user a struct ifreq for socket ioctls · d0efb162
      Peter Collingbourne authored
      A common implementation of isatty(3) involves calling a ioctl passing
      a dummy struct argument and checking whether the syscall failed --
      bionic and glibc use TCGETS (passing a struct termios), and musl uses
      TIOCGWINSZ (passing a struct winsize). If the FD is a socket, we will
      copy sizeof(struct ifreq) bytes of data from the argument and return
      -EFAULT if that fails. The result is that the isatty implementations
      may return a non-POSIX-compliant value in errno in the case where part
      of the dummy struct argument is inaccessible, as both struct termios
      and struct winsize are smaller than struct ifreq (at least on arm64).
      
      Although there is usually enough stack space following the argument
      on the stack that this did not present a practical problem up to now,
      with MTE stack instrumentation it's more likely for the copy to fail,
      as the memory following the struct may have a different tag.
      
      Fix the problem by adding an early check for whether the ioctl is a
      valid socket ioctl, and return -ENOTTY if it isn't.
      
      Fixes: 44c02a2c ("dev_ioctl(): move copyin/copyout to callers")
      Link: https://linux-review.googlesource.com/id/I869da6cf6daabc3e4b7b82ac979683ba05e27d4d
      
      
      Signed-off-by: default avatarPeter Collingbourne <pcc@google.com>
      Cc: <stable@vger.kernel.org> # 4.19
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d0efb162
  6. Aug 25, 2021
  7. Jul 29, 2021
  8. Jul 27, 2021
    • Arnd Bergmann's avatar
      net: bridge: move bridge ioctls out of .ndo_do_ioctl · ad2f99ae
      Arnd Bergmann authored
      
      Working towards obsoleting the .ndo_do_ioctl operation entirely,
      stop passing the SIOCBRADDIF/SIOCBRDELIF device ioctl commands
      into this callback.
      
      My first attempt was to add another ndo_siocbr() callback, but
      as there is only a single driver that takes these commands and
      there is already a hook mechanism to call directly into this
      driver, extend this hook instead, and use it for both the
      deviceless and the device specific ioctl commands.
      
      Cc: Roopa Prabhu <roopa@nvidia.com>
      Cc: Nikolay Aleksandrov <nikolay@nvidia.com>
      Cc: bridge@lists.linux-foundation.org
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ad2f99ae
    • Arnd Bergmann's avatar
      net: socket: return changed ifreq from SIOCDEVPRIVATE · 88fc023f
      Arnd Bergmann authored
      
      Some drivers that use SIOCDEVPRIVATE ioctl commands modify
      the ifreq structure and expect it to be passed back to user
      space, which has never really happened for compat mode
      because the calling these drivers through ndo_do_ioctl
      requires overwriting the ifr_data pointer.
      
      Now that all drivers are converted to ndo_siocdevprivate,
      change it to handle this correctly in both compat and
      native mode.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      88fc023f
    • Arnd Bergmann's avatar
      dev_ioctl: pass SIOCDEVPRIVATE data separately · a554bf96
      Arnd Bergmann authored
      
      The compat handlers for SIOCDEVPRIVATE are incorrect for any driver that
      passes data as part of struct ifreq rather than as an ifr_data pointer, or
      that passes data back this way, since the compat_ifr_data_ioctl() helper
      overwrites the ifr_data pointer and does not copy anything back out.
      
      Since all drivers using devprivate commands are now converted to the
      new .ndo_siocdevprivate callback, fix this by adding the missing piece
      and passing the pointer separately the whole way.
      
      This further unifies the native and compat logic for socket ioctls,
      as the new code now passes the correct pointer as well as the correct
      data for both native and compat ioctls.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a554bf96
  9. Jul 23, 2021
    • Arnd Bergmann's avatar
      net: socket: rework compat_ifreq_ioctl() · 29c49648
      Arnd Bergmann authored
      
      compat_ifreq_ioctl() is one of the last users of copy_in_user() and
      compat_alloc_user_space(), as it attempts to convert the 'struct ifreq'
      arguments from 32-bit to 64-bit format as used by dev_ioctl() and a
      couple of socket family specific interpretations.
      
      The current implementation works correctly when calling dev_ioctl(),
      inet_ioctl(), ieee802154_sock_ioctl(), atalk_ioctl(), qrtr_ioctl()
      and packet_ioctl(). The ioctl handlers for x25, netrom, rose and x25 do
      not interpret the arguments and only block the corresponding commands,
      so they do not care.
      
      For af_inet6 and af_decnet however, the compat conversion is slightly
      incorrect, as it will copy more data than the native handler accesses,
      both of them use a structure that is shorter than ifreq.
      
      Replace the copy_in_user() conversion with a pair of accessor functions
      to read and write the ifreq data in place with the correct length where
      needed, while leaving the other ones to copy the (already compatible)
      structures directly.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      29c49648
    • Arnd Bergmann's avatar
      net: socket: simplify dev_ifconf handling · 876f0bf9
      Arnd Bergmann authored
      
      The dev_ifconf() calling conventions make compat handling
      more complicated than necessary, simplify this by moving
      the in_compat_syscall() check into the function.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      876f0bf9
    • Arnd Bergmann's avatar
      net: socket: rework SIOC?IFMAP ioctls · 709566d7
      Arnd Bergmann authored
      
      SIOCGIFMAP and SIOCSIFMAP currently require compat_alloc_user_space()
      and copy_in_user() for compat mode.
      
      Move the compat handling into the location where the structures are
      actually used, to avoid using those interfaces and get a clearer
      implementation.
      
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      709566d7
    • Arnd Bergmann's avatar
      ethtool: improve compat ioctl handling · dd98d289
      Arnd Bergmann authored
      
      The ethtool compat ioctl handling is hidden away in net/socket.c,
      which introduces a couple of minor oddities:
      
      - The implementation may end up diverging, as seen in the RXNFC
        extension in commit 84a1d9c4 ("net: ethtool: extend RXNFC
        API to support RSS spreading of filter matches") that does not work
        in compat mode.
      
      - Most architectures do not need the compat handling at all
        because u64 and compat_u64 have the same alignment.
      
      - On x86, the conversion is done for both x32 and i386 user space,
        but it's actually wrong to do it for x32 and cannot work there.
      
      - On 32-bit Arm, it never worked for compat oabi user space, since
        that needs to do the same conversion but does not.
      
      - It would be nice to get rid of both compat_alloc_user_space()
        and copy_in_user() throughout the kernel.
      
      None of these actually seems to be a serious problem that real
      users are likely to encounter, but fixing all of them actually
      leads to code that is both shorter and more readable.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dd98d289
  10. Jul 01, 2021
  11. Jun 21, 2021
  12. Jun 18, 2021
  13. Jun 12, 2021
    • Changbin Du's avatar
      net: make get_net_ns return error if NET_NS is disabled · ea6932d7
      Changbin Du authored
      
      There is a panic in socket ioctl cmd SIOCGSKNS when NET_NS is not enabled.
      The reason is that nsfs tries to access ns->ops but the proc_ns_operations
      is not implemented in this case.
      
      [7.670023] Unable to handle kernel NULL pointer dereference at virtual address 00000010
      [7.670268] pgd = 32b54000
      [7.670544] [00000010] *pgd=00000000
      [7.671861] Internal error: Oops: 5 [#1] SMP ARM
      [7.672315] Modules linked in:
      [7.672918] CPU: 0 PID: 1 Comm: systemd Not tainted 5.13.0-rc3-00375-g6799d4f2da49 #16
      [7.673309] Hardware name: Generic DT based system
      [7.673642] PC is at nsfs_evict+0x24/0x30
      [7.674486] LR is at clear_inode+0x20/0x9c
      
      The same to tun SIOCGSKNS command.
      
      To fix this problem, we make get_net_ns() return -EINVAL when NET_NS is
      disabled. Meanwhile move it to right place net/core/net_namespace.c.
      
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Fixes: c62cce2c ("net: add an ioctl to get a socket network namespace")
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ea6932d7
  14. Mar 25, 2021
  15. Feb 24, 2021
  16. Jan 24, 2021
    • Christian Brauner's avatar
      fs: make helpers idmap mount aware · 549c7297
      Christian Brauner authored
      Extend some inode methods with an additional user namespace argument. A
      filesystem that is aware of idmapped mounts will receive the user
      namespace the mount has been marked with. This can be used for
      additional permission checking and also to enable filesystems to
      translate between uids and gids if they need to. We have implemented all
      relevant helpers in earlier patches.
      
      As requested we simply extend the exisiting inode method instead of
      introducing new ones. This is a little more code churn but it's mostly
      mechanical and doesnt't leave us with additional inode methods.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-25-christian.brauner@ubuntu.com
      
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      549c7297
    • Christian Brauner's avatar
      acl: handle idmapped mounts · e65ce2a5
      Christian Brauner authored
      The posix acl permission checking helpers determine whether a caller is
      privileged over an inode according to the acls associated with the
      inode. Add helpers that make it possible to handle acls on idmapped
      mounts.
      
      The vfs and the filesystems targeted by this first iteration make use of
      posix_acl_fix_xattr_from_user() and posix_acl_fix_xattr_to_user() to
      translate basic posix access and default permissions such as the
      ACL_USER and ACL_GROUP type according to the initial user namespace (or
      the superblock's user namespace) to and from the caller's current user
      namespace. Adapt these two helpers to handle idmapped mounts whereby we
      either map from or into the mount's user namespace depending on in which
      direction we're translating.
      Similarly, cap_convert_nscap() is used by the vfs to translate user
      namespace and non-user namespace aware filesystem capabilities from the
      superblock's user namespace to the caller's user namespace. Enable it to
      handle idmapped mounts by accounting for the mount's user namespace.
      
      In addition the fileystems targeted in the first iteration of this patch
      series make use of the posix_acl_chmod() and, posix_acl_update_mode()
      helpers. Both helpers perform permission checks on the target inode. Let
      them handle idmapped mounts. These two helpers are called when posix
      acls are set by the respective filesystems to handle this case we extend
      the ->set() method to take an additional user namespace argument to pass
      the mount's user namespace down.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-9-christian.brauner@ubuntu.com
      
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      e65ce2a5
  17. Jan 20, 2021
  18. Dec 04, 2020
  19. Nov 24, 2020
  20. Nov 23, 2020
  21. Nov 17, 2020
    • Xie He's avatar
      net: wan: Delete the DLCI / SDLA drivers · f7365919
      Xie He authored
      
      The DLCI driver (dlci.c) implements the Frame Relay protocol. However,
      we already have another newer and better implementation of Frame Relay
      provided by the HDLC_FR driver (hdlc_fr.c).
      
      The DLCI driver's implementation of Frame Relay is used by only one
      hardware driver in the kernel - the SDLA driver (sdla.c).
      
      The SDLA driver provides Frame Relay support for the Sangoma S50x devices.
      However, the vendor provides their own driver (along with their own
      multi-WAN-protocol implementations including Frame Relay), called WANPIPE.
      I believe most users of the hardware would use the vendor-provided WANPIPE
      driver instead.
      
      (The WANPIPE driver was even once in the kernel, but was deleted in
      commit 8db60bcf ("[WAN]: Remove broken and unmaintained Sangoma
      drivers.") because the vendor no longer updated the in-kernel WANPIPE
      driver.)
      
      Cc: Mike McLagan <mike.mclagan@linux.org>
      Signed-off-by: default avatarXie He <xie.he.0141@gmail.com>
      Link: https://lore.kernel.org/r/20201114150921.685594-1-xie.he.0141@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f7365919
  22. Oct 02, 2020
    • Coly Li's avatar
      net: add WARN_ONCE in kernel_sendpage() for improper zero-copy send · 7b62d31d
      Coly Li authored
      
      If a page sent into kernel_sendpage() is a slab page or it doesn't have
      ref_count, this page is improper to send by the zero copy sendpage()
      method. Otherwise such page might be unexpected released in network code
      path and causes impredictable panic due to kernel memory management data
      structure corruption.
      
      This path adds a WARN_ON() on the sending page before sends it into the
      concrete zero-copy sendpage() method, if the page is improper for the
      zero-copy sendpage() method, a warning message can be observed before
      the consequential unpredictable kernel panic.
      
      This patch does not change existing kernel_sendpage() behavior for the
      improper page zero-copy send, it just provides hint warning message for
      following potential panic due the kernel memory heap corruption.
      
      Signed-off-by: default avatarColy Li <colyli@suse.de>
      Cc: Cong Wang <amwang@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Sridhar Samudrala <sri@us.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7b62d31d
  23. Aug 27, 2020
  24. Aug 24, 2020
  25. Aug 10, 2020
  26. Aug 08, 2020
  27. Jul 28, 2020
  28. Jul 24, 2020
Loading