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: void WebRuntimeFeatures::EnableAudioOutputDevices(bool enable) {
RuntimeEnabledFeatures::SetAudioOutputDevicesEnabled(enable);
}
Commit Message: Remove RequireCSSExtensionForFile runtime enabled flag.
The feature has long since been stable (since M64) and doesn't seem
to be a need for this flag.
BUG=788936
Change-Id: I666390b869289c328acb4a2daa5bf4154e1702c0
Reviewed-on: https://chromium-review.googlesource.com/c/1324143
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607329}
CWE ID: CWE-254 | 0 | 154,591 |
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 NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name)
{
unsigned upper_length;
int len, type, optlen;
char *dest, *ret;
/* option points to OPT_DATA, need to go back to get OPT_LEN */
len = option[-OPT_DATA + OPT_LEN];
type = optflag->flags & OPTION_TYPE_MASK;
optlen = dhcp_option_lengths[type];
upper_length = len_of_option_as_string[type]
* ((unsigned)(len + optlen - 1) / (unsigned)optlen);
dest = ret = xmalloc(upper_length + strlen(opt_name) + 2);
dest += sprintf(ret, "%s=", opt_name);
while (len >= optlen) {
switch (type) {
case OPTION_IP:
case OPTION_IP_PAIR:
dest += sprint_nip(dest, "", option);
if (type == OPTION_IP)
break;
dest += sprint_nip(dest, "/", option + 4);
break;
case OPTION_U8:
dest += sprintf(dest, "%u", *option);
break;
case OPTION_U16: {
uint16_t val_u16;
move_from_unaligned16(val_u16, option);
dest += sprintf(dest, "%u", ntohs(val_u16));
break;
}
case OPTION_S32:
case OPTION_U32: {
uint32_t val_u32;
move_from_unaligned32(val_u32, option);
dest += sprintf(dest, type == OPTION_U32 ? "%lu" : "%ld", (unsigned long) ntohl(val_u32));
break;
}
/* Note: options which use 'return' instead of 'break'
* (for example, OPTION_STRING) skip the code which handles
* the case of list of options.
*/
case OPTION_STRING:
case OPTION_STRING_HOST:
memcpy(dest, option, len);
dest[len] = '\0';
if (type == OPTION_STRING_HOST && !good_hostname(dest))
safe_strncpy(dest, "bad", len);
return ret;
case OPTION_STATIC_ROUTES: {
/* Option binary format:
* mask [one byte, 0..32]
* ip [big endian, 0..4 bytes depending on mask]
* router [big endian, 4 bytes]
* may be repeated
*
* We convert it to a string "IP/MASK ROUTER IP2/MASK2 ROUTER2"
*/
const char *pfx = "";
while (len >= 1 + 4) { /* mask + 0-byte ip + router */
uint32_t nip;
uint8_t *p;
unsigned mask;
int bytes;
mask = *option++;
if (mask > 32)
break;
len--;
nip = 0;
p = (void*) &nip;
bytes = (mask + 7) / 8; /* 0 -> 0, 1..8 -> 1, 9..16 -> 2 etc */
while (--bytes >= 0) {
*p++ = *option++;
len--;
}
if (len < 4)
break;
/* print ip/mask */
dest += sprint_nip(dest, pfx, (void*) &nip);
pfx = " ";
dest += sprintf(dest, "/%u ", mask);
/* print router */
dest += sprint_nip(dest, "", option);
option += 4;
len -= 4;
}
return ret;
}
case OPTION_6RD:
/* Option binary format (see RFC 5969):
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 6rdPrefix |
* ... (16 octets) ...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* ... 6rdBRIPv4Address(es) ...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* We convert it to a string
* "IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address..."
*
* Sanity check: ensure that our length is at least 22 bytes, that
* IPv4MaskLen <= 32,
* 6rdPrefixLen <= 128,
* 6rdPrefixLen + (32 - IPv4MaskLen) <= 128
* (2nd condition need no check - it follows from 1st and 3rd).
* Else, return envvar with empty value ("optname=")
*/
if (len >= (1 + 1 + 16 + 4)
&& option[0] <= 32
&& (option[1] + 32 - option[0]) <= 128
) {
/* IPv4MaskLen */
dest += sprintf(dest, "%u ", *option++);
/* 6rdPrefixLen */
dest += sprintf(dest, "%u ", *option++);
/* 6rdPrefix */
dest += sprint_nip6(dest, /* "", */ option);
option += 16;
len -= 1 + 1 + 16 + 4;
/* "+ 4" above corresponds to the length of IPv4 addr
* we consume in the loop below */
while (1) {
/* 6rdBRIPv4Address(es) */
dest += sprint_nip(dest, " ", option);
option += 4;
len -= 4; /* do we have yet another 4+ bytes? */
if (len < 0)
break; /* no */
}
}
return ret;
#if ENABLE_FEATURE_UDHCP_RFC3397
case OPTION_DNS_STRING:
/* unpack option into dest; use ret for prefix (i.e., "optname=") */
dest = dname_dec(option, len, ret);
if (dest) {
free(ret);
return dest;
}
/* error. return "optname=" string */
return ret;
case OPTION_SIP_SERVERS:
/* Option binary format:
* type: byte
* type=0: domain names, dns-compressed
* type=1: IP addrs
*/
option++;
len--;
if (option[-1] == 0) {
dest = dname_dec(option, len, ret);
if (dest) {
free(ret);
return dest;
}
} else
if (option[-1] == 1) {
const char *pfx = "";
while (1) {
len -= 4;
if (len < 0)
break;
dest += sprint_nip(dest, pfx, option);
pfx = " ";
option += 4;
}
}
return ret;
#endif
} /* switch */
/* If we are here, try to format any remaining data
* in the option as another, similarly-formatted option
*/
option += optlen;
len -= optlen;
if (len < optlen /* || !(optflag->flags & OPTION_LIST) */)
break;
*dest++ = ' ';
*dest = '\0';
} /* while */
return ret;
}
Commit Message:
CWE ID: CWE-119 | 1 | 165,349 |
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: ZEND_API int zend_ts_hash_find(TsHashTable *ht, char *arKey, uint nKeyLength, void **pData)
{
int retval;
begin_read(ht);
retval = zend_hash_find(TS_HASH(ht), arKey, nKeyLength, pData);
end_read(ht);
return retval;
}
Commit Message:
CWE ID: | 0 | 7,450 |
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: status_t CameraDeviceClient::getCameraInfo(/*out*/CameraMetadata* info)
{
ATRACE_CALL();
ALOGV("%s", __FUNCTION__);
status_t res = OK;
if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
Mutex::Autolock icl(mBinderSerializationLock);
if (!mDevice.get()) return DEAD_OBJECT;
if (info != NULL) {
*info = mDevice->info(); // static camera metadata
}
return res;
}
Commit Message: Camera: Disallow dumping clients directly
Camera service dumps should only be initiated through
ICameraService::dump.
Bug: 26265403
Change-Id: If3ca4718ed74bf33ad8a416192689203029e2803
CWE ID: CWE-264 | 0 | 161,817 |
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 GLES2DecoderImpl::DoGetRenderbufferParameteriv(
GLenum target, GLenum pname, GLint* params) {
RenderbufferManager::RenderbufferInfo* renderbuffer =
GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
if (!renderbuffer) {
SetGLError(GL_INVALID_OPERATION,
"glGetRenderbufferParameteriv", "no renderbuffer bound");
return;
}
switch (pname) {
case GL_RENDERBUFFER_INTERNAL_FORMAT:
*params = renderbuffer->internal_format();
break;
case GL_RENDERBUFFER_WIDTH:
*params = renderbuffer->width();
break;
case GL_RENDERBUFFER_HEIGHT:
*params = renderbuffer->height();
break;
default:
glGetRenderbufferParameterivEXT(target, pname, params);
break;
}
}
Commit Message: Fix SafeAdd and SafeMultiply
BUG=145648,145544
Review URL: https://chromiumcodereview.appspot.com/10916165
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155478 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-189 | 0 | 103,535 |
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 char **GetTransformTokens(void *context,const char *text,
int *number_tokens)
{
char
**tokens;
register const char
*p,
*q;
register ssize_t
i;
SVGInfo
*svg_info;
svg_info=(SVGInfo *) context;
*number_tokens=0;
if (text == (const char *) NULL)
return((char **) NULL);
/*
Determine the number of arguments.
*/
for (p=text; *p != '\0'; p++)
{
if (*p == '(')
(*number_tokens)+=2;
}
tokens=(char **) AcquireQuantumMemory(*number_tokens+2UL,sizeof(*tokens));
if (tokens == (char **) NULL)
{
(void) ThrowMagickException(svg_info->exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",text);
return((char **) NULL);
}
/*
Convert string to an ASCII list.
*/
i=0;
p=text;
for (q=p; *q != '\0'; q++)
{
if ((*q != '(') && (*q != ')') && (*q != '\0'))
continue;
tokens[i]=AcquireString(p);
(void) CopyMagickString(tokens[i],p,(size_t) (q-p+1));
StripString(tokens[i++]);
p=q+1;
}
tokens[i]=AcquireString(p);
(void) CopyMagickString(tokens[i],p,(size_t) (q-p+1));
StripString(tokens[i++]);
tokens[i]=(char *) NULL;
return(tokens);
}
Commit Message:
CWE ID: CWE-119 | 0 | 71,712 |
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 __perf_event_task_sched_out(struct task_struct *task,
struct task_struct *next)
{
int ctxn;
if (__this_cpu_read(perf_sched_cb_usages))
perf_pmu_sched_task(task, next, false);
if (atomic_read(&nr_switch_events))
perf_event_switch(task, next, false);
for_each_task_context_nr(ctxn)
perf_event_context_sched_out(task, ctxn, next);
/*
* if cgroup events exist on this CPU, then we need
* to check if we have to switch out PMU state.
* cgroup event are system-wide mode only
*/
if (atomic_read(this_cpu_ptr(&perf_cgroup_events)))
perf_cgroup_sched_out(task, next);
}
Commit Message: perf: Fix race in swevent hash
There's a race on CPU unplug where we free the swevent hash array
while it can still have events on. This will result in a
use-after-free which is BAD.
Simply do not free the hash array on unplug. This leaves the thing
around and no use-after-free takes place.
When the last swevent dies, we do a for_each_possible_cpu() iteration
anyway to clean these up, at which time we'll free it, so no leakage
will occur.
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
CWE ID: CWE-416 | 0 | 56,027 |
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 GLES2DecoderImpl::ValidateUniformBlockBackings(const char* func_name) {
DCHECK(feature_info_->IsWebGL2OrES3Context());
if (!state_.current_program.get())
return true;
int32_t max_index = -1;
for (auto info : state_.current_program->uniform_block_size_info()) {
int32_t index = static_cast<int32_t>(info.binding);
if (index > max_index)
max_index = index;
}
if (max_index < 0)
return true;
std::vector<GLsizeiptr> uniform_block_sizes(max_index + 1);
for (int32_t ii = 0; ii <= max_index; ++ii)
uniform_block_sizes[ii] = 0;
for (auto info : state_.current_program->uniform_block_size_info()) {
uint32_t index = info.binding;
uniform_block_sizes[index] = static_cast<GLsizeiptr>(info.data_size);
}
return buffer_manager()->RequestBuffersAccess(
error_state_.get(), state_.indexed_uniform_buffer_bindings.get(),
uniform_block_sizes, 1, func_name, "uniform buffers");
}
Commit Message: Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM
This makes the query of GL_COMPLETION_STATUS_KHR to programs much
cheaper by minimizing the round-trip to the GPU thread.
Bug: 881152, 957001
Change-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657568}
CWE ID: CWE-416 | 0 | 141,696 |
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 did_receive_event() { return did_receive_event_; }
Commit Message: Add a check for disallowing remote frame navigations to local resources.
Previously, RemoteFrame navigations did not perform any renderer-side
checks and relied solely on the browser-side logic to block disallowed
navigations via mechanisms like FilterURL. This means that blocked
remote frame navigations were silently navigated to about:blank
without any console error message.
This CL adds a CanDisplay check to the remote navigation path to match
an equivalent check done for local frame navigations. This way, the
renderer can consistently block disallowed navigations in both cases
and output an error message.
Bug: 894399
Change-Id: I172f68f77c1676f6ca0172d2a6c78f7edc0e3b7a
Reviewed-on: https://chromium-review.googlesource.com/c/1282390
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601022}
CWE ID: CWE-732 | 0 | 143,934 |
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 ContentSecurityPolicy::ExperimentalFeaturesEnabled() const {
return RuntimeEnabledFeatures::
ExperimentalContentSecurityPolicyFeaturesEnabled();
}
Commit Message: Inherit the navigation initiator when navigating instead of the parent/opener
Spec PR: https://github.com/w3c/webappsec-csp/pull/358
Bug: 905301, 894228, 836148
Change-Id: I43ada2266d42d1cd56dbe3c6dd89d115e878a83a
Reviewed-on: https://chromium-review.googlesource.com/c/1314633
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610850}
CWE ID: CWE-20 | 0 | 152,484 |
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: android::SoftOMXComponent *createSoftOMXComponent(
const char *name, const OMX_CALLBACKTYPE *callbacks,
OMX_PTR appData, OMX_COMPONENTTYPE **component) {
return new android::SoftMPEG4Encoder(name, callbacks, appData, component);
}
Commit Message: codecs: handle onReset() for a few encoders
Test: Run PoC binaries
Bug: 34749392
Bug: 34705519
Change-Id: I3356eb615b0e79272d71d72578d363671038c6dd
CWE ID: | 0 | 162,478 |
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: Status IndexedDBDatabase::PutOperation(
std::unique_ptr<PutOperationParams> params,
IndexedDBTransaction* transaction) {
IDB_TRACE2("IndexedDBDatabase::PutOperation", "txn.id", transaction->id(),
"size", params->value.SizeEstimate());
DCHECK_NE(transaction->mode(), blink::kWebIDBTransactionModeReadOnly);
bool key_was_generated = false;
Status s = Status::OK();
DCHECK(metadata_.object_stores.find(params->object_store_id) !=
metadata_.object_stores.end());
const IndexedDBObjectStoreMetadata& object_store =
metadata_.object_stores[params->object_store_id];
DCHECK(object_store.auto_increment || params->key->IsValid());
std::unique_ptr<IndexedDBKey> key;
if (params->put_mode != blink::kWebIDBPutModeCursorUpdate &&
object_store.auto_increment && !params->key->IsValid()) {
std::unique_ptr<IndexedDBKey> auto_inc_key = GenerateKey(
backing_store_.get(), transaction, id(), params->object_store_id);
key_was_generated = true;
if (!auto_inc_key->IsValid()) {
params->callbacks->OnError(
IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionConstraintError,
"Maximum key generator value reached."));
return s;
}
key = std::move(auto_inc_key);
} else {
key = std::move(params->key);
}
DCHECK(key->IsValid());
IndexedDBBackingStore::RecordIdentifier record_identifier;
if (params->put_mode == blink::kWebIDBPutModeAddOnly) {
bool found = false;
Status found_status = backing_store_->KeyExistsInObjectStore(
transaction->BackingStoreTransaction(), id(), params->object_store_id,
*key, &record_identifier, &found);
if (!found_status.ok())
return found_status;
if (found) {
params->callbacks->OnError(
IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionConstraintError,
"Key already exists in the object store."));
return found_status;
}
}
std::vector<std::unique_ptr<IndexWriter>> index_writers;
base::string16 error_message;
bool obeys_constraints = false;
bool backing_store_success = MakeIndexWriters(transaction,
backing_store_.get(),
id(),
object_store,
*key,
key_was_generated,
params->index_keys,
&index_writers,
&error_message,
&obeys_constraints);
if (!backing_store_success) {
params->callbacks->OnError(IndexedDBDatabaseError(
blink::kWebIDBDatabaseExceptionUnknownError,
"Internal error: backing store error updating index keys."));
return s;
}
if (!obeys_constraints) {
params->callbacks->OnError(IndexedDBDatabaseError(
blink::kWebIDBDatabaseExceptionConstraintError, error_message));
return s;
}
s = backing_store_->PutRecord(transaction->BackingStoreTransaction(), id(),
params->object_store_id, *key, ¶ms->value,
¶ms->handles, &record_identifier);
if (!s.ok())
return s;
{
IDB_TRACE1("IndexedDBDatabase::PutOperation.UpdateIndexes", "txn.id",
transaction->id());
for (const auto& writer : index_writers) {
writer->WriteIndexKeys(record_identifier, backing_store_.get(),
transaction->BackingStoreTransaction(), id(),
params->object_store_id);
}
}
if (object_store.auto_increment &&
params->put_mode != blink::kWebIDBPutModeCursorUpdate &&
key->type() == kWebIDBKeyTypeNumber) {
IDB_TRACE1("IndexedDBDatabase::PutOperation.AutoIncrement", "txn.id",
transaction->id());
s = UpdateKeyGenerator(backing_store_.get(), transaction, id(),
params->object_store_id, *key, !key_was_generated);
if (!s.ok())
return s;
}
{
IDB_TRACE1("IndexedDBDatabase::PutOperation.Callbacks", "txn.id",
transaction->id());
params->callbacks->OnSuccess(*key);
}
FilterObservation(transaction, params->object_store_id,
params->put_mode == blink::kWebIDBPutModeAddOnly
? blink::kWebIDBAdd
: blink::kWebIDBPut,
IndexedDBKeyRange(*key), ¶ms->value);
factory_->NotifyIndexedDBContentChanged(
origin(), metadata_.name,
metadata_.object_stores[params->object_store_id].name);
return s;
}
Commit Message: [IndexedDB] Fixing early destruction of connection during forceclose
Patch is as small as possible for merging.
Bug: 842990
Change-Id: I9968ffee1bf3279e61e1ec13e4d541f713caf12f
Reviewed-on: https://chromium-review.googlesource.com/1062935
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559383}
CWE ID: | 0 | 155,456 |
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 cred_to_ucred(struct pid *pid, const struct cred *cred,
struct ucred *ucred)
{
ucred->pid = pid_vnr(pid);
ucred->uid = ucred->gid = -1;
if (cred) {
struct user_namespace *current_ns = current_user_ns();
ucred->uid = from_kuid(current_ns, cred->euid);
ucred->gid = from_kgid(current_ns, cred->egid);
}
}
Commit Message: net: sock: validate data_len before allocating skb in sock_alloc_send_pskb()
We need to validate the number of pages consumed by data_len, otherwise frags
array could be overflowed by userspace. So this patch validate data_len and
return -EMSGSIZE when data_len may occupies more frags than MAX_SKB_FRAGS.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-20 | 0 | 20,116 |
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 PageHuge(struct page *page)
{
if (!PageCompound(page))
return 0;
page = compound_head(page);
return page[1].compound_dtor == HUGETLB_PAGE_DTOR;
}
Commit Message: userfaultfd: hugetlbfs: prevent UFFDIO_COPY to fill beyond the end of i_size
This oops:
kernel BUG at fs/hugetlbfs/inode.c:484!
RIP: remove_inode_hugepages+0x3d0/0x410
Call Trace:
hugetlbfs_setattr+0xd9/0x130
notify_change+0x292/0x410
do_truncate+0x65/0xa0
do_sys_ftruncate.constprop.3+0x11a/0x180
SyS_ftruncate+0xe/0x10
tracesys+0xd9/0xde
was caused by the lack of i_size check in hugetlb_mcopy_atomic_pte.
mmap() can still succeed beyond the end of the i_size after vmtruncate
zapped vmas in those ranges, but the faults must not succeed, and that
includes UFFDIO_COPY.
We could differentiate the retval to userland to represent a SIGBUS like
a page fault would do (vs SIGSEGV), but it doesn't seem very useful and
we'd need to pick a random retval as there's no meaningful syscall
retval that would differentiate from SIGSEGV and SIGBUS, there's just
-EFAULT.
Link: http://lkml.kernel.org/r/20171016223914.2421-2-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-119 | 0 | 86,315 |
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 nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
{
struct nfs4_state *state = opendata->state;
struct nfs_inode *nfsi = NFS_I(state->inode);
struct nfs_delegation *delegation;
int open_mode = opendata->o_arg.open_flags & O_EXCL;
fmode_t fmode = opendata->o_arg.fmode;
nfs4_stateid stateid;
int ret = -EAGAIN;
for (;;) {
if (can_open_cached(state, fmode, open_mode)) {
spin_lock(&state->owner->so_lock);
if (can_open_cached(state, fmode, open_mode)) {
update_open_stateflags(state, fmode);
spin_unlock(&state->owner->so_lock);
goto out_return_state;
}
spin_unlock(&state->owner->so_lock);
}
rcu_read_lock();
delegation = rcu_dereference(nfsi->delegation);
if (!can_open_delegated(delegation, fmode)) {
rcu_read_unlock();
break;
}
/* Save the delegation */
memcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data));
rcu_read_unlock();
ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode);
if (ret != 0)
goto out;
ret = -EAGAIN;
/* Try to update the stateid using the delegation */
if (update_open_stateid(state, NULL, &stateid, fmode))
goto out_return_state;
}
out:
return ERR_PTR(ret);
out_return_state:
atomic_inc(&state->count);
return state;
}
Commit Message: NFSv4: include bitmap in nfsv4 get acl data
The NFSv4 bitmap size is unbounded: a server can return an arbitrary
sized bitmap in an FATTR4_WORD0_ACL request. Replace using the
nfs4_fattr_bitmap_maxsz as a guess to the maximum bitmask returned by a server
with the inclusion of the bitmap (xdr length plus bitmasks) and the acl data
xdr length to the (cached) acl page data.
This is a general solution to commit e5012d1f "NFSv4.1: update
nfs4_fattr_bitmap_maxsz" and fixes hitting a BUG_ON in xdr_shrink_bufhead
when getting ACLs.
Fix a bug in decode_getacl that returned -EINVAL on ACLs > page when getxattr
was called with a NULL buffer, preventing ACL > PAGE_SIZE from being retrieved.
Cc: stable@kernel.org
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
CWE ID: CWE-189 | 0 | 23,245 |
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 tst_QQuickWebView::loadEmptyPageViewHidden()
{
QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebLoadRequest*)));
webView()->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
QVERIFY(waitForLoadSucceeded(webView()));
QCOMPARE(loadSpy.size(), 2);
}
Commit Message: [Qt][WK2] Allow transparent WebViews
https://bugs.webkit.org/show_bug.cgi?id=80608
Reviewed by Tor Arne Vestbø.
Added support for transparentBackground in QQuickWebViewExperimental.
This uses the existing drawsTransparentBackground property in WebKit2.
Also, changed LayerTreeHostQt to set the contentsOpaque flag when the root layer changes,
otherwise the change doesn't take effect.
A new API test was added.
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::setTransparentBackground):
(QQuickWebViewPrivate::transparentBackground):
(QQuickWebViewExperimental::transparentBackground):
(QQuickWebViewExperimental::setTransparentBackground):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate):
* UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
(tst_QQuickWebView):
(tst_QQuickWebView::transparentWebViews):
* WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
(WebKit::LayerTreeHostQt::LayerTreeHostQt):
(WebKit::LayerTreeHostQt::setRootCompositingLayer):
git-svn-id: svn://svn.chromium.org/blink/trunk@110254 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-189 | 0 | 101,811 |
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: uint32_t get_hex(char **p, int DefaultValue)
{
uint32_t Value = 0;
unsigned char UseDefault;
UseDefault = 1;
skip_blanks(p);
while ( ((**p)<= '9' && (**p)>= '0') ||
((**p)<= 'f' && (**p)>= 'a') ||
((**p)<= 'F' && (**p)>= 'A') )
{
if (**p >= 'a')
Value = Value * 16 + (**p) - 'a' + 10;
else if (**p >= 'A')
Value = Value * 16 + (**p) - 'A' + 10;
else
Value = Value * 16 + (**p) - '0';
UseDefault = 0;
(*p)++;
}
if (UseDefault)
return DefaultValue;
else
return Value;
}
Commit Message: Add guest mode functionality (2/3)
Add a flag to enable() to start Bluetooth in restricted
mode. In restricted mode, all devices that are paired during
restricted mode are deleted upon leaving restricted mode.
Right now restricted mode is only entered while a guest
user is active.
Bug: 27410683
Change-Id: I8f23d28ef0aa3a8df13d469c73005c8e1b894d19
CWE ID: CWE-20 | 0 | 159,730 |
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: const char *FS_ReferencedPakNames( void ) {
static char info[BIG_INFO_STRING];
searchpath_t *search;
info[0] = 0;
for ( search = fs_searchpaths ; search ; search = search->next ) {
if ( search->pack ) {
if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, com_basegame->string, strlen(com_basegame->string))) {
if (*info) {
Q_strcat(info, sizeof( info ), " " );
}
Q_strcat( info, sizeof( info ), search->pack->pakGamename );
Q_strcat( info, sizeof( info ), "/" );
Q_strcat( info, sizeof( info ), search->pack->pakBasename );
}
}
}
return info;
}
Commit Message: All: Don't load .pk3s as .dlls, and don't load user config files from .pk3s
CWE ID: CWE-269 | 0 | 95,818 |
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 BrowserViewRenderer::SetDipScale(float dip_scale) {
dip_scale_ = dip_scale;
CHECK_GT(dip_scale_, 0.f);
}
Commit Message: sync compositor: pass simple gfx types by const ref
See bug for reasoning
BUG=159273
Review URL: https://codereview.chromium.org/1417893006
Cr-Commit-Position: refs/heads/master@{#356653}
CWE ID: CWE-399 | 0 | 119,545 |
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 jp2_pclr_dumpdata(jp2_box_t *box, FILE *out)
{
jp2_pclr_t *pclr = &box->data.pclr;
unsigned int i;
int j;
fprintf(out, "numents=%d; numchans=%d\n", (int) pclr->numlutents,
(int) pclr->numchans);
for (i = 0; i < pclr->numlutents; ++i) {
for (j = 0; j < pclr->numchans; ++j) {
fprintf(out, "LUT[%d][%d]=%"PRIiFAST32"\n", i, j,
pclr->lutdata[i * pclr->numchans + j]);
}
}
}
Commit Message: Fixed bugs due to uninitialized data in the JP2 decoder.
Also, added some comments marking I/O stream interfaces that probably
need to be changed (in the long term) to fix integer overflow problems.
CWE ID: CWE-476 | 0 | 67,973 |
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 PDFiumEngine::Form_Mail(IPDF_JSPLATFORM* param,
void* mail_data,
int length,
FPDF_BOOL ui,
FPDF_WIDESTRING to,
FPDF_WIDESTRING subject,
FPDF_WIDESTRING cc,
FPDF_WIDESTRING bcc,
FPDF_WIDESTRING message) {
std::string to_str =
base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(to));
std::string cc_str =
base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(cc));
std::string bcc_str =
base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(bcc));
std::string subject_str =
base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(subject));
std::string message_str =
base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(message));
PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
engine->client_->Email(to_str, cc_str, bcc_str, subject_str, message_str);
}
Commit Message: [pdf] Defer page unloading in JS callback.
One of the callbacks from PDFium JavaScript into the embedder is to get the
current page number. In Chromium, this will trigger a call to
CalculateMostVisiblePage that method will determine the visible pages and unload
any non-visible pages. But, if the originating JS is on a non-visible page
we'll delete the page and annotations associated with that page. This will
cause issues as we are currently working with those objects when the JavaScript
returns.
This Cl defers the page unloading triggered by getting the most visible page
until the next event is handled by the Chromium embedder.
BUG=chromium:653090
Review-Url: https://codereview.chromium.org/2418533002
Cr-Commit-Position: refs/heads/master@{#424781}
CWE ID: CWE-416 | 0 | 140,301 |
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 _ewk_frame_smart_del(Evas_Object* ewkFrame)
{
EWK_FRAME_SD_GET(ewkFrame, smartData);
if (smartData) {
if (smartData->frame) {
WebCore::FrameLoaderClientEfl* flc = _ewk_frame_loader_efl_get(smartData->frame);
flc->setWebFrame(0);
smartData->frame->loader()->detachFromParent();
smartData->frame->loader()->cancelAndClear();
smartData->frame = 0;
}
eina_stringshare_del(smartData->title);
eina_stringshare_del(smartData->uri);
eina_stringshare_del(smartData->name);
}
_parent_sc.del(ewkFrame);
}
Commit Message: [EFL] fast/frames/frame-crash-with-page-cache.html is crashing
https://bugs.webkit.org/show_bug.cgi?id=85879
Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-05-17
Reviewed by Noam Rosenthal.
Source/WebKit/efl:
_ewk_frame_smart_del() is considering now that the frame can be present in cache.
loader()->detachFromParent() is only applied for the main frame.
loader()->cancelAndClear() is not used anymore.
* ewk/ewk_frame.cpp:
(_ewk_frame_smart_del):
LayoutTests:
* platform/efl/test_expectations.txt: Removed fast/frames/frame-crash-with-page-cache.html.
git-svn-id: svn://svn.chromium.org/blink/trunk@117409 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399 | 1 | 170,978 |
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 kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
{
return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0;
}
Commit Message: KVM: x86: Reload pit counters for all channels when restoring state
Currently if userspace restores the pit counters with a count of 0
on channels 1 or 2 and the guest attempts to read the count on those
channels, then KVM will perform a mod of 0 and crash. This will ensure
that 0 values are converted to 65536 as per the spec.
This is CVE-2015-7513.
Signed-off-by: Andy Honig <ahonig@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: | 0 | 57,774 |
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::OnUpdateWindowScreenRect(gfx::Rect window_screen_rect) {
RenderWidget::OnUpdateWindowScreenRect(window_screen_rect);
}
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 | 148,006 |
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: PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionState& exceptionState)
{
if (!isValidName(localName)) {
exceptionState.throwDOMException(InvalidCharacterError, "The tag name provided ('" + localName + "') is not a valid name.");
return nullptr;
}
RefPtrWillBeRawPtr<Element> element;
if (CustomElement::isValidName(localName) && registrationContext()) {
element = registrationContext()->createCustomTagElement(*this, QualifiedName(nullAtom, convertLocalName(localName), xhtmlNamespaceURI));
} else {
element = createElement(localName, exceptionState);
if (exceptionState.hadException())
return nullptr;
}
if (!typeExtension.isEmpty())
CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element.get(), typeExtension);
return element.release();
}
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,316 |
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: DeviceRequest(
int requesting_process_id,
int requesting_frame_id,
int page_request_id,
bool user_gesture,
MediaStreamRequestType request_type,
const StreamControls& controls,
MediaDeviceSaltAndOrigin salt_and_origin,
DeviceStoppedCallback device_stopped_cb = DeviceStoppedCallback())
: requesting_process_id(requesting_process_id),
requesting_frame_id(requesting_frame_id),
page_request_id(page_request_id),
user_gesture(user_gesture),
controls(controls),
salt_and_origin(std::move(salt_and_origin)),
device_stopped_cb(std::move(device_stopped_cb)),
state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED),
request_type_(request_type),
audio_type_(MEDIA_NO_SERVICE),
video_type_(MEDIA_NO_SERVICE),
target_process_id_(-1),
target_frame_id_(-1) {}
Commit Message: Make MediaStreamDispatcherHost per-request instead of per-frame.
Instead of having RenderFrameHost own a single MSDH to handle all
requests from a frame, MSDH objects will be owned by a strong binding.
A consequence of this is that an additional requester ID is added to
requests to MediaStreamManager, so that an MSDH is able to cancel only
requests generated by it.
In practice, MSDH will continue to be per frame in most cases since
each frame normally makes a single request for an MSDH object.
This fixes a lifetime issue caused by the IO thread executing tasks
after the RenderFrameHost dies.
Drive-by: Fix some minor lint issues.
Bug: 912520
Change-Id: I52742ffc98b9fc57ce8e6f5093a61aed86d3e516
Reviewed-on: https://chromium-review.googlesource.com/c/1369799
Reviewed-by: Emircan Uysaler <emircan@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Olga Sharonova <olka@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616347}
CWE ID: CWE-189 | 1 | 173,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: dist_pl_internal(Point *pt, LINE *line)
{
return fabs((line->A * pt->x + line->B * pt->y + line->C) /
HYPOT(line->A, line->B));
}
Commit Message: Predict integer overflow to avoid buffer overruns.
Several functions, mostly type input functions, calculated an allocation
size such that the calculation wrapped to a small positive value when
arguments implied a sufficiently-large requirement. Writes past the end
of the inadvertent small allocation followed shortly thereafter.
Coverity identified the path_in() vulnerability; code inspection led to
the rest. In passing, add check_stack_depth() to prevent stack overflow
in related functions.
Back-patch to 8.4 (all supported versions). The non-comment hstore
changes touch code that did not exist in 8.4, so that part stops at 9.0.
Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.
Security: CVE-2014-0064
CWE ID: CWE-189 | 0 | 38,884 |
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 V8Debugger* toV8Debugger(v8::Local<v8::Value> data)
{
void* p = v8::Local<v8::External>::Cast(data)->Value();
return static_cast<V8Debugger*>(p);
}
Commit Message: [DevTools] Copy objects from debugger context to inspected context properly.
BUG=637594
Review-Url: https://codereview.chromium.org/2253643002
Cr-Commit-Position: refs/heads/master@{#412436}
CWE ID: CWE-79 | 0 | 130,390 |
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 WebsiteSettings::PresentSiteData() {
CookieInfoList cookie_info_list;
const LocalSharedObjectsCounter& allowed_objects =
tab_specific_content_settings()->allowed_local_shared_objects();
const LocalSharedObjectsCounter& blocked_objects =
tab_specific_content_settings()->blocked_local_shared_objects();
WebsiteSettingsUI::CookieInfo cookie_info;
std::string cookie_source =
net::registry_controlled_domains::GetDomainAndRegistry(
site_url_,
net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
if (cookie_source.empty())
cookie_source = site_url_.host();
cookie_info.cookie_source = cookie_source;
cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
cookie_info_list.push_back(cookie_info);
cookie_info.cookie_source = l10n_util::GetStringUTF8(
IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
cookie_info_list.push_back(cookie_info);
ui_->SetCookieInfo(cookie_info_list);
}
Commit Message: Fix UAF in Origin Info Bubble and permission settings UI.
In addition to fixing the UAF, will this also fix the problem of the bubble
showing over the previous tab (if the bubble is open when the tab it was opened
for closes).
BUG=490492
TBR=tedchoc
Review URL: https://codereview.chromium.org/1317443002
Cr-Commit-Position: refs/heads/master@{#346023}
CWE ID: | 0 | 125,250 |
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 userfaultfd_unmap_prep(struct vm_area_struct *vma,
unsigned long start, unsigned long end,
struct list_head *unmaps)
{
for ( ; vma && vma->vm_start < end; vma = vma->vm_next) {
struct userfaultfd_unmap_ctx *unmap_ctx;
struct userfaultfd_ctx *ctx = vma->vm_userfaultfd_ctx.ctx;
if (!ctx || !(ctx->features & UFFD_FEATURE_EVENT_UNMAP) ||
has_unmap_ctx(ctx, unmaps, start, end))
continue;
unmap_ctx = kzalloc(sizeof(*unmap_ctx), GFP_KERNEL);
if (!unmap_ctx)
return -ENOMEM;
userfaultfd_ctx_get(ctx);
unmap_ctx->ctx = ctx;
unmap_ctx->start = start;
unmap_ctx->end = end;
list_add_tail(&unmap_ctx->list, unmaps);
}
return 0;
}
Commit Message: userfaultfd: non-cooperative: fix fork use after free
When reading the event from the uffd, we put it on a temporary
fork_event list to detect if we can still access it after releasing and
retaking the event_wqh.lock.
If fork aborts and removes the event from the fork_event all is fine as
long as we're still in the userfault read context and fork_event head is
still alive.
We've to put the event allocated in the fork kernel stack, back from
fork_event list-head to the event_wqh head, before returning from
userfaultfd_ctx_read, because the fork_event head lifetime is limited to
the userfaultfd_ctx_read stack lifetime.
Forgetting to move the event back to its event_wqh place then results in
__remove_wait_queue(&ctx->event_wqh, &ewq->wq); in
userfaultfd_event_wait_completion to remove it from a head that has been
already freed from the reader stack.
This could only happen if resolve_userfault_fork failed (for example if
there are no file descriptors available to allocate the fork uffd). If
it succeeded it was put back correctly.
Furthermore, after find_userfault_evt receives a fork event, the forked
userfault context in fork_nctx and uwq->msg.arg.reserved.reserved1 can
be released by the fork thread as soon as the event_wqh.lock is
released. Taking a reference on the fork_nctx before dropping the lock
prevents an use after free in resolve_userfault_fork().
If the fork side aborted and it already released everything, we still
try to succeed resolve_userfault_fork(), if possible.
Fixes: 893e26e61d04eac9 ("userfaultfd: non-cooperative: Add fork() event")
Link: http://lkml.kernel.org/r/20170920180413.26713-1-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Reported-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-416 | 0 | 86,467 |
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: SWFShape_addLineStyle(SWFShape shape, unsigned short width,
byte r, byte g, byte b, byte a)
{
growLineArray(shape);
shape->lines[shape->nLines] = newSWFLineStyle(width, r, g, b, a);
return ++shape->nLines;
}
Commit Message: SWFShape_setLeftFillStyle: prevent fill overflow
CWE ID: CWE-119 | 0 | 89,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: ppp_disconnect_channel(struct channel *pch)
{
struct ppp *ppp;
int err = -EINVAL;
write_lock_bh(&pch->upl);
ppp = pch->ppp;
pch->ppp = NULL;
write_unlock_bh(&pch->upl);
if (ppp) {
/* remove it from the ppp unit's list */
ppp_lock(ppp);
list_del(&pch->clist);
if (--ppp->n_channels == 0)
wake_up_interruptible(&ppp->file.rwait);
ppp_unlock(ppp);
if (atomic_dec_and_test(&ppp->file.refcnt))
ppp_destroy_interface(ppp);
err = 0;
}
return err;
}
Commit Message: ppp: take reference on channels netns
Let channels hold a reference on their network namespace.
Some channel types, like ppp_async and ppp_synctty, can have their
userspace controller running in a different namespace. Therefore they
can't rely on them to preclude their netns from being removed from
under them.
==================================================================
BUG: KASAN: use-after-free in ppp_unregister_channel+0x372/0x3a0 at
addr ffff880064e217e0
Read of size 8 by task syz-executor/11581
=============================================================================
BUG net_namespace (Not tainted): kasan: bad access detected
-----------------------------------------------------------------------------
Disabling lock debugging due to kernel taint
INFO: Allocated in copy_net_ns+0x6b/0x1a0 age=92569 cpu=3 pid=6906
[< none >] ___slab_alloc+0x4c7/0x500 kernel/mm/slub.c:2440
[< none >] __slab_alloc+0x4c/0x90 kernel/mm/slub.c:2469
[< inline >] slab_alloc_node kernel/mm/slub.c:2532
[< inline >] slab_alloc kernel/mm/slub.c:2574
[< none >] kmem_cache_alloc+0x23a/0x2b0 kernel/mm/slub.c:2579
[< inline >] kmem_cache_zalloc kernel/include/linux/slab.h:597
[< inline >] net_alloc kernel/net/core/net_namespace.c:325
[< none >] copy_net_ns+0x6b/0x1a0 kernel/net/core/net_namespace.c:360
[< none >] create_new_namespaces+0x2f6/0x610 kernel/kernel/nsproxy.c:95
[< none >] copy_namespaces+0x297/0x320 kernel/kernel/nsproxy.c:150
[< none >] copy_process.part.35+0x1bf4/0x5760 kernel/kernel/fork.c:1451
[< inline >] copy_process kernel/kernel/fork.c:1274
[< none >] _do_fork+0x1bc/0xcb0 kernel/kernel/fork.c:1723
[< inline >] SYSC_clone kernel/kernel/fork.c:1832
[< none >] SyS_clone+0x37/0x50 kernel/kernel/fork.c:1826
[< none >] entry_SYSCALL_64_fastpath+0x16/0x7a kernel/arch/x86/entry/entry_64.S:185
INFO: Freed in net_drop_ns+0x67/0x80 age=575 cpu=2 pid=2631
[< none >] __slab_free+0x1fc/0x320 kernel/mm/slub.c:2650
[< inline >] slab_free kernel/mm/slub.c:2805
[< none >] kmem_cache_free+0x2a0/0x330 kernel/mm/slub.c:2814
[< inline >] net_free kernel/net/core/net_namespace.c:341
[< none >] net_drop_ns+0x67/0x80 kernel/net/core/net_namespace.c:348
[< none >] cleanup_net+0x4e5/0x600 kernel/net/core/net_namespace.c:448
[< none >] process_one_work+0x794/0x1440 kernel/kernel/workqueue.c:2036
[< none >] worker_thread+0xdb/0xfc0 kernel/kernel/workqueue.c:2170
[< none >] kthread+0x23f/0x2d0 kernel/drivers/block/aoe/aoecmd.c:1303
[< none >] ret_from_fork+0x3f/0x70 kernel/arch/x86/entry/entry_64.S:468
INFO: Slab 0xffffea0001938800 objects=3 used=0 fp=0xffff880064e20000
flags=0x5fffc0000004080
INFO: Object 0xffff880064e20000 @offset=0 fp=0xffff880064e24200
CPU: 1 PID: 11581 Comm: syz-executor Tainted: G B 4.4.0+
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
00000000ffffffff ffff8800662c7790 ffffffff8292049d ffff88003e36a300
ffff880064e20000 ffff880064e20000 ffff8800662c77c0 ffffffff816f2054
ffff88003e36a300 ffffea0001938800 ffff880064e20000 0000000000000000
Call Trace:
[< inline >] __dump_stack kernel/lib/dump_stack.c:15
[<ffffffff8292049d>] dump_stack+0x6f/0xa2 kernel/lib/dump_stack.c:50
[<ffffffff816f2054>] print_trailer+0xf4/0x150 kernel/mm/slub.c:654
[<ffffffff816f875f>] object_err+0x2f/0x40 kernel/mm/slub.c:661
[< inline >] print_address_description kernel/mm/kasan/report.c:138
[<ffffffff816fb0c5>] kasan_report_error+0x215/0x530 kernel/mm/kasan/report.c:236
[< inline >] kasan_report kernel/mm/kasan/report.c:259
[<ffffffff816fb4de>] __asan_report_load8_noabort+0x3e/0x40 kernel/mm/kasan/report.c:280
[< inline >] ? ppp_pernet kernel/include/linux/compiler.h:218
[<ffffffff83ad71b2>] ? ppp_unregister_channel+0x372/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392
[< inline >] ppp_pernet kernel/include/linux/compiler.h:218
[<ffffffff83ad71b2>] ppp_unregister_channel+0x372/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392
[< inline >] ? ppp_pernet kernel/drivers/net/ppp/ppp_generic.c:293
[<ffffffff83ad6f26>] ? ppp_unregister_channel+0xe6/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392
[<ffffffff83ae18f3>] ppp_asynctty_close+0xa3/0x130 kernel/drivers/net/ppp/ppp_async.c:241
[<ffffffff83ae1850>] ? async_lcp_peek+0x5b0/0x5b0 kernel/drivers/net/ppp/ppp_async.c:1000
[<ffffffff82c33239>] tty_ldisc_close.isra.1+0x99/0xe0 kernel/drivers/tty/tty_ldisc.c:478
[<ffffffff82c332c0>] tty_ldisc_kill+0x40/0x170 kernel/drivers/tty/tty_ldisc.c:744
[<ffffffff82c34943>] tty_ldisc_release+0x1b3/0x260 kernel/drivers/tty/tty_ldisc.c:772
[<ffffffff82c1ef21>] tty_release+0xac1/0x13e0 kernel/drivers/tty/tty_io.c:1901
[<ffffffff82c1e460>] ? release_tty+0x320/0x320 kernel/drivers/tty/tty_io.c:1688
[<ffffffff8174de36>] __fput+0x236/0x780 kernel/fs/file_table.c:208
[<ffffffff8174e405>] ____fput+0x15/0x20 kernel/fs/file_table.c:244
[<ffffffff813595ab>] task_work_run+0x16b/0x200 kernel/kernel/task_work.c:115
[< inline >] exit_task_work kernel/include/linux/task_work.h:21
[<ffffffff81307105>] do_exit+0x8b5/0x2c60 kernel/kernel/exit.c:750
[<ffffffff813fdd20>] ? debug_check_no_locks_freed+0x290/0x290 kernel/kernel/locking/lockdep.c:4123
[<ffffffff81306850>] ? mm_update_next_owner+0x6f0/0x6f0 kernel/kernel/exit.c:357
[<ffffffff813215e6>] ? __dequeue_signal+0x136/0x470 kernel/kernel/signal.c:550
[<ffffffff8132067b>] ? recalc_sigpending_tsk+0x13b/0x180 kernel/kernel/signal.c:145
[<ffffffff81309628>] do_group_exit+0x108/0x330 kernel/kernel/exit.c:880
[<ffffffff8132b9d4>] get_signal+0x5e4/0x14f0 kernel/kernel/signal.c:2307
[< inline >] ? kretprobe_table_lock kernel/kernel/kprobes.c:1113
[<ffffffff8151d355>] ? kprobe_flush_task+0xb5/0x450 kernel/kernel/kprobes.c:1158
[<ffffffff8115f7d3>] do_signal+0x83/0x1c90 kernel/arch/x86/kernel/signal.c:712
[<ffffffff8151d2a0>] ? recycle_rp_inst+0x310/0x310 kernel/include/linux/list.h:655
[<ffffffff8115f750>] ? setup_sigcontext+0x780/0x780 kernel/arch/x86/kernel/signal.c:165
[<ffffffff81380864>] ? finish_task_switch+0x424/0x5f0 kernel/kernel/sched/core.c:2692
[< inline >] ? finish_lock_switch kernel/kernel/sched/sched.h:1099
[<ffffffff81380560>] ? finish_task_switch+0x120/0x5f0 kernel/kernel/sched/core.c:2678
[< inline >] ? context_switch kernel/kernel/sched/core.c:2807
[<ffffffff85d794e9>] ? __schedule+0x919/0x1bd0 kernel/kernel/sched/core.c:3283
[<ffffffff81003901>] exit_to_usermode_loop+0xf1/0x1a0 kernel/arch/x86/entry/common.c:247
[< inline >] prepare_exit_to_usermode kernel/arch/x86/entry/common.c:282
[<ffffffff810062ef>] syscall_return_slowpath+0x19f/0x210 kernel/arch/x86/entry/common.c:344
[<ffffffff85d88022>] int_ret_from_sys_call+0x25/0x9f kernel/arch/x86/entry/entry_64.S:281
Memory state around the buggy address:
ffff880064e21680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff880064e21700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff880064e21780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff880064e21800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff880064e21880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Fixes: 273ec51dd7ce ("net: ppp_generic - introduce net-namespace functionality v2")
Reported-by: Baozeng Ding <sploving1@gmail.com>
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-416 | 0 | 52,624 |
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 DesktopWindowTreeHostX11::SetFullscreen(bool fullscreen) {
if (is_fullscreen_ == fullscreen)
return;
is_fullscreen_ = fullscreen;
if (is_fullscreen_)
delayed_resize_task_.Cancel();
bool unmaximize_and_remaximize = !fullscreen && IsMaximized() &&
ui::GuessWindowManager() == ui::WM_METACITY;
if (unmaximize_and_remaximize)
Restore();
SetWMSpecState(fullscreen, gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"),
x11::None);
if (unmaximize_and_remaximize)
Maximize();
if (fullscreen) {
restored_bounds_in_pixels_ = bounds_in_pixels_;
const display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(window());
bounds_in_pixels_ = ToPixelRect(display.bounds());
} else {
bounds_in_pixels_ = restored_bounds_in_pixels_;
}
OnHostMovedInPixels(bounds_in_pixels_.origin());
OnHostResizedInPixels(bounds_in_pixels_.size());
if (ui::HasWMSpecProperty(window_properties_,
gfx::GetAtom("_NET_WM_STATE_FULLSCREEN")) ==
fullscreen) {
Relayout();
ResetWindowRegion();
}
}
Commit Message: Fix PIP window being blank after minimize/show
DesktopWindowTreeHostX11::SetVisible only made the call into
OnNativeWidgetVisibilityChanged when transitioning from shown
to minimized and not vice versa. This is because this change
https://chromium-review.googlesource.com/c/chromium/src/+/1437263
considered IsVisible to be true when minimized, which made
IsVisible always true in this case. This caused layers to be hidden
but never shown again.
This is a reland of:
https://chromium-review.googlesource.com/c/chromium/src/+/1580103
Bug: 949199
Change-Id: I2151cd09e537d8ce8781897f43a3b8e9cec75996
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1584617
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: enne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654280}
CWE ID: CWE-284 | 0 | 140,591 |
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: JsArgList SyncManager::SyncInternal::GetClientServerTraffic(
const JsArgList& args) {
ListValue return_args;
ListValue* value = traffic_recorder_.ToValue();
if (value != NULL)
return_args.Append(value);
return JsArgList(&return_args);
}
Commit Message: [Sync] Cleanup all tab sync enabling logic now that its on by default.
BUG=none
TEST=
Review URL: https://chromiumcodereview.appspot.com/10443046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139462 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-362 | 0 | 105,126 |
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 GetManifestAndIssuedRequests() {
base::RunLoop run_loop;
browser()->tab_strip_model()->GetActiveWebContents()->GetManifest(
base::Bind(&ManifestCallbackAndRun, run_loop.QuitClosure()));
run_loop.Run();
return ExecuteScriptAndExtractString(
"if (issuedRequests.length != 0) reportRequests();"
"else reportOnFetch = true;");
}
Commit Message: Skip Service workers in requests for mime handler plugins
BUG=808838
TEST=./browser_tests --gtest_filter=*/ServiceWorkerTest.MimeHandlerView*
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I82e75c200091babbab648a04232db47e2938d914
Reviewed-on: https://chromium-review.googlesource.com/914150
Commit-Queue: Rob Wu <rob@robwu.nl>
Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537386}
CWE ID: CWE-20 | 0 | 147,424 |
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 ProfileSyncService::HasSyncSetupCompleted() const {
return sync_prefs_.HasSyncSetupCompleted();
}
Commit Message: [Sync] Cleanup all tab sync enabling logic now that its on by default.
BUG=none
TEST=
Review URL: https://chromiumcodereview.appspot.com/10443046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139462 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-362 | 0 | 104,942 |
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 Sp_charAt(js_State *J)
{
char buf[UTFmax + 1];
const char *s = checkstring(J, 0);
int pos = js_tointeger(J, 1);
Rune rune = js_runeat(J, s, pos);
if (rune > 0) {
buf[runetochar(buf, &rune)] = 0;
js_pushstring(J, buf);
} else {
js_pushliteral(J, "");
}
}
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,654 |
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 virtio_gpu_get_display_info(VirtIOGPU *g,
struct virtio_gpu_ctrl_command *cmd)
{
struct virtio_gpu_resp_display_info display_info;
trace_virtio_gpu_cmd_get_display_info();
memset(&display_info, 0, sizeof(display_info));
display_info.hdr.type = VIRTIO_GPU_RESP_OK_DISPLAY_INFO;
virtio_gpu_fill_display_info(g, &display_info);
virtio_gpu_ctrl_response(g, cmd, &display_info.hdr,
sizeof(display_info));
}
Commit Message:
CWE ID: CWE-772 | 0 | 6,244 |
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: gs_heap_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
{
gs_malloc_memory_t *mmem = (gs_malloc_memory_t *) mem;
gs_malloc_block_t *bp;
gs_memory_type_ptr_t pstype;
struct_proc_finalize((*finalize));
if_debug3m('a', mem, "[a-]gs_free(%s) 0x%lx(%u)\n",
client_name_string(cname), (ulong) ptr,
(ptr == 0 ? 0 : ((gs_malloc_block_t *) ptr)[-1].size));
if (ptr == 0)
return;
pstype = ((gs_malloc_block_t *) ptr)[-1].type;
finalize = pstype->finalize;
if (finalize != 0) {
if_debug3m('u', mem, "[u]finalizing %s 0x%lx (%s)\n",
struct_type_name_string(pstype),
(ulong) ptr, client_name_string(cname));
(*finalize) (mem, ptr);
}
if (mmem->monitor)
gx_monitor_enter(mmem->monitor); /* Exclusive access */
/* Previously, we used to search through every allocated block to find
* the block we are freeing. This gives us safety in that an attempt to
* free an unallocated block will not go wrong. This does radically
* slow down frees though, so we replace it with this simpler code; we
* now assume that the block is valid, and hence avoid the search.
*/
#if 1
bp = &((gs_malloc_block_t *)ptr)[-1];
if (bp->prev)
bp->prev->next = bp->next;
if (bp->next)
bp->next->prev = bp->prev;
if (bp == mmem->allocated) {
mmem->allocated = bp->next;
mmem->allocated->prev = NULL;
}
mmem->used -= bp->size + sizeof(gs_malloc_block_t);
if (mmem->monitor)
gx_monitor_leave(mmem->monitor); /* Done with exclusive access */
gs_alloc_fill(bp, gs_alloc_fill_free,
bp->size + sizeof(gs_malloc_block_t));
free(bp);
#else
bp = mmem->allocated; /* If 'finalize' releases a memory,
this function could be called recursively and
change mmem->allocated. */
if (ptr == bp + 1) {
mmem->allocated = bp->next;
mmem->used -= bp->size + sizeof(gs_malloc_block_t);
if (mmem->allocated)
mmem->allocated->prev = 0;
if (mmem->monitor)
gx_monitor_leave(mmem->monitor); /* Done with exclusive access */
gs_alloc_fill(bp, gs_alloc_fill_free,
bp->size + sizeof(gs_malloc_block_t));
free(bp);
} else {
gs_malloc_block_t *np;
/*
* bp == 0 at this point is an error, but we'd rather have an
* error message than an invalid access.
*/
if (bp) {
for (; (np = bp->next) != 0; bp = np) {
if (ptr == np + 1) {
bp->next = np->next;
if (np->next)
np->next->prev = bp;
mmem->used -= np->size + sizeof(gs_malloc_block_t);
if (mmem->monitor)
gx_monitor_leave(mmem->monitor); /* Done with exclusive access */
gs_alloc_fill(np, gs_alloc_fill_free,
np->size + sizeof(gs_malloc_block_t));
free(np);
return;
}
}
}
if (mmem->monitor)
gx_monitor_leave(mmem->monitor); /* Done with exclusive access */
lprintf2("%s: free 0x%lx not found!\n",
client_name_string(cname), (ulong) ptr);
free((char *)((gs_malloc_block_t *) ptr - 1));
}
#endif
}
Commit Message:
CWE ID: CWE-189 | 0 | 3,542 |
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: map_get_camera_xy(void)
{
return mk_point2(s_camera_x, s_camera_y);
}
Commit Message: Fix integer overflow in layer_resize in map_engine.c (#268)
* Fix integer overflow in layer_resize in map_engine.c
There's a buffer overflow bug in the function layer_resize. It allocates
a buffer `tilemap` with size `x_size * y_size * sizeof(struct map_tile)`.
But it didn't check for integer overflow, so if x_size and y_size are
very large, it's possible that the buffer size is smaller than needed,
causing a buffer overflow later.
PoC: `SetLayerSize(0, 0x7FFFFFFF, 0x7FFFFFFF);`
* move malloc to a separate line
CWE ID: CWE-190 | 0 | 75,049 |
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 CrostiniUpgrader::Cancel() {
CrostiniManager::GetForProfile(profile_)->CancelUpgradeContainer(
container_id_, base::BindOnce(&CrostiniUpgrader::OnCancel,
weak_ptr_factory_.GetWeakPtr()));
}
Commit Message: Revert "Creates a WebUI-based Crostini Upgrader"
This reverts commit 29c8bb394dd8b8c03e006efb39ec77fc42f96900.
Reason for revert:
Findit (https://goo.gl/kROfz5) identified CL at revision 717476 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzI5YzhiYjM5NGRkOGI4YzAzZTAwNmVmYjM5ZWM3N2ZjNDJmOTY5MDAM
Sample Failed Build: https://ci.chromium.org/b/8896211200981346592
Sample Failed Step: compile
Original change's description:
> Creates a WebUI-based Crostini Upgrader
>
> The UI is behind the new crostini-webui-upgrader flag
> (currently disabled by default)
>
> The main areas for review are
>
> calamity@:
> html/js - chrome/browser/chromeos/crostini_upgrader/
> mojo and webui glue classes - chrome/browser/ui/webui/crostini_upgrader/
>
> davidmunro@
> crostini business logic - chrome/browser/chromeos/crostini/
>
> In this CL, the optional container backup stage is stubbed, and will be
> in a subsequent CL.
>
> A suite of unit/browser tests are also currently lacking. I intend them for
> follow-up CLs.
>
>
> Bug: 930901
> Change-Id: Ic52c5242e6c57232ffa6be5d6af65aaff5e8f4ff
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900520
> Commit-Queue: Nicholas Verne <nverne@chromium.org>
> Reviewed-by: Sam McNally <sammc@chromium.org>
> Reviewed-by: calamity <calamity@chromium.org>
> Reviewed-by: Ken Rockot <rockot@google.com>
> Cr-Commit-Position: refs/heads/master@{#717476}
Change-Id: I704f549216a7d1dc21942fbf6cf4ab9a1d600380
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 930901
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928159
Cr-Commit-Position: refs/heads/master@{#717481}
CWE ID: CWE-20 | 0 | 136,588 |
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 WebRuntimeFeatures::EnableBackgroundVideoTrackOptimization(bool enable) {
RuntimeEnabledFeatures::SetBackgroundVideoTrackOptimizationEnabled(enable);
}
Commit Message: Remove RequireCSSExtensionForFile runtime enabled flag.
The feature has long since been stable (since M64) and doesn't seem
to be a need for this flag.
BUG=788936
Change-Id: I666390b869289c328acb4a2daa5bf4154e1702c0
Reviewed-on: https://chromium-review.googlesource.com/c/1324143
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607329}
CWE ID: CWE-254 | 0 | 154,596 |
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 char *mif_getline(jas_stream_t *stream, char *buf, int bufsize)
{
int c;
char *bufptr;
assert(bufsize > 0);
bufptr = buf;
while (bufsize > 1) {
if ((c = mif_getc(stream)) == EOF) {
break;
}
*bufptr++ = c;
--bufsize;
if (c == '\n') {
break;
}
}
*bufptr = '\0';
if (!(bufptr = strchr(buf, '\n'))) {
return 0;
}
*bufptr = '\0';
return buf;
}
Commit Message: The generation of the configuration file jas_config.h has been completely
reworked in order to avoid pollution of the global namespace.
Some problematic types like uchar, ulong, and friends have been replaced
with names with a jas_ prefix.
An option max_samples has been added to the BMP and JPEG decoders to
restrict the maximum size of image that they can decode. This change
was made as a (possibly temporary) fix to address security concerns.
A max_samples command-line option has also been added to imginfo.
Whether an image component (for jas_image_t) is stored in memory or on
disk is now based on the component size (rather than the image size).
Some debug log message were added.
Some new integer overflow checks were added.
Some new safe integer add/multiply functions were added.
More pre-C99 cruft was removed. JasPer has numerous "hacks" to
handle pre-C99 compilers. JasPer now assumes C99 support. So, this
pre-C99 cruft is unnecessary and can be removed.
The regression jasper-doublefree-mem_close.jpg has been re-enabled.
Theoretically, it should work more predictably now.
CWE ID: CWE-190 | 0 | 72,944 |
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: ikev2_auth_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep,
uint32_t phase _U_, uint32_t doi _U_,
uint32_t proto _U_, int depth _U_)
{
struct ikev2_auth a;
const char *v2_auth[]={ "invalid", "rsasig",
"shared-secret", "dsssig" };
const u_char *authdata = (const u_char*)ext + sizeof(a);
unsigned int len;
ND_TCHECK(*ext);
UNALIGNED_MEMCPY(&a, ext, sizeof(a));
ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical);
len = ntohs(a.h.len);
/*
* Our caller has ensured that the length is >= 4.
*/
ND_PRINT((ndo," len=%u method=%s", len-4,
STR_OR_ID(a.auth_method, v2_auth)));
if (len > 4) {
if (ndo->ndo_vflag > 1) {
ND_PRINT((ndo, " authdata=("));
if (!rawprint(ndo, (const uint8_t *)authdata, len - sizeof(a)))
goto trunc;
ND_PRINT((ndo, ") "));
} else if (ndo->ndo_vflag) {
if (!ike_show_somedata(ndo, authdata, ep))
goto trunc;
}
}
return (const u_char *)ext + len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
}
Commit Message: CVE-2017-13689/IKEv1: Fix addr+subnet length check.
An IPv6 address plus subnet mask is 32 bytes, not 20 bytes.
16 bytes of IPv6 address, 16 bytes of subnet mask.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.
Add a test using the capture file supplied by the reporter(s).
CWE ID: CWE-125 | 0 | 62,026 |
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: xsltCompilationCtxtCreate(xsltStylesheetPtr style) {
xsltCompilerCtxtPtr ret;
ret = (xsltCompilerCtxtPtr) xmlMalloc(sizeof(xsltCompilerCtxt));
if (ret == NULL) {
xsltTransformError(NULL, style, NULL,
"xsltCompilerCreate: allocation of compiler "
"context failed.\n");
return(NULL);
}
memset(ret, 0, sizeof(xsltCompilerCtxt));
ret->errSeverity = XSLT_ERROR_SEVERITY_ERROR;
ret->tmpList = xsltPointerListCreate(20);
if (ret->tmpList == NULL) {
goto internal_err;
}
#ifdef XSLT_REFACTORED_XPATHCOMP
/*
* Create the XPath compilation context in order
* to speed up precompilation of XPath expressions.
*/
ret->xpathCtxt = xmlXPathNewContext(NULL);
if (ret->xpathCtxt == NULL)
goto internal_err;
#endif
return(ret);
internal_err:
xsltCompilationCtxtFree(ret);
return(NULL);
}
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,881 |
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 ACodec::IdleToLoadedState::stateEntered() {
ALOGV("[%s] Now Idle->Loaded", mCodec->mComponentName.c_str());
}
Commit Message: Fix initialization of AAC presentation struct
Otherwise the new size checks trip on this.
Bug: 27207275
Change-Id: I1f8f01097e3a88ff041b69279a6121be842f1766
CWE ID: CWE-119 | 0 | 164,168 |
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: vmxnet3_io_bar0_read(void *opaque, hwaddr addr, unsigned size)
{
if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_IMR,
VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) {
g_assert_not_reached();
}
VMW_CBPRN("BAR0 unknown read [%" PRIx64 "], size %d", addr, size);
return 0;
}
Commit Message:
CWE ID: CWE-20 | 0 | 15,590 |
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: error::Error GLES2DecoderImpl::DoCommands(unsigned int num_commands,
const volatile void* buffer,
int num_entries,
int* entries_processed) {
if (gpu_debug_commands_) {
return DoCommandsImpl<true>(
num_commands, buffer, num_entries, entries_processed);
} else {
return DoCommandsImpl<false>(
num_commands, buffer, num_entries, entries_processed);
}
}
Commit Message: Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM
This makes the query of GL_COMPLETION_STATUS_KHR to programs much
cheaper by minimizing the round-trip to the GPU thread.
Bug: 881152, 957001
Change-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657568}
CWE ID: CWE-416 | 0 | 141,279 |
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: pvscsi_ring_flush_req(PVSCSIRingInfo *mgr)
{
RS_SET_FIELD(mgr, reqConsIdx, mgr->consumed_ptr);
}
Commit Message:
CWE ID: CWE-399 | 0 | 8,449 |
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: dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
{
hm_fragment *frag = NULL;
pitem *item = NULL;
int i = -1, is_complete;
unsigned char seq64be[8];
unsigned long frag_len = msg_hdr->frag_len, max_len;
if ((msg_hdr->frag_off+frag_len) > msg_hdr->msg_len)
goto err;
/* Determine maximum allowed message size. Depends on (user set)
* maximum certificate length, but 16k is minimum.
*/
if (DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH < s->max_cert_list)
max_len = s->max_cert_list;
else
max_len = DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH;
if ((msg_hdr->frag_off+frag_len) > max_len)
goto err;
/* Try to find item in queue */
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char) (msg_hdr->seq>>8);
seq64be[7] = (unsigned char) msg_hdr->seq;
item = pqueue_find(s->d1->buffered_messages, seq64be);
if (item == NULL)
{
frag = dtls1_hm_fragment_new(msg_hdr->msg_len, 1);
if ( frag == NULL)
goto err;
memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
frag->msg_header.frag_len = frag->msg_header.msg_len;
frag->msg_header.frag_off = 0;
}
else
frag = (hm_fragment*) item->data;
/* If message is already reassembled, this must be a
* retransmit and can be dropped.
*/
if (frag->reassembly == NULL)
{
unsigned char devnull [256];
while (frag_len)
{
i = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,
devnull,
frag_len>sizeof(devnull)?sizeof(devnull):frag_len,0);
if (i<=0) goto err;
frag_len -= i;
}
return DTLS1_HM_FRAGMENT_RETRY;
}
/* read the body of the fragment (header has already been read */
i = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,
frag->fragment + msg_hdr->frag_off,frag_len,0);
if (i<=0 || (unsigned long)i!=frag_len)
goto err;
RSMBLY_BITMASK_MARK(frag->reassembly, (long)msg_hdr->frag_off,
(long)(msg_hdr->frag_off + frag_len));
RSMBLY_BITMASK_IS_COMPLETE(frag->reassembly, (long)msg_hdr->msg_len,
is_complete);
if (is_complete)
{
OPENSSL_free(frag->reassembly);
frag->reassembly = NULL;
}
if (item == NULL)
{
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char)(msg_hdr->seq>>8);
seq64be[7] = (unsigned char)(msg_hdr->seq);
item = pitem_new(seq64be, frag);
if (item == NULL)
{
goto err;
i = -1;
}
pqueue_insert(s->d1->buffered_messages, item);
}
return DTLS1_HM_FRAGMENT_RETRY;
err:
if (frag != NULL) dtls1_hm_fragment_free(frag);
if (item != NULL) OPENSSL_free(item);
*ok = 0;
return i;
}
Commit Message:
CWE ID: CWE-310 | 0 | 15,407 |
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 MagickBooleanType ReadPSDChannelZip(Image *image,const size_t channels,
const ssize_t type,const PSDCompressionType compression,
const size_t compact_size,ExceptionInfo *exception)
{
MagickBooleanType
status;
register unsigned char
*p;
size_t
count,
length,
packet_size,
row_size;
ssize_t
y;
unsigned char
*compact_pixels,
*pixels;
z_stream
stream;
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer data is ZIP compressed");
if ((MagickSizeType) compact_size > GetBlobSize(image))
ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile",
image->filename);
compact_pixels=(unsigned char *) AcquireQuantumMemory(compact_size,
sizeof(*compact_pixels));
if (compact_pixels == (unsigned char *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
packet_size=GetPSDPacketSize(image);
row_size=image->columns*packet_size;
count=image->rows*row_size;
pixels=(unsigned char *) AcquireQuantumMemory(count,sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
{
compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
if (ReadBlob(image,compact_size,compact_pixels) != (ssize_t) compact_size)
{
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);
ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile",
image->filename);
}
memset(&stream,0,sizeof(stream));
stream.data_type=Z_BINARY;
stream.next_in=(Bytef *)compact_pixels;
stream.avail_in=(uInt) compact_size;
stream.next_out=(Bytef *)pixels;
stream.avail_out=(uInt) count;
if (inflateInit(&stream) == Z_OK)
{
int
ret;
while (stream.avail_out > 0)
{
ret=inflate(&stream,Z_SYNC_FLUSH);
if ((ret != Z_OK) && (ret != Z_STREAM_END))
{
(void) inflateEnd(&stream);
compact_pixels=(unsigned char *) RelinquishMagickMemory(
compact_pixels);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
return(MagickFalse);
}
if (ret == Z_STREAM_END)
break;
}
(void) inflateEnd(&stream);
}
if (compression == ZipWithPrediction)
{
p=pixels;
while (count > 0)
{
length=image->columns;
while (--length)
{
if (packet_size == 2)
{
p[2]+=p[0]+((p[1]+p[3]) >> 8);
p[3]+=p[1];
}
/*
else if (packet_size == 4)
{
TODO: Figure out what to do there.
}
*/
else
*(p+1)+=*p;
p+=packet_size;
}
p+=packet_size;
count-=row_size;
}
}
status=MagickTrue;
p=pixels;
for (y=0; y < (ssize_t) image->rows; y++)
{
status=ReadPSDChannelPixels(image,channels,y,type,p,exception);
if (status == MagickFalse)
break;
p+=row_size;
}
compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
return(status);
}
Commit Message: https://github.com/ImageMagick/ImageMagick/issues/1451
CWE ID: CWE-399 | 0 | 91,371 |
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 FLTValidFilterNode(FilterEncodingNode *psFilterNode)
{
int bReturn = 0;
if (!psFilterNode)
return 0;
if (psFilterNode->eType == FILTER_NODE_TYPE_UNDEFINED)
return 0;
if (psFilterNode->psLeftNode) {
bReturn = FLTValidFilterNode(psFilterNode->psLeftNode);
if (bReturn == 0)
return 0;
else if (psFilterNode->psRightNode)
return FLTValidFilterNode(psFilterNode->psRightNode);
}
return 1;
}
Commit Message: security fix (patch by EvenR)
CWE ID: CWE-119 | 0 | 69,026 |
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: PlatformSensorProviderAndroid* PlatformSensorProviderAndroid::GetInstance() {
return base::Singleton<
PlatformSensorProviderAndroid,
base::LeakySingletonTraits<PlatformSensorProviderAndroid>>::get();
}
Commit Message: android: Fix sensors in device service.
This patch fixes a bug that prevented more than one sensor data
to be available at once when using the device motion/orientation
API.
The issue was introduced by this other patch [1] which fixed
some security-related issues in the way shared memory region
handles are managed throughout Chromium (more details at
https://crbug.com/789959).
The device service´s sensor implementation doesn´t work
correctly because it assumes it is possible to create a
writable mapping of a given shared memory region at any
time. This assumption is not correct on Android, once an
Ashmem region has been turned read-only, such mappings
are no longer possible.
To fix the implementation, this CL changes the following:
- PlatformSensor used to require moving a
mojo::ScopedSharedBufferMapping into the newly-created
instance. Said mapping being owned by and destroyed
with the PlatformSensor instance.
With this patch, the constructor instead takes a single
pointer to the corresponding SensorReadingSharedBuffer,
i.e. the area in memory where the sensor-specific
reading data is located, and can be either updated
or read-from.
Note that the PlatformSensor does not own the mapping
anymore.
- PlatformSensorProviderBase holds the *single* writable
mapping that is used to store all SensorReadingSharedBuffer
buffers. It is created just after the region itself,
and thus can be used even after the region's access
mode has been changed to read-only.
Addresses within the mapping will be passed to
PlatformSensor constructors, computed from the
mapping's base address plus a sensor-specific
offset.
The mapping is now owned by the
PlatformSensorProviderBase instance.
Note that, security-wise, nothing changes, because all
mojo::ScopedSharedBufferMapping before the patch actually
pointed to the same writable-page in memory anyway.
Since unit or integration tests didn't catch the regression
when [1] was submitted, this patch was tested manually by
running a newly-built Chrome apk in the Android emulator
and on a real device running Android O.
[1] https://chromium-review.googlesource.com/c/chromium/src/+/805238
BUG=805146
R=mattcary@chromium.org,alexilin@chromium.org,juncai@chromium.org,reillyg@chromium.org
Change-Id: I7d60a1cad278f48c361d2ece5a90de10eb082b44
Reviewed-on: https://chromium-review.googlesource.com/891180
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Matthew Cary <mattcary@chromium.org>
Reviewed-by: Alexandr Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532607}
CWE ID: CWE-732 | 0 | 148,976 |
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 CustomButton::SetState(ButtonState state) {
if (state == state_)
return;
if (animate_on_state_change_ &&
(!is_throbbing_ || !hover_animation_->is_animating())) {
is_throbbing_ = false;
if ((state_ == STATE_HOVERED) && (state == STATE_NORMAL)) {
hover_animation_->Hide();
} else if (state != STATE_HOVERED) {
hover_animation_->Reset();
} else if (state_ == STATE_NORMAL) {
hover_animation_->Show();
} else {
hover_animation_->Reset(1);
}
}
state_ = state;
StateChanged();
SchedulePaint();
}
Commit Message: Custom buttons should only handle accelerators when focused.
BUG=541415
Review URL: https://codereview.chromium.org/1437523005
Cr-Commit-Position: refs/heads/master@{#360130}
CWE ID: CWE-254 | 0 | 132,347 |
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 add_push_report_sideband_pkt(git_push *push, git_pkt_data *data_pkt, git_buf *data_pkt_buf)
{
git_pkt *pkt;
const char *line, *line_end;
size_t line_len;
int error;
int reading_from_buf = data_pkt_buf->size > 0;
if (reading_from_buf) {
/* We had an existing partial packet, so add the new
* packet to the buffer and parse the whole thing */
git_buf_put(data_pkt_buf, data_pkt->data, data_pkt->len);
line = data_pkt_buf->ptr;
line_len = data_pkt_buf->size;
}
else {
line = data_pkt->data;
line_len = data_pkt->len;
}
while (line_len > 0) {
error = git_pkt_parse_line(&pkt, line, &line_end, line_len);
if (error == GIT_EBUFS) {
/* Buffer the data when the inner packet is split
* across multiple sideband packets */
if (!reading_from_buf)
git_buf_put(data_pkt_buf, line, line_len);
error = 0;
goto done;
}
else if (error < 0)
goto done;
/* Advance in the buffer */
line_len -= (line_end - line);
line = line_end;
/* When a valid packet with no content has been
* read, git_pkt_parse_line does not report an
* error, but the pkt pointer has not been set.
* Handle this by skipping over empty packets.
*/
if (pkt == NULL)
continue;
error = add_push_report_pkt(push, pkt);
git_pkt_free(pkt);
if (error < 0 && error != GIT_ITEROVER)
goto done;
}
error = 0;
done:
if (reading_from_buf)
git_buf_consume(data_pkt_buf, line_end);
return error;
}
Commit Message: smart_pkt: treat empty packet lines as error
The Git protocol does not specify what should happen in the case
of an empty packet line (that is a packet line "0004"). We
currently indicate success, but do not return a packet in the
case where we hit an empty line. The smart protocol was not
prepared to handle such packets in all cases, though, resulting
in a `NULL` pointer dereference.
Fix the issue by returning an error instead. As such kind of
packets is not even specified by upstream, this is the right
thing to do.
CWE ID: CWE-476 | 1 | 170,110 |
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 cpu_shares_write_u64(struct cgroup *cgrp, struct cftype *cftype,
u64 shareval)
{
return sched_group_set_shares(cgroup_tg(cgrp), shareval);
}
Commit Message: Sched: fix skip_clock_update optimization
idle_balance() drops/retakes rq->lock, leaving the previous task
vulnerable to set_tsk_need_resched(). Clear it after we return
from balancing instead, and in setup_thread_stack() as well, so
no successfully descheduled or never scheduled task has it set.
Need resched confused the skip_clock_update logic, which assumes
that the next call to update_rq_clock() will come nearly immediately
after being set. Make the optimization robust against the waking
a sleeper before it sucessfully deschedules case by checking that
the current task has not been dequeued before setting the flag,
since it is that useless clock update we're trying to save, and
clear unconditionally in schedule() proper instead of conditionally
in put_prev_task().
Signed-off-by: Mike Galbraith <efault@gmx.de>
Reported-by: Bjoern B. Brandenburg <bbb.lst@gmail.com>
Tested-by: Yong Zhang <yong.zhang0@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: stable@kernel.org
LKML-Reference: <1291802742.1417.9.camel@marge.simson.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CWE ID: | 0 | 22,382 |
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 page *new_inode_page(struct inode *inode)
{
struct dnode_of_data dn;
/* allocate inode page for new inode */
set_new_dnode(&dn, inode, NULL, NULL, inode->i_ino);
/* caller should f2fs_put_page(page, 1); */
return new_node_page(&dn, 0, NULL);
}
Commit Message: f2fs: fix race condition in between free nid allocator/initializer
In below concurrent case, allocated nid can be loaded into free nid cache
and be allocated again.
Thread A Thread B
- f2fs_create
- f2fs_new_inode
- alloc_nid
- __insert_nid_to_list(ALLOC_NID_LIST)
- f2fs_balance_fs_bg
- build_free_nids
- __build_free_nids
- scan_nat_page
- add_free_nid
- __lookup_nat_cache
- f2fs_add_link
- init_inode_metadata
- new_inode_page
- new_node_page
- set_node_addr
- alloc_nid_done
- __remove_nid_from_list(ALLOC_NID_LIST)
- __insert_nid_to_list(FREE_NID_LIST)
This patch makes nat cache lookup and free nid list operation being atomical
to avoid this race condition.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
CWE ID: CWE-362 | 0 | 85,283 |
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 rose_getsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen)
{
struct sock *sk = sock->sk;
struct rose_sock *rose = rose_sk(sk);
int val = 0;
int len;
if (level != SOL_ROSE)
return -ENOPROTOOPT;
if (get_user(len, optlen))
return -EFAULT;
if (len < 0)
return -EINVAL;
switch (optname) {
case ROSE_DEFER:
val = rose->defer;
break;
case ROSE_T1:
val = rose->t1 / HZ;
break;
case ROSE_T2:
val = rose->t2 / HZ;
break;
case ROSE_T3:
val = rose->t3 / HZ;
break;
case ROSE_HOLDBACK:
val = rose->hb / HZ;
break;
case ROSE_IDLE:
val = rose->idle / (60 * HZ);
break;
case ROSE_QBITINCL:
val = rose->qbitincl;
break;
default:
return -ENOPROTOOPT;
}
len = min_t(unsigned int, len, sizeof(int));
if (put_user(len, optlen))
return -EFAULT;
return copy_to_user(optval, &val, len) ? -EFAULT : 0;
}
Commit Message: rose: Add length checks to CALL_REQUEST parsing
Define some constant offsets for CALL_REQUEST based on the description
at <http://www.techfest.com/networking/wan/x25plp.htm> and the
definition of ROSE as using 10-digit (5-byte) addresses. Use them
consistently. Validate all implicit and explicit facilities lengths.
Validate the address length byte rather than either trusting or
assuming its value.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-20 | 0 | 22,202 |
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::PropagateStyleToViewport() {
DCHECK(InStyleRecalc());
DCHECK(documentElement());
HTMLElement* body = this->body();
const ComputedStyle* body_style =
body ? body->EnsureComputedStyle() : nullptr;
const ComputedStyle* document_element_style =
documentElement()->EnsureComputedStyle();
WritingMode root_writing_mode = document_element_style->GetWritingMode();
TextDirection root_direction = document_element_style->Direction();
if (body_style) {
root_writing_mode = body_style->GetWritingMode();
root_direction = body_style->Direction();
}
const ComputedStyle* background_style = document_element_style;
if (IsHTMLHtmlElement(documentElement()) && IsHTMLBodyElement(body) &&
!background_style->HasBackground())
background_style = body_style;
Color background_color =
background_style->VisitedDependentColor(GetCSSPropertyBackgroundColor());
FillLayer background_layers = background_style->BackgroundLayers();
for (auto* current_layer = &background_layers; current_layer;
current_layer = current_layer->Next()) {
current_layer->SetClip(EFillBox::kBorder);
if (current_layer->Attachment() == EFillAttachment::kScroll)
current_layer->SetAttachment(EFillAttachment::kLocal);
}
EImageRendering image_rendering = background_style->ImageRendering();
const ComputedStyle* overflow_style = nullptr;
if (Element* element = ViewportDefiningElement(document_element_style)) {
if (element == body) {
overflow_style = body_style;
} else {
DCHECK_EQ(element, documentElement());
overflow_style = document_element_style;
if (body_style && !body_style->IsOverflowVisible())
UseCounter::Count(*this, WebFeature::kBodyScrollsInAdditionToViewport);
}
}
EOverflowAnchor overflow_anchor = EOverflowAnchor::kAuto;
EOverflow overflow_x = EOverflow::kAuto;
EOverflow overflow_y = EOverflow::kAuto;
GapLength column_gap;
if (overflow_style) {
overflow_anchor = overflow_style->OverflowAnchor();
overflow_x = overflow_style->OverflowX();
overflow_y = overflow_style->OverflowY();
if (overflow_x == EOverflow::kVisible)
overflow_x = EOverflow::kAuto;
if (overflow_y == EOverflow::kVisible)
overflow_y = EOverflow::kAuto;
if (overflow_anchor == EOverflowAnchor::kVisible)
overflow_anchor = EOverflowAnchor::kAuto;
column_gap = overflow_style->ColumnGap();
}
ScrollSnapType snap_type = overflow_style->GetScrollSnapType();
ScrollBehavior scroll_behavior = document_element_style->GetScrollBehavior();
EOverscrollBehavior overscroll_behavior_x =
overflow_style->OverscrollBehaviorX();
EOverscrollBehavior overscroll_behavior_y =
overflow_style->OverscrollBehaviorY();
using OverscrollBehaviorType = cc::OverscrollBehavior::OverscrollBehaviorType;
if (RuntimeEnabledFeatures::CSSOverscrollBehaviorEnabled() &&
IsInMainFrame()) {
GetPage()->GetOverscrollController().SetOverscrollBehavior(
cc::OverscrollBehavior(
static_cast<OverscrollBehaviorType>(overscroll_behavior_x),
static_cast<OverscrollBehaviorType>(overscroll_behavior_y)));
}
Length scroll_padding_top = overflow_style->ScrollPaddingTop();
Length scroll_padding_right = overflow_style->ScrollPaddingRight();
Length scroll_padding_bottom = overflow_style->ScrollPaddingBottom();
Length scroll_padding_left = overflow_style->ScrollPaddingLeft();
const ComputedStyle& viewport_style = GetLayoutView()->StyleRef();
if (viewport_style.GetWritingMode() != root_writing_mode ||
viewport_style.Direction() != root_direction ||
viewport_style.VisitedDependentColor(GetCSSPropertyBackgroundColor()) !=
background_color ||
viewport_style.BackgroundLayers() != background_layers ||
viewport_style.ImageRendering() != image_rendering ||
viewport_style.OverflowAnchor() != overflow_anchor ||
viewport_style.OverflowX() != overflow_x ||
viewport_style.OverflowY() != overflow_y ||
viewport_style.ColumnGap() != column_gap ||
viewport_style.GetScrollSnapType() != snap_type ||
viewport_style.GetScrollBehavior() != scroll_behavior ||
viewport_style.OverscrollBehaviorX() != overscroll_behavior_x ||
viewport_style.OverscrollBehaviorY() != overscroll_behavior_y ||
viewport_style.ScrollPaddingTop() != scroll_padding_top ||
viewport_style.ScrollPaddingRight() != scroll_padding_right ||
viewport_style.ScrollPaddingBottom() != scroll_padding_bottom ||
viewport_style.ScrollPaddingLeft() != scroll_padding_left) {
scoped_refptr<ComputedStyle> new_style =
ComputedStyle::Clone(viewport_style);
new_style->SetWritingMode(root_writing_mode);
new_style->SetDirection(root_direction);
new_style->SetBackgroundColor(background_color);
new_style->AccessBackgroundLayers() = background_layers;
new_style->SetImageRendering(image_rendering);
new_style->SetOverflowAnchor(overflow_anchor);
new_style->SetOverflowX(overflow_x);
new_style->SetOverflowY(overflow_y);
new_style->SetColumnGap(column_gap);
new_style->SetScrollSnapType(snap_type);
new_style->SetScrollBehavior(scroll_behavior);
new_style->SetOverscrollBehaviorX(overscroll_behavior_x);
new_style->SetOverscrollBehaviorY(overscroll_behavior_y);
new_style->SetScrollPaddingTop(scroll_padding_top);
new_style->SetScrollPaddingRight(scroll_padding_right);
new_style->SetScrollPaddingBottom(scroll_padding_bottom);
new_style->SetScrollPaddingLeft(scroll_padding_left);
GetLayoutView()->SetStyle(new_style);
SetupFontBuilder(*new_style);
View()->RecalculateScrollbarOverlayColorTheme(
View()->DocumentBackgroundColor());
if (PaintLayerScrollableArea* scrollable_area =
GetLayoutView()->GetScrollableArea()) {
if (scrollable_area->HorizontalScrollbar() &&
scrollable_area->HorizontalScrollbar()->IsCustomScrollbar())
scrollable_area->HorizontalScrollbar()->StyleChanged();
if (scrollable_area->VerticalScrollbar() &&
scrollable_area->VerticalScrollbar()->IsCustomScrollbar())
scrollable_area->VerticalScrollbar()->StyleChanged();
}
}
}
Commit Message: Prevent sandboxed documents from reusing the default window
Bug: 377995
Change-Id: Iff66c6d214dfd0cb7ea9c80f83afeedfff703541
Reviewed-on: https://chromium-review.googlesource.com/983558
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567663}
CWE ID: CWE-285 | 0 | 154,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: void DocumentLoader::DetachFromFrame() {
DCHECK(frame_);
fetcher_->StopFetching();
if (frame_ && !SentDidFinishLoad())
LoadFailed(ResourceError::CancelledError(Url()));
fetcher_->ClearContext();
if (!frame_)
return;
application_cache_host_->DetachFromDocumentLoader();
application_cache_host_.Clear();
service_worker_network_provider_ = nullptr;
WeakIdentifierMap<DocumentLoader>::NotifyObjectDestroyed(this);
ClearResource();
frame_ = nullptr;
}
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 | 1 | 171,851 |
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 sctp_cmd_process_sack(sctp_cmd_seq_t *cmds,
struct sctp_association *asoc,
struct sctp_chunk *chunk)
{
int err = 0;
if (sctp_outq_sack(&asoc->outqueue, chunk)) {
struct net *net = sock_net(asoc->base.sk);
/* There are no more TSNs awaiting SACK. */
err = sctp_do_sm(net, SCTP_EVENT_T_OTHER,
SCTP_ST_OTHER(SCTP_EVENT_NO_PENDING_TSN),
asoc->state, asoc->ep, asoc, NULL,
GFP_ATOMIC);
}
return err;
}
Commit Message: sctp: Prevent soft lockup when sctp_accept() is called during a timeout event
A case can occur when sctp_accept() is called by the user during
a heartbeat timeout event after the 4-way handshake. Since
sctp_assoc_migrate() changes both assoc->base.sk and assoc->ep, the
bh_sock_lock in sctp_generate_heartbeat_event() will be taken with
the listening socket but released with the new association socket.
The result is a deadlock on any future attempts to take the listening
socket lock.
Note that this race can occur with other SCTP timeouts that take
the bh_lock_sock() in the event sctp_accept() is called.
BUG: soft lockup - CPU#9 stuck for 67s! [swapper:0]
...
RIP: 0010:[<ffffffff8152d48e>] [<ffffffff8152d48e>] _spin_lock+0x1e/0x30
RSP: 0018:ffff880028323b20 EFLAGS: 00000206
RAX: 0000000000000002 RBX: ffff880028323b20 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff880028323be0 RDI: ffff8804632c4b48
RBP: ffffffff8100bb93 R08: 0000000000000000 R09: 0000000000000000
R10: ffff880610662280 R11: 0000000000000100 R12: ffff880028323aa0
R13: ffff8804383c3880 R14: ffff880028323a90 R15: ffffffff81534225
FS: 0000000000000000(0000) GS:ffff880028320000(0000) knlGS:0000000000000000
CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: 00000000006df528 CR3: 0000000001a85000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process swapper (pid: 0, threadinfo ffff880616b70000, task ffff880616b6cab0)
Stack:
ffff880028323c40 ffffffffa01c2582 ffff880614cfb020 0000000000000000
<d> 0100000000000000 00000014383a6c44 ffff8804383c3880 ffff880614e93c00
<d> ffff880614e93c00 0000000000000000 ffff8804632c4b00 ffff8804383c38b8
Call Trace:
<IRQ>
[<ffffffffa01c2582>] ? sctp_rcv+0x492/0xa10 [sctp]
[<ffffffff8148c559>] ? nf_iterate+0x69/0xb0
[<ffffffff814974a0>] ? ip_local_deliver_finish+0x0/0x2d0
[<ffffffff8148c716>] ? nf_hook_slow+0x76/0x120
[<ffffffff814974a0>] ? ip_local_deliver_finish+0x0/0x2d0
[<ffffffff8149757d>] ? ip_local_deliver_finish+0xdd/0x2d0
[<ffffffff81497808>] ? ip_local_deliver+0x98/0xa0
[<ffffffff81496ccd>] ? ip_rcv_finish+0x12d/0x440
[<ffffffff81497255>] ? ip_rcv+0x275/0x350
[<ffffffff8145cfeb>] ? __netif_receive_skb+0x4ab/0x750
...
With lockdep debugging:
=====================================
[ BUG: bad unlock balance detected! ]
-------------------------------------
CslRx/12087 is trying to release lock (slock-AF_INET) at:
[<ffffffffa01bcae0>] sctp_generate_timeout_event+0x40/0xe0 [sctp]
but there are no more locks to release!
other info that might help us debug this:
2 locks held by CslRx/12087:
#0: (&asoc->timers[i]){+.-...}, at: [<ffffffff8108ce1f>] run_timer_softirq+0x16f/0x3e0
#1: (slock-AF_INET){+.-...}, at: [<ffffffffa01bcac3>] sctp_generate_timeout_event+0x23/0xe0 [sctp]
Ensure the socket taken is also the same one that is released by
saving a copy of the socket before entering the timeout event
critical section.
Signed-off-by: Karl Heiss <kheiss@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-362 | 0 | 57,005 |
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 PluginInfoMessageFilter::Context::DecidePluginStatus(
const GetPluginInfo_Params& params,
const WebPluginInfo& plugin,
PluginFinder* plugin_finder,
ChromeViewHostMsg_GetPluginInfo_Status* status,
std::string* group_identifier,
string16* group_name) const {
PluginInstaller* installer = plugin_finder->GetPluginInstaller(plugin);
*group_name = installer->name();
*group_identifier = installer->identifier();
ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
bool uses_default_content_setting = true;
GetPluginContentSetting(plugin, params.top_origin_url, params.url,
*group_identifier, &plugin_setting,
&uses_default_content_setting);
DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
#if defined(ENABLE_PLUGIN_INSTALLATION)
PluginInstaller::SecurityStatus plugin_status =
installer->GetSecurityStatus(plugin);
if (plugin_status == PluginInstaller::SECURITY_STATUS_OUT_OF_DATE &&
!allow_outdated_plugins_.GetValue()) {
if (allow_outdated_plugins_.IsManaged()) {
status->value =
ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed;
} else {
status->value = ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked;
}
return;
}
if ((plugin_status ==
PluginInstaller::SECURITY_STATUS_REQUIRES_AUTHORIZATION ||
PluginService::GetInstance()->IsPluginUnstable(plugin.path)) &&
plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS &&
plugin.type != WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS &&
!always_authorize_plugins_.GetValue() &&
plugin_setting != CONTENT_SETTING_BLOCK &&
uses_default_content_setting) {
status->value = ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized;
return;
}
#endif
if (plugin_setting == CONTENT_SETTING_ASK)
status->value = ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay;
else if (plugin_setting == CONTENT_SETTING_BLOCK)
status->value = ChromeViewHostMsg_GetPluginInfo_Status::kBlocked;
}
Commit Message: Handle crashing Pepper plug-ins the same as crashing NPAPI plug-ins.
BUG=151895
Review URL: https://chromiumcodereview.appspot.com/10956065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158364 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 1 | 170,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: static ALWAYS_INLINE uint32_t random_xid(void)
{
return rand();
}
Commit Message:
CWE ID: CWE-125 | 0 | 8,772 |
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 espruino_snprintf_cb(const char *str, void *userdata) {
espruino_snprintf_data *d = (espruino_snprintf_data*)userdata;
while (*str) {
if (d->idx < d->len) d->outPtr[d->idx] = *str;
d->idx++;
str++;
}
}
Commit Message: Fix stack size detection on Linux (fix #1427)
CWE ID: CWE-190 | 0 | 82,598 |
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 do_free_upto(BIO *f, BIO *upto)
{
if (upto) {
BIO *tbio;
do {
tbio = BIO_pop(f);
BIO_free(f);
f = tbio;
}
while (f && f != upto);
} else
BIO_free_all(f);
}
Commit Message:
CWE ID: CWE-311 | 0 | 11,952 |
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: LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
{
tmsize_t rowlen = TIFFScanlineSize(tif);
if (rowlen == 0)
return 0;
assert(cc%rowlen == 0);
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) {
bp += rowlen;
cc -= rowlen;
}
return (cc == 0);
}
Commit Message: * libtiff/tif_pixarlog.c, libtiff/tif_luv.c: fix heap-based buffer
overflow on generation of PixarLog / LUV compressed files, with
ColorMap, TransferFunction attached and nasty plays with bitspersample.
The fix for LUV has not been tested, but suffers from the same kind
of issue of PixarLog.
Reported by Agostino Sarubbo.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2604
CWE ID: CWE-125 | 0 | 70,244 |
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: asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7,
struct pt_regs __regs)
{
struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
unsigned long error_code;
struct task_struct *tsk = current;
#ifdef CONFIG_SH_FPU_EMU
unsigned short inst = 0;
int err;
get_user(inst, (unsigned short*)regs->pc);
err = do_fpu_inst(inst, regs);
if (!err) {
regs->pc += instruction_size(inst);
return;
}
/* not a FPU inst. */
#endif
#ifdef CONFIG_SH_DSP
/* Check if it's a DSP instruction */
if (is_dsp_inst(regs)) {
/* Enable DSP mode, and restart instruction. */
regs->sr |= SR_DSP;
/* Save DSP mode */
tsk->thread.dsp_status.status |= SR_DSP;
return;
}
#endif
error_code = lookup_exception_vector();
local_irq_enable();
force_sig(SIGILL, tsk);
die_if_no_fixup("reserved instruction", regs, error_code);
}
Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface
The nmi parameter indicated if we could do wakeups from the current
context, if not, we would set some state and self-IPI and let the
resulting interrupt do the wakeup.
For the various event classes:
- hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from
the PMI-tail (ARM etc.)
- tracepoint: nmi=0; since tracepoint could be from NMI context.
- software: nmi=[0,1]; some, like the schedule thing cannot
perform wakeups, and hence need 0.
As one can see, there is very little nmi=1 usage, and the down-side of
not using it is that on some platforms some software events can have a
jiffy delay in wakeup (when arch_irq_work_raise isn't implemented).
The up-side however is that we can remove the nmi parameter and save a
bunch of conditionals in fast paths.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Michael Cree <mcree@orcon.net.nz>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
Cc: Anton Blanchard <anton@samba.org>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CWE ID: CWE-399 | 0 | 25,552 |
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 ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len,
void *val)
{
struct kvm_ioapic *ioapic = to_ioapic(this);
u32 result;
if (!ioapic_in_range(ioapic, addr))
return -EOPNOTSUPP;
ioapic_debug("addr %lx\n", (unsigned long)addr);
ASSERT(!(addr & 0xf)); /* check alignment */
addr &= 0xff;
spin_lock(&ioapic->lock);
switch (addr) {
case IOAPIC_REG_SELECT:
result = ioapic->ioregsel;
break;
case IOAPIC_REG_WINDOW:
result = ioapic_read_indirect(ioapic, addr, len);
break;
default:
result = 0;
break;
}
spin_unlock(&ioapic->lock);
switch (len) {
case 8:
*(u64 *) val = result;
break;
case 1:
case 2:
case 4:
memcpy(val, (char *)&result, len);
break;
default:
printk(KERN_WARNING "ioapic: wrong length %d\n", len);
}
return 0;
}
Commit Message: KVM: Fix bounds checking in ioapic indirect register reads (CVE-2013-1798)
If the guest specifies a IOAPIC_REG_SELECT with an invalid value and follows
that with a read of the IOAPIC_REG_WINDOW KVM does not properly validate
that request. ioapic_read_indirect contains an
ASSERT(redir_index < IOAPIC_NUM_PINS), but the ASSERT has no effect in
non-debug builds. In recent kernels this allows a guest to cause a kernel
oops by reading invalid memory. In older kernels (pre-3.3) this allows a
guest to read from large ranges of host memory.
Tested: tested against apic unit tests.
Signed-off-by: Andrew Honig <ahonig@google.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
CWE ID: CWE-20 | 0 | 33,247 |
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 Range::expand(const String& unit, ExceptionCode& ec)
{
VisiblePosition start(startPosition());
VisiblePosition end(endPosition());
if (unit == "word") {
start = startOfWord(start);
end = endOfWord(end);
} else if (unit == "sentence") {
start = startOfSentence(start);
end = endOfSentence(end);
} else if (unit == "block") {
start = startOfParagraph(start);
end = endOfParagraph(end);
} else if (unit == "document") {
start = startOfDocument(start);
end = endOfDocument(end);
} else
return;
setStart(start.deepEquivalent().containerNode(), start.deepEquivalent().computeOffsetInContainerNode(), ec);
setEnd(end.deepEquivalent().containerNode(), end.deepEquivalent().computeOffsetInContainerNode(), ec);
}
Commit Message: There are too many poorly named functions to create a fragment from markup
https://bugs.webkit.org/show_bug.cgi?id=87339
Reviewed by Eric Seidel.
Source/WebCore:
Moved all functions that create a fragment from markup to markup.h/cpp.
There should be no behavioral change.
* dom/Range.cpp:
(WebCore::Range::createContextualFragment):
* dom/Range.h: Removed createDocumentFragmentForElement.
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::setInnerHTML):
* editing/markup.cpp:
(WebCore::createFragmentFromMarkup):
(WebCore::createFragmentForInnerOuterHTML): Renamed from createFragmentFromSource.
(WebCore::createFragmentForTransformToFragment): Moved from XSLTProcessor.
(WebCore::removeElementPreservingChildren): Moved from Range.
(WebCore::createContextualFragment): Ditto.
* editing/markup.h:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::setInnerHTML):
(WebCore::HTMLElement::setOuterHTML):
(WebCore::HTMLElement::insertAdjacentHTML):
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::patchNode): Added a FIXME since this code should be using
one of the functions listed in markup.h
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::transformToFragment):
Source/WebKit/qt:
Replace calls to Range::createDocumentFragmentForElement by calls to
createContextualDocumentFragment.
* Api/qwebelement.cpp:
(QWebElement::appendInside):
(QWebElement::prependInside):
(QWebElement::prependOutside):
(QWebElement::appendOutside):
(QWebElement::encloseContentsWith):
(QWebElement::encloseWith):
git-svn-id: svn://svn.chromium.org/blink/trunk@118414 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-264 | 0 | 100,245 |
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: WORD32 ih264d_get_vui_params(iv_obj_t *dec_hdl,
void *pv_api_ip,
void *pv_api_op)
{
ih264d_ctl_get_vui_params_ip_t *ps_ip;
ih264d_ctl_get_vui_params_op_t *ps_op;
dec_struct_t *ps_dec = dec_hdl->pv_codec_handle;
dec_seq_params_t *ps_sps;
vui_t *ps_vui;
WORD32 i;
UWORD32 u4_size;
ps_ip = (ih264d_ctl_get_vui_params_ip_t *)pv_api_ip;
ps_op = (ih264d_ctl_get_vui_params_op_t *)pv_api_op;
UNUSED(ps_ip);
u4_size = ps_op->u4_size;
memset(ps_op, 0, sizeof(ih264d_ctl_get_vui_params_op_t));
ps_op->u4_size = u4_size;
if(NULL == ps_dec->ps_cur_sps)
{
ps_op->u4_error_code = ERROR_VUI_PARAMS_NOT_FOUND;
return IV_FAIL;
}
ps_sps = ps_dec->ps_cur_sps;
if((0 == ps_sps->u1_is_valid)
|| (0 == ps_sps->u1_vui_parameters_present_flag))
{
ps_op->u4_error_code = ERROR_VUI_PARAMS_NOT_FOUND;
return IV_FAIL;
}
ps_vui = &ps_sps->s_vui;
ps_op->u1_aspect_ratio_idc = ps_vui->u1_aspect_ratio_idc;
ps_op->u2_sar_width = ps_vui->u2_sar_width;
ps_op->u2_sar_height = ps_vui->u2_sar_height;
ps_op->u1_overscan_appropriate_flag = ps_vui->u1_overscan_appropriate_flag;
ps_op->u1_video_format = ps_vui->u1_video_format;
ps_op->u1_video_full_range_flag = ps_vui->u1_video_full_range_flag;
ps_op->u1_colour_primaries = ps_vui->u1_colour_primaries;
ps_op->u1_tfr_chars = ps_vui->u1_tfr_chars;
ps_op->u1_matrix_coeffs = ps_vui->u1_matrix_coeffs;
ps_op->u1_cr_top_field = ps_vui->u1_cr_top_field;
ps_op->u1_cr_bottom_field = ps_vui->u1_cr_bottom_field;
ps_op->u4_num_units_in_tick = ps_vui->u4_num_units_in_tick;
ps_op->u4_time_scale = ps_vui->u4_time_scale;
ps_op->u1_fixed_frame_rate_flag = ps_vui->u1_fixed_frame_rate_flag;
ps_op->u1_nal_hrd_params_present = ps_vui->u1_nal_hrd_params_present;
ps_op->u1_vcl_hrd_params_present = ps_vui->u1_vcl_hrd_params_present;
ps_op->u1_low_delay_hrd_flag = ps_vui->u1_low_delay_hrd_flag;
ps_op->u1_pic_struct_present_flag = ps_vui->u1_pic_struct_present_flag;
ps_op->u1_bitstream_restriction_flag = ps_vui->u1_bitstream_restriction_flag;
ps_op->u1_mv_over_pic_boundaries_flag = ps_vui->u1_mv_over_pic_boundaries_flag;
ps_op->u4_max_bytes_per_pic_denom = ps_vui->u4_max_bytes_per_pic_denom;
ps_op->u4_max_bits_per_mb_denom = ps_vui->u4_max_bits_per_mb_denom;
ps_op->u4_log2_max_mv_length_horz = ps_vui->u4_log2_max_mv_length_horz;
ps_op->u4_log2_max_mv_length_vert = ps_vui->u4_log2_max_mv_length_vert;
ps_op->u4_num_reorder_frames = ps_vui->u4_num_reorder_frames;
ps_op->u4_max_dec_frame_buffering = ps_vui->u4_max_dec_frame_buffering;
return IV_SUCCESS;
}
Commit Message: Decoder: Increased allocation and added checks in sei parsing.
This prevents heap overflow while parsing sei_message.
Bug: 63122634
Test: ran PoC on unpatched/patched
Change-Id: I61c1ff4ac053a060be8c24da4671db985cac628c
(cherry picked from commit f2b70d353768af8d4ead7f32497be05f197925ef)
CWE ID: CWE-200 | 0 | 163,269 |
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 l2tp_ip6_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer)
{
struct sockaddr_l2tpip6 *lsa = (struct sockaddr_l2tpip6 *)uaddr;
struct sock *sk = sock->sk;
struct ipv6_pinfo *np = inet6_sk(sk);
struct l2tp_ip6_sock *lsk = l2tp_ip6_sk(sk);
lsa->l2tp_family = AF_INET6;
lsa->l2tp_flowinfo = 0;
lsa->l2tp_scope_id = 0;
if (peer) {
if (!lsk->peer_conn_id)
return -ENOTCONN;
lsa->l2tp_conn_id = lsk->peer_conn_id;
lsa->l2tp_addr = np->daddr;
if (np->sndflow)
lsa->l2tp_flowinfo = np->flow_label;
} else {
if (ipv6_addr_any(&np->rcv_saddr))
lsa->l2tp_addr = np->saddr;
else
lsa->l2tp_addr = np->rcv_saddr;
lsa->l2tp_conn_id = lsk->conn_id;
}
if (ipv6_addr_type(&lsa->l2tp_addr) & IPV6_ADDR_LINKLOCAL)
lsa->l2tp_scope_id = sk->sk_bound_dev_if;
*uaddr_len = sizeof(*lsa);
return 0;
}
Commit Message: l2tp: fix info leak via getsockname()
The L2TP code for IPv6 fails to initialize the l2tp_unused member of
struct sockaddr_l2tpip6 and that for leaks two bytes kernel stack via
the getsockname() syscall. Initialize l2tp_unused with 0 to avoid the
info leak.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: James Chapman <jchapman@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-200 | 1 | 166,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: const WTF::Vector<PopupItem*>& PopupContainer:: popupData() const
{
return m_listBox->items();
}
Commit Message: [REGRESSION] Refreshed autofill popup renders garbage
https://bugs.webkit.org/show_bug.cgi?id=83255
http://code.google.com/p/chromium/issues/detail?id=118374
The code used to update only the PopupContainer coordinates as if they were the coordinates relative
to the root view. Instead, a WebWidget positioned relative to the screen origin holds the PopupContainer,
so it is the WebWidget that should be positioned in PopupContainer::refresh(), and the PopupContainer's
location should be (0, 0) (and their sizes should always be equal).
Reviewed by Kent Tamura.
No new tests, as the popup appearance is not testable in WebKit.
* platform/chromium/PopupContainer.cpp:
(WebCore::PopupContainer::layoutAndCalculateWidgetRect): Variable renamed.
(WebCore::PopupContainer::showPopup): Use m_originalFrameRect rather than frameRect()
for passing into chromeClient.
(WebCore::PopupContainer::showInRect): Set up the correct frameRect() for the container.
(WebCore::PopupContainer::refresh): Resize the container and position the WebWidget correctly.
* platform/chromium/PopupContainer.h:
(PopupContainer):
git-svn-id: svn://svn.chromium.org/blink/trunk@113418 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 108,584 |
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: sc_pkcs15emu_add_object(sc_pkcs15_card_t *p15card, int type,
const char *label, void *data,
const sc_pkcs15_id_t *auth_id, int obj_flags)
{
sc_pkcs15_object_t *obj;
int df_type;
obj = calloc(1, sizeof(*obj));
obj->type = type;
obj->data = data;
if (label)
strncpy(obj->label, label, sizeof(obj->label)-1);
obj->flags = obj_flags;
if (auth_id)
obj->auth_id = *auth_id;
switch (type & SC_PKCS15_TYPE_CLASS_MASK) {
case SC_PKCS15_TYPE_AUTH:
df_type = SC_PKCS15_AODF;
break;
case SC_PKCS15_TYPE_PRKEY:
df_type = SC_PKCS15_PRKDF;
break;
case SC_PKCS15_TYPE_PUBKEY:
df_type = SC_PKCS15_PUKDF;
break;
case SC_PKCS15_TYPE_CERT:
df_type = SC_PKCS15_CDF;
break;
default:
sc_log(p15card->card->ctx, "Unknown PKCS15 object type %d", type);
free(obj);
return SC_ERROR_INVALID_ARGUMENTS;
}
obj->df = sc_pkcs15emu_get_df(p15card, df_type);
sc_pkcs15_add_object(p15card, obj);
return 0;
}
Commit Message: fixed out of bounds writes
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting the problems.
CWE ID: CWE-415 | 0 | 78,798 |
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: gsf_infile_tar_name_by_index (GsfInfile *infile, int target)
{
GsfInfileTar *tar = GSF_INFILE_TAR (infile);
if (target < 0 || (unsigned)target >= tar->children->len)
return NULL;
return g_array_index (tar->children, TarChild, target).name;
}
Commit Message: tar: fix crash on broken tar file.
CWE ID: CWE-476 | 0 | 47,709 |
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 QuotaManager::DeleteOriginData(
const GURL& origin, StorageType type, int quota_client_mask,
const StatusCallback& callback) {
LazyInitialize();
if (origin.is_empty() || clients_.empty()) {
callback.Run(kQuotaStatusOk);
return;
}
OriginDataDeleter* deleter =
new OriginDataDeleter(this, origin, type, quota_client_mask, callback);
deleter->Start();
}
Commit Message: Wipe out QuotaThreadTask.
This is a one of a series of refactoring patches for QuotaManager.
http://codereview.chromium.org/10872054/
http://codereview.chromium.org/10917060/
BUG=139270
Review URL: https://chromiumcodereview.appspot.com/10919070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154987 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 102,157 |
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 is_al_reg(const Operand *op) {
if (op->type & OT_MEMORY) {
return 0;
}
if (op->reg == X86R_AL && op->type & OT_BYTE) {
return 1;
}
return 0;
}
Commit Message: Fix #12372 and #12373 - Crash in x86 assembler (#12380)
0 ,0,[bP-bL-bP-bL-bL-r-bL-bP-bL-bL-
mov ,0,[ax+Bx-ax+Bx-ax+ax+Bx-ax+Bx--
leA ,0,[bP-bL-bL-bP-bL-bP-bL-60@bL-
leA ,0,[bP-bL-r-bP-bL-bP-bL-60@bL-
mov ,0,[ax+Bx-ax+Bx-ax+ax+Bx-ax+Bx--
CWE ID: CWE-125 | 0 | 75,373 |
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 FilePath GetTestFilePath(const FilePath::StringType& filename) {
FilePath path;
std::string error;
PathService::Get(chrome::DIR_TEST_DATA, &path);
path = path.AppendASCII("chromeos")
.AppendASCII("gdata")
.AppendASCII(filename.c_str());
EXPECT_TRUE(file_util::PathExists(path)) <<
"Couldn't find " << path.value();
return path;
}
Commit Message: gdata: Define the resource ID for the root directory
Per the spec, the resource ID for the root directory is defined
as "folder:root". Add the resource ID to the root directory in our
file system representation so we can look up the root directory by
the resource ID.
BUG=127697
TEST=add unit tests
Review URL: https://chromiumcodereview.appspot.com/10332253
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137928 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 104,636 |
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 V8TestObject::Uint8ArrayMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_uint8ArrayMethod");
test_object_v8_internal::Uint8ArrayMethodMethod(info);
}
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 | 135,267 |
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: spnego_gss_inquire_context(
OM_uint32 *minor_status,
const gss_ctx_id_t context_handle,
gss_name_t *src_name,
gss_name_t *targ_name,
OM_uint32 *lifetime_rec,
gss_OID *mech_type,
OM_uint32 *ctx_flags,
int *locally_initiated,
int *opened)
{
OM_uint32 ret = GSS_S_COMPLETE;
ret = gss_inquire_context(minor_status,
context_handle,
src_name,
targ_name,
lifetime_rec,
mech_type,
ctx_flags,
locally_initiated,
opened);
return (ret);
}
Commit Message: Fix SPNEGO context aliasing bugs [CVE-2015-2695]
The SPNEGO mechanism currently replaces its context handle with the
mechanism context handle upon establishment, under the assumption that
most GSS functions are only called after context establishment. This
assumption is incorrect, and can lead to aliasing violations for some
programs. Maintain the SPNEGO context structure after context
establishment and refer to it in all GSS methods. Add initiate and
opened flags to the SPNEGO context structure for use in
gss_inquire_context() prior to context establishment.
CVE-2015-2695:
In MIT krb5 1.5 and later, applications which call
gss_inquire_context() on a partially-established SPNEGO context can
cause the GSS-API library to read from a pointer using the wrong type,
generally causing a process crash. This bug may go unnoticed, because
the most common SPNEGO authentication scenario establishes the context
after just one call to gss_accept_sec_context(). Java server
applications using the native JGSS provider are vulnerable to this
bug. A carefully crafted SPNEGO packet might allow the
gss_inquire_context() call to succeed with attacker-determined
results, but applications should not make access control decisions
based on gss_inquire_context() results prior to context establishment.
CVSSv2 Vector: AV:N/AC:M/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C
[ghudson@mit.edu: several bugfixes, style changes, and edge-case
behavior changes; commit message and CVE description]
ticket: 8244
target_version: 1.14
tags: pullup
CWE ID: CWE-18 | 1 | 166,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 int vcpu_enter_guest(struct kvm_vcpu *vcpu)
{
int r;
bool req_int_win =
dm_request_for_irq_injection(vcpu) &&
kvm_cpu_accept_dm_intr(vcpu);
bool req_immediate_exit = false;
if (vcpu->requests) {
if (kvm_check_request(KVM_REQ_MMU_RELOAD, vcpu))
kvm_mmu_unload(vcpu);
if (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu))
__kvm_migrate_timers(vcpu);
if (kvm_check_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu))
kvm_gen_update_masterclock(vcpu->kvm);
if (kvm_check_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu))
kvm_gen_kvmclock_update(vcpu);
if (kvm_check_request(KVM_REQ_CLOCK_UPDATE, vcpu)) {
r = kvm_guest_time_update(vcpu);
if (unlikely(r))
goto out;
}
if (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu))
kvm_mmu_sync_roots(vcpu);
if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu))
kvm_vcpu_flush_tlb(vcpu);
if (kvm_check_request(KVM_REQ_REPORT_TPR_ACCESS, vcpu)) {
vcpu->run->exit_reason = KVM_EXIT_TPR_ACCESS;
r = 0;
goto out;
}
if (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {
vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;
r = 0;
goto out;
}
if (kvm_check_request(KVM_REQ_DEACTIVATE_FPU, vcpu)) {
vcpu->fpu_active = 0;
kvm_x86_ops->fpu_deactivate(vcpu);
}
if (kvm_check_request(KVM_REQ_APF_HALT, vcpu)) {
/* Page is swapped out. Do synthetic halt */
vcpu->arch.apf.halted = true;
r = 1;
goto out;
}
if (kvm_check_request(KVM_REQ_STEAL_UPDATE, vcpu))
record_steal_time(vcpu);
if (kvm_check_request(KVM_REQ_SMI, vcpu))
process_smi(vcpu);
if (kvm_check_request(KVM_REQ_NMI, vcpu))
process_nmi(vcpu);
if (kvm_check_request(KVM_REQ_PMU, vcpu))
kvm_pmu_handle_event(vcpu);
if (kvm_check_request(KVM_REQ_PMI, vcpu))
kvm_pmu_deliver_pmi(vcpu);
if (kvm_check_request(KVM_REQ_IOAPIC_EOI_EXIT, vcpu)) {
BUG_ON(vcpu->arch.pending_ioapic_eoi > 255);
if (test_bit(vcpu->arch.pending_ioapic_eoi,
(void *) vcpu->arch.eoi_exit_bitmap)) {
vcpu->run->exit_reason = KVM_EXIT_IOAPIC_EOI;
vcpu->run->eoi.vector =
vcpu->arch.pending_ioapic_eoi;
r = 0;
goto out;
}
}
if (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu))
vcpu_scan_ioapic(vcpu);
if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu))
kvm_vcpu_reload_apic_access_page(vcpu);
if (kvm_check_request(KVM_REQ_HV_CRASH, vcpu)) {
vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
vcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH;
r = 0;
goto out;
}
if (kvm_check_request(KVM_REQ_HV_RESET, vcpu)) {
vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
vcpu->run->system_event.type = KVM_SYSTEM_EVENT_RESET;
r = 0;
goto out;
}
}
/*
* KVM_REQ_EVENT is not set when posted interrupts are set by
* VT-d hardware, so we have to update RVI unconditionally.
*/
if (kvm_lapic_enabled(vcpu)) {
/*
* Update architecture specific hints for APIC
* virtual interrupt delivery.
*/
if (kvm_x86_ops->hwapic_irr_update)
kvm_x86_ops->hwapic_irr_update(vcpu,
kvm_lapic_find_highest_irr(vcpu));
}
if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
kvm_apic_accept_events(vcpu);
if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
r = 1;
goto out;
}
if (inject_pending_event(vcpu, req_int_win) != 0)
req_immediate_exit = true;
/* enable NMI/IRQ window open exits if needed */
else if (vcpu->arch.nmi_pending)
kvm_x86_ops->enable_nmi_window(vcpu);
else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win)
kvm_x86_ops->enable_irq_window(vcpu);
if (kvm_lapic_enabled(vcpu)) {
update_cr8_intercept(vcpu);
kvm_lapic_sync_to_vapic(vcpu);
}
}
r = kvm_mmu_reload(vcpu);
if (unlikely(r)) {
goto cancel_injection;
}
preempt_disable();
kvm_x86_ops->prepare_guest_switch(vcpu);
if (vcpu->fpu_active)
kvm_load_guest_fpu(vcpu);
kvm_load_guest_xcr0(vcpu);
vcpu->mode = IN_GUEST_MODE;
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
/* We should set ->mode before check ->requests,
* see the comment in make_all_cpus_request.
*/
smp_mb__after_srcu_read_unlock();
local_irq_disable();
if (vcpu->mode == EXITING_GUEST_MODE || vcpu->requests
|| need_resched() || signal_pending(current)) {
vcpu->mode = OUTSIDE_GUEST_MODE;
smp_wmb();
local_irq_enable();
preempt_enable();
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
r = 1;
goto cancel_injection;
}
if (req_immediate_exit)
smp_send_reschedule(vcpu->cpu);
trace_kvm_entry(vcpu->vcpu_id);
wait_lapic_expire(vcpu);
__kvm_guest_enter();
if (unlikely(vcpu->arch.switch_db_regs)) {
set_debugreg(0, 7);
set_debugreg(vcpu->arch.eff_db[0], 0);
set_debugreg(vcpu->arch.eff_db[1], 1);
set_debugreg(vcpu->arch.eff_db[2], 2);
set_debugreg(vcpu->arch.eff_db[3], 3);
set_debugreg(vcpu->arch.dr6, 6);
vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
}
kvm_x86_ops->run(vcpu);
/*
* Do this here before restoring debug registers on the host. And
* since we do this before handling the vmexit, a DR access vmexit
* can (a) read the correct value of the debug registers, (b) set
* KVM_DEBUGREG_WONT_EXIT again.
*/
if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) {
int i;
WARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);
kvm_x86_ops->sync_dirty_debug_regs(vcpu);
for (i = 0; i < KVM_NR_DB_REGS; i++)
vcpu->arch.eff_db[i] = vcpu->arch.db[i];
}
/*
* If the guest has used debug registers, at least dr7
* will be disabled while returning to the host.
* If we don't have active breakpoints in the host, we don't
* care about the messed up debug address registers. But if
* we have some of them active, restore the old state.
*/
if (hw_breakpoint_active())
hw_breakpoint_restore();
vcpu->arch.last_guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc());
vcpu->mode = OUTSIDE_GUEST_MODE;
smp_wmb();
/* Interrupt is enabled by handle_external_intr() */
kvm_x86_ops->handle_external_intr(vcpu);
++vcpu->stat.exits;
/*
* We must have an instruction between local_irq_enable() and
* kvm_guest_exit(), so the timer interrupt isn't delayed by
* the interrupt shadow. The stat.exits increment will do nicely.
* But we need to prevent reordering, hence this barrier():
*/
barrier();
kvm_guest_exit();
preempt_enable();
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
/*
* Profile KVM exit RIPs:
*/
if (unlikely(prof_on == KVM_PROFILING)) {
unsigned long rip = kvm_rip_read(vcpu);
profile_hit(KVM_PROFILING, (void *)rip);
}
if (unlikely(vcpu->arch.tsc_always_catchup))
kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
if (vcpu->arch.apic_attention)
kvm_lapic_sync_from_vapic(vcpu);
r = kvm_x86_ops->handle_exit(vcpu);
return r;
cancel_injection:
kvm_x86_ops->cancel_injection(vcpu);
if (unlikely(vcpu->arch.apic_attention))
kvm_lapic_sync_from_vapic(vcpu);
out:
return r;
}
Commit Message: KVM: x86: Reload pit counters for all channels when restoring state
Currently if userspace restores the pit counters with a count of 0
on channels 1 or 2 and the guest attempts to read the count on those
channels, then KVM will perform a mod of 0 and crash. This will ensure
that 0 values are converted to 65536 as per the spec.
This is CVE-2015-7513.
Signed-off-by: Andy Honig <ahonig@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: | 0 | 57,804 |
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: connection_ap_mark_as_non_pending_circuit(entry_connection_t *entry_conn)
{
if (PREDICT_UNLIKELY(NULL == pending_entry_connections))
return;
UNMARK();
smartlist_remove(pending_entry_connections, entry_conn);
}
Commit Message: TROVE-2017-004: Fix assertion failure in relay_send_end_cell_from_edge_
This fixes an assertion failure in relay_send_end_cell_from_edge_() when an
origin circuit and a cpath_layer = NULL were passed.
A service rendezvous circuit could do such a thing when a malformed BEGIN cell
is received but shouldn't in the first place because the service needs to send
an END cell on the circuit for which it can not do without a cpath_layer.
Fixes #22493
Reported-by: Roger Dingledine <arma@torproject.org>
Signed-off-by: David Goulet <dgoulet@torproject.org>
CWE ID: CWE-617 | 0 | 69,900 |
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: wv_csp13_opaque_literal_tag(tvbuff_t *tvb, guint32 offset,
const char *token, guint8 codepage _U_, guint32 *length)
{
guint32 data_len = tvb_get_guintvar(tvb, offset, length);
char *str = NULL;
if ( token && ( (strcmp(token, "Code") == 0)
|| (strcmp(token, "ContentSize") == 0)
|| (strcmp(token, "MessageCount") == 0)
|| (strcmp(token, "Validity") == 0)
|| (strcmp(token, "KeepAliveTime") == 0)
|| (strcmp(token, "TimeToLive") == 0)
|| (strcmp(token, "AcceptedContentLength") == 0)
|| (strcmp(token, "MultiTrans") == 0)
|| (strcmp(token, "ParserSize") == 0)
|| (strcmp(token, "ServerPollMin") == 0)
|| (strcmp(token, "TCPPort") == 0)
|| (strcmp(token, "UDPPort") == 0)
|| (strcmp(token, "HistoryPeriod") == 0)
|| (strcmp(token, "MaxWatcherList") == 0)
/* New in WV-CSP 1.3*/
|| (strcmp(token, "SearchFindings") == 0)
|| (strcmp(token, "SearchID") == 0)
|| (strcmp(token, "SearchIndex") == 0)
|| (strcmp(token, "SearchLimit") == 0)
|| (strcmp(token, "AcceptedPullLength") == 0)
|| (strcmp(token, "AcceptedPushLength") == 0)
|| (strcmp(token, "AcceptedRichContentLength") == 0)
|| (strcmp(token, "AcceptedTextContentLength") == 0)
|| (strcmp(token, "SessionPriority") == 0)
|| (strcmp(token, "UserSessionLimit") == 0)
|| (strcmp(token, "MultiTransPerMessage") == 0)
|| (strcmp(token, "ContentPolicyLimit") == 0)
|| (strcmp(token, "AnswerOptionID") == 0)
|| (strcmp(token, "SegmentCount") == 0)
|| (strcmp(token, "SegmentReference") == 0)
|| (strcmp(token, "TryAgainTimeout") == 0)
|| (strcmp(token, "GroupContentLimit") == 0)
|| (strcmp(token, "MessageTotalCount") == 0)
|| (strcmp(token, "PairID") == 0) ) )
{
str = wv_integer_from_opaque(tvb, offset + *length, data_len);
}
else
if ( token && ( (strcmp(token, "DateTime") == 0)
|| (strcmp(token, "DeliveryTime") == 0) ) )
{
str = wv_datetime_from_opaque(tvb, offset + *length, data_len);
}
if (str == NULL) { /* Error, or not parsed */
str = wmem_strdup_printf(wmem_packet_scope(), "(%d bytes of unparsed opaque data)", data_len);
}
*length += data_len;
return str;
}
Commit Message: WBXML: add a basic sanity check for offset overflow
This is a naive approach allowing to detact that something went wrong,
without the need to replace all proto_tree_add_text() calls as what was
done in master-2.0 branch.
Bug: 12408
Change-Id: Ia14905005e17ae322c2fc639ad5e491fa08b0108
Reviewed-on: https://code.wireshark.org/review/15310
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
CWE ID: CWE-119 | 0 | 51,725 |
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 jlong GetAwDrawGLFunction(JNIEnv* env, const JavaParamRef<jclass>&) {
return reinterpret_cast<intptr_t>(&DrawGLFunction);
}
Commit Message: sync compositor: pass simple gfx types by const ref
See bug for reasoning
BUG=159273
Review URL: https://codereview.chromium.org/1417893006
Cr-Commit-Position: refs/heads/master@{#356653}
CWE ID: CWE-399 | 0 | 119,583 |
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 RenderFrameHostImpl::OnCreateChildFrame(
int new_routing_id,
service_manager::mojom::InterfaceProviderRequest
new_interface_provider_provider_request,
blink::WebTreeScopeType scope,
const std::string& frame_name,
const std::string& frame_unique_name,
bool is_created_by_script,
const base::UnguessableToken& devtools_frame_token,
const blink::FramePolicy& frame_policy,
const FrameOwnerProperties& frame_owner_properties,
const blink::FrameOwnerElementType owner_type) {
DCHECK(!frame_unique_name.empty());
DCHECK(new_interface_provider_provider_request.is_pending());
if (owner_type == blink::FrameOwnerElementType::kNone) {
bad_message::ReceivedBadMessage(
GetProcess(), bad_message::RFH_CHILD_FRAME_NEEDS_OWNER_ELEMENT_TYPE);
}
if (!is_active() || !IsCurrent() || !render_frame_created_)
return;
frame_tree_->AddFrame(
frame_tree_node_, GetProcess()->GetID(), new_routing_id,
std::move(new_interface_provider_provider_request), scope, frame_name,
frame_unique_name, is_created_by_script, devtools_frame_token,
frame_policy, frame_owner_properties, was_discarded_, owner_type);
}
Commit Message: Make MediaStreamDispatcherHost per-request instead of per-frame.
Instead of having RenderFrameHost own a single MSDH to handle all
requests from a frame, MSDH objects will be owned by a strong binding.
A consequence of this is that an additional requester ID is added to
requests to MediaStreamManager, so that an MSDH is able to cancel only
requests generated by it.
In practice, MSDH will continue to be per frame in most cases since
each frame normally makes a single request for an MSDH object.
This fixes a lifetime issue caused by the IO thread executing tasks
after the RenderFrameHost dies.
Drive-by: Fix some minor lint issues.
Bug: 912520
Change-Id: I52742ffc98b9fc57ce8e6f5093a61aed86d3e516
Reviewed-on: https://chromium-review.googlesource.com/c/1369799
Reviewed-by: Emircan Uysaler <emircan@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Olga Sharonova <olka@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616347}
CWE ID: CWE-189 | 0 | 153,111 |
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 addBitsToStream(size_t* bitpointer, ucvector* bitstream, unsigned value, size_t nbits)
{
size_t i;
for(i = 0; i < nbits; i++) addBitToStream(bitpointer, bitstream, (unsigned char)((value >> i) & 1));
}
Commit Message: Fixed #5645: realloc return handling
CWE ID: CWE-772 | 0 | 87,440 |
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 __exit crypto_ctr_module_exit(void)
{
crypto_unregister_template(&crypto_rfc3686_tmpl);
crypto_unregister_template(&crypto_ctr_tmpl);
}
Commit Message: crypto: include crypto- module prefix in template
This adds the module loading prefix "crypto-" to the template lookup
as well.
For example, attempting to load 'vfat(blowfish)' via AF_ALG now correctly
includes the "crypto-" prefix at every level, correctly rejecting "vfat":
net-pf-38
algif-hash
crypto-vfat(blowfish)
crypto-vfat(blowfish)-all
crypto-vfat
Reported-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
CWE ID: CWE-264 | 0 | 45,687 |
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: InspectorNetworkAgent::~InspectorNetworkAgent() {}
Commit Message: DevTools: send proper resource type in Network.RequestWillBeSent
This patch plumbs resoure type into the DispatchWillSendRequest
instrumenation. This allows us to report accurate type in
Network.RequestWillBeSent event, instead of "Other", that we report
today.
BUG=765501
R=dgozman
Change-Id: I0134c08b841e8dd247fdc8ff208bfd51e462709c
Reviewed-on: https://chromium-review.googlesource.com/667504
Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507936}
CWE ID: CWE-119 | 0 | 138,545 |
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 estimated_size() const {
return estimated_size_;
}
Commit Message: Always write data to new buffer in SimulateAttrib0
This is to work around linux nvidia driver bug.
TEST=asan
BUG=118970
Review URL: http://codereview.chromium.org/10019003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131538 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 109,036 |
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 BrowserWindowGtk::InfoBarContainerStateChanged(bool is_animating) {
InvalidateInfoBarBits();
}
Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt.
BUG=107201
TEST=no visible change
Review URL: https://chromiumcodereview.appspot.com/11293205
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-20 | 0 | 117,952 |
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: PrintingContext::Result PrintingContextCairo::UseDefaultSettings() {
DCHECK(!in_print_job_);
ResetSettings();
#if defined(OS_CHROMEOS)
int dpi = 300;
gfx::Size physical_size_device_units;
gfx::Rect printable_area_device_units;
int32_t width = 0;
int32_t height = 0;
UErrorCode error = U_ZERO_ERROR;
ulocdata_getPaperSize(app_locale_.c_str(), &height, &width, &error);
if (error != U_ZERO_ERROR) {
LOG(WARNING) << "ulocdata_getPaperSize failed, using 8.5 x 11, error: "
<< error;
width = static_cast<int>(8.5 * dpi);
height = static_cast<int>(11 * dpi);
} else {
width = static_cast<int>(ConvertUnitDouble(width, 25.4, 1.0) * dpi);
height = static_cast<int>(ConvertUnitDouble(height, 25.4, 1.0) * dpi);
}
physical_size_device_units.SetSize(width, height);
printable_area_device_units.SetRect(
static_cast<int>(PrintSettingsInitializerGtk::kLeftMarginInInch * dpi),
static_cast<int>(PrintSettingsInitializerGtk::kTopMarginInInch * dpi),
width - (PrintSettingsInitializerGtk::kLeftMarginInInch +
PrintSettingsInitializerGtk::kRightMarginInInch) * dpi,
height - (PrintSettingsInitializerGtk::kTopMarginInInch +
PrintSettingsInitializerGtk::kBottomMarginInInch) * dpi);
settings_.set_dpi(dpi);
settings_.SetPrinterPrintableArea(physical_size_device_units,
printable_area_device_units,
dpi);
#else
if (!print_dialog_) {
print_dialog_ = create_dialog_func_(this);
print_dialog_->AddRefToDialog();
}
print_dialog_->UseDefaultSettings();
#endif // defined(OS_CHROMEOS)
return OK;
}
Commit Message: Fix print preview workflow to reflect settings of selected printer.
BUG=95110
TEST=none
Review URL: http://codereview.chromium.org/7831041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102242 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 97,572 |
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: EnumTraits<media::mojom::VideoCaptureError, media::VideoCaptureError>::ToMojom(
media::VideoCaptureError input) {
switch (input) {
case media::VideoCaptureError::kNone:
return media::mojom::VideoCaptureError::kNone;
case media::VideoCaptureError::
kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested:
return media::mojom::VideoCaptureError::
kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested;
case media::VideoCaptureError::kVideoCaptureControllerIsAlreadyInErrorState:
return media::mojom::VideoCaptureError::
kVideoCaptureControllerIsAlreadyInErrorState;
case media::VideoCaptureError::kVideoCaptureManagerDeviceConnectionLost:
return media::mojom::VideoCaptureError::
kVideoCaptureManagerDeviceConnectionLost;
case media::VideoCaptureError::
kFrameSinkVideoCaptureDeviceAleradyEndedOnFatalError:
return media::mojom::VideoCaptureError::
kFrameSinkVideoCaptureDeviceAleradyEndedOnFatalError;
case media::VideoCaptureError::
kFrameSinkVideoCaptureDeviceEncounteredFatalError:
return media::mojom::VideoCaptureError::
kFrameSinkVideoCaptureDeviceEncounteredFatalError;
case media::VideoCaptureError::kV4L2FailedToOpenV4L2DeviceDriverFile:
return media::mojom::VideoCaptureError::
kV4L2FailedToOpenV4L2DeviceDriverFile;
case media::VideoCaptureError::kV4L2ThisIsNotAV4L2VideoCaptureDevice:
return media::mojom::VideoCaptureError::
kV4L2ThisIsNotAV4L2VideoCaptureDevice;
case media::VideoCaptureError::kV4L2FailedToFindASupportedCameraFormat:
return media::mojom::VideoCaptureError::
kV4L2FailedToFindASupportedCameraFormat;
case media::VideoCaptureError::kV4L2FailedToSetVideoCaptureFormat:
return media::mojom::VideoCaptureError::
kV4L2FailedToSetVideoCaptureFormat;
case media::VideoCaptureError::kV4L2UnsupportedPixelFormat:
return media::mojom::VideoCaptureError::kV4L2UnsupportedPixelFormat;
case media::VideoCaptureError::kV4L2FailedToSetCameraFramerate:
return media::mojom::VideoCaptureError::kV4L2FailedToSetCameraFramerate;
case media::VideoCaptureError::kV4L2ErrorRequestingMmapBuffers:
return media::mojom::VideoCaptureError::kV4L2ErrorRequestingMmapBuffers;
case media::VideoCaptureError::kV4L2AllocateBufferFailed:
return media::mojom::VideoCaptureError::kV4L2AllocateBufferFailed;
case media::VideoCaptureError::kV4L2VidiocStreamonFailed:
return media::mojom::VideoCaptureError::kV4L2VidiocStreamonFailed;
case media::VideoCaptureError::kV4L2VidiocStreamoffFailed:
return media::mojom::VideoCaptureError::kV4L2VidiocStreamoffFailed;
case media::VideoCaptureError::kV4L2FailedToVidiocReqbufsWithCount0:
return media::mojom::VideoCaptureError::
kV4L2FailedToVidiocReqbufsWithCount0;
case media::VideoCaptureError::kV4L2PollFailed:
return media::mojom::VideoCaptureError::kV4L2PollFailed;
case media::VideoCaptureError::
kV4L2MultipleContinuousTimeoutsWhileReadPolling:
return media::mojom::VideoCaptureError::
kV4L2MultipleContinuousTimeoutsWhileReadPolling;
case media::VideoCaptureError::kV4L2FailedToDequeueCaptureBuffer:
return media::mojom::VideoCaptureError::kV4L2FailedToDequeueCaptureBuffer;
case media::VideoCaptureError::kV4L2FailedToEnqueueCaptureBuffer:
return media::mojom::VideoCaptureError::kV4L2FailedToEnqueueCaptureBuffer;
case media::VideoCaptureError::
kSingleClientVideoCaptureHostLostConnectionToDevice:
return media::mojom::VideoCaptureError::
kSingleClientVideoCaptureHostLostConnectionToDevice;
case media::VideoCaptureError::kSingleClientVideoCaptureDeviceLaunchAborted:
return media::mojom::VideoCaptureError::
kSingleClientVideoCaptureDeviceLaunchAborted;
case media::VideoCaptureError::
kDesktopCaptureDeviceWebrtcDesktopCapturerHasFailed:
return media::mojom::VideoCaptureError::
kDesktopCaptureDeviceWebrtcDesktopCapturerHasFailed;
case media::VideoCaptureError::kFileVideoCaptureDeviceCouldNotOpenVideoFile:
return media::mojom::VideoCaptureError::
kFileVideoCaptureDeviceCouldNotOpenVideoFile;
case media::VideoCaptureError::
kDeviceCaptureLinuxFailedToCreateVideoCaptureDelegate:
return media::mojom::VideoCaptureError::
kDeviceCaptureLinuxFailedToCreateVideoCaptureDelegate;
case media::VideoCaptureError::
kErrorFakeDeviceIntentionallyEmittingErrorEvent:
return media::mojom::VideoCaptureError::
kErrorFakeDeviceIntentionallyEmittingErrorEvent;
case media::VideoCaptureError::kDeviceClientTooManyFramesDroppedY16:
return media::mojom::VideoCaptureError::
kDeviceClientTooManyFramesDroppedY16;
case media::VideoCaptureError::
kDeviceMediaToMojoAdapterEncounteredUnsupportedBufferType:
return media::mojom::VideoCaptureError::
kDeviceMediaToMojoAdapterEncounteredUnsupportedBufferType;
case media::VideoCaptureError::
kVideoCaptureManagerProcessDeviceStartQueueDeviceInfoNotFound:
return media::mojom::VideoCaptureError::
kVideoCaptureManagerProcessDeviceStartQueueDeviceInfoNotFound;
case media::VideoCaptureError::
kInProcessDeviceLauncherFailedToCreateDeviceInstance:
return media::mojom::VideoCaptureError::
kInProcessDeviceLauncherFailedToCreateDeviceInstance;
case media::VideoCaptureError::
kServiceDeviceLauncherLostConnectionToDeviceFactoryDuringDeviceStart:
return media::mojom::VideoCaptureError::
kServiceDeviceLauncherLostConnectionToDeviceFactoryDuringDeviceStart;
case media::VideoCaptureError::
kServiceDeviceLauncherServiceRespondedWithDeviceNotFound:
return media::mojom::VideoCaptureError::
kServiceDeviceLauncherServiceRespondedWithDeviceNotFound;
case media::VideoCaptureError::
kServiceDeviceLauncherConnectionLostWhileWaitingForCallback:
return media::mojom::VideoCaptureError::
kServiceDeviceLauncherConnectionLostWhileWaitingForCallback;
case media::VideoCaptureError::kIntentionalErrorRaisedByUnitTest:
return media::mojom::VideoCaptureError::kIntentionalErrorRaisedByUnitTest;
case media::VideoCaptureError::kCrosHalV3FailedToStartDeviceThread:
return media::mojom::VideoCaptureError::
kCrosHalV3FailedToStartDeviceThread;
case media::VideoCaptureError::kCrosHalV3DeviceDelegateMojoConnectionError:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateMojoConnectionError;
case media::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToGetCameraInfo:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToGetCameraInfo;
case media::VideoCaptureError::
kCrosHalV3DeviceDelegateMissingSensorOrientationInfo:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateMissingSensorOrientationInfo;
case media::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToOpenCameraDevice:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToOpenCameraDevice;
case media::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToInitializeCameraDevice:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToInitializeCameraDevice;
case media::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToConfigureStreams:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToConfigureStreams;
case media::VideoCaptureError::
kCrosHalV3DeviceDelegateWrongNumberOfStreamsConfigured:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateWrongNumberOfStreamsConfigured;
case media::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToGetDefaultRequestSettings:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToGetDefaultRequestSettings;
case media::VideoCaptureError::
kCrosHalV3BufferManagerHalRequestedTooManyBuffers:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerHalRequestedTooManyBuffers;
case media::VideoCaptureError::
kCrosHalV3BufferManagerFailedToCreateGpuMemoryBuffer:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerFailedToCreateGpuMemoryBuffer;
case media::VideoCaptureError::
kCrosHalV3BufferManagerFailedToMapGpuMemoryBuffer:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerFailedToMapGpuMemoryBuffer;
case media::VideoCaptureError::
kCrosHalV3BufferManagerUnsupportedVideoPixelFormat:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerUnsupportedVideoPixelFormat;
case media::VideoCaptureError::kCrosHalV3BufferManagerFailedToDupFd:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerFailedToDupFd;
case media::VideoCaptureError::
kCrosHalV3BufferManagerFailedToWrapGpuMemoryHandle:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerFailedToWrapGpuMemoryHandle;
case media::VideoCaptureError::
kCrosHalV3BufferManagerFailedToRegisterBuffer:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerFailedToRegisterBuffer;
case media::VideoCaptureError::
kCrosHalV3BufferManagerProcessCaptureRequestFailed:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerProcessCaptureRequestFailed;
case media::VideoCaptureError::
kCrosHalV3BufferManagerInvalidPendingResultId:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerInvalidPendingResultId;
case media::VideoCaptureError::
kCrosHalV3BufferManagerReceivedDuplicatedPartialMetadata:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerReceivedDuplicatedPartialMetadata;
case media::VideoCaptureError::
kCrosHalV3BufferManagerIncorrectNumberOfOutputBuffersReceived:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerIncorrectNumberOfOutputBuffersReceived;
case media::VideoCaptureError::
kCrosHalV3BufferManagerInvalidTypeOfOutputBuffersReceived:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerInvalidTypeOfOutputBuffersReceived;
case media::VideoCaptureError::
kCrosHalV3BufferManagerReceivedMultipleResultBuffersForFrame:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerReceivedMultipleResultBuffersForFrame;
case media::VideoCaptureError::
kCrosHalV3BufferManagerUnknownStreamInCamera3NotifyMsg:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerUnknownStreamInCamera3NotifyMsg;
case media::VideoCaptureError::
kCrosHalV3BufferManagerReceivedInvalidShutterTime:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerReceivedInvalidShutterTime;
case media::VideoCaptureError::kCrosHalV3BufferManagerFatalDeviceError:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerFatalDeviceError;
case media::VideoCaptureError::
kCrosHalV3BufferManagerReceivedFrameIsOutOfOrder:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerReceivedFrameIsOutOfOrder;
case media::VideoCaptureError::
kCrosHalV3BufferManagerFailedToUnwrapReleaseFenceFd:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerFailedToUnwrapReleaseFenceFd;
case media::VideoCaptureError::
kCrosHalV3BufferManagerSyncWaitOnReleaseFenceTimedOut:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerSyncWaitOnReleaseFenceTimedOut;
case media::VideoCaptureError::kCrosHalV3BufferManagerInvalidJpegBlob:
return media::mojom::VideoCaptureError::
kCrosHalV3BufferManagerInvalidJpegBlob;
case media::VideoCaptureError::kAndroidFailedToAllocate:
return media::mojom::VideoCaptureError::kAndroidFailedToAllocate;
case media::VideoCaptureError::kAndroidFailedToStartCapture:
return media::mojom::VideoCaptureError::kAndroidFailedToStartCapture;
case media::VideoCaptureError::kAndroidFailedToStopCapture:
return media::mojom::VideoCaptureError::kAndroidFailedToStopCapture;
case media::VideoCaptureError::kAndroidApi1CameraErrorCallbackReceived:
return media::mojom::VideoCaptureError::
kAndroidApi1CameraErrorCallbackReceived;
case media::VideoCaptureError::kAndroidApi2CameraDeviceErrorReceived:
return media::mojom::VideoCaptureError::
kAndroidApi2CameraDeviceErrorReceived;
case media::VideoCaptureError::kAndroidApi2CaptureSessionConfigureFailed:
return media::mojom::VideoCaptureError::
kAndroidApi2CaptureSessionConfigureFailed;
case media::VideoCaptureError::kAndroidApi2ImageReaderUnexpectedImageFormat:
return media::mojom::VideoCaptureError::
kAndroidApi2ImageReaderUnexpectedImageFormat;
case media::VideoCaptureError::
kAndroidApi2ImageReaderSizeDidNotMatchImageSize:
return media::mojom::VideoCaptureError::
kAndroidApi2ImageReaderSizeDidNotMatchImageSize;
case media::VideoCaptureError::kAndroidApi2ErrorRestartingPreview:
return media::mojom::VideoCaptureError::
kAndroidApi2ErrorRestartingPreview;
case media::VideoCaptureError::kAndroidScreenCaptureUnsupportedFormat:
return media::mojom::VideoCaptureError::
kAndroidScreenCaptureUnsupportedFormat;
case media::VideoCaptureError::
kAndroidScreenCaptureFailedToStartCaptureMachine:
return media::mojom::VideoCaptureError::
kAndroidScreenCaptureFailedToStartCaptureMachine;
case media::VideoCaptureError::
kAndroidScreenCaptureTheUserDeniedScreenCapture:
return media::mojom::VideoCaptureError::
kAndroidScreenCaptureTheUserDeniedScreenCapture;
case media::VideoCaptureError::
kAndroidScreenCaptureFailedToStartScreenCapture:
return media::mojom::VideoCaptureError::
kAndroidScreenCaptureFailedToStartScreenCapture;
case media::VideoCaptureError::kWinDirectShowCantGetCaptureFormatSettings:
return media::mojom::VideoCaptureError::
kWinDirectShowCantGetCaptureFormatSettings;
case media::VideoCaptureError::
kWinDirectShowFailedToGetNumberOfCapabilities:
return media::mojom::VideoCaptureError::
kWinDirectShowFailedToGetNumberOfCapabilities;
case media::VideoCaptureError::
kWinDirectShowFailedToGetCaptureDeviceCapabilities:
return media::mojom::VideoCaptureError::
kWinDirectShowFailedToGetCaptureDeviceCapabilities;
case media::VideoCaptureError::
kWinDirectShowFailedToSetCaptureDeviceOutputFormat:
return media::mojom::VideoCaptureError::
kWinDirectShowFailedToSetCaptureDeviceOutputFormat;
case media::VideoCaptureError::kWinDirectShowFailedToConnectTheCaptureGraph:
return media::mojom::VideoCaptureError::
kWinDirectShowFailedToConnectTheCaptureGraph;
case media::VideoCaptureError::kWinDirectShowFailedToPauseTheCaptureDevice:
return media::mojom::VideoCaptureError::
kWinDirectShowFailedToPauseTheCaptureDevice;
case media::VideoCaptureError::kWinDirectShowFailedToStartTheCaptureDevice:
return media::mojom::VideoCaptureError::
kWinDirectShowFailedToStartTheCaptureDevice;
case media::VideoCaptureError::kWinDirectShowFailedToStopTheCaptureGraph:
return media::mojom::VideoCaptureError::
kWinDirectShowFailedToStopTheCaptureGraph;
case media::VideoCaptureError::kWinMediaFoundationEngineIsNull:
return media::mojom::VideoCaptureError::kWinMediaFoundationEngineIsNull;
case media::VideoCaptureError::kWinMediaFoundationEngineGetSourceFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationEngineGetSourceFailed;
case media::VideoCaptureError::
kWinMediaFoundationFillPhotoCapabilitiesFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationFillPhotoCapabilitiesFailed;
case media::VideoCaptureError::
kWinMediaFoundationFillVideoCapabilitiesFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationFillVideoCapabilitiesFailed;
case media::VideoCaptureError::kWinMediaFoundationNoVideoCapabilityFound:
return media::mojom::VideoCaptureError::
kWinMediaFoundationNoVideoCapabilityFound;
case media::VideoCaptureError::
kWinMediaFoundationGetAvailableDeviceMediaTypeFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationGetAvailableDeviceMediaTypeFailed;
case media::VideoCaptureError::
kWinMediaFoundationSetCurrentDeviceMediaTypeFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationSetCurrentDeviceMediaTypeFailed;
case media::VideoCaptureError::kWinMediaFoundationEngineGetSinkFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationEngineGetSinkFailed;
case media::VideoCaptureError::
kWinMediaFoundationSinkQueryCapturePreviewInterfaceFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationSinkQueryCapturePreviewInterfaceFailed;
case media::VideoCaptureError::
kWinMediaFoundationSinkRemoveAllStreamsFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationSinkRemoveAllStreamsFailed;
case media::VideoCaptureError::
kWinMediaFoundationCreateSinkVideoMediaTypeFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationCreateSinkVideoMediaTypeFailed;
case media::VideoCaptureError::
kWinMediaFoundationConvertToVideoSinkMediaTypeFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationConvertToVideoSinkMediaTypeFailed;
case media::VideoCaptureError::kWinMediaFoundationSinkAddStreamFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationSinkAddStreamFailed;
case media::VideoCaptureError::
kWinMediaFoundationSinkSetSampleCallbackFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationSinkSetSampleCallbackFailed;
case media::VideoCaptureError::kWinMediaFoundationEngineStartPreviewFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationEngineStartPreviewFailed;
case media::VideoCaptureError::kWinMediaFoundationGetMediaEventStatusFailed:
return media::mojom::VideoCaptureError::
kWinMediaFoundationGetMediaEventStatusFailed;
case media::VideoCaptureError::kMacSetCaptureDeviceFailed:
return media::mojom::VideoCaptureError::kMacSetCaptureDeviceFailed;
case media::VideoCaptureError::kMacCouldNotStartCaptureDevice:
return media::mojom::VideoCaptureError::kMacCouldNotStartCaptureDevice;
case media::VideoCaptureError::kMacReceivedFrameWithUnexpectedResolution:
return media::mojom::VideoCaptureError::
kMacReceivedFrameWithUnexpectedResolution;
case media::VideoCaptureError::kMacUpdateCaptureResolutionFailed:
return media::mojom::VideoCaptureError::kMacUpdateCaptureResolutionFailed;
case media::VideoCaptureError::kMacDeckLinkDeviceIdNotFoundInTheSystem:
return media::mojom::VideoCaptureError::
kMacDeckLinkDeviceIdNotFoundInTheSystem;
case media::VideoCaptureError::kMacDeckLinkErrorQueryingInputInterface:
return media::mojom::VideoCaptureError::
kMacDeckLinkErrorQueryingInputInterface;
case media::VideoCaptureError::kMacDeckLinkErrorCreatingDisplayModeIterator:
return media::mojom::VideoCaptureError::
kMacDeckLinkErrorCreatingDisplayModeIterator;
case media::VideoCaptureError::kMacDeckLinkCouldNotFindADisplayMode:
return media::mojom::VideoCaptureError::
kMacDeckLinkCouldNotFindADisplayMode;
case media::VideoCaptureError::
kMacDeckLinkCouldNotSelectTheVideoFormatWeLike:
return media::mojom::VideoCaptureError::
kMacDeckLinkCouldNotSelectTheVideoFormatWeLike;
case media::VideoCaptureError::kMacDeckLinkCouldNotStartCapturing:
return media::mojom::VideoCaptureError::
kMacDeckLinkCouldNotStartCapturing;
case media::VideoCaptureError::kMacDeckLinkUnsupportedPixelFormat:
return media::mojom::VideoCaptureError::
kMacDeckLinkUnsupportedPixelFormat;
case media::VideoCaptureError::
kMacAvFoundationReceivedAVCaptureSessionRuntimeErrorNotification:
return media::mojom::VideoCaptureError::
kMacAvFoundationReceivedAVCaptureSessionRuntimeErrorNotification;
case media::VideoCaptureError::kAndroidApi2ErrorConfiguringCamera:
return media::mojom::VideoCaptureError::
kAndroidApi2ErrorConfiguringCamera;
case media::VideoCaptureError::kCrosHalV3DeviceDelegateFailedToFlush:
return media::mojom::VideoCaptureError::
kCrosHalV3DeviceDelegateFailedToFlush;
}
NOTREACHED();
return media::mojom::VideoCaptureError::kNone;
}
Commit Message: Revert "Enable camera blob stream when needed"
This reverts commit 10f4b93635e12f9fa0cba1641a10938ca38ed448.
Reason for revert:
Findit (https://goo.gl/kROfz5) identified CL at revision 601492 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzEwZjRiOTM2MzVlMTJmOWZhMGNiYTE2NDFhMTA5MzhjYTM4ZWQ0NDgM
Sample Failed Build: https://ci.chromium.org/buildbot/chromium.memory/Linux%20ChromiumOS%20MSan%20Tests/9190
Sample Failed Step: capture_unittests
Original change's description:
> Enable camera blob stream when needed
>
> Since blob stream needs higher resolution, it causes higher cpu loading
> to require higher resolution and resize to smaller resolution.
> In hangout app, we don't need blob stream. Enabling blob stream when
> needed can save a lot of cpu usage.
>
> BUG=b:114676133
> TEST=manually test in apprtc and CCA. make sure picture taking still
> works in CCA.
>
> Change-Id: I9144461bc76627903d0b3b359ce9cf962ff3628c
> Reviewed-on: https://chromium-review.googlesource.com/c/1261242
> Commit-Queue: Heng-ruey Hsu <henryhsu@chromium.org>
> Reviewed-by: Ricky Liang <jcliang@chromium.org>
> Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#601492}
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
BUG=b:114676133
Change-Id: If173ffe9259f7eca849b184806bd56e2a9fbaac4
Reviewed-on: https://chromium-review.googlesource.com/c/1292256
Cr-Commit-Position: refs/heads/master@{#601538}
CWE ID: CWE-19 | 1 | 172,513 |
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 perf_swevent_add(struct perf_event *event, int flags)
{
struct swevent_htable *swhash = this_cpu_ptr(&swevent_htable);
struct hw_perf_event *hwc = &event->hw;
struct hlist_head *head;
if (is_sampling_event(event)) {
hwc->last_period = hwc->sample_period;
perf_swevent_set_period(event);
}
hwc->state = !(flags & PERF_EF_START);
head = find_swevent_head(swhash, event);
if (!head) {
/*
* We can race with cpu hotplug code. Do not
* WARN if the cpu just got unplugged.
*/
WARN_ON_ONCE(swhash->online);
return -EINVAL;
}
hlist_add_head_rcu(&event->hlist_entry, head);
perf_event_update_userpage(event);
return 0;
}
Commit Message: perf: Fix race in swevent hash
There's a race on CPU unplug where we free the swevent hash array
while it can still have events on. This will result in a
use-after-free which is BAD.
Simply do not free the hash array on unplug. This leaves the thing
around and no use-after-free takes place.
When the last swevent dies, we do a for_each_possible_cpu() iteration
anyway to clean these up, at which time we'll free it, so no leakage
will occur.
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
CWE ID: CWE-416 | 1 | 167,462 |
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 decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
{
__be32 *p;
uint32_t bmlen;
int status;
status = decode_op_hdr(xdr, OP_CREATE);
if (status)
return status;
if ((status = decode_change_info(xdr, cinfo)))
return status;
p = xdr_inline_decode(xdr, 4);
if (unlikely(!p))
goto out_overflow;
bmlen = be32_to_cpup(p);
p = xdr_inline_decode(xdr, bmlen << 2);
if (likely(p))
return 0;
out_overflow:
print_overflow_msg(__func__, xdr);
return -EIO;
}
Commit Message: NFSv4: include bitmap in nfsv4 get acl data
The NFSv4 bitmap size is unbounded: a server can return an arbitrary
sized bitmap in an FATTR4_WORD0_ACL request. Replace using the
nfs4_fattr_bitmap_maxsz as a guess to the maximum bitmask returned by a server
with the inclusion of the bitmap (xdr length plus bitmasks) and the acl data
xdr length to the (cached) acl page data.
This is a general solution to commit e5012d1f "NFSv4.1: update
nfs4_fattr_bitmap_maxsz" and fixes hitting a BUG_ON in xdr_shrink_bufhead
when getting ACLs.
Fix a bug in decode_getacl that returned -EINVAL on ACLs > page when getxattr
was called with a NULL buffer, preventing ACL > PAGE_SIZE from being retrieved.
Cc: stable@kernel.org
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
CWE ID: CWE-189 | 0 | 23,295 |
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 void fib6_walker_unlink(struct fib6_walker_t *w)
{
write_lock_bh(&fib6_walker_lock);
list_del(&w->lh);
write_unlock_bh(&fib6_walker_lock);
}
Commit Message: net: fib: fib6_add: fix potential NULL pointer dereference
When the kernel is compiled with CONFIG_IPV6_SUBTREES, and we return
with an error in fn = fib6_add_1(), then error codes are encoded into
the return pointer e.g. ERR_PTR(-ENOENT). In such an error case, we
write the error code into err and jump to out, hence enter the if(err)
condition. Now, if CONFIG_IPV6_SUBTREES is enabled, we check for:
if (pn != fn && pn->leaf == rt)
...
if (pn != fn && !pn->leaf && !(pn->fn_flags & RTN_RTINFO))
...
Since pn is NULL and fn is f.e. ERR_PTR(-ENOENT), then pn != fn
evaluates to true and causes a NULL-pointer dereference on further
checks on pn. Fix it, by setting both NULL in error case, so that
pn != fn already evaluates to false and no further dereference
takes place.
This was first correctly implemented in 4a287eba2 ("IPv6 routing,
NLM_F_* flag support: REPLACE and EXCL flags support, warn about
missing CREATE flag"), but the bug got later on introduced by
188c517a0 ("ipv6: return errno pointers consistently for fib6_add_1()").
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Cc: Lin Ming <mlin@ss.pku.edu.cn>
Cc: Matti Vaittinen <matti.vaittinen@nsn.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Matti Vaittinen <matti.vaittinen@nsn.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-264 | 0 | 28,434 |
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: gfx::Point RenderView::GetScrollOffset() {
WebSize scroll_offset = webview()->mainFrame()->scrollOffset();
return gfx::Point(scroll_offset.width, scroll_offset.height);
}
Commit Message: DevTools: move DevToolsAgent/Client into content.
BUG=84078
TEST=
Review URL: http://codereview.chromium.org/7461019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93596 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-20 | 0 | 98,915 |
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: server_file(struct httpd *env, struct client *clt)
{
struct http_descriptor *desc = clt->clt_descreq;
struct server_config *srv_conf = clt->clt_srv_conf;
char path[PATH_MAX];
const char *stripped, *errstr = NULL;
int ret = 500;
if (srv_conf->flags & SRVFLAG_FCGI)
return (server_fcgi(env, clt));
/* Request path is already canonicalized */
stripped = server_root_strip(
desc->http_path_alias != NULL ?
desc->http_path_alias : desc->http_path,
srv_conf->strip);
if ((size_t)snprintf(path, sizeof(path), "%s%s",
srv_conf->root, stripped) >= sizeof(path)) {
errstr = desc->http_path;
goto abort;
}
/* Returns HTTP status code on error */
if ((ret = server_file_access(env, clt, path, sizeof(path))) > 0) {
errstr = desc->http_path_alias != NULL ?
desc->http_path_alias : desc->http_path;
goto abort;
}
return (ret);
abort:
if (errstr == NULL)
errstr = strerror(errno);
server_abort_http(clt, ret, errstr);
return (-1);
}
Commit Message: Reimplement httpd's support for byte ranges.
The previous implementation loaded all the output into a single output
buffer and used its size to determine the Content-Length of the body.
The new implementation calculates the body length first and writes the
individual ranges in an async way using the bufferevent mechanism.
This prevents httpd from using too much memory and applies the
watermark and throttling mechanisms to range requests.
Problem reported by Pierre Kim (pierre.kim.sec at gmail.com)
OK benno@ sunil@
CWE ID: CWE-770 | 0 | 68,484 |
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: xfs_attr3_leaf_getvalue(
struct xfs_buf *bp,
struct xfs_da_args *args)
{
struct xfs_attr_leafblock *leaf;
struct xfs_attr3_icleaf_hdr ichdr;
struct xfs_attr_leaf_entry *entry;
struct xfs_attr_leaf_name_local *name_loc;
struct xfs_attr_leaf_name_remote *name_rmt;
int valuelen;
leaf = bp->b_addr;
xfs_attr3_leaf_hdr_from_disk(args->geo, &ichdr, leaf);
ASSERT(ichdr.count < args->geo->blksize / 8);
ASSERT(args->index < ichdr.count);
entry = &xfs_attr3_leaf_entryp(leaf)[args->index];
if (entry->flags & XFS_ATTR_LOCAL) {
name_loc = xfs_attr3_leaf_name_local(leaf, args->index);
ASSERT(name_loc->namelen == args->namelen);
ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0);
valuelen = be16_to_cpu(name_loc->valuelen);
if (args->flags & ATTR_KERNOVAL) {
args->valuelen = valuelen;
return 0;
}
if (args->valuelen < valuelen) {
args->valuelen = valuelen;
return -ERANGE;
}
args->valuelen = valuelen;
memcpy(args->value, &name_loc->nameval[args->namelen], valuelen);
} else {
name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index);
ASSERT(name_rmt->namelen == args->namelen);
ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0);
args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen);
args->rmtblkno = be32_to_cpu(name_rmt->valueblk);
args->rmtblkcnt = xfs_attr3_rmt_blocks(args->dp->i_mount,
args->rmtvaluelen);
if (args->flags & ATTR_KERNOVAL) {
args->valuelen = args->rmtvaluelen;
return 0;
}
if (args->valuelen < args->rmtvaluelen) {
args->valuelen = args->rmtvaluelen;
return -ERANGE;
}
args->valuelen = args->rmtvaluelen;
}
return 0;
}
Commit Message: xfs: don't call xfs_da_shrink_inode with NULL bp
xfs_attr3_leaf_create may have errored out before instantiating a buffer,
for example if the blkno is out of range. In that case there is no work
to do to remove it, and in fact xfs_da_shrink_inode will lead to an oops
if we try.
This also seems to fix a flaw where the original error from
xfs_attr3_leaf_create gets overwritten in the cleanup case, and it
removes a pointless assignment to bp which isn't used after this.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199969
Reported-by: Xu, Wen <wen.xu@gatech.edu>
Tested-by: Xu, Wen <wen.xu@gatech.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
CWE ID: CWE-476 | 0 | 79,914 |
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: virtual void TearDown() {
EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd());
GetContentClient()->set_browser_for_testing(old_browser_client_);
DrainMessageLoops();
}
Commit Message: Check for appropriate bindings in process-per-site mode.
BUG=174059
TEST=See bug for repro steps.
Review URL: https://chromiumcodereview.appspot.com/12188025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181386 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 116,728 |
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: opj_pi_iterator_t *pi_create_decode(opj_image_t *image, opj_cp_t *cp,
int tileno)
{
int p, q;
int compno, resno, pino;
opj_pi_iterator_t *pi = NULL;
opj_tcp_t *tcp = NULL;
opj_tccp_t *tccp = NULL;
tcp = &cp->tcps[tileno];
pi = (opj_pi_iterator_t*) opj_calloc((tcp->numpocs + 1),
sizeof(opj_pi_iterator_t));
if (!pi) {
/* TODO: throw an error */
return NULL;
}
for (pino = 0; pino < tcp->numpocs + 1; pino++) { /* change */
int maxres = 0;
int maxprec = 0;
p = tileno % cp->tw;
q = tileno / cp->tw;
pi[pino].tx0 = int_max(cp->tx0 + p * cp->tdx, image->x0);
pi[pino].ty0 = int_max(cp->ty0 + q * cp->tdy, image->y0);
pi[pino].tx1 = int_min(cp->tx0 + (p + 1) * cp->tdx, image->x1);
pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
pi[pino].numcomps = image->numcomps;
pi[pino].comps = (opj_pi_comp_t*) opj_calloc(image->numcomps,
sizeof(opj_pi_comp_t));
if (!pi[pino].comps) {
/* TODO: throw an error */
pi_destroy(pi, cp, tileno);
return NULL;
}
for (compno = 0; compno < pi->numcomps; compno++) {
int tcx0, tcy0, tcx1, tcy1;
opj_pi_comp_t *comp = &pi[pino].comps[compno];
tccp = &tcp->tccps[compno];
comp->dx = image->comps[compno].dx;
comp->dy = image->comps[compno].dy;
comp->numresolutions = tccp->numresolutions;
comp->resolutions = (opj_pi_resolution_t*) opj_calloc(comp->numresolutions,
sizeof(opj_pi_resolution_t));
if (!comp->resolutions) {
/* TODO: throw an error */
pi_destroy(pi, cp, tileno);
return NULL;
}
tcx0 = int_ceildiv(pi->tx0, comp->dx);
tcy0 = int_ceildiv(pi->ty0, comp->dy);
tcx1 = int_ceildiv(pi->tx1, comp->dx);
tcy1 = int_ceildiv(pi->ty1, comp->dy);
if (comp->numresolutions > maxres) {
maxres = comp->numresolutions;
}
for (resno = 0; resno < comp->numresolutions; resno++) {
int levelno;
int rx0, ry0, rx1, ry1;
int px0, py0, px1, py1;
opj_pi_resolution_t *res = &comp->resolutions[resno];
if (tccp->csty & J2K_CCP_CSTY_PRT) {
res->pdx = tccp->prcw[resno];
res->pdy = tccp->prch[resno];
} else {
res->pdx = 15;
res->pdy = 15;
}
levelno = comp->numresolutions - 1 - resno;
rx0 = int_ceildivpow2(tcx0, levelno);
ry0 = int_ceildivpow2(tcy0, levelno);
rx1 = int_ceildivpow2(tcx1, levelno);
ry1 = int_ceildivpow2(tcy1, levelno);
px0 = int_floordivpow2(rx0, res->pdx) << res->pdx;
py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
res->pw = (rx0 == rx1) ? 0 : ((px1 - px0) >> res->pdx);
res->ph = (ry0 == ry1) ? 0 : ((py1 - py0) >> res->pdy);
if (res->pw * res->ph > maxprec) {
maxprec = res->pw * res->ph;
}
}
}
tccp = &tcp->tccps[0];
pi[pino].step_p = 1;
pi[pino].step_c = maxprec * pi[pino].step_p;
pi[pino].step_r = image->numcomps * pi[pino].step_c;
pi[pino].step_l = maxres * pi[pino].step_r;
if (pino == 0) {
pi[pino].include = (short int*) opj_calloc(image->numcomps * maxres *
tcp->numlayers * maxprec, sizeof(short int));
if (!pi[pino].include) {
/* TODO: throw an error */
pi_destroy(pi, cp, tileno);
return NULL;
}
} else {
pi[pino].include = pi[pino - 1].include;
}
if (tcp->POC == 0) {
pi[pino].first = 1;
pi[pino].poc.resno0 = 0;
pi[pino].poc.compno0 = 0;
pi[pino].poc.layno1 = tcp->numlayers;
pi[pino].poc.resno1 = maxres;
pi[pino].poc.compno1 = image->numcomps;
pi[pino].poc.prg = tcp->prg;
} else {
pi[pino].first = 1;
pi[pino].poc.resno0 = tcp->pocs[pino].resno0;
pi[pino].poc.compno0 = tcp->pocs[pino].compno0;
pi[pino].poc.layno1 = tcp->pocs[pino].layno1;
pi[pino].poc.resno1 = tcp->pocs[pino].resno1;
pi[pino].poc.compno1 = tcp->pocs[pino].compno1;
pi[pino].poc.prg = tcp->pocs[pino].prg;
}
pi[pino].poc.layno0 = 0;
pi[pino].poc.precno0 = 0;
pi[pino].poc.precno1 = maxprec;
}
return pi;
}
Commit Message: [MJ2] Avoid index out of bounds access to pi->include[]
Signed-off-by: Young_X <YangX92@hotmail.com>
CWE ID: CWE-20 | 0 | 92,230 |
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: unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
const char *start, const char *end)
{
unsigned insn_len = end - start;
if (insn_len > len || start == NULL)
insn_len = len;
else
memcpy(insnbuf, start, insn_len);
return insn_len;
}
Commit Message: x86/paravirt: Fix spectre-v2 mitigations for paravirt guests
Nadav reported that on guests we're failing to rewrite the indirect
calls to CALLEE_SAVE paravirt functions. In particular the
pv_queued_spin_unlock() call is left unpatched and that is all over the
place. This obviously wrecks Spectre-v2 mitigation (for paravirt
guests) which relies on not actually having indirect calls around.
The reason is an incorrect clobber test in paravirt_patch_call(); this
function rewrites an indirect call with a direct call to the _SAME_
function, there is no possible way the clobbers can be different
because of this.
Therefore remove this clobber check. Also put WARNs on the other patch
failure case (not enough room for the instruction) which I've not seen
trigger in my (limited) testing.
Three live kernel image disassemblies for lock_sock_nested (as a small
function that illustrates the problem nicely). PRE is the current
situation for guests, POST is with this patch applied and NATIVE is with
or without the patch for !guests.
PRE:
(gdb) disassemble lock_sock_nested
Dump of assembler code for function lock_sock_nested:
0xffffffff817be970 <+0>: push %rbp
0xffffffff817be971 <+1>: mov %rdi,%rbp
0xffffffff817be974 <+4>: push %rbx
0xffffffff817be975 <+5>: lea 0x88(%rbp),%rbx
0xffffffff817be97c <+12>: callq 0xffffffff819f7160 <_cond_resched>
0xffffffff817be981 <+17>: mov %rbx,%rdi
0xffffffff817be984 <+20>: callq 0xffffffff819fbb00 <_raw_spin_lock_bh>
0xffffffff817be989 <+25>: mov 0x8c(%rbp),%eax
0xffffffff817be98f <+31>: test %eax,%eax
0xffffffff817be991 <+33>: jne 0xffffffff817be9ba <lock_sock_nested+74>
0xffffffff817be993 <+35>: movl $0x1,0x8c(%rbp)
0xffffffff817be99d <+45>: mov %rbx,%rdi
0xffffffff817be9a0 <+48>: callq *0xffffffff822299e8
0xffffffff817be9a7 <+55>: pop %rbx
0xffffffff817be9a8 <+56>: pop %rbp
0xffffffff817be9a9 <+57>: mov $0x200,%esi
0xffffffff817be9ae <+62>: mov $0xffffffff817be993,%rdi
0xffffffff817be9b5 <+69>: jmpq 0xffffffff81063ae0 <__local_bh_enable_ip>
0xffffffff817be9ba <+74>: mov %rbp,%rdi
0xffffffff817be9bd <+77>: callq 0xffffffff817be8c0 <__lock_sock>
0xffffffff817be9c2 <+82>: jmp 0xffffffff817be993 <lock_sock_nested+35>
End of assembler dump.
POST:
(gdb) disassemble lock_sock_nested
Dump of assembler code for function lock_sock_nested:
0xffffffff817be970 <+0>: push %rbp
0xffffffff817be971 <+1>: mov %rdi,%rbp
0xffffffff817be974 <+4>: push %rbx
0xffffffff817be975 <+5>: lea 0x88(%rbp),%rbx
0xffffffff817be97c <+12>: callq 0xffffffff819f7160 <_cond_resched>
0xffffffff817be981 <+17>: mov %rbx,%rdi
0xffffffff817be984 <+20>: callq 0xffffffff819fbb00 <_raw_spin_lock_bh>
0xffffffff817be989 <+25>: mov 0x8c(%rbp),%eax
0xffffffff817be98f <+31>: test %eax,%eax
0xffffffff817be991 <+33>: jne 0xffffffff817be9ba <lock_sock_nested+74>
0xffffffff817be993 <+35>: movl $0x1,0x8c(%rbp)
0xffffffff817be99d <+45>: mov %rbx,%rdi
0xffffffff817be9a0 <+48>: callq 0xffffffff810a0c20 <__raw_callee_save___pv_queued_spin_unlock>
0xffffffff817be9a5 <+53>: xchg %ax,%ax
0xffffffff817be9a7 <+55>: pop %rbx
0xffffffff817be9a8 <+56>: pop %rbp
0xffffffff817be9a9 <+57>: mov $0x200,%esi
0xffffffff817be9ae <+62>: mov $0xffffffff817be993,%rdi
0xffffffff817be9b5 <+69>: jmpq 0xffffffff81063aa0 <__local_bh_enable_ip>
0xffffffff817be9ba <+74>: mov %rbp,%rdi
0xffffffff817be9bd <+77>: callq 0xffffffff817be8c0 <__lock_sock>
0xffffffff817be9c2 <+82>: jmp 0xffffffff817be993 <lock_sock_nested+35>
End of assembler dump.
NATIVE:
(gdb) disassemble lock_sock_nested
Dump of assembler code for function lock_sock_nested:
0xffffffff817be970 <+0>: push %rbp
0xffffffff817be971 <+1>: mov %rdi,%rbp
0xffffffff817be974 <+4>: push %rbx
0xffffffff817be975 <+5>: lea 0x88(%rbp),%rbx
0xffffffff817be97c <+12>: callq 0xffffffff819f7160 <_cond_resched>
0xffffffff817be981 <+17>: mov %rbx,%rdi
0xffffffff817be984 <+20>: callq 0xffffffff819fbb00 <_raw_spin_lock_bh>
0xffffffff817be989 <+25>: mov 0x8c(%rbp),%eax
0xffffffff817be98f <+31>: test %eax,%eax
0xffffffff817be991 <+33>: jne 0xffffffff817be9ba <lock_sock_nested+74>
0xffffffff817be993 <+35>: movl $0x1,0x8c(%rbp)
0xffffffff817be99d <+45>: mov %rbx,%rdi
0xffffffff817be9a0 <+48>: movb $0x0,(%rdi)
0xffffffff817be9a3 <+51>: nopl 0x0(%rax)
0xffffffff817be9a7 <+55>: pop %rbx
0xffffffff817be9a8 <+56>: pop %rbp
0xffffffff817be9a9 <+57>: mov $0x200,%esi
0xffffffff817be9ae <+62>: mov $0xffffffff817be993,%rdi
0xffffffff817be9b5 <+69>: jmpq 0xffffffff81063ae0 <__local_bh_enable_ip>
0xffffffff817be9ba <+74>: mov %rbp,%rdi
0xffffffff817be9bd <+77>: callq 0xffffffff817be8c0 <__lock_sock>
0xffffffff817be9c2 <+82>: jmp 0xffffffff817be993 <lock_sock_nested+35>
End of assembler dump.
Fixes: 63f70270ccd9 ("[PATCH] i386: PARAVIRT: add common patching machinery")
Fixes: 3010a0663fd9 ("x86/paravirt, objtool: Annotate indirect calls")
Reported-by: Nadav Amit <namit@vmware.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: stable@vger.kernel.org
CWE ID: CWE-200 | 0 | 79,065 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.