Print this page
NEX-9665 libcfgadm: memory leak in do_list_common()
Reviewed by: Jan Kryl <jan.kryl@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
NEX-9634 cfgadm_plugins/shp: memory leaks in cfga_list_ext()
Reviewed by: Jan Kryl <jan.kryl@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
NEX-8148 Alerts should be sent if cores are created on a system (lint fix)
NEX-8148 Alerts should be sent if cores are created on a system
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
@@ -21,10 +21,11 @@
/*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, Joyent Inc. All rights reserved.
* Copyright (c) 2016 by Delphix. All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
@@ -62,10 +63,14 @@
#include <sys/nbmlock.h>
#include <sys/stat.h>
#include <sys/zone.h>
#include <sys/contract/process_impl.h>
#include <sys/ddi.h>
+#include <sys/fm/protocol.h>
+#include <sys/fm/util.h>
+#include <sys/fm/sw/core.h>
+#include <sys/sysevent.h>
/*
* Processes running within a zone potentially dump core in 3 locations,
* based on the per-process, per-zone, and the global zone's core settings.
*
@@ -102,10 +107,59 @@
zcmn_err(zoneid, CE_NOTE, "core_log: %s[%d] %s, errno=%d: %s",
fn, pid, why, error, path);
}
/*
+ * Generate FMA e-report for a core.
+ */
+static void
+gen_ereport(const char *path, int sig)
+{
+ nvlist_t *ereport = NULL;
+ nvlist_t *fmri = NULL;
+ nvlist_t *sw_obj = NULL;
+ uint64_t ena;
+ proc_t *p = curproc;
+ int err = 0;
+
+ if ((ereport = fm_nvlist_create(NULL)) == NULL)
+ return;
+ if ((fmri = fm_nvlist_create(NULL)) == NULL)
+ goto out;
+ if ((sw_obj = fm_nvlist_create(NULL)) == NULL)
+ goto out;
+ ena = fm_ena_generate(0, FM_ENA_FMT1);
+
+ err |= nvlist_add_uint8(fmri, FM_VERSION, FM_SW_SCHEME_VERSION);
+ err |= nvlist_add_string(fmri, FM_FMRI_SCHEME, FM_FMRI_SCHEME_SW);
+ err |= nvlist_add_string(sw_obj, FM_FMRI_SW_OBJ_PATH, path);
+ err |= nvlist_add_nvlist(fmri, FM_FMRI_SW_OBJ, sw_obj);
+
+ if (err != 0)
+ goto out;
+
+ fm_ereport_set(ereport, FM_EREPORT_VERSION, CORE_ERROR_CLASS,
+ ena, fmri, NULL);
+
+ fm_payload_set(ereport,
+ FM_EREPORT_PAYLOAD_CORE_COMMAND, DATA_TYPE_STRING,
+ p->p_exec->v_path ? p->p_exec->v_path : p->p_user.u_comm,
+ FM_EREPORT_PAYLOAD_CORE_PSARGS, DATA_TYPE_STRING,
+ p->p_user.u_psargs,
+ FM_EREPORT_PAYLOAD_CORE_SIGNAL, DATA_TYPE_INT32, sig,
+ FM_EREPORT_PAYLOAD_CORE_PATH, DATA_TYPE_STRING, path,
+ NULL);
+
+ fm_ereport_post(ereport, EVCH_SLEEP);
+
+out:
+ fm_nvlist_destroy(sw_obj, FM_NVA_FREE);
+ fm_nvlist_destroy(ereport, FM_NVA_FREE);
+ fm_nvlist_destroy(fmri, FM_NVA_FREE);
+}
+
+/*
* Private version of vn_remove().
* Refuse to unlink a directory or an unwritable file.
* Also allow the process to access files normally inaccessible due to
* chroot(2) or Zone limitations.
*/
@@ -761,10 +815,17 @@
contract_process_core(p->p_ct_process, p, sig,
error1 == 0 ? fp_process : NULL,
error2 == 0 ? fp_global : NULL,
error3 == 0 ? fp_zone : NULL);
+ /*
+ * FMA ereport is currently generated only for global zone cores
+ * with global path.
+ */
+ if (error2 == 0 && global_cg == my_cg)
+ gen_ereport(fp_global, sig);
+
if (fp_process != NULL)
kmem_free(fp_process, MAXPATHLEN);
if (fp_global != NULL)
kmem_free(fp_global, MAXPATHLEN);
if (fp_zone != NULL)