Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp422554ybl; Tue, 28 Jan 2020 05:45:20 -0800 (PST) X-Google-Smtp-Source: APXvYqyBd3oZGQog9urIrCLPjiePM5G9GJVb3Zfn28+4ml+XtEEOPQW1Vyh0A4899Eby/0ZuZSTe X-Received: by 2002:a05:6808:907:: with SMTP id w7mr2853758oih.91.1580219120877; Tue, 28 Jan 2020 05:45:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580219120; cv=none; d=google.com; s=arc-20160816; b=ACdx4TXZQM5UNGX+wL2KXV3IQEuDX9r3bPus8BX9Yx3PRAdux893xnbuOo6LL9KLgG oXat4fmj6VTOCNWJT32+IPBxfiDnHHiKCC2nE2iKKTuHtRz20eLcquUqqwnpkzUT6msE 2L74ZIPnB6zP7wx7SUM+y0berX2b08inhf0U/vQK+upsN1UHI77QxDxLC34IsdLY7SSD V1jJKaconU4BlFz3piQrs+iZsF1j35D2ZZGIPW4GeiQ+v/HqFyJG2Z92yZ1cEtYXw3KX 763wha2mqygDE8551t5/SRMbFc73Bwg6img8xFfIEDsgeJt0LfFzuRrVKjAR4STSYD9y Z3CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iX5+dNiDCHZNjF1pHsSxrGTH633M7MeaVhdvtFsHS0U=; b=azkOaNEb/r+k3uZENPe0Dovr55Fx9nW/TKi4CgnDxqyWH23VJgRv9Z8prHpzZFWCus ZsACJp8Qirqymj7tqf0+Ncnn0LKNbdK54GHZD850JbZesMFMNdOJUcx/24Lm9rIgQ/TJ rMo3EpQvQALT9BMKGf4KM+18dhMlNbSbHDCnA91vCH77ROrwrFpUWcUFf407MTaqBNte bISDVLgH/74DG4bG8EV5otNibtFx4zUie06JlCnkC9ogg7bSZZ1NQPvuc3hlNrrYiZFA QB+9Uicw0W5ztNcGo5HBHFZZg9A1hZgZ0nE9tnK/FfojFh/+WrrJ5OOH3dZiMXApYl5S EIvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WU7A92AH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u191si5244087oia.86.2020.01.28.05.45.07; Tue, 28 Jan 2020 05:45:20 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=WU7A92AH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726243AbgA1Nny (ORCPT + 99 others); Tue, 28 Jan 2020 08:43:54 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49307 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725997AbgA1Nny (ORCPT ); Tue, 28 Jan 2020 08:43:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580219033; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iX5+dNiDCHZNjF1pHsSxrGTH633M7MeaVhdvtFsHS0U=; b=WU7A92AHh79YTbJMKXbHCyWwAmmIt8+JHYlC3GS9MCCZF6TtAchrSrABRMTAYhFuZ7dYf6 a6+8AfNCAjQmU4S8AcKABf8CIHcpVTGyOYzGHztnlngjpX1E9WpHWAekfxU+Q6hTsfgxdA Sb9RfzBqfDd+GsH3Lxvpf69yWz83ndg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-Z_wc_W5FMwixynomvgh4KQ-1; Tue, 28 Jan 2020 08:43:49 -0500 X-MC-Unique: Z_wc_W5FMwixynomvgh4KQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 05EFE1800D41; Tue, 28 Jan 2020 13:43:45 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.70]) by smtp.corp.redhat.com (Postfix) with SMTP id 7881819C58; Tue, 28 Jan 2020 13:43:39 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 28 Jan 2020 14:43:43 +0100 (CET) Date: Tue, 28 Jan 2020 14:43:37 +0100 From: Oleg Nesterov To: Alexey Gladkov Cc: LKML , Kernel Hardening , Linux API , Linux FS Devel , Linux Security Module , Akinobu Mita , Alexander Viro , Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Daniel Micay , Djalal Harouni , "Dmitry V . Levin" , "Eric W . Biederman" , Greg Kroah-Hartman , Ingo Molnar , "J . Bruce Fields" , Jeff Layton , Jonathan Corbet , Kees Cook , Linus Torvalds , Solar Designer , Stephen Rothwell Subject: Re: [PATCH v7 02/11] proc: add proc_fs_info struct to store proc information Message-ID: <20200128134337.GC17943@redhat.com> References: <20200125130541.450409-1-gladkov.alexey@gmail.com> <20200125130541.450409-3-gladkov.alexey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200125130541.450409-3-gladkov.alexey@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/25, Alexey Gladkov wrote: > > static int proc_init_fs_context(struct fs_context *fc) > { > struct proc_fs_context *ctx; > + struct pid_namespace *pid_ns; > > ctx = kzalloc(sizeof(struct proc_fs_context), GFP_KERNEL); > if (!ctx) > return -ENOMEM; > > - ctx->pid_ns = get_pid_ns(task_active_pid_ns(current)); > + pid_ns = get_pid_ns(task_active_pid_ns(current)); > + > + if (!pid_ns->proc_mnt) { > + ctx->fs_info = kzalloc(sizeof(struct proc_fs_info), GFP_KERNEL); > + if (!ctx->fs_info) { > + kfree(ctx); > + return -ENOMEM; > + } > + ctx->fs_info->pid_ns = pid_ns; > + } else { > + ctx->fs_info = proc_sb_info(pid_ns->proc_mnt->mnt_sb); > + } > + it seems that this code lacks put_pid_ns() if pid_ns->proc_mnt != NULL or if kzalloc() fails? Or, better, pid_ns = task_active_pid_ns(); if (!pid_ns->proc_mnt) { ctx->fs_info = kzalloc(); ... ctx->fs_info->pid_ns = get_pid_ns(pid_ns); } No? Oleg.