]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
nfc: Fix the sockaddr length sanitization in llcp_sock_connect
authorMateusz Jurczyk <mjurczyk@google.com>
Wed, 24 May 2017 10:26:20 +0000 (12:26 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Fri, 11 Aug 2017 10:37:27 +0000 (12:37 +0200)
commitb34aa61ab8747de173dfe2b885d414971ecc3f7e
treead7a282f18481b12b4816238c1b7bdb1da0ca1e4
parente47c270e6fff55dafa05793b98ede70f0b1d934c
nfc: Fix the sockaddr length sanitization in llcp_sock_connect

BugLink: http://bugs.launchpad.net/bugs/1707233
commit 608c4adfcabab220142ee335a2a003ccd1c0b25b upstream.

Fix the sockaddr length verification in the connect() handler of NFC/LLCP
sockets, to compare against the size of the actual structure expected on
input (sockaddr_nfc_llcp) instead of its shorter version (sockaddr_nfc).

Both structures are defined in include/uapi/linux/nfc.h. The fields
specific to the _llcp extended struct are as follows:

   276 __u8 dsap; /* Destination SAP, if known */
   277 __u8 ssap; /* Source SAP to be bound to */
   278 char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */;
   279 size_t service_name_len;

If the caller doesn't provide a sufficiently long sockaddr buffer, these
fields remain uninitialized (and they currently originate from the stack
frame of the top-level sys_connect handler). They are then copied by
llcp_sock_connect() into internal storage (nfc_llcp_sock structure), and
could be subsequently read back through the user-mode getsockname()
function (handled by llcp_sock_getname()). This would result in the
disclosure of up to ~70 uninitialized bytes from the kernel stack to
user-mode clients capable of creating AFC_NFC sockets.

Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
net/nfc/llcp_sock.c