git: 653a437c0444 - main - accept_filter: Fix filter parameter handling

Mark Johnston markj at FreeBSD.org
Thu Mar 25 21:56:28 UTC 2021


The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=653a437c04440495cd8e7712c7cf39444f26f1ee

commit 653a437c04440495cd8e7712c7cf39444f26f1ee
Author:     Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-03-25 21:55:20 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-03-25 21:55:46 +0000

    accept_filter: Fix filter parameter handling
    
    For filters which implement accf_create, the setsockopt(2) handler
    caches the filter name in the socket, but it also incorrectly frees the
    buffer containing the copy, leaving a dangling pointer.  Note that no
    accept filters provided in the base system are susceptible to this, as
    they don't implement accf_create.
    
    Reported by:    Alexey Kulaev <alex.qart at gmail.com>
    Discussed with: emaste
    Security:       kernel use-after-free
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation
---
 sys/kern/uipc_accf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/kern/uipc_accf.c b/sys/kern/uipc_accf.c
index debf4b2deeb1..3ca64dd21e25 100644
--- a/sys/kern/uipc_accf.c
+++ b/sys/kern/uipc_accf.c
@@ -299,6 +299,7 @@ accept_filt_setopt(struct socket *so, struct sockopt *sopt)
 	so->sol_accept_filter = afp;
 	so->sol_accept_filter_arg = accept_filter_arg;
 	so->sol_accept_filter_str = accept_filter_str;
+	accept_filter_str = NULL;
 	so->so_options |= SO_ACCEPTFILTER;
 out:
 	SOCK_UNLOCK(so);


More information about the dev-commits-src-all mailing list