Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753027AbbKIEU4 (ORCPT ); Sun, 8 Nov 2015 23:20:56 -0500 Received: from mail-oi0-f50.google.com ([209.85.218.50]:36196 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752609AbbKIEUv (ORCPT ); Sun, 8 Nov 2015 23:20:51 -0500 MIME-Version: 1.0 In-Reply-To: <20151107111824.GA6137@pd.tnic> References: <20151107111824.GA6137@pd.tnic> From: Andy Lutomirski Date: Sun, 8 Nov 2015 20:20:31 -0800 Message-ID: Subject: Re: [PATCH 1/4] x86/entry/64: Fix irqflag tracing wrt context tracking To: Borislav Petkov Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , Brian Gerst , Linus Torvalds , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Peter Zijlstra Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1475 Lines: 35 On Sat, Nov 7, 2015 at 3:18 AM, Borislav Petkov wrote: > On Fri, Nov 06, 2015 at 03:12:43PM -0800, Andy Lutomirski wrote: >> Paolo pointed out that enter_from_user_mode could be called while >> irqflags were traced as though IRQs were on. >> >> In principle, this could confuse lockdep. It doesn't cause any >> problems that I've seen in any configuration, but if I build with >> CONFIG_DEBUG_LOCKDEP=y, enable a nohz_full CPU, and add code like: >> >> if (irqs_disabled()) { >> spin_lock(&something); >> spin_unlock(&something); >> } >> >> to the top of enter_from_user_mode, then lockdep will complain >> without this fix. It seems that lockdep's irqflags sanity checks >> are too weak to detect this bug without forcing the issue. >> >> This patch adds one byte to normal kernels, and it's IMO a bit ugly. >> I haven't spotted a better way to do this yet, though. The issue is >> that we can't do TRACE_IRQS_OFF until after SWAPGS (if needed), but >> we're also supposed to do it before calling C code. > > I would not mind to have that explanation in the code itself so that > people don't scratch heads why the duplicated TRACE_IRQS_OFF call. > Done for v2. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/