static void sysctl_check_leaf(struct nsproxy *namespaces, struct ctl_table *table, const char **fail) { struct ctl_table *ref; ref = sysctl_check_lookup(namespaces, table); if (ref && (ref != table)) set_fail(fail, table, "Sysctl already exists"); }
std::ios_base::iostate handle_error(StreamType& strm) const { std::ios_base::iostate err(error_m); try { throw; } catch (std::bad_alloc&) { set_bad(); std::ios_base::iostate exception_mask(strm.exceptions()); if (exception_mask & std::ios_base::failbit && !(exception_mask & std::ios_base::badbit)) strm.setstate(err); else if (exception_mask & std::ios_base::badbit) { try { strm.setstate(err); } catch (std::ios_base::failure&) { } throw; } } catch (...) { set_fail(); std::ios_base::iostate exception_mask(strm.exceptions()); if ((exception_mask & std::ios_base::badbit) && (err & std::ios_base::badbit)) strm.setstate(err); else if (exception_mask & std::ios_base::failbit) { try { strm.setstate(err); } catch (std::ios_base::failure&) { } throw; } } return err; }
int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table) { int error = 0; for (; table->procname; table++) { const char *fail = NULL; if (table->parent) { if (table->procname && !table->parent->procname) set_fail(&fail, table, "Parent without procname"); } if (!table->procname) set_fail(&fail, table, "No procname"); if (table->child) { if (table->data) set_fail(&fail, table, "Directory with data?"); if (table->maxlen) set_fail(&fail, table, "Directory with maxlen?"); if ((table->mode & (S_IRUGO|S_IXUGO)) != table->mode) set_fail(&fail, table, "Writable sysctl directory"); if (table->proc_handler) set_fail(&fail, table, "Directory with proc_handler"); if (table->extra1) set_fail(&fail, table, "Directory with extra1"); if (table->extra2) set_fail(&fail, table, "Directory with extra2"); } else { if ((table->proc_handler == proc_dostring) || (table->proc_handler == proc_dointvec) || (table->proc_handler == proc_dointvec_minmax) || (table->proc_handler == proc_dointvec_jiffies) || (table->proc_handler == proc_dointvec_userhz_jiffies) || (table->proc_handler == proc_dointvec_ms_jiffies) || (table->proc_handler == proc_doulongvec_minmax) || (table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) { if (!table->data) set_fail(&fail, table, "No data"); if (!table->maxlen) set_fail(&fail, table, "No maxlen"); } #ifdef CONFIG_PROC_SYSCTL if (table->procname && !table->proc_handler) set_fail(&fail, table, "No proc_handler"); #endif #if 0 if (!table->procname && table->proc_handler) set_fail(&fail, table, "proc_handler without procname"); #endif sysctl_check_leaf(namespaces, table, &fail); } if (table->mode > 0777) set_fail(&fail, table, "bogus .mode"); if (fail) { set_fail(&fail, table, NULL); error = -EINVAL; } if (table->child) error |= sysctl_check_table(namespaces, table->child); } return error; }