Index | Thread | Search

From:
Rafael Sadowski <rafael@sizeofvoid.org>
Subject:
Re: httpd: remove MAX_IMSG_DATA_SIZE
To:
tech@openbsd.org
Date:
Sun, 18 Oct 2026 09:05:12 +0200

Download raw body.

Thread
On Sat Oct 17, 2026 at 08:09:52PM +0200, Claudio Jeker wrote:
> On Sat, Oct 17, 2026 at 09:02:27AM +0200, Rafael Sadowski wrote:
> > Remove MAX_IMSG_DATA_SIZE and we avoid having to calculate the length
> > over and over again in a loop.
> > 
> > OK?
> 
> Did you consider if this can be neutralizied by using
> imsgbuf_set_maxsize()? Or are these chunks really that big?

After you pointer, yes. The limit is per imsgbuf, not per message type, so
it can't be raised just for the TLS data. It would apply to the whole
parent<->server channel and needs special-casing in the generic proc.c.

That might make sense for relayd and the CA process, but I don't think
it would work in httpd with the current design.

> 
> > commit ab64b2726bed8f57259124a8aa04ba3dd5cdf98c
> > Author: Rafael Sadowski <rafael@sizeofvoid.org>
> > Date:   Sat Oct 17 08:59:57 2026 +0200
> > 
> >     httpd: remove MAX_IMSG_DATA_SIZE
> > 
> > diff --git a/config.c b/config.c
> > index 957da66..23a7042 100644
> > --- a/config.c
> > +++ b/config.c
> > @@ -320,7 +320,7 @@ config_settls(struct httpd *env, struct server *srv, enum tls_config_type type,
> >  	struct server_config	*srv_conf = &srv->srv_conf;
> >  	struct tls_config	 tls;
> >  	struct iovec		 iov[2];
> > -	size_t			 c;
> > +	size_t			 c, maxchunk;
> >  
> >  	if (data == NULL || len == 0)
> >  		return (0);
> > @@ -335,10 +335,13 @@ config_settls(struct httpd *env, struct server *srv, enum tls_config_type type,
> >  	tls.tls_len = len;
> >  	tls.tls_chunk_offset = 0;
> >  
> > +	/* largest chunk that fits next to the header into one imsg */
> > +	maxchunk = MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(tls);
> > +
> >  	while (len > 0) {
> >  		tls.tls_chunk_len = len;
> > -		if (tls.tls_chunk_len > (MAX_IMSG_DATA_SIZE - sizeof(tls)))
> > -			tls.tls_chunk_len = MAX_IMSG_DATA_SIZE - sizeof(tls);
> > +		if (tls.tls_chunk_len > maxchunk)
> > +			tls.tls_chunk_len = maxchunk;
> >  
> >  		c = 0;
> >  		iov[c].iov_base = &tls;
> > 
> 
> -- 
> :wq Claudio