func
string
target
string
cwe
list
project
string
commit_id
string
hash
string
size
int64
message
string
vul
int64
Status ConvertNodeDefsToGraph(const GraphConstructorOptions& opts, gtl::ArraySlice<NodeDef> nodes, Graph* g) { ShapeRefiner refiner(TF_GRAPH_DEF_VERSION, g->op_registry()); // TODO(irving): Copy will go away once NodeInfo exists std::vector<const NodeDef*> node_defs; node_defs.reserve(nodes.size()); for (const auto& n : nodes) { node_defs.push_back(&n); } return GraphConstructor::Construct(opts, node_defs, nullptr, nullptr, g, &refiner, /*return_tensors=*/nullptr, /*return_nodes=*/nullptr, /*missing_unused_input_map_keys=*/nullptr); }
Safe
[ "CWE-125", "CWE-369", "CWE-908" ]
tensorflow
0cc38aaa4064fd9e79101994ce9872c6d91f816b
1.7245464124910863e+38
14
Prevent unitialized memory access in `GraphConstructor::MakeEdge` The `MakeEdge` implementation assumes that there exists an output at `output_index` of `src` node and an input at `input_index` of `dst` node. However, if this is not the case this results in accessing data out of bounds. Because we are accessing an array that is a private member of a class and only in read only mode, this usually results only in unitialized memory access. However, it is reasonable to think that malicious users could manipulate these indexes to actually read data outside the class, thus resulting in information leakage and further exploits. PiperOrigin-RevId: 346343288 Change-Id: I2127da27c2023d27f26efd39afa6c853385cab6f
0
mrb_mod_attr_reader(mrb_state *mrb, mrb_value mod) { struct RClass *c = mrb_class_ptr(mod); mrb_value *argv; mrb_int argc, i; int ai; mrb_get_args(mrb, "*", &argv, &argc); ai = mrb_gc_arena_save(mrb); for (i=0; i<argc; i++) { mrb_value name, str; mrb_sym method, sym; struct RProc *p; mrb_method_t m; method = to_sym(mrb, argv[i]); name = mrb_sym2str(mrb, method); str = mrb_str_new_capa(mrb, RSTRING_LEN(name)+1); mrb_str_cat_lit(mrb, str, "@"); mrb_str_cat_str(mrb, str, name); sym = mrb_intern_str(mrb, str); mrb_iv_check(mrb, sym); name = mrb_symbol_value(sym); p = mrb_proc_new_cfunc_with_env(mrb, attr_reader, 1, &name); MRB_METHOD_FROM_PROC(m, p); mrb_define_method_raw(mrb, c, method, m); mrb_gc_arena_restore(mrb, ai); } return mrb_nil_value(); }
Safe
[ "CWE-476", "CWE-415" ]
mruby
faa4eaf6803bd11669bc324b4c34e7162286bfa3
2.9947448276973496e+38
30
`mrb_class_real()` did not work for `BasicObject`; fix #4037
0
void PrelinEval8(register const cmsUInt16Number Input[], register cmsUInt16Number Output[], register const void* D) { cmsUInt8Number r, g, b; cmsS15Fixed16Number rx, ry, rz; cmsS15Fixed16Number c0, c1, c2, c3, Rest; int OutChan; register cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1; Prelin8Data* p8 = (Prelin8Data*) D; register const cmsInterpParams* p = p8 ->p; int TotalOut = p -> nOutputs; const cmsUInt16Number* LutTable = (const cmsUInt16Number*) p->Table; r = Input[0] >> 8; g = Input[1] >> 8; b = Input[2] >> 8; X0 = X1 = p8->X0[r]; Y0 = Y1 = p8->Y0[g]; Z0 = Z1 = p8->Z0[b]; rx = p8 ->rx[r]; ry = p8 ->ry[g]; rz = p8 ->rz[b]; X1 = X0 + ((rx == 0) ? 0 : p ->opta[2]); Y1 = Y0 + ((ry == 0) ? 0 : p ->opta[1]); Z1 = Z0 + ((rz == 0) ? 0 : p ->opta[0]); // These are the 6 Tetrahedral for (OutChan=0; OutChan < TotalOut; OutChan++) { c0 = DENS(X0, Y0, Z0); if (rx >= ry && ry >= rz) { c1 = DENS(X1, Y0, Z0) - c0; c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0); c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0); } else if (rx >= rz && rz >= ry) { c1 = DENS(X1, Y0, Z0) - c0; c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1); c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0); } else if (rz >= rx && rx >= ry) { c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1); c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1); c3 = DENS(X0, Y0, Z1) - c0; } else if (ry >= rx && rx >= rz) { c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0); c2 = DENS(X0, Y1, Z0) - c0; c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0); } else if (ry >= rz && rz >= rx) { c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1); c2 = DENS(X0, Y1, Z0) - c0; c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0); } else if (rz >= ry && ry >= rx) { c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1); c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1); c3 = DENS(X0, Y0, Z1) - c0; } else { c1 = c2 = c3 = 0; } Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001; Output[OutChan] = (cmsUInt16Number)c0 + ((Rest + (Rest >> 16)) >> 16); } }
Safe
[ "CWE-125" ]
Little-CMS
d41071eb8cfea7aa10a9262c12bd95d5d9d81c8f
1.9667745371732026e+38
88
Contributed fixes from Oracle Two minor glitches
0
void print_cert_checks(BIO *bio, X509 *x, const unsigned char *checkhost, const unsigned char *checkemail, const char *checkip) { if (x == NULL) return; if (checkhost) { BIO_printf(bio, "Hostname %s does%s match certificate\n", checkhost, X509_check_host(x, checkhost, 0, 0) ? "" : " NOT"); } if (checkemail) { BIO_printf(bio, "Email %s does%s match certificate\n", checkemail, X509_check_email(x, checkemail, 0, 0) ? "" : " NOT"); } if (checkip) { BIO_printf(bio, "IP %s does%s match certificate\n", checkip, X509_check_ip_asc(x, checkip, 0) ? "" : " NOT"); } }
Safe
[]
openssl
a70da5b3ecc3160368529677006801c58cb369db
2.042794068246556e+38
28
New functions to check a hostname email or IP address against a certificate. Add options to s_client, s_server and x509 utilities to print results of checks.
0
void blk_post_runtime_suspend(struct request_queue *q, int err) { if (!q->dev) return; spin_lock_irq(q->queue_lock); if (!err) { q->rpm_status = RPM_SUSPENDED; } else { q->rpm_status = RPM_ACTIVE; pm_runtime_mark_last_busy(q->dev); } spin_unlock_irq(q->queue_lock); }
Safe
[ "CWE-416", "CWE-703" ]
linux
54648cf1ec2d7f4b6a71767799c45676a138ca24
1.6100181397957287e+38
14
block: blk_init_allocated_queue() set q->fq as NULL in the fail case We find the memory use-after-free issue in __blk_drain_queue() on the kernel 4.14. After read the latest kernel 4.18-rc6 we think it has the same problem. Memory is allocated for q->fq in the blk_init_allocated_queue(). If the elevator init function called with error return, it will run into the fail case to free the q->fq. Then the __blk_drain_queue() uses the same memory after the free of the q->fq, it will lead to the unpredictable event. The patch is to set q->fq as NULL in the fail case of blk_init_allocated_queue(). Fixes: commit 7c94e1c157a2 ("block: introduce blk_flush_queue to drive flush machinery") Cc: <stable@vger.kernel.org> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: xiao jin <jin.xiao@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
0
void Magick::Image::solarize(const double factor_) { modifyImage(); GetPPException; SolarizeImage(image(),factor_,exceptionInfo); ThrowImageException; }
Safe
[ "CWE-416" ]
ImageMagick
8c35502217c1879cb8257c617007282eee3fe1cc
2.392475375386395e+38
7
Added missing return to avoid use after free.
0
int InstanceKlass::nof_implementors() const { assert_lock_strong(Compile_lock); Klass* k = implementor(); if (k == NULL) { return 0; } else if (k != this) { return 1; } else { return 2; } }
Safe
[]
jdk11u-dev
41825fa33d605f8501164f9296572e4378e8183b
2.0182066008747846e+38
11
8270386: Better verification of scan methods Reviewed-by: mbaesken Backport-of: ac329cef45979bd0159ecd1347e36f7129bb2ce4
0
void cpu_abort(CPUState *cpu, const char *fmt, ...) { abort(); }
Safe
[ "CWE-476" ]
unicorn
3d3deac5e6d38602b689c4fef5dac004f07a2e63
4.23300240911212e+37
4
Fix crash when mapping a big memory and calling uc_close
0
MagickExport MagickBooleanType LinearStretchImage(Image *image, const double black_point,const double white_point,ExceptionInfo *exception) { #define LinearStretchImageTag "LinearStretch/Image" CacheView *image_view; double *histogram, intensity; MagickBooleanType status; ssize_t black, white, y; /* Allocate histogram and linear map. */ assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); histogram=(double *) AcquireQuantumMemory(MaxMap+1UL,sizeof(*histogram)); if (histogram == (double *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); /* Form histogram. */ (void) memset(histogram,0,(MaxMap+1)*sizeof(*histogram)); image_view=AcquireVirtualCacheView(image,exception); for (y=0; y < (ssize_t) image->rows; y++) { register const Quantum *magick_restrict p; register ssize_t x; p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { intensity=GetPixelIntensity(image,p); histogram[ScaleQuantumToMap(ClampToQuantum(intensity))]++; p+=GetPixelChannels(image); } } image_view=DestroyCacheView(image_view); /* Find the histogram boundaries by locating the black and white point levels. */ intensity=0.0; for (black=0; black < (ssize_t) MaxMap; black++) { intensity+=histogram[black]; if (intensity >= black_point) break; } intensity=0.0; for (white=(ssize_t) MaxMap; white != 0; white--) { intensity+=histogram[white]; if (intensity >= white_point) break; } histogram=(double *) RelinquishMagickMemory(histogram); status=LevelImage(image,(double) ScaleMapToQuantum((MagickRealType) black), (double) ScaleMapToQuantum((MagickRealType) white),1.0,exception); return(status); }
Safe
[ "CWE-399", "CWE-119", "CWE-787" ]
ImageMagick
d4fc44b58a14f76b1ac997517d742ee12c9dc5d3
2.5100497497345493e+36
75
https://github.com/ImageMagick/ImageMagick/issues/1611
0
bool ConnectionManagerImpl::ActiveStreamFilterBase::commonHandleAfterHeadersCallback( FilterHeadersStatus status, bool& headers_only) { ASSERT(!headers_continued_); ASSERT(canIterate()); if (status == FilterHeadersStatus::StopIteration) { iteration_state_ = IterationState::StopSingleIteration; } else if (status == FilterHeadersStatus::StopAllIterationAndBuffer) { iteration_state_ = IterationState::StopAllBuffer; } else if (status == FilterHeadersStatus::StopAllIterationAndWatermark) { iteration_state_ = IterationState::StopAllWatermark; } else if (status == FilterHeadersStatus::ContinueAndEndStream) { // Set headers_only to true so we know to end early if necessary, // but continue filter iteration so we actually write the headers/run the cleanup code. headers_only = true; ENVOY_STREAM_LOG(debug, "converting to headers only", parent_); } else { ASSERT(status == FilterHeadersStatus::Continue); headers_continued_ = true; } handleMetadataAfterHeadersCallback(); if (stoppedAll() || status == FilterHeadersStatus::StopIteration) { return false; } else { return true; } }
Safe
[ "CWE-400", "CWE-703" ]
envoy
afc39bea36fd436e54262f150c009e8d72db5014
1.5288286513062308e+38
29
Track byteSize of HeaderMap internally. Introduces a cached byte size updated internally in HeaderMap. The value is stored as an optional, and is cleared whenever a non-const pointer or reference to a HeaderEntry is accessed. The cached value can be set with refreshByteSize() which performs an iteration over the HeaderMap to sum the size of each key and value in the HeaderMap. Signed-off-by: Asra Ali <asraa@google.com>
0
void unit_unwatch_pid(Unit *u, pid_t pid) { assert(u); assert(pid >= 1); hashmap_remove_value(u->manager->watch_pids, LONG_TO_PTR(pid), u); set_remove(u->pids, LONG_TO_PTR(pid)); }
Vulnerable
[]
systemd
5ba6985b6c8ef85a8bcfeb1b65239c863436e75b
2.9005078814908232e+38
7
core: allow PIDs to be watched by two units at the same time In some cases it is interesting to map a PID to two units at the same time. For example, when a user logs in via a getty, which is reexeced to /sbin/login that binary will be explicitly referenced as main pid of the getty service, as well as implicitly referenced as part of the session scope.
1
void cgsem_destroy(cgsem_t *cgsem) { close(cgsem->pipefd[1]); close(cgsem->pipefd[0]); }
Safe
[ "CWE-20", "CWE-703" ]
sgminer
910c36089940e81fb85c65b8e63dcd2fac71470c
5.9409005268430105e+37
5
stratum: parse_notify(): Don't die on malformed bbversion/prev_hash/nbit/ntime. Might have introduced a memory leak, don't have time to check. :( Should the other hex2bin()'s be checked? Thanks to Mick Ayzenberg <mick.dejavusecurity.com> for finding this.
0
QPDFTokenizer::presentCharacter(char ch) { if (this->m->state == st_token_ready) { throw std::logic_error( "INTERNAL ERROR: QPDF tokenizer presented character " "while token is waiting"); } char orig_ch = ch; // State machine is implemented such that some characters may be // handled more than once. This happens whenever you have to use // the character that caused a state change in the new state. bool handled = true; if (this->m->state == st_top) { // Note: we specifically do not use ctype here. It is // locale-dependent. if (isSpace(ch)) { if (this->m->include_ignorable) { this->m->state = st_in_space; this->m->val += ch; } } else if (ch == '%') { this->m->state = st_in_comment; if (this->m->include_ignorable) { this->m->val += ch; } } else if (ch == '(') { this->m->string_depth = 1; this->m->string_ignoring_newline = false; memset(this->m->bs_num_register, '\0', sizeof(this->m->bs_num_register)); this->m->last_char_was_bs = false; this->m->last_char_was_cr = false; this->m->state = st_in_string; } else if (ch == '<') { this->m->state = st_lt; } else if (ch == '>') { this->m->state = st_gt; } else { this->m->val += ch; if (ch == ')') { this->m->type = tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad )"); this->m->error_message = "unexpected )"; this->m->state = st_token_ready; } else if (ch == '[') { this->m->type = tt_array_open; this->m->state = st_token_ready; } else if (ch == ']') { this->m->type = tt_array_close; this->m->state = st_token_ready; } else if (ch == '{') { this->m->type = tt_brace_open; this->m->state = st_token_ready; } else if (ch == '}') { this->m->type = tt_brace_close; this->m->state = st_token_ready; } else { this->m->state = st_literal; } } } else if (this->m->state == st_in_space) { // We only enter this state if include_ignorable is true. if (! isSpace(ch)) { this->m->type = tt_space; this->m->unread_char = true; this->m->char_to_unread = ch; this->m->state = st_token_ready; } else { this->m->val += ch; } } else if (this->m->state == st_in_comment) { if ((ch == '\r') || (ch == '\n')) { if (this->m->include_ignorable) { this->m->type = tt_comment; this->m->unread_char = true; this->m->char_to_unread = ch; this->m->state = st_token_ready; } else { this->m->state = st_top; } } else if (this->m->include_ignorable) { this->m->val += ch; } } else if (this->m->state == st_lt) { if (ch == '<') { this->m->val = "<<"; this->m->type = tt_dict_open; this->m->state = st_token_ready; } else { handled = false; this->m->state = st_in_hexstring; } } else if (this->m->state == st_gt) { if (ch == '>') { this->m->val = ">>"; this->m->type = tt_dict_close; this->m->state = st_token_ready; } else { this->m->val = ">"; this->m->type = tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad >"); this->m->error_message = "unexpected >"; this->m->unread_char = true; this->m->char_to_unread = ch; this->m->state = st_token_ready; } } else if (this->m->state == st_in_string) { if (this->m->string_ignoring_newline && (ch != '\n')) { this->m->string_ignoring_newline = false; } size_t bs_num_count = strlen(this->m->bs_num_register); bool ch_is_octal = ((ch >= '0') && (ch <= '7')); if ((bs_num_count == 3) || ((bs_num_count > 0) && (! ch_is_octal))) { // We've accumulated \ddd. PDF Spec says to ignore // high-order overflow. this->m->val += static_cast<char>( strtol(this->m->bs_num_register, 0, 8)); memset(this->m->bs_num_register, '\0', sizeof(this->m->bs_num_register)); bs_num_count = 0; } if (this->m->string_ignoring_newline && (ch == '\n')) { // ignore this->m->string_ignoring_newline = false; } else if (ch_is_octal && (this->m->last_char_was_bs || (bs_num_count > 0))) { this->m->bs_num_register[bs_num_count++] = ch; } else if (this->m->last_char_was_bs) { switch (ch) { case 'n': this->m->val += '\n'; break; case 'r': this->m->val += '\r'; break; case 't': this->m->val += '\t'; break; case 'b': this->m->val += '\b'; break; case 'f': this->m->val += '\f'; break; case '\n': break; case '\r': this->m->string_ignoring_newline = true; break; default: // PDF spec says backslash is ignored before anything else this->m->val += ch; break; } } else if (ch == '\\') { // last_char_was_bs is set/cleared below as appropriate if (bs_num_count) { throw std::logic_error( "INTERNAL ERROR: QPDFTokenizer: bs_num_count != 0 " "when ch == '\\'"); } } else if (ch == '(') { this->m->val += ch; ++this->m->string_depth; } else if ((ch == ')') && (--this->m->string_depth == 0)) { this->m->type = tt_string; this->m->state = st_token_ready; } else if (ch == '\r') { // CR by itself is converted to LF this->m->val += '\n'; } else if (ch == '\n') { // CR LF is converted to LF if (! this->m->last_char_was_cr) { this->m->val += ch; } } else { this->m->val += ch; } this->m->last_char_was_cr = ((! this->m->string_ignoring_newline) && (ch == '\r')); this->m->last_char_was_bs = ((! this->m->last_char_was_bs) && (ch == '\\')); } else if (this->m->state == st_literal) { if (isDelimiter(ch)) { // A C-locale whitespace character or delimiter terminates // token. It is important to unread the whitespace // character even though it is ignored since it may be the // newline after a stream keyword. Removing it here could // make the stream-reading code break on some files, // though not on any files in the test suite as of this // writing. this->m->type = tt_word; this->m->unread_char = true; this->m->char_to_unread = ch; this->m->state = st_token_ready; } else { this->m->val += ch; } } else if (this->m->state == st_inline_image) { this->m->val += ch; size_t len = this->m->val.length(); if (len == this->m->inline_image_bytes) { QTC::TC("qpdf", "QPDFTokenizer found EI by byte count"); this->m->type = tt_inline_image; this->m->inline_image_bytes = 0; this->m->state = st_token_ready; } else if ((this->m->inline_image_bytes == 0) && (len >= 4) && isDelimiter(this->m->val.at(len-4)) && (this->m->val.at(len-3) == 'E') && (this->m->val.at(len-2) == 'I') && isDelimiter(this->m->val.at(len-1))) { QTC::TC("qpdf", "QPDFTokenizer found EI the old way"); this->m->val.erase(len - 1); this->m->type = tt_inline_image; this->m->unread_char = true; this->m->char_to_unread = ch; this->m->state = st_token_ready; } } else { handled = false; } if (handled) { // okay } else if (this->m->state == st_in_hexstring) { if (ch == '>') { this->m->type = tt_string; this->m->state = st_token_ready; if (this->m->val.length() % 2) { // PDF spec says odd hexstrings have implicit // trailing 0. this->m->val += '0'; } char num[3]; num[2] = '\0'; std::string nval; for (unsigned int i = 0; i < this->m->val.length(); i += 2) { num[0] = this->m->val.at(i); num[1] = this->m->val.at(i+1); char nch = static_cast<char>(strtol(num, 0, 16)); nval += nch; } this->m->val = nval; } else if (QUtil::is_hex_digit(ch)) { this->m->val += ch; } else if (isSpace(ch)) { // ignore } else { this->m->type = tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad hexstring character"); this->m->error_message = std::string("invalid character (") + ch + ") in hexstring"; this->m->state = st_token_ready; } } else { throw std::logic_error( "INTERNAL ERROR: invalid state while reading token"); } if ((this->m->state == st_token_ready) && (this->m->type == tt_word)) { resolveLiteral(); } if (! (betweenTokens() || ((this->m->state == st_token_ready) && this->m->unread_char))) { this->m->raw_val += orig_ch; } }
Safe
[ "CWE-787" ]
qpdf
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
2.4179151290563527e+37
384
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.
0
join_read_prev_same(READ_RECORD *info) { int error; TABLE *table= info->table; JOIN_TAB *tab=table->reginfo.join_tab; if (unlikely((error= table->file->ha_index_prev(table->record[0])))) return report_error(table, error); if (key_cmp_if_same(table, tab->ref.key_buff, tab->ref.key, tab->ref.key_length)) { table->status=STATUS_NOT_FOUND; error= -1; } return error; }
Safe
[]
server
ff77a09bda884fe6bf3917eb29b9d3a2f53f919b
3.0465260237058247e+38
16
MDEV-22464 Server crash on UPDATE with nested subquery Uninitialized ref_pointer_array[] because setup_fields() got empty fields list. mysql_multi_update() for some reason does that by substituting the fields list with empty total_list for the mysql_select() call (looks like wrong merge since total_list is not used anywhere else and is always empty). The fix would be to return back the original fields list. But this fails update_use_source.test case: --error ER_BAD_FIELD_ERROR update v1 set t1c1=2 order by 1; Actually not failing the above seems to be ok. The other fix would be to keep resolve_in_select_list false (and that keeps outer context from being resolved in Item_ref::fix_fields()). This fix is more consistent with how SELECT behaves: --error ER_SUBQUERY_NO_1_ROW select a from t1 where a= (select 2 from t1 having (a = 3)); So this patch implements this fix.
0
static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, struct netlink_ext_ack *extack) { struct net *net = sock_net(skb->sk); struct nlattr *tca[TCA_MAX + 1]; char name[IFNAMSIZ]; struct tcmsg *t; u32 protocol; u32 prio; bool prio_allocate; u32 parent; u32 chain_index; struct Qdisc *q; struct tcf_chain_info chain_info; struct tcf_chain *chain; struct tcf_block *block; struct tcf_proto *tp; unsigned long cl; void *fh; int err; int tp_created; bool rtnl_held = false; u32 flags; if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) return -EPERM; replay: tp_created = 0; err = nlmsg_parse_deprecated(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack); if (err < 0) return err; t = nlmsg_data(n); protocol = TC_H_MIN(t->tcm_info); prio = TC_H_MAJ(t->tcm_info); prio_allocate = false; parent = t->tcm_parent; tp = NULL; cl = 0; block = NULL; q = NULL; chain = NULL; flags = 0; if (prio == 0) { /* If no priority is provided by the user, * we allocate one. */ if (n->nlmsg_flags & NLM_F_CREATE) { prio = TC_H_MAKE(0x80000000U, 0U); prio_allocate = true; } else { NL_SET_ERR_MSG(extack, "Invalid filter command with priority of zero"); return -ENOENT; } } /* Find head of filter chain. */ err = __tcf_qdisc_find(net, &q, &parent, t->tcm_ifindex, false, extack); if (err) return err; if (tcf_proto_check_kind(tca[TCA_KIND], name)) { NL_SET_ERR_MSG(extack, "Specified TC filter name too long"); err = -EINVAL; goto errout; } /* Take rtnl mutex if rtnl_held was set to true on previous iteration, * block is shared (no qdisc found), qdisc is not unlocked, classifier * type is not specified, classifier is not unlocked. */ if (rtnl_held || (q && !(q->ops->cl_ops->flags & QDISC_CLASS_OPS_DOIT_UNLOCKED)) || !tcf_proto_is_unlocked(name)) { rtnl_held = true; rtnl_lock(); } err = __tcf_qdisc_cl_find(q, parent, &cl, t->tcm_ifindex, extack); if (err) goto errout; block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, extack); if (IS_ERR(block)) { err = PTR_ERR(block); goto errout; } block->classid = parent; chain_index = tca[TCA_CHAIN] ? nla_get_u32(tca[TCA_CHAIN]) : 0; if (chain_index > TC_ACT_EXT_VAL_MASK) { NL_SET_ERR_MSG(extack, "Specified chain index exceeds upper limit"); err = -EINVAL; goto errout; } chain = tcf_chain_get(block, chain_index, true); if (!chain) { NL_SET_ERR_MSG(extack, "Cannot create specified filter chain"); err = -ENOMEM; goto errout; } mutex_lock(&chain->filter_chain_lock); tp = tcf_chain_tp_find(chain, &chain_info, protocol, prio, prio_allocate); if (IS_ERR(tp)) { NL_SET_ERR_MSG(extack, "Filter with specified priority/protocol not found"); err = PTR_ERR(tp); goto errout_locked; } if (tp == NULL) { struct tcf_proto *tp_new = NULL; if (chain->flushing) { err = -EAGAIN; goto errout_locked; } /* Proto-tcf does not exist, create new one */ if (tca[TCA_KIND] == NULL || !protocol) { NL_SET_ERR_MSG(extack, "Filter kind and protocol must be specified"); err = -EINVAL; goto errout_locked; } if (!(n->nlmsg_flags & NLM_F_CREATE)) { NL_SET_ERR_MSG(extack, "Need both RTM_NEWTFILTER and NLM_F_CREATE to create a new filter"); err = -ENOENT; goto errout_locked; } if (prio_allocate) prio = tcf_auto_prio(tcf_chain_tp_prev(chain, &chain_info)); mutex_unlock(&chain->filter_chain_lock); tp_new = tcf_proto_create(name, protocol, prio, chain, rtnl_held, extack); if (IS_ERR(tp_new)) { err = PTR_ERR(tp_new); goto errout_tp; } tp_created = 1; tp = tcf_chain_tp_insert_unique(chain, tp_new, protocol, prio, rtnl_held); if (IS_ERR(tp)) { err = PTR_ERR(tp); goto errout_tp; } } else { mutex_unlock(&chain->filter_chain_lock); } if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) { NL_SET_ERR_MSG(extack, "Specified filter kind does not match existing one"); err = -EINVAL; goto errout; } fh = tp->ops->get(tp, t->tcm_handle); if (!fh) { if (!(n->nlmsg_flags & NLM_F_CREATE)) { NL_SET_ERR_MSG(extack, "Need both RTM_NEWTFILTER and NLM_F_CREATE to create a new filter"); err = -ENOENT; goto errout; } } else if (n->nlmsg_flags & NLM_F_EXCL) { tfilter_put(tp, fh); NL_SET_ERR_MSG(extack, "Filter already exists"); err = -EEXIST; goto errout; } if (chain->tmplt_ops && chain->tmplt_ops != tp->ops) { NL_SET_ERR_MSG(extack, "Chain template is set to a different filter kind"); err = -EINVAL; goto errout; } if (!(n->nlmsg_flags & NLM_F_CREATE)) flags |= TCA_ACT_FLAGS_REPLACE; if (!rtnl_held) flags |= TCA_ACT_FLAGS_NO_RTNL; err = tp->ops->change(net, skb, tp, cl, t->tcm_handle, tca, &fh, flags, extack); if (err == 0) { tfilter_notify(net, skb, n, tp, block, q, parent, fh, RTM_NEWTFILTER, false, rtnl_held); tfilter_put(tp, fh); /* q pointer is NULL for shared blocks */ if (q) q->flags &= ~TCQ_F_CAN_BYPASS; } errout: if (err && tp_created) tcf_chain_tp_delete_empty(chain, tp, rtnl_held, NULL); errout_tp: if (chain) { if (tp && !IS_ERR(tp)) tcf_proto_put(tp, rtnl_held, NULL); if (!tp_created) tcf_chain_put(chain); } tcf_block_release(q, block, rtnl_held); if (rtnl_held) rtnl_unlock(); if (err == -EAGAIN) { /* Take rtnl lock in case EAGAIN is caused by concurrent flush * of target chain. */ rtnl_held = true; /* Replay the request. */ goto replay; } return err; errout_locked: mutex_unlock(&chain->filter_chain_lock); goto errout; }
Safe
[ "CWE-416" ]
linux
04c2a47ffb13c29778e2a14e414ad4cb5a5db4b5
3.8285839982934763e+37
233
net: sched: fix use-after-free in tc_new_tfilter() Whenever tc_new_tfilter() jumps back to replay: label, we need to make sure @q and @chain local variables are cleared again, or risk use-after-free as in [1] For consistency, apply the same fix in tc_ctl_chain() BUG: KASAN: use-after-free in mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1581 Write of size 8 at addr ffff8880985c4b08 by task syz-executor.4/1945 CPU: 0 PID: 1945 Comm: syz-executor.4 Not tainted 5.17.0-rc1-syzkaller-00495-gff58831fa02d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x8d/0x336 mm/kasan/report.c:255 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1581 tcf_chain_head_change_item net/sched/cls_api.c:372 [inline] tcf_chain0_head_change.isra.0+0xb9/0x120 net/sched/cls_api.c:386 tcf_chain_tp_insert net/sched/cls_api.c:1657 [inline] tcf_chain_tp_insert_unique net/sched/cls_api.c:1707 [inline] tc_new_tfilter+0x1e67/0x2350 net/sched/cls_api.c:2086 rtnetlink_rcv_msg+0x80d/0xb80 net/core/rtnetlink.c:5583 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline] netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:705 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:725 ____sys_sendmsg+0x331/0x810 net/socket.c:2413 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467 __sys_sendmmsg+0x195/0x470 net/socket.c:2553 __do_sys_sendmmsg net/socket.c:2582 [inline] __se_sys_sendmmsg net/socket.c:2579 [inline] __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f2647172059 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f2645aa5168 EFLAGS: 00000246 ORIG_RAX: 0000000000000133 RAX: ffffffffffffffda RBX: 00007f2647285100 RCX: 00007f2647172059 RDX: 040000000000009f RSI: 00000000200002c0 RDI: 0000000000000006 RBP: 00007f26471cc08d R08: 0000000000000000 R09: 0000000000000000 R10: 9e00000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffb3f7f02f R14: 00007f2645aa5300 R15: 0000000000022000 </TASK> Allocated by task 1944: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc mm/kasan/common.c:515 [inline] ____kasan_kmalloc mm/kasan/common.c:474 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524 kmalloc_node include/linux/slab.h:604 [inline] kzalloc_node include/linux/slab.h:726 [inline] qdisc_alloc+0xac/0xa10 net/sched/sch_generic.c:941 qdisc_create.constprop.0+0xce/0x10f0 net/sched/sch_api.c:1211 tc_modify_qdisc+0x4c5/0x1980 net/sched/sch_api.c:1660 rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5592 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline] netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:705 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:725 ____sys_sendmsg+0x331/0x810 net/socket.c:2413 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467 __sys_sendmmsg+0x195/0x470 net/socket.c:2553 __do_sys_sendmmsg net/socket.c:2582 [inline] __se_sys_sendmmsg net/socket.c:2579 [inline] __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 3609: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x130/0x160 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:236 [inline] slab_free_hook mm/slub.c:1728 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754 slab_free mm/slub.c:3509 [inline] kfree+0xcb/0x280 mm/slub.c:4562 rcu_do_batch kernel/rcu/tree.c:2527 [inline] rcu_core+0x7b8/0x1540 kernel/rcu/tree.c:2778 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558 Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 __call_rcu kernel/rcu/tree.c:3026 [inline] call_rcu+0xb1/0x740 kernel/rcu/tree.c:3106 qdisc_put_unlocked+0x6f/0x90 net/sched/sch_generic.c:1109 tcf_block_release+0x86/0x90 net/sched/cls_api.c:1238 tc_new_tfilter+0xc0d/0x2350 net/sched/cls_api.c:2148 rtnetlink_rcv_msg+0x80d/0xb80 net/core/rtnetlink.c:5583 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline] netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:705 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:725 ____sys_sendmsg+0x331/0x810 net/socket.c:2413 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467 __sys_sendmmsg+0x195/0x470 net/socket.c:2553 __do_sys_sendmmsg net/socket.c:2582 [inline] __se_sys_sendmmsg net/socket.c:2579 [inline] __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff8880985c4800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 776 bytes inside of 1024-byte region [ffff8880985c4800, ffff8880985c4c00) The buggy address belongs to the page: page:ffffea0002617000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x985c0 head:ffffea0002617000 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c41dc0 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 1941, ts 1038999441284, free_ts 1033444432829 prep_new_page mm/page_alloc.c:2434 [inline] get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2271 alloc_slab_page mm/slub.c:1799 [inline] allocate_slab mm/slub.c:1944 [inline] new_slab+0x28a/0x3b0 mm/slub.c:2004 ___slab_alloc+0x87c/0xe90 mm/slub.c:3018 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105 slab_alloc_node mm/slub.c:3196 [inline] slab_alloc mm/slub.c:3238 [inline] __kmalloc+0x2fb/0x340 mm/slub.c:4420 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:715 [inline] __register_sysctl_table+0x112/0x1090 fs/proc/proc_sysctl.c:1335 neigh_sysctl_register+0x2c8/0x5e0 net/core/neighbour.c:3787 devinet_sysctl_register+0xb1/0x230 net/ipv4/devinet.c:2618 inetdev_init+0x286/0x580 net/ipv4/devinet.c:278 inetdev_event+0xa8a/0x15d0 net/ipv4/devinet.c:1532 notifier_call_chain+0xb5/0x200 kernel/notifier.c:84 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919 call_netdevice_notifiers_extack net/core/dev.c:1931 [inline] call_netdevice_notifiers net/core/dev.c:1945 [inline] register_netdevice+0x1073/0x1500 net/core/dev.c:9698 veth_newlink+0x59c/0xa90 drivers/net/veth.c:1722 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1352 [inline] free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404 free_unref_page_prepare mm/page_alloc.c:3325 [inline] free_unref_page+0x19/0x690 mm/page_alloc.c:3404 release_pages+0x748/0x1220 mm/swap.c:956 tlb_batch_pages_flush mm/mmu_gather.c:50 [inline] tlb_flush_mmu_free mm/mmu_gather.c:243 [inline] tlb_flush_mmu+0xe9/0x6b0 mm/mmu_gather.c:250 zap_pte_range mm/memory.c:1441 [inline] zap_pmd_range mm/memory.c:1490 [inline] zap_pud_range mm/memory.c:1519 [inline] zap_p4d_range mm/memory.c:1540 [inline] unmap_page_range+0x1d1d/0x2a30 mm/memory.c:1561 unmap_single_vma+0x198/0x310 mm/memory.c:1606 unmap_vmas+0x16b/0x2f0 mm/memory.c:1638 exit_mmap+0x201/0x670 mm/mmap.c:3178 __mmput+0x122/0x4b0 kernel/fork.c:1114 mmput+0x56/0x60 kernel/fork.c:1135 exit_mm kernel/exit.c:507 [inline] do_exit+0xa3c/0x2a30 kernel/exit.c:793 do_group_exit+0xd2/0x2f0 kernel/exit.c:935 __do_sys_exit_group kernel/exit.c:946 [inline] __se_sys_exit_group kernel/exit.c:944 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:944 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Memory state around the buggy address: ffff8880985c4a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880985c4a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880985c4b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880985c4b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880985c4c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc Fixes: 470502de5bdb ("net: sched: unlock rules update API") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Vlad Buslov <vladbu@mellanox.com> Cc: Jiri Pirko <jiri@mellanox.com> Cc: Cong Wang <xiyou.wangcong@gmail.com> Reported-by: syzbot <syzkaller@googlegroups.com> Link: https://lore.kernel.org/r/20220131172018.3704490-1-eric.dumazet@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
0
static inline void tcp_slow_start_after_idle_check(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); s32 delta; if (!sysctl_tcp_slow_start_after_idle || tp->packets_out) return; delta = tcp_time_stamp - tp->lsndtime; if (delta > inet_csk(sk)->icsk_rto) tcp_cwnd_restart(sk, delta); }
Safe
[ "CWE-416", "CWE-269" ]
linux
bb1fceca22492109be12640d49f5ea5a544c6bb4
2.8375889820883902e+38
11
tcp: fix use after free in tcp_xmit_retransmit_queue() When tcp_sendmsg() allocates a fresh and empty skb, it puts it at the tail of the write queue using tcp_add_write_queue_tail() Then it attempts to copy user data into this fresh skb. If the copy fails, we undo the work and remove the fresh skb. Unfortunately, this undo lacks the change done to tp->highest_sack and we can leave a dangling pointer (to a freed skb) Later, tcp_xmit_retransmit_queue() can dereference this pointer and access freed memory. For regular kernels where memory is not unmapped, this might cause SACK bugs because tcp_highest_sack_seq() is buggy, returning garbage instead of tp->snd_nxt, but with various debug features like CONFIG_DEBUG_PAGEALLOC, this can crash the kernel. This bug was found by Marco Grassi thanks to syzkaller. Fixes: 6859d49475d4 ("[TCP]: Abstract tp->highest_sack accessing & point to next skb") Reported-by: Marco Grassi <marco.gra@gmail.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Cc: Yuchung Cheng <ycheng@google.com> Cc: Neal Cardwell <ncardwell@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Reviewed-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
0
transit_hash_key_make (void *p) { const struct transit * transit = p; return jhash(transit->val, transit->length, 0); }
Safe
[]
quagga
8794e8d229dc9fe29ea31424883433d4880ef408
1.727028553354305e+38
6
bgpd: Fix regression in args consolidation, total should be inited from args * bgp_attr.c: (bgp_attr_unknown) total should be initialised from the args.
0
rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts) { struct ring_buffer *buffer; struct ring_buffer_per_cpu *cpu_buffer; struct ring_buffer_event *event; int nr_loops = 0; cpu_buffer = iter->cpu_buffer; buffer = cpu_buffer->buffer; /* * Check if someone performed a consuming read to * the buffer. A consuming read invalidates the iterator * and we need to reset the iterator in this case. */ if (unlikely(iter->cache_read != cpu_buffer->read || iter->cache_reader_page != cpu_buffer->reader_page)) rb_iter_reset(iter); again: if (ring_buffer_iter_empty(iter)) return NULL; /* * We repeat when a time extend is encountered or we hit * the end of the page. Since the time extend is always attached * to a data event, we should never loop more than three times. * Once for going to next page, once on time extend, and * finally once to get the event. * (We never hit the following condition more than thrice). */ if (RB_WARN_ON(cpu_buffer, ++nr_loops > 3)) return NULL; if (rb_per_cpu_empty(cpu_buffer)) return NULL; if (iter->head >= rb_page_size(iter->head_page)) { rb_inc_iter(iter); goto again; } event = rb_iter_head_event(iter); switch (event->type_len) { case RINGBUF_TYPE_PADDING: if (rb_null_event(event)) { rb_inc_iter(iter); goto again; } rb_advance_iter(iter); return event; case RINGBUF_TYPE_TIME_EXTEND: /* Internal data, OK to advance */ rb_advance_iter(iter); goto again; case RINGBUF_TYPE_TIME_STAMP: /* FIXME: not implemented */ rb_advance_iter(iter); goto again; case RINGBUF_TYPE_DATA: if (ts) { *ts = iter->read_stamp + event->time_delta; ring_buffer_normalize_time_stamp(buffer, cpu_buffer->cpu, ts); } return event; default: BUG(); } return NULL; }
Safe
[ "CWE-190" ]
linux-stable
59643d1535eb220668692a5359de22545af579f6
6.151715993584182e+37
77
ring-buffer: Prevent overflow of size in ring_buffer_resize() If the size passed to ring_buffer_resize() is greater than MAX_LONG - BUF_PAGE_SIZE then the DIV_ROUND_UP() will return zero. Here's the details: # echo 18014398509481980 > /sys/kernel/debug/tracing/buffer_size_kb tracing_entries_write() processes this and converts kb to bytes. 18014398509481980 << 10 = 18446744073709547520 and this is passed to ring_buffer_resize() as unsigned long size. size = DIV_ROUND_UP(size, BUF_PAGE_SIZE); Where DIV_ROUND_UP(a, b) is (a + b - 1)/b BUF_PAGE_SIZE is 4080 and here 18446744073709547520 + 4080 - 1 = 18446744073709551599 where 18446744073709551599 is still smaller than 2^64 2^64 - 18446744073709551599 = 17 But now 18446744073709551599 / 4080 = 4521260802379792 and size = size * 4080 = 18446744073709551360 This is checked to make sure its still greater than 2 * 4080, which it is. Then we convert to the number of buffer pages needed. nr_page = DIV_ROUND_UP(size, BUF_PAGE_SIZE) but this time size is 18446744073709551360 and 2^64 - (18446744073709551360 + 4080 - 1) = -3823 Thus it overflows and the resulting number is less than 4080, which makes 3823 / 4080 = 0 an nr_pages is set to this. As we already checked against the minimum that nr_pages may be, this causes the logic to fail as well, and we crash the kernel. There's no reason to have the two DIV_ROUND_UP() (that's just result of historical code changes), clean up the code and fix this bug. Cc: stable@vger.kernel.org # 3.5+ Fixes: 83f40318dab00 ("ring-buffer: Make removal of ring buffer pages atomic") Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
0
static int rm_read_multi(AVFormatContext *s, AVIOContext *pb, AVStream *st, char *mime) { int number_of_streams = avio_rb16(pb); int number_of_mdpr; int i, ret; unsigned size2; for (i = 0; i<number_of_streams; i++) avio_rb16(pb); number_of_mdpr = avio_rb16(pb); if (number_of_mdpr != 1) { avpriv_request_sample(s, "MLTI with multiple (%d) MDPR", number_of_mdpr); } for (i = 0; i < number_of_mdpr; i++) { AVStream *st2; if (i > 0) { st2 = avformat_new_stream(s, NULL); if (!st2) { ret = AVERROR(ENOMEM); return ret; } st2->id = st->id + (i<<16); st2->codecpar->bit_rate = st->codecpar->bit_rate; st2->start_time = st->start_time; st2->duration = st->duration; st2->codecpar->codec_type = AVMEDIA_TYPE_DATA; st2->priv_data = ff_rm_alloc_rmstream(); if (!st2->priv_data) return AVERROR(ENOMEM); } else st2 = st; size2 = avio_rb32(pb); ret = ff_rm_read_mdpr_codecdata(s, s->pb, st2, st2->priv_data, size2, NULL); if (ret < 0) return ret; } return 0; }
Safe
[ "CWE-416" ]
FFmpeg
a7e032a277452366771951e29fd0bf2bd5c029f0
1.4836507020725888e+38
40
avformat/rmdec: Do not pass mime type in rm_read_multi() to ff_rm_read_mdpr_codecdata() Fixes: use after free() Fixes: rmdec-crash-ffe85b4cab1597d1cfea6955705e53f1f5c8a362 Found-by: Paul Ch <paulcher@icloud.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
0
TEST(RegexMatchExpression, MatchesElementMultilineOn) { BSONObj match = BSON("x" << "az"); BSONObj matchMultiline = BSON("x" << "\naz"); BSONObj notMatch = BSON("x" << "\n\n"); RegexMatchExpression regex("", "^a", "m"); ASSERT(regex.matchesSingleElement(match.firstElement())); ASSERT(regex.matchesSingleElement(matchMultiline.firstElement())); ASSERT(!regex.matchesSingleElement(notMatch.firstElement())); }
Safe
[]
mongo
64095239f41e9f3841d8be9088347db56d35c891
2.530414493930342e+38
12
SERVER-51083 Reject invalid UTF-8 from $regex match expressions
0
static void write_rle_data(TGAContext *ctx, TGAColor *color, guint *rle_count) { for (; *rle_count; (*rle_count)--) { g_memmove(ctx->pptr, (guchar *) color, ctx->pbuf->n_channels); ctx->pptr += ctx->pbuf->n_channels; ctx->pbuf_bytes_done += ctx->pbuf->n_channels; if (ctx->pbuf_bytes_done == ctx->pbuf_bytes) return; } }
Vulnerable
[ "CWE-119" ]
gdk-pixbuf
edf6fb8d856574bc3bb3a703037f56533229267c
1.2046606502868044e+38
10
tga: Wrap TGAColormap struct in its own API Instead of poking into it directly.
1
process_colour_pointer_common(STREAM s, int bpp) { uint16 width, height, cache_idx, masklen, datalen; uint16 x, y; uint8 *mask; uint8 *data; RD_HCURSOR cursor; in_uint16_le(s, cache_idx); in_uint16_le(s, x); in_uint16_le(s, y); in_uint16_le(s, width); in_uint16_le(s, height); in_uint16_le(s, masklen); in_uint16_le(s, datalen); in_uint8p(s, data, datalen); in_uint8p(s, mask, masklen); if ((width != 32) || (height != 32)) { warning("process_colour_pointer_common: " "width %d height %d\n", width, height); } /* keep hotspot within cursor bounding box */ x = MIN(x, width - 1); y = MIN(y, height - 1); cursor = ui_create_cursor(x, y, width, height, mask, data, bpp); ui_set_cursor(cursor); cache_put_cursor(cache_idx, cursor); }
Safe
[ "CWE-787" ]
rdesktop
766ebcf6f23ccfe8323ac10242ae6e127d4505d2
2.776107959185804e+38
29
Malicious RDP server security fixes This commit includes fixes for a set of 21 vulnerabilities in rdesktop when a malicious RDP server is used. All vulnerabilities was identified and reported by Eyal Itkin. * Add rdp_protocol_error function that is used in several fixes * Refactor of process_bitmap_updates * Fix possible integer overflow in s_check_rem() on 32bit arch * Fix memory corruption in process_bitmap_data - CVE-2018-8794 * Fix remote code execution in process_bitmap_data - CVE-2018-8795 * Fix remote code execution in process_plane - CVE-2018-8797 * Fix Denial of Service in mcs_recv_connect_response - CVE-2018-20175 * Fix Denial of Service in mcs_parse_domain_params - CVE-2018-20175 * Fix Denial of Service in sec_parse_crypt_info - CVE-2018-20176 * Fix Denial of Service in sec_recv - CVE-2018-20176 * Fix minor information leak in rdpdr_process - CVE-2018-8791 * Fix Denial of Service in cssp_read_tsrequest - CVE-2018-8792 * Fix remote code execution in cssp_read_tsrequest - CVE-2018-8793 * Fix Denial of Service in process_bitmap_data - CVE-2018-8796 * Fix minor information leak in rdpsnd_process_ping - CVE-2018-8798 * Fix Denial of Service in process_secondary_order - CVE-2018-8799 * Fix remote code execution in in ui_clip_handle_data - CVE-2018-8800 * Fix major information leak in ui_clip_handle_data - CVE-2018-20174 * Fix memory corruption in rdp_in_unistr - CVE-2018-20177 * Fix Denial of Service in process_demand_active - CVE-2018-20178 * Fix remote code execution in lspci_process - CVE-2018-20179 * Fix remote code execution in rdpsnddbg_process - CVE-2018-20180 * Fix remote code execution in seamless_process - CVE-2018-20181 * Fix remote code execution in seamless_process_line - CVE-2018-20182
0
static MagickBooleanType IsTXT(const unsigned char *magick,const size_t length) { char colorspace[MagickPathExtent]; ssize_t count; unsigned long columns, depth, rows; if (length < 40) return(MagickFalse); if (LocaleNCompare((const char *) magick,MagickTXTID, strlen(MagickTXTID)) != 0) return(MagickFalse); count=(ssize_t) sscanf((const char *) magick+32,"%lu,%lu,%lu,%32s",&columns, &rows,&depth,colorspace); if (count != 4) return(MagickFalse); return(MagickTrue); }
Safe
[ "CWE-190" ]
ImageMagick
f0a8d407b2801174fd8923941a9e7822f7f9a506
3.1717783507301933e+38
24
https://github.com/ImageMagick/ImageMagick/issues/1719
0
static int cmd_capability(struct imap_client *imap_client, const struct imap_arg *args ATTR_UNUSED) { struct client *client = &imap_client->common; /* Client is required to send CAPABILITY after STARTTLS, so the capability resp-code workaround checks only pre-STARTTLS CAPABILITY commands. */ if (!client->starttls) imap_client->client_ignores_capability_resp_code = TRUE; client_send_raw(client, t_strconcat( "* CAPABILITY ", get_capability(client), "\r\n", NULL)); client_send_reply(client, IMAP_CMD_REPLY_OK, "Pre-login capabilities listed, post-login capabilities have more."); return 1; }
Safe
[]
core
62061e8cf68f506c0ccaaba21fd4174764ca875f
1.5305648008485823e+38
16
imap-login: Split off client_invalid_command()
0
uint32 unix_dev_minor(SMB_DEV_T dev) { #if defined(HAVE_DEVICE_MINOR_FN) return (uint32)minor(dev); #else return (uint32)(dev & 0xff); #endif }
Safe
[ "CWE-20" ]
samba
d77a74237e660dd2ce9f1e14b02635f8a2569653
7.714823113911145e+37
8
s3: nmbd: Fix bug 10633 - nmbd denial of service The Linux kernel has a bug in that it can give spurious wakeups on a non-blocking UDP socket for a non-deliverable packet. When nmbd was changed to use non-blocking sockets it became vulnerable to a spurious wakeup from poll/epoll. Fix sys_recvfile() to return on EWOULDBLOCK/EAGAIN. CVE-2014-0244 https://bugzilla.samba.org/show_bug.cgi?id=10633 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
0
get_user_cmd_complete(expand_T *xp UNUSED, int idx) { return (char_u *)command_complete[idx].name; }
Safe
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
3.1346825122121683e+38
4
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.
0
fixstr(p) register char *p; { if (p == NULL) return; for (; *p != '\0'; p++) if (*p == 'N') *p = '\n'; else if (*p == 'T') *p = '\t'; else if (*p == 'S') *p = ' '; else if (*p == 'Z') *p = '\0'; }
Safe
[ "CWE-200" ]
mysql-server
0dbd5a8797ed4bd18e8b883988fb62177eb0f73f
2.707494261645315e+38
16
Bug#21973610: BUFFER OVERFLOW ISSUES Description : Incorrect usage of sprintf/strcpy caused possible buffer overflow issues at various places. Solution : - Fixed mysql_plugin and mysqlshow - Fixed regex library issues Reviewed-By : Georgi Kodinov <georgi.kodinov@oracle.com> Reviewed-By : Venkata S Murthy Sidagam <venkata.sidagam@oracle.com>
0
_archive_write_disk_close(struct archive *_a) { struct archive_write_disk *a = (struct archive_write_disk *)_a; struct fixup_entry *next, *p; int fd, ret; archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, "archive_write_disk_close"); ret = _archive_write_disk_finish_entry(&a->archive); /* Sort dir list so directories are fixed up in depth-first order. */ p = sort_dir_list(a->fixup_list); while (p != NULL) { fd = -1; a->pst = NULL; /* Mark stat cache as out-of-date. */ if (p->fixup & (TODO_TIMES | TODO_MODE_BASE | TODO_ACLS | TODO_FFLAGS)) { fd = open(p->name, O_WRONLY | O_BINARY | O_NOFOLLOW | O_CLOEXEC); } if (p->fixup & TODO_TIMES) { set_times(a, fd, p->mode, p->name, p->atime, p->atime_nanos, p->birthtime, p->birthtime_nanos, p->mtime, p->mtime_nanos, p->ctime, p->ctime_nanos); } if (p->fixup & TODO_MODE_BASE) { #ifdef HAVE_FCHMOD if (fd >= 0) fchmod(fd, p->mode); else #endif chmod(p->name, p->mode); } if (p->fixup & TODO_ACLS) archive_write_disk_set_acls(&a->archive, fd, p->name, &p->acl, p->mode); if (p->fixup & TODO_FFLAGS) set_fflags_platform(a, fd, p->name, p->mode, p->fflags_set, 0); if (p->fixup & TODO_MAC_METADATA) set_mac_metadata(a, p->name, p->mac_metadata, p->mac_metadata_size); next = p->next; archive_acl_clear(&p->acl); free(p->mac_metadata); free(p->name); if (fd >= 0) close(fd); free(p); p = next; } a->fixup_list = NULL; return (ret); }
Vulnerable
[ "CWE-59", "CWE-269" ]
libarchive
b41daecb5ccb4c8e3b2c53fd6147109fc12c3043
3.363171452269862e+38
58
Do not follow symlinks when processing the fixup list Use lchmod() instead of chmod() and tell the remaining functions that the real file to be modified is a symbolic link. Fixes #1566
1
TEST_F(RouterTest, RetryUpstreamConnectionFailure) { Http::ConnectionPool::Callbacks* conn_pool_callbacks; EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder&, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { conn_pool_callbacks = &callbacks; return nullptr; })); expectResponseTimerCreate(); Http::TestRequestHeaderMapImpl headers{{"x-envoy-retry-on", "5xx"}, {"x-envoy-internal", "true"}}; HttpTestUtility::addDefaultHeaders(headers); router_.decodeHeaders(headers, true); EXPECT_CALL(*router_.retry_state_, onHostAttempted(_)).Times(0); router_.retry_state_->expectResetRetry(); conn_pool_callbacks->onPoolFailure(ConnectionPool::PoolFailureReason::RemoteConnectionFailure, absl::string_view(), nullptr); // Pool failure, so no upstream request was made. EXPECT_EQ(0U, callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value()); Http::ResponseDecoder* response_decoder = nullptr; // We expect this reset to kick off a new request. NiceMock<Http::MockRequestEncoder> encoder2; EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _)) .WillOnce(Invoke( [&](Http::ResponseDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { response_decoder = &decoder; EXPECT_CALL(*router_.retry_state_, onHostAttempted(_)); callbacks.onPoolReady(encoder2, cm_.thread_local_cluster_.conn_pool_.host_, upstream_stream_info_, Http::Protocol::Http10); return nullptr; })); router_.retry_state_->callback_(); EXPECT_EQ(1U, callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value()); // Normal response. EXPECT_CALL(*router_.retry_state_, shouldRetryHeaders(_, _)).WillOnce(Return(RetryStatus::No)); Http::ResponseHeaderMapPtr response_headers( new Http::TestResponseHeaderMapImpl{{":status", "200"}}); EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_, putHttpResponseCode(200)); response_decoder->decodeHeaders(std::move(response_headers), true); EXPECT_TRUE(verifyHostUpstreamStats(1, 0)); }
Safe
[ "CWE-703" ]
envoy
18871dbfb168d3512a10c78dd267ff7c03f564c6
1.0546410860178379e+38
50
[1.18] CVE-2022-21655 Crash with direct_response Signed-off-by: Otto van der Schaaf <ovanders@redhat.com>
0
static int x509_get_key_usage( unsigned char **p, const unsigned char *end, unsigned int *key_usage) { int ret; size_t i; mbedtls_x509_bitstring bs = { 0, 0, NULL }; if( ( ret = mbedtls_asn1_get_bitstring( p, end, &bs ) ) != 0 ) return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); if( bs.len < 1 ) return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_INVALID_LENGTH ); /* Get actual bitstring */ *key_usage = 0; for( i = 0; i < bs.len && i < sizeof( unsigned int ); i++ ) { *key_usage |= (unsigned int) bs.p[i] << (8*i); } return( 0 ); }
Safe
[ "CWE-287", "CWE-284" ]
mbedtls
d15795acd5074e0b44e71f7ede8bdfe1b48591fc
7.374502848558175e+37
24
Improve behaviour on fatal errors If we didn't walk the whole chain, then there may be any kind of errors in the part of the chain we didn't check, so setting all flags looks like the safe thing to do.
0
static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_encrypt_change *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); hci_dev_lock(hdev); conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); if (!conn) goto unlock; if (!ev->status) { if (ev->encrypt) { /* Encryption implies authentication */ set_bit(HCI_CONN_AUTH, &conn->flags); set_bit(HCI_CONN_ENCRYPT, &conn->flags); conn->sec_level = conn->pending_sec_level; /* P-256 authentication key implies FIPS */ if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) set_bit(HCI_CONN_FIPS, &conn->flags); if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || conn->type == LE_LINK) set_bit(HCI_CONN_AES_CCM, &conn->flags); } else { clear_bit(HCI_CONN_ENCRYPT, &conn->flags); clear_bit(HCI_CONN_AES_CCM, &conn->flags); } } /* We should disregard the current RPA and generate a new one * whenever the encryption procedure fails. */ if (ev->status && conn->type == LE_LINK) { hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); hci_adv_instances_set_rpa_expired(hdev, true); } clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); if (ev->status && conn->state == BT_CONNECTED) { if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); hci_conn_drop(conn); goto unlock; } /* In Secure Connections Only mode, do not allow any connections * that are not encrypted with AES-CCM using a P-256 authenticated * combination key. */ if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); hci_conn_drop(conn); goto unlock; } /* Try reading the encryption key size for encrypted ACL links */ if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { struct hci_cp_read_enc_key_size cp; struct hci_request req; /* Only send HCI_Read_Encryption_Key_Size if the * controller really supports it. If it doesn't, assume * the default size (16). */ if (!(hdev->commands[20] & 0x10)) { conn->enc_key_size = HCI_LINK_KEY_SIZE; goto notify; } hci_req_init(&req, hdev); cp.handle = cpu_to_le16(conn->handle); hci_req_add(&req, HCI_OP_READ_ENC_KEY_SIZE, sizeof(cp), &cp); if (hci_req_run_skb(&req, read_enc_key_size_complete)) { bt_dev_err(hdev, "sending read key size failed"); conn->enc_key_size = HCI_LINK_KEY_SIZE; goto notify; } goto unlock; } /* Set the default Authenticated Payload Timeout after * an LE Link is established. As per Core Spec v5.0, Vol 2, Part B * Section 3.3, the HCI command WRITE_AUTH_PAYLOAD_TIMEOUT should be * sent when the link is active and Encryption is enabled, the conn * type can be either LE or ACL and controller must support LMP Ping. * Ensure for AES-CCM encryption as well. */ if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && test_bit(HCI_CONN_AES_CCM, &conn->flags) && ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { struct hci_cp_write_auth_payload_to cp; cp.handle = cpu_to_le16(conn->handle); cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, sizeof(cp), &cp); } notify: if (conn->state == BT_CONFIG) { if (!ev->status) conn->state = BT_CONNECTED; hci_connect_cfm(conn, ev->status); hci_conn_drop(conn); } else hci_encrypt_cfm(conn, ev->status, ev->encrypt); unlock: hci_dev_unlock(hdev); }
Vulnerable
[ "CWE-290" ]
linux
3ca44c16b0dcc764b641ee4ac226909f5c421aa3
1.8577777361609658e+38
124
Bluetooth: Consolidate encryption handling in hci_encrypt_cfm This makes hci_encrypt_cfm calls hci_connect_cfm in case the connection state is BT_CONFIG so callers don't have to check the state. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1
bool need_SSR(struct f2fs_sb_info *sbi) { int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES); int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS); int imeta_secs = get_blocktype_secs(sbi, F2FS_DIRTY_IMETA); if (test_opt(sbi, LFS)) return false; if (sbi->gc_thread && sbi->gc_thread->gc_urgent) return true; return free_sections(sbi) <= (node_secs + 2 * dent_secs + imeta_secs + 2 * reserved_sections(sbi)); }
Safe
[ "CWE-20" ]
linux
638164a2718f337ea224b747cf5977ef143166a4
3.3470613587420146e+38
14
f2fs: fix potential panic during fstrim As Ju Hyung Park reported: "When 'fstrim' is called for manual trim, a BUG() can be triggered randomly with this patch. I'm seeing this issue on both x86 Desktop and arm64 Android phone. On x86 Desktop, this was caused during Ubuntu boot-up. I have a cronjob installed which calls 'fstrim -v /' during boot. On arm64 Android, this was caused during GC looping with 1ms gc_min_sleep_time & gc_max_sleep_time." Root cause of this issue is that f2fs_wait_discard_bios can only be used by f2fs_put_super, because during put_super there must be no other referrers, so it can ignore discard entry's reference count when removing the entry, otherwise in other caller we will hit bug_on in __remove_discard_cmd as there may be other issuer added reference count in discard entry. Thread A Thread B - issue_discard_thread - f2fs_ioc_fitrim - f2fs_trim_fs - f2fs_wait_discard_bios - __issue_discard_cmd - __submit_discard_cmd - __wait_discard_cmd - dc->ref++ - __wait_one_discard_bio - __wait_discard_cmd - __remove_discard_cmd - f2fs_bug_on(sbi, dc->ref) Fixes: 969d1b180d987c2be02de890d0fff0f66a0e80de Reported-by: Ju Hyung Park <qkrwngud825@gmail.com> Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
0
desc_get_errstat(struct ioat2_dma_chan *ioat, struct ioat_ring_ent *desc) { struct ioat_dma_descriptor *hw = desc->hw; switch (hw->ctl_f.op) { case IOAT_OP_PQ_VAL: case IOAT_OP_PQ_VAL_16S: { struct ioat_pq_descriptor *pq = desc->pq; /* check if there's error written */ if (!pq->dwbes_f.wbes) return; /* need to set a chanerr var for checking to clear later */ if (pq->dwbes_f.p_val_err) *desc->result |= SUM_CHECK_P_RESULT; if (pq->dwbes_f.q_val_err) *desc->result |= SUM_CHECK_Q_RESULT; return; } default: return; } }
Safe
[]
linux
7bced397510ab569d31de4c70b39e13355046387
1.83487317303365e+38
28
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 <dave.jiang@intel.com> Cc: Vinod Koul <vinod.koul@intel.com> Cc: David Whipple <whipple@securedatainnovations.ch> Cc: Alexander Duyck <alexander.h.duyck@intel.com> Cc: <stable@vger.kernel.org> Reported-by: Roman Gushchin <klamm@yandex-team.ru> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
0
bool git_path_does_fs_decompose_unicode(const char *root) { GIT_UNUSED(root); return false; }
Safe
[ "CWE-20", "CWE-706" ]
libgit2
3f7851eadca36a99627ad78cbe56a40d3776ed01
3.0791467799632986e+38
5
Disallow NTFS Alternate Data Stream attacks, even on Linux/macOS A little-known feature of NTFS is that it offers to store metadata in so-called "Alternate Data Streams" (inspired by Apple's "resource forks") that are copied together with the file they are associated with. These Alternate Data Streams can be accessed via `<file name>:<stream name>:<stream type>`. Directories, too, have Alternate Data Streams, and they even have a default stream type `$INDEX_ALLOCATION`. Which means that `abc/` and `abc::$INDEX_ALLOCATION/` are actually equivalent. This is of course another attack vector on the Git directory that we definitely want to prevent. On Windows, we already do this incidentally, by disallowing colons in file/directory names. While it looks as if files'/directories' Alternate Data Streams are not accessible in the Windows Subsystem for Linux, and neither via CIFS/SMB-mounted network shares in Linux, it _is_ possible to access them on SMB-mounted network shares on macOS. Therefore, let's go the extra mile and prevent this particular attack _everywhere_. To keep things simple, let's just disallow *any* Alternate Data Stream of `.git`. This is libgit2's variant of CVE-2019-1352. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
0
void imap_cachepath(char delim, const char *mailbox, struct Buffer *dest) { const char *p = mailbox; mutt_buffer_reset(dest); if (!p) return; while (*p) { if (p[0] == delim) { mutt_buffer_addch(dest, '/'); /* simple way to avoid collisions with UIDs */ if ((p[1] >= '0') && (p[1] <= '9')) mutt_buffer_addch(dest, '_'); } else mutt_buffer_addch(dest, *p); p++; } }
Safe
[ "CWE-125" ]
neomutt
fa1db5785e5cfd9d3cd27b7571b9fe268d2ec2dc
2.563242269534531e+38
21
Fix seqset iterator when it ends in a comma If the seqset ended with a comma, the substr_end marker would be just before the trailing nul. In the next call, the loop to skip the marker would iterate right past the end of string too. The fix is simple: place the substr_end marker and skip past it immediately.
0
CoreAuthHandler::CoreAuthHandler(QTcpSocket *socket, QObject *parent) : AuthHandler(parent), _peer(0), _magicReceived(false), _legacy(false), _clientRegistered(false), _connectionFeatures(0) { setSocket(socket); connect(socket, SIGNAL(readyRead()), SLOT(onReadyRead())); // TODO: Timeout for the handshake phase }
Safe
[]
quassel
e67887343c433cc35bc26ad6a9392588f427e746
1.3365726040839144e+38
14
Handle invalid handshake data properly in the core Clients sending invalid handshake data could make the core crash due to an unchecked pointer. This commit fixes this issue by having the core close the socket if a peer could not be created. Thanks to Bas Pape (Tucos) for finding this one!
0
proto_tree_add_item_new(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb, const gint start, gint length, const guint encoding) { field_info *new_fi; gint item_length; DISSECTOR_ASSERT_HINT(hfinfo != NULL, "Not passed hfi!"); get_hfi_length(hfinfo, tvb, start, &length, &item_length, encoding); test_length(hfinfo, tvb, start, item_length, encoding); CHECK_FOR_NULL_TREE(tree); TRY_TO_FAKE_THIS_ITEM(tree, hfinfo->id, hfinfo); new_fi = new_field_info(tree, hfinfo, tvb, start, item_length); return proto_tree_new_item(new_fi, tree, tvb, start, length, encoding); }
Safe
[ "CWE-401" ]
wireshark
a9fc769d7bb4b491efb61c699d57c9f35269d871
2.040584808484456e+38
19
epan: Fix a memory leak. Make sure _proto_tree_add_bits_ret_val allocates a bits array using the packet scope, otherwise we leak memory. Fixes #17032.
0
static void keyring_link_rcu_disposal(struct rcu_head *rcu) { struct keyring_list *klist = container_of(rcu, struct keyring_list, rcu); kfree(klist); } /* end keyring_link_rcu_disposal() */
Safe
[ "CWE-362" ]
linux-2.6
cea7daa3589d6b550546a8c8963599f7c1a3ae5c
2.1786099689151714e+38
8
KEYS: find_keyring_by_name() can gain access to a freed keyring find_keyring_by_name() can gain access to a keyring that has had its reference count reduced to zero, and is thus ready to be freed. This then allows the dead keyring to be brought back into use whilst it is being destroyed. The following timeline illustrates the process: |(cleaner) (user) | | free_user(user) sys_keyctl() | | | | key_put(user->session_keyring) keyctl_get_keyring_ID() | || //=> keyring->usage = 0 | | |schedule_work(&key_cleanup_task) lookup_user_key() | || | | kmem_cache_free(,user) | | . |[KEY_SPEC_USER_KEYRING] | . install_user_keyrings() | . || | key_cleanup() [<= worker_thread()] || | | || | [spin_lock(&key_serial_lock)] |[mutex_lock(&key_user_keyr..mutex)] | | || | atomic_read() == 0 || | |{ rb_ease(&key->serial_node,) } || | | || | [spin_unlock(&key_serial_lock)] |find_keyring_by_name() | | ||| | keyring_destroy(keyring) ||[read_lock(&keyring_name_lock)] | || ||| | |[write_lock(&keyring_name_lock)] ||atomic_inc(&keyring->usage) | |. ||| *** GET freeing keyring *** | |. ||[read_unlock(&keyring_name_lock)] | || || | |list_del() |[mutex_unlock(&key_user_k..mutex)] | || | | |[write_unlock(&keyring_name_lock)] ** INVALID keyring is returned ** | | . | kmem_cache_free(,keyring) . | . | atomic_dec(&keyring->usage) v *** DESTROYED *** TIME If CONFIG_SLUB_DEBUG=y then we may see the following message generated: ============================================================================= BUG key_jar: Poison overwritten ----------------------------------------------------------------------------- INFO: 0xffff880197a7e200-0xffff880197a7e200. First byte 0x6a instead of 0x6b INFO: Allocated in key_alloc+0x10b/0x35f age=25 cpu=1 pid=5086 INFO: Freed in key_cleanup+0xd0/0xd5 age=12 cpu=1 pid=10 INFO: Slab 0xffffea000592cb90 objects=16 used=2 fp=0xffff880197a7e200 flags=0x200000000000c3 INFO: Object 0xffff880197a7e200 @offset=512 fp=0xffff880197a7e300 Bytes b4 0xffff880197a7e1f0: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZZZZZZZZZ Object 0xffff880197a7e200: 6a 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b jkkkkkkkkkkkkkkk Alternatively, we may see a system panic happen, such as: BUG: unable to handle kernel NULL pointer dereference at 0000000000000001 IP: [<ffffffff810e61a3>] kmem_cache_alloc+0x5b/0xe9 PGD 6b2b4067 PUD 6a80d067 PMD 0 Oops: 0000 [#1] SMP last sysfs file: /sys/kernel/kexec_crash_loaded CPU 1 ... Pid: 31245, comm: su Not tainted 2.6.34-rc5-nofixed-nodebug #2 D2089/PRIMERGY RIP: 0010:[<ffffffff810e61a3>] [<ffffffff810e61a3>] kmem_cache_alloc+0x5b/0xe9 RSP: 0018:ffff88006af3bd98 EFLAGS: 00010002 RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffff88007d19900b RDX: 0000000100000000 RSI: 00000000000080d0 RDI: ffffffff81828430 RBP: ffffffff81828430 R08: ffff88000a293750 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000100000 R12: 00000000000080d0 R13: 00000000000080d0 R14: 0000000000000296 R15: ffffffff810f20ce FS: 00007f97116bc700(0000) GS:ffff88000a280000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000001 CR3: 000000006a91c000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process su (pid: 31245, threadinfo ffff88006af3a000, task ffff8800374414c0) Stack: 0000000512e0958e 0000000000008000 ffff880037f8d180 0000000000000001 0000000000000000 0000000000008001 ffff88007d199000 ffffffff810f20ce 0000000000008000 ffff88006af3be48 0000000000000024 ffffffff810face3 Call Trace: [<ffffffff810f20ce>] ? get_empty_filp+0x70/0x12f [<ffffffff810face3>] ? do_filp_open+0x145/0x590 [<ffffffff810ce208>] ? tlb_finish_mmu+0x2a/0x33 [<ffffffff810ce43c>] ? unmap_region+0xd3/0xe2 [<ffffffff810e4393>] ? virt_to_head_page+0x9/0x2d [<ffffffff81103916>] ? alloc_fd+0x69/0x10e [<ffffffff810ef4ed>] ? do_sys_open+0x56/0xfc [<ffffffff81008a02>] ? system_call_fastpath+0x16/0x1b Code: 0f 1f 44 00 00 49 89 c6 fa 66 0f 1f 44 00 00 65 4c 8b 04 25 60 e8 00 00 48 8b 45 00 49 01 c0 49 8b 18 48 85 db 74 0d 48 63 45 18 <48> 8b 04 03 49 89 00 eb 14 4c 89 f9 83 ca ff 44 89 e6 48 89 ef RIP [<ffffffff810e61a3>] kmem_cache_alloc+0x5b/0xe9 This problem is that find_keyring_by_name does not confirm that the keyring is valid before accepting it. Skipping keyrings that have been reduced to a zero count seems the way to go. To this end, use atomic_inc_not_zero() to increment the usage count and skip the candidate keyring if that returns false. The following script _may_ cause the bug to happen, but there's no guarantee as the window of opportunity is small: #!/bin/sh LOOP=100000 USER=dummy_user /bin/su -c "exit;" $USER || { /usr/sbin/adduser -m $USER; add=1; } for ((i=0; i<LOOP; i++)) do /bin/su -c "echo '$i' > /dev/null" $USER done (( add == 1 )) && /usr/sbin/userdel -r $USER exit Note that the nominated user must not be in use. An alternative way of testing this may be: for ((i=0; i<100000; i++)) do keyctl session foo /bin/true || break done >&/dev/null as that uses a keyring named "foo" rather than relying on the user and user-session named keyrings. Reported-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Signed-off-by: David Howells <dhowells@redhat.com> Tested-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
0
DeepTiledInputFile::levelMode () const { return _data->tileDesc.mode; }
Safe
[ "CWE-125" ]
openexr
e79d2296496a50826a15c667bf92bdc5a05518b4
2.3946865484160896e+38
4
fix memory leaks and invalid memory accesses Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
0
dump_all_config_trees( FILE *df, int comment ) { config_tree * cfg_ptr; int return_value; return_value = 0; for (cfg_ptr = cfg_tree_history; cfg_ptr != NULL; cfg_ptr = cfg_ptr->link) return_value |= dump_config_tree(cfg_ptr, df, comment); return return_value; }
Safe
[ "CWE-19" ]
ntp
fe46889f7baa75fc8e6c0fcde87706d396ce1461
1.02107206439515e+38
16
[Sec 2942]: Off-path DoS attack on auth broadcast mode. HStenn.
0
void preempt_notifier_dec(void) { static_key_slow_dec(&preempt_notifier_key); }
Safe
[ "CWE-119" ]
linux
29d6455178a09e1dc340380c582b13356227e8df
2.5846511020547724e+38
4
sched: panic on corrupted stack end Until now, hitting this BUG_ON caused a recursive oops (because oops handling involves do_exit(), which calls into the scheduler, which in turn raises an oops), which caused stuff below the stack to be overwritten until a panic happened (e.g. via an oops in interrupt context, caused by the overwritten CPU index in the thread_info). Just panic directly. Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
static inline struct device *vop_dev(struct vop_vdev *vdev) { return vdev->vpdev->dev.parent; }
Safe
[ "CWE-119", "CWE-787" ]
linux
9bf292bfca94694a721449e3fd752493856710f6
1.753532082220749e+38
4
misc: mic: Fix for double fetch security bug in VOP driver The MIC VOP driver does two successive reads from user space to read a variable length data structure. Kernel memory corruption can result if the data structure changes between the two reads. This patch disallows the chance of this happening. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116651 Reported by: Pengfei Wang <wpengfeinudt@gmail.com> Reviewed-by: Sudeep Dutt <sudeep.dutt@intel.com> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0
static ssize_t cpu_release_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { ssize_t cnt; int ret; ret = lock_device_hotplug_sysfs(); if (ret) return ret; cnt = arch_cpu_release(buf, count); unlock_device_hotplug(); return cnt; }
Safe
[ "CWE-787" ]
linux
aa838896d87af561a33ecefea1caa4c15a68bc47
1.805310300681283e+38
17
drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions Convert the various sprintf fmaily calls in sysfs device show functions to sysfs_emit and sysfs_emit_at for PAGE_SIZE buffer safety. Done with: $ spatch -sp-file sysfs_emit_dev.cocci --in-place --max-width=80 . And cocci script: $ cat sysfs_emit_dev.cocci @@ identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - sprintf(buf, + sysfs_emit(buf, ...); ...> } @@ identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ identifier d_show; identifier dev, attr, buf; expression chr; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - strcpy(buf, chr); + sysfs_emit(buf, chr); ...> } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - sprintf(buf, + sysfs_emit(buf, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... - len += scnprintf(buf + len, PAGE_SIZE - len, + len += sysfs_emit_at(buf, len, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; expression chr; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { ... - strcpy(buf, chr); - return strlen(buf); + return sysfs_emit(buf, chr); } Signed-off-by: Joe Perches <joe@perches.com> Link: https://lore.kernel.org/r/3d033c33056d88bbe34d4ddb62afd05ee166ab9a.1600285923.git.joe@perches.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0
static void annotation_get_fromfile(annotate_state_t *state, struct annotate_entry_list *entry) { const char *filename = (const char *) entry->desc->rock; char path[MAX_MAILBOX_PATH+1]; struct buf value = BUF_INITIALIZER; FILE *f; snprintf(path, sizeof(path), "%s/msg/%s", config_dir, filename); if ((f = fopen(path, "r")) && buf_getline(&value, f)) { /* TODO: we need a buf_chomp() */ if (value.s[value.len-1] == '\r') buf_truncate(&value, value.len-1); } if (f) fclose(f); output_entryatt(state, entry->name, "", &value); buf_free(&value); }
Safe
[ "CWE-732" ]
cyrus-imapd
621f9e41465b521399f691c241181300fab55995
2.208627588981489e+38
19
annotate: don't allow everyone to write shared server entries
0
static void nfs4_layoutcommit_prepare(struct rpc_task *task, void *calldata) { struct nfs4_layoutcommit_data *data = calldata; struct nfs_server *server = NFS_SERVER(data->args.inode); if (nfs4_setup_sequence(server, &data->args.seq_args, &data->res.seq_res, 1, task)) return; rpc_call_start(task); }
Safe
[ "CWE-703", "CWE-189" ]
linux
bf118a342f10dafe44b14451a1392c3254629a1f
2.472960702101347e+38
10
NFSv4: include bitmap in nfsv4 get acl data The NFSv4 bitmap size is unbounded: a server can return an arbitrary sized bitmap in an FATTR4_WORD0_ACL request. Replace using the nfs4_fattr_bitmap_maxsz as a guess to the maximum bitmask returned by a server with the inclusion of the bitmap (xdr length plus bitmasks) and the acl data xdr length to the (cached) acl page data. This is a general solution to commit e5012d1f "NFSv4.1: update nfs4_fattr_bitmap_maxsz" and fixes hitting a BUG_ON in xdr_shrink_bufhead when getting ACLs. Fix a bug in decode_getacl that returned -EINVAL on ACLs > page when getxattr was called with a NULL buffer, preventing ACL > PAGE_SIZE from being retrieved. Cc: stable@kernel.org Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0
static struct buffer_head *udf_getblk(struct inode *inode, udf_pblk_t block, int create, int *err) { struct buffer_head *bh; struct buffer_head dummy; dummy.b_state = 0; dummy.b_blocknr = -1000; *err = udf_get_block(inode, block, &dummy, create); if (!*err && buffer_mapped(&dummy)) { bh = sb_getblk(inode->i_sb, dummy.b_blocknr); if (buffer_new(&dummy)) { lock_buffer(bh); memset(bh->b_data, 0x00, inode->i_sb->s_blocksize); set_buffer_uptodate(bh); unlock_buffer(bh); mark_buffer_dirty_inode(bh, inode); } return bh; } return NULL; }
Safe
[ "CWE-476" ]
linux
7fc3b7c2981bbd1047916ade327beccb90994eee
3.363679596568448e+38
23
udf: Fix NULL ptr deref when converting from inline format udf_expand_file_adinicb() calls directly ->writepage to write data expanded into a page. This however misses to setup inode for writeback properly and so we can crash on inode->i_wb dereference when submitting page for IO like: BUG: kernel NULL pointer dereference, address: 0000000000000158 #PF: supervisor read access in kernel mode ... <TASK> __folio_start_writeback+0x2ac/0x350 __block_write_full_page+0x37d/0x490 udf_expand_file_adinicb+0x255/0x400 [udf] udf_file_write_iter+0xbe/0x1b0 [udf] new_sync_write+0x125/0x1c0 vfs_write+0x28e/0x400 Fix the problem by marking the page dirty and going through the standard writeback path to write the page. Strictly speaking we would not even have to write the page but we want to catch e.g. ENOSPC errors early. Reported-by: butt3rflyh4ck <butterflyhuangxx@gmail.com> CC: stable@vger.kernel.org Fixes: 52ebea749aae ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks") Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
0
InSliceInfo::InSliceInfo (PixelType tifb, char * b, PixelType tifl, size_t xpst, size_t ypst, size_t spst, int xsm, int ysm, bool f, bool s, double fv) : typeInFrameBuffer (tifb), typeInFile (tifl), base(b), xPointerStride (xpst), yPointerStride (ypst), sampleStride (spst), xSampling (xsm), ySampling (ysm), fill (f), skip (s), fillValue (fv) { // empty }
Safe
[ "CWE-125" ]
openexr
e79d2296496a50826a15c667bf92bdc5a05518b4
2.4787684438680197e+38
24
fix memory leaks and invalid memory accesses Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
0
rc_free_srcgtag_profile(gs_memory_t * mem, void *ptr_in, client_name_t cname) { cmm_srcgtag_profile_t *srcgtag_profile = (cmm_srcgtag_profile_t *)ptr_in; int k; gs_memory_t *mem_nongc = srcgtag_profile->memory; if (srcgtag_profile->rc.ref_count <= 1 ) { /* Decrement any profiles. */ for (k = 0; k < NUM_SOURCE_PROFILES; k++) { if (srcgtag_profile->gray_profiles[k] != NULL) { rc_decrement(srcgtag_profile->gray_profiles[k], "rc_free_srcgtag_profile(gray)"); } if (srcgtag_profile->rgb_profiles[k] != NULL) { rc_decrement(srcgtag_profile->rgb_profiles[k], "rc_free_srcgtag_profile(rgb)"); } if (srcgtag_profile->cmyk_profiles[k] != NULL) { rc_decrement(srcgtag_profile->cmyk_profiles[k], "rc_free_srcgtag_profile(cmyk)"); } if (srcgtag_profile->color_warp_profile != NULL) { rc_decrement(srcgtag_profile->color_warp_profile, "rc_free_srcgtag_profile(warp)"); } } gs_free_object(mem_nongc, srcgtag_profile->name, "rc_free_srcgtag_profile"); gs_free_object(mem_nongc, srcgtag_profile, "rc_free_srcgtag_profile"); } }
Safe
[]
ghostpdl
6d444c273da5499a4cd72f21cb6d4c9a5256807d
6.079454249965147e+37
30
Bug 697178: Add a file permissions callback For the rare occasions when the graphics library directly opens a file (currently for reading), this allows us to apply any restrictions on file access normally applied in the interpteter.
0
ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */ ecma_string_t *string2_p) /**< second ecma-string */ { JERRY_ASSERT (string1_p != NULL && string2_p != NULL); if (JERRY_UNLIKELY (ecma_string_is_empty (string1_p))) { ecma_ref_ecma_string (string2_p); return string2_p; } else if (JERRY_UNLIKELY (ecma_string_is_empty (string2_p))) { return string1_p; } lit_utf8_size_t cesu8_string2_size; lit_utf8_size_t cesu8_string2_length; lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32]; uint8_t flags = ECMA_STRING_FLAG_IS_ASCII; const lit_utf8_byte_t *cesu8_string2_p = ecma_string_get_chars (string2_p, &cesu8_string2_size, &cesu8_string2_length, uint32_to_string_buffer, &flags); JERRY_ASSERT (cesu8_string2_p != NULL); ecma_string_t *result_p = ecma_append_chars_to_string (string1_p, cesu8_string2_p, cesu8_string2_size, cesu8_string2_length); JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED)); return result_p; } /* ecma_concat_ecma_strings */
Safe
[ "CWE-416" ]
jerryscript
3bcd48f72d4af01d1304b754ef19fe1a02c96049
4.280638875412646e+37
37
Improve parse_identifier (#4691) Ascii string length is no longer computed during string allocation. JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz batizjob@gmail.com
0
void Compute(OpKernelContext* const context) override { core::RefCountPtr<BoostedTreesEnsembleResource> resource; // Get the resource. OP_REQUIRES_OK(context, LookupResource(context, HandleFromInput(context, 0), &resource)); // Get the inputs. OpInputList bucketized_features_list; OP_REQUIRES_OK(context, context->input_list("bucketized_features", &bucketized_features_list)); std::vector<tensorflow::TTypes<int32>::ConstMatrix> bucketized_features; bucketized_features.reserve(bucketized_features_list.size()); ConvertVectorsToMatrices(bucketized_features_list, bucketized_features); const int batch_size = bucketized_features[0].dimension(0); // Allocate outputs. Tensor* output_logits_t = nullptr; OP_REQUIRES_OK(context, context->allocate_output( "logits", {batch_size, logits_dimension_}, &output_logits_t)); auto output_logits = output_logits_t->matrix<float>(); // Return zero logits if it's an empty ensemble. if (resource->num_trees() <= 0) { output_logits.setZero(); return; } const int32 last_tree = resource->num_trees() - 1; auto do_work = [&resource, &bucketized_features, &output_logits, last_tree, this](int32 start, int32 end) { for (int32 i = start; i < end; ++i) { std::vector<float> tree_logits(logits_dimension_, 0.0); int32 tree_id = 0; int32 node_id = 0; while (true) { if (resource->is_leaf(tree_id, node_id)) { const float tree_weight = resource->GetTreeWeight(tree_id); const auto& leaf_logits = resource->node_value(tree_id, node_id); DCHECK_EQ(leaf_logits.size(), logits_dimension_); for (int32 j = 0; j < logits_dimension_; ++j) { tree_logits[j] += tree_weight * leaf_logits[j]; } // Stop if it was the last tree. if (tree_id == last_tree) { break; } // Move onto other trees. ++tree_id; node_id = 0; } else { node_id = resource->next_node(tree_id, node_id, i, bucketized_features); } } for (int32 j = 0; j < logits_dimension_; ++j) { output_logits(i, j) = tree_logits[j]; } } }; // 10 is the magic number. The actual number might depend on (the number of // layers in the trees) and (cpu cycles spent on each layer), but this // value would work for many cases. May be tuned later. const int64 cost = (last_tree + 1) * 10; thread::ThreadPool* const worker_threads = context->device()->tensorflow_cpu_worker_threads()->workers; Shard(worker_threads->NumThreads(), worker_threads, batch_size, /*cost_per_unit=*/cost, do_work); }
Vulnerable
[ "CWE-703", "CWE-197" ]
tensorflow
ca8c013b5e97b1373b3bb1c97ea655e69f31a575
8.323212861116911e+37
69
Prevent integer truncation from 64 to 32 bits. The `tensorflow::Shard` functions last argument must be a 2 argument function where both arguments are `int64` (`long long`, 64 bits). However, there are usages where code passes in a function where arguments are `int` or `int32` (32 bits). In these cases, it is possible that the integer truncation would later cause a segfault or other unexpected behavior. PiperOrigin-RevId: 332560414 Change-Id: Ief649406babc8d4f60b3e7a9d573cbcc5ce5b767
1
int security_msg_queue_msgctl(struct msg_queue *msq, int cmd) { return security_ops->msg_queue_msgctl(msq, cmd); }
Safe
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
1.1185212434821802e+38
4
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: James Morris <jmorris@namei.org>
0
void kick_recovery_queue() { Mutex::Locker l(recovery_lock); _maybe_queue_recovery(); }
Safe
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
4.92628437689456e+37
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 <sage@redhat.com> (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()
0
static int inSymtab(HtPP *hash, const char *name, ut64 addr) { bool found = false; char *key = rz_str_newf("%" PFMT64x ".%s", addr, name); ht_pp_find(hash, key, &found); if (found) { free(key); return true; } ht_pp_insert(hash, key, "1"); free(key); return false; }
Safe
[ "CWE-787" ]
rizin
348b1447d1452f978b69631d6de5b08dd3bdf79d
2.1373153898106987e+38
12
fix #2956 - oob write in mach0.c
0
static void tulip_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->realize = pci_tulip_realize; k->exit = pci_tulip_exit; k->vendor_id = PCI_VENDOR_ID_DEC; k->device_id = PCI_DEVICE_ID_DEC_21143; k->subsystem_vendor_id = 0x103c; k->subsystem_id = 0x104f; k->class_id = PCI_CLASS_NETWORK_ETHERNET; dc->vmsd = &vmstate_pci_tulip; device_class_set_props(dc, tulip_properties); dc->reset = tulip_qdev_reset; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); }
Safe
[ "CWE-787" ]
qemu
8ffb7265af64ec81748335ec8f20e7ab542c3850
1.034841942170232e+38
17
net: tulip: check frame size and r/w data length Tulip network driver while copying tx/rx buffers does not check frame size against r/w data length. This may lead to OOB buffer access. Add check to avoid it. Limit iterations over descriptors to avoid potential infinite loop issue in tulip_xmit_list_update. Reported-by: Li Qiang <pangpei.lq@antfin.com> Reported-by: Ziming Zhang <ezrakiez@gmail.com> Reported-by: Jason Wang <jasowang@redhat.com> Tested-by: Li Qiang <liq3ea@gmail.com> Reviewed-by: Li Qiang <liq3ea@gmail.com> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
0
void wait_for_other(int fd) { //**************************** // wait for the parent to be initialized //**************************** char childstr[BUFLEN + 1]; int newfd = dup(fd); if (newfd == -1) errExit("dup"); FILE* stream; stream = fdopen(newfd, "r"); *childstr = '\0'; if (fgets(childstr, BUFLEN, stream)) { // remove \n) char *ptr = childstr; while(*ptr !='\0' && *ptr != '\n') ptr++; if (*ptr == '\0') errExit("fgets"); *ptr = '\0'; } else { fprintf(stderr, "Error: cannot establish communication with the parent, exiting...\n"); exit(1); } fclose(stream); }
Safe
[ "CWE-284", "CWE-269" ]
firejail
903fd8a0789ca3cc3c21d84cd0282481515592ef
3.048089951212899e+37
26
security fix
0
static int h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s) { int error; if (!h2c->dfl) { error = H2_ERR_PROTOCOL_ERROR; // empty headers frame! goto strm_err; } if (!h2c->dbuf->size) return 0; // empty buffer if (h2c->dbuf->i < h2c->dfl && h2c->dbuf->i < h2c->dbuf->size) return 0; // incomplete frame /* now either the frame is complete or the buffer is complete */ if (h2s->st != H2_SS_IDLE) { /* FIXME: stream already exists, this is only allowed for * trailers (not supported for now). */ error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } else if (h2c->dsi <= h2c->max_id || !(h2c->dsi & 1)) { /* RFC7540#5.1.1 stream id > prev ones, and must be odd here */ error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } h2s = h2c_stream_new(h2c, h2c->dsi); if (!h2s) { error = H2_ERR_INTERNAL_ERROR; goto conn_err; } h2s->st = H2_SS_OPEN; if (h2c->dff & H2_F_HEADERS_END_STREAM) { h2s->st = H2_SS_HREM; h2s->flags |= H2_SF_ES_RCVD; } /* call the upper layers to process the frame, then let the upper layer * notify the stream about any change. */ h2s->cs->data_cb->recv(h2s->cs); if (h2s->cs->data_cb->wake(h2s->cs) < 0) { /* FIXME: cs has already been destroyed, but we have to kill h2s. */ error = H2_ERR_INTERNAL_ERROR; goto conn_err; } if (h2c->st0 >= H2_CS_ERROR) return 0; if (h2s->st >= H2_SS_ERROR) { /* stream error : send RST_STREAM */ h2c->st0 = H2_CS_FRAME_E; } else { /* update the max stream ID if the request is being processed */ if (h2s->id > h2c->max_id) h2c->max_id = h2s->id; } return 1; conn_err: h2c_error(h2c, error); return 0; strm_err: if (h2s) { h2s_error(h2s, error); h2c->st0 = H2_CS_FRAME_E; } else h2c_error(h2c, error); return 0; }
Safe
[ "CWE-119" ]
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
1.2670552663453143e+38
80
BUG/CRITICAL: h2: fix incorrect frame length check The incoming H2 frame length was checked against the max_frame_size setting instead of being checked against the bufsize. The max_frame_size only applies to outgoing traffic and not to incoming one, so if a large enough frame size is advertised in the SETTINGS frame, a wrapped frame will be defragmented into a temporary allocated buffer where the second fragment my overflow the heap by up to 16 kB. It is very unlikely that this can be exploited for code execution given that buffers are very short lived and their address not realistically predictable in production, but the likeliness of an immediate crash is absolutely certain. This fix must be backported to 1.8. Many thanks to Jordan Zebor from F5 Networks for reporting this issue in a responsible way.
0
static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; OPJ_UINT32 index = 0; if (!pi->first) { comp = &pi->comps[pi->compno]; res = &comp->resolutions[pi->resno]; goto LABEL_SKIP; } else { pi->first = 0; } for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) { for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) { for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) { comp = &pi->comps[pi->compno]; if (pi->resno >= comp->numresolutions) { continue; } res = &comp->resolutions[pi->resno]; if (!pi->tp_on) { pi->poc.precno1 = res->pw * res->ph; } for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (index >= pi->include_size) { opj_event_msg(pi->manager, EVT_ERROR, "Invalid access to pi->include"); return OPJ_FALSE; } if (!pi->include[index]) { pi->include[index] = 1; return OPJ_TRUE; } LABEL_SKIP: ; } } } } return OPJ_FALSE; }
Vulnerable
[ "CWE-125" ]
openjpeg
8f5aff1dff510a964d3901d0fba281abec98ab63
1.962574193009188e+38
45
pi.c: avoid out of bounds access with POC (fixes #1302)
1
void md_reap_sync_thread(struct mddev *mddev) { struct md_rdev *rdev; /* resync has finished, collect result */ md_unregister_thread(&mddev->sync_thread); if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { /* success...*/ /* activate any spares */ if (mddev->pers->spare_active(mddev)) { sysfs_notify(&mddev->kobj, NULL, "degraded"); set_bit(MD_CHANGE_DEVS, &mddev->flags); } } if (mddev_is_clustered(mddev)) md_cluster_ops->metadata_update_start(mddev); if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && mddev->pers->finish_reshape) mddev->pers->finish_reshape(mddev); /* If array is no-longer degraded, then any saved_raid_disk * information must be scrapped. */ if (!mddev->degraded) rdev_for_each(rdev, mddev) rdev->saved_raid_disk = -1; md_update_sb(mddev, 1); if (mddev_is_clustered(mddev)) md_cluster_ops->metadata_update_finish(mddev); clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); clear_bit(MD_RECOVERY_DONE, &mddev->recovery); clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); clear_bit(MD_RECOVERY_CHECK, &mddev->recovery); wake_up(&resync_wait); /* flag recovery needed just to double check */ set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); sysfs_notify_dirent_safe(mddev->sysfs_action); md_new_event(mddev); if (mddev->event_work.func) queue_work(md_misc_wq, &mddev->event_work); }
Safe
[ "CWE-200" ]
linux
b6878d9e03043695dbf3fa1caa6dfc09db225b16
3.081188260134788e+38
46
md: use kzalloc() when bitmap is disabled In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a mdu_bitmap_file_t called "file". 5769 file = kmalloc(sizeof(*file), GFP_NOIO); 5770 if (!file) 5771 return -ENOMEM; This structure is copied to user space at the end of the function. 5786 if (err == 0 && 5787 copy_to_user(arg, file, sizeof(*file))) 5788 err = -EFAULT But if bitmap is disabled only the first byte of "file" is initialized with zero, so it's possible to read some bytes (up to 4095) of kernel space memory from user space. This is an information leak. 5775 /* bitmap disabled, zero the first byte and copy out */ 5776 if (!mddev->bitmap_info.file) 5777 file->pathname[0] = '\0'; Signed-off-by: Benjamin Randazzo <benjamin@randazzo.fr> Signed-off-by: NeilBrown <neilb@suse.com>
0
virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node) { virDomainRedirFilterUSBDevDefPtr def; g_autofree char *class = NULL; g_autofree char *vendor = NULL; g_autofree char *product = NULL; g_autofree char *version = NULL; g_autofree char *allow = NULL; if (VIR_ALLOC(def) < 0) return NULL; class = virXMLPropString(node, "class"); if (class) { if ((virStrToLong_i(class, NULL, 0, &def->usbClass)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Cannot parse USB Class code %s"), class); goto error; } if (def->usbClass != -1 && def->usbClass &~ 0xFF) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid USB Class code %s"), class); goto error; } } else { def->usbClass = -1; } vendor = virXMLPropString(node, "vendor"); if (vendor) { if ((virStrToLong_i(vendor, NULL, 0, &def->vendor)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Cannot parse USB vendor ID %s"), vendor); goto error; } } else { def->vendor = -1; } product = virXMLPropString(node, "product"); if (product) { if ((virStrToLong_i(product, NULL, 0, &def->product)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Cannot parse USB product ID %s"), product); goto error; } } else { def->product = -1; } version = virXMLPropString(node, "version"); if (version) { if (STREQ(version, "-1")) def->version = -1; else if ((virDomainRedirFilterUSBVersionHelper(version, def)) < 0) goto error; } else { def->version = -1; } allow = virXMLPropString(node, "allow"); if (allow) { if (virStringParseYesNo(allow, &def->allow) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid allow value, either 'yes' or 'no'")); goto error; } } else { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing allow attribute for USB redirection filter")); goto error; } return def; error: VIR_FREE(def); return NULL; }
Safe
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
1.5021343237749275e+38
80
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 <hhan@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
0
static int l2cap_check_fcs(struct l2cap_chan *chan, struct sk_buff *skb) { u16 our_fcs, rcv_fcs; int hdr_size; if (test_bit(FLAG_EXT_CTRL, &chan->flags)) hdr_size = L2CAP_EXT_HDR_SIZE; else hdr_size = L2CAP_ENH_HDR_SIZE; if (chan->fcs == L2CAP_FCS_CRC16) { skb_trim(skb, skb->len - L2CAP_FCS_SIZE); rcv_fcs = get_unaligned_le16(skb->data + skb->len); our_fcs = crc16(0, skb->data - hdr_size, skb->len + hdr_size); if (our_fcs != rcv_fcs) return -EBADMSG; } return 0; }
Safe
[ "CWE-787" ]
linux
e860d2c904d1a9f38a24eb44c9f34b8f915a6ea3
1.9461167909002205e+38
20
Bluetooth: Properly check L2CAP config option output buffer length Validate the output buffer length for L2CAP config requests and responses to avoid overflowing the stack buffer used for building the option blocks. Cc: stable@vger.kernel.org Signed-off-by: Ben Seri <ben@armis.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb) { struct sockaddr_in sin = { .sin_family = AF_INET, .sin_port = htons(AUN_PORT), .sin_addr = {.s_addr = addr} }; struct aunhdr ah = {.code = code, .cb = cb, .handle = seq}; struct kvec iov = {.iov_base = (void *)&ah, .iov_len = sizeof(ah)}; struct msghdr udpmsg; udpmsg.msg_name = (void *)&sin; udpmsg.msg_namelen = sizeof(sin); udpmsg.msg_control = NULL; udpmsg.msg_controllen = 0; udpmsg.msg_flags=0; kernel_sendmsg(udpsock, &udpmsg, &iov, 1, sizeof(ah)); }
Safe
[ "CWE-200" ]
linux-2.6
80922bbb12a105f858a8f0abb879cb4302d0ecaa
2.3702985761624847e+38
19
econet: Fix econet_getname() leak econet_getname() can leak kernel memory to user. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
0
compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr, unsigned int *size, const char *name, struct xt_table_info *newinfo, unsigned char *base) { struct xt_entry_target *t; struct ip6t_entry *de; unsigned int origsize; int ret, h; struct xt_entry_match *ematch; ret = 0; origsize = *size; de = (struct ip6t_entry *)*dstptr; memcpy(de, e, sizeof(struct ip6t_entry)); memcpy(&de->counters, &e->counters, sizeof(e->counters)); *dstptr += sizeof(struct ip6t_entry); *size += sizeof(struct ip6t_entry) - sizeof(struct compat_ip6t_entry); xt_ematch_foreach(ematch, e) { ret = xt_compat_match_from_user(ematch, dstptr, size); if (ret != 0) return ret; } de->target_offset = e->target_offset - (origsize - *size); t = compat_ip6t_get_target(e); xt_compat_target_from_user(t, dstptr, size); de->next_offset = e->next_offset - (origsize - *size); for (h = 0; h < NF_INET_NUMHOOKS; h++) { if ((unsigned char *)de - base < newinfo->hook_entry[h]) newinfo->hook_entry[h] -= origsize - *size; if ((unsigned char *)de - base < newinfo->underflow[h]) newinfo->underflow[h] -= origsize - *size; } return ret; }
Safe
[ "CWE-284", "CWE-264" ]
linux
ce683e5f9d045e5d67d1312a42b359cb2ab2a13c
2.6583983484573288e+38
37
netfilter: x_tables: check for bogus target offset We're currently asserting that targetoff + targetsize <= nextoff. Extend it to also check that targetoff is >= sizeof(xt_entry). Since this is generic code, add an argument pointing to the start of the match/target, we can then derive the base structure size from the delta. We also need the e->elems pointer in a followup change to validate matches. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
0
struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type) { struct net_device *dev; ASSERT_RTNL(); for_each_netdev(net, dev) if (dev->type == type) return dev; return NULL; }
Safe
[ "CWE-399" ]
linux
6ec82562ffc6f297d0de36d65776cff8e5704867
2.4832222506773165e+37
11
veth: Dont kfree_skb() after dev_forward_skb() In case of congestion, netif_rx() frees the skb, so we must assume dev_forward_skb() also consume skb. Bug introduced by commit 445409602c092 (veth: move loopback logic to common location) We must change dev_forward_skb() to always consume skb, and veth to not double free it. Bug report : http://marc.info/?l=linux-netdev&m=127310770900442&w=3 Reported-by: Martín Ferrari <martin.ferrari@gmail.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static inline void ax25_uid_put(ax25_uid_assoc *assoc) { if (refcount_dec_and_test(&assoc->refcount)) { kfree(assoc); } }
Safe
[ "CWE-416" ]
linux
d01ffb9eee4af165d83b08dd73ebdf9fe94a519b
5.999275665837259e+37
6
ax25: add refcount in ax25_dev to avoid UAF bugs If we dereference ax25_dev after we call kfree(ax25_dev) in ax25_dev_device_down(), it will lead to concurrency UAF bugs. There are eight syscall functions suffer from UAF bugs, include ax25_bind(), ax25_release(), ax25_connect(), ax25_ioctl(), ax25_getname(), ax25_sendmsg(), ax25_getsockopt() and ax25_info_show(). One of the concurrency UAF can be shown as below: (USE) | (FREE) | ax25_device_event | ax25_dev_device_down ax25_bind | ... ... | kfree(ax25_dev) ax25_fillin_cb() | ... ax25_fillin_cb_from_dev() | ... | The root cause of UAF bugs is that kfree(ax25_dev) in ax25_dev_device_down() is not protected by any locks. When ax25_dev, which there are still pointers point to, is released, the concurrency UAF bug will happen. This patch introduces refcount into ax25_dev in order to guarantee that there are no pointers point to it when ax25_dev is released. Signed-off-by: Duoming Zhou <duoming@zju.edu.cn> Signed-off-by: David S. Miller <davem@davemloft.net>
0
badauth(OM_uint32 maj, OM_uint32 minor, SVCXPRT *xprt) { if (log_badauth != NULL) (*log_badauth)(maj, minor, &xprt->xp_raddr, log_badauth_data); if (log_badauth2 != NULL) (*log_badauth2)(maj, minor, xprt, log_badauth2_data); }
Safe
[ "CWE-200" ]
krb5
5bb8a6b9c9eb8dd22bc9526751610aaa255ead9c
1.929188691967681e+38
7
Fix gssrpc data leakage [CVE-2014-9423] [MITKRB5-SA-2015-001] In svcauth_gss_accept_sec_context(), do not copy bytes from the union context into the handle field we send to the client. We do not use this handle field, so just supply a fixed string of "xxxx". In gss_union_ctx_id_struct, remove the unused "interposer" field which was causing part of the union context to remain uninitialized. ticket: 8058 (new) target_version: 1.13.1 tags: pullup
0
static OPJ_BOOL opj_j2k_read_cod(opj_j2k_t *p_j2k, OPJ_BYTE * p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t * p_manager ) { /* loop */ OPJ_UINT32 i; OPJ_UINT32 l_tmp; opj_cp_t *l_cp = 00; opj_tcp_t *l_tcp = 00; opj_image_t *l_image = 00; /* preconditions */ assert(p_header_data != 00); assert(p_j2k != 00); assert(p_manager != 00); l_image = p_j2k->m_private_image; l_cp = &(p_j2k->m_cp); /* If we are in the first tile-part header of the current tile */ l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp; /* Only one COD per tile */ if (l_tcp->cod) { opj_event_msg(p_manager, EVT_ERROR, "COD marker already read. No more than one COD marker per tile.\n"); return OPJ_FALSE; } l_tcp->cod = 1; /* Make sure room is sufficient */ if (p_header_size < 5) { opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n"); return OPJ_FALSE; } opj_read_bytes(p_header_data, &l_tcp->csty, 1); /* Scod */ ++p_header_data; /* Make sure we know how to decode this */ if ((l_tcp->csty & ~(OPJ_UINT32)(J2K_CP_CSTY_PRT | J2K_CP_CSTY_SOP | J2K_CP_CSTY_EPH)) != 0U) { opj_event_msg(p_manager, EVT_ERROR, "Unknown Scod value in COD marker\n"); return OPJ_FALSE; } opj_read_bytes(p_header_data, &l_tmp, 1); /* SGcod (A) */ ++p_header_data; l_tcp->prg = (OPJ_PROG_ORDER) l_tmp; /* Make sure progression order is valid */ if (l_tcp->prg > OPJ_CPRL) { opj_event_msg(p_manager, EVT_ERROR, "Unknown progression order in COD marker\n"); l_tcp->prg = OPJ_PROG_UNKNOWN; } opj_read_bytes(p_header_data, &l_tcp->numlayers, 2); /* SGcod (B) */ p_header_data += 2; if ((l_tcp->numlayers < 1U) || (l_tcp->numlayers > 65535U)) { opj_event_msg(p_manager, EVT_ERROR, "Invalid number of layers in COD marker : %d not in range [1-65535]\n", l_tcp->numlayers); return OPJ_FALSE; } /* If user didn't set a number layer to decode take the max specify in the codestream. */ if (l_cp->m_specific_param.m_dec.m_layer) { l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_layer; } else { l_tcp->num_layers_to_decode = l_tcp->numlayers; } opj_read_bytes(p_header_data, &l_tcp->mct, 1); /* SGcod (C) */ ++p_header_data; p_header_size -= 5; for (i = 0; i < l_image->numcomps; ++i) { l_tcp->tccps[i].csty = l_tcp->csty & J2K_CCP_CSTY_PRT; } if (! opj_j2k_read_SPCod_SPCoc(p_j2k, 0, p_header_data, &p_header_size, p_manager)) { opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n"); return OPJ_FALSE; } if (p_header_size != 0) { opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n"); return OPJ_FALSE; } /* Apply the coding style to other components of the current tile or the m_default_tcp*/ opj_j2k_copy_tile_component_parameters(p_j2k); /* Index */ #ifdef WIP_REMOVE_MSD if (p_j2k->cstr_info) { /*opj_codestream_info_t *l_cstr_info = p_j2k->cstr_info;*/ p_j2k->cstr_info->prog = l_tcp->prg; p_j2k->cstr_info->numlayers = l_tcp->numlayers; p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc( l_image->numcomps * sizeof(OPJ_UINT32)); if (!p_j2k->cstr_info->numdecompos) { return OPJ_FALSE; } for (i = 0; i < l_image->numcomps; ++i) { p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1; } } #endif return OPJ_TRUE; }
Safe
[ "CWE-416", "CWE-787" ]
openjpeg
4241ae6fbbf1de9658764a80944dc8108f2b4154
2.4526577062346972e+38
115
Fix assertion in debug mode / heap-based buffer overflow in opj_write_bytes_LE for Cinema profiles with numresolutions = 1 (#985)
0
f_debugbreak(typval_T *argvars, typval_T *rettv) { int pid; rettv->vval.v_number = FAIL; pid = (int)tv_get_number(&argvars[0]); if (pid == 0) emsg(_(e_invarg)); else { HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); if (hProcess != NULL) { DebugBreakProcess(hProcess); CloseHandle(hProcess); rettv->vval.v_number = OK; } } }
Safe
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
2.080214432200931e+38
20
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.
0
format_iolog_path(void) { char dir[PATH_MAX], file[PATH_MAX]; char *iolog_path = NULL; int oldlocale; bool ok; debug_decl(format_iolog_path, SUDOERS_DEBUG_PLUGIN); /* Use sudoers locale for strftime() */ sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale); ok = expand_iolog_path(def_iolog_dir, dir, sizeof(dir), &sudoers_iolog_path_escapes[1], NULL); if (ok) { ok = expand_iolog_path(def_iolog_file, file, sizeof(file), &sudoers_iolog_path_escapes[0], dir); } sudoers_setlocale(oldlocale, NULL); if (!ok) goto done; if (asprintf(&iolog_path, "iolog_path=%s/%s", dir, file) == -1) { iolog_path = NULL; goto done; } /* Stash pointer to the I/O log for the event log. */ sudo_user.iolog_path = iolog_path + sizeof("iolog_path=") - 1; sudo_user.iolog_file = sudo_user.iolog_path + 1 + strlen(dir); done: debug_return_str(iolog_path); }
Safe
[ "CWE-193" ]
sudo
1f8638577d0c80a4ff864a2aad80a0d95488e9a8
2.809655139212585e+38
32
Fix potential buffer overflow when unescaping backslashes in user_args. Also, do not try to unescaping backslashes unless in run mode *and* we are running the command via a shell. Found by Qualys, this fixes CVE-2021-3156.
0
void winbind_msg_online(int msg_type, struct process_id src, void *buf, size_t len, void *private_data) { struct winbindd_child *child; struct winbindd_domain *domain; DEBUG(10,("winbind_msg_online: got online message.\n")); if (!lp_winbind_offline_logon()) { DEBUG(10,("winbind_msg_online: rejecting online message.\n")); return; } /* Set our global state as online. */ set_global_winbindd_state_online(); smb_nscd_flush_user_cache(); smb_nscd_flush_group_cache(); /* Set all our domains as online. */ for (domain = domain_list(); domain; domain = domain->next) { if (domain->internal) { continue; } DEBUG(5,("winbind_msg_online: requesting %s to go online.\n", domain->name)); winbindd_flush_negative_conn_cache(domain); set_domain_online_request(domain); /* Send an online message to the idmap child when our primary domain comes back online */ if ( domain->primary ) { struct winbindd_child *idmap = idmap_child(); if ( idmap->pid != 0 ) { message_send_pid(pid_to_procid(idmap->pid), MSG_WINBIND_ONLINE, domain->name, strlen(domain->name)+1, False); } } } for (child = children; child != NULL; child = child->next) { /* Don't send message to idmap child. */ if (!child->domain || (child == idmap_child())) { continue; } /* Or internal domains (this should not be possible....) */ if (child->domain->internal) { continue; } /* Each winbindd child should only process requests for one domain - make sure we only set it online / offline for that domain. */ DEBUG(10,("winbind_msg_online: sending message to pid %u for domain %s.\n", (unsigned int)child->pid, child->domain->name )); message_send_pid(pid_to_procid(child->pid), MSG_WINBIND_ONLINE, child->domain->name, strlen(child->domain->name)+1, False); } }
Safe
[]
samba
c93d42969451949566327e7fdbf29bfcee2c8319
1.2569236475408052e+38
67
Back-port of Volkers fix. Fix a race condition in winbind leading to a crash When SIGCHLD handling is delayed for some reason, sending a request to a child can fail early because the child has died already. In this case async_main_request_sent() directly called the continuation function without properly removing the malfunctioning child process and the requests in the queue. The next request would then crash in the DLIST_ADD_END() in async_request() because the request pending for the child had been talloc_free()'ed and yet still was referenced in the list. This one is *old*... Volker Jeremy.
0
extern "C" void *__wrap__memalign_r(struct _reent *r, size_t alignment, size_t bytes) { return __real__memalign_r(r, alignment, bytes); }
Safe
[ "CWE-190" ]
mbed-os
151ebfcfc9f2383ee11ce3c771c3bf92900d6b43
9.732238934269387e+37
4
Add integer overflow check to the malloc wrappers Add a check that the combined size of the buffer to allocate and alloc_info_t does not exceed the maximum integer value representable by size_t.
0
static void xmlXPathCompUnaryExpr(xmlXPathParserContextPtr ctxt) { int minus = 0; int found = 0; SKIP_BLANKS; while (CUR == '-') { minus = 1 - minus; found = 1; NEXT; SKIP_BLANKS; } xmlXPathCompUnionExpr(ctxt); CHECK_ERROR; if (found) { if (minus) PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 2, 0); else PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 3, 0);
Safe
[ "CWE-119" ]
libxml2
91d19754d46acd4a639a8b9e31f50f31c78f8c9c
3.830520467878097e+37
21
Fix the semantic of XPath axis for namespace/attribute context nodes The processing of namespace and attributes nodes was not compliant to the XPath-1.0 specification
0
struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode, ext4_lblk_t block, int map_flags) { struct ext4_map_blocks map; struct buffer_head *bh; int create = map_flags & EXT4_GET_BLOCKS_CREATE; int err; J_ASSERT(handle != NULL || create == 0); map.m_lblk = block; map.m_len = 1; err = ext4_map_blocks(handle, inode, &map, map_flags); if (err == 0) return create ? ERR_PTR(-ENOSPC) : NULL; if (err < 0) return ERR_PTR(err); bh = sb_getblk(inode->i_sb, map.m_pblk); if (unlikely(!bh)) return ERR_PTR(-ENOMEM); if (map.m_flags & EXT4_MAP_NEW) { J_ASSERT(create != 0); J_ASSERT(handle != NULL); /* * Now that we do not always journal data, we should * keep in mind whether this should always journal the * new buffer as metadata. For now, regular file * writes use ext4_get_block instead, so it's not a * problem. */ lock_buffer(bh); BUFFER_TRACE(bh, "call get_create_access"); err = ext4_journal_get_create_access(handle, bh); if (unlikely(err)) { unlock_buffer(bh); goto errout; } if (!buffer_uptodate(bh)) { memset(bh->b_data, 0, inode->i_sb->s_blocksize); set_buffer_uptodate(bh); } unlock_buffer(bh); BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); err = ext4_handle_dirty_metadata(handle, inode, bh); if (unlikely(err)) goto errout; } else BUFFER_TRACE(bh, "not a new buffer"); return bh; errout: brelse(bh); return ERR_PTR(err); }
Safe
[ "CWE-362" ]
linux
ea3d7209ca01da209cda6f0dea8be9cc4b7a933b
2.7366068281178042e+38
56
ext4: fix races between page faults and hole punching Currently, page faults and hole punching are completely unsynchronized. This can result in page fault faulting in a page into a range that we are punching after truncate_pagecache_range() has been called and thus we can end up with a page mapped to disk blocks that will be shortly freed. Filesystem corruption will shortly follow. Note that the same race is avoided for truncate by checking page fault offset against i_size but there isn't similar mechanism available for punching holes. Fix the problem by creating new rw semaphore i_mmap_sem in inode and grab it for writing over truncate, hole punching, and other functions removing blocks from extent tree and for read over page faults. We cannot easily use i_data_sem for this since that ranks below transaction start and we need something ranking above it so that it can be held over the whole truncate / hole punching operation. Also remove various workarounds we had in the code to reduce race window when page fault could have created pages with stale mapping information. Signed-off-by: Jan Kara <jack@suse.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
0
static int check_license(MYSQL *mysql) { MYSQL_ROW row; MYSQL_RES *res; NET *net= &mysql->net; static const char query[]= "SELECT @@license"; static const char required_license[]= STRINGIFY_ARG(LICENSE); if (mysql_real_query(mysql, query, sizeof(query)-1)) { if (net->last_errno == ER_UNKNOWN_SYSTEM_VARIABLE) { set_mysql_extended_error(mysql, CR_WRONG_LICENSE, unknown_sqlstate, ER(CR_WRONG_LICENSE), required_license); } return 1; } if (!(res= mysql_use_result(mysql))) return 1; row= mysql_fetch_row(res); /* If no rows in result set, or column value is NULL (none of these two is ever true for server variables now), or column value mismatch, set wrong license error. */ if (!net->last_errno && (!row || !row[0] || strncmp(row[0], required_license, sizeof(required_license)))) { set_mysql_extended_error(mysql, CR_WRONG_LICENSE, unknown_sqlstate, ER(CR_WRONG_LICENSE), required_license); } mysql_free_result(res); return net->last_errno; }
Safe
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
1.2778981508705691e+38
35
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
0
static inline int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, unsigned int family) { return __xfrm_decode_session(skb, fl, family, 0); }
Safe
[ "CWE-416" ]
linux
dbb2483b2a46fbaf833cfb5deb5ed9cace9c7399
1.56266831703021e+37
5
xfrm: clean up xfrm protocol checks In commit 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") I introduced a check for xfrm protocol, but according to Herbert IPSEC_PROTO_ANY should only be used as a wildcard for lookup, so it should be removed from validate_tmpl(). And, IPSEC_PROTO_ANY is expected to only match 3 IPSec-specific protocols, this is why xfrm_state_flush() could still miss IPPROTO_ROUTING, which leads that those entries are left in net->xfrm.state_all before exit net. Fix this by replacing IPSEC_PROTO_ANY with zero. This patch also extracts the check from validate_tmpl() to xfrm_id_proto_valid() and uses it in parse_ipsecrequest(). With this, no other protocols should be added into xfrm. Fixes: 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") Reported-by: syzbot+0bf0519d6e0de15914fe@syzkaller.appspotmail.com Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
0
static int con_install(struct tty_driver *driver, struct tty_struct *tty) { unsigned int currcons = tty->index; struct vc_data *vc; int ret; console_lock(); ret = vc_allocate(currcons); if (ret) goto unlock; vc = vc_cons[currcons].d; /* Still being freed */ if (vc->port.tty) { ret = -ERESTARTSYS; goto unlock; } ret = tty_port_install(&vc->port, driver, tty); if (ret) goto unlock; tty->driver_data = vc; vc->port.tty = tty; if (!tty->winsize.ws_row && !tty->winsize.ws_col) { tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; } if (vc->vc_utf) tty->termios.c_iflag |= IUTF8; else tty->termios.c_iflag &= ~IUTF8; unlock: console_unlock(); return ret; }
Vulnerable
[ "CWE-416", "CWE-362" ]
linux
ca4463bf8438b403596edd0ec961ca0d4fbe0220
1.433116534270431e+38
38
vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console The VT_DISALLOCATE ioctl can free a virtual console while tty_release() is still running, causing a use-after-free in con_shutdown(). This occurs because VT_DISALLOCATE considers a virtual console's 'struct vc_data' to be unused as soon as the corresponding tty's refcount hits 0. But actually it may be still being closed. Fix this by making vc_data be reference-counted via the embedded 'struct tty_port'. A newly allocated virtual console has refcount 1. Opening it for the first time increments the refcount to 2. Closing it for the last time decrements the refcount (in tty_operations::cleanup() so that it happens late enough), as does VT_DISALLOCATE. Reproducer: #include <fcntl.h> #include <linux/vt.h> #include <sys/ioctl.h> #include <unistd.h> int main() { if (fork()) { for (;;) close(open("/dev/tty5", O_RDWR)); } else { int fd = open("/dev/tty10", O_RDWR); for (;;) ioctl(fd, VT_DISALLOCATE, 5); } } KASAN report: BUG: KASAN: use-after-free in con_shutdown+0x76/0x80 drivers/tty/vt/vt.c:3278 Write of size 8 at addr ffff88806a4ec108 by task syz_vt/129 CPU: 0 PID: 129 Comm: syz_vt Not tainted 5.6.0-rc2 #11 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20191223_100556-anatol 04/01/2014 Call Trace: [...] con_shutdown+0x76/0x80 drivers/tty/vt/vt.c:3278 release_tty+0xa8/0x410 drivers/tty/tty_io.c:1514 tty_release_struct+0x34/0x50 drivers/tty/tty_io.c:1629 tty_release+0x984/0xed0 drivers/tty/tty_io.c:1789 [...] Allocated by task 129: [...] kzalloc include/linux/slab.h:669 [inline] vc_allocate drivers/tty/vt/vt.c:1085 [inline] vc_allocate+0x1ac/0x680 drivers/tty/vt/vt.c:1066 con_install+0x4d/0x3f0 drivers/tty/vt/vt.c:3229 tty_driver_install_tty drivers/tty/tty_io.c:1228 [inline] tty_init_dev+0x94/0x350 drivers/tty/tty_io.c:1341 tty_open_by_driver drivers/tty/tty_io.c:1987 [inline] tty_open+0x3ca/0xb30 drivers/tty/tty_io.c:2035 [...] Freed by task 130: [...] kfree+0xbf/0x1e0 mm/slab.c:3757 vt_disallocate drivers/tty/vt/vt_ioctl.c:300 [inline] vt_ioctl+0x16dc/0x1e30 drivers/tty/vt/vt_ioctl.c:818 tty_ioctl+0x9db/0x11b0 drivers/tty/tty_io.c:2660 [...] Fixes: 4001d7b7fc27 ("vt: push down the tty lock so we can see what is left to tackle") Cc: <stable@vger.kernel.org> # v3.4+ Reported-by: syzbot+522643ab5729b0421998@syzkaller.appspotmail.com Acked-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20200322034305.210082-2-ebiggers@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1
_asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, char *str, int str_size) { int len_len, str_len; if (der_len <= 0 || str == NULL) return ASN1_DER_ERROR; str_len = asn1_get_length_der (der, der_len, &len_len); if (str_len <= 0 || str_size < str_len) return ASN1_DER_ERROR; memcpy (str, der + len_len, str_len); str[str_len] = 0; *ret_len = str_len + len_len; return ASN1_SUCCESS; }
Safe
[]
libtasn1
51612fca32dda445056ca9a7533bae258acd3ecb
6.8277054056425725e+37
18
check for zero size in time and object ids.
0
void CWebServer::Cmd_GetSceneActivations(WebEmSession & session, const request& req, Json::Value &root) { if (session.rights != 2) { session.reply_status = reply::forbidden; return; //Only admin user allowed } std::string idx = request::findValue(&req, "idx"); if (idx.empty()) return; root["status"] = "OK"; root["title"] = "GetSceneActivations"; std::vector<std::vector<std::string> > result, result2; result = m_sql.safe_query("SELECT Activators, SceneType FROM Scenes WHERE (ID==%q)", idx.c_str()); if (result.empty()) return; int ii = 0; std::string Activators = result[0][0]; int SceneType = atoi(result[0][1].c_str()); if (!Activators.empty()) { //Get Activator device names std::vector<std::string> arrayActivators; StringSplit(Activators, ";", arrayActivators); for (const auto & ittAct : arrayActivators) { std::string sCodeCmd = ittAct; std::vector<std::string> arrayCode; StringSplit(sCodeCmd, ":", arrayCode); std::string sID = arrayCode[0]; int sCode = 0; if (arrayCode.size() == 2) { sCode = atoi(arrayCode[1].c_str()); } result2 = m_sql.safe_query("SELECT Name, [Type], SubType, SwitchType FROM DeviceStatus WHERE (ID==%q)", sID.c_str()); if (!result2.empty()) { std::vector<std::string> sd = result2[0]; std::string lstatus = "-"; if ((SceneType == 0) && (arrayCode.size() == 2)) { unsigned char devType = (unsigned char)atoi(sd[1].c_str()); unsigned char subType = (unsigned char)atoi(sd[2].c_str()); _eSwitchType switchtype = (_eSwitchType)atoi(sd[3].c_str()); int nValue = sCode; std::string sValue = ""; int llevel = 0; bool bHaveDimmer = false; bool bHaveGroupCmd = false; int maxDimLevel = 0; GetLightStatus(devType, subType, switchtype, nValue, sValue, lstatus, llevel, bHaveDimmer, maxDimLevel, bHaveGroupCmd); } uint64_t dID = std::strtoull(sID.c_str(), nullptr, 10); root["result"][ii]["idx"] = dID; root["result"][ii]["name"] = sd[0]; root["result"][ii]["code"] = sCode; root["result"][ii]["codestr"] = lstatus; ii++; } } } }
Safe
[ "CWE-89" ]
domoticz
ee70db46f81afa582c96b887b73bcd2a86feda00
1.4424544491349114e+38
70
Fixed possible SQL Injection Vulnerability (Thanks to Fabio Carretto!)
0
struct bt_att *bt_gatt_server_get_att(struct bt_gatt_server *server) { if (!server) return NULL; return server->att; }
Safe
[ "CWE-287" ]
bluez
00da0fb4972cf59e1c075f313da81ea549cb8738
7.881242235765327e+37
7
shared/gatt-server: Fix not properly checking for secure flags When passing the mask to check_permissions all valid permissions for the operation must be set including BT_ATT_PERM_SECURE flags.
0
resolve_symlinks_in_ops (void) { SetupOp *op; for (op = ops; op != NULL; op = op->next) { const char *old_source; switch (op->type) { case SETUP_RO_BIND_MOUNT: case SETUP_DEV_BIND_MOUNT: case SETUP_BIND_MOUNT: old_source = op->source; op->source = realpath (old_source, NULL); if (op->source == NULL) { if (op->flags & ALLOW_NOTEXIST && errno == ENOENT) op->source = old_source; else die_with_error("Can't find source path %s", old_source); } break; default: break; } } }
Safe
[ "CWE-20", "CWE-269" ]
bubblewrap
efc89e3b939b4bde42c10f065f6b7b02958ed50e
1.6430108655358388e+38
28
Don't create our own temporary mount point for pivot_root An attacker could pre-create /tmp/.bubblewrap-$UID and make it a non-directory, non-symlink (in which case mounting our tmpfs would fail, causing denial of service), or make it a symlink under their control (potentially allowing bad things if the protected_symlinks sysctl is not enabled). Instead, temporarily mount the tmpfs on a directory that we are sure exists and is not attacker-controlled. /tmp (the directory itself, not a subdirectory) will do. Fixes: #304 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923557 Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #305 Approved by: cgwalters
0
getinfo_helper_policies(control_connection_t *conn, const char *question, char **answer) { (void) conn; if (!strcmp(question, "exit-policy/default")) { *answer = tor_strdup(DEFAULT_EXIT_POLICY); } return 0; }
Safe
[ "CWE-119" ]
tor
43414eb98821d3b5c6c65181d7545ce938f82c8e
2.7250913653274806e+37
9
Fix bounds-checking in policy_summarize Found by piebeer.
0
static int sysfs_slab_add(struct kmem_cache *s) { int err; const char *name; int unmergeable; if (slab_state < SYSFS) /* Defer until later */ return 0; unmergeable = slab_unmergeable(s); if (unmergeable) { /* * Slabcache can never be merged so we can use the name proper. * This is typically the case for debug situations. In that * case we can catch duplicate names easily. */ sysfs_remove_link(&slab_kset->kobj, s->name); name = s->name; } else { /* * Create a unique name for the slab as a target * for the symlinks. */ name = create_unique_id(s); } s->kobj.kset = slab_kset; err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name); if (err) { kobject_put(&s->kobj); return err; } err = sysfs_create_group(&s->kobj, &slab_attr_group); if (err) return err; kobject_uevent(&s->kobj, KOBJ_ADD); if (!unmergeable) { /* Setup first alias */ sysfs_slab_alias(s, s->name); kfree(name); } return 0;
Safe
[ "CWE-189" ]
linux
f8bd2258e2d520dff28c855658bd24bdafb5102d
2.3035772441085684e+38
45
remove div_long_long_rem x86 is the only arch right now, which provides an optimized for div_long_long_rem and it has the downside that one has to be very careful that the divide doesn't overflow. The API is a little akward, as the arguments for the unsigned divide are signed. The signed version also doesn't handle a negative divisor and produces worse code on 64bit archs. There is little incentive to keep this API alive, so this converts the few users to the new API. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: john stultz <johnstul@us.ibm.com> Cc: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
ConnStateData::kick() { if (!Comm::IsConnOpen(clientConnection)) { debugs(33, 2, clientConnection << " Connection was closed"); return; } if (pinning.pinned && !Comm::IsConnOpen(pinning.serverConnection)) { debugs(33, 2, clientConnection << " Connection was pinned but server side gone. Terminating client connection"); clientConnection->close(); return; } /** \par * We are done with the response, and we are either still receiving request * body (early response!) or have already stopped receiving anything. * * If we are still receiving, then clientParseRequest() below will fail. * (XXX: but then we will call readNextRequest() which may succeed and * execute a smuggled request as we are not done with the current request). * * If we stopped because we got everything, then try the next request. * * If we stopped receiving because of an error, then close now to avoid * getting stuck and to prevent accidental request smuggling. */ if (const char *reason = stoppedReceiving()) { debugs(33, 3, "closing for earlier request error: " << reason); clientConnection->close(); return; } /** \par * Attempt to parse a request from the request buffer. * If we've been fed a pipelined request it may already * be in our read buffer. * \par * This needs to fall through - if we're unlucky and parse the _last_ request * from our read buffer we may never re-register for another client read. */ if (clientParseRequests()) { debugs(33, 3, clientConnection << ": parsed next request from buffer"); } /** \par * Either we need to kick-start another read or, if we have * a half-closed connection, kill it after the last request. * This saves waiting for half-closed connections to finished being * half-closed _AND_ then, sometimes, spending "Timeout" time in * the keepalive "Waiting for next request" state. */ if (commIsHalfClosed(clientConnection->fd) && pipeline.empty()) { debugs(33, 3, "half-closed client with no pending requests, closing"); clientConnection->close(); return; } /** \par * At this point we either have a parsed request (which we've * kicked off the processing for) or not. If we have a deferred * request (parsed but deferred for pipeling processing reasons) * then look at processing it. If not, simply kickstart * another read. */ Http::StreamPointer deferredRequest = pipeline.front(); if (deferredRequest != nullptr) { debugs(33, 3, clientConnection << ": calling PushDeferredIfNeeded"); ClientSocketContextPushDeferredIfNeeded(deferredRequest, this); } else if (flags.readMore) { debugs(33, 3, clientConnection << ": calling readNextRequest()"); readNextRequest(); } else { // XXX: Can this happen? CONNECT tunnels have deferredRequest set. debugs(33, DBG_IMPORTANT, MYNAME << "abandoning " << clientConnection); } }
Safe
[ "CWE-444" ]
squid
fd68382860633aca92065e6c343cfd1b12b126e7
2.077749877298198e+38
79
Improve Transfer-Encoding handling (#702) Reject messages containing Transfer-Encoding header with coding other than chunked or identity. Squid does not support other codings. For simplicity and security sake, also reject messages where Transfer-Encoding contains unnecessary complex values that are technically equivalent to "chunked" or "identity" (e.g., ",,chunked" or "identity, chunked"). RFC 7230 formally deprecated and removed identity coding, but it is still used by some agents.
0
static int crypto_init_blkcipher_ops_sync(struct crypto_tfm *tfm) { struct blkcipher_tfm *crt = &tfm->crt_blkcipher; struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher; unsigned long align = crypto_tfm_alg_alignmask(tfm) + 1; unsigned long addr; crt->setkey = setkey; crt->encrypt = alg->encrypt; crt->decrypt = alg->decrypt; addr = (unsigned long)crypto_tfm_ctx(tfm); addr = ALIGN(addr, align); addr += ALIGN(tfm->__crt_alg->cra_ctxsize, align); crt->iv = (void *)addr; return 0; }
Safe
[ "CWE-310" ]
linux
9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6
1.435660305787801e+38
18
crypto: user - fix info leaks in report API Three errors resulting in kernel memory disclosure: 1/ The structures used for the netlink based crypto algorithm report API are located on the stack. As snprintf() does not fill the remainder of the buffer with null bytes, those stack bytes will be disclosed to users of the API. Switch to strncpy() to fix this. 2/ crypto_report_one() does not initialize all field of struct crypto_user_alg. Fix this to fix the heap info leak. 3/ For the module name we should copy only as many bytes as module_name() returns -- not as much as the destination buffer could hold. But the current code does not and therefore copies random data from behind the end of the module name, as the module name is always shorter than CRYPTO_MAX_ALG_NAME. Also switch to use strncpy() to copy the algorithm's name and driver_name. They are strings, after all. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
0
virtual bool ms_verify_authorizer(Connection *con, int peer_type, int protocol, ceph::bufferlist& authorizer, ceph::bufferlist& authorizer_reply, bool& isvalid, CryptoKey& session_key) { return false; }
Vulnerable
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
8.876965046939713e+37
7
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 <sage@redhat.com> (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()
1
point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *group) { return group->asn1_form; }
Safe
[]
openssl
21c856b75d81eff61aa63b4f036bb64a85bf6d46
1.0333792488613545e+38
5
[crypto/ec] for ECC parameters with NULL or zero cofactor, compute it The cofactor argument to EC_GROUP_set_generator is optional, and SCA mitigations for ECC currently use it. So the library currently falls back to very old SCA-vulnerable code if the cofactor is not present. This PR allows EC_GROUP_set_generator to compute the cofactor for all curves of cryptographic interest. Steering scalar multiplication to more SCA-robust code. This issue affects persisted private keys in explicit parameter form, where the (optional) cofactor field is zero or absent. It also affects curves not built-in to the library, but constructed programatically with explicit parameters, then calling EC_GROUP_set_generator with a nonsensical value (NULL, zero). The very old scalar multiplication code is known to be vulnerable to local uarch attacks, outside of the OpenSSL threat model. New results suggest the code path is also vulnerable to traditional wall clock timing attacks. CVE-2019-1547 Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9799)
0
static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb) { /* If valid headers were found, and valid sums * were verified, then we tell the kernel that no * checksumming is necessary. Otherwise, it is [FIXME] */ if ((be16_to_cpu(fcb->flags) & RXFCB_CSUM_MASK) == (RXFCB_CIP | RXFCB_CTU)) skb->ip_summed = CHECKSUM_UNNECESSARY; else skb_checksum_none_assert(skb); }
Safe
[]
linux
d8861bab48b6c1fc3cdbcab8ff9d1eaea43afe7f
4.981605142701951e+37
12
gianfar: fix jumbo packets+napi+rx overrun crash When using jumbo packets and overrunning rx queue with napi enabled, the following sequence is observed in gfar_add_rx_frag: | lstatus | | skb | t | lstatus, size, flags | first | len, data_len, *ptr | ---+--------------------------------------+-------+-----------------------+ 13 | 18002348, 9032, INTERRUPT LAST | 0 | 9600, 8000, f554c12e | 12 | 10000640, 1600, INTERRUPT | 0 | 8000, 6400, f554c12e | 11 | 10000640, 1600, INTERRUPT | 0 | 6400, 4800, f554c12e | 10 | 10000640, 1600, INTERRUPT | 0 | 4800, 3200, f554c12e | 09 | 10000640, 1600, INTERRUPT | 0 | 3200, 1600, f554c12e | 08 | 14000640, 1600, INTERRUPT FIRST | 0 | 1600, 0, f554c12e | 07 | 14000640, 1600, INTERRUPT FIRST | 1 | 0, 0, f554c12e | 06 | 1c000080, 128, INTERRUPT LAST FIRST | 1 | 0, 0, abf3bd6e | 05 | 18002348, 9032, INTERRUPT LAST | 0 | 8000, 6400, c5a57780 | 04 | 10000640, 1600, INTERRUPT | 0 | 6400, 4800, c5a57780 | 03 | 10000640, 1600, INTERRUPT | 0 | 4800, 3200, c5a57780 | 02 | 10000640, 1600, INTERRUPT | 0 | 3200, 1600, c5a57780 | 01 | 10000640, 1600, INTERRUPT | 0 | 1600, 0, c5a57780 | 00 | 14000640, 1600, INTERRUPT FIRST | 1 | 0, 0, c5a57780 | So at t=7 a new packets is started but not finished, probably due to rx overrun - but rx overrun is not indicated in the flags. Instead a new packets starts at t=8. This results in skb->len to exceed size for the LAST fragment at t=13 and thus a negative fragment size added to the skb. This then crashes: kernel BUG at include/linux/skbuff.h:2277! Oops: Exception in kernel mode, sig: 5 [#1] ... NIP [c04689f4] skb_pull+0x2c/0x48 LR [c03f62ac] gfar_clean_rx_ring+0x2e4/0x844 Call Trace: [ec4bfd38] [c06a84c4] _raw_spin_unlock_irqrestore+0x60/0x7c (unreliable) [ec4bfda8] [c03f6a44] gfar_poll_rx_sq+0x48/0xe4 [ec4bfdc8] [c048d504] __napi_poll+0x54/0x26c [ec4bfdf8] [c048d908] net_rx_action+0x138/0x2c0 [ec4bfe68] [c06a8f34] __do_softirq+0x3a4/0x4fc [ec4bfed8] [c0040150] run_ksoftirqd+0x58/0x70 [ec4bfee8] [c0066ecc] smpboot_thread_fn+0x184/0x1cc [ec4bff08] [c0062718] kthread+0x140/0x144 [ec4bff38] [c0012350] ret_from_kernel_thread+0x14/0x1c This patch fixes this by checking for computed LAST fragment size, so a negative sized fragment is never added. In order to prevent the newer rx frame from getting corrupted, the FIRST flag is checked to discard the incomplete older frame. Signed-off-by: Michael Braun <michael-dev@fami-braun.de> Signed-off-by: David S. Miller <davem@davemloft.net>
0
TEST(WriterTest, MoveAssignment) { MemoryWriter w; w << "test"; CheckMoveAssignWriter("test", w); // This fills the inline buffer, but doesn't cause dynamic allocation. std::string s; for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE; ++i) s += '*'; w.clear(); w << s; CheckMoveAssignWriter(s, w); const char *inline_buffer_ptr = w.data(); // Adding one more character causes the content to move from the inline to // a dynamically allocated buffer. w << '*'; MemoryWriter w2; w2 = std::move(w); // Move should rip the guts of the first writer. EXPECT_EQ(inline_buffer_ptr, w.data()); EXPECT_EQ(s + '*', w2.str()); }
Safe
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
8.707397042929908e+37
21
Fix segfault on complex pointer formatting (#642)
0
static void sf_markstate(struct ip_mc_list *pmc) { struct ip_sf_list *psf; int mca_xcount = pmc->sfcount[MCAST_EXCLUDE]; for (psf=pmc->sources; psf; psf=psf->sf_next) if (pmc->sfcount[MCAST_EXCLUDE]) { psf->sf_oldin = mca_xcount == psf->sf_count[MCAST_EXCLUDE] && !psf->sf_count[MCAST_INCLUDE]; } else psf->sf_oldin = psf->sf_count[MCAST_INCLUDE] != 0; }
Safe
[ "CWE-399", "CWE-703", "CWE-369" ]
linux
a8c1f65c79cbbb2f7da782d4c9d15639a9b94b27
7.982799605327803e+37
13
igmp: Avoid zero delay when receiving odd mixture of IGMP queries Commit 5b7c84066733c5dfb0e4016d939757b38de189e4 ('ipv4: correct IGMP behavior on v3 query during v2-compatibility mode') added yet another case for query parsing, which can result in max_delay = 0. Substitute a value of 1, as in the usual v3 case. Reported-by: Simon McVittie <smcv@debian.org> References: http://bugs.debian.org/654876 Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
0
output_buffer& operator<<(output_buffer& output, const Certificate& cert) { uint sz = cert.get_length(); opaque tmp[CERT_HEADER]; if ((int)sz > CERT_HEADER) sz -= 2 * CERT_HEADER; // actual cert, not including headers else { sz = 0; // blank cert case c32to24(sz, tmp); output.write(tmp, CERT_HEADER); return output; } c32to24(sz + CERT_HEADER, tmp); output.write(tmp, CERT_HEADER); c32to24(sz, tmp); output.write(tmp, CERT_HEADER); output.write(cert.get_buffer(), sz); return output; }
Safe
[]
mysql-server
b9768521bdeb1a8069c7b871f4536792b65fd79b
7.876409595560062e+36
23
Updated yassl to yassl-2.3.8 (cherry picked from commit 7f9941eab55ed672bfcccd382dafbdbcfdc75aaa)
0
GF_Filter *gf_filter_connect_source(GF_Filter *filter, const char *url, const char *parent_url, Bool inherit_args, GF_Err *err) { GF_Filter *filter_src; const char *args; char *full_args = NULL; if (!filter) { if (err) *err = GF_BAD_PARAM; return NULL; } args = inherit_args ? gf_filter_get_dst_args(filter) : NULL; if (args) { char *rem_opts[] = {"FID", "SID", "N", "clone", NULL}; char szSep[10]; char *loc_args; u32 opt_idx; u32 dst_offset = 0; u32 len = (u32) strlen(args); sprintf(szSep, "%cgfloc%c", filter->session->sep_args, filter->session->sep_args); loc_args = strstr(args, szSep); if (loc_args) { len = (u32) (ptrdiff_t) (loc_args - args); } if (len) { gf_dynstrcat(&full_args, url, NULL); sprintf(szSep, "%cgpac%c", filter->session->sep_args, filter->session->sep_args); if ((filter->session->sep_args==':') && strstr(url, "://") && !strstr(url, szSep)) { gf_dynstrcat(&full_args, szSep, NULL); } else { sprintf(szSep, "%c", filter->session->sep_args); gf_dynstrcat(&full_args, szSep, NULL); } if (full_args) dst_offset = (u32) strlen(full_args); gf_dynstrcat(&full_args, args, NULL); sprintf(szSep, "%cgfloc%c", filter->session->sep_args, filter->session->sep_args); loc_args = strstr(full_args, "gfloc"); if (loc_args) loc_args[0] = 0; //remove all internal options FIS, SID, N opt_idx = 0; while (rem_opts[opt_idx]) { sprintf(szSep, "%c%s%c", filter->session->sep_args, rem_opts[opt_idx], filter->session->sep_name); loc_args = strstr(full_args + dst_offset, szSep); if (loc_args) { char *sep = strchr(loc_args+1, filter->session->sep_args); if (sep) memmove(loc_args, sep, strlen(sep)+1); else loc_args[0] = 0; } opt_idx++; } url = full_args; } } filter_src = gf_fs_load_source_dest_internal(filter->session, url, NULL, parent_url, err, NULL, filter, GF_TRUE, GF_TRUE, NULL); if (full_args) gf_free(full_args); if (!filter_src) return NULL; gf_mx_p(filter->tasks_mx); if (!filter->source_filters) filter->source_filters = gf_list_new(); gf_list_add(filter->source_filters, filter_src); gf_mx_v(filter->tasks_mx); return filter_src; }
Safe
[ "CWE-787" ]
gpac
da37ec8582266983d0ec4b7550ec907401ec441e
8.934741480185004e+37
67
fixed crashes for very long path - cf #1908
0
static inline ssize_t node_read_cpulist(struct device *dev, struct device_attribute *attr, char *buf) { return node_read_cpumap(dev, true, buf); }
Safe
[ "CWE-787" ]
linux
aa838896d87af561a33ecefea1caa4c15a68bc47
1.317973547525943e+38
5
drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions Convert the various sprintf fmaily calls in sysfs device show functions to sysfs_emit and sysfs_emit_at for PAGE_SIZE buffer safety. Done with: $ spatch -sp-file sysfs_emit_dev.cocci --in-place --max-width=80 . And cocci script: $ cat sysfs_emit_dev.cocci @@ identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - sprintf(buf, + sysfs_emit(buf, ...); ...> } @@ identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ identifier d_show; identifier dev, attr, buf; expression chr; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - strcpy(buf, chr); + sysfs_emit(buf, chr); ...> } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - sprintf(buf, + sysfs_emit(buf, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... - len += scnprintf(buf + len, PAGE_SIZE - len, + len += sysfs_emit_at(buf, len, ...); ...> return len; } @@ identifier d_show; identifier dev, attr, buf; expression chr; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { ... - strcpy(buf, chr); - return strlen(buf); + return sysfs_emit(buf, chr); } Signed-off-by: Joe Perches <joe@perches.com> Link: https://lore.kernel.org/r/3d033c33056d88bbe34d4ddb62afd05ee166ab9a.1600285923.git.joe@perches.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0
RequestTrailerMap& ConnectionManagerImpl::ActiveStream::addDecodedTrailers() { // Trailers can only be added during the last data frame (i.e. end_stream = true). ASSERT(state_.filter_call_state_ & FilterCallState::LastDataFrame); // Trailers can only be added once. ASSERT(!request_trailers_); request_trailers_ = RequestTrailerMapImpl::create(); return *request_trailers_; }
Safe
[ "CWE-400" ]
envoy
0e49a495826ea9e29134c1bd54fdeb31a034f40c
1.5576236319413606e+38
10
http/2: add stats and stream flush timeout (#139) This commit adds a new stream flush timeout to guard against a remote server that does not open window once an entire stream has been buffered for flushing. Additional stats have also been added to better understand the codecs view of active streams as well as amount of data buffered. Signed-off-by: Matt Klein <mklein@lyft.com>
0
do_doautocmd( char_u *arg, int do_msg, /* give message for no matching autocmds? */ int *did_something) { char_u *fname; int nothing_done = TRUE; int group; if (did_something != NULL) *did_something = FALSE; /* * Check for a legal group name. If not, use AUGROUP_ALL. */ group = au_get_grouparg(&arg); if (arg == NULL) /* out of memory */ return FAIL; if (*arg == '*') { EMSG(_("E217: Can't execute autocommands for ALL events")); return FAIL; } /* * Scan over the events. * If we find an illegal name, return here, don't do anything. */ fname = find_end_event(arg, group != AUGROUP_ALL); if (fname == NULL) return FAIL; fname = skipwhite(fname); /* * Loop over the events. */ while (*arg && !ends_excmd(*arg) && !VIM_ISWHITE(*arg)) if (apply_autocmds_group(event_name2nr(arg, &arg), fname, NULL, TRUE, group, curbuf, NULL)) nothing_done = FALSE; if (nothing_done && do_msg) MSG(_("No matching autocommands")); if (did_something != NULL) *did_something = !nothing_done; #ifdef FEAT_EVAL return aborting() ? FAIL : OK; #else return OK; #endif }
Safe
[ "CWE-200", "CWE-668" ]
vim
5a73e0ca54c77e067c3b12ea6f35e3e8681e8cf8
1.3157729459903683e+38
54
patch 8.0.1263: others can read the swap file if a user is careless Problem: Others can read the swap file if a user is careless with his primary group. Solution: If the group permission allows for reading but the world permissions doesn't, make sure the group is right.
0
static input_translation_t *setup_translation_table (exporter_v9_domain_t *exporter, uint16_t id, uint16_t input_record_size) { input_translation_t *table; extension_map_t *extension_map; uint32_t i, ipv6, offset, next_extension; size_t size_required; ipv6 = 0; table = GetTranslationTable(exporter, id); if ( !table ) { LogInfo( "Process_v9: [%u] Add template %u", exporter->info.id, id); dbg_printf("[%u] Add template %u\n", exporter->info.id, id); table = add_translation_table(exporter, id); if ( !table ) { return NULL; } // Add an extension map // The number of extensions for this template is currently unknown // Allocate enough space for all configured extensions - some may be unused later // make sure memory is 4byte alligned size_required = Max_num_extensions * sizeof(uint16_t) + sizeof(extension_map_t); size_required = (size_required + 3) &~(size_t)3; extension_map = malloc(size_required); if ( !extension_map ) { LogError( "Process_v9: Panic! malloc() error in %s line %d: %s", __FILE__, __LINE__, strerror (errno)); return NULL; } extension_map->type = ExtensionMapType; // Set size to an empty table - will be updated later extension_map->size = sizeof(extension_map_t); extension_map->map_id = INIT_ID; // packed record size still unknown at this point - will be added later extension_map->extension_size = 0; table->extension_info.map = extension_map; table->extension_map_changed = 1; #ifdef DEVEL if ( !GetTranslationTable(exporter, id) ) { printf("*** ERROR failed to crosscheck translation table\n"); } else { printf("table lookup ok!\n"); } #endif } else { extension_map = table->extension_info.map; // reset size/extension size - it's refreshed automatically extension_map->size = sizeof(extension_map_t); extension_map->extension_size = 0; dbg_printf("[%u] Refresh template %u\n", exporter->info.id, id); // very noisy for some exporters dbg_printf("[%u] Refresh template %u\n", exporter->info.id, id); } // clear current table memset((void *)table->sequence, 0, cache.max_v9_elements * sizeof(sequence_map_t)); table->number_of_sequences = 0; table->updated = time(NULL); table->flags = 0; table->flow_start = 0; table->flow_end = 0; table->EventTimeMsec = 0; table->ICMP_offset = 0; table->sampler_offset = 0; table->sampler_size = 0; table->engine_offset = 0; table->received_offset = 0; table->router_ip_offset = 0; dbg_printf("[%u] Fill translation table %u\n", exporter->info.id, id); // fill table table->id = id; /* * common data block: The common record is expected in the output stream. If not available * in the template, fill values with 0 */ // All required extensions offset = BYTE_OFFSET_first; if ( cache.lookup_info[NF_F_FLOW_CREATE_TIME_MSEC].found ) { uint32_t _tmp = 0; PushSequence( table, NF_F_FLOW_CREATE_TIME_MSEC, &_tmp, &table->flow_start, 0); dbg_printf("Push NF_F_FLOW_CREATE_TIME_MSEC\n"); } if ( cache.lookup_info[NF_F_FLOW_END_TIME_MSEC].found ) { uint32_t _tmp = 0; PushSequence( table, NF_F_FLOW_END_TIME_MSEC, &_tmp, &table->flow_end, 0); dbg_printf("Push NF_F_FLOW_END_TIME_MSEC\n"); } PushSequence( table, NF9_FIRST_SWITCHED, &offset, NULL, 0); offset = BYTE_OFFSET_first + 4; PushSequence( table, NF9_LAST_SWITCHED, &offset, NULL, 0); offset = BYTE_OFFSET_first + 8; PushSequence( table, NF9_FORWARDING_STATUS, &offset, NULL, 0); PushSequence( table, NF9_TCP_FLAGS, &offset, NULL, 0); PushSequence( table, NF9_IN_PROTOCOL, &offset, NULL, 0); PushSequence( table, NF9_SRC_TOS, &offset, NULL, 0); PushSequence( table, NF9_L4_SRC_PORT, &offset, NULL, 0); PushSequence( table, NF9_L4_DST_PORT, &offset, NULL, 0); // skip exporter_sysid and reserved offset += 4; /* IP addresss record * This record is expected in the output stream. If not available * in the template, assume empty v4 address. */ if ( cache.lookup_info[NF9_IPV4_SRC_ADDR].found ) { // IPv4 addresses PushSequence( table, NF9_IPV4_SRC_ADDR, &offset, NULL, 0); PushSequence( table, NF9_IPV4_DST_ADDR, &offset, NULL, 0); } else if ( cache.lookup_info[NF9_IPV6_SRC_ADDR].found ) { // IPv6 addresses PushSequence( table, NF9_IPV6_SRC_ADDR, &offset, NULL, 0); PushSequence( table, NF9_IPV6_DST_ADDR, &offset, NULL, 0); // mark IPv6 SetFlag(table->flags, FLAG_IPV6_ADDR); ipv6 = 1; } else { // should not happen, assume empty IPv4 addresses PushSequence( table, NF9_IPV4_SRC_ADDR, &offset, NULL, 0); PushSequence( table, NF9_IPV4_DST_ADDR, &offset, NULL, 0); } /* packet counter * This record is expected in the output stream. If not available * in the template, assume empty 4 bytes value */ PushSequence( table, NF9_IN_PACKETS, &offset, &table->packets, 0); // fix: always have 64bit counters due to possible sampling SetFlag(table->flags, FLAG_PKG_64); if ( cache.lookup_info[NF_F_FLOW_BYTES].found ) { // NSEL ASA bytes PushSequence( table, NF_F_FLOW_BYTES, &offset, &table->bytes, 0); } else if ( cache.lookup_info[NF_F_FWD_FLOW_DELTA_BYTES].found ) { // NSEL ASA 8.4 bytes PushSequence( table, NF_F_FWD_FLOW_DELTA_BYTES, &offset, &table->bytes, 0); } else { PushSequence( table, NF9_IN_BYTES, &offset, &table->bytes, 0); } // fix: always have 64bit counters due to possible sampling SetFlag(table->flags, FLAG_BYTES_64); #if defined NSEL || defined NEL if ( cache.lookup_info[NF_F_FW_EVENT].found || cache.lookup_info[NF_F_FW_EVENT_84].found || cache.lookup_info[NF_N_NAT_EVENT].found) { SetFlag(table->flags, FLAG_EVENT); } #endif // Optional extensions next_extension = 0; for (i=4; i <= Max_num_extensions; i++ ) { uint32_t map_index = i; if ( cache.common_extensions[i] == 0 ) continue; switch(i) { case EX_IO_SNMP_2: PushSequence( table, NF9_INPUT_SNMP, &offset, NULL, 0); PushSequence( table, NF9_OUTPUT_SNMP, &offset, NULL, 0); break; case EX_IO_SNMP_4: PushSequence( table, NF9_INPUT_SNMP, &offset, NULL, 1); PushSequence( table, NF9_OUTPUT_SNMP, &offset, NULL, 1); break; case EX_AS_2: PushSequence( table, NF9_SRC_AS, &offset, NULL, 0); PushSequence( table, NF9_DST_AS, &offset, NULL, 0); break; case EX_AS_4: PushSequence( table, NF9_SRC_AS, &offset, NULL, 1); PushSequence( table, NF9_DST_AS, &offset, NULL, 1); break; case EX_MULIPLE: PushSequence( table, NF9_DST_TOS, &offset, NULL, 0); PushSequence( table, NF9_DIRECTION, &offset, NULL, 0); if ( ipv6 ) { // IPv6 PushSequence( table, NF9_IPV6_SRC_MASK, &offset, NULL, 0); PushSequence( table, NF9_IPV6_DST_MASK, &offset, NULL, 0); } else { // IPv4 PushSequence( table, NF9_SRC_MASK, &offset, NULL, 0); PushSequence( table, NF9_DST_MASK, &offset, NULL, 0); } break; case EX_NEXT_HOP_v4: PushSequence( table, NF9_V4_NEXT_HOP, &offset, NULL, 0); break; case EX_NEXT_HOP_v6: PushSequence( table, NF9_V6_NEXT_HOP, &offset, NULL, 0); SetFlag(table->flags, FLAG_IPV6_NH); break; case EX_NEXT_HOP_BGP_v4: PushSequence( table, NF9_BGP_V4_NEXT_HOP, &offset, NULL, 0); break; case EX_NEXT_HOP_BGP_v6: PushSequence( table, NF9_BPG_V6_NEXT_HOP, &offset, NULL, 0); SetFlag(table->flags, FLAG_IPV6_NHB); break; case EX_VLAN: PushSequence( table, NF9_SRC_VLAN, &offset, NULL, 0); PushSequence( table, NF9_DST_VLAN, &offset, NULL, 0); break; case EX_OUT_PKG_4: PushSequence( table, NF9_OUT_PKTS, &offset, &table->out_packets, 0); break; case EX_OUT_PKG_8: PushSequence( table, NF9_OUT_PKTS, &offset, &table->out_packets, 0); break; case EX_OUT_BYTES_4: if ( cache.lookup_info[NF_F_REV_FLOW_DELTA_BYTES].found ) { PushSequence( table, NF_F_REV_FLOW_DELTA_BYTES, &offset, &table->out_bytes, 0); } else { PushSequence( table, NF9_OUT_BYTES, &offset, &table->out_bytes, 0); } break; case EX_OUT_BYTES_8: if ( cache.lookup_info[NF_F_REV_FLOW_DELTA_BYTES].found ) { PushSequence( table, NF_F_REV_FLOW_DELTA_BYTES, &offset, &table->out_bytes, 0); } else { PushSequence( table, NF9_OUT_BYTES, &offset, &table->out_bytes, 0); } break; case EX_AGGR_FLOWS_4: PushSequence( table, NF9_FLOWS_AGGR, &offset, NULL, 0); break; case EX_AGGR_FLOWS_8: PushSequence( table, NF9_FLOWS_AGGR, &offset, NULL, 0); break; case EX_MAC_1: PushSequence( table, NF9_IN_SRC_MAC, &offset, NULL, 0); PushSequence( table, NF9_OUT_DST_MAC, &offset, NULL, 0); break; case EX_MAC_2: PushSequence( table, NF9_IN_DST_MAC, &offset, NULL, 0); PushSequence( table, NF9_OUT_SRC_MAC, &offset, NULL, 0); break; case EX_MPLS: PushSequence( table, NF9_MPLS_LABEL_1, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_2, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_3, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_4, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_5, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_6, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_7, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_8, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_9, &offset, NULL, 0); PushSequence( table, NF9_MPLS_LABEL_10, &offset, NULL, 0); break; case EX_ROUTER_IP_v4: case EX_ROUTER_IP_v6: if ( exporter->info.sa_family == PF_INET6 ) { table->router_ip_offset = offset; dbg_printf("Router IPv6: Offset: %u, olen: %u\n", offset, 16 ); // not an entry for the translateion table. // but reserve space in the output record for IPv6 offset += 16; SetFlag(table->flags, FLAG_IPV6_EXP); map_index = EX_ROUTER_IP_v6; } else { table->router_ip_offset = offset; dbg_printf("Router IPv4: Offset: %u, olen: %u\n", offset, 4 ); // not an entry for the translateion table. // but reserve space in the output record for IPv4 offset += 4; ClearFlag(table->flags, FLAG_IPV6_EXP); map_index = EX_ROUTER_IP_v4; } break; case EX_ROUTER_ID: table->engine_offset = offset; dbg_printf("Engine offset: %u\n", offset); offset += 2; dbg_printf("Skip 2 unused bytes. Next offset: %u\n", offset); PushSequence( table, NF9_ENGINE_TYPE, &offset, NULL, 0); PushSequence( table, NF9_ENGINE_ID, &offset, NULL, 0); // unused fill element for 32bit alignment break; case EX_RECEIVED: table->received_offset = offset; dbg_printf("Received offset: %u\n", offset); offset += 8; break; case EX_LATENCY: { // it's bit of a hack, but .. sigh .. uint32_t i = table->number_of_sequences; // Insert a zero64 as subsequent sequences add values table->sequence[i].id = zero64; table->sequence[i].input_offset = 0; table->sequence[i].output_offset = offset; table->sequence[i].stack = NULL; table->number_of_sequences++; dbg_printf("Zero latency at offset: %u\n", offset); PushSequence( table, NF9_NPROBE_CLIENT_NW_DELAY_SEC, &offset, NULL, 0); offset -= 8; PushSequence( table, NF9_NPROBE_CLIENT_NW_DELAY_USEC, &offset, NULL, 0); table->sequence[i].id = zero64; table->sequence[i].input_offset = 0; table->sequence[i].output_offset = offset; table->sequence[i].stack = NULL; table->number_of_sequences++; dbg_printf("Zero latency at offset: %u\n", offset); PushSequence( table, NF9_NPROBE_SERVER_NW_DELAY_SEC, &offset, NULL, 0); offset -= 8; PushSequence( table, NF9_NPROBE_SERVER_NW_DELAY_USEC, &offset, NULL, 0); table->sequence[i].id = zero64; table->sequence[i].input_offset = 0; table->sequence[i].output_offset = offset; table->sequence[i].stack = NULL; table->number_of_sequences++; dbg_printf("Zero latency at offset: %u\n", offset); PushSequence( table, NF9_NPROBE_APPL_LATENCY_SEC, &offset, NULL, 0); offset -= 8; PushSequence( table, NF9_NPROBE_APPL_LATENCY_USEC, &offset, NULL, 0); } break; case EX_BGPADJ: PushSequence( table, NF9_BGP_ADJ_NEXT_AS, &offset, NULL, 0); PushSequence( table, NF9_BGP_ADJ_PREV_AS, &offset, NULL, 0); break; case EX_NSEL_COMMON: PushSequence( table, NF_F_EVENT_TIME_MSEC, &offset, &table->EventTimeMsec, 0); PushSequence( table, NF_F_CONN_ID, &offset, NULL, 0); if ( ipv6 ) { #ifdef WORDS_BIGENDIAN PushSequence( table, NF_F_ICMP_TYPE_IPV6, &offset, NULL, 0); PushSequence( table, NF_F_ICMP_CODE_IPV6, &offset, NULL, 0); #else PushSequence( table, NF_F_ICMP_CODE_IPV6, &offset, NULL, 0); PushSequence( table, NF_F_ICMP_TYPE_IPV6, &offset, NULL, 0); #endif } else { #ifdef WORDS_BIGENDIAN PushSequence( table, NF_F_ICMP_TYPE, &offset, NULL, 0); PushSequence( table, NF_F_ICMP_CODE, &offset, NULL, 0); #else PushSequence( table, NF_F_ICMP_CODE, &offset, NULL, 0); PushSequence( table, NF_F_ICMP_TYPE, &offset, NULL, 0); #endif } cache.lookup_info[NF_F_FW_EVENT_84].found ? PushSequence( table, NF_F_FW_EVENT_84, &offset, NULL, 0) : PushSequence( table, NF_F_FW_EVENT, &offset, NULL, 0); offset += 1; PushSequence( table, NF_F_FW_EXT_EVENT, &offset, NULL, 0); offset += 2; break; case EX_NSEL_XLATE_PORTS: if ( cache.lookup_info[NF_F_XLATE_SRC_ADDR_84].found ) { PushSequence( table, NF_F_XLATE_SRC_PORT_84, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_DST_PORT_84, &offset, NULL, 0); } else { PushSequence( table, NF_F_XLATE_SRC_PORT, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_DST_PORT, &offset, NULL, 0); } break; case EX_NSEL_XLATE_IP_v4: if ( cache.lookup_info[NF_F_XLATE_SRC_ADDR_84].found ) { PushSequence( table, NF_F_XLATE_SRC_ADDR_84, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_DST_ADDR_84, &offset, NULL, 0); } else { PushSequence( table, NF_F_XLATE_SRC_ADDR_IPV4, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_DST_ADDR_IPV4, &offset, NULL, 0); } break; case EX_NSEL_XLATE_IP_v6: PushSequence( table, NF_F_XLATE_SRC_ADDR_IPV6, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_DST_ADDR_IPV6, &offset, NULL, 0); break; case EX_NSEL_ACL: PushSequence( table, NF_F_INGRESS_ACL_ID, &offset, NULL, 0); PushSequence( table, NF_F_EGRESS_ACL_ID, &offset, NULL, 0); break; case EX_NSEL_USER: case EX_NSEL_USER_MAX: PushSequence( table, NF_F_USERNAME, &offset, NULL, 0); break; case EX_NEL_COMMON: PushSequence( table, NF_N_NAT_EVENT, &offset, NULL, 0); offset += 3; PushSequence( table, NF_N_EGRESS_VRFID, &offset, NULL, 0); PushSequence( table, NF_N_INGRESS_VRFID, &offset, NULL, 0); break; case EX_PORT_BLOCK_ALLOC: PushSequence( table, NF_F_XLATE_PORT_BLOCK_START, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_PORT_BLOCK_END, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_PORT_BLOCK_STEP, &offset, NULL, 0); PushSequence( table, NF_F_XLATE_PORT_BLOCK_SIZE, &offset, NULL, 0); break; case EX_NEL_GLOBAL_IP_v4: // XXX no longer used break; } extension_map->size += sizeof(uint16_t); extension_map->extension_size += extension_descriptor[map_index].size; // found extension in map_index must be the same as in map - otherwise map is dirty if ( extension_map->ex_id[next_extension] != map_index ) { // dirty map - needs to be refreshed in output stream extension_map->ex_id[next_extension] = map_index; table->extension_map_changed = 1; } next_extension++; } extension_map->ex_id[next_extension++] = 0; // make sure map is aligned if ( extension_map->size & 0x3 ) { extension_map->ex_id[next_extension] = 0; extension_map->size = ( extension_map->size + 3 ) &~ 0x3; } table->output_record_size = offset; table->input_record_size = input_record_size; /* ICMP hack for v9 */ // for netflow historical reason, ICMP type/code goes into dst port field // remember offset, for decoding if ( cache.lookup_info[NF9_ICMP_TYPE].found && cache.lookup_info[NF9_ICMP_TYPE].length == 2 ) { table->ICMP_offset = cache.lookup_info[NF9_ICMP_TYPE].offset; } /* Sampler ID */ if ( cache.lookup_info[NF9_FLOW_SAMPLER_ID].found ) { uint32_t length = cache.lookup_info[NF9_FLOW_SAMPLER_ID].length; switch (length) { case 1: case 2: case 4: table->sampler_offset = cache.lookup_info[NF9_FLOW_SAMPLER_ID].offset; table->sampler_size = length; dbg_printf("%d byte Sampling ID included at offset %u\n", length, table->sampler_offset); break; default: LogError( "Process_v9: Unexpected SAMPLER ID field length: %d", cache.lookup_info[NF9_FLOW_SAMPLER_ID].length); dbg_printf("Unexpected SAMPLER ID field length: %d", cache.lookup_info[NF9_FLOW_SAMPLER_ID].length); } } else { dbg_printf("No Sampling ID found\n"); } #ifdef DEVEL if ( table->extension_map_changed ) { printf("Extension Map id=%u changed!\n", extension_map->map_id); } else { printf("[%u] template %u unchanged\n", exporter->info.id, id); } printf("Process_v9: Check extension map: id: %d, size: %u, extension_size: %u\n", extension_map->map_id, extension_map->size, extension_map->extension_size); { int i; for (i=0; i<table->number_of_sequences; i++ ) { printf("Sequence %i: id: %u, in offset: %u, out offset: %u, stack: %llu\n", i, table->sequence[i].id, table->sequence[i].input_offset, table->sequence[i].output_offset, (unsigned long long)table->sequence[i].stack); } printf("Flags: 0x%x\n", table->flags); printf("Input record size: %u, output record size: %u\n", table->input_record_size, table->output_record_size); } PrintExtensionMap(extension_map); #endif return table; } // End of setup_translation_table
Safe
[]
nfdump
ff0e855bd1f51bed9fc5d8559c64d3cfb475a5d8
1.5152491274998006e+38
487
Fix security issues in netflow_v9.c and ipfix.c
0
static void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){ u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell]; u8 *pSrc = &pDst[pRtree->nBytesPerCell]; int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell; memmove(pDst, pSrc, nByte); writeInt16(&pNode->zData[2], NCELL(pNode)-1); pNode->isDirty = 1; }
Safe
[ "CWE-125" ]
sqlite
e41fd72acc7a06ce5a6a7d28154db1ffe8ba37a8
2.3677240886029222e+38
8
Enhance the rtreenode() function of rtree (used for testing) so that it uses the newer sqlite3_str object for better performance and improved error reporting. FossilOrigin-Name: 90acdbfce9c088582d5165589f7eac462b00062bbfffacdcc786eb9cf3ea5377
0
void conn_close_idle(conn *c) { if (settings.idle_timeout > 0 && (current_time - c->last_cmd_time) > settings.idle_timeout) { if (c->state != conn_new_cmd && c->state != conn_read) { if (settings.verbose > 1) fprintf(stderr, "fd %d wants to timeout, but isn't in read state", c->sfd); return; } if (settings.verbose > 1) fprintf(stderr, "Closing idle fd %d\n", c->sfd); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.idle_kicks++; pthread_mutex_unlock(&c->thread->stats.mutex); conn_set_state(c, conn_closing); drive_machine(c); } }
Safe
[]
memcached
f249724cedcab6605ca8a0769ac4b356a8124f63
2.5849568372760404e+38
21
crash fix: errstr wasn't initialized in metaget if meta_flag_preparse bailed out early it would try to read uninitialized memory.
0
static void mce_syscore_shutdown(void) { vendor_disable_error_reporting(); }
Safe
[ "CWE-362" ]
linux
b3b7c4795ccab5be71f080774c45bbbcc75c2aaf
2.1321790217641486e+38
4
x86/MCE: Serialize sysfs changes The check_interval file in /sys/devices/system/machinecheck/machinecheck<cpu number> directory is a global timer value for MCE polling. If it is changed by one CPU, mce_restart() broadcasts the event to other CPUs to delete and restart the MCE polling timer and __mcheck_cpu_init_timer() reinitializes the mce_timer variable. If more than one CPU writes a specific value to the check_interval file concurrently, mce_timer is not protected from such concurrent accesses and all kinds of explosions happen. Since only root can write to those sysfs variables, the issue is not a big deal security-wise. However, concurrent writes to these configuration variables is void of reason so the proper thing to do is to serialize the access with a mutex. Boris: - Make store_int_with_restart() use device_store_ulong() to filter out negative intervals - Limit min interval to 1 second - Correct locking - Massage commit message Signed-off-by: Seunghun Han <kkamagui@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Tony Luck <tony.luck@intel.com> Cc: linux-edac <linux-edac@vger.kernel.org> Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/20180302202706.9434-1-kkamagui@gmail.com
0
ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC) { databuf_t *data = NULL; char arg[11]; if (ftp == NULL) { return 0; } if (!ftp_type(ftp, type)) { goto bail; } if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) { goto bail; } if (startpos > 0) { snprintf(arg, sizeof(arg), "%ld", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } if (!ftp_getresp(ftp) || (ftp->resp != 350)) { goto bail; } } if (!ftp_putcmd(ftp, "STOR", path)) { goto bail; } if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125)) { goto bail; } if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) { goto bail; } ftp->data = data; ftp->stream = instream; ftp->lastch = 0; ftp->nb = 1; return (ftp_nb_continue_write(ftp TSRMLS_CC)); bail: ftp->data = data_close(ftp, data); return PHP_FTP_FAILED; }
Vulnerable
[ "CWE-189" ]
php-src
ac2832935435556dc593784cd0087b5e576bbe4d
5.944490185434255e+37
44
Fix bug #69545 - avoid overflow when reading list
1
regexp_macro_assembler_canonicalize() { return &regexp_macro_assembler_canonicalize_; }
Safe
[ "CWE-20", "CWE-119" ]
node
530af9cb8e700e7596b3ec812bad123c9fa06356
4.940272926304634e+37
3
v8: Interrupts must not mask stack overflow. Backport of https://codereview.chromium.org/339883002
0
static void __init i8042_free_aux_ports(void) { int i; for (i = I8042_AUX_PORT_NO; i < I8042_NUM_PORTS; i++) { kfree(i8042_ports[i].serio); i8042_ports[i].serio = NULL; } }
Safe
[ "CWE-476" ]
linux
340d394a789518018f834ff70f7534fc463d3226
6.417320679264629e+36
9
Input: i8042 - fix crash at boot time The driver checks port->exists twice in i8042_interrupt(), first when trying to assign temporary "serio" variable, and second time when deciding whether it should call serio_interrupt(). The value of port->exists may change between the 2 checks, and we may end up calling serio_interrupt() with a NULL pointer: BUG: unable to handle kernel NULL pointer dereference at 0000000000000050 IP: [<ffffffff8150feaf>] _spin_lock_irqsave+0x1f/0x40 PGD 0 Oops: 0002 [#1] SMP last sysfs file: CPU 0 Modules linked in: Pid: 1, comm: swapper Not tainted 2.6.32-358.el6.x86_64 #1 QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:[<ffffffff8150feaf>] [<ffffffff8150feaf>] _spin_lock_irqsave+0x1f/0x40 RSP: 0018:ffff880028203cc0 EFLAGS: 00010082 RAX: 0000000000010000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000282 RSI: 0000000000000098 RDI: 0000000000000050 RBP: ffff880028203cc0 R08: ffff88013e79c000 R09: ffff880028203ee0 R10: 0000000000000298 R11: 0000000000000282 R12: 0000000000000050 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000098 FS: 0000000000000000(0000) GS:ffff880028200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b CR2: 0000000000000050 CR3: 0000000001a85000 CR4: 00000000001407f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process swapper (pid: 1, threadinfo ffff88013e79c000, task ffff88013e79b500) Stack: ffff880028203d00 ffffffff813de186 ffffffffffffff02 0000000000000000 <d> 0000000000000000 0000000000000000 0000000000000000 0000000000000098 <d> ffff880028203d70 ffffffff813e0162 ffff880028203d20 ffffffff8103b8ac Call Trace: <IRQ> [<ffffffff813de186>] serio_interrupt+0x36/0xa0 [<ffffffff813e0162>] i8042_interrupt+0x132/0x3a0 [<ffffffff8103b8ac>] ? kvm_clock_read+0x1c/0x20 [<ffffffff8103b8b9>] ? kvm_clock_get_cycles+0x9/0x10 [<ffffffff810e1640>] handle_IRQ_event+0x60/0x170 [<ffffffff8103b154>] ? kvm_guest_apic_eoi_write+0x44/0x50 [<ffffffff810e3d8e>] handle_edge_irq+0xde/0x180 [<ffffffff8100de89>] handle_irq+0x49/0xa0 [<ffffffff81516c8c>] do_IRQ+0x6c/0xf0 [<ffffffff8100b9d3>] ret_from_intr+0x0/0x11 [<ffffffff81076f63>] ? __do_softirq+0x73/0x1e0 [<ffffffff8109b75b>] ? hrtimer_interrupt+0x14b/0x260 [<ffffffff8100c1cc>] ? call_softirq+0x1c/0x30 [<ffffffff8100de05>] ? do_softirq+0x65/0xa0 [<ffffffff81076d95>] ? irq_exit+0x85/0x90 [<ffffffff81516d80>] ? smp_apic_timer_interrupt+0x70/0x9b [<ffffffff8100bb93>] ? apic_timer_interrupt+0x13/0x20 To avoid the issue let's change the second check to test whether serio is NULL or not. Also, let's take i8042_lock in i8042_start() and i8042_stop() instead of trying to be overly smart and using memory barriers. Signed-off-by: Chen Hong <chenhong3@huawei.com> [dtor: take lock in i8042_start()/i8042_stop()] Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
0