Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp428967pxa; Fri, 14 Aug 2020 08:01:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyVrTk/rPi9pfS0dscFDAYcvvKC4IxP/IDHE09Qmd+kCLyY85o4G80SA5+qCyCPqiK++CQ X-Received: by 2002:a17:906:69d5:: with SMTP id g21mr2673623ejs.461.1597417288015; Fri, 14 Aug 2020 08:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597417288; cv=none; d=google.com; s=arc-20160816; b=VDlT8Ll8hlyGKZwuxiN9ZXi9iovt6tt9mEJ5H2fop/njmKUr+EAnLQR2PIvxqq8Oys M1wZ7/RIh+wUvPdgdBAil9klxPE3s4tOjp2a8b8BNZmq2F3fsPWhle8KjI9o2WG5+UzG GDz16sFyX109uBBh9hbKZUxy4bYkvpqrYh2OuAXF4tl53PbDNINXcHVDl0i9zvxGpUha 2/ZFnelnuvbee/OdMHRACaQsOkj8+ogZTSx/rvrOtzKq7mW8tm/sQooyPf1a8B5E6T9U 8yBUj15+Khn24kh6wv3dcph4mGHlxeq8RpfJNA2xDzAzufkTczYg1PCV0YuIiJbZyvg5 QoiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9d9Pfue6SLYLrl7Jq1LY1TguVBp8VoVfG2HXeD9OE1g=; b=NEdWYj3gBuWBIwkgmc40GRo07Tz8FFmxl9Ukr7luApOCObTyzJ5w6U8UnQlxw1DZdb BptTmFOyBAG6vkdoQXLUnpPVPwZxgmhkgk4WV+xpDclU1oK3FkRY+3V+3miyzyTEHNZp tDsaDInnU0dxprjIqEXW/CHl4fgPG9WmgBMab0qPf+0AMznVtRpvlx5NfnX+/gx1sKbn 3dWXtLrtgOYn83s/TuhfLwik4lGIkPiz7DzWIZ+dC62WdSiNc63rI6VzBf8SS+VzUf+Z cdJGpM3p44neJH43b21KYa0GPGnKfDSC6e1d/VRIifXtaRXyKV7Kii8At49gflrwmr9t AihA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si5201994eji.444.2020.08.14.08.01.04; Fri, 14 Aug 2020 08:01:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728519AbgHNO6B (ORCPT + 99 others); Fri, 14 Aug 2020 10:58:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:46920 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbgHNO6B (ORCPT ); Fri, 14 Aug 2020 10:58:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6D61DAED8; Fri, 14 Aug 2020 14:58:23 +0000 (UTC) Date: Fri, 14 Aug 2020 16:58:23 +0200 From: Cyril Hrubis To: Andy Lutomirski Cc: Peter Zijlstra , Alexandre Chartre , kernel test robot , LKML , lkp@lists.01.org, Thomas Gleixner , ltp@lists.linux.it Subject: Re: [LTP] [x86/entry] 2bbc68f837: ltp.ptrace08.fail Message-ID: <20200814145823.GA13646@yuki.lan> References: <87y2onbdtb.fsf@nanos.tec.linutronix.de> <8E41B15F-D567-4C52-94E9-367015480345@amacapital.net> <20200616132705.GW2531@hirez.programming.kicks-ass.net> <20200617131742.GD8389@yuki.lan> <20200812093114.GA13676@yuki.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200812093114.GA13676@yuki.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! > > do_debug is a bit of a red herring here. ptrace should not be able to > > put a breakpoint on a kernel address, period. I would just pick a > > fixed address that's in the kernel text range or even just in the > > pre-KASLR text range and make sure it gets rejected. Maybe try a few > > different addresses for good measure. > > I've looked at the code and it seems like this would be a bit more > complicated since the breakpoint is set by an accident in a race and the > call still fails. Which is why the test triggers the breakpoint and > causes infinite loop in the kernel... > > I guess that we could instead read back the address with > PTRACE_PEEKUSER, so something as: > > > break_addr = ptrace(PTRACE_PEEKUSER, child_pid, > (void *)offsetof(struct user, u_debugreg[0]), > NULL); > > if (break_addr == kernel_addr) > tst_res(TFAIL, "ptrace() set break on a kernel address"); So this works actually nicely, even better than the original code. Any hints on how to select a fixed address in the kernel range as you pointed out in one of the previous emails? I guess that this would end up as a per-architecture mess of ifdefs if we wanted to hardcode it. -- Cyril Hrubis chrubis@suse.cz