Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3284683ybk; Tue, 19 May 2020 00:18:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSFFoDErjoOtw2Cyoq5iL9FiYgwKVGJTcmI2lUcFOaHT5dDOcI4hKmVtSvzhvdSW2Lq6+u X-Received: by 2002:a50:ed84:: with SMTP id h4mr8437537edr.225.1589872739695; Tue, 19 May 2020 00:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589872739; cv=none; d=google.com; s=arc-20160816; b=bQMe5yRpjIabpjNuulxyed6iU8DR5xoKxQOT1NkIt+F4p9tdUXl9dgiq1+t9iZp0as EzQYEQlYgIdmoky7Gz6G1JFNkoGFwco7T+L/Cok1WH6cwecKrAbxaxyyR5Pe0Oyzvrmz poilVDah9MZBWeBkbaaLDYZEGUQobzkg8ocXnGolvyT/h35mNfEsFNFeylCTJWUa4+1j 0ZvNdqWi65+GY6j6QW9FncTijNsQqXAyCn7ZjNVYpbr+MHgzyKfOGmwH2FYTNSd7qu5I ezDlCnGIi2YQ4MJjbH4Lqaou9nxsAFd/WAmrTaPTOA8CxJsEaR2y8RmqaRW+uUyKfdR5 U6JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:to:from:date; bh=yg9jSDyiLrht7Q4TMv93+ljnq26lxfqA/4nDnmhPPEE=; b=hzWpkZcfR1LqwF9J7oUVaUWWG7Qd98zfu+2Bb6XTZjYu/11Iz4BaggJ9iD1Pev0DLl VPqgHXrjIjuoFflFgjX5bF9tCJHpHgoPFDLUJF0TKc1IRLl8D/eOVWUPI8XqRK5p7+UT MKzVyNEC6aZ7WtuHfbbdYVqaYpbX5iF9oLv2vLDFMW84L4aDNzkzyV2KYmvcLkBa8ztI AfNdQ4yWFceyAfBSpiU4P0NsKTMXUNCO2fCMZ/tmu4gFxQj1gp5EfAX9RnrIVPNL3YGI nRoWyLpeaio6kJnKMDFodbo++3LqDzpi4G4k+HTKKyMBTjbcAGXvyZt3q1iiHZKgWc4l T+NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si7078624ejx.339.2020.05.19.00.18.36; Tue, 19 May 2020 00:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728451AbgESHQz (ORCPT + 99 others); Tue, 19 May 2020 03:16:55 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:57933 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbgESHQz (ORCPT ); Tue, 19 May 2020 03:16:55 -0400 X-Originating-IP: 78.194.159.98 Received: from clip-os.org (unknown [78.194.159.98]) (Authenticated sender: thibaut.sautereau@clip-os.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id DE5FF40006; Tue, 19 May 2020 07:16:52 +0000 (UTC) Date: Tue, 19 May 2020 09:16:52 +0200 From: Thibaut Sautereau To: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: NULL pointer dereference in coredump code Message-ID: <20200519071652.GA924@clip-os.org> References: <20200330083158.GA21845@clip-os.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200330083158.GA21845@clip-os.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 30, 2020 at 10:31:59AM +0200, Thibaut Sautereau wrote: > I hit a kernel NULL pointer dereference caused by the following call chain: > > do_coredump() > file_start_write(cprm.file) # cprm.file is NULL > file_inode(file) # NULL ptr deref > > The `ispipe` path is followed in do_coredump(), and: > # cat /proc/sys/kernel/core_pattern > |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h > > It seems that cprm.file can be NULL after the call to the usermode > helper, especially when setting CONFIG_STATIC_USERMODEHELPER=y and > CONFIG_STATIC_USERMODEHELPER_PATH="", which is the case for me. > > One may say it's a strange combination of configuration options but I > think it should not crash the kernel anyway. As I don't know much about > coredumps in general and this code, I don't know what's the best way to > fix this issue in a clean and comprehensive way. > > I attached the patch I used to temporarily work around this issue, if > that can clarify anything. > > Thanks, For the record, this had previously been reported [1] and was eventually fixed by 3740d93e3790 ("coredump: fix crash when umh is disabled"). [1] https://bugzilla.kernel.org/show_bug.cgi?id=199795 -- Thibaut Sautereau CLIP OS developer