Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1540580

Summary: Radius service crashes with "Bad talloc magic value - unknown value" when using module sql rlm_sql
Product: Red Hat Enterprise Linux 7 Reporter: Welterlen Benoit <bwelterl>
Component: freeradiusAssignee: Alex Scheel <ascheel>
Status: CLOSED CURRENTRELEASE QA Contact: Jaroslav Aster <jaster>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.4CC: bwelterl, fkrska, nikolai.kondrashov, nkinder, pkis, toneata
Target Milestone: rcKeywords: Patch, Reproducer, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1551068 1551069 (view as bug list) Environment:
Last Closed: 2018-11-14 17:33:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1551068, 1551069    
Attachments:
Description Flags
Experimental fixed SRPM for test none

Description Welterlen Benoit 2018-01-31 12:59:19 UTC
Created attachment 1388946 [details]
Experimental fixed SRPM for test

Description of problem:
Radius service crashes with "Bad talloc magic value - unknown value" when using module sql rlm_sql because of a double free of a talloc.

Version-Release number of selected component (if applicable):
freeradius-3.0.13-8

How reproducible:
With 

Steps to Reproduce:
1.The crash happens when the radius receives an accounting packet and the sql query does not match to any existing row in the accounting table, i.e. there is not a Start entry in the accounting table.
In the code, the talloc struct is freed 2 times in the loop and the finish part.

Actual results:
crash with :
rlm_sql_mysql: Rows matched: 0  Changed: 0  Warnings: 0
(8) sql: SQL query returned: success
(8) sql: 0 record(s) updated
(8) sql: Trying next query...
(8) sql: Ignoring null query
Bad talloc magic value - unknown value

talloc abort: Bad talloc magic value - unknown value

Expected results:
no crash

Additional info:
Patch :
--- 1/src/modules/rlm_sql/rlm_sql.c     2018-01-31 10:11:36.000000000 +0100
+++ 2/src/modules/rlm_sql/rlm_sql.c     2018-01-31 10:11:50.000000000 +0100
@@ -1439,7 +1439,6 @@
                if (!*expanded) {
                        RDEBUG("Ignoring null query");
                        rcode = RLM_MODULE_NOOP;
-                       talloc_free(expanded);

                        goto finish;
                }

Comment 3 Nikolai Kondrashov 2018-02-01 13:51:13 UTC
Thank you for the report and the fix, Welterlen! Have you talked to upstream about this issue, have they verified the fix is correct to their understanding?

Comment 6 Nikolai Kondrashov 2018-02-13 15:05:31 UTC
Fix appears correct and is submitted upstream: https://github.com/FreeRADIUS/freeradius-server/pull/2180

Thank you, Benoit!

Comment 7 Nikolai Kondrashov 2018-02-13 15:11:23 UTC
Fix merged upstream.

Comment 15 Jaroslav Aster 2018-04-16 10:16:38 UTC
Hi all,

unfortunately I wasn't able to reproduce this bug. I configured radiusd to use mariadb and sent some accounting request via radclient, playing with database and so on, but nothing happen.

Maybe there is some non-standard sql query in /etc/raddb/mods-config/sql/main/mysql/queries.conf?