From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC4F2C4363A for ; Fri, 23 Oct 2020 16:41:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 13903206B5 for ; Fri, 23 Oct 2020 16:41:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="bKJlp5Zi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13903206B5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 688F66B0070; Fri, 23 Oct 2020 12:41:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65E8D6B0071; Fri, 23 Oct 2020 12:41:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 573986B0072; Fri, 23 Oct 2020 12:41:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2A9166B0070 for ; Fri, 23 Oct 2020 12:41:35 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B99B13624 for ; Fri, 23 Oct 2020 16:41:34 +0000 (UTC) X-FDA: 77403756108.24.swim13_1208e422725b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 965671A4A0 for ; Fri, 23 Oct 2020 16:41:34 +0000 (UTC) X-HE-Tag: swim13_1208e422725b X-Filterd-Recvd-Size: 7872 Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Fri, 23 Oct 2020 16:41:34 +0000 (UTC) Received: by mail-ej1-f68.google.com with SMTP id gs25so3277511ejb.1 for ; Fri, 23 Oct 2020 09:41:33 -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=GFuMF4hrteSM12D2CmxnW7tG93CoTxRdhVW0rCaBuIWUHL/JJi+ijj44vcHMN9OQ1y BVqyu+m2tzaqbI+TXLaMr5M0F0roV//KoBs5Llc9K765GTLlNyT/um4sSn9/2i7cV9vR HNOkFhQKmHRJZa7LPbAHaiL/HSN6yaaG1/G5rEUlHibLDCIlIMv+UoD+/ojQDC5EOpDT zq/cWYehwQ34+qDcN871I5eMdqMMg0Iq5Uk7r11xJw13P6CEb3YvfvOY7wI/p+gK0UWn MZdDP2DcUksIDCMOjjq4W+Dqj6wDJeG0KmuvYJqohY5fg9H17nl1VbP5Aa5XlN/m3M+C /gFw== X-Gm-Message-State: AOAM5337mlQs+8dtNYjqvVALfOBBW1J5i74Wjm7shEuQ5rLnw4nsn4R7 PpUw4x+3E1hR8DRkSJFQokzV4+O7k2X6hA== X-Google-Smtp-Source: ABdhPJw0Xryq5MBQzxFBZD4RQ6kciSPek/vYQIoBSytf/nNr0f/GZl1IBXFLDl4/3jMjmazmjZGEMw== X-Received: by 2002:a17:906:934d:: with SMTP id p13mr3017750ejw.532.1603471292456; Fri, 23 Oct 2020 09:41:32 -0700 (PDT) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com. [209.85.221.52]) by smtp.gmail.com with ESMTPSA id u26sm1019660edt.39.2020.10.23.09.41.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 09:41:32 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id b8so2754398wrn.0 for ; Fri, 23 Oct 2020 09:41:31 -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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --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 IDMgaW5zZXJ0aW9ucygrK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