func
stringlengths 0
484k
| target
int64 0
1
| cwe
sequencelengths 0
4
| project
stringclasses 799
values | commit_id
stringlengths 40
40
| hash
float64 1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
| size
int64 1
24k
| message
stringlengths 0
13.3k
|
---|---|---|---|---|---|---|---|
static void
encode_named_val (MonoReflectionAssembly *assembly, char *buffer, char *p, char **retbuffer, char **retp, guint32 *buflen, MonoType *type, char *name, MonoObject *value)
{
int len;
/* Preallocate a large enough buffer */
if (type->type == MONO_TYPE_VALUETYPE && type->data.klass->enumtype) {
char *str = type_get_qualified_name (type, NULL);
len = strlen (str);
g_free (str);
} else if (type->type == MONO_TYPE_SZARRAY && type->data.klass->enumtype) {
char *str = type_get_qualified_name (&type->data.klass->byval_arg, NULL);
len = strlen (str);
g_free (str);
} else {
len = 0;
}
len += strlen (name);
if ((p-buffer) + 20 + len >= *buflen) {
char *newbuf;
*buflen *= 2;
*buflen += len;
newbuf = g_realloc (buffer, *buflen);
p = newbuf + (p-buffer);
buffer = newbuf;
}
encode_field_or_prop_type (type, p, &p);
len = strlen (name);
mono_metadata_encode_value (len, p, &p);
memcpy (p, name, len);
p += len;
encode_cattr_value (assembly->assembly, buffer, p, &buffer, &p, buflen, type, value, NULL);
*retp = p;
*retbuffer = buffer; | 0 | [
"CWE-20"
] | mono | 4905ef1130feb26c3150b28b97e4a96752e0d399 | 250,835,788,797,470,400,000,000,000,000,000,000,000 | 36 | Handle invalid instantiation of generic methods.
* verify.c: Add new function to internal verifier API to check
method instantiations.
* reflection.c (mono_reflection_bind_generic_method_parameters):
Check the instantiation before returning it.
Fixes #655847 |
static long vmsplice_to_user(struct file *file, struct iov_iter *iter,
unsigned int flags)
{
struct pipe_inode_info *pipe = get_pipe_info(file);
struct splice_desc sd = {
.total_len = iov_iter_count(iter),
.flags = flags,
.u.data = iter
};
long ret = 0;
if (!pipe)
return -EBADF;
if (sd.total_len) {
pipe_lock(pipe);
ret = __splice_from_pipe(pipe, &sd, pipe_to_user);
pipe_unlock(pipe);
}
return ret;
} | 0 | [
"CWE-416"
] | linux | 15fab63e1e57be9fdb5eec1bbc5916e9825e9acb | 191,610,539,005,591,980,000,000,000,000,000,000,000 | 22 | fs: prevent page refcount overflow in pipe_buf_get
Change pipe_buf_get() to return a bool indicating whether it succeeded
in raising the refcount of the page (if the thing in the pipe is a page).
This removes another mechanism for overflowing the page refcount. All
callers converted to handle a failure.
Reported-by: Jann Horn <[email protected]>
Signed-off-by: Matthew Wilcox <[email protected]>
Cc: [email protected]
Signed-off-by: Linus Torvalds <[email protected]> |
static void mboxlist_racl_key(int isuser, const char *keyuser, const char *mbname, struct buf *buf)
{
buf_setcstr(buf, "$RACL$");
buf_putc(buf, isuser ? 'U' : 'S');
buf_putc(buf, '$');
if (keyuser) {
buf_appendcstr(buf, keyuser);
buf_putc(buf, '$');
}
if (mbname) {
buf_appendcstr(buf, mbname);
}
} | 0 | [
"CWE-20"
] | cyrus-imapd | 6bd33275368edfa71ae117de895488584678ac79 | 84,903,577,751,242,490,000,000,000,000,000,000,000 | 13 | mboxlist: fix uninitialised memory use where pattern is "Other Users" |
static void copy_password_acl_validation_control(
struct ldb_request *req,
struct ldb_reply *ares)
{
struct ldb_control *pav_ctrl = NULL;
struct dsdb_control_password_acl_validation *pav = NULL;
pav_ctrl = ldb_request_get_control(
discard_const(req),
DSDB_CONTROL_PASSWORD_ACL_VALIDATION_OID);
if (pav_ctrl == NULL) {
return;
}
pav = talloc_get_type_abort(
pav_ctrl->data,
struct dsdb_control_password_acl_validation);
if (pav == NULL) {
return;
}
ldb_reply_add_control(
ares,
DSDB_CONTROL_PASSWORD_ACL_VALIDATION_OID,
false,
pav);
} | 0 | [
"CWE-20"
] | samba | b95431ab2303eb258e37e88d8841f2fb79fc4af5 | 272,089,700,683,482,260,000,000,000,000,000,000,000 | 26 | CVE-2022-32743 dsdb: Implement validated dNSHostName write
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14833
Signed-off-by: Joseph Sutton <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]> |
add_account (GoaProvider *provider,
GoaClient *client,
GtkDialog *dialog,
GtkBox *vbox,
GError **error)
{
AddAccountData data;
GVariantBuilder credentials;
GVariantBuilder details;
GoaHttpClient *http_client;
GoaObject *ret;
const gchar *uri_text;
const gchar *password;
const gchar *username;
const gchar *provider_type;
gchar *presentation_identity;
gchar *server;
gchar *uri;
gchar *uri_webdav;
gint response;
http_client = NULL;
presentation_identity = NULL;
server = NULL;
uri = NULL;
ret = NULL;
memset (&data, 0, sizeof (AddAccountData));
data.cancellable = g_cancellable_new ();
data.loop = g_main_loop_new (NULL, FALSE);
data.dialog = dialog;
data.error = NULL;
create_account_details_ui (provider, dialog, vbox, TRUE, &data);
gtk_widget_show_all (GTK_WIDGET (vbox));
g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), &data);
http_client = goa_http_client_new ();
http_again:
response = gtk_dialog_run (dialog);
if (response != GTK_RESPONSE_OK)
{
g_set_error (&data.error,
GOA_ERROR,
GOA_ERROR_DIALOG_DISMISSED,
_("Dialog was dismissed"));
goto out;
}
uri_text = gtk_entry_get_text (GTK_ENTRY (data.uri));
username = gtk_entry_get_text (GTK_ENTRY (data.username));
password = gtk_entry_get_text (GTK_ENTRY (data.password));
/* See if there's already an account of this type with the
* given identity
*/
provider_type = goa_provider_get_provider_type (provider);
if (!goa_utils_check_duplicate (client,
username,
provider_type,
(GoaPeekInterfaceFunc) goa_object_peek_password_based,
&data.error))
goto out;
uri = normalize_uri (uri_text, &server);
uri_webdav = g_strconcat (uri, WEBDAV_ENDPOINT, NULL);
g_cancellable_reset (data.cancellable);
goa_http_client_check (http_client,
uri_webdav,
username,
password,
data.cancellable,
check_cb,
&data);
g_free (uri_webdav);
gtk_widget_set_sensitive (data.connect_button, FALSE);
gtk_widget_show (data.progress_grid);
g_main_loop_run (data.loop);
if (g_cancellable_is_cancelled (data.cancellable))
{
g_prefix_error (&data.error,
_("Dialog was dismissed (%s, %d): "),
g_quark_to_string (data.error->domain),
data.error->code);
data.error->domain = GOA_ERROR;
data.error->code = GOA_ERROR_DIALOG_DISMISSED;
goto out;
}
else if (data.error != NULL)
{
gchar *markup;
markup = g_strdup_printf ("<b>%s:</b> %s",
_("Error connecting to ownCloud server"),
data.error->message);
g_clear_error (&data.error);
gtk_label_set_markup (GTK_LABEL (data.cluebar_label), markup);
g_free (markup);
gtk_button_set_label (GTK_BUTTON (data.connect_button), _("_Try Again"));
gtk_widget_set_no_show_all (data.cluebar, FALSE);
gtk_widget_show_all (data.cluebar);
g_clear_pointer (&server, g_free);
g_clear_pointer (&uri, g_free);
goto http_again;
}
gtk_widget_hide (GTK_WIDGET (dialog));
g_variant_builder_init (&credentials, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&credentials, "{sv}", "password", g_variant_new_string (password));
g_variant_builder_init (&details, G_VARIANT_TYPE ("a{ss}"));
g_variant_builder_add (&details, "{ss}", "CalendarEnabled", "true");
g_variant_builder_add (&details, "{ss}", "ContactsEnabled", "true");
g_variant_builder_add (&details, "{ss}", "FilesEnabled", "true");
g_variant_builder_add (&details, "{ss}", "Uri", uri);
/* OK, everything is dandy, add the account */
/* we want the GoaClient to update before this method returns (so it
* can create a proxy for the new object) so run the mainloop while
* waiting for this to complete
*/
presentation_identity = g_strconcat (username, "@", server, NULL);
goa_manager_call_add_account (goa_client_get_manager (client),
goa_provider_get_provider_type (provider),
username,
presentation_identity,
g_variant_builder_end (&credentials),
g_variant_builder_end (&details),
NULL, /* GCancellable* */
(GAsyncReadyCallback) add_account_cb,
&data);
g_main_loop_run (data.loop);
if (data.error != NULL)
goto out;
ret = GOA_OBJECT (g_dbus_object_manager_get_object (goa_client_get_object_manager (client),
data.account_object_path));
out:
/* We might have an object even when data.error is set.
* eg., if we failed to store the credentials in the keyring.
*/
if (data.error != NULL)
g_propagate_error (error, data.error);
else
g_assert (ret != NULL);
g_free (presentation_identity);
g_free (server);
g_free (uri);
g_free (data.account_object_path);
if (data.loop != NULL)
g_main_loop_unref (data.loop);
g_clear_object (&data.cancellable);
g_clear_object (&http_client);
return ret;
} | 1 | [
"CWE-310"
] | gnome-online-accounts | edde7c63326242a60a075341d3fea0be0bc4d80e | 324,422,806,046,503,800,000,000,000,000,000,000,000 | 165 | Guard against invalid SSL certificates
None of the branded providers (eg., Google, Facebook and Windows Live)
should ever have an invalid certificate. So set "ssl-strict" on the
SoupSession object being used by GoaWebView.
Providers like ownCloud and Exchange might have to deal with
certificates that are not up to the mark. eg., self-signed
certificates. For those, show a warning when the account is being
created, and only proceed if the user decides to ignore it. In any
case, save the status of the certificate that was used to create the
account. So an account created with a valid certificate will never
work with an invalid one, and one created with an invalid certificate
will not throw any further warnings.
Fixes: CVE-2013-0240 |
dataiterator_init(Dataiterator *di, Pool *pool, Repo *repo, Id p, Id keyname, const char *match, int flags)
{
memset(di, 0, sizeof(*di));
di->pool = pool;
di->flags = flags & ~SEARCH_THISSOLVID;
if (!pool || (repo && repo->pool != pool))
{
di->state = di_bye;
return -1;
}
if (match)
{
int error;
if ((error = datamatcher_init(&di->matcher, match, flags)) != 0)
{
di->state = di_bye;
return error;
}
}
di->keyname = keyname;
di->keynames[0] = keyname;
dataiterator_set_search(di, repo, p);
return 0;
} | 0 | [
"CWE-125"
] | libsolv | fdb9c9c03508990e4583046b590c30d958f272da | 326,750,826,552,479,430,000,000,000,000,000,000,000 | 24 | repodata_schema2id: fix heap-buffer-overflow in memcmp
When the length of last schema in data->schemadata is
less than length of input schema, we got a read overflow
in asan test.
Signed-off-by: Zhipeng Xie <[email protected]> |
similar_sgr(char *a, char *b)
{
bool result = FALSE;
if (a != 0 && b != 0) {
int csi_a = is_csi(a);
int csi_b = is_csi(b);
size_t len_a;
size_t len_b;
TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s",
_nc_visbuf2(1, a),
_nc_visbuf2(2, b)));
if (csi_a != 0 && csi_b != 0 && csi_a == csi_b) {
a += csi_a;
b += csi_b;
if (*a != *b) {
a = skip_zero(a);
b = skip_zero(b);
}
}
len_a = strlen(a);
len_b = strlen(b);
if (len_a && len_b) {
if (len_a > len_b)
result = (strncmp(a, b, len_b) == 0);
else
result = (strncmp(a, b, len_a) == 0);
}
TR(TRACE_DATABASE, ("...similar_sgr: %d\n\t%s\n\t%s", result,
_nc_visbuf2(1, a),
_nc_visbuf2(2, b)));
}
return result;
} | 0 | [] | ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | 72,499,326,094,127,030,000,000,000,000,000,000,000 | 34 | ncurses 6.2 - patch 20200531
+ correct configure version-check/warnng for g++ to allow for 10.x
+ re-enable "bel" in konsole-base (report by Nia Huang)
+ add linux-s entry (patch by Alexandre Montaron).
+ drop long-obsolete convert_configure.pl
+ add test/test_parm.c, for checking tparm changes.
+ improve parameter-checking for tparm, adding function _nc_tiparm() to
handle the most-used case, which accepts only numeric parameters
(report/testcase by "puppet-meteor").
+ use a more conservative estimate of the buffer-size in lib_tparm.c's
save_text() and save_number(), in case the sprintf() function
passes-through unexpected characters from a format specifier
(report/testcase by "puppet-meteor").
+ add a check for end-of-string in cvtchar to handle a malformed
string in infotocap (report/testcase by "puppet-meteor"). |
int ZEXPORT deflateResetKeep (strm)
z_streamp strm;
{
deflate_state *s;
if (deflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
strm->total_in = strm->total_out = 0;
strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
strm->data_type = Z_UNKNOWN;
s = (deflate_state *)strm->state;
s->pending = 0;
s->pending_out = s->pending_buf;
if (s->wrap < 0) {
s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
}
s->status =
#ifdef GZIP
s->wrap == 2 ? GZIP_STATE :
#endif
INIT_STATE;
strm->adler =
#ifdef GZIP
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
#endif
adler32(0L, Z_NULL, 0);
s->last_flush = -2;
_tr_init(s);
return Z_OK;
} | 0 | [
"CWE-284",
"CWE-787"
] | zlib | 5c44459c3b28a9bd3283aaceab7c615f8020c531 | 46,920,794,036,336,915,000,000,000,000,000,000,000 | 36 | Fix a bug that can crash deflate on some input when using Z_FIXED.
This bug was reported by Danilo Ramos of Eideticom, Inc. It has
lain in wait 13 years before being found! The bug was introduced
in zlib 1.2.2.2, with the addition of the Z_FIXED option. That
option forces the use of fixed Huffman codes. For rare inputs with
a large number of distant matches, the pending buffer into which
the compressed data is written can overwrite the distance symbol
table which it overlays. That results in corrupted output due to
invalid distances, and can result in out-of-bound accesses,
crashing the application.
The fix here combines the distance buffer and literal/length
buffers into a single symbol buffer. Now three bytes of pending
buffer space are opened up for each literal or length/distance
pair consumed, instead of the previous two bytes. This assures
that the pending buffer cannot overwrite the symbol table, since
the maximum fixed code compressed length/distance is 31 bits, and
since there are four bytes of pending space for every three bytes
of symbol space. |
NOEXPORT void socks5_server(CLI *c) {
SOCKS5_UNION socks;
uint8_t host_len;
char *host_name, *port_name;
u_short port_number;
SOCKADDR_UNION addr;
int close_connection=1;
/* parse request */
memset(&socks, 0, sizeof socks);
s_ssl_read(c, &socks, sizeof socks.req);
if(socks.req.ver!=0x05) {
s_log(LOG_ERR, "Invalid SOCKS5 message version 0x%02x", socks.req.ver);
socks.resp.ver=0x05; /* response version 5 */
socks.resp.rep=0x01; /* general SOCKS server failure */
} else if(socks.req.cmd==0x01) { /* CONNECT */
if(socks.req.atyp==0x01) { /* IP v4 address */
c->connect_addr.num=1;
c->connect_addr.addr=str_alloc(sizeof(SOCKADDR_UNION));
c->connect_addr.addr[0].in.sin_family=AF_INET;
s_ssl_read(c, &socks.v4.addr, 4+2);
memcpy(&c->connect_addr.addr[0].in.sin_addr, &socks.v4.addr, 4);
memcpy(&c->connect_addr.addr[0].in.sin_port, &socks.v4.port, 2);
s_log(LOG_INFO, "SOCKS5 IPv4 address received");
if(validate(c)) {
socks.resp.rep=0x00; /* succeeded */
close_connection=0;
} else {
socks.resp.rep=0x02; /* connection not allowed by ruleset */
}
} else if(socks.req.atyp==0x03) { /* DOMAINNAME */
s_ssl_read(c, &host_len, sizeof host_len);
host_name=str_alloc((size_t)host_len+1);
s_ssl_read(c, host_name, host_len);
host_name[host_len]='\0';
s_ssl_read(c, &port_number, 2);
port_name=str_printf("%u", ntohs(port_number));
hostport2addrlist(&c->connect_addr, host_name, port_name);
str_free(port_name);
if(c->connect_addr.num) {
s_log(LOG_INFO, "SOCKS5 resolved \"%s\" to %u host(s)",
host_name, c->connect_addr.num);
if(validate(c)) {
socks.resp.rep=0x00; /* succeeded */
close_connection=0;
} else {
socks.resp.rep=0x02; /* connection not allowed by ruleset */
}
} else {
s_log(LOG_ERR, "SOCKS5 failed to resolve \"%s\"", host_name);
socks.resp.rep=0x04; /* Host unreachable */
}
str_free(host_name);
#ifdef USE_IPv6
} else if(socks.req.atyp==0x04) { /* IP v6 address */
c->connect_addr.num=1;
c->connect_addr.addr=str_alloc(sizeof(SOCKADDR_UNION));
c->connect_addr.addr[0].in6.sin6_family=AF_INET6;
s_ssl_read(c, &socks.v6.addr, 16+2);
memcpy(&c->connect_addr.addr[0].in6.sin6_addr, &socks.v6.addr, 16);
memcpy(&c->connect_addr.addr[0].in6.sin6_port, &socks.v6.port, 2);
s_log(LOG_INFO, "SOCKS5 IPv6 address received");
if(validate(c)) {
socks.resp.rep=0x00; /* succeeded */
close_connection=0;
} else {
socks.resp.rep=0x02; /* connection not allowed by ruleset */
}
#endif
} else {
s_log(LOG_ERR,
"Unsupported SOCKS5 address type 0x%02x", socks.req.atyp);
socks.resp.rep=0x07; /* Address type not supported */
}
} else if(socks.req.cmd==0xf0) { /* RESOLVE (a TOR extension) */
s_ssl_read(c, &host_len, sizeof host_len);
host_name=str_alloc((size_t)host_len+1);
s_ssl_read(c, host_name, host_len);
host_name[host_len]='\0';
s_ssl_read(c, &port_number, 2);
port_name=str_printf("%u", ntohs(port_number));
if(hostport2addr(&addr, host_name, port_name, 0)) {
if(addr.sa.sa_family==AF_INET) {
s_log(LOG_INFO, "SOCKS5/TOR resolved \"%s\" to IPv4", host_name);
memcpy(&socks.v4.addr, &addr.in.sin_addr, 4);
socks.resp.atyp=0x01; /* IP v4 address */
socks.resp.rep=0x00; /* succeeded */
#ifdef USE_IPv6
} else if(addr.sa.sa_family==AF_INET6) {
s_log(LOG_INFO, "SOCKS5/TOR resolved \"%s\" to IPv6", host_name);
memcpy(&socks.v6.addr, &addr.in6.sin6_addr, 16);
socks.resp.atyp=0x04; /* IP v6 address */
socks.resp.rep=0x00; /* succeeded */
#endif
} else {
s_log(LOG_ERR, "SOCKS5/TOR unsupported address type for \"%s\"",
host_name);
socks.resp.rep=0x04; /* Host unreachable */
}
} else {
s_log(LOG_ERR, "SOCKS5/TOR failed to resolve \"%s\"", host_name);
socks.resp.rep=0x04; /* Host unreachable */
}
str_free(host_name);
str_free(port_name);
} else {
s_log(LOG_ERR, "Unsupported SOCKS5 command 0x%02x", socks.req.cmd);
socks.resp.rep=0x07; /* Command not supported */
}
/* send response */
/* broken clients tend to expect the same address family for response,
* so stunnel tries to preserve the address family if possible */
if(socks.resp.atyp==0x04) { /* IP V6 address */
s_ssl_write(c, &socks, sizeof socks.v6);
} else {
socks.resp.atyp=0x01; /* IP v4 address */
s_ssl_write(c, &socks, sizeof socks.v4);
}
if(close_connection) /* request failed */
throw_exception(c, 2); /* don't reset */
} | 0 | [
"CWE-295"
] | stunnel | ebad9ddc4efb2635f37174c9d800d06206f1edf9 | 23,425,833,817,706,478,000,000,000,000,000,000,000 | 122 | stunnel-5.57 |
static int jpc_dec_dump(jpc_dec_t *dec, FILE *out)
{
jpc_dec_tile_t *tile;
int tileno;
jpc_dec_tcomp_t *tcomp;
int compno;
jpc_dec_rlvl_t *rlvl;
int rlvlno;
jpc_dec_band_t *band;
int bandno;
jpc_dec_prc_t *prc;
int prcno;
jpc_dec_cblk_t *cblk;
int cblkno;
for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles;
++tileno, ++tile) {
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno <
tcomp->numrlvls; ++rlvlno, ++rlvl) {
fprintf(out, "RESOLUTION LEVEL %d\n", rlvlno);
fprintf(out, "xs =%"PRIuFAST32", ys = %"PRIuFAST32", xe = %"PRIuFAST32", ye = %"PRIuFAST32", w = %"PRIuFAST32", h = %"PRIuFAST32"\n",
rlvl->xstart, rlvl->ystart, rlvl->xend, rlvl->yend, rlvl->xend -
rlvl->xstart, rlvl->yend - rlvl->ystart);
for (bandno = 0, band = rlvl->bands;
bandno < rlvl->numbands; ++bandno, ++band) {
fprintf(out, "BAND %d\n", bandno);
fprintf(out, "xs =%"PRIiFAST32", ys = %"PRIiFAST32", xe = %"PRIiFAST32", ye = %"PRIiFAST32", w = %"PRIiFAST32", h = %"PRIiFAST32"\n",
jas_seq2d_xstart(band->data), jas_seq2d_ystart(band->data), jas_seq2d_xend(band->data),
jas_seq2d_yend(band->data), jas_seq2d_xend(band->data) - jas_seq2d_xstart(band->data),
jas_seq2d_yend(band->data) - jas_seq2d_ystart(band->data));
for (prcno = 0, prc = band->prcs;
prcno < rlvl->numprcs; ++prcno,
++prc) {
fprintf(out, "CODE BLOCK GROUP %d\n", prcno);
fprintf(out, "xs =%"PRIuFAST32", ys = %"PRIuFAST32", xe = %"PRIuFAST32", ye = %"PRIuFAST32", w = %"PRIuFAST32", h = %"PRIuFAST32"\n",
prc->xstart, prc->ystart, prc->xend, prc->yend, prc->xend -
prc->xstart, prc->yend - prc->ystart);
for (cblkno = 0, cblk =
prc->cblks; cblkno <
prc->numcblks; ++cblkno,
++cblk) {
fprintf(out, "CODE BLOCK %d\n", cblkno);
fprintf(out, "xs =%"PRIiFAST32", ys = %"PRIiFAST32", xe = %"PRIiFAST32", ye = %"PRIiFAST32", w = %"PRIiFAST32", h = %"PRIiFAST32"\n",
jas_seq2d_xstart(cblk->data), jas_seq2d_ystart(cblk->data), jas_seq2d_xend(cblk->data),
jas_seq2d_yend(cblk->data), jas_seq2d_xend(cblk->data) - jas_seq2d_xstart(cblk->data),
jas_seq2d_yend(cblk->data) - jas_seq2d_ystart(cblk->data));
}
}
}
}
}
}
return 0;
} | 0 | [
"CWE-190"
] | jasper | d91198abd00fc435a397fe6bad906a4c1748e9cf | 285,173,001,664,032,030,000,000,000,000,000,000,000 | 57 | Fixed another integer overflow problem. |
DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
int height, int subsamp)
{
unsigned long retval = 0;
int pw, ph;
if (width < 1 || height < 1 || subsamp < 0 || subsamp >= NUMSUBOPT)
THROWG("tjPlaneSizeYUV(): Invalid argument");
pw = tjPlaneWidth(componentID, width, subsamp);
ph = tjPlaneHeight(componentID, height, subsamp);
if (pw < 0 || ph < 0) return -1;
if (stride == 0) stride = pw;
else stride = abs(stride);
retval = stride * (ph - 1) + pw;
bailout:
return retval;
} | 1 | [
"CWE-787"
] | libjpeg-turbo | 2a9e3bd7430cfda1bc812d139e0609c6aca0b884 | 139,937,649,636,676,130,000,000,000,000,000,000,000 | 21 | TurboJPEG: Properly handle gigapixel images
Prevent several integer overflow issues and subsequent segfaults that
occurred when attempting to compress or decompress gigapixel images with
the TurboJPEG API:
- Modify tjBufSize(), tjBufSizeYUV2(), and tjPlaneSizeYUV() to avoid
integer overflow when computing the return values and to return an
error if such an overflow is unavoidable.
- Modify tjunittest to validate the above.
- Modify tjCompress2(), tjEncodeYUVPlanes(), tjDecompress2(), and
tjDecodeYUVPlanes() to avoid integer overflow when computing the row
pointers in the 64-bit TurboJPEG C API.
- Modify TJBench (both C and Java versions) to avoid overflowing the
size argument to malloc()/new and to fail gracefully if such an
overflow is unavoidable.
In general, this allows gigapixel images to be accommodated by the
64-bit TurboJPEG C API when using automatic JPEG buffer (re)allocation.
Such images cannot currently be accommodated without automatic JPEG
buffer (re)allocation, due to the fact that tjAlloc() accepts a 32-bit
integer argument (oops.) Such images cannot be accommodated in the
TurboJPEG Java API due to the fact that Java always uses a signed 32-bit
integer as an array index.
Fixes #361 |
void MirrorJob::Bg()
{
source_session->SetPriority(0);
target_session->SetPriority(0);
Job::Bg();
} | 0 | [
"CWE-20",
"CWE-401"
] | lftp | a27e07d90a4608ceaf928b1babb27d4d803e1992 | 84,536,779,402,897,620,000,000,000,000,000,000,000 | 6 | mirror: prepend ./ to rm and chmod arguments to avoid URL recognition (fix #452) |
static void hns_nic_update_link_status(struct net_device *netdev)
{
struct hns_nic_priv *priv = netdev_priv(netdev);
struct hnae_handle *h = priv->ae_handle;
if (h->phy_dev) {
if (h->phy_if != PHY_INTERFACE_MODE_XGMII)
return;
(void)genphy_read_status(h->phy_dev);
}
hns_nic_adjust_link(netdev);
} | 0 | [
"CWE-416"
] | linux | 27463ad99f738ed93c7c8b3e2e5bc8c4853a2ff2 | 90,897,739,162,506,500,000,000,000,000,000,000,000 | 14 | net: hns: Fix a skb used after free bug
skb maybe freed in hns_nic_net_xmit_hw() and return NETDEV_TX_OK,
which cause hns_nic_net_xmit to use a freed skb.
BUG: KASAN: use-after-free in hns_nic_net_xmit_hw+0x62c/0x940...
[17659.112635] alloc_debug_processing+0x18c/0x1a0
[17659.117208] __slab_alloc+0x52c/0x560
[17659.120909] kmem_cache_alloc_node+0xac/0x2c0
[17659.125309] __alloc_skb+0x6c/0x260
[17659.128837] tcp_send_ack+0x8c/0x280
[17659.132449] __tcp_ack_snd_check+0x9c/0xf0
[17659.136587] tcp_rcv_established+0x5a4/0xa70
[17659.140899] tcp_v4_do_rcv+0x27c/0x620
[17659.144687] tcp_prequeue_process+0x108/0x170
[17659.149085] tcp_recvmsg+0x940/0x1020
[17659.152787] inet_recvmsg+0x124/0x180
[17659.156488] sock_recvmsg+0x64/0x80
[17659.160012] SyS_recvfrom+0xd8/0x180
[17659.163626] __sys_trace_return+0x0/0x4
[17659.167506] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=23 cpu=1 pid=13
[17659.174000] free_debug_processing+0x1d4/0x2c0
[17659.178486] __slab_free+0x240/0x390
[17659.182100] kmem_cache_free+0x24c/0x270
[17659.186062] kfree_skbmem+0xa0/0xb0
[17659.189587] __kfree_skb+0x28/0x40
[17659.193025] napi_gro_receive+0x168/0x1c0
[17659.197074] hns_nic_rx_up_pro+0x58/0x90
[17659.201038] hns_nic_rx_poll_one+0x518/0xbc0
[17659.205352] hns_nic_common_poll+0x94/0x140
[17659.209576] net_rx_action+0x458/0x5e0
[17659.213363] __do_softirq+0x1b8/0x480
[17659.217062] run_ksoftirqd+0x64/0x80
[17659.220679] smpboot_thread_fn+0x224/0x310
[17659.224821] kthread+0x150/0x170
[17659.228084] ret_from_fork+0x10/0x40
BUG: KASAN: use-after-free in hns_nic_net_xmit+0x8c/0xc0...
[17751.080490] __slab_alloc+0x52c/0x560
[17751.084188] kmem_cache_alloc+0x244/0x280
[17751.088238] __build_skb+0x40/0x150
[17751.091764] build_skb+0x28/0x100
[17751.095115] __alloc_rx_skb+0x94/0x150
[17751.098900] __napi_alloc_skb+0x34/0x90
[17751.102776] hns_nic_rx_poll_one+0x180/0xbc0
[17751.107097] hns_nic_common_poll+0x94/0x140
[17751.111333] net_rx_action+0x458/0x5e0
[17751.115123] __do_softirq+0x1b8/0x480
[17751.118823] run_ksoftirqd+0x64/0x80
[17751.122437] smpboot_thread_fn+0x224/0x310
[17751.126575] kthread+0x150/0x170
[17751.129838] ret_from_fork+0x10/0x40
[17751.133454] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=19 cpu=7 pid=43
[17751.139951] free_debug_processing+0x1d4/0x2c0
[17751.144436] __slab_free+0x240/0x390
[17751.148051] kmem_cache_free+0x24c/0x270
[17751.152014] kfree_skbmem+0xa0/0xb0
[17751.155543] __kfree_skb+0x28/0x40
[17751.159022] napi_gro_receive+0x168/0x1c0
[17751.163074] hns_nic_rx_up_pro+0x58/0x90
[17751.167041] hns_nic_rx_poll_one+0x518/0xbc0
[17751.171358] hns_nic_common_poll+0x94/0x140
[17751.175585] net_rx_action+0x458/0x5e0
[17751.179373] __do_softirq+0x1b8/0x480
[17751.183076] run_ksoftirqd+0x64/0x80
[17751.186691] smpboot_thread_fn+0x224/0x310
[17751.190826] kthread+0x150/0x170
[17751.194093] ret_from_fork+0x10/0x40
Fixes: 13ac695e7ea1 ("net:hns: Add support of Hip06 SoC to the Hislicon Network Subsystem")
Signed-off-by: Yunsheng Lin <[email protected]>
Signed-off-by: lipeng <[email protected]>
Reported-by: Jun He <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
static bool exclusive_event_installable(struct perf_event *event,
struct perf_event_context *ctx)
{
struct perf_event *iter_event;
struct pmu *pmu = event->pmu;
lockdep_assert_held(&ctx->mutex);
if (!is_exclusive_pmu(pmu))
return true;
list_for_each_entry(iter_event, &ctx->event_list, event_entry) {
if (exclusive_event_match(iter_event, event))
return false;
}
return true;
} | 0 | [
"CWE-401"
] | tip | 7bdb157cdebbf95a1cd94ed2e01b338714075d00 | 267,011,855,455,612,700,000,000,000,000,000,000,000 | 18 | perf/core: Fix a memory leak in perf_event_parse_addr_filter()
As shown through runtime testing, the "filename" allocation is not
always freed in perf_event_parse_addr_filter().
There are three possible ways that this could happen:
- It could be allocated twice on subsequent iterations through the loop,
- or leaked on the success path,
- or on the failure path.
Clean up the code flow to make it obvious that 'filename' is always
freed in the reallocation path and in the two return paths as well.
We rely on the fact that kfree(NULL) is NOP and filename is initialized
with NULL.
This fixes the leak. No other side effects expected.
[ Dan Carpenter: cleaned up the code flow & added a changelog. ]
[ Ingo Molnar: updated the changelog some more. ]
Fixes: 375637bc5249 ("perf/core: Introduce address range filtering")
Signed-off-by: "kiyin(尹亮)" <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Cc: "Srivatsa S. Bhat" <[email protected]>
Cc: Anthony Liguori <[email protected]>
--
kernel/events/core.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-) |
int gg_notify_ex(struct gg_session *sess, uin_t *userlist, char *types, int count)
{
struct gg_notify *n;
uin_t *u;
char *t;
int i, res = 0;
gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_notify_ex(%p, %p, %p, %d);\n", sess, userlist, types, count);
if (!sess) {
errno = EFAULT;
return -1;
}
if (sess->state != GG_STATE_CONNECTED) {
errno = ENOTCONN;
return -1;
}
if (sess->protocol_version >= GG_PROTOCOL_110)
return gg_notify105_ex(sess, userlist, types, count);
if (!userlist || !count)
return gg_send_packet(sess, GG_LIST_EMPTY, NULL);
while (count > 0) {
int part_count, packet_type;
if (count > 400) {
part_count = 400;
packet_type = GG_NOTIFY_FIRST;
} else {
part_count = count;
packet_type = GG_NOTIFY_LAST;
}
if (!(n = (struct gg_notify*) malloc(sizeof(*n) * part_count)))
return -1;
for (u = userlist, t = types, i = 0; i < part_count; u++, t++, i++) {
n[i].uin = gg_fix32(*u);
if (types == NULL)
n[i].dunno1 = GG_USER_NORMAL;
else
n[i].dunno1 = *t;
}
if (gg_send_packet(sess, packet_type, n, sizeof(*n) * part_count, NULL) == -1) {
free(n);
res = -1;
break;
}
count -= part_count;
userlist += part_count;
if (types != NULL)
types += part_count;
free(n);
}
return res;
} | 0 | [
"CWE-310"
] | libgadu | 23644f1fb8219031b3cac93289a588b05f90226b | 298,583,738,181,521,340,000,000,000,000,000,000,000 | 63 | Poprawka ograniczania długości opisu. |
static int usb_host_scan_dev(void *opaque, USBScanFunc *func)
{
FILE *f = NULL;
char line[1024];
char buf[1024];
int bus_num, addr, speed, device_count, class_id, product_id, vendor_id;
char product_name[512];
int ret = 0;
if (!usb_host_device_path) {
perror("husb: USB Host Device Path not set");
goto the_end;
}
snprintf(line, sizeof(line), "%s/devices", usb_host_device_path);
f = fopen(line, "r");
if (!f) {
perror("husb: cannot open devices file");
goto the_end;
}
device_count = 0;
bus_num = addr = speed = class_id = product_id = vendor_id = 0;
for(;;) {
if (fgets(line, sizeof(line), f) == NULL)
break;
if (strlen(line) > 0)
line[strlen(line) - 1] = '\0';
if (line[0] == 'T' && line[1] == ':') {
if (device_count && (vendor_id || product_id)) {
/* New device. Add the previously discovered device. */
ret = func(opaque, bus_num, addr, class_id, vendor_id,
product_id, product_name, speed);
if (ret)
goto the_end;
}
if (get_tag_value(buf, sizeof(buf), line, "Bus=", " ") < 0)
goto fail;
bus_num = atoi(buf);
if (get_tag_value(buf, sizeof(buf), line, "Dev#=", " ") < 0)
goto fail;
addr = atoi(buf);
if (get_tag_value(buf, sizeof(buf), line, "Spd=", " ") < 0)
goto fail;
if (!strcmp(buf, "480"))
speed = USB_SPEED_HIGH;
else if (!strcmp(buf, "1.5"))
speed = USB_SPEED_LOW;
else
speed = USB_SPEED_FULL;
product_name[0] = '\0';
class_id = 0xff;
device_count++;
product_id = 0;
vendor_id = 0;
} else if (line[0] == 'P' && line[1] == ':') {
if (get_tag_value(buf, sizeof(buf), line, "Vendor=", " ") < 0)
goto fail;
vendor_id = strtoul(buf, NULL, 16);
if (get_tag_value(buf, sizeof(buf), line, "ProdID=", " ") < 0)
goto fail;
product_id = strtoul(buf, NULL, 16);
} else if (line[0] == 'S' && line[1] == ':') {
if (get_tag_value(buf, sizeof(buf), line, "Product=", "") < 0)
goto fail;
pstrcpy(product_name, sizeof(product_name), buf);
} else if (line[0] == 'D' && line[1] == ':') {
if (get_tag_value(buf, sizeof(buf), line, "Cls=", " (") < 0)
goto fail;
class_id = strtoul(buf, NULL, 16);
}
fail: ;
}
if (device_count && (vendor_id || product_id)) {
/* Add the last device. */
ret = func(opaque, bus_num, addr, class_id, vendor_id,
product_id, product_name, speed);
}
the_end:
if (f)
fclose(f);
return ret;
} | 0 | [
"CWE-119"
] | qemu | babd03fde68093482528010a5435c14ce9128e3f | 141,419,311,059,650,020,000,000,000,000,000,000,000 | 82 | usb-linux.c: fix buffer overflow
In usb-linux.c:usb_host_handle_control, we pass a 1024-byte buffer and
length to the kernel. However, the length was provided by the caller
of dev->handle_packet, and is not checked, so the kernel might provide
too much data and overflow our buffer.
For example, hw/usb-uhci.c could set the length to 2047.
hw/usb-ohci.c looks like it might go up to 4096 or 8192.
This causes a qemu crash, as reported here:
http://www.mail-archive.com/[email protected]/msg18447.html
This patch increases the usb-linux.c buffer size to 2048 to fix the
specific device reported, and adds a check to avoid the overflow in
any case.
Signed-off-by: Jim Paris <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]> |
e_named_parameters_to_strv (const ENamedParameters *parameters)
{
GPtrArray *array = (GPtrArray *) parameters;
GPtrArray *ret = g_ptr_array_new ();
if (array) {
guint i;
for (i = 0; i < array->len; i++) {
g_ptr_array_add (ret, g_strdup (array->pdata[i]));
}
}
g_ptr_array_add (ret, NULL);
return (gchar **) g_ptr_array_free (ret, FALSE);
} | 0 | [
"CWE-295"
] | evolution-data-server | 6672b8236139bd6ef41ecb915f4c72e2a052dba5 | 327,492,630,684,591,440,000,000,000,000,000,000,000 | 16 | Let child source with 'none' authentication method use collection source authentication
That might be the same as having set NULL authentication method.
Related to https://gitlab.gnome.org/GNOME/evolution-ews/issues/27 |
free_unref_items(int copyID)
{
int did_free = FALSE;
// Let all "free" functions know that we are here. This means no
// dictionaries, lists, channels or jobs are to be freed, because we will
// do that here.
in_free_unref_items = TRUE;
/*
* PASS 1: free the contents of the items. We don't free the items
* themselves yet, so that it is possible to decrement refcount counters
*/
// Go through the list of dicts and free items without the copyID.
did_free |= dict_free_nonref(copyID);
// Go through the list of lists and free items without the copyID.
did_free |= list_free_nonref(copyID);
#ifdef FEAT_JOB_CHANNEL
// Go through the list of jobs and free items without the copyID. This
// must happen before doing channels, because jobs refer to channels, but
// the reference from the channel to the job isn't tracked.
did_free |= free_unused_jobs_contents(copyID, COPYID_MASK);
// Go through the list of channels and free items without the copyID.
did_free |= free_unused_channels_contents(copyID, COPYID_MASK);
#endif
/*
* PASS 2: free the items themselves.
*/
dict_free_items(copyID);
list_free_items(copyID);
#ifdef FEAT_JOB_CHANNEL
// Go through the list of jobs and free items without the copyID. This
// must happen before doing channels, because jobs refer to channels, but
// the reference from the channel to the job isn't tracked.
free_unused_jobs(copyID, COPYID_MASK);
// Go through the list of channels and free items without the copyID.
free_unused_channels(copyID, COPYID_MASK);
#endif
in_free_unref_items = FALSE;
return did_free;
} | 0 | [
"CWE-122",
"CWE-787"
] | vim | 605ec91e5a7330d61be313637e495fa02a6dc264 | 106,803,141,971,489,260,000,000,000,000,000,000,000 | 50 | patch 8.2.3847: illegal memory access when using a lambda with an error
Problem: Illegal memory access when using a lambda with an error.
Solution: Avoid skipping over the NUL after a string. |
static INLINE int vp8_decode_value(BOOL_DECODER *br, int bits) {
int z = 0;
int bit;
for (bit = bits - 1; bit >= 0; bit--) {
z |= (vp8dx_decode_bool(br, 0x80) << bit);
}
return z;
} | 0 | [
"CWE-125"
] | libvpx | 46e17f0cb4a80b36755c84b8bf15731d3386c08f | 270,941,809,387,927,100,000,000,000,000,000,000,000 | 10 | Fix OOB memory access on fuzzed data
vp8_norm table has 256 elements while index to it can be higher on
fuzzed data. Typecasting it to unsigned char will ensure valid range and
will trigger proper error later. Also declaring "shift" as unsigned char to
avoid UB sanitizer warning
BUG=b/122373286,b/122373822,b/122371119
Change-Id: I3cef1d07f107f061b1504976a405fa0865afe9f5 |
bool dns_name_is_static(struct dnsp_DnssrvRpcRecord *records,
uint16_t rec_count)
{
int i = 0;
for (i = 0; i < rec_count; i++) {
if (records[i].wType == DNS_TYPE_TOMBSTONE) {
continue;
}
if (records[i].wType == DNS_TYPE_SOA ||
records[i].dwTimeStamp == 0) {
return true;
}
}
return false;
} | 0 | [
"CWE-200"
] | samba | 0a3aa5f908e351201dc9c4d4807b09ed9eedff77 | 302,963,138,065,547,200,000,000,000,000,000,000,000 | 16 | CVE-2022-32746 ldb: Make use of functions for appending to an ldb_message
This aims to minimise usage of the error-prone pattern of searching for
a just-added message element in order to make modifications to it (and
potentially finding the wrong element).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009
Signed-off-by: Joseph Sutton <[email protected]> |
static int sr_read_tocentry(struct cdrom_device_info *cdi,
struct cdrom_tocentry *tocentry)
{
struct scsi_cd *cd = cdi->handle;
struct packet_command cgc;
int result;
unsigned char *buffer;
buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
if (!buffer)
return -ENOMEM;
memset(&cgc, 0, sizeof(struct packet_command));
cgc.timeout = IOCTL_TIMEOUT;
cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
cgc.cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0;
cgc.cmd[6] = tocentry->cdte_track;
cgc.cmd[8] = 12; /* LSB of length */
cgc.buffer = buffer;
cgc.buflen = 12;
cgc.data_direction = DMA_FROM_DEVICE;
result = sr_do_ioctl(cd, &cgc);
tocentry->cdte_ctrl = buffer[5] & 0xf;
tocentry->cdte_adr = buffer[5] >> 4;
tocentry->cdte_datamode = (tocentry->cdte_ctrl & 0x04) ? 1 : 0;
if (tocentry->cdte_format == CDROM_MSF) {
tocentry->cdte_addr.msf.minute = buffer[9];
tocentry->cdte_addr.msf.second = buffer[10];
tocentry->cdte_addr.msf.frame = buffer[11];
} else
tocentry->cdte_addr.lba = (((((buffer[8] << 8) + buffer[9]) << 8)
+ buffer[10]) << 8) + buffer[11];
kfree(buffer);
return result;
} | 0 | [
"CWE-119",
"CWE-787"
] | linux | f7068114d45ec55996b9040e98111afa56e010fe | 222,626,076,419,973,550,000,000,000,000,000,000,000 | 38 | sr: pass down correctly sized SCSI sense buffer
We're casting the CDROM layer request_sense to the SCSI sense
buffer, but the former is 64 bytes and the latter is 96 bytes.
As we generally allocate these on the stack, we end up blowing
up the stack.
Fix this by wrapping the scsi_execute() call with a properly
sized sense buffer, and copying back the bits for the CDROM
layer.
Cc: [email protected]
Reported-by: Piotr Gabriel Kosinski <[email protected]>
Reported-by: Daniel Shapira <[email protected]>
Tested-by: Kees Cook <[email protected]>
Fixes: 82ed4db499b8 ("block: split scsi_request out of struct request")
Signed-off-by: Jens Axboe <[email protected]> |
handle_ftp_ctl(struct conntrack *ct, const struct conn_lookup_ctx *ctx,
struct dp_packet *pkt,
const struct conn *conn_for_expectation,
long long now, enum ftp_ctl_pkt ftp_ctl, bool nat)
{
struct ip_header *l3_hdr = dp_packet_l3(pkt);
ovs_be32 v4_addr_rep = 0;
struct ct_addr v6_addr_rep;
size_t addr_offset_from_ftp_data_start = 0;
size_t addr_size = 0;
char *ftp_data_start;
bool do_seq_skew_adj = true;
enum ct_alg_mode mode = CT_FTP_MODE_ACTIVE;
if (detect_ftp_ctl_type(ctx, pkt) != ftp_ctl) {
return;
}
if (!nat || !conn_for_expectation->seq_skew) {
do_seq_skew_adj = false;
}
struct ovs_16aligned_ip6_hdr *nh6 = dp_packet_l3(pkt);
int64_t seq_skew = 0;
bool seq_skew_dir;
if (ftp_ctl == CT_FTP_CTL_OTHER) {
seq_skew = conn_for_expectation->seq_skew;
seq_skew_dir = conn_for_expectation->seq_skew_dir;
} else if (ftp_ctl == CT_FTP_CTL_INTEREST) {
enum ftp_ctl_pkt rc;
if (ctx->key.dl_type == htons(ETH_TYPE_IPV6)) {
rc = process_ftp_ctl_v6(ct, pkt, conn_for_expectation,
now, &v6_addr_rep, &ftp_data_start,
&addr_offset_from_ftp_data_start,
&addr_size, &mode);
} else {
rc = process_ftp_ctl_v4(ct, pkt, conn_for_expectation,
now, &v4_addr_rep, &ftp_data_start,
&addr_offset_from_ftp_data_start);
}
if (rc == CT_FTP_CTL_INVALID) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
VLOG_WARN_RL(&rl, "Invalid FTP control packet format");
pkt->md.ct_state |= CS_TRACKED | CS_INVALID;
return;
} else if (rc == CT_FTP_CTL_INTEREST) {
uint16_t ip_len;
if (ctx->key.dl_type == htons(ETH_TYPE_IPV6)) {
seq_skew = repl_ftp_v6_addr(pkt, v6_addr_rep, ftp_data_start,
addr_offset_from_ftp_data_start,
addr_size, mode);
seq_skew_dir = ctx->reply;
if (seq_skew) {
ip_len = ntohs(nh6->ip6_ctlun.ip6_un1.ip6_un1_plen);
ip_len += seq_skew;
nh6->ip6_ctlun.ip6_un1.ip6_un1_plen = htons(ip_len);
conn_seq_skew_set(ct, &conn_for_expectation->key, now,
seq_skew, seq_skew_dir);
}
} else {
seq_skew = repl_ftp_v4_addr(pkt, v4_addr_rep, ftp_data_start,
addr_offset_from_ftp_data_start);
seq_skew_dir = ctx->reply;
ip_len = ntohs(l3_hdr->ip_tot_len);
if (seq_skew) {
ip_len += seq_skew;
l3_hdr->ip_csum = recalc_csum16(l3_hdr->ip_csum,
l3_hdr->ip_tot_len, htons(ip_len));
l3_hdr->ip_tot_len = htons(ip_len);
conn_seq_skew_set(ct, &conn_for_expectation->key, now,
seq_skew, seq_skew_dir);
}
}
} else {
OVS_NOT_REACHED();
}
} else {
OVS_NOT_REACHED();
}
struct tcp_header *th = dp_packet_l4(pkt);
if (do_seq_skew_adj && seq_skew != 0) {
if (ctx->reply != conn_for_expectation->seq_skew_dir) {
uint32_t tcp_ack = ntohl(get_16aligned_be32(&th->tcp_ack));
if ((seq_skew > 0) && (tcp_ack < seq_skew)) {
/* Should not be possible; will be marked invalid. */
tcp_ack = 0;
} else if ((seq_skew < 0) && (UINT32_MAX - tcp_ack < -seq_skew)) {
tcp_ack = (-seq_skew) - (UINT32_MAX - tcp_ack);
} else {
tcp_ack -= seq_skew;
}
ovs_be32 new_tcp_ack = htonl(tcp_ack);
put_16aligned_be32(&th->tcp_ack, new_tcp_ack);
} else {
uint32_t tcp_seq = ntohl(get_16aligned_be32(&th->tcp_seq));
if ((seq_skew > 0) && (UINT32_MAX - tcp_seq < seq_skew)) {
tcp_seq = seq_skew - (UINT32_MAX - tcp_seq);
} else if ((seq_skew < 0) && (tcp_seq < -seq_skew)) {
/* Should not be possible; will be marked invalid. */
tcp_seq = 0;
} else {
tcp_seq += seq_skew;
}
ovs_be32 new_tcp_seq = htonl(tcp_seq);
put_16aligned_be32(&th->tcp_seq, new_tcp_seq);
}
}
th->tcp_csum = 0;
if (ctx->key.dl_type == htons(ETH_TYPE_IPV6)) {
th->tcp_csum = packet_csum_upperlayer6(nh6, th, ctx->key.nw_proto,
dp_packet_l4_size(pkt));
} else {
uint32_t tcp_csum = packet_csum_pseudoheader(l3_hdr);
th->tcp_csum = csum_finish(
csum_continue(tcp_csum, th, dp_packet_l4_size(pkt)));
}
return;
} | 0 | [
"CWE-400"
] | ovs | 35c280072c1c3ed58202745b7d27fbbd0736999b | 110,458,105,687,309,100,000,000,000,000,000,000,000 | 123 | flow: Support extra padding length.
Although not required, padding can be optionally added until
the packet length is MTU bytes. A packet with extra padding
currently fails sanity checks.
Vulnerability: CVE-2020-35498
Fixes: fa8d9001a624 ("miniflow_extract: Properly handle small IP packets.")
Reported-by: Joakim Hindersson <[email protected]>
Acked-by: Ilya Maximets <[email protected]>
Signed-off-by: Flavio Leitner <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]> |
static void rawsock_report_error(struct sock *sk, int err)
{
pr_debug("sk=%p err=%d\n", sk, err);
sk->sk_shutdown = SHUTDOWN_MASK;
sk->sk_err = -err;
sk->sk_error_report(sk);
rawsock_write_queue_purge(sk);
} | 0 | [
"CWE-276",
"CWE-703"
] | linux | 26896f01467a28651f7a536143fe5ac8449d4041 | 245,998,130,896,381,750,000,000,000,000,000,000,000 | 10 | net/nfc/rawsock.c: add CAP_NET_RAW check.
When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first.
Signed-off-by: Qingyu Li <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen)
{
struct evbuffer_chain *chain, *tmp;
int result = -1;
EVBUFFER_LOCK(buf);
if (buf->freeze_start) {
goto done;
}
chain = buf->first;
if (chain == NULL) {
chain = evbuffer_chain_new(datlen);
if (!chain)
goto done;
evbuffer_chain_insert(buf, chain);
}
/* we cannot touch immutable buffers */
if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) {
/* If this chain is empty, we can treat it as
* 'empty at the beginning' rather than 'empty at the end' */
if (chain->off == 0)
chain->misalign = chain->buffer_len;
if ((size_t)chain->misalign >= datlen) {
/* we have enough space to fit everything */
memcpy(chain->buffer + chain->misalign - datlen,
data, datlen);
chain->off += datlen;
chain->misalign -= datlen;
buf->total_len += datlen;
buf->n_add_for_cb += datlen;
goto out;
} else if (chain->misalign) {
/* we can only fit some of the data. */
memcpy(chain->buffer,
(char*)data + datlen - chain->misalign,
(size_t)chain->misalign);
chain->off += (size_t)chain->misalign;
buf->total_len += (size_t)chain->misalign;
buf->n_add_for_cb += (size_t)chain->misalign;
datlen -= (size_t)chain->misalign;
chain->misalign = 0;
}
}
/* we need to add another chain */
if ((tmp = evbuffer_chain_new(datlen)) == NULL)
goto done;
buf->first = tmp;
if (buf->last_with_datap == &buf->first)
buf->last_with_datap = &tmp->next;
tmp->next = chain;
tmp->off = datlen;
tmp->misalign = tmp->buffer_len - datlen;
memcpy(tmp->buffer + tmp->misalign, data, datlen);
buf->total_len += datlen;
buf->n_add_for_cb += (size_t)chain->misalign;
out:
evbuffer_invoke_callbacks(buf);
result = 0;
done:
EVBUFFER_UNLOCK(buf);
return result;
} | 1 | [
"CWE-189"
] | libevent | 20d6d4458bee5d88bda1511c225c25b2d3198d6c | 92,378,287,987,602,610,000,000,000,000,000,000,000 | 72 | Fix CVE-2014-6272 in Libevent 2.0
For this fix, we need to make sure that passing too-large inputs to
the evbuffer functions can't make us do bad things with the heap.
Also, lower the maximum chunk size to the lower of off_t, size_t maximum.
This is necessary since otherwise we could get into an infinite loop
if we make a chunk that 'misalign' cannot index into. |
hook_process (struct t_weechat_plugin *plugin,
const char *command, int timeout,
t_hook_callback_process *callback, void *callback_data)
{
return hook_process_hashtable (plugin, command, NULL, timeout,
callback, callback_data);
} | 0 | [
"CWE-20"
] | weechat | efb795c74fe954b9544074aafcebb1be4452b03a | 323,082,844,054,984,600,000,000,000,000,000,000,000 | 7 | core: do not call shell to execute command in hook_process (fix security problem when a plugin/script gives untrusted command) (bug #37764) |
static int csnmp_config_add_host_priv_protocol(host_definition_t *hd,
oconfig_item_t *ci) {
char buffer[4];
int status;
status = cf_util_get_string_buffer(ci, buffer, sizeof(buffer));
if (status != 0)
return status;
if (strcasecmp("AES", buffer) == 0) {
hd->priv_protocol = usmAESPrivProtocol;
hd->priv_protocol_len = sizeof(usmAESPrivProtocol) / sizeof(oid);
} else if (strcasecmp("DES", buffer) == 0) {
hd->priv_protocol = usmDESPrivProtocol;
hd->priv_protocol_len = sizeof(usmDESPrivProtocol) / sizeof(oid);
} else {
WARNING("snmp plugin: The `PrivProtocol' config option must be `AES' or "
"`DES'.");
return (-1);
}
DEBUG("snmp plugin: host = %s; host->priv_protocol = %s;", hd->name,
hd->priv_protocol == usmAESPrivProtocol ? "AES" : "DES");
return (0);
} /* int csnmp_config_add_host_priv_protocol */ | 0 | [
"CWE-415"
] | collectd | d16c24542b2f96a194d43a73c2e5778822b9cb47 | 83,010,207,213,268,140,000,000,000,000,000,000,000 | 26 | snmp plugin: Fix double free of request PDU
snmp_sess_synch_response() always frees request PDU, in both case of request
error and success. If error condition occurs inside of `while (status == 0)`
loop, double free of `req` happens.
Issue: #2291
Signed-off-by: Florian Forster <[email protected]> |
STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s)
{
if (s != NULL) {
if (s->cipher_list != NULL) {
return (s->cipher_list);
} else if ((s->ctx != NULL) && (s->ctx->cipher_list != NULL)) {
return (s->ctx->cipher_list);
}
}
return (NULL);
} | 0 | [
"CWE-310"
] | openssl | 56f1acf5ef8a432992497a04792ff4b3b2c6f286 | 139,913,458,743,933,420,000,000,000,000,000,000,000 | 11 | Disable SSLv2 default build, default negotiation and weak ciphers.
SSLv2 is by default disabled at build-time. Builds that are not
configured with "enable-ssl2" will not support SSLv2. Even if
"enable-ssl2" is used, users who want to negotiate SSLv2 via the
version-flexible SSLv23_method() will need to explicitly call either
of:
SSL_CTX_clear_options(ctx, SSL_OP_NO_SSLv2);
or
SSL_clear_options(ssl, SSL_OP_NO_SSLv2);
as appropriate. Even if either of those is used, or the application
explicitly uses the version-specific SSLv2_method() or its client
or server variants, SSLv2 ciphers vulnerable to exhaustive search
key recovery have been removed. Specifically, the SSLv2 40-bit
EXPORT ciphers, and SSLv2 56-bit DES are no longer available.
Mitigation for CVE-2016-0800
Reviewed-by: Emilia Käsper <[email protected]> |
static struct stream_encoder *dce120_stream_encoder_create(
enum engine_id eng_id,
struct dc_context *ctx)
{
struct dce110_stream_encoder *enc110 =
kzalloc(sizeof(struct dce110_stream_encoder), GFP_KERNEL);
if (!enc110)
return NULL;
dce110_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id,
&stream_enc_regs[eng_id],
&se_shift, &se_mask);
return &enc110->base;
} | 0 | [
"CWE-400",
"CWE-401"
] | linux | 104c307147ad379617472dd91a5bcb368d72bd6d | 333,534,071,345,663,400,000,000,000,000,000,000,000 | 15 | drm/amd/display: prevent memory leak
In dcn*_create_resource_pool the allocated memory should be released if
construct pool fails.
Reviewed-by: Harry Wentland <[email protected]>
Signed-off-by: Navid Emamdoost <[email protected]>
Signed-off-by: Alex Deucher <[email protected]> |
static int ieee80211_change_da(struct sk_buff *skb, struct sta_info *sta)
{
struct ethhdr *eth;
int err;
err = skb_ensure_writable(skb, ETH_HLEN);
if (unlikely(err))
return err;
eth = (void *)skb->data;
ether_addr_copy(eth->h_dest, sta->sta.addr);
return 0;
} | 0 | [
"CWE-476"
] | linux | bddc0c411a45d3718ac535a070f349be8eca8d48 | 265,564,635,874,191,200,000,000,000,000,000,000,000 | 14 | mac80211: Fix NULL ptr deref for injected rate info
The commit cb17ed29a7a5 ("mac80211: parse radiotap header when selecting Tx
queue") moved the code to validate the radiotap header from
ieee80211_monitor_start_xmit to ieee80211_parse_tx_radiotap. This made is
possible to share more code with the new Tx queue selection code for
injected frames. But at the same time, it now required the call of
ieee80211_parse_tx_radiotap at the beginning of functions which wanted to
handle the radiotap header. And this broke the rate parser for radiotap
header parser.
The radiotap parser for rates is operating most of the time only on the
data in the actual radiotap header. But for the 802.11a/b/g rates, it must
also know the selected band from the chandef information. But this
information is only written to the ieee80211_tx_info at the end of the
ieee80211_monitor_start_xmit - long after ieee80211_parse_tx_radiotap was
already called. The info->band information was therefore always 0
(NL80211_BAND_2GHZ) when the parser code tried to access it.
For a 5GHz only device, injecting a frame with 802.11a rates would cause a
NULL pointer dereference because local->hw.wiphy->bands[NL80211_BAND_2GHZ]
would most likely have been NULL when the radiotap parser searched for the
correct rate index of the driver.
Cc: [email protected]
Reported-by: Ben Greear <[email protected]>
Fixes: cb17ed29a7a5 ("mac80211: parse radiotap header when selecting Tx queue")
Signed-off-by: Mathy Vanhoef <[email protected]>
[[email protected]: added commit message]
Signed-off-by: Sven Eckelmann <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]> |
static bool is_inf(const signed char) { return false; } | 0 | [
"CWE-125"
] | CImg | 10af1e8c1ad2a58a0a3342a856bae63e8f257abb | 289,932,771,682,988,370,000,000,000,000,000,000,000 | 1 | Fix other issues in 'CImg<T>::load_bmp()'. |
static uint8_t get_mode(const char *mode)
{
if (strcasecmp("off", mode) == 0)
return MODE_OFF;
else if (strcasecmp("connectable", mode) == 0)
return MODE_CONNECTABLE;
else if (strcasecmp("discoverable", mode) == 0)
return MODE_DISCOVERABLE;
else
return MODE_UNKNOWN;
} | 0 | [
"CWE-862",
"CWE-863"
] | bluez | b497b5942a8beb8f89ca1c359c54ad67ec843055 | 101,869,172,356,970,460,000,000,000,000,000,000,000 | 11 | adapter: Fix storing discoverable setting
discoverable setting shall only be store when changed via Discoverable
property and not when discovery client set it as that be considered
temporary just for the lifetime of the discovery. |
static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
return zend_fetch_property_address_read_helper_SPEC_UNUSED_CONST(BP_VAR_IS, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
} | 0 | [] | php-src | ce96fd6b0761d98353761bf78d5bfb55291179fd | 60,865,467,857,442,840,000,000,000,000,000,000,000 | 4 | - fix #39863, do not accept paths with NULL in them. See http://news.php.net/php.internals/50191, trunk will have the patch later (adding a macro and/or changing (some) APIs. Patch by Rasmus |
static inline int check_target(struct arpt_entry *e, const char *name)
{
struct xt_entry_target *t = arpt_get_target(e);
struct xt_tgchk_param par = {
.table = name,
.entryinfo = e,
.target = t->u.kernel.target,
.targinfo = t->data,
.hook_mask = e->comefrom,
.family = NFPROTO_ARP,
};
return xt_check_target(&par, t->u.target_size - sizeof(*t), 0, false);
} | 0 | [
"CWE-476"
] | linux | 57ebd808a97d7c5b1e1afb937c2db22beba3c1f8 | 245,098,743,972,145,260,000,000,000,000,000,000,000 | 14 | netfilter: add back stackpointer size checks
The rationale for removing the check is only correct for rulesets
generated by ip(6)tables.
In iptables, a jump can only occur to a user-defined chain, i.e.
because we size the stack based on number of user-defined chains we
cannot exceed stack size.
However, the underlying binary format has no such restriction,
and the validation step only ensures that the jump target is a
valid rule start point.
IOW, its possible to build a rule blob that has no user-defined
chains but does contain a jump.
If this happens, no jump stack gets allocated and crash occurs
because no jumpstack was allocated.
Fixes: 7814b6ec6d0d6 ("netfilter: xtables: don't save/restore jumpstack offset")
Reported-by: [email protected]
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]> |
set_imsearch_global(void)
{
p_imsearch = curbuf->b_p_imsearch;
} | 0 | [
"CWE-20"
] | vim | d0b5138ba4bccff8a744c99836041ef6322ed39a | 54,596,089,685,307,275,000,000,000,000,000,000,000 | 4 | patch 8.0.0056
Problem: When setting 'filetype' there is no check for a valid name.
Solution: Only allow valid characters in 'filetype', 'syntax' and 'keymap'. |
ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) {
ASSERT_IN_VM;
// Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
CompilerThread* current_thread = CompilerThread::current();
assert(current_thread->env() == NULL, "must be");
current_thread->set_env(this);
assert(ciEnv::current() == this, "sanity");
_oop_recorder = NULL;
_debug_info = NULL;
_dependencies = NULL;
_failure_reason = NULL;
_inc_decompile_count_on_failure = true;
_compilable = MethodCompilable_never;
_break_at_compile = false;
_compiler_data = NULL;
#ifndef PRODUCT
assert(firstEnv, "must be first");
firstEnv = false;
#endif /* !PRODUCT */
_num_inlined_bytecodes = 0;
_task = NULL;
_log = NULL;
// Temporary buffer for creating symbols and such.
_name_buffer = NULL;
_name_buffer_len = 0;
_arena = arena;
_factory = new (_arena) ciObjectFactory(_arena, 128);
// Preload commonly referenced system ciObjects.
// During VM initialization, these instances have not yet been created.
// Assertions ensure that these instances are not accessed before
// their initialization.
assert(Universe::is_fully_initialized(), "must be");
_NullPointerException_instance = NULL;
_ArithmeticException_instance = NULL;
_ArrayIndexOutOfBoundsException_instance = NULL;
_ArrayStoreException_instance = NULL;
_ClassCastException_instance = NULL;
_the_null_string = NULL;
_the_min_jint_string = NULL;
_jvmti_redefinition_count = 0;
_jvmti_can_hotswap_or_post_breakpoint = false;
_jvmti_can_access_local_variables = false;
_jvmti_can_post_on_exceptions = false;
_jvmti_can_pop_frame = false;
} | 0 | [] | jdk17u | 8be0fc09f0ba2dd1dbfd6627456fa929d5574b04 | 135,495,971,320,034,940,000,000,000,000,000,000,000 | 55 | 8281859: Improve class compilation
Reviewed-by: mbaesken
Backport-of: 3ac62a66efd05d0842076dd4cfbea0e53b12630f |
void CLASS parse_kodak_ifd (int base)
{
unsigned entries, tag, type, len, save;
int i, c, wbi=-2;
float mul[3]={1,1,1}, num;
static const int wbtag[] = { 64037,64040,64039,64041,-1,-1,64042 };
entries = get2();
if (entries > 1024) return;
INT64 fsize = ifp->size();
while (entries--) {
tiff_get (base, &tag, &type, &len, &save);
INT64 savepos = ftell(ifp);
if(len > 8 && len + savepos > 2*fsize) continue;
if(callbacks.exif_cb)
{
callbacks.exif_cb(callbacks.exifparser_data,tag | 0x20000,type,len,order,ifp);
fseek(ifp,savepos,SEEK_SET);
}
if (tag == 1011) imgdata.other.FlashEC = getreal(type);
if (tag == 1020) wbi = getint(type);
if (tag == 1021 && len == 72) { /* WB set in software */
fseek (ifp, 40, SEEK_CUR);
FORC3 cam_mul[c] = 2048.0 / fMAX(1.0f,get2());
wbi = -2;
}
if (tag == 0x0848) Kodak_WB_0x08tags(LIBRAW_WBI_Daylight, type);
if (tag == 0x0849) Kodak_WB_0x08tags(LIBRAW_WBI_Tungsten, type);
if (tag == 0x084a) Kodak_WB_0x08tags(LIBRAW_WBI_Fluorescent, type);
if (tag == 0x084b) Kodak_WB_0x08tags(LIBRAW_WBI_Flash, type);
if (tag == 0x0e93) imgdata.color.linear_max[0] =
imgdata.color.linear_max[1] =
imgdata.color.linear_max[2] =
imgdata.color.linear_max[3] = get2();
if (tag == 0x09ce)
stmread(imgdata.shootinginfo.InternalBodySerial,len, ifp);
if (tag == 0xfa00)
stmread(imgdata.shootinginfo.BodySerial, len, ifp);
if (tag == 0xfa27)
{
FORC3 imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][c] = get4();
imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][3] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][1];
}
if (tag == 0xfa28)
{
FORC3 imgdata.color.WB_Coeffs[LIBRAW_WBI_Fluorescent][c] = get4();
imgdata.color.WB_Coeffs[LIBRAW_WBI_Fluorescent][3] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Fluorescent][1];
}
if (tag == 0xfa29)
{
FORC3 imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][c] = get4();
imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][3] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][1];
}
if (tag == 0xfa2a)
{
FORC3 imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][c] = get4();
imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][3] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][1];
}
if (tag == 2120 + wbi ||
(wbi<0 && tag == 2125)) /* use Auto WB if illuminant index is not set */
{
FORC3 mul[c] = (num=getreal(type))==0 ? 1 : num;
FORC3 cam_mul[c] = mul[1] / mul[c]; /* normalise against green */
}
if (tag == 2317) linear_table (len);
if (tag == 0x903) iso_speed = getreal(type);
//if (tag == 6020) iso_speed = getint(type);
if (tag == 64013) wbi = fgetc(ifp);
if ((unsigned) wbi < 7 && tag == wbtag[wbi])
FORC3 cam_mul[c] = get4();
if (tag == 64019) width = getint(type);
if (tag == 64020) height = (getint(type)+1) & -2;
fseek (ifp, save, SEEK_SET);
}
} | 0 | [
"CWE-119",
"CWE-125",
"CWE-787"
] | LibRaw | d13e8f6d1e987b7491182040a188c16a395f1d21 | 111,709,334,961,292,880,000,000,000,000,000,000,000 | 77 | CVE-2017-1438 credits; fix for Kodak 65000 out of bounds access |
static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net_device **pdev, struct br_mdb_entry **pentry)
{
struct net *net = sock_net(skb->sk);
struct br_mdb_entry *entry;
struct br_port_msg *bpm;
struct nlattr *tb[MDBA_SET_ENTRY_MAX+1];
struct net_device *dev;
int err;
err = nlmsg_parse(nlh, sizeof(*bpm), tb, MDBA_SET_ENTRY, NULL);
if (err < 0)
return err;
bpm = nlmsg_data(nlh);
if (bpm->ifindex == 0) {
pr_info("PF_BRIDGE: br_mdb_parse() with invalid ifindex\n");
return -EINVAL;
}
dev = __dev_get_by_index(net, bpm->ifindex);
if (dev == NULL) {
pr_info("PF_BRIDGE: br_mdb_parse() with unknown ifindex\n");
return -ENODEV;
}
if (!(dev->priv_flags & IFF_EBRIDGE)) {
pr_info("PF_BRIDGE: br_mdb_parse() with non-bridge\n");
return -EOPNOTSUPP;
}
*pdev = dev;
if (!tb[MDBA_SET_ENTRY] ||
nla_len(tb[MDBA_SET_ENTRY]) != sizeof(struct br_mdb_entry)) {
pr_info("PF_BRIDGE: br_mdb_parse() with invalid attr\n");
return -EINVAL;
}
entry = nla_data(tb[MDBA_SET_ENTRY]);
if (!is_valid_mdb_entry(entry)) {
pr_info("PF_BRIDGE: br_mdb_parse() with invalid entry\n");
return -EINVAL;
}
*pentry = entry;
return 0;
} | 0 | [
"CWE-399"
] | linux-2.6 | c085c49920b2f900ba716b4ca1c1a55ece9872cc | 154,726,165,749,886,270,000,000,000,000,000,000,000 | 48 | bridge: fix mdb info leaks
The bridging code discloses heap and stack bytes via the RTM_GETMDB
netlink interface and via the notify messages send to group RTNLGRP_MDB
afer a successful add/del.
Fix both cases by initializing all unset members/padding bytes with
memset(0).
Cc: Stephen Hemminger <[email protected]>
Signed-off-by: Mathias Krause <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
pdf_filter_q(fz_context *ctx, pdf_processor *proc)
{
pdf_filter_processor *p = (pdf_filter_processor*)proc;
filter_push(ctx, p);
} | 0 | [
"CWE-125"
] | mupdf | 97096297d409ec6f206298444ba00719607e8ba8 | 90,924,665,196,065,100,000,000,000,000,000,000,000 | 5 | Bug 701292: Fix test for missing/empty string. |
port::StatusOr<bool> UseTensorOps(Stream* stream, dnn::DataType type,
absl::optional<dnn::AlgorithmDesc> desc) {
bool use_tensor_ops;
if (desc.has_value()) {
use_tensor_ops = desc->tensor_ops_enabled();
if (use_tensor_ops && !IsTensorMathEnabled(stream, type)) {
return port::Status(port::error::INVALID_ARGUMENT,
"Algo requests disabled tensor op evaluation.");
}
} else {
use_tensor_ops = IsTensorMathEnabled(stream, type);
}
return use_tensor_ops;
} | 0 | [
"CWE-20"
] | tensorflow | 14755416e364f17fb1870882fa778c7fec7f16e3 | 83,422,914,970,364,160,000,000,000,000,000,000,000 | 14 | Prevent CHECK-fail in LSTM/GRU with zero-length input.
PiperOrigin-RevId: 346239181
Change-Id: I5f233dbc076aab7bb4e31ba24f5abd4eaf99ea4f |
void vterm_set_size(VTerm *vt, int rows, int cols)
{
vt->rows = rows;
vt->cols = cols;
if(vt->parser.callbacks && vt->parser.callbacks->resize)
(*vt->parser.callbacks->resize)(rows, cols, vt->parser.cbdata);
} | 0 | [
"CWE-476"
] | vim | cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8 | 337,722,020,198,730,100,000,000,000,000,000,000,000 | 8 | patch 8.1.0633: crash when out of memory while opening a terminal window
Problem: Crash when out of memory while opening a terminal window.
Solution: Handle out-of-memory more gracefully. |
static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc)
{
struct anon_vma *anon_vma;
pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
struct anon_vma_chain *avc;
int ret = SWAP_AGAIN;
anon_vma = rmap_walk_anon_lock(page, rwc);
if (!anon_vma)
return ret;
anon_vma_interval_tree_foreach(avc, &anon_vma->rb_root, pgoff, pgoff) {
struct vm_area_struct *vma = avc->vma;
unsigned long address = vma_address(page, vma);
if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg))
continue;
ret = rwc->rmap_one(page, vma, address, rwc->arg);
if (ret != SWAP_AGAIN)
break;
if (rwc->done && rwc->done(page))
break;
}
anon_vma_unlock_read(anon_vma);
return ret;
} | 0 | [
"CWE-400",
"CWE-703",
"CWE-264"
] | linux | 57e68e9cd65b4b8eb4045a1e0d0746458502554c | 278,213,880,274,745,160,000,000,000,000,000,000,000 | 27 | mm: try_to_unmap_cluster() should lock_page() before mlocking
A BUG_ON(!PageLocked) was triggered in mlock_vma_page() by Sasha Levin
fuzzing with trinity. The call site try_to_unmap_cluster() does not lock
the pages other than its check_page parameter (which is already locked).
The BUG_ON in mlock_vma_page() is not documented and its purpose is
somewhat unclear, but apparently it serializes against page migration,
which could otherwise fail to transfer the PG_mlocked flag. This would
not be fatal, as the page would be eventually encountered again, but
NR_MLOCK accounting would become distorted nevertheless. This patch adds
a comment to the BUG_ON in mlock_vma_page() and munlock_vma_page() to that
effect.
The call site try_to_unmap_cluster() is fixed so that for page !=
check_page, trylock_page() is attempted (to avoid possible deadlocks as we
already have check_page locked) and mlock_vma_page() is performed only
upon success. If the page lock cannot be obtained, the page is left
without PG_mlocked, which is again not a problem in the whole unevictable
memory design.
Signed-off-by: Vlastimil Babka <[email protected]>
Signed-off-by: Bob Liu <[email protected]>
Reported-by: Sasha Levin <[email protected]>
Cc: Wanpeng Li <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
cmsBool Type_MPEmatrix_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsUInt32Number i, nElems;
cmsStage* mpe = (cmsStage*) Ptr;
_cmsStageMatrixData* Matrix = (_cmsStageMatrixData*) mpe ->Data;
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->OutputChannels)) return FALSE;
nElems = mpe ->InputChannels * mpe ->OutputChannels;
for (i=0; i < nElems; i++) {
if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Double[i])) return FALSE;
}
for (i=0; i < mpe ->OutputChannels; i++) {
if (Matrix ->Offset == NULL) {
if (!_cmsWriteFloat32Number(io, 0)) return FALSE;
}
else {
if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Offset[i])) return FALSE;
}
}
return TRUE;
cmsUNUSED_PARAMETER(nItems);
cmsUNUSED_PARAMETER(self);
} | 0 | [] | Little-CMS | 41d222df1bc6188131a8f46c32eab0a4d4cdf1b6 | 300,362,448,532,042,900,000,000,000,000,000,000,000 | 32 | Memory squeezing fix: lcms2 cmsPipeline construction
When creating a new pipeline, lcms would often try to allocate a stage
and pass it to cmsPipelineInsertStage without checking whether the
allocation succeeded. cmsPipelineInsertStage would then assert (or crash)
if it had not.
The fix here is to change cmsPipelineInsertStage to check and return
an error value. All calling code is then checked to test this return
value and cope. |
rsvg_filter_primitive_component_transfer_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPropertyBag *atts)
{
RsvgFilterPrimitiveComponentTransfer *filter = impl;
const char *value;
if ((value = rsvg_property_bag_lookup (atts, "result")))
g_string_assign (filter->super.result, value);
if ((value = rsvg_property_bag_lookup (atts, "in")))
g_string_assign (filter->super.in, value);
filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
} | 0 | [
"CWE-369"
] | librsvg | ecf9267a24b2c3c0cd211dbdfa9ef2232511972a | 188,036,740,442,422,130,000,000,000,000,000,000,000 | 12 | bgo#783835 - Don't divide by zero in box_blur_line() for gaussian blurs
We were making the decision to use box blurs, instead of a true
Gaussian kernel, based on the size of *both* x and y dimensions. Do
them individually instead. |
static int SD_Call(GGadget *g, GEvent *e) {
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
char *fn;
unichar_t *insert;
fn = gwwv_open_filename(_("Call Script"), NULL, "*",NULL);
if ( fn==NULL )
return(true);
insert = malloc((strlen(fn)+10)*sizeof(unichar_t));
*insert = '"';
utf82u_strcpy(insert+1,fn);
uc_strcat(insert,"\"()");
GTextFieldReplace(GWidgetGetControl(GGadgetGetWindow(g),CID_Script),insert);
free(insert);
free(fn);
}
return( true );
} | 0 | [
"CWE-119",
"CWE-787"
] | fontforge | 626f751752875a0ddd74b9e217b6f4828713573c | 276,958,425,781,202,100,000,000,000,000,000,000,000 | 18 | Warn users before discarding their unsaved scripts (#3852)
* Warn users before discarding their unsaved scripts
This closes #3846. |
static int ssl3_get_record(SSL *s)
{
int ssl_major,ssl_minor,al;
int enc_err,n,i,ret= -1;
SSL3_RECORD *rr;
SSL_SESSION *sess;
unsigned char *p;
unsigned char md[EVP_MAX_MD_SIZE];
short version;
int mac_size;
int clear=0;
size_t extra;
int decryption_failed_or_bad_record_mac = 0;
unsigned char *mac = NULL;
rr= &(s->s3->rrec);
sess=s->session;
if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER)
extra=SSL3_RT_MAX_EXTRA;
else
extra=0;
if (extra && !s->s3->init_extra)
{
/* An application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER
* set after ssl3_setup_buffers() was done */
SSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR);
return -1;
}
again:
/* check if we have the header */
if ( (s->rstate != SSL_ST_READ_BODY) ||
(s->packet_length < SSL3_RT_HEADER_LENGTH))
{
n=ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);
if (n <= 0) return(n); /* error or non-blocking */
s->rstate=SSL_ST_READ_BODY;
p=s->packet;
/* Pull apart the header into the SSL3_RECORD */
rr->type= *(p++);
ssl_major= *(p++);
ssl_minor= *(p++);
version=(ssl_major<<8)|ssl_minor;
n2s(p,rr->length);
#if 0
fprintf(stderr, "Record type=%d, Length=%d\n", rr->type, rr->length);
#endif
/* Lets check version */
if (!s->first_packet)
{
if (version != s->version)
{
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER);
if ((s->version & 0xFF00) == (version & 0xFF00))
/* Send back error using their minor version number :-) */
s->version = (unsigned short)version;
al=SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
}
if ((version>>8) != SSL3_VERSION_MAJOR)
{
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER);
goto err;
}
if (rr->length > s->s3->rbuf.len - SSL3_RT_HEADER_LENGTH)
{
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG);
goto f_err;
}
/* now s->rstate == SSL_ST_READ_BODY */
}
/* s->rstate == SSL_ST_READ_BODY, get and decode the data */
if (rr->length > s->packet_length-SSL3_RT_HEADER_LENGTH)
{
/* now s->packet_length == SSL3_RT_HEADER_LENGTH */
i=rr->length;
n=ssl3_read_n(s,i,i,1);
if (n <= 0) return(n); /* error or non-blocking io */
/* now n == rr->length,
* and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */
}
s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */
/* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length,
* and we have that many bytes in s->packet
*/
rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]);
/* ok, we can now read from 's->packet' data into 'rr'
* rr->input points at rr->length bytes, which
* need to be copied into rr->data by either
* the decryption or by the decompression
* When the data is 'copied' into the rr->data buffer,
* rr->input will be pointed at the new buffer */
/* We now have - encrypted [ MAC [ compressed [ plain ] ] ]
* rr->length bytes of encrypted compressed stuff. */
/* check is not needed I believe */
if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
{
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG);
goto f_err;
}
/* decrypt in place in 'rr->input' */
rr->data=rr->input;
enc_err = s->method->ssl3_enc->enc(s,0);
if (enc_err <= 0)
{
if (enc_err == 0)
/* SSLerr() and ssl3_send_alert() have been called */
goto err;
/* Otherwise enc_err == -1, which indicates bad padding
* (rec->length has not been changed in this case).
* To minimize information leaked via timing, we will perform
* the MAC computation anyway. */
decryption_failed_or_bad_record_mac = 1;
}
#ifdef TLS_DEBUG
printf("dec %d\n",rr->length);
{ unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); }
printf("\n");
#endif
/* r->length is now the compressed data plus mac */
if ( (sess == NULL) ||
(s->enc_read_ctx == NULL) ||
(EVP_MD_CTX_md(s->read_hash) == NULL))
clear=1;
if (!clear)
{
/* !clear => s->read_hash != NULL => mac_size != -1 */
mac_size=EVP_MD_CTX_size(s->read_hash);
OPENSSL_assert(mac_size >= 0);
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size)
{
#if 0 /* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) */
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
goto f_err;
#else
decryption_failed_or_bad_record_mac = 1;
#endif
}
/* check the MAC for rr->input (it's in mac_size bytes at the tail) */
if (rr->length >= (unsigned int)mac_size)
{
rr->length -= mac_size;
mac = &rr->data[rr->length];
}
else
{
/* record (minus padding) is too short to contain a MAC */
#if 0 /* OK only for stream ciphers */
al=SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);
goto f_err;
#else
decryption_failed_or_bad_record_mac = 1;
rr->length = 0;
#endif
}
i=s->method->ssl3_enc->mac(s,md,0);
if (i < 0 || mac == NULL || memcmp(md, mac, (size_t)mac_size) != 0)
{
decryption_failed_or_bad_record_mac = 1;
}
}
if (decryption_failed_or_bad_record_mac)
{
/* A separate 'decryption_failed' alert was introduced with TLS 1.0,
* SSL 3.0 only has 'bad_record_mac'. But unless a decryption
* failure is directly visible from the ciphertext anyway,
* we should not reveal which kind of error occured -- this
* might become visible to an attacker (e.g. via a logfile) */
al=SSL_AD_BAD_RECORD_MAC;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);
goto f_err;
}
/* r->length is now just compressed */
if (s->expand != NULL)
{
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra)
{
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG);
goto f_err;
}
if (!ssl3_do_uncompress(s))
{
al=SSL_AD_DECOMPRESSION_FAILURE;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BAD_DECOMPRESSION);
goto f_err;
}
}
if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH+extra)
{
al=SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG);
goto f_err;
}
rr->off=0;
/* So at this point the following is true
* ssl->s3->rrec.type is the type of record
* ssl->s3->rrec.length == number of bytes in record
* ssl->s3->rrec.off == offset to first valid byte
* ssl->s3->rrec.data == where to take bytes from, increment
* after use :-).
*/
/* we have pulled in a full packet so zero things */
s->packet_length=0;
/* just read a 0 length packet */
if (rr->length == 0) goto again;
#if 0
fprintf(stderr, "Ultimate Record type=%d, Length=%d\n", rr->type, rr->length);
#endif
return(1);
f_err:
ssl3_send_alert(s,SSL3_AL_FATAL,al);
err:
return(ret);
} | 1 | [
"CWE-310"
] | openssl | 9c00a950604aca819cee977f1dcb4b45f2af3aa6 | 197,807,830,514,803,800,000,000,000,000,000,000,000 | 250 | Add and use a constant-time memcmp.
This change adds CRYPTO_memcmp, which compares two vectors of bytes in
an amount of time that's independent of their contents. It also changes
several MAC compares in the code to use this over the standard memcmp,
which may leak information about the size of a matching prefix.
(cherry picked from commit 2ee798880a246d648ecddadc5b91367bee4a5d98)
Conflicts:
crypto/crypto.h
ssl/t1_lib.c |
static int qrtr_port_assign(struct qrtr_sock *ipc, int *port)
{
u32 min_port;
int rc;
mutex_lock(&qrtr_port_lock);
if (!*port) {
min_port = QRTR_MIN_EPH_SOCKET;
rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, QRTR_MAX_EPH_SOCKET, GFP_ATOMIC);
if (!rc)
*port = min_port;
} else if (*port < QRTR_MIN_EPH_SOCKET && !capable(CAP_NET_ADMIN)) {
rc = -EACCES;
} else if (*port == QRTR_PORT_CTRL) {
min_port = 0;
rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, 0, GFP_ATOMIC);
} else {
min_port = *port;
rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, *port, GFP_ATOMIC);
if (!rc)
*port = min_port;
}
mutex_unlock(&qrtr_port_lock);
if (rc == -ENOSPC)
return -EADDRINUSE;
else if (rc < 0)
return rc;
sock_hold(&ipc->sk);
return 0;
} | 0 | [
"CWE-909"
] | linux | 50535249f624d0072cd885bcdce4e4b6fb770160 | 320,223,795,268,845,800,000,000,000,000,000,000,000 | 33 | net: qrtr: fix a kernel-infoleak in qrtr_recvmsg()
struct sockaddr_qrtr has a 2-byte hole, and qrtr_recvmsg() currently
does not clear it before copying kernel data to user space.
It might be too late to name the hole since sockaddr_qrtr structure is uapi.
BUG: KMSAN: kernel-infoleak in kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249
CPU: 0 PID: 29705 Comm: syz-executor.3 Not tainted 5.11.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x21c/0x280 lib/dump_stack.c:120
kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
kmsan_internal_check_memory+0x202/0x520 mm/kmsan/kmsan.c:402
kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249
instrument_copy_to_user include/linux/instrumented.h:121 [inline]
_copy_to_user+0x1ac/0x270 lib/usercopy.c:33
copy_to_user include/linux/uaccess.h:209 [inline]
move_addr_to_user+0x3a2/0x640 net/socket.c:237
____sys_recvmsg+0x696/0xd50 net/socket.c:2575
___sys_recvmsg net/socket.c:2610 [inline]
do_recvmmsg+0xa97/0x22d0 net/socket.c:2710
__sys_recvmmsg net/socket.c:2789 [inline]
__do_sys_recvmmsg net/socket.c:2812 [inline]
__se_sys_recvmmsg+0x24a/0x410 net/socket.c:2805
__x64_sys_recvmmsg+0x62/0x80 net/socket.c:2805
do_syscall_64+0x9f/0x140 arch/x86/entry/common.c:48
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x465f69
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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f43659d6188 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 0000000000465f69
RDX: 0000000000000008 RSI: 0000000020003e40 RDI: 0000000000000003
RBP: 00000000004bfa8f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000010060 R11: 0000000000000246 R12: 000000000056bf60
R13: 0000000000a9fb1f R14: 00007f43659d6300 R15: 0000000000022000
Local variable ----addr@____sys_recvmsg created at:
____sys_recvmsg+0x168/0xd50 net/socket.c:2550
____sys_recvmsg+0x168/0xd50 net/socket.c:2550
Bytes 2-3 of 12 are uninitialized
Memory access of size 12 starts at ffff88817c627b40
Data copied to user address 0000000020000140
Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Signed-off-by: Eric Dumazet <[email protected]>
Cc: Courtney Cavin <[email protected]>
Reported-by: syzbot <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
static void smack_key_free(struct key *key)
{
key->security = NULL;
} | 0 | [] | linux-2.6 | ee18d64c1f632043a02e6f5ba5e045bb26a5465f | 231,342,268,943,993,570,000,000,000,000,000,000,000 | 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 <[email protected]>
Signed-off-by: James Morris <[email protected]> |
ves_icall_System_Threading_Thread_MemoryBarrier (void)
{
mono_threads_lock ();
mono_threads_unlock ();
} | 0 | [
"CWE-399",
"CWE-264"
] | mono | 722f9890f09aadfc37ae479e7d946d5fc5ef7b91 | 115,470,842,002,390,230,000,000,000,000,000,000,000 | 5 | Fix access to freed members of a dead thread
* threads.c: Fix access to freed members of a dead thread. Found
and fixed by Rodrigo Kumpera <[email protected]>
Ref: CVE-2011-0992 |
InputBuffer(UChar32* buffer, char* widthArray, int bufferLen)
: buf32(buffer), charWidths(widthArray), buflen(bufferLen - 1), len(0), pos(0) {
buf32[0] = 0;
} | 0 | [
"CWE-200"
] | mongo | 035cf2afc04988b22cb67f4ebfd77e9b344cb6e0 | 245,721,462,537,529,470,000,000,000,000,000,000,000 | 4 | SERVER-25335 avoid group and other permissions when creating .dbshell history file |
static PHP_FUNCTION(xmlwriter_write_element)
{
zval *pind;
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *content = NULL;
int name_len, content_len, retval;
#ifdef ZEND_ENGINE_2
zval *this = getThis();
if (this) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!",
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
XMLWRITER_FROM_OBJECT(intern, this);
} else
#endif
{
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
XMLW_NAME_CHK("Invalid Element Name");
ptr = intern->ptr;
if (ptr) {
if (!content) {
retval = xmlTextWriterStartElement(ptr, (xmlChar *)name);
if (retval == -1) {
RETURN_FALSE;
}
xmlTextWriterEndElement(ptr);
if (retval == -1) {
RETURN_FALSE;
}
} else {
retval = xmlTextWriterWriteElement(ptr, (xmlChar *)name, (xmlChar *)content);
}
if (retval != -1) {
RETURN_TRUE;
}
}
RETURN_FALSE;
} | 0 | [
"CWE-20"
] | php-src | 52b93f0cfd3cba7ff98cc5198df6ca4f23865f80 | 143,164,183,418,351,930,000,000,000,000,000,000,000 | 51 | Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions) |
cmd_spec_useragent (const char *com, const char *val, void *place_ignored _GL_UNUSED)
{
/* Disallow embedded newlines. */
if (strchr (val, '\n'))
{
fprintf (stderr, _("%s: %s: Invalid value %s.\n"),
exec_name, com, quote (val));
return false;
}
xfree (opt.useragent);
opt.useragent = xstrdup (val);
return true;
} | 0 | [
"CWE-200"
] | wget | c125d24762962d91050d925fbbd9e6f30b2302f8 | 124,250,913,996,575,620,000,000,000,000,000,000,000 | 13 | Don't use extended attributes (--xattr) by default
* src/init.c (defaults): Set enable_xattr to false by default
* src/main.c (print_help): Reverse option logic of --xattr
* doc/wget.texi: Add description for --xattr
Users may not be aware that the origin URL and Referer are saved
including credentials, and possibly access tokens within
the urls. |
static void gdImageTileApply (gdImagePtr im, int x, int y)
{
gdImagePtr tile = im->tile;
int srcx, srcy;
int p;
if (!tile) {
return;
}
srcx = x % gdImageSX(tile);
srcy = y % gdImageSY(tile);
if (im->trueColor) {
p = gdImageGetPixel(tile, srcx, srcy);
if (p != gdImageGetTransparent (tile)) {
if (!tile->trueColor) {
p = gdTrueColorAlpha(tile->red[p], tile->green[p], tile->blue[p], tile->alpha[p]);
}
gdImageSetPixel(im, x, y, p);
}
} else {
p = gdImageGetPixel(tile, srcx, srcy);
/* Allow for transparency */
if (p != gdImageGetTransparent(tile)) {
if (tile->trueColor) {
/* Truecolor tile. Very slow on a palette destination. */
gdImageSetPixel(im, x, y, gdImageColorResolveAlpha(im,
gdTrueColorGetRed(p),
gdTrueColorGetGreen(p),
gdTrueColorGetBlue(p),
gdTrueColorGetAlpha(p)));
} else {
gdImageSetPixel(im, x, y, im->tileColorMap[p]);
}
}
}
} | 0 | [
"CWE-119"
] | php-src | e7f2356665c2569191a946b6fc35b437f0ae1384 | 306,931,785,885,693,430,000,000,000,000,000,000,000 | 35 | Fix #66387: Stack overflow with imagefilltoborder
The stack overflow is caused by the recursive algorithm in combination with a
very large negative coordinate passed to gdImageFillToBorder(). As there is
already a clipping for large positive coordinates to the width and height of
the image, it seems to be consequent to clip to zero also. |
static void test_bug11172()
{
MYSQL_STMT *stmt;
MYSQL_BIND bind_in[1], bind_out[2];
MYSQL_TIME hired;
int rc;
const char *stmt_text;
int i= 0, id;
ulong type;
myheader("test_bug11172");
mysql_query(mysql, "drop table if exists t1");
mysql_query(mysql, "create table t1 (id integer not null primary key,"
"hired date not null)");
rc= mysql_query(mysql,
"insert into t1 (id, hired) values (1, '1933-08-24'), "
"(2, '1965-01-01'), (3, '1949-08-17'), (4, '1945-07-07'), "
"(5, '1941-05-15'), (6, '1978-09-15'), (7, '1936-03-28')");
myquery(rc);
stmt= mysql_stmt_init(mysql);
stmt_text= "SELECT id, hired FROM t1 WHERE hired=?";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
type= (ulong) CURSOR_TYPE_READ_ONLY;
mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
bzero((char*) bind_in, sizeof(bind_in));
bzero((char*) bind_out, sizeof(bind_out));
bzero((char*) &hired, sizeof(hired));
hired.year= 1965;
hired.month= 1;
hired.day= 1;
bind_in[0].buffer_type= MYSQL_TYPE_DATE;
bind_in[0].buffer= (void*) &hired;
bind_in[0].buffer_length= sizeof(hired);
bind_out[0].buffer_type= MYSQL_TYPE_LONG;
bind_out[0].buffer= (void*) &id;
bind_out[1]= bind_in[0];
for (i= 0; i < 3; i++)
{
rc= mysql_stmt_bind_param(stmt, bind_in);
check_execute(stmt, rc);
rc= mysql_stmt_bind_result(stmt, bind_out);
check_execute(stmt, rc);
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
while ((rc= mysql_stmt_fetch(stmt)) == 0)
{
if (!opt_silent)
printf("fetched data %d:%d-%d-%d\n", id,
hired.year, hired.month, hired.day);
}
DIE_UNLESS(rc == MYSQL_NO_DATA);
if (!mysql_stmt_free_result(stmt))
mysql_stmt_reset(stmt);
}
mysql_stmt_close(stmt);
mysql_rollback(mysql);
mysql_rollback(mysql);
rc= mysql_query(mysql, "drop table t1");
myquery(rc);
} | 0 | [
"CWE-416"
] | server | eef21014898d61e77890359d6546d4985d829ef6 | 84,305,630,054,308,565,000,000,000,000,000,000,000 | 66 | MDEV-11933 Wrong usage of linked list in mysql_prune_stmt_list
mysql_prune_stmt_list() was walking the list following
element->next pointers, but inside the loop it was invoking
list_add(element) that modified element->next. So, mysql_prune_stmt_list()
failed to visit and reset all elements, and some of them were left
with pointers to invalid MYSQL. |
static int copy_altdest_file(const char *src, const char *dest, struct file_struct *file)
{
char buf[MAXPATHLEN];
const char *copy_to, *partialptr;
int save_preserve_xattrs = preserve_xattrs;
int ok, fd_w;
if (inplace) {
/* Let copy_file open the destination in place. */
fd_w = -1;
copy_to = dest;
} else {
fd_w = open_tmpfile(buf, dest, file);
if (fd_w < 0)
return -1;
copy_to = buf;
}
cleanup_set(copy_to, NULL, NULL, -1, -1);
if (copy_file(src, copy_to, fd_w, file->mode) < 0) {
if (INFO_GTE(COPY, 1)) {
rsyserr(FINFO, errno, "copy_file %s => %s",
full_fname(src), copy_to);
}
/* Try to clean up. */
unlink(copy_to);
cleanup_disable();
return -1;
}
partialptr = partial_dir ? partial_dir_fname(dest) : NULL;
preserve_xattrs = 0; /* xattrs were copied with file */
ok = finish_transfer(dest, copy_to, src, partialptr, file, 1, 0);
preserve_xattrs = save_preserve_xattrs;
cleanup_disable();
return ok ? 0 : -1;
} | 0 | [
"CWE-59"
] | rsync | e12a6c087ca1eecdb8eae5977be239c24f4dd3d9 | 170,846,124,419,038,400,000,000,000,000,000,000,000 | 35 | Add parent-dir validation for --no-inc-recurse too. |
nsim_map_key_match(struct bpf_map *map, struct nsim_map_entry *e, void *key)
{
return e->key && !memcmp(key, e->key, map->key_size);
} | 0 | [] | net | 481221775d53d6215a6e5e9ce1cce6d2b4ab9a46 | 218,189,150,830,253,530,000,000,000,000,000,000,000 | 4 | netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
since it may cause a potential kernel information leak issue, as follows:
1. nsim_bpf_map_alloc calls nsim_map_alloc_elem to allocate elements for
a new map.
2. nsim_map_alloc_elem uses kmalloc to allocate map's value, but doesn't
zero it.
3. A user application can use IOCTL BPF_MAP_LOOKUP_ELEM to get specific
element's information in the map.
4. The kernel function map_lookup_elem will call bpf_map_copy_value to get
the information allocated at step-2, then use copy_to_user to copy to the
user buffer.
This can only leak information for an array map.
Fixes: 395cacb5f1a0 ("netdevsim: bpf: support fake map offload")
Suggested-by: Jakub Kicinski <[email protected]>
Acked-by: Jakub Kicinski <[email protected]>
Signed-off-by: Haimin Zhang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]> |
static int ttm_sg_tt_alloc_page_directory(struct ttm_dma_tt *ttm)
{
ttm->dma_address = kvmalloc_array(ttm->ttm.num_pages,
sizeof(*ttm->dma_address),
GFP_KERNEL | __GFP_ZERO);
if (!ttm->dma_address)
return -ENOMEM;
return 0;
} | 0 | [] | linux | 5de5b6ecf97a021f29403aa272cb4e03318ef586 | 184,831,711,737,603,430,000,000,000,000,000,000,000 | 9 | drm/ttm/nouveau: don't call tt destroy callback on alloc failure.
This is confusing, and from my reading of all the drivers only
nouveau got this right.
Just make the API act under driver control of it's own allocation
failing, and don't call destroy, if the page table fails to
create there is nothing to cleanup here.
(I'm willing to believe I've missed something here, so please
review deeply).
Reviewed-by: Christian König <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] |
INTERNAL void vterm_push_output_sprintf_dcs(VTerm *vt, const char *fmt, ...)
{
size_t orig_cur = vt->outbuffer_cur;
va_list args;
if(!vt->mode.ctrl8bit)
vterm_push_output_sprintf(vt, ESC_S "%c", C1_DCS - 0x40);
else
vterm_push_output_sprintf(vt, "%c", C1_DCS);
va_start(args, fmt);
vterm_push_output_vsprintf(vt, fmt, args);
va_end(args);
vterm_push_output_sprintf_ctrl(vt, C1_ST, "");
if(outbuffer_is_full(vt))
vt->outbuffer_cur = orig_cur;
} | 0 | [
"CWE-476"
] | vim | cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8 | 49,470,663,905,100,060,000,000,000,000,000,000,000 | 19 | patch 8.1.0633: crash when out of memory while opening a terminal window
Problem: Crash when out of memory while opening a terminal window.
Solution: Handle out-of-memory more gracefully. |
static int ath10k_usb_hif_diag_read(struct ath10k *ar, u32 address, void *buf,
size_t buf_len)
{
struct ath10k_usb *ar_usb = ath10k_usb_priv(ar);
struct ath10k_usb_ctrl_diag_cmd_read *cmd;
u32 resp_len;
int ret;
if (buf_len < sizeof(struct ath10k_usb_ctrl_diag_resp_read))
return -EINVAL;
cmd = (struct ath10k_usb_ctrl_diag_cmd_read *)ar_usb->diag_cmd_buffer;
memset(cmd, 0, sizeof(*cmd));
cmd->cmd = ATH10K_USB_CTRL_DIAG_CC_READ;
cmd->address = cpu_to_le32(address);
resp_len = sizeof(struct ath10k_usb_ctrl_diag_resp_read);
ret = ath10k_usb_ctrl_msg_exchange(ar,
ATH10K_USB_CONTROL_REQ_DIAG_CMD,
(u8 *)cmd,
sizeof(*cmd),
ATH10K_USB_CONTROL_REQ_DIAG_RESP,
ar_usb->diag_resp_buffer, &resp_len);
if (ret)
return ret;
if (resp_len != sizeof(struct ath10k_usb_ctrl_diag_resp_read))
return -EMSGSIZE;
memcpy(buf, ar_usb->diag_resp_buffer,
sizeof(struct ath10k_usb_ctrl_diag_resp_read));
return 0;
} | 0 | [
"CWE-476"
] | linux | bfd6e6e6c5d2ee43a3d9902b36e01fc7527ebb27 | 136,039,211,629,927,870,000,000,000,000,000,000,000 | 34 | ath10k: Fix a NULL-ptr-deref bug in ath10k_usb_alloc_urb_from_pipe
The `ar_usb` field of `ath10k_usb_pipe_usb_pipe` objects
are initialized to point to the containing `ath10k_usb` object
according to endpoint descriptors read from the device side, as shown
below in `ath10k_usb_setup_pipe_resources`:
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;
// get the address from endpoint descriptor
pipe_num = ath10k_usb_get_logical_pipe_num(ar_usb,
endpoint->bEndpointAddress,
&urbcount);
......
// select the pipe object
pipe = &ar_usb->pipes[pipe_num];
// initialize the ar_usb field
pipe->ar_usb = ar_usb;
}
The driver assumes that the addresses reported in endpoint
descriptors from device side to be complete. If a device is
malicious and does not report complete addresses, it may trigger
NULL-ptr-deref `ath10k_usb_alloc_urb_from_pipe` and
`ath10k_usb_free_urb_to_pipe`.
This patch fixes the bug by preventing potential NULL-ptr-deref.
Signed-off-by: Hui Peng <[email protected]>
Reported-by: Hui Peng <[email protected]>
Reported-by: Mathias Payer <[email protected]>
Reviewed-by: Greg Kroah-Hartman <[email protected]>
[groeck: Add driver tag to subject, fix build warning]
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Kalle Valo <[email protected]> |
void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
{
struct cmsghdr __user *cm
= (__force struct cmsghdr __user*)msg->msg_control;
int fdmax = 0;
int fdnum = scm->fp->count;
struct file **fp = scm->fp->fp;
int __user *cmfptr;
int err = 0, i;
if (MSG_CMSG_COMPAT & msg->msg_flags) {
scm_detach_fds_compat(msg, scm);
return;
}
if (msg->msg_controllen > sizeof(struct cmsghdr))
fdmax = ((msg->msg_controllen - sizeof(struct cmsghdr))
/ sizeof(int));
if (fdnum < fdmax)
fdmax = fdnum;
for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
i++, cmfptr++)
{
struct socket *sock;
int new_fd;
err = security_file_receive(fp[i]);
if (err)
break;
err = get_unused_fd_flags(MSG_CMSG_CLOEXEC & msg->msg_flags
? O_CLOEXEC : 0);
if (err < 0)
break;
new_fd = err;
err = put_user(new_fd, cmfptr);
if (err) {
put_unused_fd(new_fd);
break;
}
/* Bump the usage count and install the file. */
sock = sock_from_file(fp[i], &err);
if (sock) {
sock_update_netprioidx(sock->sk);
sock_update_classid(sock->sk);
}
fd_install(new_fd, get_file(fp[i]));
}
if (i > 0)
{
int cmlen = CMSG_LEN(i*sizeof(int));
err = put_user(SOL_SOCKET, &cm->cmsg_level);
if (!err)
err = put_user(SCM_RIGHTS, &cm->cmsg_type);
if (!err)
err = put_user(cmlen, &cm->cmsg_len);
if (!err) {
cmlen = CMSG_SPACE(i*sizeof(int));
msg->msg_control += cmlen;
msg->msg_controllen -= cmlen;
}
}
if (i < fdnum || (fdnum && fdmax <= 0))
msg->msg_flags |= MSG_CTRUNC;
/*
* All of the files that fit in the message have had their
* usage counts incremented, so we just free the list.
*/
__scm_destroy(scm);
} | 0 | [
"CWE-284",
"CWE-264"
] | linux | d661684cf6820331feae71146c35da83d794467e | 189,006,816,207,470,730,000,000,000,000,000,000,000 | 73 | net: Check the correct namespace when spoofing pid over SCM_RIGHTS
This is a security bug.
The follow-up will fix nsproxy to discourage this type of issue from
happening again.
Cc: [email protected]
Signed-off-by: Andy Lutomirski <[email protected]>
Reviewed-by: "Eric W. Biederman" <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
goa_ews_client_autodiscover_sync (GoaEwsClient *client,
const gchar *email,
const gchar *password,
const gchar *username,
const gchar *server,
GCancellable *cancellable,
GError **error)
{
AutodiscoverSyncData data;
GMainContext *context = NULL;
data.error = error;
context = g_main_context_new ();
g_main_context_push_thread_default (context);
data.loop = g_main_loop_new (context, FALSE);
goa_ews_client_autodiscover (client,
email,
password,
username,
server,
cancellable,
ews_client_autodiscover_sync_cb,
&data);
g_main_loop_run (data.loop);
g_main_loop_unref (data.loop);
g_main_context_pop_thread_default (context);
g_main_context_unref (context);
return data.op_res;
} | 0 | [
"CWE-310"
] | gnome-online-accounts | edde7c63326242a60a075341d3fea0be0bc4d80e | 118,067,825,621,495,760,000,000,000,000,000,000,000 | 33 | Guard against invalid SSL certificates
None of the branded providers (eg., Google, Facebook and Windows Live)
should ever have an invalid certificate. So set "ssl-strict" on the
SoupSession object being used by GoaWebView.
Providers like ownCloud and Exchange might have to deal with
certificates that are not up to the mark. eg., self-signed
certificates. For those, show a warning when the account is being
created, and only proceed if the user decides to ignore it. In any
case, save the status of the certificate that was used to create the
account. So an account created with a valid certificate will never
work with an invalid one, and one created with an invalid certificate
will not throw any further warnings.
Fixes: CVE-2013-0240 |
static void delete_uprobe(struct uprobe *uprobe)
{
if (WARN_ON(!uprobe_is_active(uprobe)))
return;
spin_lock(&uprobes_treelock);
rb_erase(&uprobe->rb_node, &uprobes_tree);
spin_unlock(&uprobes_treelock);
RB_CLEAR_NODE(&uprobe->rb_node); /* for uprobe_is_active() */
iput(uprobe->inode);
put_uprobe(uprobe);
} | 0 | [
"CWE-416"
] | linux | 355627f518978b5167256d27492fe0b343aaf2f2 | 24,337,818,866,940,467,000,000,000,000,000,000,000 | 12 | mm, uprobes: fix multiple free of ->uprobes_state.xol_area
Commit 7c051267931a ("mm, fork: make dup_mmap wait for mmap_sem for
write killable") made it possible to kill a forking task while it is
waiting to acquire its ->mmap_sem for write, in dup_mmap().
However, it was overlooked that this introduced an new error path before
the new mm_struct's ->uprobes_state.xol_area has been set to NULL after
being copied from the old mm_struct by the memcpy in dup_mm(). For a
task that has previously hit a uprobe tracepoint, this resulted in the
'struct xol_area' being freed multiple times if the task was killed at
just the right time while forking.
Fix it by setting ->uprobes_state.xol_area to NULL in mm_init() rather
than in uprobe_dup_mmap().
With CONFIG_UPROBE_EVENTS=y, the bug can be reproduced by the same C
program given by commit 2b7e8665b4ff ("fork: fix incorrect fput of
->exe_file causing use-after-free"), provided that a uprobe tracepoint
has been set on the fork_thread() function. For example:
$ gcc reproducer.c -o reproducer -lpthread
$ nm reproducer | grep fork_thread
0000000000400719 t fork_thread
$ echo "p $PWD/reproducer:0x719" > /sys/kernel/debug/tracing/uprobe_events
$ echo 1 > /sys/kernel/debug/tracing/events/uprobes/enable
$ ./reproducer
Here is the use-after-free reported by KASAN:
BUG: KASAN: use-after-free in uprobe_clear_state+0x1c4/0x200
Read of size 8 at addr ffff8800320a8b88 by task reproducer/198
CPU: 1 PID: 198 Comm: reproducer Not tainted 4.13.0-rc7-00015-g36fde05f3fb5 #255
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-20170228_101828-anatol 04/01/2014
Call Trace:
dump_stack+0xdb/0x185
print_address_description+0x7e/0x290
kasan_report+0x23b/0x350
__asan_report_load8_noabort+0x19/0x20
uprobe_clear_state+0x1c4/0x200
mmput+0xd6/0x360
do_exit+0x740/0x1670
do_group_exit+0x13f/0x380
get_signal+0x597/0x17d0
do_signal+0x99/0x1df0
exit_to_usermode_loop+0x166/0x1e0
syscall_return_slowpath+0x258/0x2c0
entry_SYSCALL_64_fastpath+0xbc/0xbe
...
Allocated by task 199:
save_stack_trace+0x1b/0x20
kasan_kmalloc+0xfc/0x180
kmem_cache_alloc_trace+0xf3/0x330
__create_xol_area+0x10f/0x780
uprobe_notify_resume+0x1674/0x2210
exit_to_usermode_loop+0x150/0x1e0
prepare_exit_to_usermode+0x14b/0x180
retint_user+0x8/0x20
Freed by task 199:
save_stack_trace+0x1b/0x20
kasan_slab_free+0xa8/0x1a0
kfree+0xba/0x210
uprobe_clear_state+0x151/0x200
mmput+0xd6/0x360
copy_process.part.8+0x605f/0x65d0
_do_fork+0x1a5/0xbd0
SyS_clone+0x19/0x20
do_syscall_64+0x22f/0x660
return_from_SYSCALL_64+0x0/0x7a
Note: without KASAN, you may instead see a "Bad page state" message, or
simply a general protection fault.
Link: http://lkml.kernel.org/r/[email protected]
Fixes: 7c051267931a ("mm, fork: make dup_mmap wait for mmap_sem for write killable")
Signed-off-by: Eric Biggers <[email protected]>
Reported-by: Oleg Nesterov <[email protected]>
Acked-by: Oleg Nesterov <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: <[email protected]> [4.7+]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
static int handle_encls(struct kvm_vcpu *vcpu)
{
/*
* SGX virtualization is not yet supported. There is no software
* enable bit for SGX, so we have to trap ENCLS and inject a #UD
* to prevent the guest from executing ENCLS.
*/
kvm_queue_exception(vcpu, UD_VECTOR);
return 1;
} | 0 | [
"CWE-787"
] | linux | 04c4f2ee3f68c9a4bf1653d15f1a9a435ae33f7a | 120,320,158,333,151,120,000,000,000,000,000,000,000 | 10 | KVM: VMX: Don't use vcpu->run->internal.ndata as an array index
__vmx_handle_exit() uses vcpu->run->internal.ndata as an index for
an array access. Since vcpu->run is (can be) mapped to a user address
space with a writer permission, the 'ndata' could be updated by the
user process at anytime (the user process can set it to outside the
bounds of the array).
So, it is not safe that __vmx_handle_exit() uses the 'ndata' that way.
Fixes: 1aa561b1a4c0 ("kvm: x86: Add "last CPU" to some KVM_EXIT information")
Signed-off-by: Reiji Watanabe <[email protected]>
Reviewed-by: Jim Mattson <[email protected]>
Message-Id: <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]> |
void handshakeSuc(AsyncSSLSocket* /* socket */) noexcept override {
LOG(INFO) << "Renegotiating server handshake success";
socket_->setReadCB(this);
} | 0 | [
"CWE-125"
] | folly | c321eb588909646c15aefde035fd3133ba32cdee | 233,742,221,621,338,180,000,000,000,000,000,000,000 | 4 | Handle close_notify as standard writeErr in AsyncSSLSocket.
Summary: Fixes CVE-2019-11934
Reviewed By: mingtaoy
Differential Revision: D18020613
fbshipit-source-id: db82bb250e53f0d225f1280bd67bc74abd417836 |
static int ext4_ui_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, ext4_ui_proc_show, PDE(inode)->data);
} | 0 | [
"CWE-20"
] | linux-2.6 | 4ec110281379826c5cf6ed14735e47027c3c5765 | 311,091,530,354,719,960,000,000,000,000,000,000,000 | 4 | ext4: Add sanity checks for the superblock before mounting the filesystem
This avoids insane superblock configurations that could lead to kernel
oops due to null pointer derefences.
http://bugzilla.kernel.org/show_bug.cgi?id=12371
Thanks to David Maciejak at Fortinet's FortiGuard Global Security
Research Team who discovered this bug independently (but at
approximately the same time) as Thiemo Nagel, who submitted the patch.
Signed-off-by: Thiemo Nagel <[email protected]>
Signed-off-by: "Theodore Ts'o" <[email protected]>
Cc: [email protected] |
static int nci_enable_se(struct nfc_dev *nfc_dev, u32 se_idx)
{
struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
if (ndev->ops->enable_se)
return ndev->ops->enable_se(ndev, se_idx);
return 0;
} | 0 | [] | linux | 48b71a9e66c2eab60564b1b1c85f4928ed04e406 | 122,386,406,036,166,100,000,000,000,000,000,000,000 | 9 | NFC: add NCI_UNREG flag to eliminate the race
There are two sites that calls queue_work() after the
destroy_workqueue() and lead to possible UAF.
The first site is nci_send_cmd(), which can happen after the
nci_close_device as below
nfcmrvl_nci_unregister_dev | nfc_genl_dev_up
nci_close_device |
flush_workqueue |
del_timer_sync |
nci_unregister_device | nfc_get_device
destroy_workqueue | nfc_dev_up
nfc_unregister_device | nci_dev_up
device_del | nci_open_device
| __nci_request
| nci_send_cmd
| queue_work !!!
Another site is nci_cmd_timer, awaked by the nci_cmd_work from the
nci_send_cmd.
... | ...
nci_unregister_device | queue_work
destroy_workqueue |
nfc_unregister_device | ...
device_del | nci_cmd_work
| mod_timer
| ...
| nci_cmd_timer
| queue_work !!!
For the above two UAF, the root cause is that the nfc_dev_up can race
between the nci_unregister_device routine. Therefore, this patch
introduce NCI_UNREG flag to easily eliminate the possible race. In
addition, the mutex_lock in nci_close_device can act as a barrier.
Signed-off-by: Lin Ma <[email protected]>
Fixes: 6a2968aaf50c ("NFC: basic NCI protocol implementation")
Reviewed-by: Jakub Kicinski <[email protected]>
Reviewed-by: Krzysztof Kozlowski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]> |
R_API bool r_config_save_num(RConfigHold *h, ...) {
va_list ap;
char *key;
if (!h->list_num) {
h->list_num = r_list_newf ((RListFree) free);
if (!h->list_num) {
return false;
}
}
va_start (ap, h);
while ((key = va_arg (ap, char *))) {
RConfigHoldNum *hc = R_NEW0 (RConfigHoldNum);
if (!hc) {
continue;
}
hc->key = key;
hc->value = r_config_get_i (h->cfg, key);
r_list_append (h->list_num, hc);
}
va_end (ap);
return true;
} | 0 | [
"CWE-416"
] | radare2 | f85bc674b2a2256a364fe796351bc1971e106005 | 287,329,845,489,144,800,000,000,000,000,000,000,000 | 22 | Fix #7698 - UAF in r_config_set when loading a dex |
generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
loff_t *ppos, size_t len, unsigned int flags)
{
struct address_space *mapping = out->f_mapping;
struct inode *inode = mapping->host;
ssize_t ret;
int err;
ret = __splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
if (ret > 0) {
*ppos += ret;
/*
* If file or inode is SYNC and we actually wrote some data,
* sync it.
*/
if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) {
err = generic_osync_inode(inode, mapping,
OSYNC_METADATA|OSYNC_DATA);
if (err)
ret = err;
}
}
return ret;
} | 1 | [
"CWE-264"
] | linux-2.6 | 8c34e2d63231d4bf4852bac8521883944d770fe3 | 76,296,563,285,025,260,000,000,000,000,000,000,000 | 27 | [PATCH] Remove SUID when splicing into an inode
Originally from Mark Fasheh <[email protected]>
generic_file_splice_write() does not remove S_ISUID or S_ISGID. This is
inconsistent with the way we generally write to files.
Signed-off-by: Mark Fasheh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]> |
void mi_check_print_warning(MI_CHECK *param, const char *fmt,...)
{
va_list args;
DBUG_ENTER("mi_check_print_warning");
fflush(stdout);
if (!param->warning_printed && !param->error_printed)
{
if (param->testflag & T_SILENT)
fprintf(stderr,"%s: MyISAM file %s\n",my_progname_short,
param->isam_file_name);
param->out_flag|= O_DATA_LOST;
}
param->warning_printed=1;
va_start(args,fmt);
fprintf(stderr,"%s: warning: ",my_progname_short);
(void) vfprintf(stderr, fmt, args);
(void) fputc('\n',stderr);
fflush(stderr);
va_end(args);
DBUG_VOID_RETURN;
} | 0 | [
"CWE-362"
] | mysql-server | 4e5473862e6852b0f3802b0cd0c6fa10b5253291 | 24,674,139,115,296,527,000,000,000,000,000,000,000 | 22 | Bug#24388746: PRIVILEGE ESCALATION AND RACE CONDITION USING CREATE TABLE
During REPAIR TABLE of a MyISAM table, a temporary data file (.TMD)
is created. When repair finishes, this file is renamed to the original
.MYD file. The problem was that during this rename, we copied the
stats from the old file to the new file with chmod/chown. If a user
managed to replace the temporary file before chmod/chown was executed,
it was possible to get an arbitrary file with the privileges of the
mysql user.
This patch fixes the problem by not copying stats from the old
file to the new file. This is not needed as the new file was
created with the correct stats. This fix only changes server
behavior - external utilities such as myisamchk still does
chmod/chown.
No test case provided since the problem involves synchronization
with file system operations. |
int BPMDetect::decimate(SAMPLETYPE *dest, const SAMPLETYPE *src, int numsamples)
{
int count, outcount;
LONG_SAMPLETYPE out;
assert(channels > 0);
assert(decimateBy > 0);
outcount = 0;
for (count = 0; count < numsamples; count ++)
{
int j;
// convert to mono and accumulate
for (j = 0; j < channels; j ++)
{
decimateSum += src[j];
}
src += j;
decimateCount ++;
if (decimateCount >= decimateBy)
{
// Store every Nth sample only
out = (LONG_SAMPLETYPE)(decimateSum / (decimateBy * channels));
decimateSum = 0;
decimateCount = 0;
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
// check ranges for sure (shouldn't actually be necessary)
if (out > 32767)
{
out = 32767;
}
else if (out < -32768)
{
out = -32768;
}
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[outcount] = (SAMPLETYPE)out;
outcount ++;
}
}
return outcount;
}
| 0 | [
"CWE-617"
] | soundtouch | a1c400eb2cff849c0e5f9d6916d69ffea3ad2c85 | 20,932,171,073,096,532,000,000,000,000,000,000,000 | 43 | Fix issue CVE-2018-17096: Replace assert with runtime exception |
static inline bool ok_inflater_load_bits(ok_inflater *inflater, unsigned int num_bits) {
while (inflater->input_buffer_bits < num_bits) {
if (inflater->input == inflater->input_end || inflater->input_buffer_bits + 8 > 32) {
return false;
}
uint32_t input = *inflater->input++;
inflater->input_buffer |= input << inflater->input_buffer_bits;
inflater->input_buffer_bits += 8;
}
return true;
} | 0 | [
"CWE-787"
] | ok-file-formats | e49cdfb84fb5eca2a6261f3c51a3c793fab9f62e | 31,415,511,028,232,630,000,000,000,000,000,000,000 | 11 | ok_png: Disallow multiple IHDR chunks (#15) |
int parse_submodule_fetchjobs(const char *var, const char *value)
{
int fetchjobs = git_config_int(var, value);
if (fetchjobs < 0)
die(_("negative values not allowed for submodule.fetchjobs"));
return fetchjobs;
} | 0 | [
"CWE-78"
] | git | e904deb89d9a9669a76a426182506a084d3f6308 | 116,860,443,476,534,960,000,000,000,000,000,000,000 | 7 | submodule: reject submodule.update = !command in .gitmodules
Since ac1fbbda2013 (submodule: do not copy unknown update mode from
.gitmodules, 2013-12-02), Git has been careful to avoid copying
[submodule "foo"]
update = !run an arbitrary scary command
from .gitmodules to a repository's local config, copying in the
setting 'update = none' instead. The gitmodules(5) manpage documents
the intention:
The !command form is intentionally ignored here for security
reasons
Unfortunately, starting with v2.20.0-rc0 (which integrated ee69b2a9
(submodule--helper: introduce new update-module-mode helper,
2018-08-13, first released in v2.20.0-rc0)), there are scenarios where
we *don't* ignore it: if the config store contains no
submodule.foo.update setting, the submodule-config API falls back to
reading .gitmodules and the repository-supplied !command gets run
after all.
This was part of a general change over time in submodule support to
read more directly from .gitmodules, since unlike .git/config it
allows a project to change values between branches and over time
(while still allowing .git/config to override things). But it was
never intended to apply to this kind of dangerous configuration.
The behavior change was not advertised in ee69b2a9's commit message
and was missed in review.
Let's take the opportunity to make the protection more robust, even in
Git versions that are technically not affected: instead of quietly
converting 'update = !command' to 'update = none', noisily treat it as
an error. Allowing the setting but treating it as meaning something
else was just confusing; users are better served by seeing the error
sooner. Forbidding the construct makes the semantics simpler and
means we can check for it in fsck (in a separate patch).
As a result, the submodule-config API cannot read this value from
.gitmodules under any circumstance, and we can declare with confidence
For security reasons, the '!command' form is not accepted
here.
Reported-by: Joern Schneeweisz <[email protected]>
Signed-off-by: Jonathan Nieder <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]> |
OPJ_BOOL opj_j2k_read_header( opj_stream_private_t *p_stream,
opj_j2k_t* p_j2k,
opj_image_t** p_image,
opj_event_mgr_t* p_manager )
{
/* preconditions */
assert(p_j2k != 00);
assert(p_stream != 00);
assert(p_manager != 00);
/* create an empty image header */
p_j2k->m_private_image = opj_image_create0();
if (! p_j2k->m_private_image) {
return OPJ_FALSE;
}
/* customization of the validation */
if (! opj_j2k_setup_decoding_validation(p_j2k, p_manager)) {
opj_image_destroy(p_j2k->m_private_image);
p_j2k->m_private_image = NULL;
return OPJ_FALSE;
}
/* validation of the parameters codec */
if (! opj_j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream,p_manager)) {
opj_image_destroy(p_j2k->m_private_image);
p_j2k->m_private_image = NULL;
return OPJ_FALSE;
}
/* customization of the encoding */
if (! opj_j2k_setup_header_reading(p_j2k, p_manager)) {
opj_image_destroy(p_j2k->m_private_image);
p_j2k->m_private_image = NULL;
return OPJ_FALSE;
}
/* read header */
if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
opj_image_destroy(p_j2k->m_private_image);
p_j2k->m_private_image = NULL;
return OPJ_FALSE;
}
*p_image = opj_image_create0();
if (! (*p_image)) {
return OPJ_FALSE;
}
/* Copy codestream image information to the output image */
opj_copy_image_header(p_j2k->m_private_image, *p_image);
/*Allocate and initialize some elements of codestrem index*/
if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)){
return OPJ_FALSE;
}
return OPJ_TRUE;
} | 0 | [
"CWE-416"
] | openjpeg | 940100c28ae28931722290794889cf84a92c5f6f | 85,558,253,811,447,450,000,000,000,000,000,000,000 | 59 | Fix potential use-after-free in opj_j2k_write_mco function
Fixes #563 |
win_drag_vsep_line(win_T *dragwin, int offset)
{
frame_T *curfr;
frame_T *fr;
int room;
int left; // if TRUE, drag separator line left, otherwise right
int n;
fr = dragwin->w_frame;
if (fr == topframe) // only one window (cannot happen?)
return;
curfr = fr;
fr = fr->fr_parent;
// When the parent frame is not a row of frames, its parent should be.
if (fr->fr_layout != FR_ROW)
{
if (fr == topframe) // only a column of windows (cannot happen?)
return;
curfr = fr;
fr = fr->fr_parent;
}
// If this is the last frame in a row, may want to resize a parent
// frame instead.
while (curfr->fr_next == NULL)
{
if (fr == topframe)
break;
curfr = fr;
fr = fr->fr_parent;
if (fr != topframe)
{
curfr = fr;
fr = fr->fr_parent;
}
}
if (offset < 0) // drag left
{
left = TRUE;
offset = -offset;
// sum up the room of the current frame and left of it
room = 0;
for (fr = fr->fr_child; ; fr = fr->fr_next)
{
room += fr->fr_width - frame_minwidth(fr, NULL);
if (fr == curfr)
break;
}
fr = curfr->fr_next; // put fr at frame that grows
}
else // drag right
{
left = FALSE;
// sum up the room of frames right of the current one
room = 0;
FOR_ALL_FRAMES(fr, curfr->fr_next)
room += fr->fr_width - frame_minwidth(fr, NULL);
fr = curfr; // put fr at window that grows
}
if (room < offset) // Not enough room
offset = room; // Move as far as we can
if (offset <= 0) // No room at all, quit.
return;
if (fr == NULL)
// This can happen when calling win_move_separator() on the rightmost
// window. Just don't do anything.
return;
// grow frame fr by offset lines
frame_new_width(fr, fr->fr_width + offset, left, FALSE);
// shrink other frames: current and at the left or at the right
if (left)
fr = curfr; // current frame gets smaller
else
fr = curfr->fr_next; // next frame gets smaller
while (fr != NULL && offset > 0)
{
n = frame_minwidth(fr, NULL);
if (fr->fr_width - offset <= n)
{
offset -= fr->fr_width - n;
frame_new_width(fr, n, !left, FALSE);
}
else
{
frame_new_width(fr, fr->fr_width - offset, !left, FALSE);
break;
}
if (left)
fr = fr->fr_prev;
else
fr = fr->fr_next;
}
(void)win_comp_pos();
redraw_all_later(NOT_VALID);
} | 0 | [
"CWE-476"
] | vim | 0f6e28f686dbb59ab3b562408ab9b2234797b9b1 | 213,425,948,289,540,900,000,000,000,000,000,000,000 | 100 | patch 8.2.4428: crash when switching tabpage while in the cmdline window
Problem: Crash when switching tabpage while in the cmdline window.
Solution: Disallow switching tabpage when in the cmdline window. |
struct audit_chunk *audit_tree_lookup(const struct inode *inode)
{
struct list_head *list = chunk_hash(inode);
struct audit_chunk *p;
list_for_each_entry_rcu(p, list, hash) {
if (p->watch.inode == inode) {
get_inotify_watch(&p->watch);
return p;
}
}
return NULL;
} | 1 | [
"CWE-362"
] | linux-2.6 | 8f7b0ba1c853919b85b54774775f567f30006107 | 305,548,466,206,123,730,000,000,000,000,000,000,000 | 13 | Fix inotify watch removal/umount races
Inotify watch removals suck violently.
To kick the watch out we need (in this order) inode->inotify_mutex and
ih->mutex. That's fine if we have a hold on inode; however, for all
other cases we need to make damn sure we don't race with umount. We can
*NOT* just grab a reference to a watch - inotify_unmount_inodes() will
happily sail past it and we'll end with reference to inode potentially
outliving its superblock.
Ideally we just want to grab an active reference to superblock if we
can; that will make sure we won't go into inotify_umount_inodes() until
we are done. Cleanup is just deactivate_super().
However, that leaves a messy case - what if we *are* racing with
umount() and active references to superblock can't be acquired anymore?
We can bump ->s_count, grab ->s_umount, which will almost certainly wait
until the superblock is shut down and the watch in question is pining
for fjords. That's fine, but there is a problem - we might have hit the
window between ->s_active getting to 0 / ->s_count - below S_BIAS (i.e.
the moment when superblock is past the point of no return and is heading
for shutdown) and the moment when deactivate_super() acquires
->s_umount.
We could just do drop_super() yield() and retry, but that's rather
antisocial and this stuff is luser-triggerable. OTOH, having grabbed
->s_umount and having found that we'd got there first (i.e. that
->s_root is non-NULL) we know that we won't race with
inotify_umount_inodes().
So we could grab a reference to watch and do the rest as above, just
with drop_super() instead of deactivate_super(), right? Wrong. We had
to drop ih->mutex before we could grab ->s_umount. So the watch
could've been gone already.
That still can be dealt with - we need to save watch->wd, do idr_find()
and compare its result with our pointer. If they match, we either have
the damn thing still alive or we'd lost not one but two races at once,
the watch had been killed and a new one got created with the same ->wd
at the same address. That couldn't have happened in inotify_destroy(),
but inotify_rm_wd() could run into that. Still, "new one got created"
is not a problem - we have every right to kill it or leave it alone,
whatever's more convenient.
So we can use idr_find(...) == watch && watch->inode->i_sb == sb as
"grab it and kill it" check. If it's been our original watch, we are
fine, if it's a newcomer - nevermind, just pretend that we'd won the
race and kill the fscker anyway; we are safe since we know that its
superblock won't be going away.
And yes, this is far beyond mere "not very pretty"; so's the entire
concept of inotify to start with.
Signed-off-by: Al Viro <[email protected]>
Acked-by: Greg KH <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
static void dasher_send_encode_hints(GF_DasherCtx *ctx, GF_DashStream *ds)
{
if (!ctx->sfile && !ds->stl && !ctx->use_cues) {
GF_FilterEvent evt;
GF_FEVT_INIT(evt, GF_FEVT_ENCODE_HINTS, ds->ipid)
evt.encode_hints.intra_period = ds->dash_dur;
gf_filter_pid_send_event(ds->ipid, &evt);
}
} | 0 | [
"CWE-787"
] | gpac | ea1eca00fd92fa17f0e25ac25652622924a9a6a0 | 319,028,666,335,885,900,000,000,000,000,000,000,000 | 9 | fixed #2138 |
dwarf_formstring(Dwarf_Attribute attr,
char **return_str, Dwarf_Error * error)
{
Dwarf_CU_Context cu_context = 0;
Dwarf_Debug dbg = 0;
Dwarf_Unsigned offset = 0;
int res = DW_DLV_ERROR;
Dwarf_Small *secdataptr = 0;
Dwarf_Small *secend = 0;
Dwarf_Unsigned secdatalen = 0;
Dwarf_Small *infoptr = attr->ar_debug_ptr;
Dwarf_Small *contextend = 0;
res = get_attr_dbg(&dbg,&cu_context,attr,error);
if (res != DW_DLV_OK) {
return res;
}
if (cu_context->cc_is_info) {
secdataptr = (Dwarf_Small *)dbg->de_debug_info.dss_data;
secdatalen = dbg->de_debug_info.dss_size;
} else {
secdataptr = (Dwarf_Small *)dbg->de_debug_types.dss_data;
secdatalen = dbg->de_debug_types.dss_size;
}
contextend = secdataptr +
cu_context->cc_debug_offset +
cu_context->cc_length +
cu_context->cc_length_size +
cu_context->cc_extension_size;
secend = secdataptr + secdatalen;
if (contextend < secend) {
secend = contextend;
}
switch(attr->ar_attribute_form) {
case DW_FORM_string: {
Dwarf_Small *begin = attr->ar_debug_ptr;
res= _dwarf_check_string_valid(dbg,secdataptr,begin, secend,
DW_DLE_FORM_STRING_BAD_STRING,error);
if (res != DW_DLV_OK) {
return res;
}
*return_str = (char *) (begin);
return DW_DLV_OK;
}
case DW_FORM_GNU_strp_alt:
case DW_FORM_strp_sup: {
Dwarf_Error alterr = 0;
Dwarf_Bool is_info = TRUE;
/* See dwarfstd.org issue 120604.1
This is the offset in the .debug_str section
of another object file.
The 'tied' file notion should apply.
It is not clear whether both a supplementary
and a split object might be needed at the same time
(hence two 'tied' files simultaneously). */
Dwarf_Off soffset = 0;
res = dwarf_global_formref_b(attr, &soffset,
&is_info,error);
if (res != DW_DLV_OK) {
return res;
}
res = _dwarf_get_string_from_tied(dbg, soffset,
return_str, &alterr);
if (res == DW_DLV_ERROR) {
if (dwarf_errno(alterr) ==
DW_DLE_NO_TIED_FILE_AVAILABLE) {
dwarf_dealloc(dbg,alterr,DW_DLA_ERROR);
if ( attr->ar_attribute_form ==
DW_FORM_GNU_strp_alt) {
*return_str =
(char *)"<DW_FORM_GNU_strp_alt-no-tied-file>";
} else {
*return_str =
(char *)"<DW_FORM_strp_sup-no-tied-file>";
}
return DW_DLV_OK;
}
if (error) {
*error = alterr;
} else {
dwarf_dealloc_error(dbg,alterr);
alterr = 0;
}
return res;
}
if (res == DW_DLV_NO_ENTRY) {
if ( attr->ar_attribute_form == DW_FORM_GNU_strp_alt) {
*return_str =
(char *)"<DW_FORM_GNU_strp_alt-no-tied-file>";
}else {
*return_str =
(char *)"<DW_FORM_strp_sup-no-tied-file>";
}
}
return res;
}
case DW_FORM_GNU_str_index:
case DW_FORM_strx:
case DW_FORM_strx1:
case DW_FORM_strx2:
case DW_FORM_strx3:
case DW_FORM_strx4: {
Dwarf_Unsigned offsettostr= 0;
res = _dwarf_extract_string_offset_via_str_offsets(dbg,
infoptr,
secend,
attr->ar_attribute,
attr->ar_attribute_form,
cu_context,
&offsettostr,
error);
if (res != DW_DLV_OK) {
return res;
}
offset = offsettostr;
break;
}
case DW_FORM_strp:
case DW_FORM_line_strp:{
READ_UNALIGNED_CK(dbg, offset, Dwarf_Unsigned,
infoptr,
cu_context->cc_length_size,error,secend);
break;
}
default:
_dwarf_error(dbg, error, DW_DLE_STRING_FORM_IMPROPER);
return DW_DLV_ERROR;
}
/* Now we have offset so read the string from
debug_str or debug_line_str. */
res = _dwarf_extract_local_debug_str_string_given_offset(dbg,
attr->ar_attribute_form,
offset,
return_str,
error);
return res;
} | 0 | [
"CWE-703",
"CWE-125"
] | libdwarf-code | 7ef09e1fc9ba07653dd078edb2408631c7969162 | 29,103,162,508,517,620,000,000,000,000,000,000,000 | 140 | Fixes old bug(which could result in Denial of Service)
due to a missing check before reading the 8 bytes of a DW_FORM_ref_sig8.
DW202206-001
modified: src/lib/libdwarf/dwarf_form.c |
bool Downstream::request_buf_full() {
auto handler = upstream_->get_client_handler();
auto faddr = handler->get_upstream_addr();
auto worker = handler->get_worker();
// We don't check buffer size here for API endpoint.
if (faddr->alt_mode == UpstreamAltMode::API) {
return false;
}
if (dconn_) {
auto &downstreamconf = *worker->get_downstream_config();
return blocked_request_buf_.rleft() + request_buf_.rleft() >=
downstreamconf.request_buffer_size;
}
return false;
} | 0 | [] | nghttp2 | 319d5ab1c6d916b6b8a0d85b2ae3f01b3ad04f2c | 323,330,415,963,636,300,000,000,000,000,000,000,000 | 18 | nghttpx: Fix request stall
Fix request stall if backend connection is reused and buffer is full. |
cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID)
{
static const cmsFloat64Number a1[] = {
100.0, 0, 0,
0, 255.0, 0,
0, 0, 255.0
};
static const cmsFloat64Number o1[] = {
0,
-128.0,
-128.0
};
cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, o1);
if (mpe == NULL) return mpe;
mpe ->Implements = cmsSigFloatPCS2Lab;
return mpe;
} | 0 | [] | Little-CMS | b0d5ffd4ad91cf8683ee106f13742db3dc66599a | 52,914,944,673,402,130,000,000,000,000,000,000,000 | 19 | Memory Squeezing: LCMS2: CLUTElemDup
Check for allocation failures and tidy up if found. |
static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl)
{
unsigned long flags;
struct snd_kctl_event *cread;
spin_lock_irqsave(&ctl->read_lock, flags);
while (!list_empty(&ctl->events)) {
cread = snd_kctl_event(ctl->events.next);
list_del(&cread->list);
kfree(cread);
}
spin_unlock_irqrestore(&ctl->read_lock, flags);
} | 0 | [
"CWE-190",
"CWE-189"
] | linux | ac902c112d90a89e59916f751c2745f4dbdbb4bd | 239,645,538,141,054,450,000,000,000,000,000,000,000 | 13 | ALSA: control: Handle numid overflow
Each control gets automatically assigned its numids when the control is created.
The allocation is done by incrementing the numid by the amount of allocated
numids per allocation. This means that excessive creation and destruction of
controls (e.g. via SNDRV_CTL_IOCTL_ELEM_ADD/REMOVE) can cause the id to
eventually overflow. Currently when this happens for the control that caused the
overflow kctl->id.numid + kctl->count will also over flow causing it to be
smaller than kctl->id.numid. Most of the code assumes that this is something
that can not happen, so we need to make sure that it won't happen
Signed-off-by: Lars-Peter Clausen <[email protected]>
Acked-by: Jaroslav Kysela <[email protected]>
Cc: <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]> |
koi8_r_get_case_fold_codes_by_str(OnigCaseFoldType flag,
const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
{
return onigenc_get_case_fold_codes_by_str_with_map(
sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,
flag, p, end, items);
} | 0 | [
"CWE-125"
] | oniguruma | 65a9b1aa03c9bc2dc01b074295b9603232cb3b78 | 150,180,395,272,925,220,000,000,000,000,000,000,000 | 7 | onig-5.9.2 |
void perf_sched_cb_inc(struct pmu *pmu)
{
struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
if (!cpuctx->sched_cb_usage++)
list_add(&cpuctx->sched_cb_entry, this_cpu_ptr(&sched_cb_list));
this_cpu_inc(perf_sched_cb_usages);
} | 0 | [
"CWE-362",
"CWE-125"
] | linux | 321027c1fe77f892f4ea07846aeae08cefbbb290 | 189,046,520,833,383,730,000,000,000,000,000,000,000 | 9 | perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race
Di Shen reported a race between two concurrent sys_perf_event_open()
calls where both try and move the same pre-existing software group
into a hardware context.
The problem is exactly that described in commit:
f63a8daa5812 ("perf: Fix event->ctx locking")
... where, while we wait for a ctx->mutex acquisition, the event->ctx
relation can have changed under us.
That very same commit failed to recognise sys_perf_event_context() as an
external access vector to the events and thereby didn't apply the
established locking rules correctly.
So while one sys_perf_event_open() call is stuck waiting on
mutex_lock_double(), the other (which owns said locks) moves the group
about. So by the time the former sys_perf_event_open() acquires the
locks, the context we've acquired is stale (and possibly dead).
Apply the established locking rules as per perf_event_ctx_lock_nested()
to the mutex_lock_double() for the 'move_group' case. This obviously means
we need to validate state after we acquire the locks.
Reported-by: Di Shen (Keen Lab)
Tested-by: John Dias <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Min Chong <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vince Weaver <[email protected]>
Fixes: f63a8daa5812 ("perf: Fix event->ctx locking")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]> |
string expectedResult() {
return "b";
} | 0 | [
"CWE-835"
] | mongo | 0a076417d1d7fba3632b73349a1fd29a83e68816 | 207,540,824,293,301,030,000,000,000,000,000,000,000 | 3 | SERVER-38070 fix infinite loop in agg expression |
static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, int num, int gen, int skip_xrefs)
{
pdf_xref_entry *entry;
pdf_obj *obj;
pdf_obj *type;
fz_try(ctx)
{
obj = pdf_load_object(ctx, doc, num);
}
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
if (opts->continue_on_error)
{
fz_write_printf(ctx, opts->out, "%d %d obj\nnull\nendobj\n", num, gen);
if (opts->errors)
(*opts->errors)++;
fz_warn(ctx, "%s", fz_caught_message(ctx));
return;
}
else
fz_rethrow(ctx);
}
/* skip ObjStm and XRef objects */
if (pdf_is_dict(ctx, obj))
{
type = pdf_dict_get(ctx, obj, PDF_NAME_Type);
if (pdf_name_eq(ctx, type, PDF_NAME_ObjStm))
{
opts->use_list[num] = 0;
pdf_drop_obj(ctx, obj);
return;
}
if (skip_xrefs && pdf_name_eq(ctx, type, PDF_NAME_XRef))
{
opts->use_list[num] = 0;
pdf_drop_obj(ctx, obj);
return;
}
}
entry = pdf_get_xref_entry(ctx, doc, num);
if (!pdf_obj_num_is_stream(ctx, doc, num))
{
fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_obj(ctx, opts->out, obj, opts->do_tight);
fz_write_string(ctx, opts->out, "\nendobj\n\n");
}
else if (entry->stm_ofs < 0 && entry->stm_buf == NULL)
{
fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_obj(ctx, opts->out, obj, opts->do_tight);
fz_write_string(ctx, opts->out, "\nstream\nendstream\nendobj\n\n");
}
else
{
fz_try(ctx)
{
int do_deflate = opts->do_compress;
int do_expand = opts->do_expand;
if (opts->do_compress_images && is_image_stream(ctx, obj))
do_deflate = 1, do_expand = 0;
if (opts->do_compress_fonts && is_font_stream(ctx, obj))
do_deflate = 1, do_expand = 0;
if (is_xml_metadata(ctx, obj))
do_deflate = 0, do_expand = 0;
if (do_expand)
expandstream(ctx, doc, opts, obj, num, gen, do_deflate);
else
copystream(ctx, doc, opts, obj, num, gen, do_deflate);
}
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
if (opts->continue_on_error)
{
fz_write_printf(ctx, opts->out, "%d %d obj\nnull\nendobj\n", num, gen);
if (opts->errors)
(*opts->errors)++;
fz_warn(ctx, "%s", fz_caught_message(ctx));
}
else
{
pdf_drop_obj(ctx, obj);
fz_rethrow(ctx);
}
}
}
pdf_drop_obj(ctx, obj);
} | 0 | [
"CWE-119"
] | mupdf | 520cc26d18c9ee245b56e9e91f9d4fcae02be5f0 | 40,595,336,032,508,220,000,000,000,000,000,000,000 | 93 | Bug 689699: Avoid buffer overrun.
When cleaning a pdf file, various lists (of pdf_xref_len length) are
defined early on.
If we trigger a repair during the clean, this can cause pdf_xref_len
to increase causing an overrun.
Fix this by watching for changes in the length, and checking accesses
to the list for validity.
This also appears to fix bugs 698700-698703. |
check_for_chan_or_job_arg(typval_T *args, int idx)
{
if (args[idx].v_type != VAR_CHANNEL && args[idx].v_type != VAR_JOB)
{
semsg(_(e_chan_or_job_required_for_argument_nr), idx + 1);
return FAIL;
}
return OK;
} | 0 | [
"CWE-125",
"CWE-122"
] | vim | 1e56bda9048a9625bce6e660938c834c5c15b07d | 13,527,258,414,271,878,000,000,000,000,000,000,000 | 9 | patch 9.0.0104: going beyond allocated memory when evaluating string constant
Problem: Going beyond allocated memory when evaluating string constant.
Solution: Properly skip over <Key> form. |
int Field_geom::store(const char *from, size_t length, CHARSET_INFO *cs)
{
if (!length)
bzero(ptr, Field_blob::pack_length());
else
{
if (from == Geometry::bad_geometry_data.ptr())
goto err;
// Check given WKB
uint32 wkb_type;
if (length < SRID_SIZE + WKB_HEADER_SIZE + 4)
goto err;
wkb_type= uint4korr(from + SRID_SIZE + 1);
if (wkb_type < (uint32) Geometry::wkb_point ||
wkb_type > (uint32) Geometry::wkb_last)
goto err;
if (geom_type != Field::GEOM_GEOMETRY &&
geom_type != Field::GEOM_GEOMETRYCOLLECTION &&
(uint32) geom_type != wkb_type)
{
const char *db= table->s->db.str;
const char *tab_name= table->s->table_name.str;
Geometry_buffer buffer;
Geometry *geom= NULL;
String wkt;
const char *dummy;
if (!db)
db= "";
if (!tab_name)
tab_name= "";
wkt.set_charset(&my_charset_latin1);
if (!(geom= Geometry::construct(&buffer, from, uint32(length))) ||
geom->as_wkt(&wkt, &dummy))
goto err;
my_error(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, MYF(0),
Geometry::ci_collection[geom_type]->m_name.str,
wkt.c_ptr_safe(), db, tab_name, field_name.str,
(ulong) table->in_use->get_stmt_da()->
current_row_for_warning());
goto err_exit;
}
Field_blob::store_length(length);
if ((table->copy_blobs || length <= MAX_FIELD_WIDTH) &&
from != value.ptr())
{ // Must make a copy
value.copy(from, length, cs);
from= value.ptr();
}
bmove(ptr + packlength, &from, sizeof(char*));
}
return 0;
err:
my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
ER_THD(get_thd(), ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
err_exit:
bzero(ptr, Field_blob::pack_length());
return -1;
} | 0 | [
"CWE-416",
"CWE-703"
] | server | 08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917 | 98,407,529,964,914,750,000,000,000,000,000,000,000 | 64 | MDEV-24176 Server crashes after insert in the table with virtual
column generated using date_format() and if()
vcol_info->expr is allocated on expr_arena at parsing stage. Since
expr item is allocated on expr_arena all its containee items must be
allocated on expr_arena too. Otherwise fix_session_expr() will
encounter prematurely freed item.
When table is reopened from cache vcol_info contains stale
expression. We refresh expression via TABLE::vcol_fix_exprs() but
first we must prepare a proper context (Vcol_expr_context) which meets
some requirements:
1. As noted above expr update must be done on expr_arena as there may
be new items created. It was a bug in fix_session_expr_for_read() and
was just not reproduced because of no second refix. Now refix is done
for more cases so it does reproduce. Tests affected: vcol.binlog
2. Also name resolution context must be narrowed to the single table.
Tested by: vcol.update main.default vcol.vcol_syntax gcol.gcol_bugfixes
3. sql_mode must be clean and not fail expr update.
sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc
must not affect vcol expression update. If the table was created
successfully any further evaluation must not fail. Tests affected:
main.func_like
Reviewed by: Sergei Golubchik <[email protected]> |
void mg_log_set_callback(void (*fn)(const void *, size_t, void *), void *fnd) {
s_fn = fn;
s_fn_param = fnd;
} | 0 | [
"CWE-552"
] | mongoose | c65c8fdaaa257e0487ab0aaae9e8f6b439335945 | 147,723,784,791,069,440,000,000,000,000,000,000,000 | 4 | Protect against the directory traversal in mg_upload() |
int rom_add_elf_program(const char *name, void *data, size_t datasize,
size_t romsize, hwaddr addr, AddressSpace *as)
{
Rom *rom;
rom = g_malloc0(sizeof(*rom));
rom->name = g_strdup(name);
rom->addr = addr;
rom->datasize = datasize;
rom->romsize = romsize;
rom->data = data;
rom->as = as;
rom_insert(rom);
return 0;
} | 0 | [
"CWE-787"
] | qemu | 4f1c6cb2f9afafda05eab150fd2bd284edce6676 | 123,802,716,714,809,630,000,000,000,000,000,000,000 | 15 | hw/core/loader: Fix possible crash in rom_copy()
Both, "rom->addr" and "addr" are derived from the binary image
that can be loaded with the "-kernel" paramer. The code in
rom_copy() then calculates:
d = dest + (rom->addr - addr);
and uses "d" as destination in a memcpy() some lines later. Now with
bad kernel images, it is possible that rom->addr is smaller than addr,
thus "rom->addr - addr" gets negative and the memcpy() then tries to
copy contents from the image to a bad memory location. This could
maybe be used to inject code from a kernel image into the QEMU binary,
so we better fix it with an additional sanity check here.
Cc: [email protected]
Reported-by: Guangming Liu
Buglink: https://bugs.launchpad.net/qemu/+bug/1844635
Message-Id: <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
(cherry picked from commit e423455c4f23a1a828901c78fe6d03b7dde79319)
Signed-off-by: Michael Roth <[email protected]> |
TF_LITE_MICRO_TEST(GatherNd_SliceIndexingIntoRank3Tensor) {
// For input_dims[], index_dims[], or output_dims[], element 0 is the
// number of dimensions in that array, not the actual dimension data.
int input_dims[] = {3, 3, 2, 3};
int index_dims[] = {2, 2, 1};
const int32_t index_data[] = {0, 2};
const float input_data[] = {1.1, -1.2, 1.3, -2.1, 2.2, 2.3, //
3.1, 3.2, -3.3, -4.1, -4.2, 4.3, //
5.1, -5.2, 5.3, 6.1, -6.2, 6.3};
const float golden_data[] = {1.1, -1.2, 1.3, -2.1, 2.2, 2.3,
5.1, -5.2, 5.3, 6.1, -6.2, 6.3};
float output_data[12];
int output_dims[] = {3, 0, 0, 0};
tflite::testing::TestGatherNd<float, int32_t>(
input_dims, input_data, index_dims, index_data, output_dims, output_data,
golden_data);
} | 0 | [
"CWE-703"
] | tflite-micro | 4142e47e9e31db481781b955ed3ff807a781b494 | 93,410,767,095,951,320,000,000,000,000,000,000,000 | 17 | GatherNd verifies that an index is valid before reading. (#1286) |
static void _ldm_printk (const char *level, const char *function,
const char *fmt, ...)
{
static char buf[128];
va_list args;
va_start (args, fmt);
vsnprintf (buf, sizeof (buf), fmt, args);
va_end (args);
printk ("%s%s(): %s\n", level, function, buf);
} | 0 | [
"CWE-119",
"CWE-787"
] | linux | cae13fe4cc3f24820ffb990c09110626837e85d4 | 160,578,142,671,164,000,000,000,000,000,000,000,000 | 12 | Fix for buffer overflow in ldm_frag_add not sufficient
As Ben Hutchings discovered [1], the patch for CVE-2011-1017 (buffer
overflow in ldm_frag_add) is not sufficient. The original patch in
commit c340b1d64000 ("fs/partitions/ldm.c: fix oops caused by corrupted
partition table") does not consider that, for subsequent fragments,
previously allocated memory is used.
[1] http://lkml.org/lkml/2011/5/6/407
Reported-by: Ben Hutchings <[email protected]>
Signed-off-by: Timo Warns <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
static Token *make_tok_qstr_len(Token *next, const char *str, size_t len)
{
char *p = nasm_quote(str, &len);
return new_Token_free(next, TOK_STRING, p, len);
} | 0 | [] | nasm | 6299a3114ce0f3acd55d07de201a8ca2f0a83059 | 296,230,919,608,142,200,000,000,000,000,000,000,000 | 5 | BR 3392708: fix NULL pointer reference for invalid %stacksize
After issuing an error message for a missing %stacksize argument, need
to quit rather than continuing to try to access the pointer.
Fold uses of tok_text() while we are at it.
Reported-by: Suhwan <[email protected]>
Signed-off-by: H. Peter Anvin (Intel) <[email protected]> |
InputFile::compatibilityInitialize (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is)
{
is.seekg(0);
//
// Construct a MultiPartInputFile, initialize InputFile
// with the part 0 data.
// (TODO) may want to have a way to set the reconstruction flag.
//
_data->multiPartBackwardSupport = true;
_data->multiPartFile = new MultiPartInputFile(is, _data->numThreads);
InputPartData* part = _data->multiPartFile->getPart(0);
multiPartInitialize (part);
} | 0 | [
"CWE-125"
] | openexr | e79d2296496a50826a15c667bf92bdc5a05518b4 | 108,419,524,004,873,000,000,000,000,000,000,000,000 | 15 | fix memory leaks and invalid memory accesses
Signed-off-by: Peter Hillman <[email protected]> |
static ssize_t sockfs_getxattr(struct dentry *dentry,
const char *name, void *value, size_t size)
{
const char *proto_name;
size_t proto_size;
int error;
error = -ENODATA;
if (!strncmp(name, XATTR_NAME_SOCKPROTONAME, XATTR_NAME_SOCKPROTONAME_LEN)) {
proto_name = dentry->d_name.name;
proto_size = strlen(proto_name);
if (value) {
error = -ERANGE;
if (proto_size + 1 > size)
goto out;
strncpy(value, proto_name, proto_size + 1);
}
error = proto_size + 1;
}
out:
return error;
} | 0 | [
"CWE-264"
] | net | 4de930efc23b92ddf88ce91c405ee645fe6e27ea | 51,653,496,279,175,630,000,000,000,000,000,000,000 | 25 | net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfrom
Cc: [email protected] # v3.19
Signed-off-by: Al Viro <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
void mlx5_stop_health_poll(struct mlx5_core_dev *dev, bool disable_health)
{
struct mlx5_core_health *health = &dev->priv.health;
unsigned long flags;
if (disable_health) {
spin_lock_irqsave(&health->wq_lock, flags);
set_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags);
spin_unlock_irqrestore(&health->wq_lock, flags);
}
del_timer_sync(&health->timer);
} | 0 | [
"CWE-400",
"CWE-401"
] | linux | c7ed6d0183d5ea9bc31bcaeeba4070bd62546471 | 226,568,248,040,863,200,000,000,000,000,000,000,000 | 13 | net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump
In mlx5_fw_fatal_reporter_dump if mlx5_crdump_collect fails the
allocated memory for cr_data must be released otherwise there will be
memory leak. To fix this, this commit changes the return instruction
into goto error handling.
Fixes: 9b1f29823605 ("net/mlx5: Add support for FW fatal reporter dump")
Signed-off-by: Navid Emamdoost <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]> |
static inline int managed_dentry_rcu(struct dentry *dentry)
{
return (dentry->d_flags & DCACHE_MANAGE_TRANSIT) ?
dentry->d_op->d_manage(dentry, true) : 0;
} | 0 | [
"CWE-416"
] | linux | f15133df088ecadd141ea1907f2c96df67c729f0 | 93,971,110,023,286,590,000,000,000,000,000,000,000 | 5 | path_openat(): fix double fput()
path_openat() jumps to the wrong place after do_tmpfile() - it has
already done path_cleanup() (as part of path_lookupat() called by
do_tmpfile()), so doing that again can lead to double fput().
Cc: [email protected] # v3.11+
Signed-off-by: Al Viro <[email protected]> |
void drop_inmem_page(struct inode *inode, struct page *page)
{
struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct list_head *head = &fi->inmem_pages;
struct inmem_pages *cur = NULL;
f2fs_bug_on(sbi, !IS_ATOMIC_WRITTEN_PAGE(page));
mutex_lock(&fi->inmem_lock);
list_for_each_entry(cur, head, list) {
if (cur->page == page)
break;
}
f2fs_bug_on(sbi, !cur || cur->page != page);
list_del(&cur->list);
mutex_unlock(&fi->inmem_lock);
dec_page_count(sbi, F2FS_INMEM_PAGES);
kmem_cache_free(inmem_entry_slab, cur);
ClearPageUptodate(page);
set_page_private(page, 0);
ClearPagePrivate(page);
f2fs_put_page(page, 0);
trace_f2fs_commit_inmem_page(page, INMEM_INVALIDATE);
} | 0 | [
"CWE-20"
] | linux | 638164a2718f337ea224b747cf5977ef143166a4 | 168,225,587,753,567,050,000,000,000,000,000,000,000 | 29 | 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 <[email protected]>
Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]> |
static void handle_rx(struct vhost_net *net)
{
struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_RX];
struct vhost_virtqueue *vq = &nvq->vq;
unsigned uninitialized_var(in), log;
struct vhost_log *vq_log;
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
.msg_control = NULL, /* FIXME: get and handle RX aux data. */
.msg_controllen = 0,
.msg_flags = MSG_DONTWAIT,
};
struct virtio_net_hdr hdr = {
.flags = 0,
.gso_type = VIRTIO_NET_HDR_GSO_NONE
};
size_t total_len = 0;
int err, mergeable;
s16 headcount, nheads = 0;
size_t vhost_hlen, sock_hlen;
size_t vhost_len, sock_len;
struct socket *sock;
struct iov_iter fixup;
__virtio16 num_buffers;
mutex_lock_nested(&vq->mutex, 0);
sock = vq->private_data;
if (!sock)
goto out;
if (!vq_iotlb_prefetch(vq))
goto out;
vhost_disable_notify(&net->dev, vq);
vhost_net_disable_vq(net, vq);
vhost_hlen = nvq->vhost_hlen;
sock_hlen = nvq->sock_hlen;
vq_log = unlikely(vhost_has_feature(vq, VHOST_F_LOG_ALL)) ?
vq->log : NULL;
mergeable = vhost_has_feature(vq, VIRTIO_NET_F_MRG_RXBUF);
while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk))) {
sock_len += sock_hlen;
vhost_len = sock_len + vhost_hlen;
headcount = get_rx_bufs(vq, vq->heads + nheads, vhost_len,
&in, vq_log, &log,
likely(mergeable) ? UIO_MAXIOV : 1);
/* On error, stop handling until the next kick. */
if (unlikely(headcount < 0))
goto out;
/* OK, now we need to know about added descriptors. */
if (!headcount) {
if (unlikely(vhost_enable_notify(&net->dev, vq))) {
/* They have slipped one in as we were
* doing that: check again. */
vhost_disable_notify(&net->dev, vq);
continue;
}
/* Nothing new? Wait for eventfd to tell us
* they refilled. */
goto out;
}
if (nvq->rx_ring)
msg.msg_control = vhost_net_buf_consume(&nvq->rxq);
/* On overrun, truncate and discard */
if (unlikely(headcount > UIO_MAXIOV)) {
iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1);
err = sock->ops->recvmsg(sock, &msg,
1, MSG_DONTWAIT | MSG_TRUNC);
pr_debug("Discarded rx packet: len %zd\n", sock_len);
continue;
}
/* We don't need to be notified again. */
iov_iter_init(&msg.msg_iter, READ, vq->iov, in, vhost_len);
fixup = msg.msg_iter;
if (unlikely((vhost_hlen))) {
/* We will supply the header ourselves
* TODO: support TSO.
*/
iov_iter_advance(&msg.msg_iter, vhost_hlen);
}
err = sock->ops->recvmsg(sock, &msg,
sock_len, MSG_DONTWAIT | MSG_TRUNC);
/* Userspace might have consumed the packet meanwhile:
* it's not supposed to do this usually, but might be hard
* to prevent. Discard data we got (if any) and keep going. */
if (unlikely(err != sock_len)) {
pr_debug("Discarded rx packet: "
" len %d, expected %zd\n", err, sock_len);
vhost_discard_vq_desc(vq, headcount);
continue;
}
/* Supply virtio_net_hdr if VHOST_NET_F_VIRTIO_NET_HDR */
if (unlikely(vhost_hlen)) {
if (copy_to_iter(&hdr, sizeof(hdr),
&fixup) != sizeof(hdr)) {
vq_err(vq, "Unable to write vnet_hdr "
"at addr %p\n", vq->iov->iov_base);
goto out;
}
} else {
/* Header came from socket; we'll need to patch
* ->num_buffers over if VIRTIO_NET_F_MRG_RXBUF
*/
iov_iter_advance(&fixup, sizeof(hdr));
}
/* TODO: Should check and handle checksum. */
num_buffers = cpu_to_vhost16(vq, headcount);
if (likely(mergeable) &&
copy_to_iter(&num_buffers, sizeof num_buffers,
&fixup) != sizeof num_buffers) {
vq_err(vq, "Failed num_buffers write");
vhost_discard_vq_desc(vq, headcount);
goto out;
}
nheads += headcount;
if (nheads > VHOST_RX_BATCH) {
vhost_add_used_and_signal_n(&net->dev, vq, vq->heads,
nheads);
nheads = 0;
}
if (unlikely(vq_log))
vhost_log_write(vq, vq_log, log, vhost_len);
total_len += vhost_len;
if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
vhost_poll_queue(&vq->poll);
goto out;
}
}
vhost_net_enable_vq(net, vq);
out:
if (nheads)
vhost_add_used_and_signal_n(&net->dev, vq, vq->heads,
nheads);
mutex_unlock(&vq->mutex);
} | 1 | [
"CWE-787"
] | linux | f5a4941aa6d190e676065e8f4ed35999f52a01c3 | 9,079,046,485,111,848,000,000,000,000,000,000,000 | 140 | vhost_net: flush batched heads before trying to busy polling
After commit e2b3b35eb989 ("vhost_net: batch used ring update in rx"),
we tend to batch updating used heads. But it doesn't flush batched
heads before trying to do busy polling, this will cause vhost to wait
for guest TX which waits for the used RX. Fixing by flush batched
heads before busy loop.
1 byte TCP_RR performance recovers from 13107.83 to 50402.65.
Fixes: e2b3b35eb989 ("vhost_net: batch used ring update in rx")
Signed-off-by: Jason Wang <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
int gnutls_x509_ext_import_proxy(const gnutls_datum_t * ext, int *pathlen,
char **policyLanguage, char **policy,
size_t * sizeof_policy)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
int result;
gnutls_datum_t value = { NULL, 0 };
if ((result = asn1_create_element
(_gnutls_get_pkix(), "PKIX1.ProxyCertInfo",
&c2)) != ASN1_SUCCESS) {
gnutls_assert();
return _gnutls_asn2err(result);
}
result = asn1_der_decoding(&c2, ext->data, ext->size, NULL);
if (result != ASN1_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto cleanup;
}
if (pathlen) {
result = _gnutls_x509_read_uint(c2, "pCPathLenConstraint",
(unsigned int *)
pathlen);
if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
*pathlen = -1;
else if (result != GNUTLS_E_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto cleanup;
}
}
result = _gnutls_x509_read_value(c2, "proxyPolicy.policyLanguage",
&value);
if (result < 0) {
gnutls_assert();
goto cleanup;
}
if (policyLanguage) {
*policyLanguage = (char *)value.data;
} else {
gnutls_free(value.data);
value.data = NULL;
}
result = _gnutls_x509_read_value(c2, "proxyPolicy.policy", &value);
if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) {
if (policy)
*policy = NULL;
if (sizeof_policy)
*sizeof_policy = 0;
} else if (result < 0) {
gnutls_assert();
goto cleanup;
} else {
if (policy) {
*policy = (char *)value.data;
value.data = NULL;
}
if (sizeof_policy)
*sizeof_policy = value.size;
}
result = 0;
cleanup:
gnutls_free(value.data);
asn1_delete_structure(&c2);
return result;
} | 0 | [] | gnutls | d6972be33264ecc49a86cd0958209cd7363af1e9 | 56,822,815,354,946,650,000,000,000,000,000,000,000 | 74 | eliminated double-free in the parsing of dist points
Reported by Robert Święcki. |
static int atl2_close(struct net_device *netdev)
{
struct atl2_adapter *adapter = netdev_priv(netdev);
WARN_ON(test_bit(__ATL2_RESETTING, &adapter->flags));
atl2_down(adapter);
atl2_free_irq(adapter);
atl2_free_ring_resources(adapter);
return 0;
} | 0 | [
"CWE-200"
] | linux | f43bfaeddc79effbf3d0fcb53ca477cca66f3db8 | 279,607,679,267,072,240,000,000,000,000,000,000,000 | 12 | atl2: Disable unimplemented scatter/gather feature
atl2 includes NETIF_F_SG in hw_features even though it has no support
for non-linear skbs. This bug was originally harmless since the
driver does not claim to implement checksum offload and that used to
be a requirement for SG.
Now that SG and checksum offload are independent features, if you
explicitly enable SG *and* use one of the rare protocols that can use
SG without checkusm offload, this potentially leaks sensitive
information (before you notice that it just isn't working). Therefore
this obscure bug has been designated CVE-2016-2117.
Reported-by: Justin Yackoski <[email protected]>
Signed-off-by: Ben Hutchings <[email protected]>
Fixes: ec5f06156423 ("net: Kill link between CSUM and SG features.")
Signed-off-by: David S. Miller <[email protected]> |
static void ima_adpcm_run_pull (_AFmoduleinst *module)
{
ima_adpcm_data *d = (ima_adpcm_data *) module->modspec;
AFframecount frames2read = module->outc->nframes;
AFframecount nframes = 0;
int i, framesPerBlock, blockCount;
ssize_t blocksRead, bytesDecoded;
framesPerBlock = d->samplesPerBlock / d->track->f.channelCount;
assert(module->outc->nframes % framesPerBlock == 0);
blockCount = module->outc->nframes / framesPerBlock;
/* Read the compressed frames. */
blocksRead = af_fread(module->inc->buf, d->blockAlign, blockCount, d->fh);
/* This condition would indicate that the file is bad. */
if (blocksRead < 0)
{
if (d->track->filemodhappy)
{
_af_error(AF_BAD_READ, "file missing data");
d->track->filemodhappy = AF_FALSE;
}
}
if (blocksRead < blockCount)
blockCount = blocksRead;
/* Decompress into module->outc. */
for (i=0; i<blockCount; i++)
{
bytesDecoded = ima_adpcm_decode_block(d,
(uint8_t *) module->inc->buf + i * d->blockAlign,
(int16_t *) module->outc->buf + i * d->samplesPerBlock);
nframes += framesPerBlock;
}
d->track->nextfframe += nframes;
if (blocksRead > 0)
d->track->fpos_next_frame += blocksRead * d->blockAlign;
assert(af_ftell(d->fh) == d->track->fpos_next_frame);
/*
If we got EOF from read, then we return the actual amount read.
Complain only if there should have been more frames in the file.
*/
if (d->track->totalfframes != -1 && nframes != frames2read)
{
/* Report error if we haven't already */
if (d->track->filemodhappy)
{
_af_error(AF_BAD_READ,
"file missing data -- read %d frames, should be %d",
d->track->nextfframe,
d->track->totalfframes);
d->track->filemodhappy = AF_FALSE;
}
}
module->outc->nframes = nframes;
} | 1 | [
"CWE-119"
] | audiofile | e8cf0095b3f319739f9aa1ab5a1aa52b76be8cdd | 135,392,062,269,304,940,000,000,000,000,000,000,000 | 66 | Fix decoding of multi-channel ADPCM audio files. |
create_trace_option_file(struct trace_array *tr,
struct trace_option_dentry *topt,
struct tracer_flags *flags,
struct tracer_opt *opt)
{
struct dentry *t_options;
t_options = trace_options_init_dentry(tr);
if (!t_options)
return;
topt->flags = flags;
topt->opt = opt;
topt->tr = tr;
topt->entry = trace_create_file(opt->name, 0644, t_options, topt,
&trace_options_fops);
} | 0 | [
"CWE-415"
] | linux | 4397f04575c44e1440ec2e49b6302785c95fd2f8 | 321,644,912,274,922,500,000,000,000,000,000,000,000 | 19 | tracing: Fix possible double free on failure of allocating trace buffer
Jing Xia and Chunyan Zhang reported that on failing to allocate part of the
tracing buffer, memory is freed, but the pointers that point to them are not
initialized back to NULL, and later paths may try to free the freed memory
again. Jing and Chunyan fixed one of the locations that does this, but
missed a spot.
Link: http://lkml.kernel.org/r/[email protected]
Cc: [email protected]
Fixes: 737223fbca3b1 ("tracing: Consolidate buffer allocation code")
Reported-by: Jing Xia <[email protected]>
Reported-by: Chunyan Zhang <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]> |
Subsets and Splits