instruction
stringclasses
1 value
input
stringlengths
56
241k
output
int64
0
1
__index_level_0__
int64
0
175k
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ~IncrementalMarkingScope() { EXPECT_TRUE(marking_worklist_->IsGlobalEmpty()); EXPECT_TRUE(not_fully_constructed_worklist_->IsGlobalEmpty()); thread_state_->DisableIncrementalMarkingBarrier(); heap_.GetWeakCallbackWorklist()->Clear(); thread_state_->SetGCPhase(ThreadState::GCPhase::kSweeping); thread_state_->SetGCPhase(ThreadState::GCPhase::kNone); } Commit Message: [oilpan] Fix GCInfoTable for multiple threads Previously, grow and access from different threads could lead to a race on the table backing; see bug. - Rework the table to work on an existing reservation. - Commit upon growing, avoiding any copies. Drive-by: Fix over-allocation of table. Bug: chromium:841280 Change-Id: I329cb6f40091e14e8c05334ba1104a9440c31d43 Reviewed-on: https://chromium-review.googlesource.com/1061525 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Cr-Commit-Position: refs/heads/master@{#560434} CWE ID: CWE-362
0
153,823
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: pdf14_push_transparency_group(pdf14_ctx *ctx, gs_int_rect *rect, bool isolated, bool knockout, byte alpha, byte shape, gs_blend_mode_t blend_mode, bool idle, uint mask_id, int numcomps, bool cm_back_drop, cmm_profile_t *group_profile, cmm_profile_t *tos_profile, gs_gstate *pgs, gx_device *dev) { pdf14_buf *tos = ctx->stack; pdf14_buf *buf, *backdrop; bool has_shape, has_tags; if_debug1m('v', ctx->memory, "[v]pdf14_push_transparency_group, idle = %d\n", idle); /* We are going to use the shape in the knockout computation. If previous buffer has a shape or if this is a knockout then we will have a shape here */ has_shape = tos->has_shape || tos->knockout; /* If previous buffer has tags, then add tags here */ has_tags = tos->has_tags; /* If the group is NOT isolated we add in the alpha_g plane. This enables recompositing to be performed ala art_pdf_recomposite_group_8 so that the backdrop is only included one time in the computation. */ /* Order of buffer data is color data, followed by alpha channel, followed by shape (if present), then alpha_g (if present), then tags (if present) */ buf = pdf14_buf_new(rect, has_tags, !isolated, has_shape, idle, numcomps + 1, tos->num_spots, ctx->memory); if (buf == NULL) return_error(gs_error_VMerror); if_debug4m('v', ctx->memory, "[v]base buf: %d x %d, %d color channels, %d planes\n", buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes); buf->isolated = isolated; buf->knockout = knockout; buf->alpha = alpha; buf->shape = shape; buf->blend_mode = blend_mode; buf->mask_id = mask_id; buf->mask_stack = ctx->mask_stack; /* Save because the group rendering may set up another (nested) mask. */ ctx->mask_stack = NULL; /* Clean the mask field for rendering this group. See pdf14_pop_transparency_group how to handle it. */ buf->saved = tos; ctx->stack = buf; if (buf->data == NULL) return 0; if (idle) return 0; backdrop = pdf14_find_backdrop_buf(ctx); if (backdrop == NULL) { /* Note, don't clear out tags set by pdf14_buf_new == GS_UNKNOWN_TAG */ memset(buf->data, 0, buf->planestride * (buf->n_chan + (buf->has_shape ? 1 : 0) + (buf->has_alpha_g ? 1 : 0))); } else { if (!buf->knockout) { if (!cm_back_drop) { pdf14_preserve_backdrop(buf, tos, false); } else { /* We must have an non-isolated group with a mismatch in color spaces. In this case, we can't just copy the buffer but must CM it */ pdf14_preserve_backdrop_cm(buf, group_profile, tos, tos_profile, ctx->memory, pgs, dev, false); } } } /* If knockout, we have to maintain a copy of the backdrop in case we are drawing nonisolated groups on top of the knockout group. */ if (buf->knockout) { buf->backdrop = gs_alloc_bytes(ctx->memory, buf->planestride * buf->n_chan, "pdf14_push_transparency_group"); if (buf->backdrop == NULL) { return gs_throw(gs_error_VMerror, "Knockout backdrop allocation failed"); } if (buf->isolated) { /* We will have opaque backdrop for non-isolated compositing */ memset(buf->backdrop, 0, buf->planestride * buf->n_chan); } else { /* Save knockout backdrop for non-isolated compositing */ /* Note that we need to drill down through the non-isolated groups in our stack and make sure that we are not embedded in another knockout group */ pdf14_buf *check = tos; pdf14_buf *child = NULL; /* Needed so we can get profile */ cmm_profile_t *prev_knockout_profile; while (check != NULL) { if (check->isolated) break; if (check->knockout) { break; } child = check; check = check->saved; } /* Here we need to grab a back drop from a knockout parent group and potentially worry about color differences. */ if (check == NULL) { prev_knockout_profile = tos_profile; check = tos; } else { if (child == NULL) { prev_knockout_profile = tos_profile; } else { prev_knockout_profile = child->parent_color_info_procs->icc_profile; } } if (!cm_back_drop) { pdf14_preserve_backdrop(buf, check, false); } else { /* We must have an non-isolated group with a mismatch in color spaces. In this case, we can't just copy the buffer but must CM it */ pdf14_preserve_backdrop_cm(buf, group_profile, check, prev_knockout_profile, ctx->memory, pgs, dev, false); } memcpy(buf->backdrop, buf->data, buf->planestride * buf->n_chan); } #if RAW_DUMP /* Dump the current buffer to see what we have. */ dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y, ctx->stack->rowstride, buf->n_chan, ctx->stack->planestride, ctx->stack->rowstride, "KnockoutBackDrop", buf->backdrop); global_index++; #endif } else { buf->backdrop = NULL; } #if RAW_DUMP /* Dump the current buffer to see what we have. */ dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y, ctx->stack->rowstride, ctx->stack->n_planes, ctx->stack->planestride, ctx->stack->rowstride, "TransGroupPush", ctx->stack->data); global_index++; #endif return 0; } Commit Message: CWE ID: CWE-416
0
2,969
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: streamCG *streamCreateCG(stream *s, char *name, size_t namelen, streamID *id) { if (s->cgroups == NULL) s->cgroups = raxNew(); if (raxFind(s->cgroups,(unsigned char*)name,namelen) != raxNotFound) return NULL; streamCG *cg = zmalloc(sizeof(*cg)); cg->pel = raxNew(); cg->consumers = raxNew(); cg->last_id = *id; raxInsert(s->cgroups,(unsigned char*)name,namelen,cg,NULL); return cg; } Commit Message: Abort in XGROUP if the key is not a stream CWE ID: CWE-704
0
81,786
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) { /* Check chunk_name and return "keep" value if it's on the list, else 0 */ int i; png_bytep p; if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) return 0; p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5; for (i = png_ptr->num_chunk_list; i; i--, p -= 5) if (!png_memcmp(chunk_name, p, 4)) return ((int)*(p + 4)); return 0; } Commit Message: third_party/libpng: update to 1.2.54 TBR=darin@chromium.org BUG=560291 Review URL: https://codereview.chromium.org/1467263003 Cr-Commit-Position: refs/heads/master@{#362298} CWE ID: CWE-119
0
131,258
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) { struct console_font_op cfo = { .op = KD_FONT_OP_GET, .width = UINT_MAX, .height = UINT_MAX, .charcount = UINT_MAX, }; struct unimapinit adv = {}; struct unimapdesc unimapd; _cleanup_free_ struct unipair* unipairs = NULL; _cleanup_free_ void *fontbuf = NULL; unsigned i; int r; unipairs = new(struct unipair, USHRT_MAX); if (!unipairs) { log_oom(); return; } /* get metadata of the current font (width, height, count) */ r = ioctl(src_fd, KDFONTOP, &cfo); if (r < 0) log_warning_errno(errno, "KD_FONT_OP_GET failed while trying to get the font metadata: %m"); else { /* verify parameter sanity first */ if (cfo.width > 32 || cfo.height > 32 || cfo.charcount > 512) log_warning("Invalid font metadata - width: %u (max 32), height: %u (max 32), count: %u (max 512)", cfo.width, cfo.height, cfo.charcount); else { /* * Console fonts supported by the kernel are limited in size to 32 x 32 and maximum 512 * characters. Thus with 1 bit per pixel it requires up to 65536 bytes. The height always * requires 32 per glyph, regardless of the actual height - see the comment above #define * max_font_size 65536 in drivers/tty/vt/vt.c for more details. */ fontbuf = malloc_multiply((cfo.width + 7) / 8 * 32, cfo.charcount); if (!fontbuf) { log_oom(); return; } /* get fonts from the source console */ cfo.data = fontbuf; r = ioctl(src_fd, KDFONTOP, &cfo); if (r < 0) log_warning_errno(errno, "KD_FONT_OP_GET failed while trying to read the font data: %m"); else { unimapd.entries = unipairs; unimapd.entry_ct = USHRT_MAX; r = ioctl(src_fd, GIO_UNIMAP, &unimapd); if (r < 0) log_warning_errno(errno, "GIO_UNIMAP failed while trying to read unicode mappings: %m"); else cfo.op = KD_FONT_OP_SET; } } } if (cfo.op != KD_FONT_OP_SET) log_warning("Fonts will not be copied to remaining consoles"); for (i = 1; i <= 63; i++) { char ttyname[sizeof("/dev/tty63")]; _cleanup_close_ int fd_d = -1; if (i == src_idx || verify_vc_allocation(i) < 0) continue; /* try to open terminal */ xsprintf(ttyname, "/dev/tty%u", i); fd_d = open_terminal(ttyname, O_RDWR|O_CLOEXEC|O_NOCTTY); if (fd_d < 0) { log_warning_errno(fd_d, "Unable to open tty%u, fonts will not be copied: %m", i); continue; } if (verify_vc_kbmode(fd_d) < 0) continue; toggle_utf8(ttyname, fd_d, utf8); if (cfo.op != KD_FONT_OP_SET) continue; r = ioctl(fd_d, KDFONTOP, &cfo); if (r < 0) { int last_errno, mode; /* The fonts couldn't have been copied. It might be due to the * terminal being in graphical mode. In this case the kernel * returns -EINVAL which is too generic for distinguishing this * specific case. So we need to retrieve the terminal mode and if * the graphical mode is in used, let's assume that something else * is using the terminal and the failure was expected as we * shouldn't have tried to copy the fonts. */ last_errno = errno; if (ioctl(fd_d, KDGETMODE, &mode) >= 0 && mode != KD_TEXT) log_debug("KD_FONT_OP_SET skipped: tty%u is not in text mode", i); else log_warning_errno(last_errno, "KD_FONT_OP_SET failed, fonts will not be copied to tty%u: %m", i); continue; } /* * copy unicode translation table unimapd is a ushort count and a pointer * to an array of struct unipair { ushort, ushort } */ r = ioctl(fd_d, PIO_UNIMAPCLR, &adv); if (r < 0) { log_warning_errno(errno, "PIO_UNIMAPCLR failed, unimaps might be incorrect for tty%u: %m", i); continue; } r = ioctl(fd_d, PIO_UNIMAP, &unimapd); if (r < 0) { log_warning_errno(errno, "PIO_UNIMAP failed, unimaps might be incorrect for tty%u: %m", i); continue; } log_debug("Font and unimap successfully copied to %s", ttyname); } } Commit Message: Merge pull request #12378 from rbalint/vt-kbd-reset-check VT kbd reset check CWE ID: CWE-255
1
169,778
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void btrfs_clear_bit_hook(struct inode *inode, struct extent_state *state, unsigned *bits) { u64 len = state->end + 1 - state->start; u64 num_extents = div64_u64(len + BTRFS_MAX_EXTENT_SIZE -1, BTRFS_MAX_EXTENT_SIZE); spin_lock(&BTRFS_I(inode)->lock); if ((state->state & EXTENT_DEFRAG) && (*bits & EXTENT_DEFRAG)) BTRFS_I(inode)->defrag_bytes -= len; spin_unlock(&BTRFS_I(inode)->lock); /* * set_bit and clear bit hooks normally require _irqsave/restore * but in this case, we are only testing for the DELALLOC * bit, which is only set or cleared with irqs on */ if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { struct btrfs_root *root = BTRFS_I(inode)->root; bool do_list = !btrfs_is_free_space_inode(inode); if (*bits & EXTENT_FIRST_DELALLOC) { *bits &= ~EXTENT_FIRST_DELALLOC; } else if (!(*bits & EXTENT_DO_ACCOUNTING)) { spin_lock(&BTRFS_I(inode)->lock); BTRFS_I(inode)->outstanding_extents -= num_extents; spin_unlock(&BTRFS_I(inode)->lock); } /* * We don't reserve metadata space for space cache inodes so we * don't need to call dellalloc_release_metadata if there is an * error. */ if (*bits & EXTENT_DO_ACCOUNTING && root != root->fs_info->tree_root) btrfs_delalloc_release_metadata(inode, len); /* For sanity tests. */ if (btrfs_test_is_dummy_root(root)) return; if (root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID && do_list && !(state->state & EXTENT_NORESERVE)) btrfs_free_reserved_data_space(inode, len); __percpu_counter_add(&root->fs_info->delalloc_bytes, -len, root->fs_info->delalloc_batch); spin_lock(&BTRFS_I(inode)->lock); BTRFS_I(inode)->delalloc_bytes -= len; if (do_list && BTRFS_I(inode)->delalloc_bytes == 0 && test_bit(BTRFS_INODE_IN_DELALLOC_LIST, &BTRFS_I(inode)->runtime_flags)) btrfs_del_delalloc_inode(root, inode); spin_unlock(&BTRFS_I(inode)->lock); } } Commit Message: Btrfs: fix truncation of compressed and inlined extents When truncating a file to a smaller size which consists of an inline extent that is compressed, we did not discard (or made unusable) the data between the new file size and the old file size, wasting metadata space and allowing for the truncated data to be leaked and the data corruption/loss mentioned below. We were also not correctly decrementing the number of bytes used by the inode, we were setting it to zero, giving a wrong report for callers of the stat(2) syscall. The fsck tool also reported an error about a mismatch between the nbytes of the file versus the real space used by the file. Now because we weren't discarding the truncated region of the file, it was possible for a caller of the clone ioctl to actually read the data that was truncated, allowing for a security breach without requiring root access to the system, using only standard filesystem operations. The scenario is the following: 1) User A creates a file which consists of an inline and compressed extent with a size of 2000 bytes - the file is not accessible to any other users (no read, write or execution permission for anyone else); 2) The user truncates the file to a size of 1000 bytes; 3) User A makes the file world readable; 4) User B creates a file consisting of an inline extent of 2000 bytes; 5) User B issues a clone operation from user A's file into its own file (using a length argument of 0, clone the whole range); 6) User B now gets to see the 1000 bytes that user A truncated from its file before it made its file world readbale. User B also lost the bytes in the range [1000, 2000[ bytes from its own file, but that might be ok if his/her intention was reading stale data from user A that was never supposed to be public. Note that this contrasts with the case where we truncate a file from 2000 bytes to 1000 bytes and then truncate it back from 1000 to 2000 bytes. In this case reading any byte from the range [1000, 2000[ will return a value of 0x00, instead of the original data. This problem exists since the clone ioctl was added and happens both with and without my recent data loss and file corruption fixes for the clone ioctl (patch "Btrfs: fix file corruption and data loss after cloning inline extents"). So fix this by truncating the compressed inline extents as we do for the non-compressed case, which involves decompressing, if the data isn't already in the page cache, compressing the truncated version of the extent, writing the compressed content into the inline extent and then truncate it. The following test case for fstests reproduces the problem. In order for the test to pass both this fix and my previous fix for the clone ioctl that forbids cloning a smaller inline extent into a larger one, which is titled "Btrfs: fix file corruption and data loss after cloning inline extents", are needed. Without that other fix the test fails in a different way that does not leak the truncated data, instead part of destination file gets replaced with zeroes (because the destination file has a larger inline extent than the source). seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" tmp=/tmp/$$ status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { rm -f $tmp.* } # get standard environment, filters and checks . ./common/rc . ./common/filter # real QA test starts here _need_to_be_root _supported_fs btrfs _supported_os Linux _require_scratch _require_cloner rm -f $seqres.full _scratch_mkfs >>$seqres.full 2>&1 _scratch_mount "-o compress" # Create our test files. File foo is going to be the source of a clone operation # and consists of a single inline extent with an uncompressed size of 512 bytes, # while file bar consists of a single inline extent with an uncompressed size of # 256 bytes. For our test's purpose, it's important that file bar has an inline # extent with a size smaller than foo's inline extent. $XFS_IO_PROG -f -c "pwrite -S 0xa1 0 128" \ -c "pwrite -S 0x2a 128 384" \ $SCRATCH_MNT/foo | _filter_xfs_io $XFS_IO_PROG -f -c "pwrite -S 0xbb 0 256" $SCRATCH_MNT/bar | _filter_xfs_io # Now durably persist all metadata and data. We do this to make sure that we get # on disk an inline extent with a size of 512 bytes for file foo. sync # Now truncate our file foo to a smaller size. Because it consists of a # compressed and inline extent, btrfs did not shrink the inline extent to the # new size (if the extent was not compressed, btrfs would shrink it to 128 # bytes), it only updates the inode's i_size to 128 bytes. $XFS_IO_PROG -c "truncate 128" $SCRATCH_MNT/foo # Now clone foo's inline extent into bar. # This clone operation should fail with errno EOPNOTSUPP because the source # file consists only of an inline extent and the file's size is smaller than # the inline extent of the destination (128 bytes < 256 bytes). However the # clone ioctl was not prepared to deal with a file that has a size smaller # than the size of its inline extent (something that happens only for compressed # inline extents), resulting in copying the full inline extent from the source # file into the destination file. # # Note that btrfs' clone operation for inline extents consists of removing the # inline extent from the destination inode and copy the inline extent from the # source inode into the destination inode, meaning that if the destination # inode's inline extent is larger (N bytes) than the source inode's inline # extent (M bytes), some bytes (N - M bytes) will be lost from the destination # file. Btrfs could copy the source inline extent's data into the destination's # inline extent so that we would not lose any data, but that's currently not # done due to the complexity that would be needed to deal with such cases # (specially when one or both extents are compressed), returning EOPNOTSUPP, as # it's normally not a very common case to clone very small files (only case # where we get inline extents) and copying inline extents does not save any # space (unlike for normal, non-inlined extents). $CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/foo $SCRATCH_MNT/bar # Now because the above clone operation used to succeed, and due to foo's inline # extent not being shinked by the truncate operation, our file bar got the whole # inline extent copied from foo, making us lose the last 128 bytes from bar # which got replaced by the bytes in range [128, 256[ from foo before foo was # truncated - in other words, data loss from bar and being able to read old and # stale data from foo that should not be possible to read anymore through normal # filesystem operations. Contrast with the case where we truncate a file from a # size N to a smaller size M, truncate it back to size N and then read the range # [M, N[, we should always get the value 0x00 for all the bytes in that range. # We expected the clone operation to fail with errno EOPNOTSUPP and therefore # not modify our file's bar data/metadata. So its content should be 256 bytes # long with all bytes having the value 0xbb. # # Without the btrfs bug fix, the clone operation succeeded and resulted in # leaking truncated data from foo, the bytes that belonged to its range # [128, 256[, and losing data from bar in that same range. So reading the # file gave us the following content: # # 0000000 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 # * # 0000200 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a # * # 0000400 echo "File bar's content after the clone operation:" od -t x1 $SCRATCH_MNT/bar # Also because the foo's inline extent was not shrunk by the truncate # operation, btrfs' fsck, which is run by the fstests framework everytime a # test completes, failed reporting the following error: # # root 5 inode 257 errors 400, nbytes wrong status=0 exit Cc: stable@vger.kernel.org Signed-off-by: Filipe Manana <fdmanana@suse.com> CWE ID: CWE-200
0
41,620
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int bt_seq_show(struct seq_file *seq, void *v) { struct bt_seq_state *s = seq->private; struct bt_sock_list *l = s->l; if (v == SEQ_START_TOKEN) { seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); if (l->custom_seq_show) { seq_putc(seq, ' '); l->custom_seq_show(seq, v); } seq_putc(seq, '\n'); } else { struct sock *sk = sk_entry(v); struct bt_sock *bt = bt_sk(sk); seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pMR %pMR %-6lu", sk, atomic_read(&sk->sk_refcnt), sk_rmem_alloc_get(sk), sk_wmem_alloc_get(sk), from_kuid(seq_user_ns(seq), sock_i_uid(sk)), sock_i_ino(sk), &bt->src, &bt->dst, bt->parent? sock_i_ino(bt->parent): 0LU); if (l->custom_seq_show) { seq_putc(seq, ' '); l->custom_seq_show(seq, v); } seq_putc(seq, '\n'); } return 0; } Commit Message: Bluetooth: fix possible info leak in bt_sock_recvmsg() In case the socket is already shutting down, bt_sock_recvmsg() returns with 0 without updating msg_namelen leading to net/socket.c leaking the local, uninitialized sockaddr_storage variable to userland -- 128 bytes of kernel stack memory. Fix this by moving the msg_namelen assignment in front of the shutdown test. Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Gustavo Padovan <gustavo@padovan.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-200
0
30,760
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: DECLAREcpFunc(cpContig2ContigByRow) { tsize_t scanlinesize = TIFFScanlineSize(in); tdata_t buf; uint32 row; buf = _TIFFmalloc(scanlinesize); if (!buf) return 0; _TIFFmemset(buf, 0, scanlinesize); (void) imagewidth; (void) spp; for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), "Error, can't read scanline %lu", (unsigned long) row); goto bad; } if (TIFFWriteScanline(out, buf, row, 0) < 0) { TIFFError(TIFFFileName(out), "Error, can't write scanline %lu", (unsigned long) row); goto bad; } } _TIFFfree(buf); return 1; bad: _TIFFfree(buf); return 0; } Commit Message: * tools/tiffcp.c: fix out-of-bounds write on tiled images with odd tile width vs image width. Reported as MSVR 35103 by Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & Mitigations team. CWE ID: CWE-787
0
48,185
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: GF_Err pitm_dump(GF_Box *a, FILE * trace) { GF_PrimaryItemBox *p = (GF_PrimaryItemBox *)a; gf_isom_box_dump_start(a, "PrimaryItemBox", trace); fprintf(trace, "item_ID=\"%d\">\n", p->item_ID); gf_isom_box_dump_done("PrimaryItemBox", a, trace); return GF_OK; } Commit Message: fixed 2 possible heap overflows (inc. #1088) CWE ID: CWE-125
0
80,821
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: megasas_set_nvme_device_properties(struct scsi_device *sdev, u32 max_io_size) { struct megasas_instance *instance; u32 mr_nvme_pg_size; instance = (struct megasas_instance *)sdev->host->hostdata; mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, MR_DEFAULT_NVME_PAGE_SIZE); blk_queue_max_hw_sectors(sdev->request_queue, (max_io_size / 512)); blk_queue_flag_set(QUEUE_FLAG_NOMERGES, sdev->request_queue); blk_queue_virt_boundary(sdev->request_queue, mr_nvme_pg_size - 1); } Commit Message: scsi: megaraid_sas: return error when create DMA pool failed when create DMA pool for cmd frames failed, we should return -ENOMEM, instead of 0. In some case in: megasas_init_adapter_fusion() -->megasas_alloc_cmds() -->megasas_create_frame_pool create DMA pool failed, --> megasas_free_cmds() [1] -->megasas_alloc_cmds_fusion() failed, then goto fail_alloc_cmds. -->megasas_free_cmds() [2] we will call megasas_free_cmds twice, [1] will kfree cmd_list, [2] will use cmd_list.it will cause a problem: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = ffffffc000f70000 [00000000] *pgd=0000001fbf893003, *pud=0000001fbf893003, *pmd=0000001fbf894003, *pte=006000006d000707 Internal error: Oops: 96000005 [#1] SMP Modules linked in: CPU: 18 PID: 1 Comm: swapper/0 Not tainted task: ffffffdfb9290000 ti: ffffffdfb923c000 task.ti: ffffffdfb923c000 PC is at megasas_free_cmds+0x30/0x70 LR is at megasas_free_cmds+0x24/0x70 ... Call trace: [<ffffffc0005b779c>] megasas_free_cmds+0x30/0x70 [<ffffffc0005bca74>] megasas_init_adapter_fusion+0x2f4/0x4d8 [<ffffffc0005b926c>] megasas_init_fw+0x2dc/0x760 [<ffffffc0005b9ab0>] megasas_probe_one+0x3c0/0xcd8 [<ffffffc0004a5abc>] local_pci_probe+0x4c/0xb4 [<ffffffc0004a5c40>] pci_device_probe+0x11c/0x14c [<ffffffc00053a5e4>] driver_probe_device+0x1ec/0x430 [<ffffffc00053a92c>] __driver_attach+0xa8/0xb0 [<ffffffc000538178>] bus_for_each_dev+0x74/0xc8 [<ffffffc000539e88>] driver_attach+0x28/0x34 [<ffffffc000539a18>] bus_add_driver+0x16c/0x248 [<ffffffc00053b234>] driver_register+0x6c/0x138 [<ffffffc0004a5350>] __pci_register_driver+0x5c/0x6c [<ffffffc000ce3868>] megasas_init+0xc0/0x1a8 [<ffffffc000082a58>] do_one_initcall+0xe8/0x1ec [<ffffffc000ca7be8>] kernel_init_freeable+0x1c8/0x284 [<ffffffc0008d90b8>] kernel_init+0x1c/0xe4 Signed-off-by: Jason Yan <yanaijie@huawei.com> Acked-by: Sumit Saxena <sumit.saxena@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> CWE ID: CWE-476
0
90,410
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int build_segment_manager(struct f2fs_sb_info *sbi) { struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); struct f2fs_sm_info *sm_info; int err; sm_info = kzalloc(sizeof(struct f2fs_sm_info), GFP_KERNEL); if (!sm_info) return -ENOMEM; /* init sm info */ sbi->sm_info = sm_info; sm_info->seg0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr); sm_info->main_blkaddr = le32_to_cpu(raw_super->main_blkaddr); sm_info->segment_count = le32_to_cpu(raw_super->segment_count); sm_info->reserved_segments = le32_to_cpu(ckpt->rsvd_segment_count); sm_info->ovp_segments = le32_to_cpu(ckpt->overprov_segment_count); sm_info->main_segments = le32_to_cpu(raw_super->segment_count_main); sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr); sm_info->rec_prefree_segments = sm_info->main_segments * DEF_RECLAIM_PREFREE_SEGMENTS / 100; if (sm_info->rec_prefree_segments > DEF_MAX_RECLAIM_PREFREE_SEGMENTS) sm_info->rec_prefree_segments = DEF_MAX_RECLAIM_PREFREE_SEGMENTS; if (!test_opt(sbi, LFS)) sm_info->ipu_policy = 1 << F2FS_IPU_FSYNC; sm_info->min_ipu_util = DEF_MIN_IPU_UTIL; sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS; sm_info->min_hot_blocks = DEF_MIN_HOT_BLOCKS; sm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS; INIT_LIST_HEAD(&sm_info->sit_entry_set); if (test_opt(sbi, FLUSH_MERGE) && !f2fs_readonly(sbi->sb)) { err = create_flush_cmd_control(sbi); if (err) return err; } err = create_discard_cmd_control(sbi); if (err) return err; err = build_sit_info(sbi); if (err) return err; err = build_free_segmap(sbi); if (err) return err; err = build_curseg(sbi); if (err) return err; /* reinit free segmap based on SIT */ build_sit_entries(sbi); init_free_segmap(sbi); err = build_dirty_segmap(sbi); if (err) return err; init_min_max_mtime(sbi); return 0; } Commit Message: f2fs: fix a panic caused by NULL flush_cmd_control Mount fs with option noflush_merge, boot failed for illegal address fcc in function f2fs_issue_flush: if (!test_opt(sbi, FLUSH_MERGE)) { ret = submit_flush_wait(sbi); atomic_inc(&fcc->issued_flush); -> Here, fcc illegal return ret; } Signed-off-by: Yunlei He <heyunlei@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> CWE ID: CWE-476
1
169,381
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void GDataFileSystem::CheckLocalModificationAndRunAfterGetFileInfo( scoped_ptr<GDataEntryProto> entry_proto, const GetEntryInfoCallback& callback, base::PlatformFileInfo* file_info, bool* get_file_info_result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!*get_file_info_result) { if (!callback.is_null()) callback.Run(GDATA_FILE_ERROR_NOT_FOUND, scoped_ptr<GDataEntryProto>()); return; } PlatformFileInfoProto entry_file_info; GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); *entry_proto->mutable_file_info() = entry_file_info; if (!callback.is_null()) callback.Run(GDATA_FILE_OK, entry_proto.Pass()); } Commit Message: Remove parent* arg from GDataEntry ctor. * Remove static FromDocumentEntry from GDataEntry, GDataFile, GDataDirectory. Replace with InitFromDocumentEntry. * Move common code from GDataFile::InitFromDocumentEntry and GDataDirectory::InitFromDocumentEntry to GDataEntry::InitFromDocumentEntry. * Add GDataDirectoryService::FromDocumentEntry and use this everywhere. * Make ctors of GDataFile, GDataDirectory private, so these must be created by GDataDirectoryService's CreateGDataFile and CreateGDataDirectory. Make GDataEntry ctor protected. BUG=141494 TEST=unit tests. Review URL: https://chromiumcodereview.appspot.com/10854083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151008 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
116,925
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void stringMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); TestObjectPythonV8Internal::stringMethodMethod(info); TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); } Commit Message: document.location bindings fix BUG=352374 R=jochen@chromium.org Review URL: https://codereview.chromium.org/196343011 git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
122,685
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: PHP_FUNCTION(linkinfo) { char *link; size_t link_len; zend_stat_t sb; int ret; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) { return; } ret = VCWD_STAT(link, &sb); if (ret == -1) { php_error_docref(NULL, E_WARNING, "%s", strerror(errno)); RETURN_LONG(Z_L(-1)); } RETURN_LONG((zend_long) sb.st_dev); } Commit Message: Fixed bug #76459 windows linkinfo lacks openbasedir check CWE ID: CWE-200
1
169,107
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: get_stringbuf (struct stringbuf *sb) { char *p; if (sb->out_of_core) { xfree (sb->buf); sb->buf = NULL; return NULL; } sb->buf[sb->len] = 0; p = sb->buf; sb->buf = NULL; sb->out_of_core = 1; /* make sure the caller does an init before reuse */ return p; } Commit Message: CWE ID: CWE-119
0
11,014
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) { struct xdr_stream xdr; struct compound_hdr hdr; int status; xdr_init_decode(&xdr, &req->rq_rcv_buf, p); status = decode_compound_hdr(&xdr, &hdr); if (!status) status = decode_putfh(&xdr); if (!status) status = decode_fsinfo(&xdr, fsinfo); if (!status) status = nfs4_stat_to_errno(hdr.status); return status; } Commit Message: NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID:
0
23,102
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) { int command_id; if (!FindCommandIdForAccelerator(accelerator, &command_id)) return false; UpdateAcceleratorMetrics(accelerator, command_id); return chrome::ExecuteCommand(browser_.get(), command_id); } Commit Message: Mac: turn popups into new tabs while in fullscreen. It's platform convention to show popups as new tabs while in non-HTML5 fullscreen. (Popups cause tabs to lose HTML5 fullscreen.) This was implemented for Cocoa in a BrowserWindow override, but it makes sense to just stick it into Browser and remove a ton of override code put in just to support this. BUG=858929, 868416 TEST=as in bugs Change-Id: I43471f242813ec1159d9c690bab73dab3e610b7d Reviewed-on: https://chromium-review.googlesource.com/1153455 Reviewed-by: Sidney San Martín <sdy@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/master@{#578755} CWE ID: CWE-20
0
155,138
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: std::string StringPrintf(std::string str, int d) { char buf[30]; sprintf(buf, str.c_str(), d); return std::string(buf); } Commit Message: Test for error in handling getters changing element kind. Bug: 111274046 Test: m -j proxy_resolver_v8_unittest && adb sync && adb shell \ /data/nativetest64/proxy_resolver_v8_unittest/proxy_resolver_v8_unittest Merged-In: I99def991ebcb7c26ba7ca4b4b31ef1cdeaea7721 Change-Id: I99def991ebcb7c26ba7ca4b4b31ef1cdeaea7721 (cherry picked from commit 59b9b11a462fe3aad313b8538fb98468f22d9095) CWE ID: CWE-704
0
164,560
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static zend_object_value spl_heap_object_clone(zval *zobject TSRMLS_DC) /* {{{ */ { zend_object_value new_obj_val; zend_object *old_object; zend_object *new_object; zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); spl_heap_object *intern; old_object = zend_objects_get_address(zobject TSRMLS_CC); new_obj_val = spl_heap_object_new_ex(old_object->ce, &intern, zobject, 1 TSRMLS_CC); new_object = &intern->std; zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC); return new_obj_val; } /* }}} */ Commit Message: CWE ID:
0
14,901
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: TT_RunIns( TT_ExecContext exc ) { FT_ULong ins_counter = 0; /* executed instructions counter */ FT_ULong num_twilight_points; FT_UShort i; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY FT_Byte opcode_pattern[1][2] = { /* #8 TypeMan Talk Align */ { 0x06, /* SPVTL */ 0x7D, /* RDTG */ }, }; FT_UShort opcode_patterns = 1; FT_UShort opcode_pointer[1] = { 0 }; FT_UShort opcode_size[1] = { 1 }; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY exc->iup_called = FALSE; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* * Toggle backward compatibility according to what font wants, except * when * * 1) we have a `tricky' font that heavily relies on the interpreter to * render glyphs correctly, for example DFKai-SB, or * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested. * * In those cases, backward compatibility needs to be turned off to get * correct rendering. The rendering is then completely up to the * font's programming. * */ if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean && !FT_IS_TRICKY( &exc->face->root ) ) exc->backward_compatibility = !( exc->GS.instruct_control & 4 ); else exc->backward_compatibility = FALSE; exc->iupx_called = FALSE; exc->iupy_called = FALSE; #endif /* We restrict the number of twilight points to a reasonable, */ /* heuristic value to avoid slow execution of malformed bytecode. */ num_twilight_points = FT_MAX( 30, 2 * ( exc->pts.n_points + exc->cvtSize ) ); if ( exc->twilight.n_points > num_twilight_points ) { if ( num_twilight_points > 0xFFFFU ) num_twilight_points = 0xFFFFU; FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n" " from %d to the more reasonable value %d\n", exc->twilight.n_points, num_twilight_points )); exc->twilight.n_points = (FT_UShort)num_twilight_points; } /* Set up loop detectors. We restrict the number of LOOPCALL loops */ /* and the number of JMPR, JROT, and JROF calls with a negative */ /* argument to values that depend on various parameters like the */ /* size of the CVT table or the number of points in the current */ /* glyph (if applicable). */ /* */ /* The idea is that in real-world bytecode you either iterate over */ /* all CVT entries (in the `prep' table), or over all points (or */ /* contours, in the `glyf' table) of a glyph, and such iterations */ /* don't happen very often. */ exc->loopcall_counter = 0; exc->neg_jump_counter = 0; /* The maximum values are heuristic. */ if ( exc->pts.n_points ) exc->loopcall_counter_max = FT_MAX( 50, 10 * exc->pts.n_points ) + FT_MAX( 50, exc->cvtSize / 10 ); else exc->loopcall_counter_max = 300 + 8 * exc->cvtSize; /* as a protection against an unreasonable number of CVT entries */ /* we assume at most 100 control values per glyph for the counter */ if ( exc->loopcall_counter_max > 100 * (FT_ULong)exc->face->root.num_glyphs ) exc->loopcall_counter_max = 100 * (FT_ULong)exc->face->root.num_glyphs; FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL" " to %d\n", exc->loopcall_counter_max )); exc->neg_jump_counter_max = exc->loopcall_counter_max; FT_TRACE5(( "TT_RunIns: Limiting total number of backward jumps" " to %d\n", exc->neg_jump_counter_max )); /* set PPEM and CVT functions */ exc->tt_metrics.ratio = 0; if ( exc->metrics.x_ppem != exc->metrics.y_ppem ) { /* non-square pixels, use the stretched routines */ exc->func_cur_ppem = Current_Ppem_Stretched; exc->func_read_cvt = Read_CVT_Stretched; exc->func_write_cvt = Write_CVT_Stretched; exc->func_move_cvt = Move_CVT_Stretched; } else { /* square pixels, use normal routines */ exc->func_cur_ppem = Current_Ppem; exc->func_read_cvt = Read_CVT; exc->func_write_cvt = Write_CVT; exc->func_move_cvt = Move_CVT; } Compute_Funcs( exc ); Compute_Round( exc, (FT_Byte)exc->GS.round_state ); do { exc->opcode = exc->code[exc->IP]; #ifdef FT_DEBUG_LEVEL_TRACE { FT_Long cnt = FT_MIN( 8, exc->top ); FT_Long n; /* if tracing level is 7, show current code position */ /* and the first few stack elements also */ FT_TRACE6(( " " )); FT_TRACE7(( "%06d ", exc->IP )); FT_TRACE6(( opcode_name[exc->opcode] + 2 )); FT_TRACE7(( "%*s", *opcode_name[exc->opcode] == 'A' ? 2 : 12 - ( *opcode_name[exc->opcode] - '0' ), "#" )); for ( n = 1; n <= cnt; n++ ) FT_TRACE7(( " %d", exc->stack[exc->top - n] )); FT_TRACE6(( "\n" )); } #endif /* FT_DEBUG_LEVEL_TRACE */ if ( ( exc->length = opcode_length[exc->opcode] ) < 0 ) { if ( exc->IP + 1 >= exc->codeSize ) goto LErrorCodeOverflow_; exc->length = 2 - exc->length * exc->code[exc->IP + 1]; } if ( exc->IP + exc->length > exc->codeSize ) goto LErrorCodeOverflow_; /* First, let's check for empty stack and overflow */ exc->args = exc->top - ( Pop_Push_Count[exc->opcode] >> 4 ); /* `args' is the top of the stack once arguments have been popped. */ /* One can also interpret it as the index of the last argument. */ if ( exc->args < 0 ) { if ( exc->pedantic_hinting ) { exc->error = FT_THROW( Too_Few_Arguments ); goto LErrorLabel_; } /* push zeroes onto the stack */ for ( i = 0; i < Pop_Push_Count[exc->opcode] >> 4; i++ ) exc->stack[i] = 0; exc->args = 0; } #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT if ( exc->opcode == 0x91 ) { /* this is very special: GETVARIATION returns */ /* a variable number of arguments */ /* it is the job of the application to `activate' GX handling, */ /* this is, calling any of the GX API functions on the current */ /* font to select a variation instance */ if ( exc->face->blend ) exc->new_top = exc->args + exc->face->blend->num_axis; } else #endif exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 ); /* `new_top' is the new top of the stack, after the instruction's */ /* execution. `top' will be set to `new_top' after the `switch' */ /* statement. */ if ( exc->new_top > exc->stackSize ) { exc->error = FT_THROW( Stack_Overflow ); goto LErrorLabel_; } exc->step_ins = TRUE; exc->error = FT_Err_Ok; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { for ( i = 0; i < opcode_patterns; i++ ) { if ( opcode_pointer[i] < opcode_size[i] && exc->opcode == opcode_pattern[i][opcode_pointer[i]] ) { opcode_pointer[i] += 1; if ( opcode_pointer[i] == opcode_size[i] ) { FT_TRACE6(( "sph: opcode ptrn: %d, %s %s\n", i, exc->face->root.family_name, exc->face->root.style_name )); switch ( i ) { case 0: break; } opcode_pointer[i] = 0; } } else opcode_pointer[i] = 0; } } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ { FT_Long* args = exc->stack + exc->args; FT_Byte opcode = exc->opcode; switch ( opcode ) { case 0x00: /* SVTCA y */ case 0x01: /* SVTCA x */ case 0x02: /* SPvTCA y */ case 0x03: /* SPvTCA x */ case 0x04: /* SFvTCA y */ case 0x05: /* SFvTCA x */ Ins_SxyTCA( exc ); break; case 0x06: /* SPvTL // */ case 0x07: /* SPvTL + */ Ins_SPVTL( exc, args ); break; case 0x08: /* SFvTL // */ case 0x09: /* SFvTL + */ Ins_SFVTL( exc, args ); break; case 0x0A: /* SPvFS */ Ins_SPVFS( exc, args ); break; case 0x0B: /* SFvFS */ Ins_SFVFS( exc, args ); break; case 0x0C: /* GPv */ Ins_GPV( exc, args ); break; case 0x0D: /* GFv */ Ins_GFV( exc, args ); break; case 0x0E: /* SFvTPv */ Ins_SFVTPV( exc ); break; case 0x0F: /* ISECT */ Ins_ISECT( exc, args ); break; case 0x10: /* SRP0 */ Ins_SRP0( exc, args ); break; case 0x11: /* SRP1 */ Ins_SRP1( exc, args ); break; case 0x12: /* SRP2 */ Ins_SRP2( exc, args ); break; case 0x13: /* SZP0 */ Ins_SZP0( exc, args ); break; case 0x14: /* SZP1 */ Ins_SZP1( exc, args ); break; case 0x15: /* SZP2 */ Ins_SZP2( exc, args ); break; case 0x16: /* SZPS */ Ins_SZPS( exc, args ); break; case 0x17: /* SLOOP */ Ins_SLOOP( exc, args ); break; case 0x18: /* RTG */ Ins_RTG( exc ); break; case 0x19: /* RTHG */ Ins_RTHG( exc ); break; case 0x1A: /* SMD */ Ins_SMD( exc, args ); break; case 0x1B: /* ELSE */ Ins_ELSE( exc ); break; case 0x1C: /* JMPR */ Ins_JMPR( exc, args ); break; case 0x1D: /* SCVTCI */ Ins_SCVTCI( exc, args ); break; case 0x1E: /* SSWCI */ Ins_SSWCI( exc, args ); break; case 0x1F: /* SSW */ Ins_SSW( exc, args ); break; case 0x20: /* DUP */ Ins_DUP( args ); break; case 0x21: /* POP */ Ins_POP(); break; case 0x22: /* CLEAR */ Ins_CLEAR( exc ); break; case 0x23: /* SWAP */ Ins_SWAP( args ); break; case 0x24: /* DEPTH */ Ins_DEPTH( exc, args ); break; case 0x25: /* CINDEX */ Ins_CINDEX( exc, args ); break; case 0x26: /* MINDEX */ Ins_MINDEX( exc, args ); break; case 0x27: /* ALIGNPTS */ Ins_ALIGNPTS( exc, args ); break; case 0x28: /* RAW */ Ins_UNKNOWN( exc ); break; case 0x29: /* UTP */ Ins_UTP( exc, args ); break; case 0x2A: /* LOOPCALL */ Ins_LOOPCALL( exc, args ); break; case 0x2B: /* CALL */ Ins_CALL( exc, args ); break; case 0x2C: /* FDEF */ Ins_FDEF( exc, args ); break; case 0x2D: /* ENDF */ Ins_ENDF( exc ); break; case 0x2E: /* MDAP */ case 0x2F: /* MDAP */ Ins_MDAP( exc, args ); break; case 0x30: /* IUP */ case 0x31: /* IUP */ Ins_IUP( exc ); break; case 0x32: /* SHP */ case 0x33: /* SHP */ Ins_SHP( exc ); break; case 0x34: /* SHC */ case 0x35: /* SHC */ Ins_SHC( exc, args ); break; case 0x36: /* SHZ */ case 0x37: /* SHZ */ Ins_SHZ( exc, args ); break; case 0x38: /* SHPIX */ Ins_SHPIX( exc, args ); break; case 0x39: /* IP */ Ins_IP( exc ); break; case 0x3A: /* MSIRP */ case 0x3B: /* MSIRP */ Ins_MSIRP( exc, args ); break; case 0x3C: /* AlignRP */ Ins_ALIGNRP( exc ); break; case 0x3D: /* RTDG */ Ins_RTDG( exc ); break; case 0x3E: /* MIAP */ case 0x3F: /* MIAP */ Ins_MIAP( exc, args ); break; case 0x40: /* NPUSHB */ Ins_NPUSHB( exc, args ); break; case 0x41: /* NPUSHW */ Ins_NPUSHW( exc, args ); break; case 0x42: /* WS */ Ins_WS( exc, args ); break; case 0x43: /* RS */ Ins_RS( exc, args ); break; case 0x44: /* WCVTP */ Ins_WCVTP( exc, args ); break; case 0x45: /* RCVT */ Ins_RCVT( exc, args ); break; case 0x46: /* GC */ case 0x47: /* GC */ Ins_GC( exc, args ); break; case 0x48: /* SCFS */ Ins_SCFS( exc, args ); break; case 0x49: /* MD */ case 0x4A: /* MD */ Ins_MD( exc, args ); break; case 0x4B: /* MPPEM */ Ins_MPPEM( exc, args ); break; case 0x4C: /* MPS */ Ins_MPS( exc, args ); break; case 0x4D: /* FLIPON */ Ins_FLIPON( exc ); break; case 0x4E: /* FLIPOFF */ Ins_FLIPOFF( exc ); break; case 0x4F: /* DEBUG */ Ins_DEBUG( exc ); break; case 0x50: /* LT */ Ins_LT( args ); break; case 0x51: /* LTEQ */ Ins_LTEQ( args ); break; case 0x52: /* GT */ Ins_GT( args ); break; case 0x53: /* GTEQ */ Ins_GTEQ( args ); break; case 0x54: /* EQ */ Ins_EQ( args ); break; case 0x55: /* NEQ */ Ins_NEQ( args ); break; case 0x56: /* ODD */ Ins_ODD( exc, args ); break; case 0x57: /* EVEN */ Ins_EVEN( exc, args ); break; case 0x58: /* IF */ Ins_IF( exc, args ); break; case 0x59: /* EIF */ Ins_EIF(); break; case 0x5A: /* AND */ Ins_AND( args ); break; case 0x5B: /* OR */ Ins_OR( args ); break; case 0x5C: /* NOT */ Ins_NOT( args ); break; case 0x5D: /* DELTAP1 */ Ins_DELTAP( exc, args ); break; case 0x5E: /* SDB */ Ins_SDB( exc, args ); break; case 0x5F: /* SDS */ Ins_SDS( exc, args ); break; case 0x60: /* ADD */ Ins_ADD( args ); break; case 0x61: /* SUB */ Ins_SUB( args ); break; case 0x62: /* DIV */ Ins_DIV( exc, args ); break; case 0x63: /* MUL */ Ins_MUL( args ); break; case 0x64: /* ABS */ Ins_ABS( args ); break; case 0x65: /* NEG */ Ins_NEG( args ); break; case 0x66: /* FLOOR */ Ins_FLOOR( args ); break; case 0x67: /* CEILING */ Ins_CEILING( args ); break; case 0x68: /* ROUND */ case 0x69: /* ROUND */ case 0x6A: /* ROUND */ case 0x6B: /* ROUND */ Ins_ROUND( exc, args ); break; case 0x6C: /* NROUND */ case 0x6D: /* NROUND */ case 0x6E: /* NRRUND */ case 0x6F: /* NROUND */ Ins_NROUND( exc, args ); break; case 0x70: /* WCVTF */ Ins_WCVTF( exc, args ); break; case 0x71: /* DELTAP2 */ case 0x72: /* DELTAP3 */ Ins_DELTAP( exc, args ); break; case 0x73: /* DELTAC0 */ case 0x74: /* DELTAC1 */ case 0x75: /* DELTAC2 */ Ins_DELTAC( exc, args ); break; case 0x76: /* SROUND */ Ins_SROUND( exc, args ); break; case 0x77: /* S45Round */ Ins_S45ROUND( exc, args ); break; case 0x78: /* JROT */ Ins_JROT( exc, args ); break; case 0x79: /* JROF */ Ins_JROF( exc, args ); break; case 0x7A: /* ROFF */ Ins_ROFF( exc ); break; case 0x7B: /* ???? */ Ins_UNKNOWN( exc ); break; case 0x7C: /* RUTG */ Ins_RUTG( exc ); break; case 0x7D: /* RDTG */ Ins_RDTG( exc ); break; case 0x7E: /* SANGW */ Ins_SANGW(); break; case 0x7F: /* AA */ Ins_AA(); break; case 0x80: /* FLIPPT */ Ins_FLIPPT( exc ); break; case 0x81: /* FLIPRGON */ Ins_FLIPRGON( exc, args ); break; case 0x82: /* FLIPRGOFF */ Ins_FLIPRGOFF( exc, args ); break; case 0x83: /* UNKNOWN */ case 0x84: /* UNKNOWN */ Ins_UNKNOWN( exc ); break; case 0x85: /* SCANCTRL */ Ins_SCANCTRL( exc, args ); break; case 0x86: /* SDPvTL */ case 0x87: /* SDPvTL */ Ins_SDPVTL( exc, args ); break; case 0x88: /* GETINFO */ Ins_GETINFO( exc, args ); break; case 0x89: /* IDEF */ Ins_IDEF( exc, args ); break; case 0x8A: /* ROLL */ Ins_ROLL( args ); break; case 0x8B: /* MAX */ Ins_MAX( args ); break; case 0x8C: /* MIN */ Ins_MIN( args ); break; case 0x8D: /* SCANTYPE */ Ins_SCANTYPE( exc, args ); break; case 0x8E: /* INSTCTRL */ Ins_INSTCTRL( exc, args ); break; case 0x8F: /* ADJUST */ case 0x90: /* ADJUST */ Ins_UNKNOWN( exc ); break; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT case 0x91: /* it is the job of the application to `activate' GX handling, */ /* this is, calling any of the GX API functions on the current */ /* font to select a variation instance */ if ( exc->face->blend ) Ins_GETVARIATION( exc, args ); else Ins_UNKNOWN( exc ); break; case 0x92: /* there is at least one MS font (LaoUI.ttf version 5.01) that */ /* uses IDEFs for 0x91 and 0x92; for this reason we activate */ /* GETDATA for GX fonts only, similar to GETVARIATION */ if ( exc->face->blend ) Ins_GETDATA( args ); else Ins_UNKNOWN( exc ); break; #endif default: if ( opcode >= 0xE0 ) Ins_MIRP( exc, args ); else if ( opcode >= 0xC0 ) Ins_MDRP( exc, args ); else if ( opcode >= 0xB8 ) Ins_PUSHW( exc, args ); else if ( opcode >= 0xB0 ) Ins_PUSHB( exc, args ); else Ins_UNKNOWN( exc ); } } if ( exc->error ) { switch ( exc->error ) { /* looking for redefined instructions */ case FT_ERR( Invalid_Opcode ): { TT_DefRecord* def = exc->IDefs; TT_DefRecord* limit = def + exc->numIDefs; for ( ; def < limit; def++ ) { if ( def->active && exc->opcode == (FT_Byte)def->opc ) { TT_CallRec* callrec; if ( exc->callTop >= exc->callSize ) { exc->error = FT_THROW( Invalid_Reference ); goto LErrorLabel_; } callrec = &exc->callStack[exc->callTop]; callrec->Caller_Range = exc->curRange; callrec->Caller_IP = exc->IP + 1; callrec->Cur_Count = 1; callrec->Def = def; if ( Ins_Goto_CodeRange( exc, def->range, def->start ) == FAILURE ) goto LErrorLabel_; goto LSuiteLabel_; } } } exc->error = FT_THROW( Invalid_Opcode ); goto LErrorLabel_; #if 0 break; /* Unreachable code warning suppression. */ /* Leave to remind in case a later change the editor */ /* to consider break; */ #endif default: goto LErrorLabel_; #if 0 break; #endif } } exc->top = exc->new_top; if ( exc->step_ins ) exc->IP += exc->length; /* increment instruction counter and check if we didn't */ /* run this program for too long (e.g. infinite loops). */ if ( ++ins_counter > TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES ) return FT_THROW( Execution_Too_Long ); LSuiteLabel_: if ( exc->IP >= exc->codeSize ) { if ( exc->callTop > 0 ) { exc->error = FT_THROW( Code_Overflow ); goto LErrorLabel_; } else goto LNo_Error_; } } while ( !exc->instruction_trap ); LNo_Error_: FT_TRACE4(( " %d instruction%s executed\n", ins_counter == 1 ? "" : "s", ins_counter )); return FT_Err_Ok; LErrorCodeOverflow_: exc->error = FT_THROW( Code_Overflow ); LErrorLabel_: if ( exc->error && !exc->instruction_trap ) FT_TRACE1(( " The interpreter returned error 0x%x\n", exc->error )); return exc->error; } Commit Message: CWE ID: CWE-476
0
10,722
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SWFOutput_writeGlyphShape(SWFOutput out, SWFShape shape) { unsigned char c; int styleDone = 0; int i; c = 1<<4; SWFOutput_writeUInt8(out, c); shape->nFills = 1; shape->nLines = 0; for ( i=0; i<shape->nRecords; ++i ) { if(!styleDone && shape->records[i].type == SHAPERECORD_STATECHANGE) { shape->records[i].record.stateChange->flags |= SWF_SHAPE_FILLSTYLE0FLAG; shape->records[i].record.stateChange->leftFill = 1; styleDone = 1; } if ( i < shape->nRecords-1 || shape->records[i].type != SHAPERECORD_STATECHANGE ) { SWFShape_writeShapeRecord(shape, shape->records[i], out); } } SWFOutput_writeBits(out, 0, 6); /* end tag */ SWFOutput_byteAlign(out); } Commit Message: SWFShape_setLeftFillStyle: prevent fill overflow CWE ID: CWE-119
0
89,495
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static inline int rcu_use_vmalloc(int size) { /* Too big for a single page? */ if (HDRLEN_KMALLOC + size > PAGE_SIZE) return 1; return 0; } Commit Message: ipc,sem: fine grained locking for semtimedop Introduce finer grained locking for semtimedop, to handle the common case of a program wanting to manipulate one semaphore from an array with multiple semaphores. If the call is a semop manipulating just one semaphore in an array with multiple semaphores, only take the lock for that semaphore itself. If the call needs to manipulate multiple semaphores, or another caller is in a transaction that manipulates multiple semaphores, the sem_array lock is taken, as well as all the locks for the individual semaphores. On a 24 CPU system, performance numbers with the semop-multi test with N threads and N semaphores, look like this: vanilla Davidlohr's Davidlohr's + Davidlohr's + threads patches rwlock patches v3 patches 10 610652 726325 1783589 2142206 20 341570 365699 1520453 1977878 30 288102 307037 1498167 2037995 40 290714 305955 1612665 2256484 50 288620 312890 1733453 2650292 60 289987 306043 1649360 2388008 70 291298 306347 1723167 2717486 80 290948 305662 1729545 2763582 90 290996 306680 1736021 2757524 100 292243 306700 1773700 3059159 [davidlohr.bueso@hp.com: do not call sem_lock when bogus sma] [davidlohr.bueso@hp.com: make refcounter atomic] Signed-off-by: Rik van Riel <riel@redhat.com> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Davidlohr Bueso <davidlohr.bueso@hp.com> Cc: Chegu Vinod <chegu_vinod@hp.com> Cc: Jason Low <jason.low2@hp.com> Reviewed-by: Michel Lespinasse <walken@google.com> Cc: Peter Hurley <peter@hurleysoftware.com> Cc: Stanislav Kinsbursky <skinsbursky@parallels.com> Tested-by: Emmanuel Benisty <benisty.e@gmail.com> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-189
0
29,582
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView) { g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); return webView->priv->webSettings.get(); } Commit Message: 2011-06-02 Joone Hur <joone.hur@collabora.co.uk> Reviewed by Martin Robinson. [GTK] Only load dictionaries if spell check is enabled https://bugs.webkit.org/show_bug.cgi?id=32879 We don't need to call enchant if enable-spell-checking is false. * webkit/webkitwebview.cpp: (webkit_web_view_update_settings): Skip loading dictionaries when enable-spell-checking is false. (webkit_web_view_settings_notify): Ditto. git-svn-id: svn://svn.chromium.org/blink/trunk@87925 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
100,573
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void vmx_vcpu_reset(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); struct msr_data apic_base_msr; vmx->rmode.vm86_active = 0; vmx->soft_vnmi_blocked = 0; vmx->vcpu.arch.regs[VCPU_REGS_RDX] = get_rdx_init_val(); kvm_set_cr8(&vmx->vcpu, 0); apic_base_msr.data = APIC_DEFAULT_PHYS_BASE | MSR_IA32_APICBASE_ENABLE; if (kvm_vcpu_is_bsp(&vmx->vcpu)) apic_base_msr.data |= MSR_IA32_APICBASE_BSP; apic_base_msr.host_initiated = true; kvm_set_apic_base(&vmx->vcpu, &apic_base_msr); vmx_segment_cache_clear(vmx); seg_setup(VCPU_SREG_CS); vmcs_write16(GUEST_CS_SELECTOR, 0xf000); vmcs_write32(GUEST_CS_BASE, 0xffff0000); seg_setup(VCPU_SREG_DS); seg_setup(VCPU_SREG_ES); seg_setup(VCPU_SREG_FS); seg_setup(VCPU_SREG_GS); seg_setup(VCPU_SREG_SS); vmcs_write16(GUEST_TR_SELECTOR, 0); vmcs_writel(GUEST_TR_BASE, 0); vmcs_write32(GUEST_TR_LIMIT, 0xffff); vmcs_write32(GUEST_TR_AR_BYTES, 0x008b); vmcs_write16(GUEST_LDTR_SELECTOR, 0); vmcs_writel(GUEST_LDTR_BASE, 0); vmcs_write32(GUEST_LDTR_LIMIT, 0xffff); vmcs_write32(GUEST_LDTR_AR_BYTES, 0x00082); vmcs_write32(GUEST_SYSENTER_CS, 0); vmcs_writel(GUEST_SYSENTER_ESP, 0); vmcs_writel(GUEST_SYSENTER_EIP, 0); vmcs_writel(GUEST_RFLAGS, 0x02); kvm_rip_write(vcpu, 0xfff0); vmcs_writel(GUEST_GDTR_BASE, 0); vmcs_write32(GUEST_GDTR_LIMIT, 0xffff); vmcs_writel(GUEST_IDTR_BASE, 0); vmcs_write32(GUEST_IDTR_LIMIT, 0xffff); vmcs_write32(GUEST_ACTIVITY_STATE, GUEST_ACTIVITY_ACTIVE); vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, 0); vmcs_write32(GUEST_PENDING_DBG_EXCEPTIONS, 0); /* Special registers */ vmcs_write64(GUEST_IA32_DEBUGCTL, 0); setup_msrs(vmx); vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); /* 22.2.1 */ if (cpu_has_vmx_tpr_shadow()) { vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, 0); if (vm_need_tpr_shadow(vmx->vcpu.kvm)) vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, __pa(vmx->vcpu.arch.apic->regs)); vmcs_write32(TPR_THRESHOLD, 0); } kvm_vcpu_reload_apic_access_page(vcpu); if (vmx_vm_has_apicv(vcpu->kvm)) memset(&vmx->pi_desc, 0, sizeof(struct pi_desc)); if (vmx->vpid != 0) vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */ vmx_set_cr4(&vmx->vcpu, 0); vmx_set_efer(&vmx->vcpu, 0); vmx_fpu_activate(&vmx->vcpu); update_exception_bitmap(&vmx->vcpu); vpid_sync_context(vmx); } Commit Message: x86,kvm,vmx: Preserve CR4 across VM entry CR4 isn't constant; at least the TSD and PCE bits can vary. TBH, treating CR0 and CR3 as constant scares me a bit, too, but it looks like it's correct. This adds a branch and a read from cr4 to each vm entry. Because it is extremely likely that consecutive entries into the same vcpu will have the same host cr4 value, this fixes up the vmcs instead of restoring cr4 after the fact. A subsequent patch will add a kernel-wide cr4 shadow, reducing the overhead in the common case to just two memory reads and a branch. Signed-off-by: Andy Lutomirski <luto@amacapital.net> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Cc: stable@vger.kernel.org Cc: Petr Matousek <pmatouse@redhat.com> Cc: Gleb Natapov <gleb@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-399
0
37,317
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: mm_sshpam_free_ctx(void *ctxtp) { Buffer m; debug3("%s", __func__); buffer_init(&m); mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_FREE_CTX, &m); debug3("%s: waiting for MONITOR_ANS_PAM_FREE_CTX", __func__); mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_FREE_CTX, &m); buffer_free(&m); } Commit Message: Don't resend username to PAM; it already has it. Pointed out by Moritz Jodeit; ok dtucker@ CWE ID: CWE-20
0
42,169
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int __init bt_init(void) { int err; BT_INFO("Core ver %s", VERSION); err = bt_sysfs_init(); if (err < 0) return err; err = sock_register(&bt_sock_family_ops); if (err < 0) { bt_sysfs_cleanup(); return err; } BT_INFO("HCI device and connection manager initialized"); err = hci_sock_init(); if (err < 0) goto error; err = l2cap_init(); if (err < 0) goto sock_err; err = sco_init(); if (err < 0) { l2cap_exit(); goto sock_err; } return 0; sock_err: hci_sock_cleanup(); error: sock_unregister(PF_BLUETOOTH); bt_sysfs_cleanup(); return err; } Commit Message: Bluetooth: fix possible info leak in bt_sock_recvmsg() In case the socket is already shutting down, bt_sock_recvmsg() returns with 0 without updating msg_namelen leading to net/socket.c leaking the local, uninitialized sockaddr_storage variable to userland -- 128 bytes of kernel stack memory. Fix this by moving the msg_namelen assignment in front of the shutdown test. Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Gustavo Padovan <gustavo@padovan.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-200
0
30,754
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void free_http_req_rules(struct list *r) { struct act_rule *tr, *pr; list_for_each_entry_safe(pr, tr, r, list) { LIST_DEL(&pr->list); if (pr->action == ACT_HTTP_REQ_AUTH) free(pr->arg.auth.realm); regex_free(&pr->arg.hdr_add.re); free(pr); } } Commit Message: CWE ID: CWE-200
0
6,805
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr) { apic_set_reg(apic, APIC_TASKPRI, tpr); apic_update_ppr(apic); } Commit Message: KVM: x86: fix guest-initiated crash with x2apic (CVE-2013-6376) A guest can cause a BUG_ON() leading to a host kernel crash. When the guest writes to the ICR to request an IPI, while in x2apic mode the following things happen, the destination is read from ICR2, which is a register that the guest can control. kvm_irq_delivery_to_apic_fast uses the high 16 bits of ICR2 as the cluster id. A BUG_ON is triggered, which is a protection against accessing map->logical_map with an out-of-bounds access and manages to avoid that anything really unsafe occurs. The logic in the code is correct from real HW point of view. The problem is that KVM supports only one cluster with ID 0 in clustered mode, but the code that has the bug does not take this into account. Reported-by: Lars Bull <larsbull@google.com> Cc: stable@vger.kernel.org Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID: CWE-189
0
28,738
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int gx_device_delete_output_file(const gx_device * dev, const char *fname) { gs_parsed_file_name_t parsed; const char *fmt; char *pfname = (char *)gs_alloc_bytes(dev->memory, gp_file_name_sizeof, "gx_device_delete_output_file(pfname)"); int code; if (pfname == NULL) { code = gs_note_error(gs_error_VMerror); goto done; } code = gx_parse_output_file_name(&parsed, &fmt, fname, strlen(fname), dev->memory); if (code < 0) { goto done; } if (parsed.iodev && !strcmp(parsed.iodev->dname, "%stdout%")) goto done; if (fmt) { /* filename includes "%nnd" */ long count1 = dev->PageCount + 1; while (*fmt != 'l' && *fmt != '%') --fmt; if (*fmt == 'l') gs_sprintf(pfname, parsed.fname, count1); else gs_sprintf(pfname, parsed.fname, (int)count1); } else if (parsed.len && strchr(parsed.fname, '%')) /* filename with "%%" but no "%nnd" */ gs_sprintf(pfname, parsed.fname); else pfname[0] = 0; /* 0 to use "fname", not "pfname" */ if (pfname[0]) { parsed.fname = pfname; parsed.len = strlen(parsed.fname); } if (parsed.iodev) code = parsed.iodev->procs.delete_file((gx_io_device *)(&parsed.iodev), (const char *)parsed.fname); else code = gs_note_error(gs_error_invalidfileaccess); done: if (pfname != NULL) gs_free_object(dev->memory, pfname, "gx_device_delete_output_file(pfname)"); return(code); } Commit Message: CWE ID: CWE-78
0
2,803
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int em_jmp_far(struct x86_emulate_ctxt *ctxt) { int rc; unsigned short sel, old_sel; struct desc_struct old_desc, new_desc; const struct x86_emulate_ops *ops = ctxt->ops; u8 cpl = ctxt->ops->cpl(ctxt); /* Assignment of RIP may only fail in 64-bit mode */ if (ctxt->mode == X86EMUL_MODE_PROT64) ops->get_segment(ctxt, &old_sel, &old_desc, NULL, VCPU_SREG_CS); memcpy(&sel, ctxt->src.valptr + ctxt->op_bytes, 2); rc = __load_segment_descriptor(ctxt, sel, VCPU_SREG_CS, cpl, false, &new_desc); if (rc != X86EMUL_CONTINUE) return rc; rc = assign_eip_far(ctxt, ctxt->src.val, &new_desc); if (rc != X86EMUL_CONTINUE) { WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64); /* assigning eip failed; restore the old cs */ ops->set_segment(ctxt, old_sel, &old_desc, 0, VCPU_SREG_CS); return rc; } return rc; } Commit Message: KVM: x86: SYSENTER emulation is broken SYSENTER emulation is broken in several ways: 1. It misses the case of 16-bit code segments completely (CVE-2015-0239). 2. MSR_IA32_SYSENTER_CS is checked in 64-bit mode incorrectly (bits 0 and 1 can still be set without causing #GP). 3. MSR_IA32_SYSENTER_EIP and MSR_IA32_SYSENTER_ESP are not masked in legacy-mode. 4. There is some unneeded code. Fix it. Cc: stable@vger.linux.org Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID: CWE-362
0
45,024
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason) { u32 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); struct vcpu_vmx *vmx = to_vmx(vcpu); struct vmcs12 *vmcs12 = get_vmcs12(vcpu); if (vmx->nested.nested_run_pending) return false; if (unlikely(vmx->fail)) { pr_info_ratelimited("%s failed vm entry %x\n", __func__, vmcs_read32(VM_INSTRUCTION_ERROR)); return true; } /* * The host physical addresses of some pages of guest memory * are loaded into the vmcs02 (e.g. vmcs12's Virtual APIC * Page). The CPU may write to these pages via their host * physical address while L2 is running, bypassing any * address-translation-based dirty tracking (e.g. EPT write * protection). * * Mark them dirty on every exit from L2 to prevent them from * getting out of sync with dirty tracking. */ nested_mark_vmcs12_pages_dirty(vcpu); trace_kvm_nested_vmexit(kvm_rip_read(vcpu), exit_reason, vmcs_readl(EXIT_QUALIFICATION), vmx->idt_vectoring_info, intr_info, vmcs_read32(VM_EXIT_INTR_ERROR_CODE), KVM_ISA_VMX); switch (exit_reason) { case EXIT_REASON_EXCEPTION_NMI: if (is_nmi(intr_info)) return false; else if (is_page_fault(intr_info)) return !vmx->vcpu.arch.apf.host_apf_reason && enable_ept; else if (is_no_device(intr_info) && !(vmcs12->guest_cr0 & X86_CR0_TS)) return false; else if (is_debug(intr_info) && vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) return false; else if (is_breakpoint(intr_info) && vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) return false; return vmcs12->exception_bitmap & (1u << (intr_info & INTR_INFO_VECTOR_MASK)); case EXIT_REASON_EXTERNAL_INTERRUPT: return false; case EXIT_REASON_TRIPLE_FAULT: return true; case EXIT_REASON_PENDING_INTERRUPT: return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_INTR_PENDING); case EXIT_REASON_NMI_WINDOW: return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_NMI_PENDING); case EXIT_REASON_TASK_SWITCH: return true; case EXIT_REASON_CPUID: return true; case EXIT_REASON_HLT: return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING); case EXIT_REASON_INVD: return true; case EXIT_REASON_INVLPG: return nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING); case EXIT_REASON_RDPMC: return nested_cpu_has(vmcs12, CPU_BASED_RDPMC_EXITING); case EXIT_REASON_RDRAND: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDRAND_EXITING); case EXIT_REASON_RDSEED: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDSEED_EXITING); case EXIT_REASON_RDTSC: case EXIT_REASON_RDTSCP: return nested_cpu_has(vmcs12, CPU_BASED_RDTSC_EXITING); case EXIT_REASON_VMCALL: case EXIT_REASON_VMCLEAR: case EXIT_REASON_VMLAUNCH: case EXIT_REASON_VMPTRLD: case EXIT_REASON_VMPTRST: case EXIT_REASON_VMREAD: case EXIT_REASON_VMRESUME: case EXIT_REASON_VMWRITE: case EXIT_REASON_VMOFF: case EXIT_REASON_VMON: case EXIT_REASON_INVEPT: case EXIT_REASON_INVVPID: /* * VMX instructions trap unconditionally. This allows L1 to * emulate them for its L2 guest, i.e., allows 3-level nesting! */ return true; case EXIT_REASON_CR_ACCESS: return nested_vmx_exit_handled_cr(vcpu, vmcs12); case EXIT_REASON_DR_ACCESS: return nested_cpu_has(vmcs12, CPU_BASED_MOV_DR_EXITING); case EXIT_REASON_IO_INSTRUCTION: return nested_vmx_exit_handled_io(vcpu, vmcs12); case EXIT_REASON_GDTR_IDTR: case EXIT_REASON_LDTR_TR: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_DESC); case EXIT_REASON_MSR_READ: case EXIT_REASON_MSR_WRITE: return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason); case EXIT_REASON_INVALID_STATE: return true; case EXIT_REASON_MWAIT_INSTRUCTION: return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING); case EXIT_REASON_MONITOR_TRAP_FLAG: return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_TRAP_FLAG); case EXIT_REASON_MONITOR_INSTRUCTION: return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING); case EXIT_REASON_PAUSE_INSTRUCTION: return nested_cpu_has(vmcs12, CPU_BASED_PAUSE_EXITING) || nested_cpu_has2(vmcs12, SECONDARY_EXEC_PAUSE_LOOP_EXITING); case EXIT_REASON_MCE_DURING_VMENTRY: return false; case EXIT_REASON_TPR_BELOW_THRESHOLD: return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW); case EXIT_REASON_APIC_ACCESS: case EXIT_REASON_APIC_WRITE: case EXIT_REASON_EOI_INDUCED: /* * The controls for "virtualize APIC accesses," "APIC- * register virtualization," and "virtual-interrupt * delivery" only come from vmcs12. */ return true; case EXIT_REASON_EPT_VIOLATION: /* * L0 always deals with the EPT violation. If nested EPT is * used, and the nested mmu code discovers that the address is * missing in the guest EPT table (EPT12), the EPT violation * will be injected with nested_ept_inject_page_fault() */ return false; case EXIT_REASON_EPT_MISCONFIG: /* * L2 never uses directly L1's EPT, but rather L0's own EPT * table (shadow on EPT) or a merged EPT table that L0 built * (EPT on EPT). So any problems with the structure of the * table is L0's fault. */ return false; case EXIT_REASON_INVPCID: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_ENABLE_INVPCID) && nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING); case EXIT_REASON_WBINVD: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING); case EXIT_REASON_XSETBV: return true; case EXIT_REASON_XSAVES: case EXIT_REASON_XRSTORS: /* * This should never happen, since it is not possible to * set XSS to a non-zero value---neither in L1 nor in L2. * If if it were, XSS would have to be checked against * the XSS exit bitmap in vmcs12. */ return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES); case EXIT_REASON_PREEMPTION_TIMER: return false; case EXIT_REASON_PML_FULL: /* We emulate PML support to L1. */ return false; case EXIT_REASON_VMFUNC: /* VM functions are emulated through L2->L0 vmexits. */ return false; default: return true; } } Commit Message: kvm: nVMX: Enforce cpl=0 for VMX instructions VMX instructions executed inside a L1 VM will always trigger a VM exit even when executed with cpl 3. This means we must perform the privilege check in software. Fixes: 70f3aac964ae("kvm: nVMX: Remove superfluous VMX instruction fault checks") Cc: stable@vger.kernel.org Signed-off-by: Felix Wilhelm <fwilhelm@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID:
0
80,986
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i) { char *to = addr; if (unlikely(i->type & ITER_PIPE)) { WARN_ON(1); return false; } if (unlikely(i->count < bytes)) return false; iterate_all_kinds(i, bytes, v, ({ if (__copy_from_user_nocache((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len)) return false; 0;}), memcpy_from_page((to += v.bv_len) - v.bv_len, v.bv_page, v.bv_offset, v.bv_len), memcpy((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len) ) iov_iter_advance(i, bytes); return true; } Commit Message: fix a fencepost error in pipe_advance() The logics in pipe_advance() used to release all buffers past the new position failed in cases when the number of buffers to release was equal to pipe->buffers. If that happened, none of them had been released, leaving pipe full. Worse, it was trivial to trigger and we end up with pipe full of uninitialized pages. IOW, it's an infoleak. Cc: stable@vger.kernel.org # v4.9 Reported-by: "Alan J. Wylie" <alan@wylie.me.uk> Tested-by: "Alan J. Wylie" <alan@wylie.me.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> CWE ID: CWE-200
0
68,718
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int UDPSocketLibevent::RecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address, const CompletionCallback& callback) { DCHECK(CalledOnValidThread()); DCHECK_NE(kInvalidSocket, socket_); DCHECK(read_callback_.is_null()); DCHECK(!recv_from_address_); DCHECK(!callback.is_null()); // Synchronous operation not supported DCHECK_GT(buf_len, 0); int nread = InternalRecvFrom(buf, buf_len, address); if (nread != ERR_IO_PENDING) return nread; if (!base::MessageLoopForIO::current()->WatchFileDescriptor( socket_, true, base::MessageLoopForIO::WATCH_READ, &read_socket_watcher_, &read_watcher_)) { PLOG(ERROR) << "WatchFileDescriptor failed on read"; int result = MapSystemError(errno); LogRead(result, NULL, 0, NULL); return result; } read_buf_ = buf; read_buf_len_ = buf_len; recv_from_address_ = address; read_callback_ = callback; return ERR_IO_PENDING; } Commit Message: Map posix error codes in bind better, and fix one windows mapping. r=wtc BUG=330233 Review URL: https://codereview.chromium.org/101193008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242224 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-416
0
113,418
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int propagate_one(struct mount *m) { struct mount *child; int type; /* skip ones added by this propagate_mnt() */ if (IS_MNT_NEW(m)) return 0; /* skip if mountpoint isn't covered by it */ if (!is_subdir(mp->m_dentry, m->mnt.mnt_root)) return 0; if (peers(m, last_dest)) { type = CL_MAKE_SHARED; } else { struct mount *n, *p; bool done; for (n = m; ; n = p) { p = n->mnt_master; if (p == dest_master || IS_MNT_MARKED(p)) break; } do { struct mount *parent = last_source->mnt_parent; if (last_source == first_source) break; done = parent->mnt_master == p; if (done && peers(n, parent)) break; last_source = last_source->mnt_master; } while (!done); type = CL_SLAVE; /* beginning of peer group among the slaves? */ if (IS_MNT_SHARED(m)) type |= CL_MAKE_SHARED; } /* Notice when we are propagating across user namespaces */ if (m->mnt_ns->user_ns != user_ns) type |= CL_UNPRIVILEGED; child = copy_tree(last_source, last_source->mnt.mnt_root, type); if (IS_ERR(child)) return PTR_ERR(child); child->mnt.mnt_flags &= ~MNT_LOCKED; mnt_set_mountpoint(m, mp, child); last_dest = m; last_source = child; if (m->mnt_master != dest_master) { read_seqlock_excl(&mount_lock); SET_MNT_MARK(m->mnt_master); read_sequnlock_excl(&mount_lock); } hlist_add_head(&child->mnt_hash, list); return 0; } Commit Message: mnt: Add a per mount namespace limit on the number of mounts CAI Qian <caiqian@redhat.com> pointed out that the semantics of shared subtrees make it possible to create an exponentially increasing number of mounts in a mount namespace. mkdir /tmp/1 /tmp/2 mount --make-rshared / for i in $(seq 1 20) ; do mount --bind /tmp/1 /tmp/2 ; done Will create create 2^20 or 1048576 mounts, which is a practical problem as some people have managed to hit this by accident. As such CVE-2016-6213 was assigned. Ian Kent <raven@themaw.net> described the situation for autofs users as follows: > The number of mounts for direct mount maps is usually not very large because of > the way they are implemented, large direct mount maps can have performance > problems. There can be anywhere from a few (likely case a few hundred) to less > than 10000, plus mounts that have been triggered and not yet expired. > > Indirect mounts have one autofs mount at the root plus the number of mounts that > have been triggered and not yet expired. > > The number of autofs indirect map entries can range from a few to the common > case of several thousand and in rare cases up to between 30000 and 50000. I've > not heard of people with maps larger than 50000 entries. > > The larger the number of map entries the greater the possibility for a large > number of active mounts so it's not hard to expect cases of a 1000 or somewhat > more active mounts. So I am setting the default number of mounts allowed per mount namespace at 100,000. This is more than enough for any use case I know of, but small enough to quickly stop an exponential increase in mounts. Which should be perfect to catch misconfigurations and malfunctioning programs. For anyone who needs a higher limit this can be changed by writing to the new /proc/sys/fs/mount-max sysctl. Tested-by: CAI Qian <caiqian@redhat.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> CWE ID: CWE-400
1
167,012
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int cac_is_cert(cac_private_data_t * priv, const sc_path_t *in_path) { cac_object_t test_obj; test_obj.path = *in_path; test_obj.path.index = 0; test_obj.path.count = 0; return (list_contains(&priv->pki_list, &test_obj) != 0); } Commit Message: fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes. CWE ID: CWE-125
0
78,241
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int main(int argc, char *argv[]) { int ret = -1; /* * what we pass to fuse_main is: * argv[0] -s -f -o allow_other,directio argv[1] NULL */ int nargs = 5, cnt = 0; char *newargv[6]; #ifdef FORTRAVIS /* for travis which runs on 12.04 */ if (glib_check_version (2, 36, 0) != NULL) g_type_init (); #endif /* accomodate older init scripts */ swallow_arg(&argc, argv, "-s"); swallow_arg(&argc, argv, "-f"); swallow_option(&argc, argv, "-o", "allow_other"); if (argc == 2 && strcmp(argv[1], "--version") == 0) { fprintf(stderr, "%s\n", VERSION); exit(0); } if (argc != 2 || is_help(argv[1])) usage(argv[0]); newargv[cnt++] = argv[0]; newargv[cnt++] = "-f"; newargv[cnt++] = "-o"; newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5"; newargv[cnt++] = argv[1]; newargv[cnt++] = NULL; if (!cgfs_setup_controllers()) goto out; ret = fuse_main(nargs, newargv, &lxcfs_ops, NULL); out: return ret; } Commit Message: Implement privilege check when moving tasks When writing pids to a tasks file in lxcfs, lxcfs was checking for privilege over the tasks file but not over the pid being moved. Since the cgm_movepid request is done as root on the host, not with the requestor's credentials, we must copy the check which cgmanager was doing to ensure that the requesting task is allowed to change the victim task's cgroup membership. This is CVE-2015-1344 https://bugs.launchpad.net/ubuntu/+source/lxcfs/+bug/1512854 Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> CWE ID: CWE-264
0
44,422
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int wc_ecc_set_curve(ecc_key* key, int keysize, int curve_id) { if (keysize <= 0 && curve_id < 0) { return BAD_FUNC_ARG; } if (keysize > ECC_MAXSIZE) { return ECC_BAD_ARG_E; } /* handle custom case */ if (key->idx != ECC_CUSTOM_IDX) { int x; /* default values */ key->idx = 0; key->dp = NULL; /* find ecc_set based on curve_id or key size */ for (x = 0; ecc_sets[x].size != 0; x++) { if (curve_id > ECC_CURVE_DEF) { if (curve_id == ecc_sets[x].id) break; } else if (keysize <= ecc_sets[x].size) { break; } } if (ecc_sets[x].size == 0) { WOLFSSL_MSG("ECC Curve not found"); return ECC_CURVE_OID_E; } key->idx = x; key->dp = &ecc_sets[x]; } return 0; } Commit Message: Change ECDSA signing to use blinding. CWE ID: CWE-200
0
81,918
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int am_get_boolean_query_parameter(request_rec *r, const char *name, int *return_value, int default_value) { char *value_str; int ret = OK; *return_value = default_value; value_str = am_extract_query_parameter(r->pool, r->args, name); if (value_str != NULL) { ret = am_urldecode(value_str); if (ret != OK) { AM_LOG_RERROR(APLOG_MARK, APLOG_ERR, 0, r, "Error urldecoding \"%s\" boolean query parameter, " "value=\"%s\"", name, value_str); return ret; } if(!strcmp(value_str, "true")) { *return_value = TRUE; } else if(!strcmp(value_str, "false")) { *return_value = FALSE; } else { AM_LOG_RERROR(APLOG_MARK, APLOG_ERR, 0, r, "Invalid value for \"%s\" boolean query parameter, " "value=\"%s\"", name, value_str); ret = HTTP_BAD_REQUEST; } } return ret; } Commit Message: Fix redirect URL validation bypass It turns out that browsers silently convert backslash characters into forward slashes, while apr_uri_parse() does not. This mismatch allows an attacker to bypass the redirect URL validation by using an URL like: https://sp.example.org/mellon/logout?ReturnTo=https:%5c%5cmalicious.example.org/ mod_auth_mellon will assume that it is a relative URL and allow the request to pass through, while the browsers will use it as an absolute url and redirect to https://malicious.example.org/ . This patch fixes this issue by rejecting all redirect URLs with backslashes. CWE ID: CWE-601
0
91,708
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void AudioHandler::CheckNumberOfChannelsForInput(AudioNodeInput* input) { DCHECK(Context()->IsAudioThread()); DCHECK(Context()->IsGraphOwner()); DCHECK(inputs_.Contains(input)); if (!inputs_.Contains(input)) return; input->UpdateInternalBus(); } Commit Message: Revert "Keep AudioHandlers alive until they can be safely deleted." This reverts commit 071df33edf2c8b4375fa432a83953359f93ea9e4. Reason for revert: This CL seems to cause an AudioNode leak on the Linux leak bot. The log is: https://ci.chromium.org/buildbot/chromium.webkit/WebKit%20Linux%20Trusty%20Leak/14252 * webaudio/AudioNode/audionode-connect-method-chaining.html * webaudio/Panner/pannernode-basic.html * webaudio/dom-exceptions.html Original change's description: > Keep AudioHandlers alive until they can be safely deleted. > > When an AudioNode is disposed, the handler is also disposed. But add > the handler to the orphan list so that the handler stays alive until > the context can safely delete it. If we don't do this, the handler > may get deleted while the audio thread is processing the handler (due > to, say, channel count changes and such). > > For an realtime context, always save the handler just in case the > audio thread is running after the context is marked as closed (because > the audio thread doesn't instantly stop when requested). > > For an offline context, only need to do this when the context is > running because the context is guaranteed to be stopped if we're not > in the running state. Hence, there's no possibility of deleting the > handler while the graph is running. > > This is a revert of > https://chromium-review.googlesource.com/c/chromium/src/+/860779, with > a fix for the leak. > > Bug: 780919 > Change-Id: Ifb6b5fcf3fbc373f5779256688731245771da33c > Reviewed-on: https://chromium-review.googlesource.com/862723 > Reviewed-by: Hongchan Choi <hongchan@chromium.org> > Commit-Queue: Raymond Toy <rtoy@chromium.org> > Cr-Commit-Position: refs/heads/master@{#528829} TBR=rtoy@chromium.org,hongchan@chromium.org Change-Id: Ibf406bf6ed34ea1f03e86a64a1e5ba6de0970c6f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 780919 Reviewed-on: https://chromium-review.googlesource.com/863402 Reviewed-by: Taiju Tsuiki <tzik@chromium.org> Commit-Queue: Taiju Tsuiki <tzik@chromium.org> Cr-Commit-Position: refs/heads/master@{#528888} CWE ID: CWE-416
0
148,795
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: enqueue_runnable_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { } Commit Message: sched/fair: Fix infinite loop in update_blocked_averages() by reverting a9e7f6544b9c Zhipeng Xie, Xie XiuQi and Sargun Dhillon reported lockups in the scheduler under high loads, starting at around the v4.18 time frame, and Zhipeng Xie tracked it down to bugs in the rq->leaf_cfs_rq_list manipulation. Do a (manual) revert of: a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path") It turns out that the list_del_leaf_cfs_rq() introduced by this commit is a surprising property that was not considered in followup commits such as: 9c2791f936ef ("sched/fair: Fix hierarchical order in rq->leaf_cfs_rq_list") As Vincent Guittot explains: "I think that there is a bigger problem with commit a9e7f6544b9c and cfs_rq throttling: Let take the example of the following topology TG2 --> TG1 --> root: 1) The 1st time a task is enqueued, we will add TG2 cfs_rq then TG1 cfs_rq to leaf_cfs_rq_list and we are sure to do the whole branch in one path because it has never been used and can't be throttled so tmp_alone_branch will point to leaf_cfs_rq_list at the end. 2) Then TG1 is throttled 3) and we add TG3 as a new child of TG1. 4) The 1st enqueue of a task on TG3 will add TG3 cfs_rq just before TG1 cfs_rq and tmp_alone_branch will stay on rq->leaf_cfs_rq_list. With commit a9e7f6544b9c, we can del a cfs_rq from rq->leaf_cfs_rq_list. So if the load of TG1 cfs_rq becomes NULL before step 2) above, TG1 cfs_rq is removed from the list. Then at step 4), TG3 cfs_rq is added at the beginning of rq->leaf_cfs_rq_list but tmp_alone_branch still points to TG3 cfs_rq because its throttled parent can't be enqueued when the lock is released. tmp_alone_branch doesn't point to rq->leaf_cfs_rq_list whereas it should. So if TG3 cfs_rq is removed or destroyed before tmp_alone_branch points on another TG cfs_rq, the next TG cfs_rq that will be added, will be linked outside rq->leaf_cfs_rq_list - which is bad. In addition, we can break the ordering of the cfs_rq in rq->leaf_cfs_rq_list but this ordering is used to update and propagate the update from leaf down to root." Instead of trying to work through all these cases and trying to reproduce the very high loads that produced the lockup to begin with, simplify the code temporarily by reverting a9e7f6544b9c - which change was clearly not thought through completely. This (hopefully) gives us a kernel that doesn't lock up so people can continue to enjoy their holidays without worrying about regressions. ;-) [ mingo: Wrote changelog, fixed weird spelling in code comment while at it. ] Analyzed-by: Xie XiuQi <xiexiuqi@huawei.com> Analyzed-by: Vincent Guittot <vincent.guittot@linaro.org> Reported-by: Zhipeng Xie <xiezhipeng1@huawei.com> Reported-by: Sargun Dhillon <sargun@sargun.me> Reported-by: Xie XiuQi <xiexiuqi@huawei.com> Tested-by: Zhipeng Xie <xiezhipeng1@huawei.com> Tested-by: Sargun Dhillon <sargun@sargun.me> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Vincent Guittot <vincent.guittot@linaro.org> Cc: <stable@vger.kernel.org> # v4.13+ Cc: Bin Li <huawei.libin@huawei.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path") Link: http://lkml.kernel.org/r/1545879866-27809-1-git-send-email-xiexiuqi@huawei.com Signed-off-by: Ingo Molnar <mingo@kernel.org> CWE ID: CWE-400
0
92,543
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: RenderFrameImpl::CreateApplicationCacheHost( blink::WebApplicationCacheHostClient* client) { if (!frame_ || !frame_->View()) return nullptr; DocumentState* document_state = frame_->GetProvisionalDocumentLoader() ? DocumentState::FromDocumentLoader( frame_->GetProvisionalDocumentLoader()) : DocumentState::FromDocumentLoader(frame_->GetDocumentLoader()); NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(document_state->navigation_state()); return std::make_unique<RendererWebApplicationCacheHostImpl>( RenderViewImpl::FromWebView(frame_->View()), client, RenderThreadImpl::current()->appcache_dispatcher()->backend_proxy(), navigation_state->request_params().appcache_host_id, routing_id_); } Commit Message: If a page calls |window.focus()|, kick it out of fullscreen. BUG=776418, 800056 Change-Id: I1880fe600e4814c073f247c43b1c1ac80c8fc017 Reviewed-on: https://chromium-review.googlesource.com/852378 Reviewed-by: Nasko Oskov <nasko@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/master@{#533790} CWE ID:
0
147,744
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void RenderViewImpl::OnSelectRange(const gfx::Point& start, const gfx::Point& end) { if (!webview()) return; Send(new ViewHostMsg_SelectRange_ACK(routing_id_)); base::AutoReset<bool> handling_select_range(&handling_select_range_, true); webview()->focusedFrame()->selectRange(start, end); } Commit Message: Let the browser handle external navigations from DevTools. BUG=180555 Review URL: https://chromiumcodereview.appspot.com/12531004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186793 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
0
115,559
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Browser::InitCommandState() { command_updater_.UpdateCommandEnabled(IDC_RELOAD, true); command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true); IncognitoModePrefs::Availability incognito_avail = IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); command_updater_.UpdateCommandEnabled( IDC_NEW_WINDOW, incognito_avail != IncognitoModePrefs::FORCED); command_updater_.UpdateCommandEnabled( IDC_NEW_INCOGNITO_WINDOW, incognito_avail != IncognitoModePrefs::DISABLED); command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true); command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true); command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, true); command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, false); command_updater_.UpdateCommandEnabled(IDC_EXIT, true); command_updater_.UpdateCommandEnabled(IDC_TOGGLE_VERTICAL_TABS, true); command_updater_.UpdateCommandEnabled(IDC_DEBUG_FRAME_TOGGLE, true); command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_AUTO_DETECT, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF8, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF16LE, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88591, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1252, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_GBK, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_GB18030, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_BIG5HKSCS, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_BIG5, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_THAI, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOREAN, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_SHIFTJIS, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO2022JP, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_EUCJP, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885915, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_MACINTOSH, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88592, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1250, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88595, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1251, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOI8R, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOI8U, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88597, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1253, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88594, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885913, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1257, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88593, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885910, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885914, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885916, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1254, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true); command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true); command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true); command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true); command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, true); command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true); UpdateOpenFileState(); command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false); UpdateCommandsForDevTools(); command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true); command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true); command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, browser_defaults::bookmarks_enabled); command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true); command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true); command_updater_.UpdateCommandEnabled(IDC_BOOKMARKS_MENU, true); #if defined(OS_CHROMEOS) command_updater_.UpdateCommandEnabled(IDC_FILE_MANAGER, true); command_updater_.UpdateCommandEnabled(IDC_SEARCH, true); command_updater_.UpdateCommandEnabled(IDC_SHOW_KEYBOARD_OVERLAY, true); command_updater_.UpdateCommandEnabled(IDC_SYSTEM_OPTIONS, true); command_updater_.UpdateCommandEnabled(IDC_INTERNET_OPTIONS, true); #endif command_updater_.UpdateCommandEnabled( IDC_SHOW_SYNC_SETUP, profile_->GetOriginalProfile()->IsSyncAccessible()); ExtensionService* extension_service = profile()->GetExtensionService(); bool enable_extensions = extension_service && extension_service->extensions_enabled(); command_updater_.UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS, enable_extensions); bool normal_window = is_type_tabbed(); command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window); command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, !(is_type_panel() && is_app())); command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB, normal_window); command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_NEXT, normal_window); command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window); #if defined(OS_MACOSX) command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window); command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE, !(is_type_panel() && is_app())); #endif command_updater_.UpdateCommandEnabled(IDC_COPY_URL, !is_devtools()); command_updater_.UpdateCommandEnabled(IDC_FIND, !is_devtools()); command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, !is_devtools()); command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, !is_devtools()); command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window); command_updater_.UpdateCommandEnabled(IDC_UPGRADE_DIALOG, true); command_updater_.UpdateCommandEnabled(IDC_VIEW_INCOMPATIBILITIES, true); command_updater_.UpdateCommandEnabled(IDC_VIEW_BACKGROUND_PAGES, true); command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true); UpdateCommandsForFullscreenMode(false); UpdateCommandsForContentRestrictionState(); UpdateCommandsForBookmarkEditing(); } Commit Message: Implement a bubble that appears at the top of the screen when a tab enters fullscreen mode via webkitRequestFullScreen(), telling the user how to exit fullscreen. This is implemented as an NSView rather than an NSWindow because the floating chrome that appears in presentation mode should overlap the bubble. Content-initiated fullscreen mode makes use of 'presentation mode' on the Mac: the mode in which the UI is hidden, accessible by moving the cursor to the top of the screen. On Snow Leopard, this mode is synonymous with fullscreen mode. On Lion, however, fullscreen mode does not imply presentation mode: in non-presentation fullscreen mode, the chrome is permanently shown. It is possible to switch between presentation mode and fullscreen mode using the presentation mode UI control. When a tab initiates fullscreen mode on Lion, we enter presentation mode if not in presentation mode already. When the user exits fullscreen mode using Chrome UI (i.e. keyboard shortcuts, menu items, buttons, switching tabs, etc.) we return the user to the mode they were in before the tab entered fullscreen. BUG=14471 TEST=Enter fullscreen mode using webkitRequestFullScreen. You should see a bubble pop down from the top of the screen. Need to test the Lion logic somehow, with no Lion trybots. BUG=96883 Original review http://codereview.chromium.org/7890056/ TBR=thakis Review URL: http://codereview.chromium.org/7920024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101624 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
97,249
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples) { config->flags |= CONFIG_COMPATIBLE_WRITE; // write earlier version streams if (total_samples == (uint32_t) -1) return WavpackSetConfiguration64 (wpc, config, -1, NULL); else return WavpackSetConfiguration64 (wpc, config, total_samples, NULL); } Commit Message: issue #53: error out on zero sample rate CWE ID: CWE-835
0
75,643
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: size_t TopSitesCache::GetNumNonForcedURLs() const { return top_sites_.size() - num_forced_urls_; } Commit Message: TopSites: Clear thumbnails from the cache when their URLs get removed We already cleared the thumbnails from persistent storage, but they remained in the in-memory cache, so they remained accessible (until the next Chrome restart) even after all browsing data was cleared. Bug: 758169 Change-Id: Id916d22358430a82e6d5043ac04fa463a32f824f Reviewed-on: https://chromium-review.googlesource.com/758640 Commit-Queue: Marc Treib <treib@chromium.org> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org> Cr-Commit-Position: refs/heads/master@{#514861} CWE ID: CWE-200
0
147,037
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void js_pushnumber(js_State *J, double v) { CHECKSTACK(1); STACK[TOP].type = JS_TNUMBER; STACK[TOP].u.number = v; ++TOP; } Commit Message: CWE ID: CWE-119
0
13,464
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ProfileImplIOData::~ProfileImplIOData() {} Commit Message: Give the media context an ftp job factory; prevent a browser crash. BUG=112983 TEST=none Review URL: http://codereview.chromium.org/9372002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121378 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
108,221
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int vrend_decode_set_index_buffer(struct vrend_decode_ctx *ctx, int length) { if (length != 1 && length != 3) return EINVAL; vrend_set_index_buffer(ctx->grctx, get_buf_entry(ctx, VIRGL_SET_INDEX_BUFFER_HANDLE), (length == 3) ? get_buf_entry(ctx, VIRGL_SET_INDEX_BUFFER_INDEX_SIZE) : 0, (length == 3) ? get_buf_entry(ctx, VIRGL_SET_INDEX_BUFFER_OFFSET) : 0); return 0; } Commit Message: CWE ID: CWE-476
0
9,117
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void g2m_paint_cursor(G2MContext *c, uint8_t *dst, int stride) { int i, j; int x, y, w, h; const uint8_t *cursor; if (!c->cursor) return; x = c->cursor_x - c->cursor_hot_x; y = c->cursor_y - c->cursor_hot_y; cursor = c->cursor; w = c->cursor_w; h = c->cursor_h; if (x + w > c->width) w = c->width - x; if (y + h > c->height) h = c->height - y; if (x < 0) { w += x; cursor += -x * 4; } else { dst += x * 3; } if (y < 0) { h += y; cursor += -y * c->cursor_stride; } else { dst += y * stride; } if (w < 0 || h < 0) return; for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { uint8_t alpha = cursor[i * 4]; APPLY_ALPHA(dst[i * 3 + 0], cursor[i * 4 + 1], alpha); APPLY_ALPHA(dst[i * 3 + 1], cursor[i * 4 + 2], alpha); APPLY_ALPHA(dst[i * 3 + 2], cursor[i * 4 + 3], alpha); } dst += stride; cursor += c->cursor_stride; } } Commit Message: avcodec/g2meet: Fix framebuf size Currently the code can in some cases draw tiles that hang outside the allocated buffer. This patch increases the buffer size to avoid out of array accesses. An alternative would be to fail if such tiles are encountered. I do not know if any valid files use such hanging tiles. Fixes Ticket2971 Found-by: ami_stuff Signed-off-by: Michael Niedermayer <michaelni@gmx.at> CWE ID: CWE-119
0
28,033
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void reload_ucode_intel(void) { struct ucode_cpu_info uci; enum ucode_state ret; if (!mc_saved_data.mc_saved_count) return; collect_cpu_info_early(&uci); ret = generic_load_microcode_early(mc_saved_data.mc_saved, mc_saved_data.mc_saved_count, &uci); if (ret != UCODE_OK) return; apply_microcode_early(&uci, false); } Commit Message: x86/microcode/intel: Guard against stack overflow in the loader mc_saved_tmp is a static array allocated on the stack, we need to make sure mc_saved_count stays within its bounds, otherwise we're overflowing the stack in _save_mc(). A specially crafted microcode header could lead to a kernel crash or potentially kernel execution. Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Link: http://lkml.kernel.org/r/1422964824-22056-1-git-send-email-quentin.casasnovas@oracle.com Signed-off-by: Borislav Petkov <bp@suse.de> CWE ID: CWE-119
0
43,856
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, bool *own_req) { struct inet_request_sock *ireq; struct ipv6_pinfo *newnp; const struct ipv6_pinfo *np = inet6_sk(sk); struct tcp6_sock *newtcp6sk; struct inet_sock *newinet; struct tcp_sock *newtp; struct sock *newsk; #ifdef CONFIG_TCP_MD5SIG struct tcp_md5sig_key *key; #endif struct flowi6 fl6; if (skb->protocol == htons(ETH_P_IP)) { /* * v6 mapped */ newsk = tcp_v4_syn_recv_sock(sk, skb, req, dst, req_unhash, own_req); if (!newsk) return NULL; newtcp6sk = (struct tcp6_sock *)newsk; inet_sk(newsk)->pinet6 = &newtcp6sk->inet6; newinet = inet_sk(newsk); newnp = inet6_sk(newsk); newtp = tcp_sk(newsk); memcpy(newnp, np, sizeof(struct ipv6_pinfo)); newnp->saddr = newsk->sk_v6_rcv_saddr; inet_csk(newsk)->icsk_af_ops = &ipv6_mapped; newsk->sk_backlog_rcv = tcp_v4_do_rcv; #ifdef CONFIG_TCP_MD5SIG newtp->af_specific = &tcp_sock_ipv6_mapped_specific; #endif newnp->ipv6_ac_list = NULL; newnp->ipv6_fl_list = NULL; newnp->pktoptions = NULL; newnp->opt = NULL; newnp->mcast_oif = tcp_v6_iif(skb); newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb)); if (np->repflow) newnp->flow_label = ip6_flowlabel(ipv6_hdr(skb)); /* * No need to charge this sock to the relevant IPv6 refcnt debug socks count * here, tcp_create_openreq_child now does this for us, see the comment in * that function for the gory details. -acme */ /* It is tricky place. Until this moment IPv4 tcp worked with IPv6 icsk.icsk_af_ops. Sync it now. */ tcp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie); return newsk; } ireq = inet_rsk(req); if (sk_acceptq_is_full(sk)) goto out_overflow; if (!dst) { dst = inet6_csk_route_req(sk, &fl6, req, IPPROTO_TCP); if (!dst) goto out; } newsk = tcp_create_openreq_child(sk, req, skb); if (!newsk) goto out_nonewsk; /* * No need to charge this sock to the relevant IPv6 refcnt debug socks * count here, tcp_create_openreq_child now does this for us, see the * comment in that function for the gory details. -acme */ newsk->sk_gso_type = SKB_GSO_TCPV6; __ip6_dst_store(newsk, dst, NULL, NULL); inet6_sk_rx_dst_set(newsk, skb); newtcp6sk = (struct tcp6_sock *)newsk; inet_sk(newsk)->pinet6 = &newtcp6sk->inet6; newtp = tcp_sk(newsk); newinet = inet_sk(newsk); newnp = inet6_sk(newsk); memcpy(newnp, np, sizeof(struct ipv6_pinfo)); newsk->sk_v6_daddr = ireq->ir_v6_rmt_addr; newnp->saddr = ireq->ir_v6_loc_addr; newsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr; newsk->sk_bound_dev_if = ireq->ir_iif; /* Now IPv6 options... First: no IPv4 options. */ newinet->inet_opt = NULL; newnp->ipv6_ac_list = NULL; newnp->ipv6_fl_list = NULL; /* Clone RX bits */ newnp->rxopt.all = np->rxopt.all; newnp->pktoptions = NULL; newnp->opt = NULL; newnp->mcast_oif = tcp_v6_iif(skb); newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb)); if (np->repflow) newnp->flow_label = ip6_flowlabel(ipv6_hdr(skb)); /* Clone native IPv6 options from listening socket (if any) Yes, keeping reference count would be much more clever, but we make one more one thing there: reattach optmem to newsk. */ if (np->opt) newnp->opt = ipv6_dup_options(newsk, np->opt); inet_csk(newsk)->icsk_ext_hdr_len = 0; if (newnp->opt) inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + newnp->opt->opt_flen); tcp_ca_openreq_child(newsk, dst); tcp_sync_mss(newsk, dst_mtu(dst)); newtp->advmss = dst_metric_advmss(dst); if (tcp_sk(sk)->rx_opt.user_mss && tcp_sk(sk)->rx_opt.user_mss < newtp->advmss) newtp->advmss = tcp_sk(sk)->rx_opt.user_mss; tcp_initialize_rcv_mss(newsk); newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; newinet->inet_rcv_saddr = LOOPBACK4_IPV6; #ifdef CONFIG_TCP_MD5SIG /* Copy over the MD5 key from the original socket */ key = tcp_v6_md5_do_lookup(sk, &newsk->sk_v6_daddr); if (key) { /* We're using one, so create a matching key * on the newsk structure. If we fail to get * memory, then we end up not copying the key * across. Shucks. */ tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newsk->sk_v6_daddr, AF_INET6, key->key, key->keylen, sk_gfp_atomic(sk, GFP_ATOMIC)); } #endif if (__inet_inherit_port(sk, newsk) < 0) { inet_csk_prepare_forced_close(newsk); tcp_done(newsk); goto out; } *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash)); if (*own_req) { tcp_move_syn(newtp, req); /* Clone pktoptions received with SYN, if we own the req */ if (ireq->pktopts) { newnp->pktoptions = skb_clone(ireq->pktopts, sk_gfp_atomic(sk, GFP_ATOMIC)); consume_skb(ireq->pktopts); ireq->pktopts = NULL; if (newnp->pktoptions) skb_set_owner_r(newnp->pktoptions, newsk); } } return newsk; out_overflow: NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS); out_nonewsk: dst_release(dst); out: NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); return NULL; } Commit Message: ipv6: add complete rcu protection around np->opt This patch addresses multiple problems : UDP/RAW sendmsg() need to get a stable struct ipv6_txoptions while socket is not locked : Other threads can change np->opt concurrently. Dmitry posted a syzkaller (http://github.com/google/syzkaller) program desmonstrating use-after-free. Starting with TCP/DCCP lockless listeners, tcp_v6_syn_recv_sock() and dccp_v6_request_recv_sock() also need to use RCU protection to dereference np->opt once (before calling ipv6_dup_options()) This patch adds full RCU protection to np->opt Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-416
1
167,342
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: struct io_context *get_io_context(gfp_t gfp_flags, int node) { struct io_context *ret = NULL; /* * Check for unlikely race with exiting task. ioc ref count is * zero when ioc is being detached. */ do { ret = current_io_context(gfp_flags, node); if (unlikely(!ret)) break; } while (!atomic_long_inc_not_zero(&ret->refcount)); return ret; } Commit Message: block: Fix io_context leak after clone with CLONE_IO With CLONE_IO, copy_io() increments both ioc->refcount and ioc->nr_tasks. However exit_io_context() only decrements ioc->refcount if ioc->nr_tasks reaches 0. Always call put_io_context() in exit_io_context(). Signed-off-by: Louis Rilling <louis.rilling@kerlabs.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com> CWE ID: CWE-20
0
21,573
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void QQuickWebViewExperimental::setCertificateVerificationDialog(QQmlComponent* certificateVerificationDialog) { Q_D(QQuickWebView); if (d->certificateVerificationDialog == certificateVerificationDialog) return; d->certificateVerificationDialog = certificateVerificationDialog; emit certificateVerificationDialogChanged(); } Commit Message: [Qt][WK2] There's no way to test the gesture tap on WTR https://bugs.webkit.org/show_bug.cgi?id=92895 Reviewed by Kenneth Rohde Christiansen. Source/WebKit2: Add an instance of QtViewportHandler to QQuickWebViewPrivate, so it's now available on mobile and desktop modes, as a side effect gesture tap events can now be created and sent to WebCore. This is needed to test tap gestures and to get tap gestures working when you have a WebView (in desktop mode) on notebooks equipped with touch screens. * UIProcess/API/qt/qquickwebview.cpp: (QQuickWebViewPrivate::onComponentComplete): (QQuickWebViewFlickablePrivate::onComponentComplete): Implementation moved to QQuickWebViewPrivate::onComponentComplete. * UIProcess/API/qt/qquickwebview_p_p.h: (QQuickWebViewPrivate): (QQuickWebViewFlickablePrivate): Tools: WTR doesn't create the QQuickItem from C++, not from QML, so a call to componentComplete() was added to mimic the QML behaviour. * WebKitTestRunner/qt/PlatformWebViewQt.cpp: (WTR::PlatformWebView::PlatformWebView): git-svn-id: svn://svn.chromium.org/blink/trunk@124625 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
108,040
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void acm_port_destruct(struct tty_port *port) { struct acm *acm = container_of(port, struct acm, port); dev_dbg(&acm->control->dev, "%s\n", __func__); acm_release_minor(acm); usb_put_intf(acm->control); kfree(acm->country_codes); kfree(acm); } Commit Message: USB: cdc-acm: more sanity checking An attack has become available which pretends to be a quirky device circumventing normal sanity checks and crashes the kernel by an insufficient number of interfaces. This patch adds a check to the code path for quirky devices. Signed-off-by: Oliver Neukum <ONeukum@suse.com> CC: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> CWE ID:
0
54,188
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void DXVAVideoDecodeAccelerator::ReusePictureBuffer( int32 picture_buffer_id) { DCHECK(CalledOnValidThread()); OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id); RETURN_AND_NOTIFY_ON_FAILURE(it != output_picture_buffers_.end(), "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,); it->second->ReusePictureBuffer(); ProcessPendingSamples(); } Commit Message: Convert plugin and GPU process to brokered handle duplication. BUG=119250 Review URL: https://chromiumcodereview.appspot.com/9958034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132303 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
106,946
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: cupsdUpdateCGI(void) { char *ptr, /* Pointer to end of line in buffer */ message[1024]; /* Pointer to message text */ int loglevel; /* Log level for message */ while ((ptr = cupsdStatBufUpdate(CGIStatusBuffer, &loglevel, message, sizeof(message))) != NULL) { if (loglevel == CUPSD_LOG_INFO) cupsdLogMessage(CUPSD_LOG_INFO, "%s", message); if (!strchr(CGIStatusBuffer->buffer, '\n')) break; } if (ptr == NULL && !CGIStatusBuffer->bufused) { /* * Fatal error on pipe - should never happen! */ cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdUpdateCGI: error reading from CGI error pipe - %s", strerror(errno)); } } Commit Message: Don't treat "localhost.localdomain" as an allowed replacement for localhost, since it isn't. CWE ID: CWE-290
0
86,104
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: iasecc_sdo_generate(struct sc_card *card, struct iasecc_sdo *sdo) { struct sc_context *ctx = card->ctx; struct iasecc_sdo_update update_pubkey; struct sc_apdu apdu; unsigned char scb, sbuf[5], rbuf[0x400], exponent[3] = {0x01, 0x00, 0x01}; int offs = 0, rv = SC_ERROR_NOT_SUPPORTED; LOG_FUNC_CALLED(ctx); if (sdo->sdo_class != IASECC_SDO_CLASS_RSA_PRIVATE) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "For a moment, only RSA_PRIVATE class can be accepted for the SDO generation"); if (sdo->docp.acls_contact.size == 0) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Bewildered ... there are no ACLs"); scb = sdo->docp.scbs[IASECC_ACLS_RSAKEY_GENERATE]; sc_log(ctx, "'generate RSA key' SCB 0x%X", scb); do { unsigned all_conditions = scb & IASECC_SCB_METHOD_NEED_ALL ? 1 : 0; if (scb & IASECC_SCB_METHOD_USER_AUTH) if (!all_conditions) break; if (scb & IASECC_SCB_METHOD_EXT_AUTH) LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Not yet"); if (scb & IASECC_SCB_METHOD_SM) { rv = iasecc_sm_rsa_generate(card, scb & IASECC_SCB_METHOD_MASK_REF, sdo); LOG_FUNC_RETURN(ctx, rv); } } while(0); memset(&update_pubkey, 0, sizeof(update_pubkey)); update_pubkey.magic = SC_CARDCTL_IASECC_SDO_MAGIC_PUT_DATA; update_pubkey.sdo_class = IASECC_SDO_CLASS_RSA_PUBLIC; update_pubkey.sdo_ref = sdo->sdo_ref; update_pubkey.fields[0].parent_tag = IASECC_SDO_PUBKEY_TAG; update_pubkey.fields[0].tag = IASECC_SDO_PUBKEY_TAG_E; update_pubkey.fields[0].value = exponent; update_pubkey.fields[0].size = sizeof(exponent); rv = iasecc_sdo_put_data(card, &update_pubkey); LOG_TEST_RET(ctx, rv, "iasecc_sdo_generate() update SDO public key failed"); offs = 0; sbuf[offs++] = IASECC_SDO_TEMPLATE_TAG; sbuf[offs++] = 0x03; sbuf[offs++] = IASECC_SDO_TAG_HEADER; sbuf[offs++] = IASECC_SDO_CLASS_RSA_PRIVATE | IASECC_OBJECT_REF_LOCAL; sbuf[offs++] = sdo->sdo_ref & ~IASECC_OBJECT_REF_LOCAL; sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x47, 0x00, 0x00); apdu.data = sbuf; apdu.datalen = offs; apdu.lc = offs; apdu.resp = rbuf; apdu.resplen = sizeof(rbuf); apdu.le = 0x100; rv = sc_transmit_apdu(card, &apdu); LOG_TEST_RET(ctx, rv, "APDU transmit failed"); rv = sc_check_sw(card, apdu.sw1, apdu.sw2); LOG_TEST_RET(ctx, rv, "SDO get data error"); LOG_FUNC_RETURN(ctx, rv); } Commit Message: fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes. CWE ID: CWE-125
0
78,512
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static bool Supported(LocalFrame*) { return true; } Commit Message: Move Editor::Transpose() out of Editor class This patch moves |Editor::Transpose()| out of |Editor| class as preparation of expanding it into |ExecutTranspose()| in "EditorCommand.cpp" to make |Editor| class simpler for improving code health. Following patch will expand |Transpose()| into |ExecutTranspose()|. Bug: 672405 Change-Id: Icde253623f31813d2b4517c4da7d4798bd5fadf6 Reviewed-on: https://chromium-review.googlesource.com/583880 Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Yoshifumi Inoue <yosin@chromium.org> Cr-Commit-Position: refs/heads/master@{#489518} CWE ID:
0
128,661
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void LimitedWithMissingDefaultAttributeAttributeSetter( v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); ALLOW_UNUSED_LOCAL(isolate); v8::Local<v8::Object> holder = info.Holder(); ALLOW_UNUSED_LOCAL(holder); TestObject* impl = V8TestObject::ToImpl(holder); V0CustomElementProcessingStack::CallbackDeliveryScope delivery_scope; V8StringResource<> cpp_value = v8_value; if (!cpp_value.Prepare()) return; impl->setAttribute(html_names::kLimitedwithmissingdefaultattributeAttr, cpp_value); } Commit Message: bindings: Support "attribute FrozenArray<T>?" Adds a quick hack to support a case of "attribute FrozenArray<T>?". Bug: 1028047 Change-Id: Ib3cecc4beb6bcc0fb0dbc667aca595454cc90c86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933866 Reviewed-by: Hitoshi Yoshida <peria@chromium.org> Commit-Queue: Yuki Shiino <yukishiino@chromium.org> Cr-Commit-Position: refs/heads/master@{#718676} CWE ID:
0
134,807
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Extension::RuntimeData::SetActivePermissions( const PermissionSet* active) { active_permissions_ = active; } Commit Message: Tighten restrictions on hosted apps calling extension APIs Only allow component apps to make any API calls, and for them only allow the namespaces they explicitly have permission for (plus chrome.test - I need to see if I can rework some WebStore tests to remove even this). BUG=172369 Review URL: https://chromiumcodereview.appspot.com/12095095 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180426 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
0
114,369
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void addranges_D(struct cstate *g) { addrange(g, 0, '0'-1); addrange(g, '9'+1, 0xFFFF); } Commit Message: Bug 700937: Limit recursion in regexp matcher. Also handle negative return code as an error in the JS bindings. CWE ID: CWE-400
0
90,681
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void RunTransactionTestWithLog(net::HttpCache* cache, const MockTransaction& trans_info, const net::BoundNetLog& log) { RunTransactionTestWithRequestAndLog( cache, trans_info, MockHttpRequest(trans_info), NULL, log); } Commit Message: Http cache: Test deleting an entry with a pending_entry when adding the truncated flag. BUG=125159 TEST=net_unittests Review URL: https://chromiumcodereview.appspot.com/10356113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139331 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
108,112
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void dentry_reset_mounted(struct dentry *dentry) { unsigned u; for (u = 0; u < HASH_SIZE; u++) { struct mount *p; list_for_each_entry(p, &mount_hashtable[u], mnt_hash) { if (p->mnt_mountpoint == dentry) return; } } spin_lock(&dentry->d_lock); dentry->d_flags &= ~DCACHE_MOUNTED; spin_unlock(&dentry->d_lock); } Commit Message: vfs: Carefully propogate mounts across user namespaces As a matter of policy MNT_READONLY should not be changable if the original mounter had more privileges than creator of the mount namespace. Add the flag CL_UNPRIVILEGED to note when we are copying a mount from a mount namespace that requires more privileges to a mount namespace that requires fewer privileges. When the CL_UNPRIVILEGED flag is set cause clone_mnt to set MNT_NO_REMOUNT if any of the mnt flags that should never be changed are set. This protects both mount propagation and the initial creation of a less privileged mount namespace. Cc: stable@vger.kernel.org Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Reported-by: Andy Lutomirski <luto@amacapital.net> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> CWE ID: CWE-264
0
32,340
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int ip_queue_xmit(struct sk_buff *skb) { struct sock *sk = skb->sk; struct inet_sock *inet = inet_sk(sk); struct ip_options *opt = inet->opt; struct rtable *rt; struct iphdr *iph; int res; /* Skip all of this if the packet is already routed, * f.e. by something like SCTP. */ rcu_read_lock(); rt = skb_rtable(skb); if (rt != NULL) goto packet_routed; /* Make sure we can route this packet. */ rt = (struct rtable *)__sk_dst_check(sk, 0); if (rt == NULL) { __be32 daddr; /* Use correct destination address if we have options. */ daddr = inet->inet_daddr; if(opt && opt->srr) daddr = opt->faddr; /* If this fails, retransmit mechanism of transport layer will * keep trying until route appears or the connection times * itself out. */ rt = ip_route_output_ports(sock_net(sk), sk, daddr, inet->inet_saddr, inet->inet_dport, inet->inet_sport, sk->sk_protocol, RT_CONN_FLAGS(sk), sk->sk_bound_dev_if); if (IS_ERR(rt)) goto no_route; sk_setup_caps(sk, &rt->dst); } skb_dst_set_noref(skb, &rt->dst); packet_routed: if (opt && opt->is_strictroute && rt->rt_dst != rt->rt_gateway) goto no_route; /* OK, we know where to send it, allocate and build IP header. */ skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0)); skb_reset_network_header(skb); iph = ip_hdr(skb); *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); if (ip_dont_fragment(sk, &rt->dst) && !skb->local_df) iph->frag_off = htons(IP_DF); else iph->frag_off = 0; iph->ttl = ip_select_ttl(inet, &rt->dst); iph->protocol = sk->sk_protocol; iph->saddr = rt->rt_src; iph->daddr = rt->rt_dst; /* Transport layer set skb->h.foo itself. */ if (opt && opt->optlen) { iph->ihl += opt->optlen >> 2; ip_options_build(skb, opt, inet->inet_daddr, rt, 0); } ip_select_ident_more(iph, &rt->dst, sk, (skb_shinfo(skb)->gso_segs ?: 1) - 1); skb->priority = sk->sk_priority; skb->mark = sk->sk_mark; res = ip_local_out(skb); rcu_read_unlock(); return res; no_route: rcu_read_unlock(); IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); kfree_skb(skb); return -EHOSTUNREACH; } Commit Message: inet: add RCU protection to inet->opt We lack proper synchronization to manipulate inet->opt ip_options Problem is ip_make_skb() calls ip_setup_cork() and ip_setup_cork() possibly makes a copy of ipc->opt (struct ip_options), without any protection against another thread manipulating inet->opt. Another thread can change inet->opt pointer and free old one under us. Use RCU to protect inet->opt (changed to inet->inet_opt). Instead of handling atomic refcounts, just copy ip_options when necessary, to avoid cache line dirtying. We cant insert an rcu_head in struct ip_options since its included in skb->cb[], so this patch is large because I had to introduce a new ip_options_rcu structure. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-362
1
165,563
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: nfs4_layoutcommit_done(struct rpc_task *task, void *calldata) { struct nfs4_layoutcommit_data *data = calldata; struct nfs_server *server = NFS_SERVER(data->args.inode); if (!nfs4_sequence_done(task, &data->res.seq_res)) return; switch (task->tk_status) { /* Just ignore these failures */ case NFS4ERR_DELEG_REVOKED: /* layout was recalled */ case NFS4ERR_BADIOMODE: /* no IOMODE_RW layout for range */ case NFS4ERR_BADLAYOUT: /* no layout */ case NFS4ERR_GRACE: /* loca_recalim always false */ task->tk_status = 0; } if (nfs4_async_handle_error(task, server, NULL) == -EAGAIN) { rpc_restart_call_prepare(task); return; } if (task->tk_status == 0) nfs_post_op_update_inode_force_wcc(data->args.inode, data->res.fattr); } Commit Message: Fix length of buffer copied in __nfs4_get_acl_uncached _copy_from_pages() used to copy data from the temporary buffer to the user passed buffer is passed the wrong size parameter when copying data. res.acl_len contains both the bitmap and acl lenghts while acl_len contains the acl length after adjusting for the bitmap size. Signed-off-by: Sachin Prabhu <sprabhu@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID: CWE-189
0
19,920
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: mrb_mod_module_eval(mrb_state *mrb, mrb_value mod) { mrb_value a, b; if (mrb_get_args(mrb, "|S&", &a, &b) == 1) { mrb_raise(mrb, E_NOTIMP_ERROR, "module_eval/class_eval with string not implemented"); } return eval_under(mrb, mod, b, mrb_class_ptr(mod)); } Commit Message: Check length of env stack before accessing upvar; fix #3995 CWE ID: CWE-190
0
83,183
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: HeadlessWebContents::Builder::MojoService::~MojoService() {} Commit Message: Use pdf compositor service for printing when OOPIF is enabled When OOPIF is enabled (by site-per-process flag or top-document-isolation feature), use the pdf compositor service for converting PaintRecord to PDF on renderers. In the future, this will make compositing PDF from multiple renderers possible. TBR=jzfeng@chromium.org BUG=455764 Change-Id: I3c28f03f4358e4228239fe1a33384f85e7716e8f Reviewed-on: https://chromium-review.googlesource.com/699765 Commit-Queue: Wei Li <weili@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#511616} CWE ID: CWE-254
0
126,888
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void RestackWindow(XID window, XID sibling, bool above) { XWindowChanges changes; changes.sibling = sibling; changes.stack_mode = above ? Above : Below; XConfigureWindow(GetXDisplay(), window, CWSibling | CWStackMode, &changes); } Commit Message: Make shared memory segments writable only by their rightful owners. BUG=143859 TEST=Chrome's UI still works on Linux and Chrome OS Review URL: https://chromiumcodereview.appspot.com/10854242 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158289 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
0
119,207
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: authz_status oidc_authz_checker(request_rec *r, const char *require_args, const void *parsed_require_args) { /* check for anonymous access and PASS mode */ if (r->user != NULL && strlen(r->user) == 0) { r->user = NULL; if (oidc_dir_cfg_unauth_action(r) == OIDC_UNAUTH_PASS) return AUTHZ_GRANTED; } /* get the set of claims from the request state (they've been set in the authentication part earlier */ json_t *claims = NULL, *id_token = NULL; oidc_authz_get_claims_and_idtoken(r, &claims, &id_token); /* merge id_token claims (e.g. "iss") in to claims json object */ if (claims) oidc_util_json_merge(id_token, claims); /* dispatch to the >=2.4 specific authz routine */ authz_status rc = oidc_authz_worker24(r, claims ? claims : id_token, require_args); /* cleanup */ if (claims) json_decref(claims); if (id_token) json_decref(id_token); if ((rc == AUTHZ_DENIED) && ap_auth_type(r) && (apr_strnatcasecmp((const char *) ap_auth_type(r), "oauth20") == 0)) oidc_oauth_return_www_authenticate(r, "insufficient_scope", "Different scope(s) or other claims required"); return rc; } Commit Message: release 2.1.6 : security fix: scrub headers for "AuthType oauth20" Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu> CWE ID: CWE-287
0
68,120
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int qcow2_write_snapshots(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; QCowSnapshotHeader h; QCowSnapshotExtraData extra; int i, name_size, id_str_size, snapshots_size; struct { uint32_t nb_snapshots; uint64_t snapshots_offset; } QEMU_PACKED header_data; int64_t offset, snapshots_offset; int ret; /* compute the size of the snapshots */ offset = 0; for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; offset = align_offset(offset, 8); offset += sizeof(h); offset += sizeof(extra); offset += strlen(sn->id_str); offset += strlen(sn->name); } snapshots_size = offset; /* Allocate space for the new snapshot list */ snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); offset = snapshots_offset; if (offset < 0) { ret = offset; goto fail; } ret = bdrv_flush(bs); if (ret < 0) { goto fail; } /* The snapshot list position has not yet been updated, so these clusters * must indeed be completely free */ ret = qcow2_pre_write_overlap_check(bs, 0, offset, snapshots_size); if (ret < 0) { goto fail; } /* Write all snapshots to the new list */ for(i = 0; i < s->nb_snapshots; i++) { sn = s->snapshots + i; memset(&h, 0, sizeof(h)); h.l1_table_offset = cpu_to_be64(sn->l1_table_offset); h.l1_size = cpu_to_be32(sn->l1_size); /* If it doesn't fit in 32 bit, older implementations should treat it * as a disk-only snapshot rather than truncate the VM state */ if (sn->vm_state_size <= 0xffffffff) { h.vm_state_size = cpu_to_be32(sn->vm_state_size); } h.date_sec = cpu_to_be32(sn->date_sec); h.date_nsec = cpu_to_be32(sn->date_nsec); h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec); h.extra_data_size = cpu_to_be32(sizeof(extra)); memset(&extra, 0, sizeof(extra)); extra.vm_state_size_large = cpu_to_be64(sn->vm_state_size); extra.disk_size = cpu_to_be64(sn->disk_size); id_str_size = strlen(sn->id_str); name_size = strlen(sn->name); assert(id_str_size <= UINT16_MAX && name_size <= UINT16_MAX); h.id_str_size = cpu_to_be16(id_str_size); h.name_size = cpu_to_be16(name_size); offset = align_offset(offset, 8); ret = bdrv_pwrite(bs->file, offset, &h, sizeof(h)); if (ret < 0) { goto fail; } offset += sizeof(h); ret = bdrv_pwrite(bs->file, offset, &extra, sizeof(extra)); if (ret < 0) { goto fail; } offset += sizeof(extra); ret = bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size); if (ret < 0) { goto fail; } offset += id_str_size; ret = bdrv_pwrite(bs->file, offset, sn->name, name_size); if (ret < 0) { goto fail; } offset += name_size; } /* * Update the header to point to the new snapshot table. This requires the * new table and its refcounts to be stable on disk. */ ret = bdrv_flush(bs); if (ret < 0) { goto fail; } QEMU_BUILD_BUG_ON(offsetof(QCowHeader, snapshots_offset) != offsetof(QCowHeader, nb_snapshots) + sizeof(header_data.nb_snapshots)); header_data.nb_snapshots = cpu_to_be32(s->nb_snapshots); header_data.snapshots_offset = cpu_to_be64(snapshots_offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapshots), &header_data, sizeof(header_data)); if (ret < 0) { goto fail; } /* free the old snapshot table */ qcow2_free_clusters(bs, s->snapshots_offset, s->snapshots_size, QCOW2_DISCARD_SNAPSHOT); s->snapshots_offset = snapshots_offset; s->snapshots_size = snapshots_size; return 0; fail: if (snapshots_offset > 0) { qcow2_free_clusters(bs, snapshots_offset, snapshots_size, QCOW2_DISCARD_ALWAYS); } return ret; } Commit Message: CWE ID: CWE-119
0
16,788
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: struct sctp_association *sctp_unpack_cookie( const struct sctp_endpoint *ep, const struct sctp_association *asoc, struct sctp_chunk *chunk, gfp_t gfp, int *error, struct sctp_chunk **errp) { struct sctp_association *retval = NULL; struct sctp_signed_cookie *cookie; struct sctp_cookie *bear_cookie; int headersize, bodysize, fixed_size; __u8 *digest = ep->digest; struct scatterlist sg; unsigned int len; sctp_scope_t scope; struct sk_buff *skb = chunk->skb; ktime_t kt; struct hash_desc desc; /* Header size is static data prior to the actual cookie, including * any padding. */ headersize = sizeof(sctp_chunkhdr_t) + (sizeof(struct sctp_signed_cookie) - sizeof(struct sctp_cookie)); bodysize = ntohs(chunk->chunk_hdr->length) - headersize; fixed_size = headersize + sizeof(struct sctp_cookie); /* Verify that the chunk looks like it even has a cookie. * There must be enough room for our cookie and our peer's * INIT chunk. */ len = ntohs(chunk->chunk_hdr->length); if (len < fixed_size + sizeof(struct sctp_chunkhdr)) goto malformed; /* Verify that the cookie has been padded out. */ if (bodysize % SCTP_COOKIE_MULTIPLE) goto malformed; /* Process the cookie. */ cookie = chunk->subh.cookie_hdr; bear_cookie = &cookie->c; if (!sctp_sk(ep->base.sk)->hmac) goto no_hmac; /* Check the signature. */ sg_init_one(&sg, bear_cookie, bodysize); desc.tfm = sctp_sk(ep->base.sk)->hmac; desc.flags = 0; memset(digest, 0x00, SCTP_SIGNATURE_SIZE); if (crypto_hash_setkey(desc.tfm, ep->secret_key, sizeof(ep->secret_key)) || crypto_hash_digest(&desc, &sg, bodysize, digest)) { *error = -SCTP_IERROR_NOMEM; goto fail; } if (memcmp(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) { *error = -SCTP_IERROR_BAD_SIG; goto fail; } no_hmac: /* IG Section 2.35.2: * 3) Compare the port numbers and the verification tag contained * within the COOKIE ECHO chunk to the actual port numbers and the * verification tag within the SCTP common header of the received * packet. If these values do not match the packet MUST be silently * discarded, */ if (ntohl(chunk->sctp_hdr->vtag) != bear_cookie->my_vtag) { *error = -SCTP_IERROR_BAD_TAG; goto fail; } if (chunk->sctp_hdr->source != bear_cookie->peer_addr.v4.sin_port || ntohs(chunk->sctp_hdr->dest) != bear_cookie->my_port) { *error = -SCTP_IERROR_BAD_PORTS; goto fail; } /* Check to see if the cookie is stale. If there is already * an association, there is no need to check cookie's expiration * for init collision case of lost COOKIE ACK. * If skb has been timestamped, then use the stamp, otherwise * use current time. This introduces a small possibility that * that a cookie may be considered expired, but his would only slow * down the new association establishment instead of every packet. */ if (sock_flag(ep->base.sk, SOCK_TIMESTAMP)) kt = skb_get_ktime(skb); else kt = ktime_get(); if (!asoc && ktime_before(bear_cookie->expiration, kt)) { /* * Section 3.3.10.3 Stale Cookie Error (3) * * Cause of error * --------------- * Stale Cookie Error: Indicates the receipt of a valid State * Cookie that has expired. */ len = ntohs(chunk->chunk_hdr->length); *errp = sctp_make_op_error_space(asoc, chunk, len); if (*errp) { suseconds_t usecs = ktime_to_us(ktime_sub(kt, bear_cookie->expiration)); __be32 n = htonl(usecs); sctp_init_cause(*errp, SCTP_ERROR_STALE_COOKIE, sizeof(n)); sctp_addto_chunk(*errp, sizeof(n), &n); *error = -SCTP_IERROR_STALE_COOKIE; } else *error = -SCTP_IERROR_NOMEM; goto fail; } /* Make a new base association. */ scope = sctp_scope(sctp_source(chunk)); retval = sctp_association_new(ep, ep->base.sk, scope, gfp); if (!retval) { *error = -SCTP_IERROR_NOMEM; goto fail; } /* Set up our peer's port number. */ retval->peer.port = ntohs(chunk->sctp_hdr->source); /* Populate the association from the cookie. */ memcpy(&retval->c, bear_cookie, sizeof(*bear_cookie)); if (sctp_assoc_set_bind_addr_from_cookie(retval, bear_cookie, GFP_ATOMIC) < 0) { *error = -SCTP_IERROR_NOMEM; goto fail; } /* Also, add the destination address. */ if (list_empty(&retval->base.bind_addr.address_list)) { sctp_add_bind_addr(&retval->base.bind_addr, &chunk->dest, SCTP_ADDR_SRC, GFP_ATOMIC); } retval->next_tsn = retval->c.initial_tsn; retval->ctsn_ack_point = retval->next_tsn - 1; retval->addip_serial = retval->c.initial_tsn; retval->adv_peer_ack_point = retval->ctsn_ack_point; retval->peer.prsctp_capable = retval->c.prsctp_capable; retval->peer.adaptation_ind = retval->c.adaptation_ind; /* The INIT stuff will be done by the side effects. */ return retval; fail: if (retval) sctp_association_free(retval); return NULL; malformed: /* Yikes! The packet is either corrupt or deliberately * malformed. */ *error = -SCTP_IERROR_MALFORMED; goto fail; } Commit Message: net: sctp: fix NULL pointer dereference in af->from_addr_param on malformed packet An SCTP server doing ASCONF will panic on malformed INIT ping-of-death in the form of: ------------ INIT[PARAM: SET_PRIMARY_IP] ------------> While the INIT chunk parameter verification dissects through many things in order to detect malformed input, it misses to actually check parameters inside of parameters. E.g. RFC5061, section 4.2.4 proposes a 'set primary IP address' parameter in ASCONF, which has as a subparameter an address parameter. So an attacker may send a parameter type other than SCTP_PARAM_IPV4_ADDRESS or SCTP_PARAM_IPV6_ADDRESS, param_type2af() will subsequently return 0 and thus sctp_get_af_specific() returns NULL, too, which we then happily dereference unconditionally through af->from_addr_param(). The trace for the log: BUG: unable to handle kernel NULL pointer dereference at 0000000000000078 IP: [<ffffffffa01e9c62>] sctp_process_init+0x492/0x990 [sctp] PGD 0 Oops: 0000 [#1] SMP [...] Pid: 0, comm: swapper Not tainted 2.6.32-504.el6.x86_64 #1 Bochs Bochs RIP: 0010:[<ffffffffa01e9c62>] [<ffffffffa01e9c62>] sctp_process_init+0x492/0x990 [sctp] [...] Call Trace: <IRQ> [<ffffffffa01f2add>] ? sctp_bind_addr_copy+0x5d/0xe0 [sctp] [<ffffffffa01e1fcb>] sctp_sf_do_5_1B_init+0x21b/0x340 [sctp] [<ffffffffa01e3751>] sctp_do_sm+0x71/0x1210 [sctp] [<ffffffffa01e5c09>] ? sctp_endpoint_lookup_assoc+0xc9/0xf0 [sctp] [<ffffffffa01e61f6>] sctp_endpoint_bh_rcv+0x116/0x230 [sctp] [<ffffffffa01ee986>] sctp_inq_push+0x56/0x80 [sctp] [<ffffffffa01fcc42>] sctp_rcv+0x982/0xa10 [sctp] [<ffffffffa01d5123>] ? ipt_local_in_hook+0x23/0x28 [iptable_filter] [<ffffffff8148bdc9>] ? nf_iterate+0x69/0xb0 [<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0 [<ffffffff8148bf86>] ? nf_hook_slow+0x76/0x120 [<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0 [...] A minimal way to address this is to check for NULL as we do on all other such occasions where we know sctp_get_af_specific() could possibly return with NULL. Fixes: d6de3097592b ("[SCTP]: Add the handling of "Set Primary IP Address" parameter to INIT") Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Cc: Vlad Yasevich <vyasevich@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-399
0
35,893
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void BlinkTestRunner::SetPermission(const std::string& name, const std::string& value, const GURL& origin, const GURL& embedding_origin) { content::PermissionStatus status; if (value == "granted") status = PERMISSION_STATUS_GRANTED; else if (value == "prompt") status = PERMISSION_STATUS_ASK; else if (value == "denied") status = PERMISSION_STATUS_DENIED; else { NOTREACHED(); status = PERMISSION_STATUS_DENIED; } Send(new LayoutTestHostMsg_SetPermission( routing_id(), name, status, origin, embedding_origin)); } Commit Message: content: Rename webkit_test_helpers.{cc,h} to blink_test_helpers.{cc,h} Now that webkit/ is gone, we are preparing ourselves for the merge of third_party/WebKit into //blink. BUG=None BUG=content_shell && content_unittests R=avi@chromium.org Review URL: https://codereview.chromium.org/1118183003 Cr-Commit-Position: refs/heads/master@{#328202} CWE ID: CWE-399
0
123,605
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: WizardController* LoginDisplayHostWebUI::CreateWizardController() { OobeUI* oobe_ui = GetOobeUI(); return new WizardController(this, oobe_ui); } Commit Message: cros: Check initial auth type when showing views login. Bug: 859611 Change-Id: I0298db9bbf4aed6bd40600aef2e1c5794e8cd058 Reviewed-on: https://chromium-review.googlesource.com/1123056 Reviewed-by: Xiaoyin Hu <xiaoyinh@chromium.org> Commit-Queue: Jacob Dufault <jdufault@chromium.org> Cr-Commit-Position: refs/heads/master@{#572224} CWE ID:
0
131,612
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: add_op(regex_t* reg, int opcode) { int r; r = ops_new(reg); if (r != ONIG_NORMAL) return r; #ifdef USE_DIRECT_THREADED_CODE *(reg->ocs + (reg->ops_curr - reg->ops)) = opcode; #else reg->ops_curr->opcode = opcode; #endif return 0; } Commit Message: Fix CVE-2019-13225: problem in converting if-then-else pattern to bytecode. CWE ID: CWE-476
0
89,103
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) { struct usb_device *dev = chip->dev; struct usb_host_interface *host_iface; struct usb_interface_descriptor *altsd; void *control_header; int i, protocol; /* find audiocontrol interface */ host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; control_header = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen, NULL, UAC_HEADER); altsd = get_iface_desc(host_iface); protocol = altsd->bInterfaceProtocol; if (!control_header) { dev_err(&dev->dev, "cannot find UAC_HEADER\n"); return -EINVAL; } switch (protocol) { default: dev_warn(&dev->dev, "unknown interface protocol %#02x, assuming v1\n", protocol); /* fall through */ case UAC_VERSION_1: { struct uac1_ac_header_descriptor *h1 = control_header; if (!h1->bInCollection) { dev_info(&dev->dev, "skipping empty audio interface (v1)\n"); return -EINVAL; } if (h1->bLength < sizeof(*h1) + h1->bInCollection) { dev_err(&dev->dev, "invalid UAC_HEADER (v1)\n"); return -EINVAL; } for (i = 0; i < h1->bInCollection; i++) snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]); break; } case UAC_VERSION_2: { struct usb_interface_assoc_descriptor *assoc = usb_ifnum_to_if(dev, ctrlif)->intf_assoc; if (!assoc) { /* * Firmware writers cannot count to three. So to find * the IAD on the NuForce UDH-100, also check the next * interface. */ struct usb_interface *iface = usb_ifnum_to_if(dev, ctrlif + 1); if (iface && iface->intf_assoc && iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO && iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2) assoc = iface->intf_assoc; } if (!assoc) { dev_err(&dev->dev, "Audio class v2 interfaces need an interface association\n"); return -EINVAL; } for (i = 0; i < assoc->bInterfaceCount; i++) { int intf = assoc->bFirstInterface + i; if (intf != ctrlif) snd_usb_create_stream(chip, ctrlif, intf); } break; } } return 0; } Commit Message: ALSA: usb-audio: Check out-of-bounds access by corrupted buffer descriptor When a USB-audio device receives a maliciously adjusted or corrupted buffer descriptor, the USB-audio driver may access an out-of-bounce value at its parser. This was detected by syzkaller, something like: BUG: KASAN: slab-out-of-bounds in usb_audio_probe+0x27b2/0x2ab0 Read of size 1 at addr ffff88006b83a9e8 by task kworker/0:1/24 CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 4.14.0-rc1-42251-gebb2c2437d80 #224 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:16 dump_stack+0x292/0x395 lib/dump_stack.c:52 print_address_description+0x78/0x280 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 kasan_report+0x22f/0x340 mm/kasan/report.c:409 __asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:427 snd_usb_create_streams sound/usb/card.c:248 usb_audio_probe+0x27b2/0x2ab0 sound/usb/card.c:605 usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361 really_probe drivers/base/dd.c:413 driver_probe_device+0x610/0xa00 drivers/base/dd.c:557 __device_attach_driver+0x230/0x290 drivers/base/dd.c:653 bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463 __device_attach+0x26e/0x3d0 drivers/base/dd.c:710 device_initial_probe+0x1f/0x30 drivers/base/dd.c:757 bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523 device_add+0xd0b/0x1660 drivers/base/core.c:1835 usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932 generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174 usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266 really_probe drivers/base/dd.c:413 driver_probe_device+0x610/0xa00 drivers/base/dd.c:557 __device_attach_driver+0x230/0x290 drivers/base/dd.c:653 bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463 __device_attach+0x26e/0x3d0 drivers/base/dd.c:710 device_initial_probe+0x1f/0x30 drivers/base/dd.c:757 bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523 device_add+0xd0b/0x1660 drivers/base/core.c:1835 usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457 hub_port_connect drivers/usb/core/hub.c:4903 hub_port_connect_change drivers/usb/core/hub.c:5009 port_event drivers/usb/core/hub.c:5115 hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195 process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119 worker_thread+0x221/0x1850 kernel/workqueue.c:2253 kthread+0x3a1/0x470 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 This patch adds the checks of out-of-bounce accesses at appropriate places and bails out when it goes out of the given buffer. Reported-by: Andrey Konovalov <andreyknvl@google.com> Tested-by: Andrey Konovalov <andreyknvl@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> CWE ID: CWE-125
1
167,681
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; struct hci_dev *hdev; struct sk_buff *skb; int err; BT_DBG("sock %p sk %p", sock, sk); if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE)) return -EINVAL; if (len < 4 || len > HCI_MAX_FRAME_SIZE) return -EINVAL; lock_sock(sk); switch (hci_pi(sk)->channel) { case HCI_CHANNEL_RAW: case HCI_CHANNEL_USER: break; case HCI_CHANNEL_CONTROL: err = mgmt_control(sk, msg, len); goto done; case HCI_CHANNEL_MONITOR: err = -EOPNOTSUPP; goto done; default: err = -EINVAL; goto done; } hdev = hci_pi(sk)->hdev; if (!hdev) { err = -EBADFD; goto done; } if (!test_bit(HCI_UP, &hdev->flags)) { err = -ENETDOWN; goto done; } skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err); if (!skb) goto done; if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) { err = -EFAULT; goto drop; } bt_cb(skb)->pkt_type = *((unsigned char *) skb->data); skb_pull(skb, 1); if (hci_pi(sk)->channel == HCI_CHANNEL_RAW && bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { u16 opcode = get_unaligned_le16(skb->data); u16 ogf = hci_opcode_ogf(opcode); u16 ocf = hci_opcode_ocf(opcode); if (((ogf > HCI_SFLT_MAX_OGF) || !hci_test_bit(ocf & HCI_FLT_OCF_BITS, &hci_sec_filter.ocf_mask[ogf])) && !capable(CAP_NET_RAW)) { err = -EPERM; goto drop; } if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) { skb_queue_tail(&hdev->raw_q, skb); queue_work(hdev->workqueue, &hdev->tx_work); } else { /* Stand-alone HCI commands must be flaged as * single-command requests. */ bt_cb(skb)->req.start = true; skb_queue_tail(&hdev->cmd_q, skb); queue_work(hdev->workqueue, &hdev->cmd_work); } } else { if (!capable(CAP_NET_RAW)) { err = -EPERM; goto drop; } if (hci_pi(sk)->channel == HCI_CHANNEL_USER && bt_cb(skb)->pkt_type != HCI_COMMAND_PKT && bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT && bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) { err = -EINVAL; goto drop; } skb_queue_tail(&hdev->raw_q, skb); queue_work(hdev->workqueue, &hdev->tx_work); } err = len; done: release_sock(sk); return err; drop: kfree_skb(skb); goto done; } Commit Message: net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <davem@davemloft.net> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
40,367
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: long mkvparser::UnserializeString(IMkvReader* pReader, long long pos, long long size_, char*& str) { delete[] str; str = NULL; if (size_ >= LONG_MAX) // we need (size+1) chars return E_FILE_FORMAT_INVALID; const long size = static_cast<long>(size_); str = new (std::nothrow) char[size + 1]; if (str == NULL) return -1; unsigned char* const buf = reinterpret_cast<unsigned char*>(str); const long status = pReader->Read(pos, size, buf); if (status) { delete[] str; str = NULL; return status; } str[size] = '\0'; return 0; // success } Commit Message: external/libvpx/libwebm: Update snapshot Update libwebm snapshot. This update contains security fixes from upstream. Upstream git hash: 229f49347d19b0ca0941e072b199a242ef6c5f2b BUG=23167726 Change-Id: Id3e140e7b31ae11294724b1ecfe2e9c83b4d4207 (cherry picked from commit d0281a15b3c6bd91756e453cc9398c5ef412d99a) CWE ID: CWE-20
1
173,867
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void jas_free(void *ptr) { JAS_DBGLOG(100, ("jas_free(%p)\n", ptr)); free(ptr); } Commit Message: Fixed an integer overflow problem. CWE ID: CWE-190
0
70,380
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: xsltFreeExtModule(xsltExtModulePtr ext) { if (ext == NULL) return; xmlFree(ext); } Commit Message: Roll libxslt to 891681e3e948f31732229f53cb6db7215f740fc7 BUG=583156,583171 Review URL: https://codereview.chromium.org/1853083002 Cr-Commit-Position: refs/heads/master@{#385338} CWE ID: CWE-119
0
156,690
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu, hpa_t hpa) { if (!is_guest_mode(vcpu)) { vmcs_write64(APIC_ACCESS_ADDR, hpa); vmx_flush_tlb(vcpu, true); } } Commit Message: kvm: nVMX: Enforce cpl=0 for VMX instructions VMX instructions executed inside a L1 VM will always trigger a VM exit even when executed with cpl 3. This means we must perform the privilege check in software. Fixes: 70f3aac964ae("kvm: nVMX: Remove superfluous VMX instruction fault checks") Cc: stable@vger.kernel.org Signed-off-by: Felix Wilhelm <fwilhelm@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID:
0
81,065
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: OMX_ERRORTYPE omx_video::free_buffer(OMX_IN OMX_HANDLETYPE hComp, OMX_IN OMX_U32 port, OMX_IN OMX_BUFFERHEADERTYPE* buffer) { (void)hComp; OMX_ERRORTYPE eRet = OMX_ErrorNone; unsigned int nPortIndex; DEBUG_PRINT_LOW("In for encoder free_buffer"); if (m_state == OMX_StateIdle && (BITMASK_PRESENT(&m_flags ,OMX_COMPONENT_LOADING_PENDING))) { DEBUG_PRINT_LOW(" free buffer while Component in Loading pending"); } else if ((m_sInPortDef.bEnabled == OMX_FALSE && port == PORT_INDEX_IN)|| (m_sOutPortDef.bEnabled == OMX_FALSE && port == PORT_INDEX_OUT)) { DEBUG_PRINT_LOW("Free Buffer while port %u disabled", (unsigned int)port); } else if (m_state == OMX_StateExecuting || m_state == OMX_StatePause) { DEBUG_PRINT_ERROR("ERROR: Invalid state to free buffer,ports need to be disabled"); post_event(OMX_EventError, OMX_ErrorPortUnpopulated, OMX_COMPONENT_GENERATE_EVENT); return eRet; } else { DEBUG_PRINT_ERROR("ERROR: Invalid state to free buffer,port lost Buffers"); post_event(OMX_EventError, OMX_ErrorPortUnpopulated, OMX_COMPONENT_GENERATE_EVENT); } if (port == PORT_INDEX_IN) { nPortIndex = buffer - ((!meta_mode_enable)?m_inp_mem_ptr:meta_buffer_hdr); DEBUG_PRINT_LOW("free_buffer on i/p port - Port idx %u, actual cnt %u", nPortIndex, (unsigned int)m_sInPortDef.nBufferCountActual); if (nPortIndex < m_sInPortDef.nBufferCountActual && BITMASK_PRESENT(&m_inp_bm_count, nPortIndex)) { BITMASK_CLEAR(&m_inp_bm_count,nPortIndex); free_input_buffer (buffer); m_sInPortDef.bPopulated = OMX_FALSE; /*Free the Buffer Header*/ if (release_input_done() #ifdef _ANDROID_ICS_ && !meta_mode_enable #endif ) { input_use_buffer = false; if (m_inp_mem_ptr) { DEBUG_PRINT_LOW("Freeing m_inp_mem_ptr"); free (m_inp_mem_ptr); m_inp_mem_ptr = NULL; } if (m_pInput_pmem) { DEBUG_PRINT_LOW("Freeing m_pInput_pmem"); free(m_pInput_pmem); m_pInput_pmem = NULL; } #ifdef USE_ION if (m_pInput_ion) { DEBUG_PRINT_LOW("Freeing m_pInput_ion"); free(m_pInput_ion); m_pInput_ion = NULL; } #endif } } else { DEBUG_PRINT_ERROR("ERROR: free_buffer ,Port Index Invalid"); eRet = OMX_ErrorBadPortIndex; } if (BITMASK_PRESENT((&m_flags),OMX_COMPONENT_INPUT_DISABLE_PENDING) && release_input_done()) { DEBUG_PRINT_LOW("MOVING TO DISABLED STATE"); BITMASK_CLEAR((&m_flags),OMX_COMPONENT_INPUT_DISABLE_PENDING); post_event(OMX_CommandPortDisable, PORT_INDEX_IN, OMX_COMPONENT_GENERATE_EVENT); } } else if (port == PORT_INDEX_OUT) { nPortIndex = buffer - (OMX_BUFFERHEADERTYPE*)m_out_mem_ptr; DEBUG_PRINT_LOW("free_buffer on o/p port - Port idx %u, actual cnt %u", nPortIndex, (unsigned int)m_sOutPortDef.nBufferCountActual); if (nPortIndex < m_sOutPortDef.nBufferCountActual && BITMASK_PRESENT(&m_out_bm_count, nPortIndex)) { BITMASK_CLEAR(&m_out_bm_count,nPortIndex); m_sOutPortDef.bPopulated = OMX_FALSE; free_output_buffer (buffer); if (release_output_done()) { output_use_buffer = false; if (m_out_mem_ptr) { DEBUG_PRINT_LOW("Freeing m_out_mem_ptr"); free (m_out_mem_ptr); m_out_mem_ptr = NULL; } if (m_pOutput_pmem) { DEBUG_PRINT_LOW("Freeing m_pOutput_pmem"); free(m_pOutput_pmem); m_pOutput_pmem = NULL; } #ifdef USE_ION if (m_pOutput_ion) { DEBUG_PRINT_LOW("Freeing m_pOutput_ion"); free(m_pOutput_ion); m_pOutput_ion = NULL; } #endif } } else { DEBUG_PRINT_ERROR("ERROR: free_buffer , Port Index Invalid"); eRet = OMX_ErrorBadPortIndex; } if (BITMASK_PRESENT((&m_flags),OMX_COMPONENT_OUTPUT_DISABLE_PENDING) && release_output_done() ) { DEBUG_PRINT_LOW("FreeBuffer : If any Disable event pending,post it"); DEBUG_PRINT_LOW("MOVING TO DISABLED STATE"); BITMASK_CLEAR((&m_flags),OMX_COMPONENT_OUTPUT_DISABLE_PENDING); post_event(OMX_CommandPortDisable, PORT_INDEX_OUT, OMX_COMPONENT_GENERATE_EVENT); } } else { eRet = OMX_ErrorBadPortIndex; } if ((eRet == OMX_ErrorNone) && (BITMASK_PRESENT(&m_flags ,OMX_COMPONENT_LOADING_PENDING))) { if (release_done()) { if (dev_stop() != 0) { DEBUG_PRINT_ERROR("ERROR: dev_stop() FAILED"); eRet = OMX_ErrorHardware; } BITMASK_CLEAR((&m_flags),OMX_COMPONENT_LOADING_PENDING); post_event(OMX_CommandStateSet, OMX_StateLoaded, OMX_COMPONENT_GENERATE_EVENT); } else { DEBUG_PRINT_HIGH("in free buffer, release not done, need to free more buffers input %" PRIx64" output %" PRIx64, m_out_bm_count, m_inp_bm_count); } } return eRet; } Commit Message: DO NOT MERGE mm-video-v4l2: venc: add checks before accessing heap pointers Heap pointers do not point to user virtual addresses in case of secure session. Set them to NULL and add checks to avoid accesing them Bug: 28815329 Bug: 28920116 Change-Id: I94fd5808e753b58654d65e175d3857ef46ffba26 CWE ID: CWE-200
0
159,172
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void AllowState(LifecycleUnitState allowed_state) { allowed_states_.insert(allowed_state); } Commit Message: Connect the LocalDB to TabManager. Bug: 773382 Change-Id: Iec8fe5226ee175105d51f300f30b4865478ac099 Reviewed-on: https://chromium-review.googlesource.com/1118611 Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org> Reviewed-by: François Doray <fdoray@chromium.org> Cr-Commit-Position: refs/heads/master@{#572871} CWE ID:
0
132,138
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void FrameLoader::Init() { ScriptForbiddenScope forbid_scripts; ResourceRequest initial_request{KURL(g_empty_string)}; initial_request.SetRequestContext(WebURLRequest::kRequestContextInternal); initial_request.SetFrameType( frame_->IsMainFrame() ? network::mojom::RequestContextFrameType::kTopLevel : network::mojom::RequestContextFrameType::kNested); provisional_document_loader_ = Client()->CreateDocumentLoader(frame_, initial_request, SubstituteData(), ClientRedirectPolicy::kNotClientRedirect, base::UnguessableToken::Create()); provisional_document_loader_->StartLoading(); frame_->GetDocument()->CancelParsing(); state_machine_.AdvanceTo( FrameLoaderStateMachine::kDisplayingInitialEmptyDocument); document_loader_->SetSentDidFinishLoad(); if (frame_->GetPage()->Paused()) SetDefersLoading(true); TakeObjectSnapshot(); } Commit Message: Fix detach with open()ed document leaving parent loading indefinitely Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6 Bug: 803416 Test: fast/loader/document-open-iframe-then-detach.html Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6 Reviewed-on: https://chromium-review.googlesource.com/887298 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/master@{#532967} CWE ID: CWE-362
0
125,795
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void vrend_draw_bind_vertex_legacy(struct vrend_context *ctx, struct vrend_vertex_element_array *va) { uint32_t num_enable; uint32_t enable_bitmask; uint32_t disable_bitmask; int i; num_enable = va->count; enable_bitmask = 0; disable_bitmask = ~((1ull << num_enable) - 1); for (i = 0; i < va->count; i++) { struct vrend_vertex_element *ve = &va->elements[i]; int vbo_index = ve->base.vertex_buffer_index; struct vrend_resource *res; GLint loc; if (i >= ctx->sub->prog->ss[PIPE_SHADER_VERTEX]->sel->sinfo.num_inputs) { /* XYZZY: debug this? */ num_enable = ctx->sub->prog->ss[PIPE_SHADER_VERTEX]->sel->sinfo.num_inputs; break; } res = (struct vrend_resource *)ctx->sub->vbo[vbo_index].buffer; if (!res) { fprintf(stderr,"cannot find vbo buf %d %d %d\n", i, va->count, ctx->sub->prog->ss[PIPE_SHADER_VERTEX]->sel->sinfo.num_inputs); continue; } if (vrend_state.use_explicit_locations || vrend_state.have_vertex_attrib_binding) { loc = i; } else { if (ctx->sub->prog->attrib_locs) { loc = ctx->sub->prog->attrib_locs[i]; } else loc = -1; if (loc == -1) { fprintf(stderr,"%s: cannot find loc %d %d %d\n", ctx->debug_name, i, va->count, ctx->sub->prog->ss[PIPE_SHADER_VERTEX]->sel->sinfo.num_inputs); num_enable--; if (i == 0) { fprintf(stderr,"%s: shader probably didn't compile - skipping rendering\n", ctx->debug_name); return; } continue; } } if (ve->type == GL_FALSE) { fprintf(stderr,"failed to translate vertex type - skipping render\n"); return; } glBindBuffer(GL_ARRAY_BUFFER, res->id); if (ctx->sub->vbo[vbo_index].stride == 0) { void *data; /* for 0 stride we are kinda screwed */ data = glMapBufferRange(GL_ARRAY_BUFFER, ctx->sub->vbo[vbo_index].buffer_offset, ve->nr_chan * sizeof(GLfloat), GL_MAP_READ_BIT); switch (ve->nr_chan) { case 1: glVertexAttrib1fv(loc, data); break; case 2: glVertexAttrib2fv(loc, data); break; case 3: glVertexAttrib3fv(loc, data); break; case 4: default: glVertexAttrib4fv(loc, data); break; } glUnmapBuffer(GL_ARRAY_BUFFER); disable_bitmask |= (1 << loc); } else { enable_bitmask |= (1 << loc); if (util_format_is_pure_integer(ve->base.src_format)) { glVertexAttribIPointer(loc, ve->nr_chan, ve->type, ctx->sub->vbo[vbo_index].stride, (void *)(unsigned long)(ve->base.src_offset + ctx->sub->vbo[vbo_index].buffer_offset)); } else { glVertexAttribPointer(loc, ve->nr_chan, ve->type, ve->norm, ctx->sub->vbo[vbo_index].stride, (void *)(unsigned long)(ve->base.src_offset + ctx->sub->vbo[vbo_index].buffer_offset)); } glVertexAttribDivisorARB(loc, ve->base.instance_divisor); } } if (ctx->sub->enabled_attribs_bitmask != enable_bitmask) { uint32_t mask = ctx->sub->enabled_attribs_bitmask & disable_bitmask; while (mask) { i = u_bit_scan(&mask); glDisableVertexAttribArray(i); } ctx->sub->enabled_attribs_bitmask &= ~disable_bitmask; mask = ctx->sub->enabled_attribs_bitmask ^ enable_bitmask; while (mask) { i = u_bit_scan(&mask); glEnableVertexAttribArray(i); } ctx->sub->enabled_attribs_bitmask = enable_bitmask; } } Commit Message: CWE ID: CWE-772
0
8,857
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void rpng2_x_init(void) { ulg i; ulg rowbytes = rpng2_info.rowbytes; Trace((stderr, "beginning rpng2_x_init()\n")) Trace((stderr, " rowbytes = %d\n", rpng2_info.rowbytes)) Trace((stderr, " width = %ld\n", rpng2_info.width)) Trace((stderr, " height = %ld\n", rpng2_info.height)) rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); if (!rpng2_info.image_data) { readpng2_cleanup(&rpng2_info); return; } rpng2_info.row_pointers = (uch **)malloc(rpng2_info.height * sizeof(uch *)); if (!rpng2_info.row_pointers) { free(rpng2_info.image_data); rpng2_info.image_data = NULL; readpng2_cleanup(&rpng2_info); return; } for (i = 0; i < rpng2_info.height; ++i) rpng2_info.row_pointers[i] = rpng2_info.image_data + i*rowbytes; /* do the basic X initialization stuff, make the window, and fill it with * the user-specified, file-specified or default background color or * pattern */ if (rpng2_x_create_window()) { /* GRR TEMPORARY HACK: this is fundamentally no different from cases * above; libpng should call our error handler to longjmp() back to us * when png_ptr goes away. If we/it segfault instead, seems like a * libpng bug... */ /* we're here via libpng callback, so if window fails, clean and bail */ readpng2_cleanup(&rpng2_info); rpng2_x_cleanup(); exit(2); } rpng2_info.state = kWindowInit; } Commit Message: DO NOT MERGE Update libpng to 1.6.20 BUG:23265085 Change-Id: I85199805636d771f3597b691b63bc0bf46084833 (cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82) CWE ID:
0
159,807
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc) { xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) return err; return DoCreateContext(cl, req->context, req->shareList, config, pGlxScreen, req->isDirect); } Commit Message: CWE ID: CWE-20
0
14,150
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt) { KLVPacket klv; MXFContext *mxf = s->priv_data; int ret; while ((ret = klv_read_packet(&klv, s->pb)) == 0) { PRINT_KEY(s, "read packet", klv.key); av_log(s, AV_LOG_TRACE, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset); if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) { ret = mxf_decrypt_triplet(s, pkt, &klv); if (ret < 0) { av_log(s, AV_LOG_ERROR, "invalid encoded triplet\n"); return ret; } return 0; } if (IS_KLV_KEY(klv.key, mxf_essence_element_key) || IS_KLV_KEY(klv.key, mxf_canopus_essence_element_key) || IS_KLV_KEY(klv.key, mxf_avid_essence_element_key)) { int index = mxf_get_stream_index(s, &klv); int64_t next_ofs, next_klv; AVStream *st; MXFTrack *track; AVCodecParameters *par; if (index < 0) { av_log(s, AV_LOG_ERROR, "error getting stream index %"PRIu32"\n", AV_RB32(klv.key + 12)); goto skip; } st = s->streams[index]; track = st->priv_data; if (s->streams[index]->discard == AVDISCARD_ALL) goto skip; next_klv = avio_tell(s->pb) + klv.length; next_ofs = mxf_set_current_edit_unit(mxf, klv.offset); if (next_ofs >= 0 && next_klv > next_ofs) { /* if this check is hit then it's possible OPAtom was treated as OP1a * truncate the packet since it's probably very large (>2 GiB is common) */ avpriv_request_sample(s, "OPAtom misinterpreted as OP1a? " "KLV for edit unit %i extending into " "next edit unit", mxf->current_edit_unit); klv.length = next_ofs - avio_tell(s->pb); } /* check for 8 channels AES3 element */ if (klv.key[12] == 0x06 && klv.key[13] == 0x01 && klv.key[14] == 0x10) { ret = mxf_get_d10_aes3_packet(s->pb, s->streams[index], pkt, klv.length); if (ret < 0) { av_log(s, AV_LOG_ERROR, "error reading D-10 aes3 frame\n"); return ret; } } else { ret = av_get_packet(s->pb, pkt, klv.length); if (ret < 0) return ret; } pkt->stream_index = index; pkt->pos = klv.offset; par = st->codecpar; if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) { /* mxf->current_edit_unit good - see if we have an * index table to derive timestamps from */ MXFIndexTable *t = &mxf->index_tables[0]; if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) { pkt->dts = mxf->current_edit_unit + t->first_dts; pkt->pts = t->ptses[mxf->current_edit_unit]; } else if (track && track->intra_only) { /* intra-only -> PTS = EditUnit. * let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */ pkt->pts = mxf->current_edit_unit; } } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) { ret = mxf_set_audio_pts(mxf, par, pkt); if (ret < 0) return ret; } /* seek for truncated packets */ avio_seek(s->pb, next_klv, SEEK_SET); return 0; } else skip: avio_skip(s->pb, klv.length); } return avio_feof(s->pb) ? AVERROR_EOF : ret; } Commit Message: avformat/mxfdec: Fix DoS issues in mxf_read_index_entry_array() Fixes: 20170829A.mxf Co-Author: 张洪亮(望初)" <wangchu.zhl@alibaba-inc.com> Found-by: Xiaohei and Wangchu from Alibaba Security Team Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> CWE ID: CWE-834
0
61,604
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Document::setContentLanguage(const AtomicString& language) { if (m_contentLanguage == language) return; m_contentLanguage = language; setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::Language)); } Commit Message: Change Document::detach() to RELEASE_ASSERT all subframes are gone. BUG=556724,577105 Review URL: https://codereview.chromium.org/1667573002 Cr-Commit-Position: refs/heads/master@{#373642} CWE ID: CWE-264
0
124,498
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: sshpkt_ptr(struct ssh *ssh, size_t *lenp) { if (lenp != NULL) *lenp = sshbuf_len(ssh->state->incoming_packet); return sshbuf_ptr(ssh->state->incoming_packet); } Commit Message: CWE ID: CWE-119
0
13,017
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void pdf_run_h(fz_context *ctx, pdf_processor *proc) { pdf_run_processor *pr = (pdf_run_processor *)proc; fz_closepath(ctx, pr->path); } Commit Message: CWE ID: CWE-416
0
532
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int http_handle_stats(struct stream *s, struct channel *req) { struct stats_admin_rule *stats_admin_rule; struct stream_interface *si = &s->si[1]; struct session *sess = s->sess; struct http_txn *txn = s->txn; struct http_msg *msg = &txn->req; struct uri_auth *uri_auth = s->be->uri_auth; const char *uri, *h, *lookup; struct appctx *appctx; appctx = si_appctx(si); memset(&appctx->ctx.stats, 0, sizeof(appctx->ctx.stats)); appctx->st1 = appctx->st2 = 0; appctx->ctx.stats.st_code = STAT_STATUS_INIT; appctx->ctx.stats.flags |= STAT_FMT_HTML; /* assume HTML mode by default */ if ((msg->flags & HTTP_MSGF_VER_11) && (s->txn->meth != HTTP_METH_HEAD)) appctx->ctx.stats.flags |= STAT_CHUNKED; uri = msg->chn->buf->p + msg->sl.rq.u; lookup = uri + uri_auth->uri_len; for (h = lookup; h <= uri + msg->sl.rq.u_l - 3; h++) { if (memcmp(h, ";up", 3) == 0) { appctx->ctx.stats.flags |= STAT_HIDE_DOWN; break; } } if (uri_auth->refresh) { for (h = lookup; h <= uri + msg->sl.rq.u_l - 10; h++) { if (memcmp(h, ";norefresh", 10) == 0) { appctx->ctx.stats.flags |= STAT_NO_REFRESH; break; } } } for (h = lookup; h <= uri + msg->sl.rq.u_l - 4; h++) { if (memcmp(h, ";csv", 4) == 0) { appctx->ctx.stats.flags &= ~STAT_FMT_HTML; break; } } for (h = lookup; h <= uri + msg->sl.rq.u_l - 6; h++) { if (memcmp(h, ";typed", 6) == 0) { appctx->ctx.stats.flags &= ~STAT_FMT_HTML; appctx->ctx.stats.flags |= STAT_FMT_TYPED; break; } } for (h = lookup; h <= uri + msg->sl.rq.u_l - 8; h++) { if (memcmp(h, ";st=", 4) == 0) { int i; h += 4; appctx->ctx.stats.st_code = STAT_STATUS_UNKN; for (i = STAT_STATUS_INIT + 1; i < STAT_STATUS_SIZE; i++) { if (strncmp(stat_status_codes[i], h, 4) == 0) { appctx->ctx.stats.st_code = i; break; } } break; } } appctx->ctx.stats.scope_str = 0; appctx->ctx.stats.scope_len = 0; for (h = lookup; h <= uri + msg->sl.rq.u_l - 8; h++) { if (memcmp(h, STAT_SCOPE_INPUT_NAME "=", strlen(STAT_SCOPE_INPUT_NAME) + 1) == 0) { int itx = 0; const char *h2; char scope_txt[STAT_SCOPE_TXT_MAXLEN + 1]; const char *err; h += strlen(STAT_SCOPE_INPUT_NAME) + 1; h2 = h; appctx->ctx.stats.scope_str = h2 - msg->chn->buf->p; while (*h != ';' && *h != '\0' && *h != '&' && *h != ' ' && *h != '\n') { itx++; h++; } if (itx > STAT_SCOPE_TXT_MAXLEN) itx = STAT_SCOPE_TXT_MAXLEN; appctx->ctx.stats.scope_len = itx; /* scope_txt = search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */ memcpy(scope_txt, h2, itx); scope_txt[itx] = '\0'; err = invalid_char(scope_txt); if (err) { /* bad char in search text => clear scope */ appctx->ctx.stats.scope_str = 0; appctx->ctx.stats.scope_len = 0; } break; } } /* now check whether we have some admin rules for this request */ list_for_each_entry(stats_admin_rule, &uri_auth->admin_rules, list) { int ret = 1; if (stats_admin_rule->cond) { ret = acl_exec_cond(stats_admin_rule->cond, s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (stats_admin_rule->cond->pol == ACL_COND_UNLESS) ret = !ret; } if (ret) { /* no rule, or the rule matches */ appctx->ctx.stats.flags |= STAT_ADMIN; break; } } /* Was the status page requested with a POST ? */ if (unlikely(txn->meth == HTTP_METH_POST && txn->req.body_len > 0)) { if (appctx->ctx.stats.flags & STAT_ADMIN) { /* we'll need the request body, possibly after sending 100-continue */ if (msg->msg_state < HTTP_MSG_CHUNK_SIZE) req->analysers |= AN_REQ_HTTP_BODY; appctx->st0 = STAT_HTTP_POST; } else { appctx->ctx.stats.st_code = STAT_STATUS_DENY; appctx->st0 = STAT_HTTP_LAST; } } else { /* So it was another method (GET/HEAD) */ appctx->st0 = STAT_HTTP_HEAD; } s->task->nice = -32; /* small boost for HTTP statistics */ return 1; } Commit Message: CWE ID: CWE-200
0
6,830
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static bool shouldEmitNewlineForNode(Node* node, bool emitsOriginalText) { RenderObject* renderer = node->renderer(); if (renderer ? !renderer->isBR() : !node->hasTagName(brTag)) return false; return emitsOriginalText || !(node->isInShadowTree() && node->shadowHost()->toInputElement()); } Commit Message: Upgrade a TextIterator ASSERT to a RELEASE_ASSERT as a defensive measure. BUG=156930,177197 R=inferno@chromium.org Review URL: https://codereview.chromium.org/15057010 git-svn-id: svn://svn.chromium.org/blink/trunk@150123 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-119
0
113,366
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: IW_IMPL(int) iw_detect_fmt_from_filename(const char *fn) { char *s; int i; struct fmttable_struct { const char *ext; int fmt; }; static const struct fmttable_struct fmttable[] = { {"png", IW_FORMAT_PNG}, {"jpg", IW_FORMAT_JPEG}, {"jpeg", IW_FORMAT_JPEG}, {"bmp", IW_FORMAT_BMP}, {"tif", IW_FORMAT_TIFF}, {"tiff", IW_FORMAT_TIFF}, {"miff", IW_FORMAT_MIFF}, {"webp", IW_FORMAT_WEBP}, {"gif", IW_FORMAT_GIF}, {"pnm", IW_FORMAT_PNM}, {"pbm", IW_FORMAT_PBM}, {"pgm", IW_FORMAT_PGM}, {"ppm", IW_FORMAT_PPM}, {"pam", IW_FORMAT_PAM}, {NULL, 0} }; s=strrchr(fn,'.'); if(!s) return IW_FORMAT_UNKNOWN; s++; for(i=0;fmttable[i].ext;i++) { if(!iw_stricmp(s,fmttable[i].ext)) return fmttable[i].fmt; } return IW_FORMAT_UNKNOWN; } Commit Message: Trying to fix some invalid left shift operations Fixes issue #16 CWE ID: CWE-682
0
66,266
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int WebContentsImpl::CreateSwappedOutRenderView( SiteInstance* instance) { return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true, true); } Commit Message: Cancel JavaScript dialogs when an interstitial appears. BUG=295695 TEST=See bug for repro steps. Review URL: https://chromiumcodereview.appspot.com/24360011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225026 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
110,578
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int poke_user(struct task_struct *child, addr_t addr, addr_t data) { addr_t mask; /* * Stupid gdb peeks/pokes the access registers in 64 bit with * an alignment of 4. Programmers from hell indeed... */ mask = __ADDR_MASK; #ifdef CONFIG_64BIT if (addr >= (addr_t) &((struct user *) NULL)->regs.acrs && addr < (addr_t) &((struct user *) NULL)->regs.orig_gpr2) mask = 3; #endif if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK) return -EIO; return __poke_user(child, addr, data); } Commit Message: s390/ptrace: fix PSW mask check The PSW mask check of the PTRACE_POKEUSR_AREA command is incorrect. The PSW_MASK_USER define contains the PSW_MASK_ASC bits, the ptrace interface accepts all combinations for the address-space-control bits. To protect the kernel space the PSW mask check in ptrace needs to reject the address-space-control bit combination for home space. Fixes CVE-2014-3534 Cc: stable@vger.kernel.org Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> CWE ID: CWE-264
0
38,024
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: AutofillPopupRowView::AutofillPopupRowView( AutofillPopupViewNativeViews* popup_view, int line_number) : popup_view_(popup_view), line_number_(line_number) { set_notify_enter_exit_on_child(true); } Commit Message: [Autofill] Remove AutofillPopupViewViews and associated feature. Bug: 906135,831603 Change-Id: I3c982f8b3ffb4928c7c878e74e10113999106499 Reviewed-on: https://chromium-review.googlesource.com/c/1387124 Reviewed-by: Robert Kaplow <rkaplow@chromium.org> Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org> Reviewed-by: Fabio Tirelo <ftirelo@chromium.org> Reviewed-by: Tommy Martino <tmartino@chromium.org> Commit-Queue: Mathieu Perreault <mathp@chromium.org> Cr-Commit-Position: refs/heads/master@{#621360} CWE ID: CWE-416
0
130,526
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool HasEnvironmentVariable(const std::string& variable_name) { return HasEnvironmentVariable16(UTF8ToUTF16(variable_name)); } Commit Message: Ignore switches following "--" when parsing a command line. BUG=933004 R=wfh@chromium.org Change-Id: I911be4cbfc38a4d41dec85d85f7fe0f50ddca392 Reviewed-on: https://chromium-review.googlesource.com/c/1481210 Auto-Submit: Greg Thompson <grt@chromium.org> Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org> Reviewed-by: Julian Pastarmov <pastarmovj@chromium.org> Cr-Commit-Position: refs/heads/master@{#634604} CWE ID: CWE-77
0
152,645
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void OMXCodec::fillOutputBuffers() { CHECK_EQ((int)mState, (int)EXECUTING); if (mSignalledEOS && countBuffersWeOwn(mPortBuffers[kPortIndexInput]) == mPortBuffers[kPortIndexInput].size() && countBuffersWeOwn(mPortBuffers[kPortIndexOutput]) == mPortBuffers[kPortIndexOutput].size()) { mNoMoreOutputData = true; mBufferFilled.signal(); return; } Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexOutput]; for (size_t i = 0; i < buffers->size(); ++i) { BufferInfo *info = &buffers->editItemAt(i); if (info->mStatus == OWNED_BY_US) { fillOutputBuffer(&buffers->editItemAt(i)); } } } Commit Message: OMXCodec: check IMemory::pointer() before using allocation Bug: 29421811 Change-Id: I0a73ba12bae4122f1d89fc92e5ea4f6a96cd1ed1 CWE ID: CWE-284
0
158,155
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int jpc_siz_putparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out) { jpc_siz_t *siz = &ms->parms.siz; unsigned int i; /* Eliminate compiler warning about unused variables. */ cstate = 0; assert(siz->width && siz->height && siz->tilewidth && siz->tileheight && siz->numcomps); if (jpc_putuint16(out, siz->caps) || jpc_putuint32(out, siz->width) || jpc_putuint32(out, siz->height) || jpc_putuint32(out, siz->xoff) || jpc_putuint32(out, siz->yoff) || jpc_putuint32(out, siz->tilewidth) || jpc_putuint32(out, siz->tileheight) || jpc_putuint32(out, siz->tilexoff) || jpc_putuint32(out, siz->tileyoff) || jpc_putuint16(out, siz->numcomps)) { return -1; } for (i = 0; i < siz->numcomps; ++i) { if (jpc_putuint8(out, ((siz->comps[i].sgnd & 1) << 7) | ((siz->comps[i].prec - 1) & 0x7f)) || jpc_putuint8(out, siz->comps[i].hsamp) || jpc_putuint8(out, siz->comps[i].vsamp)) { return -1; } } return 0; } Commit Message: Added some missing sanity checks on the data in a SIZ marker segment. CWE ID: CWE-20
0
72,986
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: construct_le_tlv(struct sc_apdu *apdu, unsigned char *apdu_buf, size_t data_tlv_len, unsigned char *le_tlv, size_t * le_tlv_len, const unsigned char key_type) { size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8); *(apdu_buf + block_size + data_tlv_len) = 0x97; if (apdu->le > 0x7F) { /* Le' > 0x7E, use extended APDU */ *(apdu_buf + block_size + data_tlv_len + 1) = 2; *(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)(apdu->le / 0x100); *(apdu_buf + block_size + data_tlv_len + 3) = (unsigned char)(apdu->le % 0x100); memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 4); *le_tlv_len = 4; } else { *(apdu_buf + block_size + data_tlv_len + 1) = 1; *(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)apdu->le; memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 3); *le_tlv_len = 3; } return 0; } Commit Message: fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes. CWE ID: CWE-125
0
78,373