Received: by 10.192.165.156 with SMTP id m28csp1038648imm; Mon, 16 Apr 2018 13:00:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Tz2BR778hCHJqEVnahjNUMl+BfDJ0Khc9iXS414SoetXlgkDZ0HW/dY1jHUgX9Z6o2Bbu X-Received: by 10.167.131.217 with SMTP id j25mr22556195pfn.5.1523908840859; Mon, 16 Apr 2018 13:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523908840; cv=none; d=google.com; s=arc-20160816; b=k2Ziuo6Cx5zi8rs+Bq1pA1pxtNmFld+9K5Q8n7Z/R9d9c7pl+c7J/lVMRB1NfX5n/k vkDj9oeWfOS2MMWL8T2zDvdcymw6Rlp1ZYuoAp7S4IHS/HN42hfnokT5X/K+WdWZgtHG ShMBu40Gg2mnrLLjn1BPWlTuF9XnQj5oNNTGKi1pOS4lbgXZ1ATSG0KOdcI898Riw6XP xS5W4jjsMcf3LHveOQMa2NFX5OPMP9PK2EhdbAHZvdYuJrv0Syx00ZLySQ11IlHc46PS ll9ySxSCCVH4DB/hG7eHiWF14MTmz1bCdOrDmzqdZfRUYiMiqWf/5u4RGmx8TVgFf+lL 4dlQ== 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:arc-authentication-results; bh=65aYVe5BlkCnT7G/GOz67hbnzg8wDksJogbLSDUynMs=; b=JBEYdzjEdISq/1ACA0zDShzoTfV8NHZ4RLxANQhoVjr7HuxY6HckbeT+V6TK58O1JX Qp3188cRCV7ewd5bbkYUSZYqJoeeOECPfApW3NlpxSW6fDfA1Cur5HAGN1LQNNeEmPro YyRE2mPS1ShG6hDCwKQSIlbqER3zCLabhFV1D8NzTVp+nBWfn/JXnucr/iVYRJmnx8kC htJR4pCgH9Tu21+OOHmfO9vEU7gr5T0gqCSSRELa1WJs2Se3BEyC6J8K+z3MYEWld7wK laeA/kZGaiCXIjhDXluKMdChB9yKFISg+bYuunqrA8ijd9KEp6Fkm4BiuZgBQyQCT8TA GPgA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 q12si3811085pgc.614.2018.04.16.13.00.26; Mon, 16 Apr 2018 13:00:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753537AbeDPT5p (ORCPT + 99 others); Mon, 16 Apr 2018 15:57:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47172 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753269AbeDPT5n (ORCPT ); Mon, 16 Apr 2018 15:57:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FF2176FB9; Mon, 16 Apr 2018 19:57:43 +0000 (UTC) Received: from treble (ovpn-121-163.rdu2.redhat.com [10.10.121.163]) by smtp.corp.redhat.com (Postfix) with SMTP id F04762166BAD; Mon, 16 Apr 2018 19:57:42 +0000 (UTC) Date: Mon, 16 Apr 2018 14:57:42 -0500 From: Josh Poimboeuf To: Petr Mladek Cc: Jiri Kosina , Miroslav Benes , Joe Lawrence , Jessica Yu , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 0/2] livepatch: Allocate and free shadow variables more safely Message-ID: <20180416195742.n2zsthypbx7c4yzn@treble> References: <20180416113647.25288-1-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180416113647.25288-1-pmladek@suse.com> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Apr 2018 19:57:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Apr 2018 19:57:43 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jpoimboe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 16, 2018 at 01:36:45PM +0200, Petr Mladek wrote: > Nikolai started to use shadow variables and found that list_head > is not initialized correctly using the existing API. > > The problem is that LIST_HEAD_INIT() set pointers to itself. > klp_shadow_alloc() then copies these pointers to another location. > > It would be possible to solve this by a late initialization. But > this does not work well with klp_shadow_get_or_alloc(). Also this > behavior is error prone. Note that list_head might be hidden in > another structure, for example mutex. > > I suggest to change the API and allow to initialize the shadow > variables using a custom callback. I think that we have already > talked about this but we decided to go the easier way. It seems > that it was a bad decision. > > I send also patch that add a symmetric callback to the klp_shadow_free() > functions. It might be handy especially for klp_shadow_free_all(). > > > Changes against v2: > > + Use pr_err() instead of WARN() when ctor() fails [Josh] > + Some typos [Mirek] > > > Changes against v1: > > + Rename init/free callbacks to ctor/dtor > + Misc update of comments and commit messages > + Fix sizeof() in the sample code in shadow-vars.txt Acked-by: Josh Poimboeuf -- Josh