Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6158964imu; Mon, 21 Jan 2019 04:16:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN4YmLN9ih3aHbkPipMXS/1YzlggDG3u8UtFzqJVGGu595pyrwzVLkGhdiC4bjONTgtNlaCV X-Received: by 2002:a63:6bc1:: with SMTP id g184mr28448603pgc.25.1548072976171; Mon, 21 Jan 2019 04:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548072976; cv=none; d=google.com; s=arc-20160816; b=j0L6L3ekTTK28uZwYqk1yUhS1tSpGj2Y3bMZjCSl+gV9T8FjBZWYFKI1kZ0HosADBc vBGhHn+nBUEVmEx6LGD/ppS9iJXoTUier415uq8qhHaakxGvOOTLpWilkybRhZCO7L+i 6JmkitJnxupjrDyv36lePR/rHKrGkE3bqRz9idCQp2uOJQh81ENKKSc39CnCxaKKBB9U JgaTSw5y24qqSL5PdgkEaTLYa2WPpRx1wqk1C7A6cO0WS2rXr/YAc89WHBPa09DvLb1/ 2TwJ5TPRVPPT1lZRX7bccyfjSpVByHAUsvCTUFHpijDNWM38PS2CTU4WmFrfiwr1ep/h 8wwg== 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; bh=DBeZgXITWAPj3uOUoS40uNlWFtDGkOH6zC3ep3UL/ro=; b=0yTVjKwkxd0xSJdo9sz3/JoYIQSBcS1AIByISkOFh96zDMwUwR0jgVSIU8Y6017PnI LPA/g2aNU8o0G/+lfd8Z6gFm5Kell3aPp8UpqNKmLYvWgsrwL0+hYsyS8DmhMbMv6QsI Ok0WB6+4mg/c2xdVvnTwzapfCbr6osWpJWYNlhSf0qPvmj7noN3ugUFJ25SZeEl4WS+h c0XcV2t924Lj4CVMh+xPqTM6UbiRFRTaQWkrg3HYRNxB9A3LzKNrI9uc4hKTxEati2lR rzjB1mUZ4BMKrBKhWPqIP0xA/YdjpHkCFMrj8SKaroCCocmnJg08dNVWE0gimmXCWiyt unlg== 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 v14si12883126pfc.76.2019.01.21.04.15.46; Mon, 21 Jan 2019 04:16:16 -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; 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 S1728327AbfAUMOk (ORCPT + 99 others); Mon, 21 Jan 2019 07:14:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:40994 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727971AbfAUMOk (ORCPT ); Mon, 21 Jan 2019 07:14:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id ECCFBAB87; Mon, 21 Jan 2019 12:14:38 +0000 (UTC) Date: Mon, 21 Jan 2019 13:14:38 +0100 (CET) From: Miroslav Benes To: Petr Mladek cc: Jiri Kosina , Josh Poimboeuf , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] livepatch: Handle failing allocation of shadow variables in the selftest In-Reply-To: <20190116161720.796-3-pmladek@suse.com> Message-ID: References: <20190116161720.796-1-pmladek@suse.com> <20190116161720.796-3-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 Hi, On Wed, 16 Jan 2019, Petr Mladek wrote: > Do not dereference pointers to the shadow variables when either > klp_shadow_alloc() or klp_shadow_get() fail. I may misunderstand the patch, so bear with me, please. Is this because of a possible null pointer dereference? If yes, shouldn't this say rather "when both klp_shadow_alloc() and klp_shadow_get() fail"? > There is no need to check the other locations explicitly. The test > would fail if any allocation fails. And the existing messages, printed > during the test, provide enough information to debug eventual problems. > > Signed-off-by: Petr Mladek > --- > lib/livepatch/test_klp_shadow_vars.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/livepatch/test_klp_shadow_vars.c b/lib/livepatch/test_klp_shadow_vars.c > index 02f892f941dc..55e6820430dc 100644 > --- a/lib/livepatch/test_klp_shadow_vars.c > +++ b/lib/livepatch/test_klp_shadow_vars.c > @@ -162,15 +162,15 @@ static int test_klp_shadow_vars_init(void) > * to expected data. > */ > ret = shadow_get(obj, id); > - if (ret == sv1 && *sv1 == &var1) > + if (ret && ret == sv1 && *sv1 == &var1) > pr_info(" got expected PTR%d -> PTR%d result\n", > ptr_id(sv1), ptr_id(*sv1)); > ret = shadow_get(obj + 1, id); > - if (ret == sv2 && *sv2 == &var2) > + if (ret && ret == sv2 && *sv2 == &var2) > pr_info(" got expected PTR%d -> PTR%d result\n", > ptr_id(sv2), ptr_id(*sv2)); > ret = shadow_get(obj, id + 1); > - if (ret == sv3 && *sv3 == &var3) > + if (ret && ret == sv3 && *sv3 == &var3) > pr_info(" got expected PTR%d -> PTR%d result\n", > ptr_id(sv3), ptr_id(*sv3)); There is one more similar site calling shadow_get(obj, id + 1) which is fixed. Thanks, Miroslav