Received: by 10.192.165.156 with SMTP id m28csp493696imm; Wed, 11 Apr 2018 02:34:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx497b4qICQn8EJteLunesHjzL0RHpRcCfyJfzx9QwD+a//v+zsYLDQp6JC46Tzn7gDEEUElr X-Received: by 2002:a17:902:6709:: with SMTP id f9-v6mr4328514plk.159.1523439261789; Wed, 11 Apr 2018 02:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523439261; cv=none; d=google.com; s=arc-20160816; b=UEKr+16l9jJMUmtyT65VhYeDI7/B6Vhf4U1Gc3aavF1zafLhj/QK1azzktO+0bm/0F YKlrkfG6pf6rFqKv37rrQAbYpNKXjjZVoxA+IHeW+LWODiI+atSBCJGLOudVKaUQwfwI HbbNd7yyQI4ggnoVNdQdCqkiU0XDsR3XSvd6X+f9XBoM3OwLCSSbXMomI65pvqvcq5sX vLylEM/eBBDwz1R1O5/AW1sKgznouwUQSXLrHW+SSeHJMEGtBkFu5+tTrp5mvwbiJBj8 tk2cIUZRonQOChuSm3oE5GqKI+Kx3MgRs5EvJtEnXbz8koBqYTHYD7dCvM87/IIrHa1A p02A== 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 :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=JMyg+g+e/xDEd1ITBpFFi+zViGF6aSK6YYDQnlaZSZY=; b=pa0ffaYLqXJGybHAMEnhn3EmGfcaOjno7Vs109ktemPM8tvqoESjPhK0BQ16D4g2kk 5RS+zOzPidTWfKMyil1Rr0PoQjbrXCy/Wj1RNoGnGJTWqxLxlJbJMN7rmRwFkEChMYN1 K0CqmlrKqp7KINfcW11B0i0q1rNeYCNdgHiKG+8DSrghOuVm1AqTlW/Qt2r5RWo/tNNH Q77431wLwte+8YsZlMJTUa5fzSv08XfePrR+OgRy5BBmy8X7lpLbrbeZXsHwOWbAm36D 0cx2D1GvEhFzS3v8gTHcCYjxEzRwgmXQW1EfuHWTZDS+Epvg9+xValZ7vdJDoCHMvJsp UpNw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22-v6si775542plj.155.2018.04.11.02.33.45; Wed, 11 Apr 2018 02:34:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbeDKJaC (ORCPT + 99 others); Wed, 11 Apr 2018 05:30:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:33043 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbeDKJ36 (ORCPT ); Wed, 11 Apr 2018 05:29:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 00001ACED; Wed, 11 Apr 2018 09:29:56 +0000 (UTC) Date: Wed, 11 Apr 2018 11:29:56 +0200 (CEST) From: Miroslav Benes To: Petr Mladek cc: Jiri Kosina , Josh Poimboeuf , Joe Lawrence , Jessica Yu , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] livepatch: Initialize shadow variables safely by a custom callback In-Reply-To: <20180405122315.29065-2-pmladek@suse.com> Message-ID: References: <20180405122315.29065-1-pmladek@suse.com> <20180405122315.29065-2-pmladek@suse.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Apr 2018, Petr Mladek wrote: > The existing API allows to pass a sample data to initialize the shadow > data. It works well when the data are position independent. But it fails > miserably when we need to set a pointer to the shadow structure itself. > > Unfortunately, we might need to initialize the pointer surprisingly > often because of struct list_head. It is even worse because the list > might be hidden in other common structures, for example, struct mutex, > struct wait_queue_head. > > For example, this was needed to fix races in ALSA sequncer. It required s/sequncer/sequencer/ > to add mutex into struct snd_seq_client. See commit b3defb791b26ea06 > ("ALSA: seq: Make ioctls race-free") and commit d15d662e89fc667b9 > ("ALSA: seq: Fix racy pool initializations") > > This patch makes the API more safe. A custom constructor function and data > are passed to klp_shadow_*alloc() functions instead of the sample data. > > Note that ctor_data are not longer a template for shadow->data. It might s/not longer/no longer/ > point to any data that might be necessary when the constructor is called. Miroslav