Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp642945pxu; Fri, 23 Oct 2020 09:38:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOQ4u52BAIt0IijfHXo2K3jffr6yedriFETbq4/XPuXFT6QcmwKfdf89kM9D/OHzgj4RIz X-Received: by 2002:a17:906:34ce:: with SMTP id h14mr2773654ejb.325.1603471102775; Fri, 23 Oct 2020 09:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603471102; cv=none; d=google.com; s=arc-20160816; b=axIWho8fBFdqgDnSCKfHNQruDMeacrkh+6jaFQlAZNRpm4/vld9L07qRa6NNjlujSq SFtJ4BgR8dxeA6otWtSSSOYGTHzCVHhkyvKNGcYbwRqoWCMRKYoWBJ2HS7vPtuzipLt2 4EK8a6+C1A3ne+KAx9YsWUrmJB+mhVGYabK9hfKdQ5uhayEnXuoeEc2sHeftyNW1uIHN +EiiULzSeaTtsFujEPBf1XQzX8NnJJk2Tl4BkBu0TwNPm/EDesnPbRIx2XT8fY3ZKDfB YPMXZ6MNJY9EFYijbBvxg5MB3ETfQ2qUWamOThOlzx9ZbClcPoJLT+g2iHRrxwf0Vxzr 19qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5/+Z2DTY0X3UNE1zOAnDc3GMvU3/neAbYyAwV9Uv1sQ=; b=sSX5pyeYZfzReIW/o6OkmxsqO8iDy/kP3nHx9sJN0MXRCtohds4uwBFQz4FVAbEC+s /UAWOFF3eCAbpOYH3kL51ZV9q2K+H/5/avM2DsCQYDyQBmu+f82+37s8M79i6vb9w4is Ha03SvNQAYSwpE3lXyXNuZUd6d5nBNqs3YOVkdO9ZU3yht4eUHitXwJvQTT5A+SzWGUA /MUn2uDH29TRj6EpRWur/0UkYLSl5xFFMqAoNrCJTpz8QYECNKdS8eEUfbUehmmutoA3 XYWjEqhMX98nbPzqJDrnh2/RfzHdHkZHnRTAoHN82HLFAjFRf4Uu2AkkQS1X1t0bOGCR 1/mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=bKJlp5Zi; 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 c15si1290007ejr.333.2020.10.23.09.37.59; Fri, 23 Oct 2020 09:38:22 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=bKJlp5Zi; 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 S1751816AbgJWQdg (ORCPT + 99 others); Fri, 23 Oct 2020 12:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbgJWQdP (ORCPT ); Fri, 23 Oct 2020 12:33:15 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96DEDC0613D2 for ; Fri, 23 Oct 2020 09:33:14 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id l2so2842896lfk.0 for ; Fri, 23 Oct 2020 09:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5/+Z2DTY0X3UNE1zOAnDc3GMvU3/neAbYyAwV9Uv1sQ=; b=bKJlp5Zi29qle5D9opf4NXlbOWJhqSLbkPTTzs3cyEfB6yY5yL2nVp+B2qxgDBuenW Ld6FBX1RcXCS8NhhbFgQYSvjxx2DmHG9Bt0hUX7JvJOKxhXXzfzBAxggPWaZ91DMIf/e dpBAABcXoHgqg2SosGBxhJHT4bBdoCmPY82fA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5/+Z2DTY0X3UNE1zOAnDc3GMvU3/neAbYyAwV9Uv1sQ=; b=Z/B3MtriFKmv0eqNLr/Fv5mDCbjKk2EGYv5I1t1ssOb6lU/qm/fb+Yvh0QBeHn5E1R R/tQWGIJdN0t0u4yN0e9gf1subWUpgm9FFZuh+senxr8ESeaEUMit2oGQNp2sYDLUGH4 2MRcFG1q5M6MONlu8Yaj9mGTAElrOncdolgNHVc2FhqSUr9DhsrdpVrZ5NbNYPPssIDF /j7YWS5l8atfheNe80RNlQLTJB6nH8ImTcmdJnhdQEI401i/5birYTEWsKm1QKNdoe9h iD5nQpcqSfcmZwK2jEY05wLmU/NB6jfuwl8pz+q/ax9KQgfnMbZ1coePk88rW6cYK2HZ bc9Q== X-Gm-Message-State: AOAM533YFW/LnB2Fv21QxRJLFeJ5sXr58m1pNjC0t4OoIWe2YqZpFfsa UdAeTZpf4Bi5B677O9/iL3HtPjfD6bBjyQ== X-Received: by 2002:a19:4006:: with SMTP id n6mr1021350lfa.28.1603470792719; Fri, 23 Oct 2020 09:33:12 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id q20sm182872lfp.43.2020.10.23.09.33.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 09:33:11 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id z2so2840622lfr.1 for ; Fri, 23 Oct 2020 09:33:11 -0700 (PDT) X-Received: by 2002:a19:c703:: with SMTP id x3mr971141lff.105.1603470790607; Fri, 23 Oct 2020 09:33:10 -0700 (PDT) MIME-Version: 1.0 References: <20201023050214.GG23681@linux.intel.com> <356811ab-cb08-7685-ca01-fe58b5654953@rasmusvillemoes.dk> In-Reply-To: From: Linus Torvalds Date: Fri, 23 Oct 2020 09:32:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [LTP] mmstress[1309]: segfault at 7f3d71a36ee8 ip 00007f3d77132bdf sp 00007f3d71a36ee8 error 4 in libc-2.27.so[7f3d77058000+1aa000] To: Rasmus Villemoes Cc: Sean Christopherson , =?UTF-8?B?RGFuaWVsIETDrWF6?= , Naresh Kamboju , Stephen Rothwell , "Matthew Wilcox (Oracle)" , zenglg.jy@cn.fujitsu.com, "Peter Zijlstra (Intel)" , Viresh Kumar , X86 ML , open list , lkft-triage@lists.linaro.org, "Eric W. Biederman" , linux-mm , linux-m68k , Linux-Next Mailing List , Thomas Gleixner , kasan-dev , Dmitry Vyukov , Geert Uytterhoeven , Christian Brauner , Ingo Molnar , LTP List , Al Viro Content-Type: multipart/mixed; boundary="000000000000e2112705b259227d" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000e2112705b259227d Content-Type: text/plain; charset="UTF-8" On Fri, Oct 23, 2020 at 8:54 AM Linus Torvalds wrote: > > On Fri, Oct 23, 2020 at 12:14 AM Rasmus Villemoes > wrote: > > > > That's certainly garbage. Now, I don't know if it's a sufficient fix (or > > could break something else), but the obvious first step of rearranging > > so that the ptr argument is evaluated before the assignment to __val_pu > > Ack. We could do that. > > I'm more inclined to just bite the bullet and go back to the ugly > conditional on the size that I had hoped to avoid, but if that turns > out too ugly, mind signing off on your patch and I'll have that as a > fallback? Actually, looking at that code, and the fact that we've used the "register asm()" format forever for the get_user() side, I think your approach is the right one. I'd rename the internal ptr variable to "__ptr_pu", and make sure the assignments happen just before the asm call (with the __val_pu assignment being the final thing). lso, it needs to be void __user *__ptr_pu; instead of __typeof__(ptr) __ptr = (ptr); because "ptr" may actually be an array, and we need to have the usual C "array to pointer" conversions happen, rather than try to make __ptr_pu be an array too. So the patch would become something like the appended instead, but I'd still like your sign-off (and I'd put you as author of the fix). Narest, can you confirm that this patch fixes the issue for you? Linus --000000000000e2112705b259227d Content-Type: application/octet-stream; name=patch Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kgmh3alt0 IGFyY2gveDg2L2luY2x1ZGUvYXNtL3VhY2Nlc3MuaCB8IDQgKysrLQogMSBmaWxlIGNoYW5nZWQs IDMgaW5zZXJ0aW9ucygrKSwgMSBkZWxldGlvbigtKQoKZGlmZiAtLWdpdCBhL2FyY2gveDg2L2lu Y2x1ZGUvYXNtL3VhY2Nlc3MuaCBiL2FyY2gveDg2L2luY2x1ZGUvYXNtL3VhY2Nlc3MuaAppbmRl eCBmMTM2NTk1MjMxMDguLmQwMDZhZjkxNWQ0YSAxMDA2NDQKLS0tIGEvYXJjaC94ODYvaW5jbHVk ZS9hc20vdWFjY2Vzcy5oCisrKyBiL2FyY2gveDg2L2luY2x1ZGUvYXNtL3VhY2Nlc3MuaApAQCAt MjExLDEzICsyMTEsMTUgQEAgZXh0ZXJuIHZvaWQgX19wdXRfdXNlcl9ub2NoZWNrXzgodm9pZCk7 CiAjZGVmaW5lIGRvX3B1dF91c2VyX2NhbGwoZm4seCxwdHIpCQkJCQlcCiAoewkJCQkJCQkJCVwK IAlpbnQgX19yZXRfcHU7CQkJCQkJCVwKKwl2b2lkIF9fdXNlciAqX19wdHJfcHU7CQkJCQkJXAog CXJlZ2lzdGVyIF9fdHlwZW9mX18oKihwdHIpKSBfX3ZhbF9wdSBhc20oIiUiX0FTTV9BWCk7CQlc CiAJX19jaGtfdXNlcl9wdHIocHRyKTsJCQkJCQlcCisJX19wdHJfcHUgPSAocHRyKTsJCQkJCQlc CiAJX192YWxfcHUgPSAoeCk7CQkJCQkJCVwKIAlhc20gdm9sYXRpbGUoImNhbGwgX18iICNmbiAi XyVQW3NpemVdIgkJCQlcCiAJCSAgICAgOiAiPWMiIChfX3JldF9wdSksCQkJCQlcCiAJCQlBU01f Q0FMTF9DT05TVFJBSU5UCQkJCVwKLQkJICAgICA6ICIwIiAocHRyKSwJCQkJCVwKKwkJICAgICA6 ICIwIiAoX19wdHJfcHUpLAkJCQkJXAogCQkgICAgICAgInIiIChfX3ZhbF9wdSksCQkJCQlcCiAJ CSAgICAgICBbc2l6ZV0gImkiIChzaXplb2YoKihwdHIpKSkJCQlcCiAJCSAgICAgOiJlYngiKTsJ CQkJCQlcCg== --000000000000e2112705b259227d--