1. 01 10月, 2021 1 次提交
    • J
      SUNRPC: fix sign error causing rpcsec_gss drops · 2ba5acfb
      J. Bruce Fields 提交于
      If sd_max is unsigned, then sd_max - GSS_SEQ_WIN is a very large number
      whenever sd_max is less than GSS_SEQ_WIN, and the comparison:
      
      	seq_num <= sd->sd_max - GSS_SEQ_WIN
      
      in gss_check_seq_num is pretty much always true, even when that's
      clearly not what was intended.
      
      This was causing pynfs to hang when using krb5, because pynfs uses zero
      as the initial gss sequence number.  That's perfectly legal, but this
      logic error causes knfsd to drop the rpc in that case.  Out-of-order
      sequence IDs in the first GSS_SEQ_WIN (128) calls will also cause this.
      
      Fixes: 10b9d99a ("SUNRPC: Augment server-side rpcgss tracepoints")
      Cc: stable@vger.kernel.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      2ba5acfb
  2. 04 9月, 2021 1 次提交
  3. 17 8月, 2021 1 次提交
  4. 11 8月, 2021 2 次提交
    • C
      SUNRPC: Set rq_auth_stat in the pg_authenticate() callout · 5c2465df
      Chuck Lever 提交于
      In a few moments, rq_auth_stat will need to be explicitly set to
      rpc_auth_ok before execution gets to the dispatcher.
      
      svc_authenticate() already sets it, but it often gets reset to
      rpc_autherr_badcred right after that call, even when authentication
      is successful. Let's ensure that the pg_authenticate callout and
      svc_set_client() set it properly in every case.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      5c2465df
    • C
      SUNRPC: Add svc_rqst::rq_auth_stat · 438623a0
      Chuck Lever 提交于
      I'd like to take commit 4532608d ("SUNRPC: Clean up generic
      dispatcher code") even further by using only private local SVC
      dispatchers for all kernel RPC services. This change would enable
      the removal of the logic that switches between
      svc_generic_dispatch() and a service's private dispatcher, and
      simplify the invocation of the service's pc_release method
      so that humans can visually verify that it is always invoked
      properly.
      
      All that will come later.
      
      First, let's provide a better way to return authentication errors
      from SVC dispatcher functions. Instead of overloading the dispatch
      method's *statp argument, add a field to struct svc_rqst that can
      hold an error value.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      438623a0
  5. 07 7月, 2021 1 次提交
  6. 22 6月, 2021 1 次提交
  7. 07 3月, 2021 1 次提交
  8. 21 10月, 2020 1 次提交
    • M
      SUNRPC: fix copying of multiple pages in gss_read_proxy_verf() · d48c8124
      Martijn de Gouw 提交于
      When the passed token is longer than 4032 bytes, the remaining part
      of the token must be copied from the rqstp->rq_arg.pages. But the
      copy must make sure it happens in a consecutive way.
      
      With the existing code, the first memcpy copies 'length' bytes from
      argv->iobase, but since the header is in front, this never fills the
      whole first page of in_token->pages.
      
      The mecpy in the loop copies the following bytes, but starts writing at
      the next page of in_token->pages.  This leaves the last bytes of page 0
      unwritten.
      
      Symptoms were that users with many groups were not able to access NFS
      exports, when using Active Directory as the KDC.
      Signed-off-by: NMartijn de Gouw <martijn.de.gouw@prodrive-technologies.com>
      Fixes: 5866efa8 "SUNRPC: Fix svcauth_gss_proxy_init()"
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      d48c8124
  9. 25 7月, 2020 1 次提交
  10. 14 7月, 2020 1 次提交
    • C
      SUNRPC: Augment server-side rpcgss tracepoints · 10b9d99a
      Chuck Lever 提交于
      Add similar tracepoints to those that were recently added on the
      client side to track failures in the integ and priv unwrap paths.
      
      And, let's collect the seqno-specific tracepoints together with a
      common naming convention.
      
      Regarding the gss_check_seq_num() changes: everywhere else treats
      the GSS sequence number as an unsigned 32-bit integer. As far back
      as 2.6.12, I couldn't find a compelling reason to do things
      differently here. As a defensive change it's better to eliminate
      needless implicit sign conversions.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      10b9d99a
  11. 29 5月, 2020 2 次提交
  12. 27 4月, 2020 2 次提交
    • C
      SUNRPC: Revert 241b1f41 ("SUNRPC: Remove xdr_buf_trim()") · 0a8e7b7d
      Chuck Lever 提交于
      I've noticed that when krb5i or krb5p security is in use,
      retransmitted requests are missing the server's duplicate reply
      cache. The computed checksum on the retransmitted request does not
      match the cached checksum, resulting in the server performing the
      retransmitted request again instead of returning the cached reply.
      
      The assumptions made when removing xdr_buf_trim() were not correct.
      In the send paths, the upper layer has already set the segment
      lengths correctly, and shorting the buffer's content is simply a
      matter of reducing buf->len.
      
      xdr_buf_trim() is the right answer in the receive/unwrap path on
      both the client and the server. The buffer segment lengths have to
      be shortened one-by-one.
      
      On the server side in particular, head.iov_len needs to be updated
      correctly to enable nfsd_cache_csum() to work correctly. The simple
      buf->len computation doesn't do that, and that results in
      checksumming stale data in the buffer.
      
      The problem isn't noticed until there's significant instability of
      the RPC transport. At that point, the reliability of retransmit
      detection on the server becomes crucial.
      
      Fixes: 241b1f41 ("SUNRPC: Remove xdr_buf_trim()")
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      0a8e7b7d
    • C
      SUNRPC: Add "@len" parameter to gss_unwrap() · 31c9590a
      Chuck Lever 提交于
      Refactor: This is a pre-requisite to fixing the client-side ralign
      computation in gss_unwrap_resp_priv().
      
      The length value is passed in explicitly rather that as the value
      of buf->len. This will subsequently allow gss_unwrap_kerberos_v1()
      to compute a slack and align value, instead of computing it in
      gss_unwrap_resp_priv().
      
      Fixes: 35e77d21 ("SUNRPC: Add rpc_auth::au_ralign field")
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      31c9590a
  13. 17 3月, 2020 3 次提交
  14. 08 2月, 2020 1 次提交
  15. 04 2月, 2020 1 次提交
  16. 15 1月, 2020 1 次提交
    • A
      sunrpc: convert to time64_t for expiry · 52879b46
      Arnd Bergmann 提交于
      Using signed 32-bit types for UTC time leads to the y2038 overflow,
      which is what happens in the sunrpc code at the moment.
      
      This changes the sunrpc code over to use time64_t where possible.
      The one exception is the gss_import_v{1,2}_context() function for
      kerberos5, which uses 32-bit timestamps in the protocol. Here,
      we can at least treat the numbers as 'unsigned', which extends the
      range from 2038 to 2106.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      52879b46
  17. 19 12月, 2019 2 次提交
    • A
      nfs: use time64_t internally · f559935e
      Arnd Bergmann 提交于
      The timestamps for the cache are all in boottime seconds, so they
      don't overflow 32-bit values, but the use of time_t is deprecated
      because it generally does overflow when used with wall-clock time.
      
      There are multiple possible ways of avoiding it:
      
      - leave time_t, which is safe here, but forces others to
        look into this code to determine that it is over and over.
      
      - use a more generic type, like 'int' or 'long', which is known
        to be sufficient here but loses the documentation of referring
        to timestamps
      
      - use ktime_t everywhere, and convert into seconds in the few
        places where we want realtime-seconds. The conversion is
        sometimes expensive, but not more so than the conversion we
        do today.
      
      - use time64_t to clarify that this code is safe. Nothing would
        change for 64-bit architectures, but it is slightly less
        efficient on 32-bit architectures.
      
      Without a clear winner of the three approaches above, this picks
      the last one, favouring readability over a small performance
      loss on 32-bit architectures.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      f559935e
    • A
      sunrpc: convert to time64_t for expiry · 294ec5b8
      Arnd Bergmann 提交于
      Using signed 32-bit types for UTC time leads to the y2038 overflow,
      which is what happens in the sunrpc code at the moment.
      
      This changes the sunrpc code over to use time64_t where possible.
      The one exception is the gss_import_v{1,2}_context() function for
      kerberos5, which uses 32-bit timestamps in the protocol. Here,
      we can at least treat the numbers as 'unsigned', which extends the
      range from 2038 to 2106.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      294ec5b8
  18. 31 10月, 2019 2 次提交
    • C
      SUNRPC: Fix svcauth_gss_proxy_init() · 5866efa8
      Chuck Lever 提交于
      gss_read_proxy_verf() assumes things about the XDR buffer containing
      the RPC Call that are not true for buffers generated by
      svc_rdma_recv().
      
      RDMA's buffers look more like what the upper layer generates for
      sending: head is a kmalloc'd buffer; it does not point to a page
      whose contents are contiguous with the first page in the buffers'
      page array. The result is that ACCEPT_SEC_CONTEXT via RPC/RDMA has
      stopped working on Linux NFS servers that use gssproxy.
      
      This does not affect clients that use only TCP to send their
      ACCEPT_SEC_CONTEXT operation (that's all Linux clients). Other
      clients, like Solaris NFS clients, send ACCEPT_SEC_CONTEXT on the
      same transport as they send all other NFS operations. Such clients
      can send ACCEPT_SEC_CONTEXT via RPC/RDMA.
      
      I thought I had found every direct reference in the server RPC code
      to the rqstp->rq_pages field.
      
      Bug found at the 2019 Westford NFS bake-a-thon.
      
      Fixes: 3316f063 ("svcrdma: Persistently allocate and DMA- ... ")
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Tested-by: NBill Baker <bill.baker@oracle.com>
      Reviewed-by: NSimo Sorce <simo@redhat.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      5866efa8
    • C
      SUNRPC: Trace gssproxy upcall results · ff27e9f7
      Chuck Lever 提交于
      Record results of a GSS proxy ACCEPT_SEC_CONTEXT upcall and the
      svc_authenticate() function to make field debugging of NFS server
      Kerberos issues easier.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Reviewed-by: NBill Baker <bill.baker@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      ff27e9f7
  19. 24 4月, 2019 1 次提交
  20. 14 2月, 2019 2 次提交
  21. 28 12月, 2018 1 次提交
  22. 30 10月, 2018 1 次提交
  23. 03 10月, 2018 1 次提交
  24. 01 8月, 2018 1 次提交
  25. 27 3月, 2018 1 次提交
  26. 15 12月, 2017 1 次提交
  27. 28 11月, 2017 1 次提交
  28. 08 11月, 2017 1 次提交
  29. 29 6月, 2017 1 次提交
    • C
      sunrpc: Disable splice for krb5i · 06eb8a56
      Chuck Lever 提交于
      Running a multi-threaded 8KB fio test (70/30 mix), three or four out
      of twelve of the jobs fail when using krb5i. The failure is an EIO
      on a read.
      
      Troubleshooting confirmed the EIO results when the client fails to
      verify the MIC of an NFS READ reply. Bruce suggested the problem
      could be due to the data payload changing between the time the
      reply's MIC was computed on the server and the time the reply was
      actually sent.
      
      krb5p gets around this problem by disabling RQ_SPLICE_OK. Use the
      same mechanism for krb5i RPCs.
      
      "iozone -i0 -i1 -s128m -y1k -az -I", export is tmpfs, mount is
      sec=krb5i,vers=3,proto=rdma. The important numbers are the
      read / reread column.
      
      Here's without the RQ_SPLICE_OK patch:
      
                    kB  reclen    write  rewrite    read    reread
                131072       1     7546     7929     8396     8267
                131072       2    14375    14600    15843    15639
                131072       4    19280    19248    21303    21410
                131072       8    32350    31772    35199    34883
                131072      16    36748    37477    49365    51706
                131072      32    55669    56059    57475    57389
                131072      64    74599    75190    74903    75550
                131072     128    99810   101446   102828   102724
                131072     256   122042   122612   124806   125026
                131072     512   137614   138004   141412   141267
                131072    1024   146601   148774   151356   151409
                131072    2048   180684   181727   293140   292840
                131072    4096   206907   207658   552964   549029
                131072    8192   223982   224360   454493   473469
                131072   16384   228927   228390   654734   632607
      
      And here's with it:
      
                    kB  reclen    write  rewrite    read    reread
                131072       1     7700     7365     7958     8011
                131072       2    13211    13303    14937    14414
                131072       4    19001    19265    20544    20657
                131072       8    30883    31097    34255    33566
                131072      16    36868    34908    51499    49944
                131072      32    56428    55535    58710    56952
                131072      64    73507    74676    75619    74378
                131072     128   100324   101442   103276   102736
                131072     256   122517   122995   124639   124150
                131072     512   137317   139007   140530   140830
                131072    1024   146807   148923   151246   151072
                131072    2048   179656   180732   292631   292034
                131072    4096   206216   208583   543355   541951
                131072    8192   223738   224273   494201   489372
                131072   16384   229313   229840   691719   668427
      
      I would say that there is not much difference in this test.
      
      For good measure, here's the same test with sec=krb5p:
      
                    kB  reclen    write  rewrite    read    reread
                131072       1     5982     5881     6137     6218
                131072       2    10216    10252    10850    10932
                131072       4    12236    12575    15375    15526
                131072       8    15461    15462    23821    22351
                131072      16    25677    25811    27529    27640
                131072      32    31903    32354    34063    33857
                131072      64    42989    43188    45635    45561
                131072     128    52848    53210    56144    56141
                131072     256    59123    59214    62691    62933
                131072     512    63140    63277    66887    67025
                131072    1024    65255    65299    69213    69140
                131072    2048    76454    76555   133767   133862
                131072    4096    84726    84883   251925   250702
                131072    8192    89491    89482   270821   276085
                131072   16384    91572    91597   361768   336868
      
      BugLink: https://bugzilla.linux-nfs.org/show_bug.cgi?id=307Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      06eb8a56
  30. 01 2月, 2017 1 次提交
  31. 13 1月, 2017 1 次提交
    • J
      svcrpc: don't leak contexts on PROC_DESTROY · 78794d18
      J. Bruce Fields 提交于
      Context expiry times are in units of seconds since boot, not unix time.
      
      The use of get_seconds() here therefore sets the expiry time decades in
      the future.  This prevents timely freeing of contexts destroyed by
      client RPC_GSS_PROC_DESTROY requests.  We'd still free them eventually
      (when the module is unloaded or the container shut down), but a lot of
      contexts could pile up before then.
      
      Cc: stable@vger.kernel.org
      Fixes: c5b29f88 "sunrpc: use seconds since boot in expiry cache"
      Reported-by: NAndy Adamson <andros@netapp.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      78794d18
  32. 01 12月, 2016 1 次提交
    • C
      svcauth_gss: Close connection when dropping an incoming message · 4d712ef1
      Chuck Lever 提交于
      S5.3.3.1 of RFC 2203 requires that an incoming GSS-wrapped message
      whose sequence number lies outside the current window is dropped.
      The rationale is:
      
        The reason for discarding requests silently is that the server
        is unable to determine if the duplicate or out of range request
        was due to a sequencing problem in the client, network, or the
        operating system, or due to some quirk in routing, or a replay
        attack by an intruder.  Discarding the request allows the client
        to recover after timing out, if indeed the duplication was
        unintentional or well intended.
      
      However, clients may rely on the server dropping the connection to
      indicate that a retransmit is needed. Without a connection reset, a
      client can wait forever without retransmitting, and the workload
      just stops dead. I've reproduced this behavior by running xfstests
      generic/323 on an NFSv4.0 mount with proto=rdma and sec=krb5i.
      
      To address this issue, have the server close the connection when it
      silently discards an incoming message due to a GSS sequence number
      problem.
      
      There are a few other places where the server will never reply.
      Change those spots in a similar fashion.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      4d712ef1