Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPACK dyn tables do not update special fields in req structure #1617

Closed
alegz-filomaphitskay opened this issue Apr 19, 2022 · 1 comment
Closed
Assignees
Milestone

Comments

@alegz-filomaphitskay
Copy link
Contributor

alegz-filomaphitskay commented Apr 19, 2022

See second request below that use indexes from hpack dynamic table:

	FOR_REQ_H2_HPACK(
	    HEADERS_FRAME_BEGIN();
		// :method = "GET"
		HEADER(INDEX(2));
		// :scheme = "https"
		HEADER(INDEX(7));
		// :path = "/"
		HEADER(INDEX(4));
		// host = "developer.mozilla.org:5588"
		HEADER(INC_IND(INDEX(38), VALUE("developer.mozilla.org:5588")));
		// if-modified-since = "Inv, 31 Jan 2012 15:02:53"
		HEADER(INC_IND(INDEX(40), VALUE("Inv, 31 Jan 2012 15:02:53 GMT")));
	    HEADERS_FRAME_END();
	)
	{
		EXPECT_TFWSTR_EQ(&req->h_tbl->tbl[TFW_HTTP_HDR_HOST],
				 "host" "developer.mozilla.org:5588");
		EXPECT_EQ(req->host_port, 5588);
		EXPECT_TFWSTR_EQ(&req->h_tbl->tbl[TFW_HTTP_HDR_RAW],
				 "if-modified-since"
				 "Inv, 31 Jan 2012 15:02:53 GMT");
		EXPECT_TRUE(req->cond.m_date == 1328022173);
		EXPECT_TRUE(req->cond.flags & TFW_HTTP_COND_IF_MSINCE);
	}

#define TOTAL_CNT_INC_IND 2

#define HPACK_DYN_TBL_INDEX 62
#define DYN_IND(entry_seq_no) \
	(HPACK_DYN_TBL_INDEX + TOTAL_CNT_INC_IND - entry_seq_no)

	FOR_REQ_H2_HPACK(
	    HEADERS_FRAME_BEGIN();
		// :method = "GET"
		HEADER(INDEX(2));
		// :scheme = "https"
		HEADER(INDEX(7));
		// :path = "/"
		HEADER(INDEX(4));
		// host = "developer.mozilla.org:5588"
		HEADER(INDEX(DYN_IND(1)));
		// if-modified-since = "Inv, 31 Jan 2012 15:02:53"
		HEADER(INDEX(DYN_IND(2)));
	    HEADERS_FRAME_END();
	)
	{
		EXPECT_TFWSTR_EQ(&req->h_tbl->tbl[TFW_HTTP_HDR_HOST],
				 "host" "developer.mozilla.org:5588");
		EXPECT_EQ(req->host_port, 5588);			// not passed!!!
		EXPECT_TFWSTR_EQ(&req->h_tbl->tbl[TFW_HTTP_HDR_RAW],
				 "if-modified-since"
				 "Inv, 31 Jan 2012 15:02:53 GMT");
		EXPECT_TRUE(req->cond.m_date == 1328022173);		// not passed!!!
		EXPECT_TRUE(req->cond.flags & TFW_HTTP_COND_IF_MSINCE);	// not passed!!!
	}

Also hpack do not recognize HTTP_METHOD from saved entry in dynamic table. See code:

	FOR_REQ_H2_HPACK(
	    HEADERS_FRAME_BEGIN();
		// :method = "GET"
		HEADER(INC_IND(INDEX(2), VALUE("GET")));
		// :scheme = "https"
		HEADER(INC_IND(INDEX(7), VALUE("https")));
		// :path = "/"
		HEADER(INC_IND(INDEX(4), VALUE("/")));
	    HEADERS_FRAME_END();
	)
	{
		EXPECT_EQ(req->method, TFW_HTTP_METH_GET);
		EXPECT_TFWSTR_EQ(&req->h_tbl->tbl[TFW_HTTP_HDR_H2_SCHEME],
				 ":scheme" "https");
		EXPECT_TFWSTR_EQ(&req->uri_path, "/");
	}

#define TOTAL_CNT_INC_IND 3

#define HPACK_DYN_TBL_INDEX 62
#define DYN_IND(entry_seq_no) \
	(HPACK_DYN_TBL_INDEX + TOTAL_CNT_INC_IND - entry_seq_no)

	FOR_REQ_H2_HPACK(
	    HEADERS_FRAME_BEGIN();
		// :method = "GET"
		HEADER(INDEX(DYN_IND(1)));
		// :scheme = "https"
		HEADER(INDEX(DYN_IND(2)));
		// :path = "/"
		HEADER(INDEX(DYN_IND(3)));
	    HEADERS_FRAME_END();
	);

and log:

[23925.976245] tfw_test: === request: [HTTP/2 request preview is not available now...]
[23925.977833] [tempesta fw] Free msg=000000008a90b302
[23925.978954] [tempesta fw] Set up HTTP message 000000008a90b302 with 3 bytes data
[23925.980661] tfw_test: do_split_and_parse: chunk_mode=1, chunk_size_index=0, chunk_size=9216
[23925.982471] tfw_test: split_and_parse_n: len=3, chunk_size=9216
[23925.983875] tfw_test: split_and_parse_n: len=3 pos=0
[23925.985019] [tempesta fw] tfw_hpack_decode: header processing, n=3, to_parse=3, state=0
[23925.986855] [tempesta fw] tfw_hpack_decode: reference by index...
[23925.988325] [tempesta fw] tfw_hpack_decode: decoded index: 64
[23925.989622] [tempesta fw] tfw_hpack_decode: get entire header by index: 64
[23925.991192] [tempesta fw] tfw_hpack_find_index: tbl->length=32, tbl->curr=3, curr=0, index=3
[23925.993025] [tempesta fw] tfw_hpack_find_index: [entry->hdr]
[23925.993027] [tempesta fw] tfw_hpack_find_index: nchunks=2, flags=0, len=10, data='\x80\xe0}˝\x96\xff\xff'
[23925.995986] [tempesta fw] tfw_hpack_find_index: nchunks=0, flags=0, len=7, data=':method'
[23925.997665] [tempesta fw] tfw_hpack_find_index: nchunks=0, flags=128, len=3, data='GET'
[23925.999368] [tempesta fw] tfw_hpack_find_index: entry->tag=0
> [23926.001543] WARNING: CPU: 2 PID: 147737 at /home/dev/Work/tempesta/fw/t/unit/../../..//fw/hpack.c:1213 tfw_hpack_decode+0x1ccb/0x1d00 [tfw_test]
[23926.004264] Modules linked in: tfw_test(OE+) tfw_fuzzer(OE) tempesta_db(OE) tempesta_lib(OE) prl_fs_freeze(POE) rfkill(E) prl_fs(POE) prl_eth(POE) intel_rapl_msr(E) intel_rapl_common(E) intel_pmc_core_pltdrv(E) intel_pmc_core(E) x86_
pkg_temp_thermal(E) coretemp(E) ghash_clmulni_intel(E) aesni_intel(E) libaes(E) crypto_simd(E) cryptd(E) glue_helper(E) snd_intel8x0(E) rapl(E) snd_ac97_codec(E) ac97_bus(E) snd_pcm(E) joydev(E) snd_timer(E) snd(E) soundcore(E) serio_ra
w(E) sbs(E) pcspkr(E) sg(E) virtio_balloon(E) pvpanic(E) sbshc(E) evdev(E) ac(E) binfmt_misc(E) parport_pc(E) ppdev(E) lp(E) parport(E) fuse(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc32c_generic(E) crc16(E) mbcache(E
) jbd2(E) sd_mod(E) t10_pi(E) sr_mod(E) crc_t10dif(E) cdrom(E) crct10dif_generic(E) ata_generic(E) hid_generic(E) usbhid(E) hid(E) virtio_gpu(E) virtio_dma_buf(E) drm_kms_helper(E) cec(E) xhci_pci(E) virtio_net(E) net_failover(E) drm(E)
xhci_hcd(E) ata_piix(E) failover(E) ehci_pci(E) ahci(E)
[23926.004316] uhci_hcd(E) libahci(E) crct10dif_pclmul(E) crct10dif_common(E) libata(E) ehci_hcd(E) crc32_pclmul(E) prl_tg(POE) crc32c_intel(E) i2c_i801(E) psmouse(E) virtio_pci(E) i2c_smbus(E) lpc_ich(E) virtio_ring(E) scsi_mod(E) usb
core(E) virtio(E) battery(E) button(E) [last unloaded: tempesta_lib]
[23926.032430] RIP: 0010:tfw_hpack_decode+0x1ccb/0x1d00 [tfw_test]
[23926.051287] tfw_h2_parse_req+0x5c/0x250 [tfw_test]
[23926.052334] do_split_and_parse.constprop.0+0x1df/0x294 [tfw_test]
[23926.054333] test_suite__http2_parser_hpack+0x7dd/0x8b3 [tfw_test]
[23926.055712] test_run_all+0x46/0x90 [tfw_test]
[23926.056674] tfw_test_init+0x17/0x49 [tfw_test]
[23926.079342] tfw_test: /home/dev/Work/tempesta/fw/t/unit/test_http2_parser_hpack.c:424: error:
[23926.081116] tfw_test: FAIL:
[23926.081713] tfw_test: test__http2_parser_hpack__dynamic_table()
[23926.082974] tfw_test: can't parse request (code=-2)

@krizhanovsky
Copy link
Contributor

It seems this is the 2nd warning from #1387

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants