Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2616520ybb; Sat, 30 Mar 2019 09:17:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRBpSIqkIOSuj9n1JUgNX9cVuMILDAFqs4Adn846oNXjxa4BGina+3tJ965aqA1+wNcULE X-Received: by 2002:a65:65c4:: with SMTP id y4mr51676758pgv.305.1553962676978; Sat, 30 Mar 2019 09:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553962676; cv=none; d=google.com; s=arc-20160816; b=BCxhiBfWN1gffOxiT4ZmCKUkcWcXBD7DZzPH0a5kjQMggUW9+y2v4Ho4qfUXjpSnt+ BJDMTui+EtZoGLZ8sRPjfEC69sPg6zwm0G9SvZIZ8njPDdHq4f0xPUa9P0twvcQ4GFmZ ZUA22WgCsFxDKjzQ7DQjxxB6vXUXwGgr2Z3oBWyVnoaOfCHuD9qRdczSllZlX0as6wKW Fl4+ZbIfV3m72/W5IByPxlWUHYhqSKeC1HM7hNr3iqd2DnvsPPcyZ0KYsgzeeDa2FC8H vqOP3+CN591mG5wnOc0RQP3vqs5H/47E/5AxrOkMpJ2+e6Ef+TYrM82ojxY60fw/P1FZ G1Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dmarc-filter:dkim-signature :dkim-signature; bh=AC9/ElBcwmpy0Qg6QgLGJMvqpbHFVOIBjBjaRsMpW7A=; b=iZG6/7CEzucT6wK/s8BmyRNMIyYU0hrA0MkImiK28nWYdyuofptwUzhoCOWF5MWI0P E84FE1ZWTLPLSNtVKI2+mDz/I+Xlffwe70tC2B++tg3MxYmI/totbxELtPSc0ScGjbYQ Qg3YoPwoX2VrjVf3HHmLTfeOxpkdcGI64/QU+9rxmmcBH3hjfzjIe3kWUUf3PC8Ab/4K zfre5+B5ZU1T15iy2wyTQ+rDsFy2LdkTYoZSeUsOjOm7bnZz7nxLfmbSzfNOl/pOGfb9 VfC5/34ePPzXmlhdhegEa6L4qkTsgjW0L2hDC2x+pPjvS4aEmkISV3J8Qhuj2dnLSNHa Yjmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KRDx8SkP; dkim=pass header.i=@codeaurora.org header.s=default header.b=Hobcm8bl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23si4714924pfd.182.2019.03.30.09.17.41; Sat, 30 Mar 2019 09:17:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KRDx8SkP; dkim=pass header.i=@codeaurora.org header.s=default header.b=Hobcm8bl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730971AbfC3QRD (ORCPT + 99 others); Sat, 30 Mar 2019 12:17:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34482 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730849AbfC3QRC (ORCPT ); Sat, 30 Mar 2019 12:17:02 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4D43C60790; Sat, 30 Mar 2019 16:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553962621; bh=IYH95s5Yr5FuY1fNL4ZN8mwKASSE6Monn3hW1rzsmPg=; h=Subject:To:References:From:Date:In-Reply-To:From; b=KRDx8SkPQZDAQaBSkyTyLhYIWiW7YcC2s23uREKSSiul5WJaMe7LyYayMqDdKp69C tedwn8Sb85SJaPWDgGgbKMpvftVugw0ixGeRfzKQGx+TPKlPwX8ZOw7y80y0U7uPy0 s9xR71t6S/fAF2knORPHYY3QpYGVNgyH1jhNEwRE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from [10.79.166.167] (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mojha@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 379956072E; Sat, 30 Mar 2019 16:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553962620; bh=IYH95s5Yr5FuY1fNL4ZN8mwKASSE6Monn3hW1rzsmPg=; h=Subject:To:References:From:Date:In-Reply-To:From; b=Hobcm8blHmMkV8p23wIRcvFHx1YF/rnRCGQS/aA08+eKuOjomOQsAuED21DRmVdai wJ8W3xfFqg1kcsY+wORTBa6Gqa2W/nyR+ev2tZV57LFu/U6NAM7F8NdhB10nR7+UYm Vo4s33QSx6aOKcZbkkKSFid+ECbFdJsyijvf/ht8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 379956072E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mojha@codeaurora.org Subject: Re: [PATCH] fs/binfmt_elf.c: fix GPF when dereferencing invalid interpreter To: Nikitas Angelinas , Alexander Viro , Alexey Dobriyan , Andrew Morton , Linus Torvalds , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, syzbot+0d1fcd7268b21baced4a@syzkaller.appspotmail.com References: <20190330140032.GA1527@vostro> From: Mukesh Ojha Message-ID: <47235084-9333-1096-e411-8d25ec120f30@codeaurora.org> Date: Sat, 30 Mar 2019 21:46:53 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190330140032.GA1527@vostro> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/30/2019 7:30 PM, Nikitas Angelinas wrote: > Syzkaller found an issue where an invalid interpreter pointer is > dereferenced in load_elf_binary()->allow_write_access() please mention here on failure path insideĀ  allow_write_access as there are two path it gets called. > . Fix this by > jumping to a different label in the cleanup path. > > This patch applies against the latest linux-next tree. I have not tested > that the patch addresses the issue, but it should, imho. This should not be written in commit text body. please fix. > > Signed-off-by: Nikitas Angelinas > Reported-by: syzbot+0d1fcd7268b21baced4a@syzkaller.appspotmail.com > Fixes: 44e63c4a0263 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP") > --- Patch looks valid to me as interpreter may be NULL and it later get tried to dereferencing inside allow_write_access under label out_free_dentry. Reviewed-by: Mukesh Ojha Cheers, -Mukesh > fs/binfmt_elf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c > index 51bc894..09e76b2 100644 > --- a/fs/binfmt_elf.c > +++ b/fs/binfmt_elf.c > @@ -777,7 +777,7 @@ static int load_elf_binary(struct linux_binprm *bprm) > kfree(elf_interpreter); > retval = PTR_ERR(interpreter); > if (IS_ERR(interpreter)) > - goto out_free_dentry; > + goto out_free_ph; > > /* > * If the binary is not readable then enforce