Received: by 10.213.65.68 with SMTP id h4csp1203035imn; Wed, 14 Mar 2018 12:45:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELsMHHk3ZIIFA7X+FdqgGPhOs2Z6MLd/x1rnzj+lDPO+6NiGYfrOEmzs2++GlE/Ow3e1S8Dy X-Received: by 10.98.219.129 with SMTP id f123mr5402390pfg.195.1521056725852; Wed, 14 Mar 2018 12:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521056725; cv=none; d=google.com; s=arc-20160816; b=r5Xpg5oiYATRPsP/h6E29dr8OqNx83LLFdkloDqOjw2gx8m41MVPapvmlOP7p7H3gI HYHCmDYeC+gfxWpGc0erU1fCnOVkyqw1f+kTQoKl80Va766hgB2/GB+9XwmSVh2ToMIP G6s8lyXJipi8AYjmYSPllM1AhQZarWXFcwloWh7mqOXnBI4QB9+4sMoHEz8JwMVHReg+ cvLr0mrFB4ppueAq8aoTsrpIa/qb0gfxuzjvjMC22wG4b72Y9g3iVTCzJfNaSWgTOwKL ZBoDkUiq4eY5cd19jzOsS3wqzxmvPzfdBu2KK5+POFr5e3X9rZPUCwk9NKPmcDEKkSy2 r7pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=fKWlXmA37Ese2J7LOXMp38zwIBc/K2/c52JajCmrOyI=; b=gai/69sh1cKR/CNNSgh+GNn2KyPOAxmmAUKymfiVixU1n2cVSlw8z4WIXLDGhYMt/+ ugQ6r8cKwDLINoFCbVwaREcotKe55v0w+KjPWxWPA5Wja2c64/Vkvd/BsUFI9hbDQ0zD sLCxygIC/MxYfmEk/yugC3DspoNRwyRuMKtfD07pXfEBqJT7ADVA82knW/avil8ZFgTY YjTqupoTV1yAvlGmnDnBj2KSNXykHFh6n7S13QrJFwIhmtVs1jSIH3iD10zzzZJkBvub edfjr/w7h61CcDzQdSCv2UUW6Kfa3d56m4nUHmsQapbHiEKzNn8TKgCV+5sba4N5ZK8m jsSg== 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 v17si2512443pfe.186.2018.03.14.12.45.10; Wed, 14 Mar 2018 12:45:25 -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 S1751754AbeCNTnE (ORCPT + 99 others); Wed, 14 Mar 2018 15:43:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38356 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751289AbeCNTnD (ORCPT ); Wed, 14 Mar 2018 15:43:03 -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 7EE0F8151D49; Wed, 14 Mar 2018 19:43:02 +0000 (UTC) Received: from jlaw-desktop.bos.csb (ovpn-125-196.rdu2.redhat.com [10.10.125.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EBE72166BDA; Wed, 14 Mar 2018 19:43:02 +0000 (UTC) Subject: Re: [PATCH 1/2] livepatch: Initialize shadow variables by init function safely To: Josh Poimboeuf , Petr Mladek Cc: Jiri Kosina , Miroslav Benes , Jessica Yu , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180313155448.1998-1-pmladek@suse.com> <20180313155448.1998-2-pmladek@suse.com> <20180314192857.yfdk2uwn4okuzlfh@treble> From: Joe Lawrence Organization: Red Hat Message-ID: Date: Wed, 14 Mar 2018 15:43:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20180314192857.yfdk2uwn4okuzlfh@treble> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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.8]); Wed, 14 Mar 2018 19:43:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Mar 2018 19:43:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'joe.lawrence@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/14/2018 03:28 PM, Josh Poimboeuf wrote: > On Tue, Mar 13, 2018 at 04:54:47PM +0100, Petr Mladek wrote: > >> diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h >> index 4754f01c1abb..fc7c64ce0992 100644 >> --- a/include/linux/livepatch.h >> +++ b/include/linux/livepatch.h >> @@ -186,11 +186,20 @@ static inline bool klp_have_reliable_stack(void) >> IS_ENABLED(CONFIG_HAVE_RELIABLE_STACKTRACE); >> } >> >> +struct klp_shadow; > > Why is this forward struct declaration needed? Compiles ok w/o it, so shouldn't be needed. >> @@ -150,6 +145,23 @@ static void *__klp_shadow_get_or_alloc(void *obj, unsigned long id, void *data, >> goto exists; >> } >> >> + new_shadow->obj = obj; >> + new_shadow->id = id; >> + >> + if (init_func) { >> + int err; >> + >> + err = init_func(obj, new_shadow->data, init_data); > > Am I hallucinating, or will new_shadow->data always be NULL? How did it > even work before? > struct klp_shadow { struct hlist_node node; struct rcu_head rcu_head; void *obj; unsigned long id; char data[]; << not a pointer }; In the past, this function would allocate the klp_shadow struct size accordingly, then memcpy in its data contents. This patch pushes the responsibility of data initialization out to the init_func(). -- Joe