BUG/MEDIUM: mux-h1: Be sure xprt support splicing to use it during fast-forward

The commit d6d4abdc3 ("BUILD: mux-h1: Fix build without kernel splicing
support") introduced a regression. The kernel support for the underlying
XPRT is no longer checked. So it is possible to enable the splicing for SSL
connection. This of course leads to a segfault.

This patch restore the test on the xprt rcv_pipe/snd_pipe functions.

This patch should fix a crash reported by Tristan in #2095
(#issuecomment-1788949014). No backport needed.
This commit is contained in:
Christopher Faulet 2023-11-07 18:16:33 +01:00
parent 6f9b65f952
commit 7d7df1cf0a

View File

@ -4424,7 +4424,7 @@ static size_t h1_nego_ff(struct stconn *sc, struct buffer *input, size_t count,
*/ */
if (!b_data(input) && !b_data(&h1c->obuf) && may_splice) { if (!b_data(input) && !b_data(&h1c->obuf) && may_splice) {
#if defined(USE_LINUX_SPLICE) #if defined(USE_LINUX_SPLICE)
if (h1s->sd->iobuf.pipe || (pipes_used < global.maxpipes && (h1s->sd->iobuf.pipe = get_pipe()))) { if (h1c->conn->xprt->snd_pipe && (h1s->sd->iobuf.pipe || (pipes_used < global.maxpipes && (h1s->sd->iobuf.pipe = get_pipe())))) {
h1s->sd->iobuf.offset = 0; h1s->sd->iobuf.offset = 0;
h1s->sd->iobuf.data = 0; h1s->sd->iobuf.data = 0;
ret = count; ret = count;
@ -4585,7 +4585,7 @@ static int h1_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags)
if (h1m->state == H1_MSG_DATA && (h1m->flags & (H1_MF_CHNK|H1_MF_CLEN)) && count > h1m->curr_len) if (h1m->state == H1_MSG_DATA && (h1m->flags & (H1_MF_CHNK|H1_MF_CLEN)) && count > h1m->curr_len)
count = h1m->curr_len; count = h1m->curr_len;
try = se_nego_ff(sdo, &h1c->ibuf, count, !!(flags & CO_RFL_MAY_SPLICE) && !(sdo->iobuf.flags & IOBUF_FL_NO_SPLICING)); try = se_nego_ff(sdo, &h1c->ibuf, count, h1c->conn->xprt->rcv_pipe && !!(flags & CO_RFL_MAY_SPLICE) && !(sdo->iobuf.flags & IOBUF_FL_NO_SPLICING));
if (b_room(&h1c->ibuf) && (h1c->flags & H1C_F_IN_FULL)) { if (b_room(&h1c->ibuf) && (h1c->flags & H1C_F_IN_FULL)) {
h1c->flags &= ~H1C_F_IN_FULL; h1c->flags &= ~H1C_F_IN_FULL;
TRACE_STATE("h1c ibuf not full anymore", H1_EV_STRM_RECV|H1_EV_H1C_BLK); TRACE_STATE("h1c ibuf not full anymore", H1_EV_STRM_RECV|H1_EV_H1C_BLK);