[PATCH] Avoid symbol collision between ulogd and jansson.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hastable_del() is both existed in ulogd and jansson.
And it can causes symbol collision, try to avoid it.

Signed-off-by: hongsik.jo <hongsik.jo@xxxxxxx>
---
 include/ulogd/hash.h            | 2 +-
 input/flow/ulogd_inpflow_NFCT.c | 4 ++--
 src/hash.c                      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/ulogd/hash.h b/include/ulogd/hash.h
index d4aedb8..4b4874b 100644
--- a/include/ulogd/hash.h
+++ b/include/ulogd/hash.h
@@ -34,7 +34,7 @@ void hashtable_destroy(struct hashtable *h);
 int hashtable_hash(const struct hashtable *table, const void *data);
 struct hashtable_node *hashtable_find(const struct hashtable *table, const void *data, int id);
 int hashtable_add(struct hashtable *table, struct hashtable_node *n, int id);
-void hashtable_del(struct hashtable *table, struct hashtable_node *node);
+void hashtable_delete(struct hashtable *table, struct hashtable_node *node);
 int hashtable_flush(struct hashtable *table);
 int hashtable_iterate(struct hashtable *table, void *data,
                      int (*iterate)(void *data, void *n));
diff --git a/input/flow/ulogd_inpflow_NFCT.c b/input/flow/ulogd_inpflow_NFCT.c
index 899b7e3..38baf05 100644
--- a/input/flow/ulogd_inpflow_NFCT.c
+++ b/input/flow/ulogd_inpflow_NFCT.c
@@ -702,7 +702,7 @@ event_handler_hashtable(enum nf_conntrack_msg_type type,
                if (ts) {
                        set_timestamp_from_ct(ts, ct, STOP);
                        do_propagate_ct(upi, ct, type, ts);
-                       hashtable_del(cpi->ct_active, &ts->hashnode);
+                       hashtable_delete(cpi->ct_active, &ts->hashnode);
                        nfct_destroy(ts->ct);
                        free(ts);
                } else {
@@ -886,7 +886,7 @@ static int do_purge(void *data1, void *data2)
        ret = nfct_query(cpi->pgh, NFCT_Q_GET, ts->ct);
        if (ret == -1 && errno == ENOENT) {
                do_propagate_ct(upi, ts->ct, NFCT_T_DESTROY, ts);
-               hashtable_del(cpi->ct_active, &ts->hashnode);
+               hashtable_delete(cpi->ct_active, &ts->hashnode);
                nfct_destroy(ts->ct);
                free(ts);
        }
diff --git a/src/hash.c b/src/hash.c
index 1d99130..8fd98a1 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -91,7 +91,7 @@ int hashtable_add(struct hashtable *table, struct hashtable_node *n, int id)
        return 0;
 }

-void hashtable_del(struct hashtable *table, struct hashtable_node *n)
+void hashtable_delete(struct hashtable *table, struct hashtable_node *n)
 {
        llist_del(&n->head);
        table->count--;
--
2.34.1

________________________________________
ë³´ë?¸ ì?¬ë??: 조í??ì??/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP <hongsik.jo@xxxxxxx>
ë³´ë?¸ ë? ì§?: 2025ë?? 1ì?? 14ì?¼ í??ì??ì?¼ ì?¤í?? 2:00
ë°?ë?? ì?¬ë??: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
참조: netfilter-devel@xxxxxxxxxxxxxxx <netfilter-devel@xxxxxxxxxxxxxxx>; ì??ì??ì?­/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP <loth.son@xxxxxxx>; ë?¨ì ?주/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP <jungjoo.nahm@xxxxxxx>; ì ?ì?¬ì?¤/Task Leader/SW Platform(ì?°)ì? í??Platformê°?ë°?ì?¤ ì??ì?¤í??SW Task <jaeyoon.jung@xxxxxxx>; ì¡°í??ì??/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP <hongsik.jo@xxxxxxx>
�목: Re: Symbol Collision between ulogd and jansson
 
Here is the result of finding symbols in ulogd and libjansson.

$ nm -D libjansson.so | grep hashtable_del
0000000000005b50 T hashtable_del@@JANSSON_4

$ nm ulogd | grep hashtable_del
0000000000007704 T hashtable_del

We did not build it as a static library.
Like you mentioned, I also do not know the exact reason why a SEGV occurs in this case.
However, I have confirmed through sources like GPT that symbol collisions can occur in such situations (the possibility of symbol collisions due to the loading order of libraries).

Answers of GPT:
Therefore, even if a symbol version like hashtable_del@@JANSSON_4 exists, if a symbol with the same name is defined in another library, a symbol collision can still occur.
In such cases, which symbol gets called will depend on factors such as library load order, version information, and environment variable settings.

Anyway, I'll update the patch (including Signed-off-by: ) in next reply to divide the content.

________________________________________
ë³´ë?¸ ì?¬ë??: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
ë³´ë?¸ ë? ì§?: 2025ë?? 1ì?? 14ì?¼ í??ì??ì?¼ ì?¤ì ? 7:23
ë°?ë?? ì?¬ë??: 조í??ì??/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP <hongsik.jo@xxxxxxx>
참조: netfilter-devel@xxxxxxxxxxxxxxx <netfilter-devel@xxxxxxxxxxxxxxx>; ì??ì??ì?­/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP <loth.son@xxxxxxx>; ë?¨ì ?주/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP <jungjoo.nahm@xxxxxxx>; ì ?ì?¬ì?¤/Task Leader/SW Platform(ì?°)ì? í??Platformê°?ë°?ì?¤ ì??ì?¤í??SW Task <jaeyoon.jung@xxxxxxx>
�목: Re: Symbol Collision between ulogd and jansson
 
Hi,

On Mon, Jan 13, 2025 at 06:41:19AM +0000, ì¡°í??ì??/ì±?ì??ì?°êµ¬ì??/SW Securityê°?ë°?ì?¤ SW Security TP wrote:
> The issue I would like to bring to your attention is as follows: We
> are using the JSON feature in the PACKAGECONFIG of ulogd, and we
> have discovered that both ulogd and jansson have methods with the
> same name, which can lead to a symbol reference error resulting in a
> segmentation fault.  The method in question is hashtable_del().
> Based on our backtrace analysis, it appears that when ulogd's
> hashtable_del() is executed instead of jansson's hashtable_del(), it
> leads to a segmentation fault (SEGV).
> To avoid this symbol collision, I modified ulogd's hashtable_del()
> to hashtable_delete(), and I have confirmed that this resolves the
> issue.

$ nm -D libjansson.so.4 | grep hashtable_del
$

Are you building a static binary? Otherwise, I don't see how the clash
is going on.

I am fine with this patch, would you submit it using git format-patch
and including Signed-off-by:?

Thanks.




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux