Skip to content

Commit

Permalink
BUG/MEDIUM: mux-h1: Be sure xprt support splicing to use it during fa…
Browse files Browse the repository at this point in the history
…st-forward

The commit d6d4abd ("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 haproxy#2095
(#issuecomment-1788949014). No backport needed.
  • Loading branch information
capflam committed Nov 7, 2023
1 parent 6f9b65f commit 7d7df1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mux_h1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.data = 0;
ret = count;
Expand Down Expand Up @@ -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)
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)) {
h1c->flags &= ~H1C_F_IN_FULL;
TRACE_STATE("h1c ibuf not full anymore", H1_EV_STRM_RECV|H1_EV_H1C_BLK);
Expand Down

0 comments on commit 7d7df1c

Please sign in to comment.