func
stringlengths
0
484k
target
int64
0
1
cwe
listlengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
static struct neighbour *neigh_get_idx(struct seq_file *seq, loff_t *pos) { struct neighbour *n = neigh_get_first(seq); if (n) { while (*pos) { n = neigh_get_next(seq, n, pos); if (!n) break; } } return *pos ? NULL : n; }
0
[ "CWE-200" ]
linux-2.6
9ef1d4c7c7aca1cd436612b6ca785b726ffb8ed8
95,953,515,148,894,230,000,000,000,000,000,000,000
13
[NETLINK]: Missing initializations in dumped data Mostly missing initialization of padding fields of 1 or 2 bytes length, two instances of uninitialized nlmsgerr->msg of 16 bytes length. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
rgw::auth::s3::STSEngine::get_session_token(const boost::string_view& session_token, STS::SessionToken& token) const { string decodedSessionToken; try { decodedSessionToken = rgw::from_base64(session_token); } catch (...) { ldout(cct, 0) << "ERROR: Invalid session token, not base64 encoded." << dendl; return -EINVAL; } auto* cryptohandler = cct->get_crypto_handler(CEPH_CRYPTO_AES); if (! cryptohandler) { return -EINVAL; } string secret_s = cct->_conf->rgw_sts_key; buffer::ptr secret(secret_s.c_str(), secret_s.length()); int ret = 0; if (ret = cryptohandler->validate_secret(secret); ret < 0) { ldout(cct, 0) << "ERROR: Invalid secret key" << dendl; return -EINVAL; } string error; auto* keyhandler = cryptohandler->get_key_handler(secret, error); if (! keyhandler) { return -EINVAL; } error.clear(); string decrypted_str; buffer::list en_input, dec_output; en_input = buffer::list::static_from_string(decodedSessionToken); ret = keyhandler->decrypt(en_input, dec_output, &error); if (ret < 0) { ldout(cct, 0) << "ERROR: Decryption failed: " << error << dendl; return -EPERM; } else { try { dec_output.append('\0'); auto iter = dec_output.cbegin(); decode(token, iter); } catch (const buffer::error& e) { ldout(cct, 0) << "ERROR: decode SessionToken failed: " << error << dendl; return -EINVAL; } } return 0; }
0
[ "CWE-79" ]
ceph
fce0b267446d6f3f631bb4680ebc3527bbbea002
256,400,719,533,652,720,000,000,000,000,000,000,000
49
rgw: reject unauthenticated response-header actions Signed-off-by: Matt Benjamin <[email protected]> Reviewed-by: Casey Bodley <[email protected]> (cherry picked from commit d8dd5e513c0c62bbd7d3044d7e2eddcd897bd400)
static avifTile * avifDecoderDataCreateTile(avifDecoderData * data) { avifTile * tile = (avifTile *)avifArrayPushPtr(&data->tiles); tile->image = avifImageCreateEmpty(); tile->input = avifCodecDecodeInputCreate(); return tile; }
0
[ "CWE-703", "CWE-787" ]
libavif
0a8e7244d494ae98e9756355dfbfb6697ded2ff9
225,332,177,948,005,060,000,000,000,000,000,000,000
7
Set max image size to 16384 * 16384 Fix https://crbug.com/oss-fuzz/24728 and https://crbug.com/oss-fuzz/24734.
virDomainDefHasVcpuPin(const virDomainDef *def) { size_t i; for (i = 0; i < def->maxvcpus; i++) { if (def->vcpus[i]->cpumask) return true; } return false; }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
114,426,642,405,270,630,000,000,000,000,000,000,000
11
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
CSteamNetworkConnectionUDP::~CSteamNetworkConnectionUDP() { }
0
[ "CWE-703" ]
GameNetworkingSockets
d944a10808891d202bb1d5e1998de6e0423af678
213,969,752,825,029,980,000,000,000,000,000,000,000
3
Tweak pointer math to avoid possible integer overflow
find_ms_san(hx509_context context, hx509_cert cert, void *ctx) { char *upn; int ret; ret = get_ms_san(context, cert, &upn); if (ret == 0) free(upn); return ret; }
0
[ "CWE-320" ]
heimdal
2f7f3d9960aa6ea21358bdf3687cee5149aa35cf
251,469,328,180,439,700,000,000,000,000,000,000,000
10
CVE-2019-12098: krb5: always confirm PA-PKINIT-KX for anon PKINIT RFC8062 Section 7 requires verification of the PA-PKINIT-KX key excahnge when anonymous PKINIT is used. Failure to do so can permit an active attacker to become a man-in-the-middle. Introduced by a1ef548600c5bb51cf52a9a9ea12676506ede19f. First tagged release Heimdal 1.4.0. CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N (4.8) Change-Id: I6cc1c0c24985936468af08693839ac6c3edda133 Signed-off-by: Jeffrey Altman <[email protected]> Approved-by: Jeffrey Altman <[email protected]> (cherry picked from commit 38c797e1ae9b9c8f99ae4aa2e73957679031fd2b)
void avcc_box_del(GF_Box *s) { GF_AVCConfigurationBox *ptr = (GF_AVCConfigurationBox *)s; if (ptr->config) gf_odf_avc_cfg_del(ptr->config); ptr->config = NULL; gf_free(ptr); }
0
[ "CWE-401" ]
gpac
0a85029d694f992f3631e2f249e4999daee15cbf
269,190,682,623,724,000,000,000,000,000,000,000,000
7
fixed #1785 (fuzz)
static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, bool force_nonblock) { ssize_t ret; ret = io_prep_rw(req, sqe, force_nonblock); if (ret) return ret; if (unlikely(!(req->file->f_mode & FMODE_WRITE))) return -EBADF; /* either don't need iovec imported or already have it */ if (!req->io || req->flags & REQ_F_NEED_CLEANUP) return 0; return io_rw_prep_async(req, WRITE, force_nonblock); }
0
[]
linux
0f2122045b946241a9e549c2a76cea54fa58a7ff
152,615,969,549,164,100,000,000,000,000,000,000,000
17
io_uring: don't rely on weak ->files references Grab actual references to the files_struct. To avoid circular references issues due to this, we add a per-task note that keeps track of what io_uring contexts a task has used. When the tasks execs or exits its assigned files, we cancel requests based on this tracking. With that, we can grab proper references to the files table, and no longer need to rely on stashing away ring_fd and ring_file to check if the ring_fd may have been closed. Cc: [email protected] # v5.5+ Reviewed-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
get_additional_name(struct rrset_parse* rrset, struct rr_parse* rr, uint8_t** nm, size_t* nmlen, sldns_buffer* pkt) { size_t offset = 0; size_t len, oldpos; switch(rrset->type) { case LDNS_RR_TYPE_MB: case LDNS_RR_TYPE_MD: case LDNS_RR_TYPE_MF: case LDNS_RR_TYPE_NS: offset = 0; break; case LDNS_RR_TYPE_MX: case LDNS_RR_TYPE_KX: offset = 2; break; case LDNS_RR_TYPE_SRV: offset = 6; break; case LDNS_RR_TYPE_NAPTR: /* TODO: NAPTR not supported, glue stripped off */ return 0; default: return 0; } len = sldns_read_uint16(rr->ttl_data+sizeof(uint32_t)); if(len < offset+1) return 0; /* rdata field too small */ *nm = rr->ttl_data+sizeof(uint32_t)+sizeof(uint16_t)+offset; oldpos = sldns_buffer_position(pkt); sldns_buffer_set_position(pkt, (size_t)(*nm - sldns_buffer_begin(pkt))); *nmlen = pkt_dname_len(pkt); sldns_buffer_set_position(pkt, oldpos); if(*nmlen == 0) return 0; return 1; }
0
[ "CWE-400" ]
unbound
ba0f382eee814e56900a535778d13206b86b6d49
292,308,581,727,650,230,000,000,000,000,000,000,000
37
- CVE-2020-12662 Unbound can be tricked into amplifying an incoming query into a large number of queries directed to a target. - CVE-2020-12663 Malformed answers from upstream name servers can be used to make Unbound unresponsive.
static int io_tee(struct io_kiocb *req, bool force_nonblock) { struct io_splice *sp = &req->splice; struct file *in = sp->file_in; struct file *out = sp->file_out; unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED; long ret = 0; if (force_nonblock) return -EAGAIN; if (sp->len) ret = do_tee(in, out, sp->len, flags); io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED)); req->flags &= ~REQ_F_NEED_CLEANUP; if (ret != sp->len) req_set_fail_links(req); io_req_complete(req, ret); return 0; }
0
[]
linux
0f2122045b946241a9e549c2a76cea54fa58a7ff
302,589,540,456,735,200,000,000,000,000,000,000,000
21
io_uring: don't rely on weak ->files references Grab actual references to the files_struct. To avoid circular references issues due to this, we add a per-task note that keeps track of what io_uring contexts a task has used. When the tasks execs or exits its assigned files, we cancel requests based on this tracking. With that, we can grab proper references to the files table, and no longer need to rely on stashing away ring_fd and ring_file to check if the ring_fd may have been closed. Cc: [email protected] # v5.5+ Reviewed-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
f_settabvar(typval_T *argvars, typval_T *rettv) { tabpage_T *save_curtab; tabpage_T *tp; char_u *varname, *tabvarname; typval_T *varp; rettv->vval.v_number = 0; if (check_secure()) return; tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL)); varname = tv_get_string_chk(&argvars[1]); varp = &argvars[2]; if (varname != NULL && varp != NULL && tp != NULL) { save_curtab = curtab; goto_tabpage_tp(tp, FALSE, FALSE); tabvarname = alloc((unsigned)STRLEN(varname) + 3); if (tabvarname != NULL) { STRCPY(tabvarname, "t:"); STRCPY(tabvarname + 2, varname); set_var(tabvarname, varp, TRUE); vim_free(tabvarname); } /* Restore current tabpage */ if (valid_tabpage(save_curtab)) goto_tabpage_tp(save_curtab, FALSE, FALSE); } }
0
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
216,704,318,225,588,460,000,000,000,000,000,000,000
35
patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
static int parse_part_values (void **ret_buffer, size_t *ret_buffer_len, value_t **ret_values, int *ret_num_values) { char *buffer = *ret_buffer; size_t buffer_len = *ret_buffer_len; uint16_t tmp16; size_t exp_size; int i; uint16_t pkg_length; uint16_t pkg_type; uint16_t pkg_numval; uint8_t *pkg_types; value_t *pkg_values; if (buffer_len < 15) { NOTICE ("network plugin: packet is too short: " "buffer_len = %zu", buffer_len); return (-1); } memcpy ((void *) &tmp16, buffer, sizeof (tmp16)); buffer += sizeof (tmp16); pkg_type = ntohs (tmp16); memcpy ((void *) &tmp16, buffer, sizeof (tmp16)); buffer += sizeof (tmp16); pkg_length = ntohs (tmp16); memcpy ((void *) &tmp16, buffer, sizeof (tmp16)); buffer += sizeof (tmp16); pkg_numval = ntohs (tmp16); assert (pkg_type == TYPE_VALUES); exp_size = 3 * sizeof (uint16_t) + pkg_numval * (sizeof (uint8_t) + sizeof (value_t)); if (buffer_len < exp_size) { WARNING ("network plugin: parse_part_values: " "Packet too short: " "Chunk of size %zu expected, " "but buffer has only %zu bytes left.", exp_size, buffer_len); return (-1); } if (pkg_length != exp_size) { WARNING ("network plugin: parse_part_values: " "Length and number of values " "in the packet don't match."); return (-1); } pkg_types = (uint8_t *) malloc (pkg_numval * sizeof (uint8_t)); pkg_values = (value_t *) malloc (pkg_numval * sizeof (value_t)); if ((pkg_types == NULL) || (pkg_values == NULL)) { sfree (pkg_types); sfree (pkg_values); ERROR ("network plugin: parse_part_values: malloc failed."); return (-1); } memcpy ((void *) pkg_types, (void *) buffer, pkg_numval * sizeof (uint8_t)); buffer += pkg_numval * sizeof (uint8_t); memcpy ((void *) pkg_values, (void *) buffer, pkg_numval * sizeof (value_t)); buffer += pkg_numval * sizeof (value_t); for (i = 0; i < pkg_numval; i++) { switch (pkg_types[i]) { case DS_TYPE_COUNTER: pkg_values[i].counter = (counter_t) ntohll (pkg_values[i].counter); break; case DS_TYPE_GAUGE: pkg_values[i].gauge = (gauge_t) ntohd (pkg_values[i].gauge); break; case DS_TYPE_DERIVE: pkg_values[i].derive = (derive_t) ntohll (pkg_values[i].derive); break; case DS_TYPE_ABSOLUTE: pkg_values[i].absolute = (absolute_t) ntohll (pkg_values[i].absolute); break; default: NOTICE ("network plugin: parse_part_values: " "Don't know how to handle data source type %"PRIu8, pkg_types[i]); sfree (pkg_types); sfree (pkg_values); return (-1); } /* switch (pkg_types[i]) */ } *ret_buffer = buffer; *ret_buffer_len = buffer_len - pkg_length; *ret_num_values = pkg_numval; *ret_values = pkg_values; sfree (pkg_types); return (0); } /* int parse_part_values */
0
[ "CWE-119", "CWE-787" ]
collectd
b589096f907052b3a4da2b9ccc9b0e2e888dfc18
308,756,723,150,018,980,000,000,000,000,000,000,000
112
network plugin: Fix heap overflow in parse_packet(). Emilien Gaspar has identified a heap overflow in parse_packet(), the function used by the network plugin to parse incoming network packets. This is a vulnerability in collectd, though the scope is not clear at this point. At the very least specially crafted network packets can be used to crash the daemon. We can't rule out a potential remote code execution though. Fixes: CVE-2016-6254
int mongo_env_read_socket( mongo *conn, void *buf, int len ) { char *cbuf = buf; while ( len ) { int sent = recv( conn->sock, cbuf, len, 0 ); if ( sent == 0 || sent == -1 ) { __mongo_set_error( conn, MONGO_IO_ERROR, NULL, WSAGetLastError() ); return MONGO_ERROR; } cbuf += sent; len -= sent; } return MONGO_OK; }
1
[ "CWE-190" ]
mongo-c-driver-legacy
1a1f5e26a4309480d88598913f9eebf9e9cba8ca
245,243,935,275,700,370,000,000,000,000,000,000,000
15
don't mix up int and size_t (first pass to fix that)
xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, int terminate) { int end_in_lf = 0; int remain = 0; size_t old_avail = 0; size_t avail = 0; if (ctxt == NULL) return(XML_ERR_INTERNAL_ERROR); if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) return(ctxt->errNo); if (ctxt->instate == XML_PARSER_EOF) return(-1); if (ctxt->instate == XML_PARSER_START) xmlDetectSAX2(ctxt); if ((size > 0) && (chunk != NULL) && (!terminate) && (chunk[size - 1] == '\r')) { end_in_lf = 1; size--; } xmldecl_done: if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) && (ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) { size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input); size_t cur = ctxt->input->cur - ctxt->input->base; int res; old_avail = xmlBufUse(ctxt->input->buf->buffer); /* * Specific handling if we autodetected an encoding, we should not * push more than the first line ... which depend on the encoding * And only push the rest once the final encoding was detected */ if ((ctxt->instate == XML_PARSER_START) && (ctxt->input != NULL) && (ctxt->input->buf != NULL) && (ctxt->input->buf->encoder != NULL)) { unsigned int len = 45; if ((xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name, BAD_CAST "UTF-16")) || (xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name, BAD_CAST "UTF16"))) len = 90; else if ((xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name, BAD_CAST "UCS-4")) || (xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name, BAD_CAST "UCS4"))) len = 180; if (ctxt->input->buf->rawconsumed < len) len -= ctxt->input->buf->rawconsumed; /* * Change size for reading the initial declaration only * if size is greater than len. Otherwise, memmove in xmlBufferAdd * will blindly copy extra bytes from memory. */ if ((unsigned int) size > len) { remain = size - len; size = len; } else { remain = 0; } } res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk); xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur); if (res < 0) { ctxt->errNo = XML_PARSER_EOF; xmlHaltParser(ctxt); return (XML_PARSER_EOF); } #ifdef DEBUG_PUSH xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size); #endif } else if (ctxt->instate != XML_PARSER_EOF) { if ((ctxt->input != NULL) && ctxt->input->buf != NULL) { xmlParserInputBufferPtr in = ctxt->input->buf; if ((in->encoder != NULL) && (in->buffer != NULL) && (in->raw != NULL)) { int nbchars; size_t base = xmlBufGetInputBase(in->buffer, ctxt->input); size_t current = ctxt->input->cur - ctxt->input->base; nbchars = xmlCharEncInput(in, terminate); xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current); if (nbchars < 0) { /* TODO 2.6.0 */ xmlGenericError(xmlGenericErrorContext, "xmlParseChunk: encoder error\n"); xmlHaltParser(ctxt); return(XML_ERR_INVALID_ENCODING); } } } } if (remain != 0) { xmlParseTryOrFinish(ctxt, 0); } else { if ((ctxt->input != NULL) && (ctxt->input->buf != NULL)) avail = xmlBufUse(ctxt->input->buf->buffer); /* * Depending on the current state it may not be such * a good idea to try parsing if there is nothing in the chunk * which would be worth doing a parser state transition and we * need to wait for more data */ if ((terminate) || (avail > XML_MAX_TEXT_LENGTH) || (old_avail == 0) || (avail == 0) || (xmlParseCheckTransition(ctxt, (const char *)&ctxt->input->base[old_avail], avail - old_avail))) xmlParseTryOrFinish(ctxt, terminate); } if (ctxt->instate == XML_PARSER_EOF) return(ctxt->errNo); if ((ctxt->input != NULL) && (((ctxt->input->end - ctxt->input->cur) > XML_MAX_LOOKUP_LIMIT) || ((ctxt->input->cur - ctxt->input->base) > XML_MAX_LOOKUP_LIMIT)) && ((ctxt->options & XML_PARSE_HUGE) == 0)) { xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup"); xmlHaltParser(ctxt); } if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) return(ctxt->errNo); if (remain != 0) { chunk += size; size = remain; remain = 0; goto xmldecl_done; } if ((end_in_lf == 1) && (ctxt->input != NULL) && (ctxt->input->buf != NULL)) { size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input); size_t current = ctxt->input->cur - ctxt->input->base; xmlParserInputBufferPush(ctxt->input->buf, 1, "\r"); xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, current); } if (terminate) { /* * Check for termination */ int cur_avail = 0; if (ctxt->input != NULL) { if (ctxt->input->buf == NULL) cur_avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base); else cur_avail = xmlBufUse(ctxt->input->buf->buffer) - (ctxt->input->cur - ctxt->input->base); } if ((ctxt->instate != XML_PARSER_EOF) && (ctxt->instate != XML_PARSER_EPILOG)) { xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL); } if ((ctxt->instate == XML_PARSER_EPILOG) && (cur_avail > 0)) { xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL); } if (ctxt->instate != XML_PARSER_EOF) { if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) ctxt->sax->endDocument(ctxt->userData); } ctxt->instate = XML_PARSER_EOF; } if (ctxt->wellFormed == 0) return((xmlParserErrors) ctxt->errNo); else return(0); }
0
[ "CWE-776" ]
libxml2
8598060bacada41a0eb09d95c97744ff4e428f8e
27,368,247,279,317,770,000,000,000,000,000,000,000
178
Patch for security issue CVE-2021-3541 This is relapted to parameter entities expansion and following the line of the billion laugh attack. Somehow in that path the counting of parameters was missed and the normal algorithm based on entities "density" was useless.
innodb_handle( /*==========*/ ENGINE_HANDLE* handle) /*!< in: Generic engine handle */ { return((struct innodb_engine*) handle); }
0
[]
mysql-server
659514dc83299a7d8c7defeb543be4339fbe1ee1
279,404,175,219,537,340,000,000,000,000,000,000,000
6
Bug #25147515 SET DAEMON_MEMCACHED_R_BATCH_SIZE GREATER THAN 1 MAKE MYSQLD CRASHED PROBLEM ------- User starts a "get" the the connection with SET DAEMON_MEMCACHED_R_BATCH_SIZE= 5 and with binlog on. Since "get" is a read transaction this connection is not allocated any conn_data->thd (which is used for bin log commit).The connection is kept open. Innodb background thread tries to commit transactions which have exceed CONN_IDLE_TIME_TO_BK_COMMIT and whose read batch size > 0, when it finds this connection it tries to attach conn_data->thd to bin log thread.Since conn_data->thd is NULL it crashes. FIX --- Check conn_data->thd value before attaching it to binlog thread.
static int ctnetlink_stat_ct(struct net *net, struct sock *ctnl, struct sk_buff *skb, const struct nlmsghdr *nlh, const struct nlattr * const cda[], struct netlink_ext_ack *extack) { struct sk_buff *skb2; int err; skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (skb2 == NULL) return -ENOMEM; err = ctnetlink_stat_ct_fill_info(skb2, NETLINK_CB(skb).portid, nlh->nlmsg_seq, NFNL_MSG_TYPE(nlh->nlmsg_type), sock_net(skb->sk)); if (err <= 0) goto free; err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT); if (err < 0) goto out; return 0; free: kfree_skb(skb2); out: /* this avoids a loop in nfnetlink. */ return err == -EAGAIN ? -ENOBUFS : err; }
0
[ "CWE-120" ]
linux
1cc5ef91d2ff94d2bf2de3b3585423e8a1051cb6
39,771,798,676,927,700,000,000,000,000,000,000,000
31
netfilter: ctnetlink: add a range check for l3/l4 protonum The indexes to the nf_nat_l[34]protos arrays come from userspace. So check the tuple's family, e.g. l3num, when creating the conntrack in order to prevent an OOB memory access during setup. Here is an example kernel panic on 4.14.180 when userspace passes in an index greater than NFPROTO_NUMPROTO. Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in:... Process poc (pid: 5614, stack limit = 0x00000000a3933121) CPU: 4 PID: 5614 Comm: poc Tainted: G S W O 4.14.180-g051355490483 Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150 Google Inc. MSM task: 000000002a3dfffe task.stack: 00000000a3933121 pc : __cfi_check_fail+0x1c/0x24 lr : __cfi_check_fail+0x1c/0x24 ... Call trace: __cfi_check_fail+0x1c/0x24 name_to_dev_t+0x0/0x468 nfnetlink_parse_nat_setup+0x234/0x258 ctnetlink_parse_nat_setup+0x4c/0x228 ctnetlink_new_conntrack+0x590/0xc40 nfnetlink_rcv_msg+0x31c/0x4d4 netlink_rcv_skb+0x100/0x184 nfnetlink_rcv+0xf4/0x180 netlink_unicast+0x360/0x770 netlink_sendmsg+0x5a0/0x6a4 ___sys_sendmsg+0x314/0x46c SyS_sendmsg+0xb4/0x108 el0_svc_naked+0x34/0x38 This crash is not happening since 5.4+, however, ctnetlink still allows for creating entries with unsupported layer 3 protocol number. Fixes: c1d10adb4a521 ("[NETFILTER]: Add ctnetlink port for nf_conntrack") Signed-off-by: Will McVicker <[email protected]> [[email protected]: rebased original patch on top of nf.git] Signed-off-by: Pablo Neira Ayuso <[email protected]>
longlong Item_func_between::val_int_cmp_int() { Longlong_hybrid value= args[0]->to_longlong_hybrid(); if ((null_value= args[0]->null_value)) return 0; /* purecov: inspected */ Longlong_hybrid a= args[1]->to_longlong_hybrid(); Longlong_hybrid b= args[2]->to_longlong_hybrid(); if (!args[1]->null_value && !args[2]->null_value) return (longlong) ((value.cmp(a) >= 0 && value.cmp(b) <= 0) != negated); if (args[1]->null_value && args[2]->null_value) null_value= true; else if (args[1]->null_value) null_value= value.cmp(b) <= 0; // not null if false range. else null_value= value.cmp(a) >= 0; return (longlong) (!null_value && negated); }
0
[ "CWE-617" ]
server
807945f2eb5fa22e6f233cc17b85a2e141efe2c8
127,278,139,454,062,290,000,000,000,000,000,000,000
17
MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order... When doing condition pushdown from HAVING into WHERE, Item_equal::create_pushable_equalities() calls item->set_extraction_flag(IMMUTABLE_FL) for constant items. Then, Item::cleanup_excluding_immutables_processor() checks for this flag to see if it should call item->cleanup() or leave the item as-is. The failure happens when a constant item has a non-constant one inside it, like: (tbl.col=0 AND impossible_cond) item->walk(cleanup_excluding_immutables_processor) works in a bottom-up way so it 1. will call Item_func_eq(tbl.col=0)->cleanup() 2. will not call Item_cond_and->cleanup (as the AND is constant) This creates an item tree where a fixed Item has an un-fixed Item inside it which eventually causes an assertion failure. Fixed by introducing this rule: instead of just calling item->set_extraction_flag(IMMUTABLE_FL); we call Item::walk() to set the flag for all sub-items of the item.
struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, nodemask_t *nmask) { gfp_t gfp_mask = htlb_alloc_mask(h); spin_lock(&hugetlb_lock); if (h->free_huge_pages - h->resv_huge_pages > 0) { struct page *page; page = dequeue_huge_page_nodemask(h, gfp_mask, preferred_nid, nmask); if (page) { spin_unlock(&hugetlb_lock); return page; } } spin_unlock(&hugetlb_lock); /* No reservations, try to overcommit */ return __alloc_buddy_huge_page(h, gfp_mask, preferred_nid, nmask); }
0
[ "CWE-703" ]
linux
5af10dfd0afc559bb4b0f7e3e8227a1578333995
165,649,567,483,994,380,000,000,000,000,000,000,000
21
userfaultfd: hugetlbfs: remove superfluous page unlock in VM_SHARED case huge_add_to_page_cache->add_to_page_cache implicitly unlocks the page before returning in case of errors. The error returned was -EEXIST by running UFFDIO_COPY on a non-hole offset of a VM_SHARED hugetlbfs mapping. It was an userland bug that triggered it and the kernel must cope with it returning -EEXIST from ioctl(UFFDIO_COPY) as expected. page dumped because: VM_BUG_ON_PAGE(!PageLocked(page)) kernel BUG at mm/filemap.c:964! invalid opcode: 0000 [#1] SMP CPU: 1 PID: 22582 Comm: qemu-system-x86 Not tainted 4.11.11-300.fc26.x86_64 #1 RIP: unlock_page+0x4a/0x50 Call Trace: hugetlb_mcopy_atomic_pte+0xc0/0x320 mcopy_atomic+0x96f/0xbe0 userfaultfd_ioctl+0x218/0xe90 do_vfs_ioctl+0xa5/0x600 SyS_ioctl+0x79/0x90 entry_SYSCALL_64_fastpath+0x1a/0xa9 Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Andrea Arcangeli <[email protected]> Tested-by: Maxime Coquelin <[email protected]> Reviewed-by: Mike Kravetz <[email protected]> Cc: "Dr. David Alan Gilbert" <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Alexey Perevalov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static size_t rtnl_link_get_slave_info_data_size(const struct net_device *dev) { struct net_device *master_dev; const struct rtnl_link_ops *ops; size_t size = 0; rcu_read_lock(); master_dev = netdev_master_upper_dev_get_rcu((struct net_device *)dev); if (!master_dev) goto out; ops = master_dev->rtnl_link_ops; if (!ops || !ops->get_slave_size) goto out; /* IFLA_INFO_SLAVE_DATA + nested data */ size = nla_total_size(sizeof(struct nlattr)) + ops->get_slave_size(master_dev, dev); out: rcu_read_unlock(); return size; }
0
[ "CWE-476" ]
linux
f428fe4a04cc339166c8bbd489789760de3a0cee
183,876,164,065,989,100,000,000,000,000,000,000,000
23
rtnetlink: give a user socket to get_target_net() This function is used from two places: rtnl_dump_ifinfo and rtnl_getlink. In rtnl_getlink(), we give a request skb into get_target_net(), but in rtnl_dump_ifinfo, we give a response skb into get_target_net(). The problem here is that NETLINK_CB() isn't initialized for the response skb. In both cases we can get a user socket and give it instead of skb into get_target_net(). This bug was found by syzkaller with this call-trace: kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] SMP KASAN Modules linked in: CPU: 1 PID: 3149 Comm: syzkaller140561 Not tainted 4.15.0-rc4-mm1+ #47 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:__netlink_ns_capable+0x8b/0x120 net/netlink/af_netlink.c:868 RSP: 0018:ffff8801c880f348 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff8443f900 RDX: 000000000000007b RSI: ffffffff86510f40 RDI: 00000000000003d8 RBP: ffff8801c880f360 R08: 0000000000000000 R09: 1ffff10039101e4f R10: 0000000000000000 R11: 0000000000000001 R12: ffffffff86510f40 R13: 000000000000000c R14: 0000000000000004 R15: 0000000000000011 FS: 0000000001a1a880(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020151000 CR3: 00000001c9511005 CR4: 00000000001606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: netlink_ns_capable+0x26/0x30 net/netlink/af_netlink.c:886 get_target_net+0x9d/0x120 net/core/rtnetlink.c:1765 rtnl_dump_ifinfo+0x2e5/0xee0 net/core/rtnetlink.c:1806 netlink_dump+0x48c/0xce0 net/netlink/af_netlink.c:2222 __netlink_dump_start+0x4f0/0x6d0 net/netlink/af_netlink.c:2319 netlink_dump_start include/linux/netlink.h:214 [inline] rtnetlink_rcv_msg+0x7f0/0xb10 net/core/rtnetlink.c:4485 netlink_rcv_skb+0x21e/0x460 net/netlink/af_netlink.c:2441 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4540 netlink_unicast_kernel net/netlink/af_netlink.c:1308 [inline] netlink_unicast+0x4be/0x6a0 net/netlink/af_netlink.c:1334 netlink_sendmsg+0xa4a/0xe60 net/netlink/af_netlink.c:1897 Cc: Jiri Benc <[email protected]> Fixes: 79e1ad148c84 ("rtnetlink: use netnsid to query interface") Signed-off-by: Andrei Vagin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
void do_sync_with_master2(struct st_command *command, long offset) { MYSQL_RES *res; MYSQL_ROW row; MYSQL *mysql= &cur_con->mysql; char query_buf[FN_REFLEN+128]; int timeout= 300; /* seconds */ if (!master_pos.file[0]) die("Calling 'sync_with_master' without calling 'save_master_pos'"); sprintf(query_buf, "select master_pos_wait('%s', %ld, %d)", master_pos.file, master_pos.pos + offset, timeout); if (mysql_query(mysql, query_buf)) die("failed in '%s': %d: %s", query_buf, mysql_errno(mysql), mysql_error(mysql)); if (!(res= mysql_store_result(mysql))) die("mysql_store_result() returned NULL for '%s'", query_buf); if (!(row= mysql_fetch_row(res))) { mysql_free_result(res); die("empty result in %s", query_buf); } int result= -99; const char* result_str= row[0]; if (result_str) result= atoi(result_str); mysql_free_result(res); if (!result_str || result < 0) { /* master_pos_wait returned NULL or < 0 */ show_query(mysql, "SHOW MASTER STATUS"); show_query(mysql, "SHOW SLAVE STATUS"); show_query(mysql, "SHOW PROCESSLIST"); fprintf(stderr, "analyze: sync_with_master\n"); if (!result_str) { /* master_pos_wait returned NULL. This indicates that slave SQL thread is not started, the slave's master information is not initialized, the arguments are incorrect, or an error has occured */ die("%.*s failed: '%s' returned NULL "\ "indicating slave SQL thread failure", command->first_word_len, command->query, query_buf); } if (result == -1) die("%.*s failed: '%s' returned -1 "\ "indicating timeout after %d seconds", command->first_word_len, command->query, query_buf, timeout); else die("%.*s failed: '%s' returned unknown result :%d", command->first_word_len, command->query, query_buf, result); } return; }
0
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
225,996,358,435,297,170,000,000,000,000,000,000,000
66
WL#6791 : Redefine client --ssl option to imply enforced encryption # Changed the meaning of the --ssl=1 option of all client binaries to mean force ssl, not try ssl and fail over to eunecrypted # Added a new MYSQL_OPT_SSL_ENFORCE mysql_options() option to specify that an ssl connection is required. # Added a new macro SSL_SET_OPTIONS() to the client SSL handling headers that sets all the relevant SSL options at once. # Revamped all of the current native clients to use the new macro # Removed some Windows line endings. # Added proper handling of the new option into the ssl helper headers. # If SSL is mandatory assume that the media is secure enough for the sha256 plugin to do unencrypted password exchange even before establishing a connection. # Set the default ssl cipher to DHE-RSA-AES256-SHA if none is specified. # updated test cases that require a non-default cipher to spawn a mysql command line tool binary since mysqltest has no support for specifying ciphers. # updated the replication slave connection code to always enforce SSL if any of the SSL config options is present. # test cases added and updated. # added a mysql_get_option() API to return mysql_options() values. Used the new API inside the sha256 plugin. # Fixed compilation warnings because of unused variables. # Fixed test failures (mysql_ssl and bug13115401) # Fixed whitespace issues. # Fully implemented the mysql_get_option() function. # Added a test case for mysql_get_option() # fixed some trailing whitespace issues # fixed some uint/int warnings in mysql_client_test.c # removed shared memory option from non-windows get_options tests # moved MYSQL_OPT_LOCAL_INFILE to the uint options
void js_dup2(js_State *J) { CHECKSTACK(2); STACK[TOP] = STACK[TOP-2]; STACK[TOP+1] = STACK[TOP-1]; TOP += 2; }
0
[ "CWE-476" ]
mujs
77ab465f1c394bb77f00966cd950650f3f53cb24
45,821,657,467,563,020,000,000,000,000,000,000,000
7
Fix 697401: Error when dropping extra arguments to lightweight functions.
xmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) { xmlDocDumpFormatMemoryEnc(cur, mem, size, NULL, 0); }
0
[ "CWE-502" ]
libxml2
c97750d11bb8b6f3303e7131fe526a61ac65bcfd
330,049,722,521,896,380,000,000,000,000,000,000,000
3
Avoid an out of bound access when serializing malformed strings For https://bugzilla.gnome.org/show_bug.cgi?id=766414 * xmlsave.c: xmlBufAttrSerializeTxtContent() if an attribute value is not UTF-8 be more careful when serializing it as we may do an out of bound access as a result.
thumbnailers_directory_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, GnomeDesktopThumbnailFactory *factory) { gchar *path; switch (event_type) { case G_FILE_MONITOR_EVENT_CREATED: case G_FILE_MONITOR_EVENT_CHANGED: case G_FILE_MONITOR_EVENT_DELETED: path = g_file_get_path (file); if (!g_str_has_suffix (path, THUMBNAILER_EXTENSION)) { g_free (path); return; } if (event_type == G_FILE_MONITOR_EVENT_DELETED) remove_thumbnailer (factory, path); else update_or_create_thumbnailer (factory, path); g_free (path); break; case G_FILE_MONITOR_EVENT_UNMOUNTED: case G_FILE_MONITOR_EVENT_MOVED: path = g_file_get_path (file); remove_thumbnailers_for_dir (factory, path, monitor); if (event_type == G_FILE_MONITOR_EVENT_MOVED) gnome_desktop_thumbnail_factory_load_thumbnailers_for_dir (factory, path); g_free (path); break; case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: case G_FILE_MONITOR_EVENT_PRE_UNMOUNT: case G_FILE_MONITOR_EVENT_RENAMED: case G_FILE_MONITOR_EVENT_MOVED_IN: case G_FILE_MONITOR_EVENT_MOVED_OUT: default: break; } }
0
[]
nautilus
2ddba428ef2b13d0620bd599c3635b9c11044659
89,643,123,846,954,030,000,000,000,000,000,000,000
47
Update gnome-desktop code Closes https://gitlab.gnome.org/GNOME/nautilus/issues/987
std::string JSON::JSON_number::unparse(size_t) const { return encoded; }
0
[ "CWE-787" ]
qpdf
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
207,510,894,558,195,600,000,000,000,000,000,000,000
4
Fix sign and conversion warnings (major) This makes all integer type conversions that have potential data loss explicit with calls that do range checks and raise an exception. After this commit, qpdf builds with no warnings when -Wsign-conversion -Wconversion is used with gcc or clang or when -W3 -Wd4800 is used with MSVC. This significantly reduces the likelihood of potential crashes from bogus integer values. There are some parts of the code that take int when they should take size_t or an offset. Such places would make qpdf not support files with more than 2^31 of something that usually wouldn't be so large. In the event that such a file shows up and is valid, at least qpdf would raise an error in the right spot so the issue could be legitimately addressed rather than failing in some weird way because of a silent overflow condition.
bool asn1_write_DATA_BLOB_LDAPString(struct asn1_data *data, const DATA_BLOB *s) { return asn1_write(data, s->data, s->length); }
0
[ "CWE-399" ]
samba
9d989c9dd7a5b92d0c5d65287935471b83b6e884
312,383,705,531,841,740,000,000,000,000,000,000,000
4
CVE-2015-7540: lib: util: Check *every* asn1 return call and early return. BUG: https://bugzilla.samba.org/show_bug.cgi?id=9187 Signed-off-by: Jeremy Allison <[email protected]> Reviewed-by: Volker Lendecke <[email protected]> Autobuild-User(master): Jeremy Allison <[email protected]> Autobuild-Date(master): Fri Sep 19 01:29:00 CEST 2014 on sn-devel-104 (cherry picked from commit b9d3fd4cc551df78a7b066ee8ce43bbaa3ff994a)
CURLcode Curl_init_userdefined(struct UserDefined *set) { CURLcode result = CURLE_OK; set->out = stdout; /* default output to stdout */ set->in_set = stdin; /* default input from stdin */ set->err = stderr; /* default stderr to stderr */ /* use fwrite as default function to store output */ set->fwrite_func = (curl_write_callback)fwrite; /* use fread as default function to read input */ set->fread_func_set = (curl_read_callback)fread; set->is_fread_set = 0; set->is_fwrite_set = 0; set->seek_func = ZERO_NULL; set->seek_client = ZERO_NULL; /* conversion callbacks for non-ASCII hosts */ set->convfromnetwork = ZERO_NULL; set->convtonetwork = ZERO_NULL; set->convfromutf8 = ZERO_NULL; set->filesize = -1; /* we don't know the size */ set->postfieldsize = -1; /* unknown size */ set->maxredirs = -1; /* allow any amount by default */ set->httpreq = HTTPREQ_GET; /* Default HTTP request */ set->rtspreq = RTSPREQ_OPTIONS; /* Default RTSP request */ set->ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */ set->ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */ set->ftp_use_pret = FALSE; /* mainly useful for drftpd servers */ set->ftp_filemethod = FTPFILE_MULTICWD; set->dns_cache_timeout = 60; /* Timeout every 60 seconds by default */ /* Set the default size of the SSL session ID cache */ set->general_ssl.max_ssl_sessions = 5; set->proxyport = 0; set->proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */ set->httpauth = CURLAUTH_BASIC; /* defaults to basic */ set->proxyauth = CURLAUTH_BASIC; /* defaults to basic */ /* SOCKS5 proxy auth defaults to username/password + GSS-API */ set->socks5auth = CURLAUTH_BASIC | CURLAUTH_GSSAPI; /* make libcurl quiet by default: */ set->hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */ /* * libcurl 7.10 introduced SSL verification *by default*! This needs to be * switched off unless wanted. */ set->ssl.primary.verifypeer = TRUE; set->ssl.primary.verifyhost = TRUE; #ifdef USE_TLS_SRP set->ssl.authtype = CURL_TLSAUTH_NONE; #endif set->ssh_auth_types = CURLSSH_AUTH_DEFAULT; /* defaults to any auth type */ set->ssl.primary.sessionid = TRUE; /* session ID caching enabled by default */ set->proxy_ssl = set->ssl; set->new_file_perms = 0644; /* Default permissions */ set->new_directory_perms = 0755; /* Default permissions */ /* for the *protocols fields we don't use the CURLPROTO_ALL convenience define since we internally only use the lower 16 bits for the passed in bitmask to not conflict with the private bits */ set->allowed_protocols = CURLPROTO_ALL; set->redir_protocols = CURLPROTO_ALL & /* All except FILE, SCP and SMB */ ~(CURLPROTO_FILE | CURLPROTO_SCP | CURLPROTO_SMB | CURLPROTO_SMBS); #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) /* * disallow unprotected protection negotiation NEC reference implementation * seem not to follow rfc1961 section 4.3/4.4 */ set->socks5_gssapi_nec = FALSE; #endif /* This is our preferred CA cert bundle/path since install time */ #if defined(CURL_CA_BUNDLE) result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], CURL_CA_BUNDLE); if(result) return result; result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY], CURL_CA_BUNDLE); if(result) return result; #endif #if defined(CURL_CA_PATH) result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_ORIG], CURL_CA_PATH); if(result) return result; result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY], CURL_CA_PATH); if(result) return result; #endif set->wildcard_enabled = FALSE; set->chunk_bgn = ZERO_NULL; set->chunk_end = ZERO_NULL; /* tcp keepalives are disabled by default, but provide reasonable values for * the interval and idle times. */ set->tcp_keepalive = FALSE; set->tcp_keepintvl = 60; set->tcp_keepidle = 60; set->tcp_fastopen = FALSE; set->tcp_nodelay = TRUE; set->ssl_enable_npn = TRUE; set->ssl_enable_alpn = TRUE; set->expect_100_timeout = 1000L; /* Wait for a second by default. */ set->sep_headers = TRUE; /* separated header lists by default */ set->buffer_size = READBUFFER_SIZE; Curl_http2_init_userset(set); return result; }
0
[ "CWE-119" ]
curl
9b5e12a5491d2e6b68e0c88ca56f3a9ef9fba400
305,187,582,878,526,200,000,000,000,000,000,000,000
128
url: fix alignment of ssl_backend_data struct - Align the array of ssl_backend_data on a max 32 byte boundary. 8 is likely to be ok but I went with 32 for posterity should one of the ssl_backend_data structs change to contain a larger sized variable in the future. Prior to this change (since dev 70f1db3, release 7.56) the connectdata structure was undersized by 4 bytes in 32-bit builds with ssl enabled because long long * was mistakenly used for alignment instead of long long, with the intention being an 8 byte boundary. Also long long may not be an available type. The undersized connectdata could lead to oob read/write past the end in what was expected to be the last 4 bytes of the connection's secondary socket https proxy ssl_backend_data struct (the secondary socket in a connection is used by ftp, others?). Closes https://github.com/curl/curl/issues/2093 CVE-2017-8818 Bug: https://curl.haxx.se/docs/adv_2017-af0a.html
static inline int is_revectored(int nr, struct revectored_struct *bitmap) { __asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0" :"=r" (nr) :"m" (*bitmap), "r" (nr)); return nr; }
0
[ "CWE-264" ]
linux-2.6
1a5a9906d4e8d1976b701f889d8f35d54b928f25
232,269,537,288,860,770,000,000,000,000,000,000,000
7
mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode In some cases it may happen that pmd_none_or_clear_bad() is called with the mmap_sem hold in read mode. In those cases the huge page faults can allocate hugepmds under pmd_none_or_clear_bad() and that can trigger a false positive from pmd_bad() that will not like to see a pmd materializing as trans huge. It's not khugepaged causing the problem, khugepaged holds the mmap_sem in write mode (and all those sites must hold the mmap_sem in read mode to prevent pagetables to go away from under them, during code review it seems vm86 mode on 32bit kernels requires that too unless it's restricted to 1 thread per process or UP builds). The race is only with the huge pagefaults that can convert a pmd_none() into a pmd_trans_huge(). Effectively all these pmd_none_or_clear_bad() sites running with mmap_sem in read mode are somewhat speculative with the page faults, and the result is always undefined when they run simultaneously. This is probably why it wasn't common to run into this. For example if the madvise(MADV_DONTNEED) runs zap_page_range() shortly before the page fault, the hugepage will not be zapped, if the page fault runs first it will be zapped. Altering pmd_bad() not to error out if it finds hugepmds won't be enough to fix this, because zap_pmd_range would then proceed to call zap_pte_range (which would be incorrect if the pmd become a pmd_trans_huge()). The simplest way to fix this is to read the pmd in the local stack (regardless of what we read, no need of actual CPU barriers, only compiler barrier needed), and be sure it is not changing under the code that computes its value. Even if the real pmd is changing under the value we hold on the stack, we don't care. If we actually end up in zap_pte_range it means the pmd was not none already and it was not huge, and it can't become huge from under us (khugepaged locking explained above). All we need is to enforce that there is no way anymore that in a code path like below, pmd_trans_huge can be false, but pmd_none_or_clear_bad can run into a hugepmd. The overhead of a barrier() is just a compiler tweak and should not be measurable (I only added it for THP builds). I don't exclude different compiler versions may have prevented the race too by caching the value of *pmd on the stack (that hasn't been verified, but it wouldn't be impossible considering pmd_none_or_clear_bad, pmd_bad, pmd_trans_huge, pmd_none are all inlines and there's no external function called in between pmd_trans_huge and pmd_none_or_clear_bad). if (pmd_trans_huge(*pmd)) { if (next-addr != HPAGE_PMD_SIZE) { VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem)); split_huge_page_pmd(vma->vm_mm, pmd); } else if (zap_huge_pmd(tlb, vma, pmd, addr)) continue; /* fall through */ } if (pmd_none_or_clear_bad(pmd)) Because this race condition could be exercised without special privileges this was reported in CVE-2012-1179. The race was identified and fully explained by Ulrich who debugged it. I'm quoting his accurate explanation below, for reference. ====== start quote ======= mapcount 0 page_mapcount 1 kernel BUG at mm/huge_memory.c:1384! At some point prior to the panic, a "bad pmd ..." message similar to the following is logged on the console: mm/memory.c:145: bad pmd ffff8800376e1f98(80000000314000e7). The "bad pmd ..." message is logged by pmd_clear_bad() before it clears the page's PMD table entry. 143 void pmd_clear_bad(pmd_t *pmd) 144 { -> 145 pmd_ERROR(*pmd); 146 pmd_clear(pmd); 147 } After the PMD table entry has been cleared, there is an inconsistency between the actual number of PMD table entries that are mapping the page and the page's map count (_mapcount field in struct page). When the page is subsequently reclaimed, __split_huge_page() detects this inconsistency. 1381 if (mapcount != page_mapcount(page)) 1382 printk(KERN_ERR "mapcount %d page_mapcount %d\n", 1383 mapcount, page_mapcount(page)); -> 1384 BUG_ON(mapcount != page_mapcount(page)); The root cause of the problem is a race of two threads in a multithreaded process. Thread B incurs a page fault on a virtual address that has never been accessed (PMD entry is zero) while Thread A is executing an madvise() system call on a virtual address within the same 2 MB (huge page) range. virtual address space .---------------------. | | | | .-|---------------------| | | | | | |<-- B(fault) | | | 2 MB | |/////////////////////|-. huge < |/////////////////////| > A(range) page | |/////////////////////|-' | | | | | | '-|---------------------| | | | | '---------------------' - Thread A is executing an madvise(..., MADV_DONTNEED) system call on the virtual address range "A(range)" shown in the picture. sys_madvise // Acquire the semaphore in shared mode. down_read(&current->mm->mmap_sem) ... madvise_vma switch (behavior) case MADV_DONTNEED: madvise_dontneed zap_page_range unmap_vmas unmap_page_range zap_pud_range zap_pmd_range // // Assume that this huge page has never been accessed. // I.e. content of the PMD entry is zero (not mapped). // if (pmd_trans_huge(*pmd)) { // We don't get here due to the above assumption. } // // Assume that Thread B incurred a page fault and .---------> // sneaks in here as shown below. | // | if (pmd_none_or_clear_bad(pmd)) | { | if (unlikely(pmd_bad(*pmd))) | pmd_clear_bad | { | pmd_ERROR | // Log "bad pmd ..." message here. | pmd_clear | // Clear the page's PMD entry. | // Thread B incremented the map count | // in page_add_new_anon_rmap(), but | // now the page is no longer mapped | // by a PMD entry (-> inconsistency). | } | } | v - Thread B is handling a page fault on virtual address "B(fault)" shown in the picture. ... do_page_fault __do_page_fault // Acquire the semaphore in shared mode. down_read_trylock(&mm->mmap_sem) ... handle_mm_fault if (pmd_none(*pmd) && transparent_hugepage_enabled(vma)) // We get here due to the above assumption (PMD entry is zero). do_huge_pmd_anonymous_page alloc_hugepage_vma // Allocate a new transparent huge page here. ... __do_huge_pmd_anonymous_page ... spin_lock(&mm->page_table_lock) ... page_add_new_anon_rmap // Here we increment the page's map count (starts at -1). atomic_set(&page->_mapcount, 0) set_pmd_at // Here we set the page's PMD entry which will be cleared // when Thread A calls pmd_clear_bad(). ... spin_unlock(&mm->page_table_lock) The mmap_sem does not prevent the race because both threads are acquiring it in shared mode (down_read). Thread B holds the page_table_lock while the page's map count and PMD table entry are updated. However, Thread A does not synchronize on that lock. ====== end quote ======= [[email protected]: checkpatch fixes] Reported-by: Ulrich Obergfell <[email protected]> Signed-off-by: Andrea Arcangeli <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Dave Jones <[email protected]> Acked-by: Larry Woodman <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: <[email protected]> [2.6.38+] Cc: Mark Salter <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static int pfkey_migrate(struct sock *sk, struct sk_buff *skb, const struct sadb_msg *hdr, void * const *ext_hdrs) { return -ENOPROTOOPT; }
0
[]
linux
096f41d3a8fcbb8dde7f71379b1ca85fe213eded
300,388,917,811,672,000,000,000,000,000,000,000,000
5
af_key: Fix sadb_x_ipsecrequest parsing The parsing of sadb_x_ipsecrequest is broken in a number of ways. First of all we're not verifying sadb_x_ipsecrequest_len. This is needed when the structure carries addresses at the end. Worse we don't even look at the length when we parse those optional addresses. The migration code had similar parsing code that's better but it also has some deficiencies. The length is overcounted first of all as it includes the header itself. It also fails to check the length before dereferencing the sa_family field. This patch fixes those problems in parse_sockaddr_pair and then uses it in parse_ipsecrequest. Reported-by: Andrey Konovalov <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
Type_handler::get_handler_by_field_type(enum_field_types type) { switch (type) { case MYSQL_TYPE_DECIMAL: return &type_handler_olddecimal; case MYSQL_TYPE_NEWDECIMAL: return &type_handler_newdecimal; case MYSQL_TYPE_TINY: return &type_handler_tiny; case MYSQL_TYPE_SHORT: return &type_handler_short; case MYSQL_TYPE_LONG: return &type_handler_long; case MYSQL_TYPE_LONGLONG: return &type_handler_longlong; case MYSQL_TYPE_INT24: return &type_handler_int24; case MYSQL_TYPE_YEAR: return &type_handler_year; case MYSQL_TYPE_BIT: return &type_handler_bit; case MYSQL_TYPE_FLOAT: return &type_handler_float; case MYSQL_TYPE_DOUBLE: return &type_handler_double; case MYSQL_TYPE_NULL: return &type_handler_null; case MYSQL_TYPE_VARCHAR: return &type_handler_varchar; case MYSQL_TYPE_TINY_BLOB: return &type_handler_tiny_blob; case MYSQL_TYPE_MEDIUM_BLOB: return &type_handler_medium_blob; case MYSQL_TYPE_LONG_BLOB: return &type_handler_long_blob; case MYSQL_TYPE_BLOB: return &type_handler_blob; case MYSQL_TYPE_VAR_STRING: return &type_handler_varchar; // Map to VARCHAR case MYSQL_TYPE_STRING: return &type_handler_string; case MYSQL_TYPE_ENUM: return &type_handler_varchar; // Map to VARCHAR case MYSQL_TYPE_SET: return &type_handler_varchar; // Map to VARCHAR case MYSQL_TYPE_GEOMETRY: #ifdef HAVE_SPATIAL return &type_handler_geometry; #else return NULL; #endif case MYSQL_TYPE_TIMESTAMP: return &type_handler_timestamp2;// Map to timestamp2 case MYSQL_TYPE_TIMESTAMP2: return &type_handler_timestamp2; case MYSQL_TYPE_DATE: return &type_handler_newdate; // Map to newdate case MYSQL_TYPE_TIME: return &type_handler_time2; // Map to time2 case MYSQL_TYPE_TIME2: return &type_handler_time2; case MYSQL_TYPE_DATETIME: return &type_handler_datetime2; // Map to datetime2 case MYSQL_TYPE_DATETIME2: return &type_handler_datetime2; case MYSQL_TYPE_NEWDATE: /* NEWDATE is actually a real_type(), not a field_type(), but it's used around the code in field_type() context. We should probably clean up the code not to use MYSQL_TYPE_NEWDATE in field_type() context and add DBUG_ASSERT(0) here. */ return &type_handler_newdate; }; DBUG_ASSERT(0); return &type_handler_string; }
0
[ "CWE-120" ]
server
eca207c46293bc72dd8d0d5622153fab4d3fccf1
179,964,758,144,168,960,000,000,000,000,000,000,000
49
MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size. Precision should be kept below DECIMAL_MAX_SCALE for computations. It can be bigger in Item_decimal. I'd fix this too but it changes the existing behaviour so problemmatic to ix.
static void free_pgt(struct user_ta_ctx *utc, vaddr_t base, size_t size) { struct thread_specific_data *tsd = thread_get_tsd(); struct pgt_cache *pgt_cache = NULL; if (&utc->ctx == tsd->ctx) pgt_cache = &tsd->pgt_cache; pgt_flush_ctx_range(pgt_cache, &utc->ctx, base, base + size); }
0
[ "CWE-20", "CWE-787" ]
optee_os
95f36d661f2b75887772ea28baaad904bde96970
211,335,590,967,730,560,000,000,000,000,000,000,000
10
core: tee_mmu_check_access_rights() check all pages Prior to this patch tee_mmu_check_access_rights() checks an address in each page of a supplied range. If both the start and length of that range is unaligned the last page in the range is sometimes not checked. With this patch the first address of each page in the range is checked to simplify the logic of checking each page and the range and also to cover the last page under all circumstances. Fixes: OP-TEE-2018-0005: "tee_mmu_check_access_rights does not check final page of TA buffer" Signed-off-by: Jens Wiklander <[email protected]> Tested-by: Joakim Bech <[email protected]> (QEMU v7, v8) Reviewed-by: Joakim Bech <[email protected]> Reported-by: Riscure <[email protected]> Reported-by: Alyssa Milburn <[email protected]> Acked-by: Etienne Carriere <[email protected]>
Status ClientConnectionImpl::onStatus(const char* data, size_t length) { auto& headers = absl::get<ResponseHeaderMapPtr>(headers_or_trailers_); StatefulHeaderKeyFormatterOptRef formatter(headers->formatter()); if (formatter.has_value()) { formatter->setReasonPhrase(absl::string_view(data, length)); } return okStatus(); }
0
[ "CWE-416" ]
envoy
fe7c69c248f4fe5a9080c7ccb35275b5218bb5ab
132,574,611,441,108,680,000,000,000,000,000,000,000
9
internal redirect: fix a lifetime bug (#785) Signed-off-by: Alyssa Wilk <[email protected]> Signed-off-by: Matt Klein <[email protected]> Signed-off-by: Pradeep Rao <[email protected]>
tight_detect_smooth_image24(VncState *vs, int w, int h) { int off; int x, y, d, dx; unsigned int c; unsigned int stats[256]; int pixels = 0; int pix, left[3]; unsigned int errors; unsigned char *buf = vs->tight->tight.buffer; /* * If client is big-endian, color samples begin from the second * byte (offset 1) of a 32-bit pixel value. */ off = vs->client_be; memset(stats, 0, sizeof (stats)); for (y = 0, x = 0; y < h && x < w;) { for (d = 0; d < h - y && d < w - x - VNC_TIGHT_DETECT_SUBROW_WIDTH; d++) { for (c = 0; c < 3; c++) { left[c] = buf[((y+d)*w+x+d)*4+off+c] & 0xFF; } for (dx = 1; dx <= VNC_TIGHT_DETECT_SUBROW_WIDTH; dx++) { for (c = 0; c < 3; c++) { pix = buf[((y+d)*w+x+d+dx)*4+off+c] & 0xFF; stats[abs(pix - left[c])]++; left[c] = pix; } pixels++; } } if (w > h) { x += h; y = 0; } else { x = 0; y += w; } } if (pixels == 0) { return 0; } /* 95% smooth or more ... */ if (stats[0] * 33 / pixels >= 95) { return 0; } errors = 0; for (c = 1; c < 8; c++) { errors += stats[c] * (c * c); if (stats[c] == 0 || stats[c] > stats[c-1] * 2) { return 0; } } for (; c < 256; c++) { errors += stats[c] * (c * c); } errors /= (pixels * 3 - stats[0]); return errors; }
0
[ "CWE-401" ]
qemu
6bf21f3d83e95bcc4ba35a7a07cc6655e8b010b0
27,126,539,111,312,524,000,000,000,000,000,000,000
66
vnc: fix memory leak when vnc disconnect Currently when qemu receives a vnc connect, it creates a 'VncState' to represent this connection. In 'vnc_worker_thread_loop' it creates a local 'VncState'. The connection 'VcnState' and local 'VncState' exchange data in 'vnc_async_encoding_start' and 'vnc_async_encoding_end'. In 'zrle_compress_data' it calls 'deflateInit2' to allocate the libz library opaque data. The 'VncState' used in 'zrle_compress_data' is the local 'VncState'. In 'vnc_zrle_clear' it calls 'deflateEnd' to free the libz library opaque data. The 'VncState' used in 'vnc_zrle_clear' is the connection 'VncState'. In currently implementation there will be a memory leak when the vnc disconnect. Following is the asan output backtrack: Direct leak of 29760 byte(s) in 5 object(s) allocated from: 0 0xffffa67ef3c3 in __interceptor_calloc (/lib64/libasan.so.4+0xd33c3) 1 0xffffa65071cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) 2 0xffffa5e968f7 in deflateInit2_ (/lib64/libz.so.1+0x78f7) 3 0xaaaacec58613 in zrle_compress_data ui/vnc-enc-zrle.c:87 4 0xaaaacec58613 in zrle_send_framebuffer_update ui/vnc-enc-zrle.c:344 5 0xaaaacec34e77 in vnc_send_framebuffer_update ui/vnc.c:919 6 0xaaaacec5e023 in vnc_worker_thread_loop ui/vnc-jobs.c:271 7 0xaaaacec5e5e7 in vnc_worker_thread ui/vnc-jobs.c:340 8 0xaaaacee4d3c3 in qemu_thread_start util/qemu-thread-posix.c:502 9 0xffffa544e8bb in start_thread (/lib64/libpthread.so.0+0x78bb) 10 0xffffa53965cb in thread_start (/lib64/libc.so.6+0xd55cb) This is because the opaque allocated in 'deflateInit2' is not freed in 'deflateEnd'. The reason is that the 'deflateEnd' calls 'deflateStateCheck' and in the latter will check whether 's->strm != strm'(libz's data structure). This check will be true so in 'deflateEnd' it just return 'Z_STREAM_ERROR' and not free the data allocated in 'deflateInit2'. The reason this happens is that the 'VncState' contains the whole 'VncZrle', so when calling 'deflateInit2', the 's->strm' will be the local address. So 's->strm != strm' will be true. To fix this issue, we need to make 'zrle' of 'VncState' to be a pointer. Then the connection 'VncState' and local 'VncState' exchange mechanism will work as expection. The 'tight' of 'VncState' has the same issue, let's also turn it to a pointer. Reported-by: Ying Fang <[email protected]> Signed-off-by: Li Qiang <[email protected]> Message-id: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]>
njs_generate_if_statement_cond(njs_vm_t *vm, njs_generator_t *generator, njs_parser_node_t *node) { njs_int_t ret; njs_jump_off_t jump_offset; njs_vmcode_cond_jump_t *cond_jump; njs_generate_code(generator, njs_vmcode_cond_jump_t, cond_jump, NJS_VMCODE_IF_FALSE_JUMP, 2, node); cond_jump->cond = node->left->index; ret = njs_generate_node_index_release(vm, generator, node->left); if (njs_slow_path(ret != NJS_OK)) { return ret; } jump_offset = njs_code_offset(generator, cond_jump); if (node->right != NULL && node->right->token_type == NJS_TOKEN_BRANCHING) { /* The "then" branch in a case of "if/then/else" statement. */ node = node->right; njs_generator_next(generator, njs_generate, node->left); return njs_generator_after(vm, generator, njs_queue_first(&generator->stack), node, njs_generate_if_statement_then, &jump_offset, sizeof(njs_jump_off_t)); } /* * The "then" branch in a case of "if/then" statement * or the "else" branch in a case of "if/then/else" statement. */ njs_generator_next(generator, njs_generate, node->right); return njs_generator_after(vm, generator, njs_queue_first(&generator->stack), node, njs_generate_if_statement_else, &jump_offset, sizeof(njs_jump_off_t)); }
0
[ "CWE-703", "CWE-754" ]
njs
404553896792b8f5f429dc8852d15784a59d8d3e
228,144,033,761,220,700,000,000,000,000,000,000,000
44
Fixed break instruction in a try-catch block. Previously, JUMP offset for a break instruction inside a try-catch block was not set to a correct offset during code generation when a return instruction was present in inner try-catch block. The fix is to update the JUMP offset appropriately. This closes #553 issue on Github.
MpdCantataMounterInterface * RemoteFsDevice::mounter() { if (!mounterIface) { if (!QDBusConnection::systemBus().interface()->isServiceRegistered(MpdCantataMounterInterface::staticInterfaceName())) { QDBusConnection::systemBus().interface()->startService(MpdCantataMounterInterface::staticInterfaceName()); } mounterIface=new MpdCantataMounterInterface(MpdCantataMounterInterface::staticInterfaceName(), "/Mounter", QDBusConnection::systemBus(), this); connect(mounterIface, SIGNAL(mountStatus(const QString &, int, int)), SLOT(mountStatus(const QString &, int, int))); connect(mounterIface, SIGNAL(umountStatus(const QString &, int, int)), SLOT(umountStatus(const QString &, int, int))); } return mounterIface; }
1
[ "CWE-20", "CWE-22" ]
cantata
afc4f8315d3e96574925fb530a7004cc9e6ce3d3
209,087,791,007,908,770,000,000,000,000,000,000,000
13
Remove internal Samba shre mounting code, this had some privilege escalation issues, and is not well tested
static int tcmu_glfs_write(struct tcmu_device *dev, struct tcmulib_cmd *cmd, struct iovec *iov, size_t iov_cnt, size_t length, off_t offset) { struct glfs_state *state = tcmu_get_dev_private(dev); glfs_cbk_cookie *cookie; cookie = calloc(1, sizeof(*cookie)); if (!cookie) { tcmu_err("Could not allocate cookie: %m\n"); goto out; } cookie->dev = dev; cookie->cmd = cmd; cookie->length = length; cookie->op = TCMU_GLFS_WRITE; if (glfs_pwritev_async(state->gfd, iov, iov_cnt, offset, ALLOWED_BSOFLAGS, glfs_async_cbk, cookie) < 0) { tcmu_err("glfs_pwritev_async failed: %m\n"); goto out; } return 0; out: free(cookie); return SAM_STAT_TASK_SET_FULL; }
0
[ "CWE-200", "CWE-119" ]
tcmu-runner
61bd03e600d2abf309173e9186f4d465bb1b7157
201,284,468,981,640,570,000,000,000,000,000,000,000
30
glfs: discard glfs_check_config Signed-off-by: Prasanna Kumar Kalever <[email protected]>
static int FIPS_des3_test(void) { int ret = 0; unsigned char pltmp[8]; unsigned char citmp[8]; unsigned char key[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18, 19,20,21,22,23,24}; unsigned char plaintext[] = { 'e', 't', 'a', 'o', 'n', 'r', 'i', 's' }; EVP_CIPHER_CTX ctx; FIPS_cipher_ctx_init(&ctx); if (FIPS_cipherinit(&ctx, EVP_des_ede3_ecb(), key, NULL, 1) <= 0) goto err; FIPS_cipher(&ctx, citmp, plaintext, 8); if (FIPS_cipherinit(&ctx, EVP_des_ede3_ecb(), key, NULL, 0) <= 0) goto err; FIPS_cipher(&ctx, pltmp, citmp, 8); if (memcmp(pltmp, plaintext, 8)) goto err; ret = 1; err: FIPS_cipher_ctx_cleanup(&ctx); return ret; }
0
[]
openssl
200f249b8c3b6439e0200d01caadc24806f1a983
292,958,730,932,282,200,000,000,000,000,000,000,000
23
Remove Dual EC DRBG from FIPS module.
compare_cookies (gconstpointer a, gconstpointer b, gpointer jar) { SoupCookie *ca = (SoupCookie *)a; SoupCookie *cb = (SoupCookie *)b; SoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar); int alen, blen; guint aserial, bserial; /* "Cookies with longer path fields are listed before cookies * with shorter path field." */ alen = ca->path ? strlen (ca->path) : 0; blen = cb->path ? strlen (cb->path) : 0; if (alen != blen) return blen - alen; /* "Among cookies that have equal length path fields, cookies * with earlier creation dates are listed before cookies with * later creation dates." */ aserial = GPOINTER_TO_UINT (g_hash_table_lookup (priv->serials, ca)); bserial = GPOINTER_TO_UINT (g_hash_table_lookup (priv->serials, cb)); return aserial - bserial; }
0
[ "CWE-125" ]
libsoup
db2b0d5809d5f8226d47312b40992cadbcde439f
321,344,434,198,276,800,000,000,000,000,000,000,000
24
cookie-jar: bail if hostname is an empty string There are several other ways to fix the problem with this function, but skipping over all of the code is probably the simplest. Fixes #3
static int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int i, changed = 0; struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); for (i = 0; i < 2; i++) if (line6pcm->volume_playback[i] != ucontrol->value.integer.value[i]) { line6pcm->volume_playback[i] = ucontrol->value.integer.value[i]; changed = 1; } return changed; }
0
[ "CWE-476" ]
linux
3450121997ce872eb7f1248417225827ea249710
22,060,736,853,331,684,000,000,000,000,000,000,000
16
ALSA: line6: Fix write on zero-sized buffer LINE6 drivers allocate the buffers based on the value returned from usb_maxpacket() calls. The manipulated device may return zero for this, and this results in the kmalloc() with zero size (and it may succeed) while the other part of the driver code writes the packet data with the fixed size -- which eventually overwrites. This patch adds a simple sanity check for the invalid buffer size for avoiding that problem. Reported-by: [email protected] Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
TPML_CC_Unmarshal(TPML_CC *target, BYTE **buffer, INT32 *size) { TPM_RC rc = TPM_RC_SUCCESS; UINT32 i; if (rc == TPM_RC_SUCCESS) { rc = UINT32_Unmarshal(&target->count, buffer, size); } if (rc == TPM_RC_SUCCESS) { if (target->count > MAX_CAP_CC) { rc = TPM_RC_SIZE; } } for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { rc = TPM_CC_Unmarshal(&target->commandCodes[i], buffer, size); } return rc; }
1
[ "CWE-787" ]
libtpms
f16250b35aff6995e540143a9858c9cf0d1f9573
300,331,104,579,238,500,000,000,000,000,000,000,000
18
tpm2: Reset TPM2B buffer sizes after test fails for valid buffer size Reset the buffer size indicator in a TPM2B type of buffer after it failed the test for the maximum buffer size it allows. This prevents having bad buffer sizes in memory that can come to haunt us when writing the volatile state for example. Signed-off-by: Stefan Berger <[email protected]>
void CoreUserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QString &msg) { Q_UNUSED(bufferInfo); // trim spaces before chans or keys QString sane_msg = msg; sane_msg.replace(QRegExp(", +"), ","); QStringList params = sane_msg.trimmed().split(" "); QStringList chans = params[0].split(",", QString::SkipEmptyParts); QStringList keys; if (params.count() > 1) keys = params[1].split(","); int i; for (i = 0; i < chans.count(); i++) { if (!network()->isChannelName(chans[i])) chans[i].prepend('#'); if (i < keys.count()) { network()->addChannelKey(chans[i], keys[i]); } else { network()->removeChannelKey(chans[i]); } } static const char *cmd = "JOIN"; i = 0; QStringList joinChans, joinKeys; int slicesize = chans.count(); QList<QByteArray> encodedParams; // go through all to-be-joined channels and (re)build the join list while (i < chans.count()) { joinChans.append(chans.at(i)); if (i < keys.count()) joinKeys.append(keys.at(i)); // if the channel list we built so far either contains all requested channels or exceeds // the desired amount of channels in this slice, try to send what we have so far if (++i == chans.count() || joinChans.count() >= slicesize) { params.clear(); params.append(joinChans.join(",")); params.append(joinKeys.join(",")); encodedParams = serverEncode(params); // check if it fits in one command if (lastParamOverrun(cmd, encodedParams) == 0) { emit putCmd(cmd, encodedParams); } else if (slicesize > 1) { // back to start of slice, try again with half the amount of channels i -= slicesize; slicesize /= 2; } joinChans.clear(); joinKeys.clear(); } } }
0
[ "CWE-399" ]
quassel
b5e38970ffd55e2dd9f706ce75af9a8d7730b1b8
240,418,591,137,432,560,000,000,000,000,000,000,000
60
Improve the message-splitting algorithm for PRIVMSG and CTCP This introduces a new message splitting algorithm based on QTextBoundaryFinder. It works by first starting with the entire message to be sent, encoding it, and checking to see if it is over the maximum message length. If it is, it uses QTBF to find the word boundary most immediately preceding the maximum length. If no suitable boundary can be found, it falls back to searching for grapheme boundaries. It repeats this process until the entire message has been sent. Unlike what it replaces, the new splitting code is not recursive and cannot cause stack overflows. Additionally, if it is unable to split a string, it will give up gracefully and not crash the core or cause a thread to run away. This patch fixes two bugs. The first is garbage characters caused by accidentally splitting the string in the middle of a multibyte character. Since the new code splits at a character level instead of a byte level, this will no longer be an issue. The second is the core crash caused by sending an overlength CTCP query ("/me") containing only multibyte characters. This bug was caused by the old CTCP splitter using the byte index from lastParamOverrun() as a character index for a QString.
const void *_ssh_list_pop_head(struct ssh_list *list){ struct ssh_iterator *iterator=list->root; const void *data; if(!list->root) return NULL; data=iterator->data; list->root=iterator->next; if(list->end==iterator) list->end=NULL; SAFE_FREE(iterator); return data; }
0
[]
libssh
2ba1dea5493fb2f5a5be2dd263ce46ccb5f8ec76
241,471,652,149,981,530,000,000,000,000,000,000,000
12
CVE-2019-14889: misc: Add function to quote file names The added function quote file names strings to be used in a shell. Special cases are treated for the charactes '\'' and '!'. Fixes T181 Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]> Reviewed-by: Andreas Schneider <[email protected]> (cherry picked from commit c4ad1aba9860e02fe03ef3f58a047964e9e765fc)
struct super_block *get_super_thawed(struct block_device *bdev) { while (1) { struct super_block *s = get_super(bdev); if (!s || s->s_writers.frozen == SB_UNFROZEN) return s; up_read(&s->s_umount); wait_event(s->s_writers.wait_unfrozen, s->s_writers.frozen == SB_UNFROZEN); put_super(s); } }
0
[ "CWE-17" ]
linux
eee5cc2702929fd41cce28058dc6d6717f723f87
166,770,023,783,017,840,000,000,000,000,000,000,000
12
get rid of s_files and files_lock The only thing we need it for is alt-sysrq-r (emergency remount r/o) and these days we can do just as well without going through the list of files. Signed-off-by: Al Viro <[email protected]>
bool isInMem () const { return type_ == bMemory; }
0
[ "CWE-190" ]
exiv2
c73d1e27198a389ce7caf52ac30f8e2120acdafd
195,093,024,111,699,570,000,000,000,000,000,000,000
4
Avoid negative integer overflow when `filesize < io_->tell()`. This fixes #791.
static void __net_exit dccp_v6_exit_net(struct net *net) { inet_ctl_sock_destroy(net->dccp.v6_ctl_sk); }
0
[ "CWE-362" ]
linux-2.6
f6d8bd051c391c1c0458a30b2a7abcd939329259
115,479,088,776,514,340,000,000,000,000,000,000,000
4
inet: add RCU protection to inet->opt We lack proper synchronization to manipulate inet->opt ip_options Problem is ip_make_skb() calls ip_setup_cork() and ip_setup_cork() possibly makes a copy of ipc->opt (struct ip_options), without any protection against another thread manipulating inet->opt. Another thread can change inet->opt pointer and free old one under us. Use RCU to protect inet->opt (changed to inet->inet_opt). Instead of handling atomic refcounts, just copy ip_options when necessary, to avoid cache line dirtying. We cant insert an rcu_head in struct ip_options since its included in skb->cb[], so this patch is large because I had to introduce a new ip_options_rcu structure. Signed-off-by: Eric Dumazet <[email protected]> Cc: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static int samldb_modify(struct ldb_module *module, struct ldb_request *req) { struct ldb_context *ldb; struct samldb_ctx *ac; struct ldb_message_element *el, *el2; struct ldb_control *is_undelete; bool modified = false; int ret; if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } ldb = ldb_module_get_ctx(module); /* * we are going to need some special handling if in Undelete call. * Since tombstone_reanimate module will restore certain attributes, * we need to relax checks for: sAMAccountType, primaryGroupID */ is_undelete = ldb_request_get_control(req, DSDB_CONTROL_RESTORE_TOMBSTONE_OID); /* make sure that "objectSid" is not specified */ el = ldb_msg_find_element(req->op.mod.message, "objectSid"); if (el != NULL) { if (ldb_request_get_control(req, LDB_CONTROL_PROVISION_OID) == NULL) { ldb_set_errstring(ldb, "samldb: objectSid must not be specified!"); return LDB_ERR_UNWILLING_TO_PERFORM; } } if (is_undelete == NULL) { /* make sure that "sAMAccountType" is not specified */ el = ldb_msg_find_element(req->op.mod.message, "sAMAccountType"); if (el != NULL) { ldb_set_errstring(ldb, "samldb: sAMAccountType must not be specified!"); return LDB_ERR_UNWILLING_TO_PERFORM; } } /* make sure that "isCriticalSystemObject" is not specified */ el = ldb_msg_find_element(req->op.mod.message, "isCriticalSystemObject"); if (el != NULL) { if (ldb_request_get_control(req, LDB_CONTROL_RELAX_OID) == NULL) { ldb_set_errstring(ldb, "samldb: isCriticalSystemObject must not be specified!"); return LDB_ERR_UNWILLING_TO_PERFORM; } } /* msDS-IntId is not allowed to be modified * except when modification comes from replication */ if (ldb_msg_find_element(req->op.mod.message, "msDS-IntId")) { if (!ldb_request_get_control(req, DSDB_CONTROL_REPLICATED_UPDATE_OID)) { return LDB_ERR_CONSTRAINT_VIOLATION; } } el = ldb_msg_find_element(req->op.mod.message, "userParameters"); if (el != NULL && ldb_req_is_untrusted(req)) { const char *reason = "samldb: " "setting userParameters is not supported over LDAP, " "see https://bugzilla.samba.org/show_bug.cgi?id=8077"; ldb_debug(ldb, LDB_DEBUG_WARNING, "%s", reason); return ldb_error(ldb, LDB_ERR_CONSTRAINT_VIOLATION, reason); } ac = samldb_ctx_init(module, req); if (ac == NULL) { return ldb_operr(ldb); } /* build the new msg */ ac->msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (ac->msg == NULL) { talloc_free(ac); ldb_debug(ldb, LDB_DEBUG_FATAL, "samldb_modify: ldb_msg_copy_shallow failed!\n"); return ldb_operr(ldb); } ret = samldb_check_sensitive_attributes(ac); if (ret != LDB_SUCCESS) { talloc_free(ac); return ret; } if (is_undelete == NULL) { el = ldb_msg_find_element(ac->msg, "primaryGroupID"); if (el != NULL) { ret = samldb_prim_group_trigger(ac); if (ret != LDB_SUCCESS) { return ret; } } } el = ldb_msg_find_element(ac->msg, "userAccountControl"); if (el != NULL) { modified = true; ret = samldb_user_account_control_change(ac); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "pwdLastSet"); if (el != NULL) { modified = true; ret = samldb_pwd_last_set_change(ac); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "lockoutTime"); if (el != NULL) { modified = true; ret = samldb_lockout_time(ac); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "groupType"); if (el != NULL) { modified = true; ret = samldb_group_type_change(ac); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "sAMAccountName"); if (el != NULL) { uint32_t user_account_control; struct ldb_result *res = NULL; const char * const attrs[] = { "userAccountControl", "objectclass", NULL }; ret = dsdb_module_search_dn(ac->module, ac, &res, ac->msg->dn, attrs, DSDB_FLAG_NEXT_MODULE | DSDB_SEARCH_SHOW_DELETED, ac->req); if (ret != LDB_SUCCESS) { return ret; } user_account_control = ldb_msg_find_attr_as_uint(res->msgs[0], "userAccountControl", 0); if ((user_account_control & UF_TRUST_ACCOUNT_MASK) != 0) { ac->need_trailing_dollar = true; } else if (samdb_find_attribute(ldb, res->msgs[0], "objectclass", "computer") != NULL) { ac->need_trailing_dollar = true; } ret = samldb_sam_accountname_valid_check(ac); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "userPrincipalName"); if (el != NULL) { ret = samldb_sam_account_upn_clash(ac); if (ret != LDB_SUCCESS) { talloc_free(ac); return ret; } } el = ldb_msg_find_element(ac->msg, "ldapDisplayName"); if (el != NULL) { ret = samldb_schema_ldapdisplayname_valid_check(ac); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "attributeID"); if (el != NULL) { ldb_asprintf_errstring(ldb_module_get_ctx(ac->module), "Once set, attributeID values may not be modified"); return LDB_ERR_CONSTRAINT_VIOLATION; } el = ldb_msg_find_element(ac->msg, "governsID"); if (el != NULL) { ldb_asprintf_errstring(ldb_module_get_ctx(ac->module), "Once set, governsID values may not be modified"); return LDB_ERR_CONSTRAINT_VIOLATION; } el = ldb_msg_find_element(ac->msg, "member"); if (el != NULL) { struct ldb_control *fix_link_sid_ctrl = NULL; fix_link_sid_ctrl = ldb_request_get_control(ac->req, DSDB_CONTROL_DBCHECK_FIX_LINK_DN_SID); if (fix_link_sid_ctrl == NULL) { ret = samldb_member_check(ac); if (ret != LDB_SUCCESS) { return ret; } } } el = ldb_msg_find_element(ac->msg, "description"); if (el != NULL) { ret = samldb_description_check(ac, &modified); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "dNSHostName"); el2 = ldb_msg_find_element(ac->msg, "sAMAccountName"); if ((el != NULL) || (el2 != NULL)) { modified = true; /* * samldb_service_principal_names_change() might add SPN * changes to the request, so this must come before the SPN * uniqueness check below. * * Note we ALSO have to do the SPN uniqueness check inside * samldb_service_principal_names_change(), because it does a * subrequest to do requested SPN modifications *before* its * automatic ones are added. */ ret = samldb_service_principal_names_change(ac); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "servicePrincipalName"); if ((el != NULL)) { /* * We need to check whether the SPN collides with an existing * one (anywhere) including via aliases. */ modified = true; ret = samldb_spn_uniqueness_check(ac, el); if (ret != LDB_SUCCESS) { return ret; } } el = ldb_msg_find_element(ac->msg, "fSMORoleOwner"); if (el != NULL) { ret = samldb_fsmo_role_owner_check(ac); if (ret != LDB_SUCCESS) { return ret; } } if (modified) { struct ldb_request *child_req; /* Now perform the real modifications as a child request */ ret = ldb_build_mod_req(&child_req, ldb, ac, ac->msg, req->controls, req, dsdb_next_callback, req); LDB_REQ_SET_LOCATION(child_req); if (ret != LDB_SUCCESS) { return ret; } return ldb_next_request(module, child_req); } talloc_free(ac); /* no change which interests us, go on */ return ldb_next_request(module, req); }
0
[ "CWE-200" ]
samba
0a3aa5f908e351201dc9c4d4807b09ed9eedff77
236,413,864,665,631,300,000,000,000,000,000,000,000
291
CVE-2022-32746 ldb: Make use of functions for appending to an ldb_message This aims to minimise usage of the error-prone pattern of searching for a just-added message element in order to make modifications to it (and potentially finding the wrong element). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009 Signed-off-by: Joseph Sutton <[email protected]>
TPM_KEY_BITS_Unmarshal(TPM_KEY_BITS *target, BYTE **buffer, INT32 *size) { TPM_RC rc = TPM_RC_SUCCESS; if (rc == TPM_RC_SUCCESS) { rc = UINT16_Unmarshal(target, buffer, size); } return rc; }
0
[ "CWE-787" ]
libtpms
5cc98a62dc6f204dcf5b87c2ee83ac742a6a319b
322,205,603,506,358,800,000,000,000,000,000,000,000
9
tpm2: Restore original value if unmarshalled value was illegal Restore the original value of the memory location where data from a stream was unmarshalled and the unmarshalled value was found to be illegal. The goal is to not keep illegal values in memory. Signed-off-by: Stefan Berger <[email protected]>
post_chdir(cdscope_T scope) { if (scope != CDSCOPE_WINDOW) // Clear tab local directory for both :cd and :tcd VIM_CLEAR(curtab->tp_localdir); VIM_CLEAR(curwin->w_localdir); if (scope != CDSCOPE_GLOBAL) { char_u *pdir = get_prevdir(scope); // If still in the global directory, need to remember current // directory as the global directory. if (globaldir == NULL && pdir != NULL) globaldir = vim_strsave(pdir); // Remember this local directory for the window. if (mch_dirname(NameBuff, MAXPATHL) == OK) { if (scope == CDSCOPE_TABPAGE) curtab->tp_localdir = vim_strsave(NameBuff); else curwin->w_localdir = vim_strsave(NameBuff); } } else { // We are now in the global directory, no need to remember its name. VIM_CLEAR(globaldir); } shorten_fnames(TRUE); }
0
[ "CWE-122" ]
vim
35a319b77f897744eec1155b736e9372c9c5575f
332,110,341,416,892,670,000,000,000,000,000,000,000
32
patch 8.2.3489: ml_get error after search with range Problem: ml_get error after search with range. Solution: Limit the line number to the buffer line count.
TEST(BasicFlatBufferModel, TestCustomErrorReporter) { TestErrorReporter reporter; auto model = FlatBufferModel::BuildFromFile( "tensorflow/lite/testdata/empty_model.bin", &reporter); ASSERT_TRUE(model); std::unique_ptr<Interpreter> interpreter; TrivialResolver resolver; InterpreterBuilder(*model, resolver)(&interpreter); ASSERT_NE(interpreter->Invoke(), kTfLiteOk); ASSERT_EQ(reporter.num_calls(), 1); }
0
[ "CWE-20", "CWE-787" ]
tensorflow
d58c96946b2880991d63d1dacacb32f0a4dfa453
339,123,789,054,301,000,000,000,000,000,000,000,000
12
[tflite] Ensure inputs and outputs don't overlap. If a model uses the same tensor for both an input and an output then this can result in data loss and memory corruption. This should not happen. PiperOrigin-RevId: 332522916 Change-Id: If0905b142415a9dfceaf2d181872f2a8fb88f48a
default_notify (void *data, p11_index *index, CK_OBJECT_HANDLE handle, CK_ATTRIBUTE *attrs) { }
0
[ "CWE-190" ]
p11-kit
5307a1d21a50cacd06f471a873a018d23ba4b963
7,389,313,955,192,632,000,000,000,000,000,000,000
7
Check for arithmetic overflows before allocating
void LanLinkProvider::newConnection() { qCDebug(KDECONNECT_CORE) << "LanLinkProvider newConnection"; while (m_server->hasPendingConnections()) { QSslSocket* socket = m_server->nextPendingConnection(); configureSocket(socket); //This socket is still managed by us (and child of the QTcpServer), if //it disconnects before we manage to pass it to a LanDeviceLink, it's //our responsibility to delete it. We do so with this connection. connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater); connect(socket, &QIODevice::readyRead, this, &LanLinkProvider::dataReceived); } }
1
[ "CWE-400", "CWE-703" ]
kdeconnect-kde
024e5f23db8d8ad3449714b906b46094baaffb89
182,314,545,391,440,740,000,000,000,000,000,000,000
17
Do not let lanlink connections stay open for long without authenticating If there's no information received, close the socket to try again. Thanks Matthias Gerstner <[email protected]> for reporting this.
next_pwrite (void *nxdata, const void *buf, uint32_t count, uint64_t offset, uint32_t flags, int *err) { struct b_conn *b_conn = nxdata; return b_conn->b->pwrite (b_conn->b, b_conn->conn, buf, count, offset, flags, err); }
0
[ "CWE-406" ]
nbdkit
b2bc6683ea3cd1f6be694e8a681dfa411b7d15f3
297,860,640,463,117,000,000,000,000,000,000,000,000
7
server: Fix regression for NBD_OPT_INFO before NBD_OPT_GO Most known NBD clients do not bother with NBD_OPT_INFO (except for clients like 'qemu-nbd --list' that don't ever intend to connect), but go straight to NBD_OPT_GO. However, it's not too hard to hack up qemu to add in an extra client step (whether info on the same name, or more interestingly, info on a different name), as a patch against qemu commit 6f214b30445: | diff --git i/nbd/client.c w/nbd/client.c | index f6733962b49b..425292ac5ea9 100644 | --- i/nbd/client.c | +++ w/nbd/client.c | @@ -1038,6 +1038,14 @@ int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc, | * TLS). If it is not available, fall back to | * NBD_OPT_LIST for nicer error messages about a missing | * export, then use NBD_OPT_EXPORT_NAME. */ | + if (getenv ("HACK")) | + info->name[0]++; | + result = nbd_opt_info_or_go(ioc, NBD_OPT_INFO, info, errp); | + if (getenv ("HACK")) | + info->name[0]--; | + if (result < 0) { | + return -EINVAL; | + } | result = nbd_opt_info_or_go(ioc, NBD_OPT_GO, info, errp); | if (result < 0) { | return -EINVAL; This works just fine in 1.14.0, where we call .open only once (so the INFO and GO repeat calls into the same plugin handle), but in 1.14.1 it regressed into causing an assertion failure: we are now calling .open a second time on a connection that is already opened: $ nbdkit -rfv null & $ hacked-qemu-io -f raw -r nbd://localhost -c quit ... nbdkit: null[1]: debug: null: open readonly=1 nbdkit: backend.c:179: backend_open: Assertion `h->handle == NULL' failed. Worse, on the mainline development, we have recently made it possible for plugins to actively report different information for different export names; for example, a plugin may choose to report different answers for .can_write on export A than for export B; but if we share cached handles, then an NBD_OPT_INFO on one export prevents correct answers for NBD_OPT_GO on the second export name. (The HACK envvar in my qemu modifications can be used to demonstrate cross-name requests, which are even less likely in a real client). The solution is to call .close after NBD_OPT_INFO, coupled with enough glue logic to reset cached connection handles back to the state expected by .open. This in turn means factoring out another backend_* function, but also gives us an opportunity to change backend_set_handle to no longer accept NULL. The assertion failure is, to some extent, a possible denial of service attack (one client can force nbdkit to exit by merely sending OPT_INFO before OPT_GO, preventing the next client from connecting), although this is mitigated by using TLS to weed out untrusted clients. Still, the fact that we introduced a potential DoS attack while trying to fix a traffic amplification security bug is not very nice. Sadly, as there are no known clients that easily trigger this mode of operation (OPT_INFO before OPT_GO), there is no easy way to cover this via a testsuite addition. I may end up hacking something into libnbd. Fixes: c05686f957 Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit a6b88b195a959b17524d1c8353fd425d4891dc5f) Conflicts: server/backend.c server/connections.c server/filters.c server/internal.h server/plugins.c No backend.c in the stable branch, and less things to reset, so instead ode that logic into filter_close. Signed-off-by: Eric Blake <[email protected]>
void dump_content_length(struct req_state* const s, const uint64_t len) { try { RESTFUL_IO(s)->send_content_length(len); } catch (rgw::io::Exception& e) { ldout(s->cct, 0) << "ERROR: s->cio->send_content_length() returned err=" << e.what() << dendl; } dump_header(s, "Accept-Ranges", "bytes"); }
0
[ "CWE-770" ]
ceph
ab29bed2fc9f961fe895de1086a8208e21ddaddc
275,184,946,085,524,020,000,000,000,000,000,000,000
10
rgw: fix issues with 'enforce bounds' patch The patch to enforce bounds on max-keys/max-uploads/max-parts had a few issues that would prevent us from compiling it. Instead of changing the code provided by the submitter, we're addressing them in a separate commit to maintain the DCO. Signed-off-by: Joao Eduardo Luis <[email protected]> Signed-off-by: Abhishek Lekshmanan <[email protected]> (cherry picked from commit 29bc434a6a81a2e5c5b8cfc4c8d5c82ca5bf538a) mimic specific fixes: As the largeish change from master g_conf() isn't in mimic yet, use the g_conf global structure, also make rgw_op use the value from req_info ceph context as we do for all the requests
static inline void copy_kernel_to_xregs_booting(struct xregs_state *xstate) { u64 mask = -1; u32 lmask = mask; u32 hmask = mask >> 32; int err; WARN_ON(system_state != SYSTEM_BOOTING); if (boot_cpu_has(X86_FEATURE_XSAVES)) XSTATE_OP(XRSTORS, xstate, lmask, hmask, err); else XSTATE_OP(XRSTOR, xstate, lmask, hmask, err); /* * We should never fault when copying from a kernel buffer, and the FPU * state we set at boot time should be valid. */ WARN_ON_FPU(err); }
0
[ "CWE-119", "CWE-732", "CWE-787" ]
linux
59c4bd853abcea95eccc167a7d7fd5f1a5f47b98
325,943,101,602,603,550,000,000,000,000,000,000,000
20
x86/fpu: Don't cache access to fpu_fpregs_owner_ctx The state/owner of the FPU is saved to fpu_fpregs_owner_ctx by pointing to the context that is currently loaded. It never changed during the lifetime of a task - it remained stable/constant. After deferred FPU registers loading until return to userland was implemented, the content of fpu_fpregs_owner_ctx may change during preemption and must not be cached. This went unnoticed for some time and was now noticed, in particular since gcc 9 is caching that load in copy_fpstate_to_sigframe() and reusing it in the retry loop: copy_fpstate_to_sigframe() load fpu_fpregs_owner_ctx and save on stack fpregs_lock() copy_fpregs_to_sigframe() /* failed */ fpregs_unlock() *** PREEMPTION, another uses FPU, changes fpu_fpregs_owner_ctx *** fault_in_pages_writeable() /* succeed, retry */ fpregs_lock() __fpregs_load_activate() fpregs_state_valid() /* uses fpu_fpregs_owner_ctx from stack */ copy_fpregs_to_sigframe() /* succeeds, random FPU content */ This is a comparison of the assembly produced by gcc 9, without vs with this patch: | # arch/x86/kernel/fpu/signal.c:173: if (!access_ok(buf, size)) | cmpq %rdx, %rax # tmp183, _4 | jb .L190 #, |-# arch/x86/include/asm/fpu/internal.h:512: return fpu == this_cpu_read_stable(fpu_fpregs_owner_ctx) && cpu == fpu->last_cpu; |-#APP |-# 512 "arch/x86/include/asm/fpu/internal.h" 1 |- movq %gs:fpu_fpregs_owner_ctx,%rax #, pfo_ret__ |-# 0 "" 2 |-#NO_APP |- movq %rax, -88(%rbp) # pfo_ret__, %sfp … |-# arch/x86/include/asm/fpu/internal.h:512: return fpu == this_cpu_read_stable(fpu_fpregs_owner_ctx) && cpu == fpu->last_cpu; |- movq -88(%rbp), %rcx # %sfp, pfo_ret__ |- cmpq %rcx, -64(%rbp) # pfo_ret__, %sfp |+# arch/x86/include/asm/fpu/internal.h:512: return fpu == this_cpu_read(fpu_fpregs_owner_ctx) && cpu == fpu->last_cpu; |+#APP |+# 512 "arch/x86/include/asm/fpu/internal.h" 1 |+ movq %gs:fpu_fpregs_owner_ctx(%rip),%rax # fpu_fpregs_owner_ctx, pfo_ret__ |+# 0 "" 2 |+# arch/x86/include/asm/fpu/internal.h:512: return fpu == this_cpu_read(fpu_fpregs_owner_ctx) && cpu == fpu->last_cpu; |+#NO_APP |+ cmpq %rax, -64(%rbp) # pfo_ret__, %sfp Use this_cpu_read() instead this_cpu_read_stable() to avoid caching of fpu_fpregs_owner_ctx during preemption points. The Fixes: tag points to the commit where deferred FPU loading was added. Since this commit, the compiler is no longer allowed to move the load of fpu_fpregs_owner_ctx somewhere else / outside of the locked section. A task preemption will change its value and stale content will be observed. [ bp: Massage. ] Debugged-by: Austin Clements <[email protected]> Debugged-by: David Chase <[email protected]> Debugged-by: Ian Lance Taylor <[email protected]> Fixes: 5f409e20b7945 ("x86/fpu: Defer FPU state load until return to userspace") Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Rik van Riel <[email protected]> Tested-by: Borislav Petkov <[email protected]> Cc: Aubrey Li <[email protected]> Cc: Austin Clements <[email protected]> Cc: Barret Rhoden <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Chase <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: Josh Bleecher Snyder <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: https://bugzilla.kernel.org/show_bug.cgi?id=205663
static int php_stream_memory_flush(php_stream *stream TSRMLS_DC) { /* nothing to do here */ return 0; }
0
[ "CWE-20" ]
php-src
6297a117d77fa3a0df2e21ca926a92c231819cd5
271,158,254,477,588,040,000,000,000,000,000,000,000
5
Fixed bug #71323 - Output of stream_get_meta_data can be falsified by its input
vhost_user_unlock_all_queue_pairs(struct virtio_net *dev) { unsigned int i = 0; unsigned int vq_num = 0; while (vq_num < dev->nr_vring) { struct vhost_virtqueue *vq = dev->virtqueue[i]; if (vq) { rte_spinlock_unlock(&vq->access_lock); vq_num++; } i++; } }
0
[]
dpdk
612e17cf6d7b2bf05a687d8a9ba7be582a744e50
246,760,886,677,233,720,000,000,000,000,000,000,000
15
vhost: fix possible denial of service on SET_VRING_NUM vhost_user_set_vring_num() performs multiple allocations without checking whether data were previously allocated. It may cause a denial of service because of the memory leaks that happen if a malicious vhost-user master keeps sending VHOST_USER_SET_VRING_NUM request until the slave runs out of memory. This issue has been assigned CVE-2019-14818 Fixes: b0a985d1f340 ("vhost: add dequeue zero copy") Reported-by: Jason Wang <[email protected]> Signed-off-by: Maxime Coquelin <[email protected]>
void clear_outstanding_pg_stats(){ Mutex::Locker l(pg_stat_queue_lock); outstanding_pg_stats.clear(); }
0
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
73,988,649,289,022,860,000,000,000,000,000,000,000
4
auth/cephx: add authorizer challenge Allow the accepting side of a connection to reject an initial authorizer with a random challenge. The connecting side then has to respond with an updated authorizer proving they are able to decrypt the service's challenge and that the new authorizer was produced for this specific connection instance. The accepting side requires this challenge and response unconditionally if the client side advertises they have the feature bit. Servers wishing to require this improved level of authentication simply have to require the appropriate feature. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b) # Conflicts: # src/auth/Auth.h # src/auth/cephx/CephxProtocol.cc # src/auth/cephx/CephxProtocol.h # src/auth/none/AuthNoneProtocol.h # src/msg/Dispatcher.h # src/msg/async/AsyncConnection.cc - const_iterator - ::decode vs decode - AsyncConnection ctor arg noise - get_random_bytes(), not cct->random()
static void make_tok_num(Token * tok, int64_t val) { char numbuf[32]; snprintf(numbuf, sizeof(numbuf), "%"PRId64"", val); tok->text = nasm_strdup(numbuf); tok->type = TOK_NUMBER; }
0
[ "CWE-125" ]
nasm
3144e84add8b152cc7a71e44617ce6f21daa4ba3
62,876,011,730,427,720,000,000,000,000,000,000,000
7
preproc: Don't access offsting byte on unterminated strings https://bugzilla.nasm.us/show_bug.cgi?id=3392446 Signed-off-by: Cyrill Gorcunov <[email protected]>
CIFSSMBQFSPosixInfo(const int xid, struct cifs_tcon *tcon, struct kstatfs *FSData) { /* level 0x201 SMB_QUERY_CIFS_POSIX_INFO */ TRANSACTION2_QFSI_REQ *pSMB = NULL; TRANSACTION2_QFSI_RSP *pSMBr = NULL; FILE_SYSTEM_POSIX_INFO *response_data; int rc = 0; int bytes_returned = 0; __u16 params, byte_count; cFYI(1, "In QFSPosixInfo"); QFSPosixRetry: rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, (void **) &pSMBr); if (rc) return rc; params = 2; /* level */ pSMB->TotalDataCount = 0; pSMB->DataCount = 0; pSMB->DataOffset = 0; pSMB->MaxParameterCount = cpu_to_le16(2); /* BB find exact max SMB PDU from sess structure BB */ pSMB->MaxDataCount = cpu_to_le16(100); pSMB->MaxSetupCount = 0; pSMB->Reserved = 0; pSMB->Flags = 0; pSMB->Timeout = 0; pSMB->Reserved2 = 0; byte_count = params + 1 /* pad */ ; pSMB->ParameterCount = cpu_to_le16(params); pSMB->TotalParameterCount = pSMB->ParameterCount; pSMB->ParameterOffset = cpu_to_le16(offsetof(struct smb_com_transaction2_qfsi_req, InformationLevel) - 4); pSMB->SetupCount = 1; pSMB->Reserved3 = 0; pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_POSIX_FS_INFO); inc_rfc1001_len(pSMB, byte_count); pSMB->ByteCount = cpu_to_le16(byte_count); rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, (struct smb_hdr *) pSMBr, &bytes_returned, 0); if (rc) { cFYI(1, "Send error in QFSUnixInfo = %d", rc); } else { /* decode response */ rc = validate_t2((struct smb_t2_rsp *)pSMBr); if (rc || get_bcc(&pSMBr->hdr) < 13) { rc = -EIO; /* bad smb */ } else { __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); response_data = (FILE_SYSTEM_POSIX_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); FSData->f_bsize = le32_to_cpu(response_data->BlockSize); FSData->f_blocks = le64_to_cpu(response_data->TotalBlocks); FSData->f_bfree = le64_to_cpu(response_data->BlocksAvail); if (response_data->UserBlocksAvail == cpu_to_le64(-1)) { FSData->f_bavail = FSData->f_bfree; } else { FSData->f_bavail = le64_to_cpu(response_data->UserBlocksAvail); } if (response_data->TotalFileNodes != cpu_to_le64(-1)) FSData->f_files = le64_to_cpu(response_data->TotalFileNodes); if (response_data->FreeFileNodes != cpu_to_le64(-1)) FSData->f_ffree = le64_to_cpu(response_data->FreeFileNodes); } } cifs_buf_release(pSMB); if (rc == -EAGAIN) goto QFSPosixRetry; return rc; }
0
[ "CWE-362", "CWE-119", "CWE-189" ]
linux
9438fabb73eb48055b58b89fc51e0bc4db22fabd
103,137,145,788,649,000,000,000,000,000,000,000,000
84
cifs: fix possible memory corruption in CIFSFindNext The name_len variable in CIFSFindNext is a signed int that gets set to the resume_name_len in the cifs_search_info. The resume_name_len however is unsigned and for some infolevels is populated directly from a 32 bit value sent by the server. If the server sends a very large value for this, then that value could look negative when converted to a signed int. That would make that value pass the PATH_MAX check later in CIFSFindNext. The name_len would then be used as a length value for a memcpy. It would then be treated as unsigned again, and the memcpy scribbles over a ton of memory. Fix this by making the name_len an unsigned value in CIFSFindNext. Cc: <[email protected]> Reported-by: Darren Lavender <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Steve French <[email protected]>
static void v4l_print_streamparm(const void *arg, bool write_only) { const struct v4l2_streamparm *p = arg; pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { const struct v4l2_captureparm *c = &p->parm.capture; pr_cont(", capability=0x%x, capturemode=0x%x, timeperframe=%d/%d, extendedmode=%d, readbuffers=%d\n", c->capability, c->capturemode, c->timeperframe.numerator, c->timeperframe.denominator, c->extendedmode, c->readbuffers); } else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT || p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { const struct v4l2_outputparm *c = &p->parm.output; pr_cont(", capability=0x%x, outputmode=0x%x, timeperframe=%d/%d, extendedmode=%d, writebuffers=%d\n", c->capability, c->outputmode, c->timeperframe.numerator, c->timeperframe.denominator, c->extendedmode, c->writebuffers); } else { pr_cont("\n"); } }
0
[ "CWE-401" ]
linux
fb18802a338b36f675a388fc03d2aa504a0d0899
30,737,637,438,832,693,000,000,000,000,000,000,000
26
media: v4l: ioctl: Fix memory leak in video_usercopy When an IOCTL with argument size larger than 128 that also used array arguments were handled, two memory allocations were made but alas, only the latter one of them was released. This happened because there was only a single local variable to hold such a temporary allocation. Fix this by adding separate variables to hold the pointers to the temporary allocations. Reported-by: Arnd Bergmann <[email protected]> Reported-by: [email protected] Fixes: d14e6d76ebf7 ("[media] v4l: Add multi-planar ioctl handling code") Cc: [email protected] Signed-off-by: Sakari Ailus <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Acked-by: Hans Verkuil <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
void _CbInRangeAav(RCore *core, ut64 from, ut64 to, int vsize, bool asterisk, int count) { bool isarm = archIsArmOrThumb (core); if (isarm) { if (to & 1) { // .dword 0x000080b9 in reality is 0x000080b8 to--; r_anal_hint_set_bits (core->anal, to, 16); // can we assume is gonna be always a function? } else { r_core_seek_archbits (core, from); ut64 bits = r_config_get_i (core->config, "asm.bits"); r_anal_hint_set_bits (core->anal, from, bits); } } else { bool ismips = archIsMips (core); if (ismips) { if (from % 4 || to % 4) { eprintf ("False positive\n"); return; } } } if (asterisk) { r_cons_printf ("ax 0x%"PFMT64x " 0x%"PFMT64x "\n", to, from); r_cons_printf ("Cd %d @ 0x%"PFMT64x "\n", vsize, from); r_cons_printf ("f+ aav.0x%08"PFMT64x "= 0x%08"PFMT64x, to, to); } else { #if 1 r_anal_ref_add (core->anal, to, from, ' '); r_meta_add (core->anal, 'd', from, from + vsize, NULL); if (!r_flag_get_at (core->flags, to, false)) { char *name = r_str_newf ("aav.0x%08"PFMT64x, to); r_flag_set (core->flags, name, to, vsize); free (name); } #else r_core_cmdf (core, "ax 0x%"PFMT64x " 0x%"PFMT64x, to, from); r_core_cmdf (core, "Cd %d @ 0x%"PFMT64x, vsize, from); r_core_cmdf (core, "f+ aav.0x%08"PFMT64x "= 0x%08"PFMT64x, to, to); #endif } }
0
[ "CWE-416", "CWE-908" ]
radare2
9d348bcc2c4bbd3805e7eec97b594be9febbdf9a
6,198,650,719,550,280,000,000,000,000,000,000,000
42
Fix #9943 - Invalid free on RAnal.avr
static connection *connection_init(server *srv) { connection * const con = calloc(1, sizeof(*con)); force_assert(NULL != con); con->fd = 0; con->ndx = -1; con->bytes_written = 0; con->bytes_read = 0; con->dst_addr_buf = buffer_init(); con->srv = srv; con->plugin_slots = srv->plugin_slots; con->config_data_base = srv->config_data_base; request_st * const r = &con->request; request_init_data(r, con, srv); config_reset_config(r); con->write_queue = &r->write_queue; con->read_queue = &r->read_queue; /* init plugin-specific per-connection structures */ con->plugin_ctx = calloc(1, (srv->plugins.used + 1) * sizeof(void *)); force_assert(NULL != con->plugin_ctx); return con; }
0
[ "CWE-703" ]
lighttpd1.4
b03b86f47b0d5a553137f081fadc482b4af1372d
93,079,500,607,159,600,000,000,000,000,000,000,000
26
[core] fix merging large headers across mult reads (fixes #3059) (thx mitd) x-ref: "Connections stuck in Close_Wait causing 100% cpu usage" https://redmine.lighttpd.net/issues/3059
_bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, Buffer buf, OffsetNumber offset, ScanKey itup_scankey, IndexUniqueCheck checkUnique, bool *is_unique) { TupleDesc itupdesc = RelationGetDescr(rel); int natts = rel->rd_rel->relnatts; SnapshotData SnapshotDirty; OffsetNumber maxoff; Page page; BTPageOpaque opaque; Buffer nbuf = InvalidBuffer; bool found = false; /* Assume unique until we find a duplicate */ *is_unique = true; InitDirtySnapshot(SnapshotDirty); page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); maxoff = PageGetMaxOffsetNumber(page); /* * Scan over all equal tuples, looking for live conflicts. */ for (;;) { ItemId curitemid; IndexTuple curitup; BlockNumber nblkno; /* * make sure the offset points to an actual item before trying to * examine it... */ if (offset <= maxoff) { curitemid = PageGetItemId(page, offset); /* * We can skip items that are marked killed. * * Formerly, we applied _bt_isequal() before checking the kill * flag, so as to fall out of the item loop as soon as possible. * However, in the presence of heavy update activity an index may * contain many killed items with the same key; running * _bt_isequal() on each killed item gets expensive. Furthermore * it is likely that the non-killed version of each key appears * first, so that we didn't actually get to exit any sooner * anyway. So now we just advance over killed items as quickly as * we can. We only apply _bt_isequal() when we get to a non-killed * item or the end of the page. */ if (!ItemIdIsDead(curitemid)) { ItemPointerData htid; bool all_dead; /* * _bt_compare returns 0 for (1,NULL) and (1,NULL) - this's * how we handling NULLs - and so we must not use _bt_compare * in real comparison, but only for ordering/finding items on * pages. - vadim 03/24/97 */ if (!_bt_isequal(itupdesc, page, offset, natts, itup_scankey)) break; /* we're past all the equal tuples */ /* okay, we gotta fetch the heap tuple ... */ curitup = (IndexTuple) PageGetItem(page, curitemid); htid = curitup->t_tid; /* * If we are doing a recheck, we expect to find the tuple we * are rechecking. It's not a duplicate, but we have to keep * scanning. */ if (checkUnique == UNIQUE_CHECK_EXISTING && ItemPointerCompare(&htid, &itup->t_tid) == 0) { found = true; } /* * We check the whole HOT-chain to see if there is any tuple * that satisfies SnapshotDirty. This is necessary because we * have just a single index entry for the entire chain. */ else if (heap_hot_search(&htid, heapRel, &SnapshotDirty, &all_dead)) { TransactionId xwait; /* * It is a duplicate. If we are only doing a partial * check, then don't bother checking if the tuple is being * updated in another transaction. Just return the fact * that it is a potential conflict and leave the full * check till later. */ if (checkUnique == UNIQUE_CHECK_PARTIAL) { if (nbuf != InvalidBuffer) _bt_relbuf(rel, nbuf); *is_unique = false; return InvalidTransactionId; } /* * If this tuple is being updated by other transaction * then we have to wait for its commit/abort. */ xwait = (TransactionIdIsValid(SnapshotDirty.xmin)) ? SnapshotDirty.xmin : SnapshotDirty.xmax; if (TransactionIdIsValid(xwait)) { if (nbuf != InvalidBuffer) _bt_relbuf(rel, nbuf); /* Tell _bt_doinsert to wait... */ return xwait; } /* * Otherwise we have a definite conflict. But before * complaining, look to see if the tuple we want to insert * is itself now committed dead --- if so, don't complain. * This is a waste of time in normal scenarios but we must * do it to support CREATE INDEX CONCURRENTLY. * * We must follow HOT-chains here because during * concurrent index build, we insert the root TID though * the actual tuple may be somewhere in the HOT-chain. * While following the chain we might not stop at the * exact tuple which triggered the insert, but that's OK * because if we find a live tuple anywhere in this chain, * we have a unique key conflict. The other live tuple is * not part of this chain because it had a different index * entry. */ htid = itup->t_tid; if (heap_hot_search(&htid, heapRel, SnapshotSelf, NULL)) { /* Normal case --- it's still live */ } else { /* * It's been deleted, so no error, and no need to * continue searching */ break; } /* * This is a definite conflict. Break the tuple down into * datums and report the error. But first, make sure we * release the buffer locks we're holding --- * BuildIndexValueDescription could make catalog accesses, * which in the worst case might touch this same index and * cause deadlocks. */ if (nbuf != InvalidBuffer) _bt_relbuf(rel, nbuf); _bt_relbuf(rel, buf); { Datum values[INDEX_MAX_KEYS]; bool isnull[INDEX_MAX_KEYS]; char *key_desc; index_deform_tuple(itup, RelationGetDescr(rel), values, isnull); key_desc = BuildIndexValueDescription(rel, values, isnull); ereport(ERROR, (errcode(ERRCODE_UNIQUE_VIOLATION), errmsg("duplicate key value violates unique constraint \"%s\"", RelationGetRelationName(rel)), key_desc ? errdetail("Key %s already exists.", key_desc) : 0, errtableconstraint(heapRel, RelationGetRelationName(rel)))); } } else if (all_dead) { /* * The conflicting tuple (or whole HOT chain) is dead to * everyone, so we may as well mark the index entry * killed. */ ItemIdMarkDead(curitemid); opaque->btpo_flags |= BTP_HAS_GARBAGE; /* * Mark buffer with a dirty hint, since state is not * crucial. Be sure to mark the proper buffer dirty. */ if (nbuf != InvalidBuffer) MarkBufferDirtyHint(nbuf, true); else MarkBufferDirtyHint(buf, true); } } } /* * Advance to next tuple to continue checking. */ if (offset < maxoff) offset = OffsetNumberNext(offset); else { /* If scankey == hikey we gotta check the next page too */ if (P_RIGHTMOST(opaque)) break; if (!_bt_isequal(itupdesc, page, P_HIKEY, natts, itup_scankey)) break; /* Advance to next non-dead page --- there must be one */ for (;;) { nblkno = opaque->btpo_next; nbuf = _bt_relandgetbuf(rel, nbuf, nblkno, BT_READ); page = BufferGetPage(nbuf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (!P_IGNORE(opaque)) break; if (P_RIGHTMOST(opaque)) elog(ERROR, "fell off the end of index \"%s\"", RelationGetRelationName(rel)); } maxoff = PageGetMaxOffsetNumber(page); offset = P_FIRSTDATAKEY(opaque); } } /* * If we are doing a recheck then we should have found the tuple we are * checking. Otherwise there's something very wrong --- probably, the * index is on a non-immutable expression. */ if (checkUnique == UNIQUE_CHECK_EXISTING && !found) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to re-find tuple within index \"%s\"", RelationGetRelationName(rel)), errhint("This may be because of a non-immutable index expression."), errtableconstraint(heapRel, RelationGetRelationName(rel)))); if (nbuf != InvalidBuffer) _bt_relbuf(rel, nbuf); return InvalidTransactionId; }
0
[ "CWE-209" ]
postgres
804b6b6db4dcfc590a468e7be390738f9f7755fb
212,655,178,498,619,780,000,000,000,000,000,000,000
258
Fix column-privilege leak in error-message paths While building error messages to return to the user, BuildIndexValueDescription, ExecBuildSlotValueDescription and ri_ReportViolation would happily include the entire key or entire row in the result returned to the user, even if the user didn't have access to view all of the columns being included. Instead, include only those columns which the user is providing or which the user has select rights on. If the user does not have any rights to view the table or any of the columns involved then no detail is provided and a NULL value is returned from BuildIndexValueDescription and ExecBuildSlotValueDescription. Note that, for key cases, the user must have access to all of the columns for the key to be shown; a partial key will not be returned. Further, in master only, do not return any data for cases where row security is enabled on the relation and row security should be applied for the user. This required a bit of refactoring and moving of things around related to RLS- note the addition of utils/misc/rls.c. Back-patch all the way, as column-level privileges are now in all supported versions. This has been assigned CVE-2014-8161, but since the issue and the patch have already been publicized on pgsql-hackers, there's no point in trying to hide this commit.
int samdb_msg_add_uint_flags(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char *attr_name, unsigned int v, int flags) { return samdb_msg_add_int_flags(sam_ldb, mem_ctx, msg, attr_name, (int)v, flags); }
0
[ "CWE-200" ]
samba
0a3aa5f908e351201dc9c4d4807b09ed9eedff77
67,930,533,561,911,110,000,000,000,000,000,000,000
5
CVE-2022-32746 ldb: Make use of functions for appending to an ldb_message This aims to minimise usage of the error-prone pattern of searching for a just-added message element in order to make modifications to it (and potentially finding the wrong element). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009 Signed-off-by: Joseph Sutton <[email protected]>
int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info) { struct btrfs_path *path; struct btrfs_root *root = fs_info->dev_root; struct btrfs_key key; u64 prev_devid = 0; u64 prev_dev_ext_end = 0; int ret = 0; /* * We don't have a dev_root because we mounted with ignorebadroots and * failed to load the root, so we want to skip the verification in this * case for sure. * * However if the dev root is fine, but the tree itself is corrupted * we'd still fail to mount. This verification is only to make sure * writes can happen safely, so instead just bypass this check * completely in the case of IGNOREBADROOTS. */ if (btrfs_test_opt(fs_info, IGNOREBADROOTS)) return 0; key.objectid = 1; key.type = BTRFS_DEV_EXTENT_KEY; key.offset = 0; path = btrfs_alloc_path(); if (!path) return -ENOMEM; path->reada = READA_FORWARD; ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); if (ret < 0) goto out; if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { ret = btrfs_next_leaf(root, path); if (ret < 0) goto out; /* No dev extents at all? Not good */ if (ret > 0) { ret = -EUCLEAN; goto out; } } while (1) { struct extent_buffer *leaf = path->nodes[0]; struct btrfs_dev_extent *dext; int slot = path->slots[0]; u64 chunk_offset; u64 physical_offset; u64 physical_len; u64 devid; btrfs_item_key_to_cpu(leaf, &key, slot); if (key.type != BTRFS_DEV_EXTENT_KEY) break; devid = key.objectid; physical_offset = key.offset; dext = btrfs_item_ptr(leaf, slot, struct btrfs_dev_extent); chunk_offset = btrfs_dev_extent_chunk_offset(leaf, dext); physical_len = btrfs_dev_extent_length(leaf, dext); /* Check if this dev extent overlaps with the previous one */ if (devid == prev_devid && physical_offset < prev_dev_ext_end) { btrfs_err(fs_info, "dev extent devid %llu physical offset %llu overlap with previous dev extent end %llu", devid, physical_offset, prev_dev_ext_end); ret = -EUCLEAN; goto out; } ret = verify_one_dev_extent(fs_info, chunk_offset, devid, physical_offset, physical_len); if (ret < 0) goto out; prev_devid = devid; prev_dev_ext_end = physical_offset + physical_len; ret = btrfs_next_item(root, path); if (ret < 0) goto out; if (ret > 0) { ret = 0; break; } } /* Ensure all chunks have corresponding dev extents */ ret = verify_chunk_dev_extent_mapping(fs_info); out: btrfs_free_path(path); return ret; }
0
[ "CWE-476", "CWE-703" ]
linux
e4571b8c5e9ffa1e85c0c671995bd4dcc5c75091
170,785,440,641,131,660,000,000,000,000,000,000,000
95
btrfs: fix NULL pointer dereference when deleting device by invalid id [BUG] It's easy to trigger NULL pointer dereference, just by removing a non-existing device id: # mkfs.btrfs -f -m single -d single /dev/test/scratch1 \ /dev/test/scratch2 # mount /dev/test/scratch1 /mnt/btrfs # btrfs device remove 3 /mnt/btrfs Then we have the following kernel NULL pointer dereference: BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 9 PID: 649 Comm: btrfs Not tainted 5.14.0-rc3-custom+ #35 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:btrfs_rm_device+0x4de/0x6b0 [btrfs] btrfs_ioctl+0x18bb/0x3190 [btrfs] ? lock_is_held_type+0xa5/0x120 ? find_held_lock.constprop.0+0x2b/0x80 ? do_user_addr_fault+0x201/0x6a0 ? lock_release+0xd2/0x2d0 ? __x64_sys_ioctl+0x83/0xb0 __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae [CAUSE] Commit a27a94c2b0c7 ("btrfs: Make btrfs_find_device_by_devspec return btrfs_device directly") moves the "missing" device path check into btrfs_rm_device(). But btrfs_rm_device() itself can have case where it only receives @devid, with NULL as @device_path. In that case, calling strcmp() on NULL will trigger the NULL pointer dereference. Before that commit, we handle the "missing" case inside btrfs_find_device_by_devspec(), which will not check @device_path at all if @devid is provided, thus no way to trigger the bug. [FIX] Before calling strcmp(), also make sure @device_path is not NULL. Fixes: a27a94c2b0c7 ("btrfs: Make btrfs_find_device_by_devspec return btrfs_device directly") CC: [email protected] # 5.4+ Reported-by: butt3rflyh4ck <[email protected]> Reviewed-by: Anand Jain <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
ossl_cipher_set_key(VALUE self, VALUE key) { EVP_CIPHER_CTX *ctx; StringValue(key); GetCipher(self, ctx); if (RSTRING_LEN(key) < EVP_CIPHER_CTX_key_length(ctx)) ossl_raise(eCipherError, "key length too short"); if (EVP_CipherInit_ex(ctx, NULL, NULL, (unsigned char *)RSTRING_PTR(key), NULL, -1) != 1) ossl_raise(eCipherError, NULL); return key; }
1
[ "CWE-326" ]
ruby
739782e37a6662fea379e7ef3ec89e851b04b46c
123,942,368,751,913,560,000,000,000,000,000,000,000
15
* ext/openssl/ossl_cipher.c: remove the encryption key initialization from Cipher#initialize. This is effectively a revert of r32723 ("Avoid possible SEGV from AES encryption/decryption", 2011-07-28). the patch is derived from https://github.com/ruby/openssl/commit/8108e0a6db133f3375608303fdd2083eb5115062, written by Kazuki Yamaguchi. [Backport #8221] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
void CLASS parse_riff() { unsigned i, size, end; char tag[4], date[64], month[64]; static const char mon[12][4] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; struct tm t; order = 0x4949; fread (tag, 4, 1, ifp); size = get4(); end = ftell(ifp) + size; if (!memcmp(tag,"RIFF",4) || !memcmp(tag,"LIST",4)) { int maxloop = 1000; get4(); while (ftell(ifp)+7 < end && !feof(ifp) && maxloop--) parse_riff(); } else if (!memcmp(tag,"nctg",4)) { while (ftell(ifp)+7 < end) { i = get2(); size = get2(); if ((i+1) >> 1 == 10 && size == 20) get_timestamp(0); else fseek (ifp, size, SEEK_CUR); } } else if (!memcmp(tag,"IDIT",4) && size < 64) { fread (date, 64, 1, ifp); date[size] = 0; memset (&t, 0, sizeof t); if (sscanf (date, "%*s %s %d %d:%d:%d %d", month, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec, &t.tm_year) == 6) { for (i=0; i < 12 && strcasecmp(mon[i],month); i++); t.tm_mon = i; t.tm_year -= 1900; if (mktime(&t) > 0) timestamp = mktime(&t); } } else fseek (ifp, size, SEEK_CUR); }
0
[ "CWE-129" ]
LibRaw
89d065424f09b788f443734d44857289489ca9e2
264,440,317,591,835,900,000,000,000,000,000,000,000
40
fixed two more problems found by fuzzer
MagickExport int LocaleUppercase(const int c) { #if defined(MAGICKCORE_LOCALE_SUPPORT) if (c_locale != (locale_t) NULL) return(toupper_l(c,c_locale)); #endif return(toupper(c)); }
1
[ "CWE-125" ]
ImageMagick
07eebcd72f45c8fd7563d3f9ec5d2bed48f65f36
223,511,465,968,931,300,000,000,000,000,000,000,000
8
...
hivex_node_children (hive_h *h, hive_node_h node) { hive_node_h *children; size_t *blocks; if (_hivex_get_children (h, node, &children, &blocks, 0) == -1) return NULL; free (blocks); return children; }
0
[ "CWE-400" ]
hivex
771728218dac2fbf6997a7e53225e75a4c6b7255
89,476,299,865,568,980,000,000,000,000,000,000,000
11
lib/node.c: Limit recursion in ri-records (CVE-2021-3622) Windows Registry hive "ri"-records are arbitrarily nested B-tree-like structures: +-------------+ | ri | |-------------| | nr_offsets | | offset[0] ------> points to another lf/lh/li/ri block | offset[1] ------> | offset[2] ------> +-------------+ It is possible to construct a hive with a very deeply nested tree of ri-records, causing the internal _get_children function to recurse to any depth which can cause programs linked to hivex to crash with a stack overflow. Since it is not thought that deeply nested ri-records occur in real hives, limit recursion depth. If you hit this limit you will see the following error and the operation will return an error instead of crashing: \> ls hivex: _get_children: returning EINVAL because: ri-record nested to depth >= 32 ls: Invalid argument Thanks to Jeremy Galindo for finding and reporting this bug. Reported-by: Jeremy Galindo, Sr Security Engineer, Datto.com Signed-off-by: Richard W.M. Jones <[email protected]> Fixes: CVE-2021-3622 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1975489 (cherry picked from commit 781a12c4a49dd81365c9c567c5aa5e19e894ba0e)
static int __get_parent_info_legacy(struct rbd_device *rbd_dev, struct page *req_page, struct page *reply_page, struct parent_image_info *pii) { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; size_t reply_len = PAGE_SIZE; void *p, *end; int ret; ret = ceph_osdc_call(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc, "rbd", "get_parent", CEPH_OSD_FLAG_READ, req_page, sizeof(u64), &reply_page, &reply_len); if (ret) return ret; p = page_address(reply_page); end = p + reply_len; ceph_decode_64_safe(&p, end, pii->pool_id, e_inval); pii->image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL); if (IS_ERR(pii->image_id)) { ret = PTR_ERR(pii->image_id); pii->image_id = NULL; return ret; } ceph_decode_64_safe(&p, end, pii->snap_id, e_inval); pii->has_overlap = true; ceph_decode_64_safe(&p, end, pii->overlap, e_inval); return 0; e_inval: return -EINVAL; }
0
[ "CWE-863" ]
linux
f44d04e696feaf13d192d942c4f14ad2e117065a
301,716,555,103,306,320,000,000,000,000,000,000,000
34
rbd: require global CAP_SYS_ADMIN for mapping and unmapping It turns out that currently we rely only on sysfs attribute permissions: $ ll /sys/bus/rbd/{add*,remove*} --w------- 1 root root 4096 Sep 3 20:37 /sys/bus/rbd/add --w------- 1 root root 4096 Sep 3 20:37 /sys/bus/rbd/add_single_major --w------- 1 root root 4096 Sep 3 20:37 /sys/bus/rbd/remove --w------- 1 root root 4096 Sep 3 20:38 /sys/bus/rbd/remove_single_major This means that images can be mapped and unmapped (i.e. block devices can be created and deleted) by a UID 0 process even after it drops all privileges or by any process with CAP_DAC_OVERRIDE in its user namespace as long as UID 0 is mapped into that user namespace. Be consistent with other virtual block devices (loop, nbd, dm, md, etc) and require CAP_SYS_ADMIN in the initial user namespace for mapping and unmapping, and also for dumping the configuration string and refreshing the image header. Cc: [email protected] Signed-off-by: Ilya Dryomov <[email protected]> Reviewed-by: Jeff Layton <[email protected]>
template<typename t> bool operator!=(const CImg<t>& img) const { return !((*this)==img);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
233,690,966,556,901,520,000,000,000,000,000,000,000
3
Fix other issues in 'CImg<T>::load_bmp()'.
int TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response) { PKCS7 *token = TS_RESP_get_token(response); TS_TST_INFO *tst_info = TS_RESP_get_tst_info(response); int ret = 0; /* Check if we have a successful TS_TST_INFO object in place. */ if (!TS_check_status_info(response)) goto err; /* Check the contents of the time stamp token. */ if (!_TS_RESP_verify_token(ctx, token, tst_info)) goto err; ret = 1; err: return ret; }
0
[]
openssl
c7235be6e36c4bef84594aa3b2f0561db84b63d8
86,356,695,412,679,490,000,000,000,000,000,000,000
17
RFC 3161 compliant time stamp request creation, response generation and response verification. Submitted by: Zoltan Glozik <[email protected]> Reviewed by: Ulf Moeller
static void __sk_free(struct sock *sk) { struct sk_filter *filter; if (sk->sk_destruct) sk->sk_destruct(sk); filter = rcu_dereference_check(sk->sk_filter, atomic_read(&sk->sk_wmem_alloc) == 0); if (filter) { sk_filter_uncharge(sk, filter); RCU_INIT_POINTER(sk->sk_filter, NULL); } sock_disable_timestamp(sk, SK_FLAGS_TIMESTAMP); if (atomic_read(&sk->sk_omem_alloc)) pr_debug("%s: optmem leakage (%d bytes) detected\n", __func__, atomic_read(&sk->sk_omem_alloc)); if (sk->sk_peer_cred) put_cred(sk->sk_peer_cred); put_pid(sk->sk_peer_pid); put_net(sock_net(sk)); sk_prot_free(sk->sk_prot_creator, sk); }
0
[]
linux
7bced397510ab569d31de4c70b39e13355046387
145,666,446,146,338,300,000,000,000,000,000,000,000
26
net_dma: simple removal Per commit "77873803363c net_dma: mark broken" net_dma is no longer used and there is no plan to fix it. This is the mechanical removal of bits in CONFIG_NET_DMA ifdef guards. Reverting the remainder of the net_dma induced changes is deferred to subsequent patches. Marked for stable due to Roman's report of a memory leak in dma_pin_iovec_pages(): https://lkml.org/lkml/2014/9/3/177 Cc: Dave Jiang <[email protected]> Cc: Vinod Koul <[email protected]> Cc: David Whipple <[email protected]> Cc: Alexander Duyck <[email protected]> Cc: <[email protected]> Reported-by: Roman Gushchin <[email protected]> Acked-by: David S. Miller <[email protected]> Signed-off-by: Dan Williams <[email protected]>
asn1_decode_simple_der (unsigned int etype, const unsigned char *der, unsigned int der_len, const unsigned char **str, unsigned int *str_len) { int tag_len, len_len; const unsigned char *p; unsigned char class; unsigned long tag; long ret; if (der == NULL || der_len == 0) return ASN1_VALUE_NOT_VALID; if (ETYPE_OK (etype) == 0) return ASN1_VALUE_NOT_VALID; /* doesn't handle constructed classes */ if (ETYPE_CLASS (etype) != ASN1_CLASS_UNIVERSAL) return ASN1_VALUE_NOT_VALID; p = der; ret = asn1_get_tag_der (p, der_len, &class, &tag_len, &tag); if (ret != ASN1_SUCCESS) return ret; if (class != ETYPE_CLASS (etype) || tag != ETYPE_TAG (etype)) return ASN1_DER_ERROR; p += tag_len; der_len -= tag_len; ret = asn1_get_length_der (p, der_len, &len_len); if (ret < 0) return ASN1_DER_ERROR; p += len_len; der_len -= len_len; *str_len = ret; *str = p; return ASN1_SUCCESS; }
0
[]
libtasn1
ff3b5c68cc32e30d19edbbc3a962b2266029f3cc
165,166,855,775,606,620,000,000,000,000,000,000,000
43
Corrected an off-by-one error. The issue was discovered using the codenomicon TLS suite.
static void ip6gre_tunnel_setup(struct net_device *dev) { dev->netdev_ops = &ip6gre_netdev_ops; dev->destructor = ip6gre_dev_free; dev->type = ARPHRD_IP6GRE; dev->flags |= IFF_NOARP; dev->addr_len = sizeof(struct in6_addr); netif_keep_dst(dev); }
0
[ "CWE-125" ]
net
7892032cfe67f4bde6fc2ee967e45a8fbaf33756
293,197,638,136,939,350,000,000,000,000,000,000,000
11
ip6_gre: fix ip6gre_err() invalid reads Andrey Konovalov reported out of bound accesses in ip6gre_err() If GRE flags contains GRE_KEY, the following expression *(((__be32 *)p) + (grehlen / 4) - 1) accesses data ~40 bytes after the expected point, since grehlen includes the size of IPv6 headers. Let's use a "struct gre_base_hdr *greh" pointer to make this code more readable. p[1] becomes greh->protocol. grhlen is the GRE header length. Fixes: c12b395a4664 ("gre: Support GRE over IPv6") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Andrey Konovalov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
gst_rtsp_connection_send (GstRTSPConnection * conn, GstRTSPMessage * message, GTimeVal * timeout) { g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL); g_return_val_if_fail (message != NULL, GST_RTSP_EINVAL); return gst_rtsp_connection_send_messages (conn, message, 1, timeout); }
0
[]
gst-plugins-base
f672277509705c4034bc92a141eefee4524d15aa
320,915,645,105,596,950,000,000,000,000,000,000,000
8
gstrtspconnection: Security loophole making heap overflow The former code allowed an attacker to create a heap overflow by sending a longer than allowed session id in a response and including a semicolon to change the maximum length. With this change, the parser will never go beyond 512 bytes.
OPJ_FLOAT64 opj_clock(void) { #ifdef _WIN32 /* _WIN32: use QueryPerformance (very accurate) */ LARGE_INTEGER freq, t ; /* freq is the clock speed of the CPU */ QueryPerformanceFrequency(&freq) ; /* cout << "freq = " << ((double) freq.QuadPart) << endl; */ /* t is the high resolution performance counter (see MSDN) */ QueryPerformanceCounter(& t) ; return freq.QuadPart ? ((OPJ_FLOAT64)t.QuadPart / (OPJ_FLOAT64)freq.QuadPart) : 0; #elif defined(__linux) struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); return ((OPJ_FLOAT64)ts.tv_sec + (OPJ_FLOAT64)ts.tv_nsec * 1e-9); #else /* Unix : use resource usage */ /* FIXME: this counts the total CPU time, instead of the user perceived time */ struct rusage t; OPJ_FLOAT64 procTime; /* (1) Get the rusage data structure at this moment (man getrusage) */ getrusage(0, &t); /* (2) What is the elapsed time ? - CPU time = User time + System time */ /* (2a) Get the seconds */ procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec); /* (2b) More precisely! Get the microseconds part ! */ return (procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6) ; #endif }
0
[ "CWE-824" ]
openjpeg
0afbdcf3e6d0d2bd2e16a0c4d513ee3cf86e460d
131,896,007,925,921,000,000,000,000,000,000,000,000
31
Fix segfault in src/bin/jp2/opj_decompress.c due to uninitialized pointer (fixes #1368) (#1369)
pb_istream_t pb_istream_from_buffer(uint8_t *buf, size_t bufsize) { pb_istream_t stream; #ifdef PB_BUFFER_ONLY stream.callback = NULL; #else stream.callback = &buf_read; #endif stream.state = buf; stream.bytes_left = bufsize; #ifndef PB_NO_ERRMSG stream.errmsg = NULL; #endif return stream; }
0
[ "CWE-125" ]
nanopb
7b396821ddd06df8e39143f16e1dc0a4645b89a3
17,703,642,829,184,459,000,000,000,000,000,000,000
15
Fix invalid free() after failed realloc() (GHSA-gcx3-7m76-287p)
void CSnapIDPool::FreeID(int ID) { if(ID < 0) return; dbg_assert(m_aIDs[ID].m_State == 1, "id is not allocated"); m_InUsage--; m_aIDs[ID].m_State = 2; m_aIDs[ID].m_Timeout = time_get()+time_freq()*5; m_aIDs[ID].m_Next = -1; if(m_LastTimed != -1) { m_aIDs[m_LastTimed].m_Next = ID; m_LastTimed = ID; } else { m_FirstTimed = ID; m_LastTimed = ID; } }
0
[ "CWE-20", "CWE-703", "CWE-400" ]
teeworlds
c68402fa7e279d42886d5951d1ea8ac2facc1ea5
262,130,226,769,101,400,000,000,000,000,000,000,000
22
changed a check
static void vnc_dpy_resize(DisplayState *ds) { VncDisplay *vd = ds->opaque; VncState *vs; vnc_abort_display_jobs(vd); /* server surface */ qemu_pixman_image_unref(vd->server); vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT, ds_get_width(ds), ds_get_height(ds), NULL, 0); /* guest surface */ #if 0 /* FIXME */ if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel) console_color_init(ds); #endif qemu_pixman_image_unref(vd->guest.fb); vd->guest.fb = pixman_image_ref(ds->surface->image); vd->guest.format = ds->surface->format; memset(vd->guest.dirty, 0xFF, sizeof(vd->guest.dirty)); QTAILQ_FOREACH(vs, &vd->clients, next) { vnc_colordepth(vs); vnc_desktop_resize(vs); if (vs->vd->cursor) { vnc_cursor_define(vs); } memset(vs->dirty, 0xFF, sizeof(vs->dirty)); } }
0
[ "CWE-125" ]
qemu
9f64916da20eea67121d544698676295bbb105a7
365,926,215,381,055,400,000,000,000,000,000,000
33
pixman/vnc: use pixman images in vnc. The vnc code uses *three* DisplaySurfaces: First is the surface of the actual QemuConsole, usually the guest screen, but could also be a text console (monitor/serial reachable via Ctrl-Alt-<nr> keys). This is left as-is. Second is the current server's view of the screen content. The vnc code uses this to figure which parts of the guest screen did _really_ change to reduce the amount of updates sent to the vnc clients. It is also used as data source when sending out the updates to the clients. This surface gets replaced by a pixman image. The format changes too, instead of using the guest screen format we'll use fixed 32bit rgb framebuffer and convert the pixels on the fly when comparing and updating the server framebuffer. Third surface carries the format expected by the vnc client. That isn't used to store image data. This surface is switched to PixelFormat and a boolean for bigendian byte order. Signed-off-by: Gerd Hoffmann <[email protected]>
static void raw_cmd_done(int flag) { if (!flag) { raw_cmd->flags |= FD_RAW_FAILURE; raw_cmd->flags |= FD_RAW_HARDFAILURE; } else { raw_cmd->reply_count = inr; if (raw_cmd->reply_count > FD_RAW_REPLY_SIZE) raw_cmd->reply_count = 0; memcpy(raw_cmd->reply, reply_buffer, raw_cmd->reply_count); if (raw_cmd->flags & (FD_RAW_READ | FD_RAW_WRITE)) { unsigned long flags; flags = claim_dma_lock(); raw_cmd->length = fd_get_dma_residue(); release_dma_lock(flags); } if ((raw_cmd->flags & FD_RAW_SOFTFAILURE) && (!raw_cmd->reply_count || (raw_cmd->reply[0] & 0xc0))) raw_cmd->flags |= FD_RAW_FAILURE; if (disk_change(current_drive)) raw_cmd->flags |= FD_RAW_DISK_CHANGE; else raw_cmd->flags &= ~FD_RAW_DISK_CHANGE; if (raw_cmd->flags & FD_RAW_NO_MOTOR_AFTER) motor_off_callback(&motor_off_timer[current_drive]); if (raw_cmd->next && (!(raw_cmd->flags & FD_RAW_FAILURE) || !(raw_cmd->flags & FD_RAW_STOP_IF_FAILURE)) && ((raw_cmd->flags & FD_RAW_FAILURE) || !(raw_cmd->flags & FD_RAW_STOP_IF_SUCCESS))) { raw_cmd = raw_cmd->next; return; } } generic_done(flag); }
0
[ "CWE-416" ]
linux
233087ca063686964a53c829d547c7571e3f67bf
188,818,972,830,443,920,000,000,000,000,000,000,000
40
floppy: disable FDRAWCMD by default Minh Yuan reported a concurrency use-after-free issue in the floppy code between raw_cmd_ioctl and seek_interrupt. [ It turns out this has been around, and that others have reported the KASAN splats over the years, but Minh Yuan had a reproducer for it and so gets primary credit for reporting it for this fix - Linus ] The problem is, this driver tends to break very easily and nowadays, nobody is expected to use FDRAWCMD anyway since it was used to manipulate non-standard formats. The risk of breaking the driver is higher than the risk presented by this race, and accessing the device requires privileges anyway. Let's just add a config option to completely disable this ioctl and leave it disabled by default. Distros shouldn't use it, and only those running on antique hardware might need to enable it. Link: https://lore.kernel.org/all/[email protected]/ Link: https://lore.kernel.org/lkml/CAKcFiNC=MfYVW-Jt9A3=FPJpTwCD2PL_ULNCpsCVE5s8ZeBQgQ@mail.gmail.com Link: https://lore.kernel.org/all/CAEAjamu1FRhz6StCe_55XY5s389ZP_xmCF69k987En+1z53=eg@mail.gmail.com Reported-by: Minh Yuan <[email protected]> Reported-by: [email protected] Reported-by: cruise k <[email protected]> Reported-by: Kyungtae Kim <[email protected]> Suggested-by: Linus Torvalds <[email protected]> Tested-by: Denis Efremov <[email protected]> Signed-off-by: Willy Tarreau <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
void test_nghttp2_session_recv_data_no_auto_flow_control(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; my_user_data ud; nghttp2_option *option; nghttp2_frame_hd hd; size_t padlen; uint8_t data[8192]; ssize_t rv; size_t sendlen; nghttp2_stream *stream; size_t i; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.send_callback = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; nghttp2_option_new(&option); nghttp2_option_set_no_auto_window_update(option, 1); nghttp2_session_server_new2(&session, &callbacks, &ud, option); /* Create DATA frame with length 4KiB + 11 bytes padding*/ padlen = 11; memset(data, 0, sizeof(data)); hd.length = 4096 + 1 + padlen; hd.type = NGHTTP2_DATA; hd.flags = NGHTTP2_FLAG_PADDED; hd.stream_id = 1; nghttp2_frame_pack_frame_hd(data, &hd); data[NGHTTP2_FRAME_HDLEN] = (uint8_t)padlen; /* First create stream 1, then close it. Check that data is consumed for connection in this situation */ open_recv_stream(session, 1); /* Receive first 100 bytes */ sendlen = 100; rv = nghttp2_session_mem_recv(session, data, sendlen); CU_ASSERT((ssize_t)sendlen == rv); /* We consumed pad length field (1 byte) */ CU_ASSERT(1 == session->consumed_size); /* close stream here */ nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 1, NGHTTP2_NO_ERROR); nghttp2_session_send(session); /* stream 1 has been closed, and we disabled auto flow-control, so data must be immediately consumed for connection. */ rv = nghttp2_session_mem_recv(session, data + sendlen, NGHTTP2_FRAME_HDLEN + hd.length - sendlen); CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + hd.length - sendlen) == rv); /* We already consumed pad length field (1 byte), so do +1 here */ CU_ASSERT((int32_t)(NGHTTP2_FRAME_HDLEN + hd.length - sendlen + 1) == session->consumed_size); nghttp2_session_del(session); /* Reuse DATA created previously. */ nghttp2_session_server_new2(&session, &callbacks, &ud, option); /* Now we are expecting final response header, which means receiving DATA for that stream is illegal. */ stream = open_recv_stream(session, 1); stream->http_flags |= NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE; rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + hd.length); CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + hd.length) == rv); /* Whole payload must be consumed now because HTTP messaging rule was not honored. */ CU_ASSERT((int32_t)hd.length == session->consumed_size); nghttp2_session_del(session); /* Check window_update_queued flag in both session and stream */ nghttp2_session_server_new2(&session, &callbacks, &ud, option); stream = open_recv_stream(session, 1); hd.length = 4096; hd.type = NGHTTP2_DATA; hd.flags = NGHTTP2_FLAG_NONE; hd.stream_id = 1; nghttp2_frame_pack_frame_hd(data, &hd); /* Receive up to 65535 bytes of DATA */ for (i = 0; i < 15; ++i) { rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); } hd.length = 4095; nghttp2_frame_pack_frame_hd(data, &hd); rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4095); CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4095 == rv); CU_ASSERT(65535 == session->recv_window_size); CU_ASSERT(65535 == stream->recv_window_size); /* The first call of nghttp2_session_consume_connection() will queue WINDOW_UPDATE. Next call does not. */ nghttp2_session_consume_connection(session, 32767); nghttp2_session_consume_connection(session, 32768); CU_ASSERT(32768 == session->recv_window_size); CU_ASSERT(65535 == stream->recv_window_size); CU_ASSERT(1 == session->window_update_queued); CU_ASSERT(0 == stream->window_update_queued); ud.frame_send_cb_called = 0; /* This will send WINDOW_UPDATE, and check whether we should send WINDOW_UPDATE, and queue and send it at once. */ CU_ASSERT(0 == nghttp2_session_send(session)); CU_ASSERT(0 == session->recv_window_size); CU_ASSERT(65535 == stream->recv_window_size); CU_ASSERT(0 == session->window_update_queued); CU_ASSERT(0 == stream->window_update_queued); CU_ASSERT(2 == ud.frame_send_cb_called); /* Do the same for stream */ nghttp2_session_consume_stream(session, 1, 32767); nghttp2_session_consume_stream(session, 1, 32768); CU_ASSERT(0 == session->recv_window_size); CU_ASSERT(32768 == stream->recv_window_size); CU_ASSERT(0 == session->window_update_queued); CU_ASSERT(1 == stream->window_update_queued); ud.frame_send_cb_called = 0; CU_ASSERT(0 == nghttp2_session_send(session)); CU_ASSERT(0 == session->recv_window_size); CU_ASSERT(0 == stream->recv_window_size); CU_ASSERT(0 == session->window_update_queued); CU_ASSERT(0 == stream->window_update_queued); CU_ASSERT(2 == ud.frame_send_cb_called); nghttp2_session_del(session); nghttp2_option_del(option); }
0
[]
nghttp2
0a6ce87c22c69438ecbffe52a2859c3a32f1620f
132,557,000,905,545,320,000,000,000,000,000,000,000
146
Add nghttp2_option_set_max_outbound_ack
static int run_event_gtk_ask_yes_no_yesforever(const char *key, const char *msg, void *args) { const int ret = run_ask_yes_no_yesforever_dialog(key, msg, GTK_WINDOW(g_wnd_assistant)); log_request_response_communication(msg, ret ? "YES" : "NO", (struct analyze_event_data *)args); return ret; }
0
[ "CWE-200" ]
libreport
257578a23d1537a2d235aaa2b1488ee4f818e360
294,576,839,391,886,770,000,000,000,000,000,000,000
6
wizard: fix save users changes after reviewing dump dir files If the user reviewed the dump dir's files during reporting the crash, the changes was thrown away and original data was passed to the bugzilla bug report. report-gtk saves the first text view buffer and then reloads data from the reported problem directory, which causes that the changes made to those text views are thrown away. Function save_text_if_changed(), except of saving text, also reload the files from dump dir and update gui state from the dump dir. The commit moves the reloading and updating gui functions away from this function. Related to rhbz#1270235 Signed-off-by: Matej Habrnal <[email protected]>
virtual GBool useShadedFills(int type) { return gFalse; }
0
[]
poppler
abf167af8b15e5f3b510275ce619e6fdb42edd40
6,172,423,609,459,824,000,000,000,000,000,000,000
1
Implement tiling/patterns in SplashOutputDev Fixes bug 13518
exif_mnote_data_pentax_identify (const ExifData *ed, const ExifEntry *e) { (void) ed; /* unused */ if ((e->size >= 8) && !memcmp (e->data, "AOC", 4)) { if (((e->data[4] == 'I') && (e->data[5] == 'I')) || ((e->data[4] == 'M') && (e->data[5] == 'M'))) return pentaxV3; else /* Uses Casio v2 tags */ return pentaxV2; } if ((e->size >= 8) && !memcmp (e->data, "QVC", 4)) return casioV2; /* This isn't a very robust test, so make sure it's done last */ /* Maybe we should additionally check for a make of Asahi or Pentax */ if ((e->size >= 2) && (e->data[0] == 0x00) && (e->data[1] == 0x1b)) return pentaxV1; return 0; }
0
[ "CWE-125" ]
libexif
435e21f05001fb03f9f186fa7cbc69454afd00d1
205,855,923,951,937,740,000,000,000,000,000,000,000
22
Fix MakerNote tag size overflow issues at read time. Check for a size overflow while reading tags, which ensures that the size is always consistent for the given components and type of the entry, making checking further down superfluous. This provides an alternate fix for https://sourceforge.net/p/libexif/bugs/125/ CVE-2016-6328 and for all the MakerNote types. Likely, this makes both commits 41bd0423 and 89e5b1c1 redundant as it ensures that MakerNote entries are well-formed when they're populated. Some improvements on top by Marcus Meissner <[email protected]> CVE-2020-13112
remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base) { if (hrtimer_is_queued(timer)) { int reprogram; /* * Remove the timer and force reprogramming when high * resolution mode is active and the timer is on the current * CPU. If we remove a timer on another CPU, reprogramming is * skipped. The interrupt event on this CPU is fired and * reprogramming happens in the interrupt handler. This is a * rare case and less expensive than a smp call. */ timer_stats_hrtimer_clear_start_info(timer); reprogram = base->cpu_base == &__get_cpu_var(hrtimer_bases); __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, reprogram); return 1; } return 0; }
0
[ "CWE-189" ]
linux-2.6
13788ccc41ceea5893f9c747c59bc0b28f2416c2
315,817,146,536,492,820,000,000,000,000,000,000,000
21
[PATCH] hrtimer: prevent overrun DoS in hrtimer_forward() hrtimer_forward() does not check for the possible overflow of timer->expires. This can happen on 64 bit machines with large interval values and results currently in an endless loop in the softirq because the expiry value becomes negative and therefor the timer is expired all the time. Check for this condition and set the expiry value to the max. expiry time in the future. The fix should be applied to stable kernel series as well. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Ingo Molnar <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
void Field_newdate::store_TIME(MYSQL_TIME *ltime) { uint tmp= ltime->year*16*32 + ltime->month*32+ltime->day; int3store(ptr,tmp); }
0
[ "CWE-416", "CWE-703" ]
server
08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917
197,073,623,011,072,770,000,000,000,000,000,000,000
5
MDEV-24176 Server crashes after insert in the table with virtual column generated using date_format() and if() vcol_info->expr is allocated on expr_arena at parsing stage. Since expr item is allocated on expr_arena all its containee items must be allocated on expr_arena too. Otherwise fix_session_expr() will encounter prematurely freed item. When table is reopened from cache vcol_info contains stale expression. We refresh expression via TABLE::vcol_fix_exprs() but first we must prepare a proper context (Vcol_expr_context) which meets some requirements: 1. As noted above expr update must be done on expr_arena as there may be new items created. It was a bug in fix_session_expr_for_read() and was just not reproduced because of no second refix. Now refix is done for more cases so it does reproduce. Tests affected: vcol.binlog 2. Also name resolution context must be narrowed to the single table. Tested by: vcol.update main.default vcol.vcol_syntax gcol.gcol_bugfixes 3. sql_mode must be clean and not fail expr update. sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc must not affect vcol expression update. If the table was created successfully any further evaluation must not fail. Tests affected: main.func_like Reviewed by: Sergei Golubchik <[email protected]>
static int rtw_wx_set_frag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct adapter *padapter = rtw_netdev_priv(dev); if (wrqu->frag.disabled) { padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; } else { if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1; } DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); return 0; }
0
[ "CWE-787" ]
linux
74b6b20df8cfe90ada777d621b54c32e69e27cd7
166,839,098,180,016,020,000,000,000,000,000,000,000
20
staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan() This code has a check to prevent read overflow but it needs another check to prevent writing beyond the end of the ->ssid[] array. Fixes: a2c60d42d97c ("staging: r8188eu: Add files for new driver - part 16") Signed-off-by: Dan Carpenter <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/YEHymwsnHewzoam7@mwanda Signed-off-by: Greg Kroah-Hartman <[email protected]>
static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id) { unsigned int connect_mask = HID_CONNECT_DEFAULT; struct lg_drv_data *drv_data; int ret; drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL); if (!drv_data) { hid_err(hdev, "Insufficient memory, cannot allocate driver data\n"); return -ENOMEM; } drv_data->quirks = id->driver_data; hid_set_drvdata(hdev, (void *)drv_data); if (drv_data->quirks & LG_NOGET) hdev->quirks |= HID_QUIRK_NOGET; ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); goto err_free; } if (drv_data->quirks & (LG_FF | LG_FF2 | LG_FF3 | LG_FF4)) connect_mask &= ~HID_CONNECT_FF; ret = hid_hw_start(hdev, connect_mask); if (ret) { hid_err(hdev, "hw start failed\n"); goto err_free; } /* Setup wireless link with Logitech Wii wheel */ if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) { unsigned char buf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); if (ret >= 0) { /* insert a little delay of 10 jiffies ~ 40ms */ wait_queue_head_t wait; init_waitqueue_head (&wait); wait_event_interruptible_timeout(wait, 0, 10); /* Select random Address */ buf[1] = 0xB2; get_random_bytes(&buf[2], 2); ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); } } if (drv_data->quirks & LG_FF) lgff_init(hdev); if (drv_data->quirks & LG_FF2) lg2ff_init(hdev); if (drv_data->quirks & LG_FF3) lg3ff_init(hdev); if (drv_data->quirks & LG_FF4) lg4ff_init(hdev); return 0; err_free: kfree(drv_data); return ret; }
0
[ "CWE-119", "CWE-787" ]
linux
4ab25786c87eb20857bbb715c3ae34ec8fd6a214
276,003,700,064,057,900,000,000,000,000,000,000,000
69
HID: fix a couple of off-by-ones There are a few very theoretical off-by-one bugs in report descriptor size checking when performing a pre-parsing fixup. Fix those. Cc: [email protected] Reported-by: Ben Hawkes <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
static void FVMenuPrint(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { FontView *fv = (FontView *) GDrawGetUserData(gw); if ( fv->b.container!=NULL && fv->b.container->funcs->is_modal ) return; PrintFFDlg(fv,NULL,NULL); }
0
[ "CWE-119", "CWE-787" ]
fontforge
626f751752875a0ddd74b9e217b6f4828713573c
52,632,369,781,163,950,000,000,000,000,000,000,000
7
Warn users before discarding their unsaved scripts (#3852) * Warn users before discarding their unsaved scripts This closes #3846.
static void dmar_set_intr_remap_table(struct dmar_drhd_rt *dmar_unit) { uint64_t address; uint32_t status; uint8_t size; spinlock_obtain(&(dmar_unit->lock)); /* Set number of bits needed to represent the entries minus 1 */ size = (uint8_t) fls32(CONFIG_MAX_IR_ENTRIES) - 1U; address = dmar_unit->ir_table_addr | DMAR_IR_ENABLE_EIM | size; iommu_write64(dmar_unit, DMAR_IRTA_REG, address); iommu_write32(dmar_unit, DMAR_GCMD_REG, dmar_unit->gcmd | DMA_GCMD_SIRTP); dmar_wait_completion(dmar_unit, DMAR_GSTS_REG, DMA_GSTS_IRTPS, 0U, &status); spinlock_release(&(dmar_unit->lock)); }
0
[ "CWE-120", "CWE-787" ]
acrn-hypervisor
25c0e3817eb332660dd63d1d4522e63dcc94e79a
231,935,548,975,345,260,000,000,000,000,000,000,000
20
hv: validate input for dmar_free_irte function Malicious input 'index' may trigger buffer overflow on array 'irte_alloc_bitmap[]'. This patch validate that 'index' shall be less than 'CONFIG_MAX_IR_ENTRIES' and also remove unnecessary check on 'index' in 'ptirq_free_irte()' function with this fix. Tracked-On: #6132 Signed-off-by: Yonghua Huang <[email protected]>
static NAN_MODULE_INIT(Init) { Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New); tpl->SetClassName(Nan::New("AESGCMCipher").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); SetPrototypeMethod(tpl, "encrypt", Encrypt); SetPrototypeMethod(tpl, "free", Free); constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("AESGCMCipher").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); }
0
[ "CWE-78" ]
ssh2
f763271f41320e71d5cbee02ea5bc6a2ded3ca21
78,176,910,772,326,800,000,000,000,000,000,000,000
14
examples,lib,test: switch to code rewrite For more information see: https://github.com/mscdex/ssh2/issues/935
query_thread (GSimpleAsyncResult *result, GDataService *service, GCancellable *cancellable) { GError *error = NULL; QueryAsyncData *data = g_simple_async_result_get_op_res_gpointer (result); /* Execute the query and return */ data->feed = __gdata_service_query (service, data->domain, data->feed_uri, data->query, data->entry_type, cancellable, data->progress_callback, data->progress_user_data, &error, TRUE); if (data->feed == NULL && error != NULL) { g_simple_async_result_set_from_error (result, error); g_error_free (error); } if (data->destroy_progress_user_data != NULL) { data->destroy_progress_user_data (data->progress_user_data); } }
0
[ "CWE-20" ]
libgdata
6799f2c525a584dc998821a6ce897e463dad7840
243,156,510,396,754,430,000,000,000,000,000,000,000
17
core: Validate SSL certificates for all connections This prevents MitM attacks which use spoofed SSL certificates. Note that this bumps our libsoup requirement to 2.37.91. Closes: https://bugzilla.gnome.org/show_bug.cgi?id=671535
RZ_API char *rz_core_analysis_fcn_name(RzCore *core, RzAnalysisFunction *fcn) { bool demangle = rz_config_get_i(core->config, "bin.demangle"); const char *lang = demangle ? rz_config_get(core->config, "bin.lang") : NULL; bool keep_lib = rz_config_get_i(core->config, "bin.demangle.libs"); char *name = strdup(fcn->name ? fcn->name : ""); if (demangle) { char *tmp = rz_bin_demangle(core->bin->cur, lang, name, fcn->addr, keep_lib); if (tmp) { free(name); name = tmp; } } return name; }
0
[ "CWE-703" ]
rizin
6ce71d8aa3dafe3cdb52d5d72ae8f4b95916f939
180,352,179,610,037,400,000,000,000,000,000,000,000
14
Initialize retctx,ctx before freeing the inner elements In rz_core_analysis_type_match retctx structure was initialized on the stack only after a "goto out_function", where a field of that structure was freed. When the goto path is taken, the field is not properly initialized and it cause cause a crash of Rizin or have other effects. Fixes: CVE-2021-4022
struct ndp_msgrs *ndp_msgrs(struct ndp_msg *msg) { if (ndp_msg_type(msg) != NDP_MSG_RS) return NULL; return &msg->nd_msg.rs; }
0
[ "CWE-284" ]
libndp
a4892df306e0532487f1634ba6d4c6d4bb381c7f
64,295,170,809,403,900,000,000,000,000,000,000,000
6
libndp: validate the IPv6 hop limit None of the NDP messages should ever come from a non-local network; as stated in RFC4861's 6.1.1 (RS), 6.1.2 (RA), 7.1.1 (NS), 7.1.2 (NA), and 8.1. (redirect): - The IP Hop Limit field has a value of 255, i.e., the packet could not possibly have been forwarded by a router. This fixes CVE-2016-3698. Reported by: Julien BERNARD <[email protected]> Signed-off-by: Lubomir Rintel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]>
add_durable_context(struct kvec *iov, unsigned int *num_iovec, struct cifs_open_parms *oparms) { struct smb2_create_req *req = iov[0].iov_base; unsigned int num = *num_iovec; if (oparms->reconnect) { iov[num].iov_base = create_reconnect_durable_buf(oparms->fid); /* indicate that we don't need to relock the file */ oparms->reconnect = false; } else iov[num].iov_base = create_durable_buf(); if (iov[num].iov_base == NULL) return -ENOMEM; iov[num].iov_len = sizeof(struct create_durable); if (!req->CreateContextsOffset) req->CreateContextsOffset = cpu_to_le32(sizeof(struct smb2_create_req) - 4 + iov[1].iov_len); le32_add_cpu(&req->CreateContextsLength, sizeof(struct create_durable)); inc_rfc1001_len(&req->hdr, sizeof(struct create_durable)); *num_iovec = num + 1; return 0; }
0
[ "CWE-399" ]
linux
18f39e7be0121317550d03e267e3ebd4dbfbb3ce
49,007,924,813,283,410,000,000,000,000,000,000,000
24
[CIFS] Possible null ptr deref in SMB2_tcon As Raphael Geissert pointed out, tcon_error_exit can dereference tcon and there is one path in which tcon can be null. Signed-off-by: Steve French <[email protected]> CC: Stable <[email protected]> # v3.7+ Reported-by: Raphael Geissert <[email protected]>
static inline void SetPixelY(const Image *restrict image,const Quantum y, Quantum *restrict pixel) { pixel[image->channel_map[YPixelChannel].offset]=y; }
0
[ "CWE-119", "CWE-787" ]
ImageMagick
450bd716ed3b9186dd10f9e60f630a3d9eeea2a4
81,841,548,336,705,150,000,000,000,000,000,000,000
5
asmlinkage long sys_recv(int fd, void __user *ubuf, size_t size, unsigned int flags) { return sys_recvfrom(fd, ubuf, size, flags, NULL, NULL); }
0
[ "CWE-399", "CWE-703" ]
linux
ed6fe9d614fc1bca95eb8c0ccd0e92db00ef9d5d
277,763,732,884,548,100,000,000,000,000,000,000,000
5
Fix order of arguments to compat_put_time[spec|val] Commit 644595f89620 ("compat: Handle COMPAT_USE_64BIT_TIME in net/socket.c") introduced a bug where the helper functions to take either a 64-bit or compat time[spec|val] got the arguments in the wrong order, passing the kernel stack pointer off as a user pointer (and vice versa). Because of the user address range check, that in turn then causes an EFAULT due to the user pointer range checking failing for the kernel address. Incorrectly resuling in a failed system call for 32-bit processes with a 64-bit kernel. On odder architectures like HP-PA (with separate user/kernel address spaces), it can be used read kernel memory. Signed-off-by: Mikulas Patocka <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
void maybe_inject_dispatch_delay() { if (g_conf->osd_debug_inject_dispatch_delay_probability > 0) { if (rand() % 10000 < g_conf->osd_debug_inject_dispatch_delay_probability * 10000) { utime_t t; t.set_from_double(g_conf->osd_debug_inject_dispatch_delay_duration); t.sleep(); } } }
0
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
70,471,557,544,254,750,000,000,000,000,000,000,000
10
auth/cephx: add authorizer challenge Allow the accepting side of a connection to reject an initial authorizer with a random challenge. The connecting side then has to respond with an updated authorizer proving they are able to decrypt the service's challenge and that the new authorizer was produced for this specific connection instance. The accepting side requires this challenge and response unconditionally if the client side advertises they have the feature bit. Servers wishing to require this improved level of authentication simply have to require the appropriate feature. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b) # Conflicts: # src/auth/Auth.h # src/auth/cephx/CephxProtocol.cc # src/auth/cephx/CephxProtocol.h # src/auth/none/AuthNoneProtocol.h # src/msg/Dispatcher.h # src/msg/async/AsyncConnection.cc - const_iterator - ::decode vs decode - AsyncConnection ctor arg noise - get_random_bytes(), not cct->random()
void CLASS phase_one_load_raw() { int row, col, a, b; ushort *pixel, akey, bkey, mask; fseek (ifp, ph1.key_off, SEEK_SET); akey = get2(); bkey = get2(); mask = ph1.format == 1 ? 0x5555:0x1354; fseek (ifp, data_offset + top_margin*raw_width*2, SEEK_SET); pixel = (ushort *) calloc (raw_width, sizeof *pixel); merror (pixel, "phase_one_load_raw()"); for (row=0; row < height; row++) { read_shorts (pixel, raw_width); if (ph1.format) for (col=0; col < raw_width; col+=2) { a = pixel[col+0] ^ akey; b = pixel[col+1] ^ bkey; pixel[col+0] = (a & mask) | (b & ~mask); pixel[col+1] = (b & mask) | (a & ~mask); } for (col=0; col < width; col++) BAYER(row,col) = pixel[col+left_margin]; } free (pixel); phase_one_correct(); }
0
[ "CWE-189" ]
rawstudio
983bda1f0fa5fa86884381208274198a620f006e
221,102,351,259,949,240,000,000,000,000,000,000,000
27
Avoid overflow in ljpeg_start().
void MainWindow::changeTheme(const QString &theme) { LOG_DEBUG() << "begin"; if (theme == "dark") { QApplication::setStyle("Fusion"); QPalette palette; palette.setColor(QPalette::Window, QColor(50,50,50)); palette.setColor(QPalette::WindowText, QColor(220,220,220)); palette.setColor(QPalette::Base, QColor(30,30,30)); palette.setColor(QPalette::AlternateBase, QColor(40,40,40)); palette.setColor(QPalette::Highlight, QColor(23,92,118)); palette.setColor(QPalette::HighlightedText, Qt::white); palette.setColor(QPalette::ToolTipBase, palette.color(QPalette::Highlight)); palette.setColor(QPalette::ToolTipText, palette.color(QPalette::WindowText)); palette.setColor(QPalette::Text, palette.color(QPalette::WindowText)); palette.setColor(QPalette::BrightText, Qt::red); palette.setColor(QPalette::Button, palette.color(QPalette::Window)); palette.setColor(QPalette::ButtonText, palette.color(QPalette::WindowText)); palette.setColor(QPalette::Link, palette.color(QPalette::Highlight).lighter()); palette.setColor(QPalette::LinkVisited, palette.color(QPalette::Highlight)); palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray); palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray); QApplication::setPalette(palette); QIcon::setThemeName("dark"); } else if (theme == "light") { QStyle* style = QStyleFactory::create("Fusion"); QApplication::setStyle(style); QApplication::setPalette(style->standardPalette()); QIcon::setThemeName("light"); } else { QApplication::setStyle(qApp->property("system-style").toString()); QIcon::setThemeName("oxygen"); } emit QmlApplication::singleton().paletteChanged(); LOG_DEBUG() << "end"; }
0
[ "CWE-89", "CWE-327", "CWE-295" ]
shotcut
f008adc039642307f6ee3378d378cdb842e52c1d
197,025,416,783,057,020,000,000,000,000,000,000,000
36
fix upgrade check is not using TLS correctly