diff mbox series

smackfs: use netlbl_cfg_cipsov4_del() for deleting cipso_v4_doi

Message ID 3be0eeb1-c1d7-9809-ac27-e36fdb62074d@i-love.sakura.ne.jp (mailing list archive)
State New, archived
Headers show
Series smackfs: use netlbl_cfg_cipsov4_del() for deleting cipso_v4_doi | expand

Commit Message

Tetsuo Handa Oct. 19, 2021, 11:27 a.m. UTC
syzbot is reporting UAF at cipso_v4_doi_search() [1], for smk_cipso_doi()
is calling kfree() without removing from the cipso_v4_doi_list list after
netlbl_cfg_cipsov4_map_add() returned an error. We need to use
netlbl_cfg_cipsov4_del() in order to remove from the list and wait for
RCU grace period before kfree().

Link: https://syzkaller.appspot.com/bug?extid=93dba5b91f0fed312cbd [1]
Reported-by: syzbot <syzbot+93dba5b91f0fed312cbd@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: 6c2e8ac0953fccdd ("netlabel: Update kernel configuration API")
---
 security/smack/smackfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Casey Schaufler Oct. 22, 2021, 6:02 p.m. UTC | #1
On 10/19/2021 4:27 AM, Tetsuo Handa wrote:
> syzbot is reporting UAF at cipso_v4_doi_search() [1], for smk_cipso_doi()
> is calling kfree() without removing from the cipso_v4_doi_list list after
> netlbl_cfg_cipsov4_map_add() returned an error. We need to use
> netlbl_cfg_cipsov4_del() in order to remove from the list and wait for
> RCU grace period before kfree().
>
> Link: https://syzkaller.appspot.com/bug?extid=93dba5b91f0fed312cbd [1]
> Reported-by: syzbot <syzbot+93dba5b91f0fed312cbd@syzkaller.appspotmail.com>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Fixes: 6c2e8ac0953fccdd ("netlabel: Update kernel configuration API")

Added to smack-next. Thank you.

> ---
>   security/smack/smackfs.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index 3a75d2a8f517..83b90442f963 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -714,7 +714,7 @@ static void smk_cipso_doi(void)
>   	if (rc != 0) {
>   		printk(KERN_WARNING "%s:%d map add rc = %d\n",
>   		       __func__, __LINE__, rc);
> -		kfree(doip);
> +		netlbl_cfg_cipsov4_del(doip->doi, &nai);
>   		return;
>   	}
>   }
diff mbox series

Patch

diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 3a75d2a8f517..83b90442f963 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -714,7 +714,7 @@  static void smk_cipso_doi(void)
 	if (rc != 0) {
 		printk(KERN_WARNING "%s:%d map add rc = %d\n",
 		       __func__, __LINE__, rc);
-		kfree(doip);
+		netlbl_cfg_cipsov4_del(doip->doi, &nai);
 		return;
 	}
 }