From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=new2025; t=1757166296; bh=oV/NmCsqxGcYQMBEyML6gmMZIWVO3rxReXv6KxDqFnw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=TDfTxDteBdEh7G2lKdkf2lkR90CC4xZcSkm2OlfKQliodNQvOkkCIs7SHZLbUc46Q 9OoCKJpW6GMil3PJC9liXCIA/uV9qmlwYDlvjlJ3rYq55r9u83UVf1ke+iXGEOVyqU NAABHlgMUK+9bu9b6nvIpkxPGDgMCwfg/mgLsqZ+InBacVvElV1XmwI9HDtX8pG4w6 2Mg22bPzbbvrV2Yt5uiqtfcjQTm/7I/FLYg60yjZJZW8Yiry7tr5aTHOTQscp9MvaL fG2LKersQpSmnb7ZOPH+cj6/YOWvS9WYkvFYDuHHfJF8gs1+Dr+26cThefFV/rEvR4 tdJbVpx1qId3Q== Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id B0EFC31279C9 for ; Sat, 6 Sep 2025 13:44:56 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-32b6108f2d5so2109154a91.3 for ; Sat, 06 Sep 2025 06:44:56 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWGouweMPYYlBn2+XF8vGTquWmCwMiXHEHM1tLzyifidmkYLZ+g8qkKpMtLdx+09TFzVrAS@vger.gnuweeb.org X-Gm-Message-State: AOJu0YxhOFpCtPjI+IzBiXuC00xi2LzoFP5znOJf7SLh0hRGco62TLYx Gkczzs+yiJQKHIuJtjv4HPHIrpmAO6aY+zHK0jPOlrU4wxdtxcLUscn/T0nXnOJxML9tBmG7cdc Ws6ivrDPIG9zoF9Wiv8JW0lxbUGdgjR0= X-Google-Smtp-Source: AGHT+IGzyN1c4z2XDj2D+a/hUCjMItJbXPOZosXRZt1ZdWu+0Aum1UK5UhhIuXZ3xV6nMyp6+hC50GPnQOII2y8/PzI= X-Received: by 2002:a17:90b:574b:b0:32b:51ab:5d40 with SMTP id 98e67ed59e1d1-32d43f9a7dbmr3124117a91.35.1757166295091; Sat, 06 Sep 2025 06:44:55 -0700 (PDT) MIME-Version: 1.0 References: <20250829075557.598176-1-reyuki@gnuweeb.org> <20250829075557.598176-3-reyuki@gnuweeb.org> In-Reply-To: From: Alviro Iskandar Setiawan Date: Sat, 6 Sep 2025 20:44:43 +0700 X-Gmail-Original-Message-ID: X-Gm-Features: Ac12FXyoc5lS4SjE3Tsc1FKxRAcwie5IaXP-_WGpNH5OWBXzEf3DJsfLNoL9Zzs Message-ID: Subject: Re: [PATCH gwproxy v8 2/2] gwproxy: refactor code base to add experimental raw DNS backend To: Ahmad Gani Cc: Ammar Faizi , "GNU/Weeb Mailing List" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: On Sat, Sep 6, 2025 at 8:30=E2=80=AFPM Alviro Iskandar Setiawan wrote: > But note that, since the lifetime of the "struct > gwp_conn_pair" is now tied to both: > 1) The SOCKS5 session, and > 2) The DNS resolution query. > You will need to make "struct gwp_conn_pair" refcounted to avoid > use-after-free in case the DNS resolution query completes after the > SOCKS5 session has been killed. Thinking about this more, I found that the "struct gwp_conn_pair" does not need to be refcounted. So, we have: struct gwp_conn_pair *sess_map[65536]; Initially, set: sess_map[0..65535] =3D NULL; then, when a SOCKS5 needs a DNS query, generate a txid, then set: sess_map[txid] =3D socks5 session; if the socks5 session dies first before the DNS query completes, set: sess_map[txid] =3D NULL; then, when the DNS query completes and it sees sess_map[txid] =3D=3D NULL, just drop the response, do nothing. No refcount needed.