From c1d034958dfd0431d8020bd8fac24a28e8141e61 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 27 Apr 2015 19:39:25 +0200 Subject: [PATCH 029/257] ggatec: Reject unsupported BIO commands Due to missing sanity checks in ggatec, requests like BIO_FLUSH and BIO_DELETE were previously accepted and sent as zero-size reads or writes. Also due to missing sanity checks, ggated did not mind. Obtained from: ElectroBSD --- sbin/ggate/ggatec/ggatec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index dd75c6468e9f..650e4f585d54 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -146,6 +146,13 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_ERR, + "Rejecting unsupported BIO command: %d", + ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; -- 2.11.0