Skip to content
Snippets Groups Projects
  1. Jun 01, 2018
    • TeYuan Wang's avatar
      arm64/configs: Remove LIMITS_LITE_HW config · f5b04bed
      TeYuan Wang authored
      
      Suspect device may have posibility to be blocked by lmh_read when resume,
      and we do not need to get the details about sensors which supported by LMH Lite,
      so remove lmh lite driver to avoid resume hang risk.
      
      Bug: 80022235
      Test: Thermal-engine work properly
      
      Change-Id: I8d7052246aa9f2c8669132931dc91893c43d30cd
      Signed-off-by: default avatarTeYuan Wang <kamewang@google.com>
      f5b04bed
  2. May 10, 2018
  3. May 07, 2018
  4. Apr 16, 2018
    • Stuart Scott's avatar
    • tinlin's avatar
      qcacld-2.0: Add data_len check to avoid OOB access · a0ae6f0e
      tinlin authored
      Add data_len check in wma_nan_rsp_event_handler()
      to avoid OOB access.
      
      Bug: 74237168
      Change-Id: Iff42da84567381a4b64bc07e69ff1a0cd4b5a543
      CRs-Fixed: 2170630
      a0ae6f0e
    • Chenglu Lin's avatar
      drivers: htc_debug: Avoid possible buffer overflow in reboot_block driver · fe22ed6e
      Chenglu Lin authored
      
      Bug: 71363680
      Change-Id: I1a07a74cae96b4548df4cb089e31485734149280
      Signed-off-by: default avatarChenglu Lin <chenglulin@android.com>
      fe22ed6e
    • Hardik Arya's avatar
      diag: Validate copying length against source buffer length · 87dc0bb9
      Hardik Arya authored
      
      There a possibility of out-of-bound read because of not
      validating source buffer length against length that about
      to be copied. The patch adds proper check for validating
      length before copying data
      
      Bug: 70399602
      CRs-Fixed: 2163793
      Change-Id: I7c93839d0c4d83024ce23a0ce494d09dd08567a9
      Signed-off-by: default avatarHardik Arya <harya@codeaurora.org>
      87dc0bb9
    • Zhang Qian's avatar
      qcacld-2.0: Fix potential buffer overflow · 4e6d3a6b
      Zhang Qian authored
      
      Fragment count will be larger than the upper limit of
      cvg_nbuf_cb->extra_flag.num which would lead to an overread
      of fragment length. Upper limit check for fragment count
      is added in this change.
      
      Change-Id: Icc078b2efee554ac84377b5edd90d0a5c7a61f98
      CRs-Fixed: 2129566
      Bug: 72957387
      Signed-off-by: default avatarEcco Park <eccopark@google.com>
      4e6d3a6b
    • Tharun Kumar Merugu's avatar
      msm: adsprpc: Fix race conditions on same buffer · eb630f73
      Tharun Kumar Merugu authored
      
      Variable map may pointing to the same buffer on race conditions
      in functions fastrpc_internal_mmap and fastrpc_internal_munmap,
      use mutex to avoid race conditions on same buffer.
      
      Bug: 72957546
      Change-Id: I96ed884c44a36f574677ba3ba189dfbf2ce3751d
      Acked-by: default avatarKrishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
      Signed-off-by: default avatarTharun Kumar Merugu <mtharu@codeaurora.org>
      eb630f73
    • Tiger Yu's avatar
      qcacld-2.0: Fix potential buffer overwrite in the htt_t2h_lp_msg_handler · 61980fa7
      Tiger Yu authored
      
      Check for the validity of tx_desc_id when received the htt message of
      HTT_T2H_MSG_TYPE_MGMT_TX_COMPL_IND from firmware to ensure the buffer
      overwrite does not happen.
      
      Bug: 74237532
      
      Change-Id: I0afc781b7fff303525352b817e7eb60b8b05e4d3
      CRs-Fixed: 2157917
      Signed-off-by: default avatarAhmed ElArabawy <arabawy@google.com>
      61980fa7
    • Alan Stern's avatar
      USB: core: prevent malicious bNumInterfaces overflow · ac75d0c2
      Alan Stern authored
      
      commit 48a4ff1c upstream.
      
      A malicious USB device with crafted descriptors can cause the kernel
      to access unallocated memory by setting the bNumInterfaces value too
      high in a configuration descriptor.  Although the value is adjusted
      during parsing, this adjustment is skipped in one of the error return
      paths.
      
      This patch prevents the problem by setting bNumInterfaces to 0
      initially.  The existing code already sets it to the proper value
      after parsing is complete.
      
      Bug: 71751622
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Change-Id: I89bb5c8e48e7654aac05a7936f4ee92e1481ca65
      ac75d0c2
    • Sean Callanan's avatar
      mm-camera2:isp2: Handle use after free buffer · 1b940319
      Sean Callanan authored
      
      In the code, start_fetch can try to access the
      buffer pointer variable after free, as the
      same pointer can be freed at RELEASE_BUF call
      at the same time.
      
      CRs-Fixed: 2149998
      Change-Id: Ic83f22336504cf67afe12131f791eee25477f011
      Signed-off-by: default avatarMeera Gande <mgande@codeaurora.org>
      Signed-off-by: default avatarVijayaKumar T M <vtmuni@codeaurora.org>
      
      Bug: 69065862
      Signed-off-by: default avatarSean Callanan <spyffe@google.com>
      1b940319
    • Himanshu Agarwal's avatar
      qcacld-2.0: Move NBUF_UPDATE_TX_PKT_COUNT before freeing netbuf · f3caabdf
      Himanshu Agarwal authored
      
      Move NBUF_UPDATE_TX_PKT_COUNT in ol_tx_completion_handler to make
      sure that netbuf is not accessed after it is freed.
      
      Bug: 71638332
      
      Change-Id: Ifba9de788b11ce8cb323827d10f8005029609231
      CRs-fixed: 1040612
      Signed-off-by: default avatarAhmed ElArabawy <arabawy@google.com>
      f3caabdf
    • Tharun Kumar Merugu's avatar
      msm: ADSPRPC: Use ID in response to get context pointer · af97a143
      Tharun Kumar Merugu authored
      
      Send context ID in rpc header instead of context pointer.
      Validate context ID received in response and get context pointer.
      
      Bug: 74237782
      Change-Id: I9cfd10d0c1b25c3085b8e15c7ca1c8ff214bf10d
      Acked-by: default avatarViswanatham Paduchuri <vpaduchu@qti.qualcomm.com>
      Signed-off-by: default avatarTharun Kumar Merugu <mtharu@codeaurora.org>
      Signed-off-by: default avatarSteve Pfetsch <spfetsch@google.com>
      af97a143
    • c_mtharu's avatar
      msm: ADSPRPC: validate context pointer with magic number · a68d2bd2
      c_mtharu authored
      
      Validate context pointer using magic number instead of searching
      through context list. It removes the usage of spin lock in interrupt
      handler for avoiding deadlock and reducing latency.
      
      Bug: 74237782
      Change-Id: I2492a7984a8d6545618a9cfb7a2d239d03ddd5a2
      Acked-by: default avatarViswanatham Paduchuri <vpaduchu@qti.qualcomm.com>
      Signed-off-by: default avatarTharun Kumar Merugu <mtharu@codeaurora.org>
      a68d2bd2
    • Andrew Chant's avatar
      diag: dci: check signed values for negativity · a589cb7a
      Andrew Chant authored
      
      when comparing a signed value vs sizeof, make sure
      it's >= 0 so that when promoted to signed for comparison
      it won't lead to unexpected results.
      
      Bug: 70528036
      Change-Id: I99a1220598e67e3ce5c99d425e84c79639121838
      Signed-off-by: default avatarAndrew Chant <achant@google.com>
      a589cb7a
    • Sreelakshmi Gownipalli's avatar
      diag: Add conditional check for len in dci_process_ctrl_status() · 154e958a
      Sreelakshmi Gownipalli authored
      
      Add correct conditional check for len in dci_process_ctrl_status() to
      prevent buffer overflow.
      
      Bug: 70528036
      Change-Id: Id73ed1c8b104428eceef0544ce2858160cc08fd2
      Signed-off-by: default avatarSreelakshmi Gownipalli <sgownipa@codeaurora.org>
      154e958a
    • Mark Salyzyn's avatar
      ANDROID: Bluetooth: hidp: buffer overflow in hidp_process_report · 9d65e3a7
      Mark Salyzyn authored
      
      The buffer length is unsigned at all layers, but gets cast to int and
      checked in hidp_process_report and can lead to a buffer overflow.
      Switch len parameter to unsigned int to resolve issue.
      
      Signed-off-by: default avatarMark Salyzyn <salyzyn@google.com>
      Fixes: 678af93e46ac10318b54f2f0c9abbdfe75c4e078 ("HID: Bluetooth: hidp: make sure input buffers are big enough")
      Bug: 65853588
      Change-Id: I779ce783ae7c3bce8c5a66c0954ef31347e42cfc
      9d65e3a7
    • Carter Cooper's avatar
      msm: kgsl: Properly remove ref count on gpuobj_sync failure · a6fba7d9
      Carter Cooper authored
      
      The user can pass bad data into kgsl_ioctl_gpuobj_sync(). If
      _copy_from_user() fails do to bad data, undo any current
      references taken through this ioctl call.
      
      Bug: 74237606
      Change-Id: I56195520b9dadba20ee419658fc2cbb282b8449c
      Signed-off-by: default avatarCarter Cooper <ccooper@codeaurora.org>
      Signed-off-by: default avatarsamit vats <svats@codeaurora.org>
      a6fba7d9
    • Eric Biggers's avatar
      KEYS: add missing permission check for request_key() destination · af06b5bb
      Eric Biggers authored
      
      commit 4dca6ea1 upstream.
      
      When the request_key() syscall is not passed a destination keyring, it
      links the requested key (if constructed) into the "default" request-key
      keyring.  This should require Write permission to the keyring.  However,
      there is actually no permission check.
      
      This can be abused to add keys to any keyring to which only Search
      permission is granted.  This is because Search permission allows joining
      the keyring.  keyctl_set_reqkey_keyring(KEY_REQKEY_DEFL_SESSION_KEYRING)
      then will set the default request-key keyring to the session keyring.
      Then, request_key() can be used to add keys to the keyring.
      
      Both negatively and positively instantiated keys can be added using this
      method.  Adding negative keys is trivial.  Adding a positive key is a
      bit trickier.  It requires that either /sbin/request-key positively
      instantiates the key, or that another thread adds the key to the process
      keyring at just the right time, such that request_key() misses it
      initially but then finds it in construct_alloc_key().
      
      Fix this bug by checking for Write permission to the keyring in
      construct_get_dest_keyring() when the default keyring is being used.
      
      We don't do the permission check for non-default keyrings because that
      was already done by the earlier call to lookup_user_key().  Also,
      request_key_and_link() is currently passed a 'struct key *' rather than
      a key_ref_t, so the "possessed" bit is unavailable.
      
      We also don't do the permission check for the "requestor keyring", to
      continue to support the use case described by commit 8bbf4976
      ("KEYS: Alter use of key instantiation link-to-keyring argument") where
      /sbin/request-key recursively calls request_key() to add keys to the
      original requestor's destination keyring.  (I don't know of any users
      who actually do that, though...)
      
      Fixes: 3e30148c ("[PATCH] Keys: Make request-key create an authorisation key")
      Bug: 71751178
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Change-Id: I22bf395912a0d4dd84f27d27138bd9d03dcce5ab
      af06b5bb
    • Eric Biggers's avatar
      crypto: hmac - require that the underlying hash algorithm is unkeyed · 6da4492f
      Eric Biggers authored
      
      commit <af3ff804> upstream.
      
      Because the HMAC template didn't check that its underlying hash
      algorithm is unkeyed, trying to use "hmac(hmac(sha3-512-generic))"
      through AF_ALG or through KEYCTL_DH_COMPUTE resulted in the inner HMAC
      being used without having been keyed, resulting in sha3_update() being
      called without sha3_init(), causing a stack buffer overflow.
      
      This is a very old bug, but it seems to have only started causing real
      problems when SHA-3 support was added (requires CONFIG_CRYPTO_SHA3)
      because the innermost hash's state is ->import()ed from a zeroed buffer,
      and it just so happens that other hash algorithms are fine with that,
      but SHA-3 is not.  However, there could be arch or hardware-dependent
      hash algorithms also affected; I couldn't test everything.
      
      Fix the bug by introducing a function crypto_shash_alg_has_setkey()
      which tests whether a shash algorithm is keyed.  Then update the HMAC
      template to require that its underlying hash algorithm is unkeyed.
      
      Here is a reproducer:
      
          #include <linux/if_alg.h>
          #include <sys/socket.h>
      
          int main()
          {
              int algfd;
              struct sockaddr_alg addr = {
                  .salg_type = "hash",
                  .salg_name = "hmac(hmac(sha3-512-generic))",
              };
              char key[4096] = { 0 };
      
              algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
              bind(algfd, (const struct sockaddr *)&addr, sizeof(addr));
              setsockopt(algfd, SOL_ALG, ALG_SET_KEY, key, sizeof(key));
          }
      
      Here was the KASAN report from syzbot:
      
          BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:341  [inline]
          BUG: KASAN: stack-out-of-bounds in sha3_update+0xdf/0x2e0  crypto/sha3_generic.c:161
          Write of size 4096 at addr ffff8801cca07c40 by task syzkaller076574/3044
      
          CPU: 1 PID: 3044 Comm: syzkaller076574 Not tainted 4.14.0-mm1+ #25
          Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  Google 01/01/2011
          Call Trace:
            __dump_stack lib/dump_stack.c:17 [inline]
            dump_stack+0x194/0x257 lib/dump_stack.c:53
            print_address_description+0x73/0x250 mm/kasan/report.c:252
            kasan_report_error mm/kasan/report.c:351 [inline]
            kasan_report+0x25b/0x340 mm/kasan/report.c:409
            check_memory_region_inline mm/kasan/kasan.c:260 [inline]
            check_memory_region+0x137/0x190 mm/kasan/kasan.c:267
            memcpy+0x37/0x50 mm/kasan/kasan.c:303
            memcpy include/linux/string.h:341 [inline]
            sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
            crypto_shash_update+0xcb/0x220 crypto/shash.c:109
            shash_finup_unaligned+0x2a/0x60 crypto/shash.c:151
            crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
            hmac_finup+0x182/0x330 crypto/hmac.c:152
            crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
            shash_digest_unaligned+0x9e/0xd0 crypto/shash.c:172
            crypto_shash_digest+0xc4/0x120 crypto/shash.c:186
            hmac_setkey+0x36a/0x690 crypto/hmac.c:66
            crypto_shash_setkey+0xad/0x190 crypto/shash.c:64
            shash_async_setkey+0x47/0x60 crypto/shash.c:207
            crypto_ahash_setkey+0xaf/0x180 crypto/ahash.c:200
            hash_setkey+0x40/0x90 crypto/algif_hash.c:446
            alg_setkey crypto/af_alg.c:221 [inline]
            alg_setsockopt+0x2a1/0x350 crypto/af_alg.c:254
            SYSC_setsockopt net/socket.c:1851 [inline]
            SyS_setsockopt+0x189/0x360 net/socket.c:1830
            entry_SYSCALL_64_fastpath+0x1f/0x96
      
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Bug: 71752561
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Change-Id: Icfc16f18b0454ecc886cab0cdf9e93c018f2a44d
      6da4492f
    • Liam Mark's avatar
      ion: ensure CMO target is valid · 2aabc328
      Liam Mark authored
      
      Cleanup ION cache maintenance code to properly validate the target of
      userspace cache maintenance requests.
      
      Bug: 72957321
      Change-Id: I55b8e3584c59634f95250bc7c0bce5d8d70e6a13
      Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
      2aabc328
    • Eric Biggers's avatar
      KEYS: fix out-of-bounds read during ASN.1 parsing · 0aa2e60f
      Eric Biggers authored
      
      commit 2eb9eabf upstream.
      
      syzkaller with KASAN reported an out-of-bounds read in
      asn1_ber_decoder().  It can be reproduced by the following command,
      assuming CONFIG_X509_CERTIFICATE_PARSER=y and CONFIG_KASAN=y:
      
          keyctl add asymmetric desc $'\x30\x30' @s
      
      The bug is that the length of an ASN.1 data value isn't validated in the
      case where it is encoded using the short form, causing the decoder to
      read past the end of the input buffer.  Fix it by validating the length.
      
      The bug report was:
      
          BUG: KASAN: slab-out-of-bounds in asn1_ber_decoder+0x10cb/0x1730 lib/asn1_decoder.c:233
          Read of size 1 at addr ffff88003cccfa02 by task syz-executor0/6818
      
          CPU: 1 PID: 6818 Comm: syz-executor0 Not tainted 4.14.0-rc7-00008-g5f479447d983 #2
          Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
          Call Trace:
           __dump_stack lib/dump_stack.c:16 [inline]
           dump_stack+0xb3/0x10b lib/dump_stack.c:52
           print_address_description+0x79/0x2a0 mm/kasan/report.c:252
           kasan_report_error mm/kasan/report.c:351 [inline]
           kasan_report+0x236/0x340 mm/kasan/report.c:409
           __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:427
           asn1_ber_decoder+0x10cb/0x1730 lib/asn1_decoder.c:233
           x509_cert_parse+0x1db/0x650 crypto/asymmetric_keys/x509_cert_parser.c:89
           x509_key_preparse+0x64/0x7a0 crypto/asymmetric_keys/x509_public_key.c:174
           asymmetric_key_preparse+0xcb/0x1a0 crypto/asymmetric_keys/asymmetric_type.c:388
           key_create_or_update+0x347/0xb20 security/keys/key.c:855
           SYSC_add_key security/keys/keyctl.c:122 [inline]
           SyS_add_key+0x1cd/0x340 security/keys/keyctl.c:62
           entry_SYSCALL_64_fastpath+0x1f/0xbe
          RIP: 0033:0x447c89
          RSP: 002b:00007fca7a5d3bd8 EFLAGS: 00000246 ORIG_RAX: 00000000000000f8
          RAX: ffffffffffffffda RBX: 00007fca7a5d46cc RCX: 0000000000447c89
          RDX: 0000000020006f4a RSI: 0000000020006000 RDI: 0000000020001ff5
          RBP: 0000000000000046 R08: fffffffffffffffd R09: 0000000000000000
          R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
          R13: 0000000000000000 R14: 00007fca7a5d49c0 R15: 00007fca7a5d4700
      
      Fixes: 42d5ec27 ("X.509: Add an ASN.1 decoder")
      Bug: 73827422
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Change-Id: I49455e7006a338e15326c9c3e1a2607ebf09baf4
      0aa2e60f
    • Hanumanth Reddy Pothula's avatar
      qcacld-2.0: Remove FW memory dump feature · d4bf16ed
      Hanumanth Reddy Pothula authored
      
      FW memory dump feature is no longer used. Hence remove FW memory
      dump feature code changes.
      
      Change-Id: Ida655f83630c369df746e7c0c9d61a8fee2932a2
      CRs-Fixed: 2120605
      Bug: 65542521
      Signed-off-by: default avatarSrinivas Girigowda <sgirigow@codeaurora.org>
      d4bf16ed
    • Sean Callanan's avatar
      msm: ADSPRPC: use access_ok to validate pointers · 4afaa191
      Sean Callanan authored
      
      The FASTRPC_IOCTL_INIT ioctl registers a pointer for later
      access without checking that it is a user pointer.  This could
      allow arbitrary kernel memory access.
      
      This patch verifies that the pointer is a user pointer.
      
      Bug: 63165064
      Change-Id: I936f73a2c2029f9e7ca12cc8fc06d0698e6710c0
      Signed-off-by: default avatarTharun Kumar Merugu <mtharu@codeaurora.org>
      Signed-off-by: default avatarSean Callanan <spyffe@google.com>
      4afaa191
    • Vaishnavi Kommaraju's avatar
      ASoC: wcd_cpe_core: Add mutex lock for CPE session · 45ee7d90
      Vaishnavi Kommaraju authored
      
      Add mutex lock to ensure atomic access to core handle
      in CPE alloc and dealloc sessions.
      
      CRs-Fixed: 2169403
      Bug: 62536960
      Signed-off-by: default avatarVaishnavi Kommaraju <vkommara@codeaurora.org>
      Change-Id: Iaf95e462e6ec8bfa711013d2239140b51d897eff
      45ee7d90
    • Mike Maloney's avatar
      ipv6: fix udpv6 sendmsg crash caused by too small MTU · fe0ec339
      Mike Maloney authored
      
      [ Upstream commit 749439bf ]
      
      The logic in __ip6_append_data() assumes that the MTU is at least large
      enough for the headers.  A device's MTU may be adjusted after being
      added while sendmsg() is processing data, resulting in
      __ip6_append_data() seeing any MTU.  For an mtu smaller than the size of
      the fragmentation header, the math results in a negative 'maxfraglen',
      which causes problems when refragmenting any previous skb in the
      skb_write_queue, leaving it possibly malformed.
      
      Instead sendmsg returns EINVAL when the mtu is calculated to be less
      than IPV6_MIN_MTU.
      
      Found by syzkaller:
      kernel BUG at ./include/linux/skbuff.h:2064!
      invalid opcode: 0000 [#1] SMP KASAN
      Dumping ftrace buffer:
         (ftrace buffer empty)
      Modules linked in:
      CPU: 1 PID: 14216 Comm: syz-executor5 Not tainted 4.13.0-rc4+ #2
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      task: ffff8801d0b68580 task.stack: ffff8801ac6b8000
      RIP: 0010:__skb_pull include/linux/skbuff.h:2064 [inline]
      RIP: 0010:__ip6_make_skb+0x18cf/0x1f70 net/ipv6/ip6_output.c:1617
      RSP: 0018:ffff8801ac6bf570 EFLAGS: 00010216
      RAX: 0000000000010000 RBX: 0000000000000028 RCX: ffffc90003cce000
      RDX: 00000000000001b8 RSI: ffffffff839df06f RDI: ffff8801d9478ca0
      RBP: ffff8801ac6bf780 R08: ffff8801cc3f1dbc R09: 0000000000000000
      R10: ffff8801ac6bf7a0 R11: 43cb4b7b1948a9e7 R12: ffff8801cc3f1dc8
      R13: ffff8801cc3f1d40 R14: 0000000000001036 R15: dffffc0000000000
      FS:  00007f43d740c700(0000) GS:ffff8801dc100000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f7834984000 CR3: 00000001d79b9000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       ip6_finish_skb include/net/ipv6.h:911 [inline]
       udp_v6_push_pending_frames+0x255/0x390 net/ipv6/udp.c:1093
       udpv6_sendmsg+0x280d/0x31a0 net/ipv6/udp.c:1363
       inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:762
       sock_sendmsg_nosec net/socket.c:633 [inline]
       sock_sendmsg+0xca/0x110 net/socket.c:643
       SYSC_sendto+0x352/0x5a0 net/socket.c:1750
       SyS_sendto+0x40/0x50 net/socket.c:1718
       entry_SYSCALL_64_fastpath+0x1f/0xbe
      RIP: 0033:0x4512e9
      RSP: 002b:00007f43d740bc08 EFLAGS: 00000216 ORIG_RAX: 000000000000002c
      RAX: ffffffffffffffda RBX: 00000000007180a8 RCX: 00000000004512e9
      RDX: 000000000000002e RSI: 0000000020d08000 RDI: 0000000000000005
      RBP: 0000000000000086 R08: 00000000209c1000 R09: 000000000000001c
      R10: 0000000000040800 R11: 0000000000000216 R12: 00000000004b9c69
      R13: 00000000ffffffff R14: 0000000000000005 R15: 00000000202c2000
      Code: 9e 01 fe e9 c5 e8 ff ff e8 7f 9e 01 fe e9 4a ea ff ff 48 89 f7 e8 52 9e 01 fe e9 aa eb ff ff e8 a8 b6 cf fd 0f 0b e8 a1 b6 cf fd <0f> 0b 49 8d 45 78 4d 8d 45 7c 48 89 85 78 fe ff ff 49 8d 85 ba
      RIP: __skb_pull include/linux/skbuff.h:2064 [inline] RSP: ffff8801ac6bf570
      RIP: __ip6_make_skb+0x18cf/0x1f70 net/ipv6/ip6_output.c:1617 RSP: ffff8801ac6bf570
      
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Bug: 65023306
      Signed-off-by: default avatarMike Maloney <maloney@google.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Change-Id: If7663cd538ca686c8a7874181b45bdb48630f538
      fe0ec339
    • Eric Biggers's avatar
      ASN.1: fix out-of-bounds read when parsing indefinite length item · 7bd28b66
      Eric Biggers authored
      
      commit e0058f3a upstream.
      
      In asn1_ber_decoder(), indefinitely-sized ASN.1 items were being passed
      to the action functions before their lengths had been computed, using
      the bogus length of 0x80 (ASN1_INDEFINITE_LENGTH).  This resulted in
      reading data past the end of the input buffer, when given a specially
      crafted message.
      
      Fix it by rearranging the code so that the indefinite length is resolved
      before the action is called.
      
      This bug was originally found by fuzzing the X.509 parser in userspace
      using libFuzzer from the LLVM project.
      
      KASAN report (cleaned up slightly):
      
          BUG: KASAN: slab-out-of-bounds in memcpy ./include/linux/string.h:341 [inline]
          BUG: KASAN: slab-out-of-bounds in x509_fabricate_name.constprop.1+0x1a4/0x940 crypto/asymmetric_keys/x509_cert_parser.c:366
          Read of size 128 at addr ffff880035dd9eaf by task keyctl/195
      
          CPU: 1 PID: 195 Comm: keyctl Not tainted 4.14.0-09238-g1d3b78bbc6e9 #26
          Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
          Call Trace:
           __dump_stack lib/dump_stack.c:17 [inline]
           dump_stack+0xd1/0x175 lib/dump_stack.c:53
           print_address_description+0x78/0x260 mm/kasan/report.c:252
           kasan_report_error mm/kasan/report.c:351 [inline]
           kasan_report+0x23f/0x350 mm/kasan/report.c:409
           memcpy+0x1f/0x50 mm/kasan/kasan.c:302
           memcpy ./include/linux/string.h:341 [inline]
           x509_fabricate_name.constprop.1+0x1a4/0x940 crypto/asymmetric_keys/x509_cert_parser.c:366
           asn1_ber_decoder+0xb4a/0x1fd0 lib/asn1_decoder.c:447
           x509_cert_parse+0x1c7/0x620 crypto/asymmetric_keys/x509_cert_parser.c:89
           x509_key_preparse+0x61/0x750 crypto/asymmetric_keys/x509_public_key.c:174
           asymmetric_key_preparse+0xa4/0x150 crypto/asymmetric_keys/asymmetric_type.c:388
           key_create_or_update+0x4d4/0x10a0 security/keys/key.c:850
           SYSC_add_key security/keys/keyctl.c:122 [inline]
           SyS_add_key+0xe8/0x290 security/keys/keyctl.c:62
           entry_SYSCALL_64_fastpath+0x1f/0x96
      
          Allocated by task 195:
           __do_kmalloc_node mm/slab.c:3675 [inline]
           __kmalloc_node+0x47/0x60 mm/slab.c:3682
           kvmalloc ./include/linux/mm.h:540 [inline]
           SYSC_add_key security/keys/keyctl.c:104 [inline]
           SyS_add_key+0x19e/0x290 security/keys/keyctl.c:62
           entry_SYSCALL_64_fastpath+0x1f/0x96
      
      Fixes: 42d5ec27 ("X.509: Add an ASN.1 decoder")
      Reported-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: <stable@vger.kernel.org> # v3.7+
      Bug: 73827422
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Change-Id: Ie5738889d965b8e45cf193ee6d098bab964d9675
      7bd28b66
Loading