Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2510736imm; Mon, 28 May 2018 09:26:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKQxkCrVCDxp2UUea9rk1cOsJttLyfRPfBPiZfre5GdnAGKmP7bSMR39zkZyxtPf+Q2EM1e X-Received: by 2002:a17:902:bf48:: with SMTP id u8-v6mr2686193pls.322.1527524814970; Mon, 28 May 2018 09:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524814; cv=none; d=google.com; s=arc-20160816; b=rZa1lIuqSzZ4uOxICZtrQdyVtPt2jboojlShef735zP/5KPP9MMQ7xjpmcIOdcv+hu UGoV8wVfWFOy2P5u5mPAAdXMC5rcwqNiVK93pfoSBFDe7FmrsMns72Prnn3F2bYxPiC8 KThTqR5qqUrLrNGaoTnOVTnqlYMGFHdP+55r+maowUqjKk0txcNWiDocHlkAuPd1GV32 9O7CT33HWYialaxo8SuqCmjfiV8h/AJinDk7MmMKOIz7y0cARLJRy9VoqrCDun/QJmcE yIJctgEqRL0uvUgyw5E3BNuCf+35S5yKBxkd6K/khYRduhMCp1oPOXRBA6VDVhPTnW5C I+iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=9H8EFIWjHa6J8c+rLHXlsiS0Aw1+owAePowTwH8yNOI=; b=RCKMDSj5G+HjJ5ez6tUprooBpWUFglTXE0q5vymOjl7+Q3VrVLitJfvwmT+pyrWOB7 6BZp75Mf4RMvf1dfRAWht7unrcMuh7TfH05YE9iyODK4tp4qDWZUqObl+W3Bxe3ZqQrC vGurhZ91zUH7s9N0WVEt/Xc+LSP+rob0Nl8a4pKts/55aTutJciJzZ7GpejMom5hplJ/ 6uampTh52gzoOnxnifaQPQGPHfdrPqoING2klbHu9DAj0niI+MfLSuq2OmH6+U3X3m8e m9wFkItyC0+2UV65Cg7kWVZKPGZ1ziMU96bQb0sV3jlf5wv6UC9ndT55gkYbHTI1LgdW iWNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TZo9W1zP; 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 p91-v6si30550042plb.457.2018.05.28.09.26.40; Mon, 28 May 2018 09:26:54 -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=@kernel.org header.s=default header.b=TZo9W1zP; 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 S936508AbeE1KKe (ORCPT + 99 others); Mon, 28 May 2018 06:10:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:58644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933629AbeE1KKa (ORCPT ); Mon, 28 May 2018 06:10:30 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3AC712086D; Mon, 28 May 2018 10:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502229; bh=z/vQ1n7dNu5q1BH+Qc8ktq2dAbKu9/XK7115Tj4rlTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TZo9W1zP70Sbaf6uANmf7+ubD5yH/jvAFexQnTw8YqYg69tbGAc14XmdLiyFfvHXW 8nSZJ3texAiqV4RTP2nav0EoWwkVoQiw39qCO6pylnBbv9qg8ydM4J7k1Cb8neR/rD IOlPwU4Zn8SZOD+CNQaqWoT0hIZEM8owtVtt2u2E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Danilo Krummrich , Kees Cook , Andrew Morton , "Luis R . Rodriguez" , "Eric W. Biederman" , Alexey Dobriyan , Linus Torvalds , Sasha Levin Subject: [PATCH 3.18 110/185] fs/proc/proc_sysctl.c: fix potential page fault while unregistering sysctl table Date: Mon, 28 May 2018 12:02:31 +0200 Message-Id: <20180528100101.091591758@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Danilo Krummrich [ Upstream commit a0b0d1c345d0317efe594df268feb5ccc99f651e ] proc_sys_link_fill_cache() does not take currently unregistering sysctl tables into account, which might result into a page fault in sysctl_follow_link() - add a check to fix it. This bug has been present since v3.4. Link: http://lkml.kernel.org/r/20180228013506.4915-1-danilokrummrich@dk-develop.de Fixes: 0e47c99d7fe25 ("sysctl: Replace root_list with links between sysctl_table_sets") Signed-off-by: Danilo Krummrich Acked-by: Kees Cook Reviewed-by: Andrew Morton Cc: "Luis R . Rodriguez" Cc: "Eric W. Biederman" Cc: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/proc/proc_sysctl.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -617,7 +617,10 @@ static bool proc_sys_link_fill_cache(str struct ctl_table *table) { bool ret = true; + head = sysctl_head_grab(head); + if (IS_ERR(head)) + return false; if (S_ISLNK(table->mode)) { /* It is not an error if we can not follow the link ignore it */