diff mbox series

smackfs: use __GFP_NOFAIL for smk_cipso_doi()

Message ID 96c25c43-a419-bc5e-839a-7ff484b1c22a@i-love.sakura.ne.jp (mailing list archive)
State New, archived
Headers show
Series smackfs: use __GFP_NOFAIL for smk_cipso_doi() | expand

Commit Message

Tetsuo Handa Oct. 19, 2021, 11:54 a.m. UTC
syzbot is reporting kernel panic at smk_cipso_doi() due to memory
allocation fault injection [1]. The reason for need to use panic() was
not explained. But since no fix was proposed for 18 months, for now
let's use __GFP_NOFAIL for utilizing syzbot resource on other bugs.

Link: https://syzkaller.appspot.com/bug?extid=89731ccb6fec15ce1c22 [1]
Reported-by: syzbot <syzbot+89731ccb6fec15ce1c22@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 security/smack/smackfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Casey Schaufler Oct. 22, 2021, 6:03 p.m. UTC | #1
On 10/19/2021 4:54 AM, Tetsuo Handa wrote:
> syzbot is reporting kernel panic at smk_cipso_doi() due to memory
> allocation fault injection [1]. The reason for need to use panic() was
> not explained. But since no fix was proposed for 18 months, for now
> let's use __GFP_NOFAIL for utilizing syzbot resource on other bugs.
>
> Link: https://syzkaller.appspot.com/bug?extid=89731ccb6fec15ce1c22 [1]
> Reported-by: syzbot <syzbot+89731ccb6fec15ce1c22@syzkaller.appspotmail.com>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

Added to smack-next. Thank you.

> ---
>   security/smack/smackfs.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index 83b90442f963..3e6a198dd3dd 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -693,9 +693,7 @@ static void smk_cipso_doi(void)
>   		printk(KERN_WARNING "%s:%d remove rc = %d\n",
>   		       __func__, __LINE__, rc);
>   
> -	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
> -	if (doip == NULL)
> -		panic("smack:  Failed to initialize cipso DOI.\n");
> +	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL | __GFP_NOFAIL);
>   	doip->map.std = NULL;
>   	doip->doi = smk_cipso_doi_value;
>   	doip->type = CIPSO_V4_MAP_PASS;
diff mbox series

Patch

diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 83b90442f963..3e6a198dd3dd 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -693,9 +693,7 @@  static void smk_cipso_doi(void)
 		printk(KERN_WARNING "%s:%d remove rc = %d\n",
 		       __func__, __LINE__, rc);
 
-	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
-	if (doip == NULL)
-		panic("smack:  Failed to initialize cipso DOI.\n");
+	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL | __GFP_NOFAIL);
 	doip->map.std = NULL;
 	doip->doi = smk_cipso_doi_value;
 	doip->type = CIPSO_V4_MAP_PASS;